diff --git a/2022/rust/Cargo.toml b/2022/rust/Cargo.toml index 13d5820..1d7b199 100644 --- a/2022/rust/Cargo.toml +++ b/2022/rust/Cargo.toml @@ -22,4 +22,12 @@ path = "src/day3.rs" name = "day4" path = "src/day4.rs" +[[bin]] +name = "day4-alt1" +path = "src/day4-alt1.rs" + +[[bin]] +name = "day5" +path = "src/day5.rs" + [dependencies] diff --git a/2022/rust/src/common.rs b/2022/rust/src/common.rs index d5bb362..1db9c23 100644 --- a/2022/rust/src/common.rs +++ b/2022/rust/src/common.rs @@ -11,10 +11,13 @@ pub fn day_input(day: u8) -> String { fs::read_to_string(file_path).unwrap() } +#[allow(dead_code)] pub fn show_answers(answer1: &impl Debug, answer2: &impl Debug) { println!("Part 1: {:?}", answer1); println!("Part 2: {:?}", answer2); } + +#[allow(dead_code)] pub fn show_both_answers((a, b): &(impl Debug, impl Debug)) { show_answers(a, b) } diff --git a/2022/rust/src/day5.rs b/2022/rust/src/day5.rs index 4382952..928da8b 100644 --- a/2022/rust/src/day5.rs +++ b/2022/rust/src/day5.rs @@ -1,18 +1,29 @@ mod common; +type Input = String; +type Result = usize; + +fn processed_input(input: &str) -> Input { + input.to_owned() +} + +fn part1(input: &Input) -> Result { + 0 +} + +fn part2(input: &Input) -> Result { + 0 +} + fn main() { - let input = common::day_input(5); - println!("Part 1: {}", part1(&input)); - println!("Part 2: {}", part2(&input)); + let input = processed_input(&common::day_input(5)); + common::show_answers(&part1(&input), &part2(&input)) + // common::show_both_answers(&both_parts(&input)) } -fn part1(input: &str) -> i32 { - 0 -} - -fn part2(input: &str) -> i32 { - 0 -} +// fn both_parts(input: &Input) -> (Result, Result) { +// (0, 0) +// } #[cfg(test)] mod tests { @@ -21,12 +32,9 @@ mod tests { const TEST_INPUT: &str = ""; #[test] - fn test_part1() { - assert_eq!(part1(TEST_INPUT), 0) - } - - #[test] - fn test_part2() { - assert_eq!(part2(TEST_INPUT), 0) + fn test() { + let input = processed_input(TEST_INPUT); + assert_eq!(part1(&input), 0); + assert_eq!(part2(&input), 0); } } diff --git a/2022/rust/src/scaffold.rs b/2022/rust/src/scaffold.rs index e031169..5143914 100644 --- a/2022/rust/src/scaffold.rs +++ b/2022/rust/src/scaffold.rs @@ -1,20 +1,31 @@ mod common; -type Input = &str; +type Input = String; +type Result = usize; + +fn processed_input(input: &str) -> Input { + input.to_owned() +} + +fn part1(input: &Input) -> Result { + 0 +} + +fn part2(input: &Input) -> Result { + 0 +} fn main() { - let input = common::day_input(panic!("PUT THE CORRECT DAY NUMBER HERE")); - println!("Part 1: {}", part1(&input)); - println!("Part 2: {}", part2(&input)); + let input = processed_input(&common::day_input(panic!( + "PUT THE CORRECT DAY NUMBER HERE AND ADD bin TO Cargo.toml" + ))); + common::show_answers(&part1(&input), &part2(&input)) + // common::show_both_answers(&both_parts(&input)) } -fn part1(input: &str) -> i32 { - 0 -} - -fn part2(input: &str) -> i32 { - 0 -} +// fn both_parts(input: &Input) -> (Result, Result) { +// (0, 0) +// } #[cfg(test)] mod tests { @@ -23,12 +34,9 @@ mod tests { const TEST_INPUT: &str = ""; #[test] - fn test_part1() { - assert_eq!(part1(TEST_INPUT), 0) - } - - #[test] - fn test_part2() { - assert_eq!(part2(TEST_INPUT), 0) + fn test() { + let input = processed_input(TEST_INPUT); + assert_eq!(part1(&input), 0); + assert_eq!(part2(&input), 0); } }