diff --git a/src/bin/25.rs b/src/bin/25.rs new file mode 100644 index 000000000..1284031 --- /dev/null +++ b/src/bin/25.rs @@ -0,0 +1,40 @@ +const ONE: u64 = 20151125; +pub fn part_one(input: &str) -> Option { + let l = input.len(); + let (row, column): (u32, u32) = input[80..l - 1] + .split_once(", column ") + .map(|(x, y)| (x.parse().unwrap(), y.parse().unwrap())) + .unwrap(); + + let n = (row + column) * (row + column - 1) / 2 - row + 1; + let mut c = 1; + let mut code = ONE; + while c < n { + code = (code * 252533) % 33554393; + c += 1; + } + + Some(code) +} +pub fn part_two(input: &str) -> Option { + None +} +fn main() { + let input = &aoc::read_file("inputs", 25); + aoc::solve!(1, part_one, input); + aoc::solve!(2, part_two, input); +} +#[cfg(test)] +mod tests { + use super::*; + #[test] + fn test_part_one() { + let input = aoc::read_file("test_inputs", 25); + assert_eq!(part_one(&input.trim()), Some(7726640)); + } + #[test] + fn test_part_two() { + let input = aoc::read_file("test_inputs", 25); + assert_eq!(part_two(&input.trim()), None); + } +} diff --git a/src/test_inputs/25.txt b/src/test_inputs/25.txt new file mode 100644 index 000000000..28e3e1b --- /dev/null +++ b/src/test_inputs/25.txt @@ -0,0 +1 @@ +To continue, please consult the code grid in the manual. Enter the code at row 2, column 4.