--- /dev/null
+fn input() -> &'static str {
+ include_str!("../input/day11.txt")
+}
+
+fn parse(input: &str) -> Vec<u64> {
+ input
+ .split_whitespace()
+ .map(|s| s.parse().unwrap())
+ .collect()
+}
+
+fn iterate(stones: &[u64]) -> Vec<u64> {
+ stones
+ .iter()
+ .flat_map(|n| {
+ if *n == 0 {
+ vec![1]
+ } else {
+ let s = format!("{}", n);
+ let l = s.len();
+ if l % 2 == 0 {
+ vec![s[0..l / 2].parse().unwrap(), s[l / 2..l].parse().unwrap()]
+ } else {
+ vec![n * 2024]
+ }
+ }
+ })
+ .collect()
+}
+
+pub fn part1() {
+ let n = std::iter::successors(Some(parse(input())), |v| Some(iterate(v)))
+ .take(26)
+ .last()
+ .unwrap()
+ .len();
+ println!("Day 11 Part 1: {}", n);
+}
+
+pub fn part2() {
+ // lol no
+ let n = std::iter::successors(Some(parse(input())), |v| Some(iterate(v)))
+ .take(76)
+ .last()
+ .unwrap()
+ .len();
+ println!("Day 11 Part 2: {}", n);
+}
+
+#[cfg(test)]
+mod test {
+ use super::*;
+
+ const INPUT_STR: &str = concat!("0 1 10 99 999\n");
+
+ #[test]
+ fn test_parse() {
+ assert_eq!(parse(INPUT_STR), [0, 1, 10, 99, 999])
+ }
+
+ #[test]
+ fn test_iterate() {
+ assert_eq!(iterate(&parse(INPUT_STR)), [1, 2024, 1, 0, 9, 9, 2021976]);
+ assert_eq!(
+ std::iter::successors(Some(parse("125 17")), |v| Some(iterate(v)))
+ .take(7)
+ .collect::<Vec<_>>(),
+ [
+ vec![125, 17],
+ vec![253000, 1, 7],
+ vec![253, 0, 2024, 14168],
+ vec![512072, 1, 20, 24, 28676032],
+ vec![512, 72, 2024, 2, 0, 2, 4, 2867, 6032],
+ vec![1036288, 7, 2, 20, 24, 4048, 1, 4048, 8096, 28, 67, 60, 32],
+ vec![
+ 2097446912, 14168, 4048, 2, 0, 2, 4, 40, 48, 2024, 40, 48, 80, 96, 2, 8, 6, 7,
+ 6, 0, 3, 2
+ ]
+ ]
+ )
+ }
+}
pub mod day08;
pub mod day09;
pub mod day10;
-// pub mod day11;
+pub mod day11;
// pub mod day12;
// pub mod day13;
// pub mod day14;
(day08::part1 as fn(), day08::part2 as fn()),
(day09::part1 as fn(), day09::part2 as fn()),
(day10::part1 as fn(), day10::part2 as fn()),
- // (day11::part1 as fn(), day11::part2 as fn()),
+ (day11::part1 as fn(), day11::part2 as fn()),
// (day12::part1 as fn(), day12::part2 as fn()),
// (day13::part1 as fn(), day13::part2 as fn()),
// (day14::part1 as fn(), day14::part2 as fn()),