From 7a2db9ae562130ef370afe8bd745e7192b5f76b2 Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Mon, 5 Dec 2022 23:24:46 -0600 Subject: [PATCH] Cleanup --- 2022/rust/src/day6.rs | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/2022/rust/src/day6.rs b/2022/rust/src/day6.rs index 705f125..59dcb32 100644 --- a/2022/rust/src/day6.rs +++ b/2022/rust/src/day6.rs @@ -2,13 +2,9 @@ mod common; use std::collections::HashSet; -type Input = String; +type Input = str; type Result = usize; -fn processed_input(input: &str) -> Input { - input.to_owned() -} - fn part1(input: &Input) -> Result { let c: Vec = input.chars().collect(); for i in 3.. { @@ -28,8 +24,6 @@ fn part1(input: &Input) -> Result { fn part2(input: &Input) -> Result { let c: Vec = input.chars().collect(); - println!("{} {}", 88, c.len()); - for i in 13..c.len() { let mut s: HashSet = HashSet::new(); for j in i - 13..=i { @@ -45,16 +39,9 @@ fn part2(input: &Input) -> Result { fn main() { let input_text = common::day_input(6); - let input = processed_input(&input_text); - let input2 = processed_input(&input_text); - common::show_answers(&part1(&input), &part2(&input2)) - // common::show_both_answers(&both_parts(&input)) + common::show_answers(&part1(&input_text), &part2(&input_text)) } -// fn both_parts(input: &Input) -> (Result, Result) { -// (0, 0) -// } - #[cfg(test)] mod tests { use super::*; @@ -63,10 +50,8 @@ mod tests { #[test] fn test() { - // let input = processed_input(TEST_INPUT); - // assert_eq!(part1(&input), 7); - let input = processed_input(TEST_INPUT); - assert_eq!(part2(&input), 19); - // assert_eq!(both_parts(&input), (0, 0)); + let input = TEST_INPUT; + assert_eq!(part1(input), 7); + assert_eq!(part2(input), 19); } }