From f23a95e2e2a8780a557cc53d1753955c02b8353e Mon Sep 17 00:00:00 2001 From: kageru Date: Wed, 13 Dec 2023 09:30:03 +0100 Subject: [PATCH] add 2023/13/1 --- 2023/inputs/day13 | 1339 +++++++++++++++++++++++++++++++++++++++++ 2023/src/bin/day01.rs | 20 +- 2023/src/bin/day02.rs | 4 +- 2023/src/bin/day03.rs | 4 +- 2023/src/bin/day04.rs | 4 +- 2023/src/bin/day05.rs | 4 +- 2023/src/bin/day06.rs | 4 +- 2023/src/bin/day07.rs | 4 +- 2023/src/bin/day08.rs | 22 +- 2023/src/bin/day09.rs | 4 +- 2023/src/bin/day10.rs | 4 +- 2023/src/bin/day11.rs | 4 +- 2023/src/bin/day12.rs | 4 +- 2023/src/bin/day13.rs | 71 +++ 2023/src/teststuff.rs | 8 +- 15 files changed, 1456 insertions(+), 44 deletions(-) create mode 100644 2023/inputs/day13 create mode 100644 2023/src/bin/day13.rs diff --git a/2023/inputs/day13 b/2023/inputs/day13 new file mode 100644 index 0000000..b3ff455 --- /dev/null +++ b/2023/inputs/day13 @@ -0,0 +1,1339 @@ +#..#..##.#. +#..#..##.#. +......#..## +##########. +..####.#.## +#.#.##....# +..#.##....# +..####.#.## +##########. +......#..## +#..#..##.#. + +#..#####.##.#.#.. +####..#.#....#### +..##.......##.#.# +#..######.#.##### +#..######.#.##### +..##.......##.#.# +####..#.#....#### +#..#####.##.#.#.. +#..#...###..#..#. +#..#.###.#..#...# +###.##..#.####.#. +.##.###.##...#.## +##.###.#..###..## +#..###.#..###..## +.##.###.##...#.## +###.##..#.####.#. +#..#.###.#..#...# + +##.##.# +..#...# +###.##. +###.##. +..#...# +##.##.# +..#..#. +##.#.## +.####.# + +#..#...#..#.. +####.##....## +.##.####.#### +......######. +.##..#......# +.##.##..##..# +#..###.#..#.# +.....#......# +#####..#..#.. +.##..#.#..#.# +#..##..#..#.. +#..#..##..##. +#####..#..#.. + +.##.....##... +.##.....##.#. +.#.###...###. +#..##.#.##### +#####.##..... +#####.##..... +#..##.#.##### +.#.###...###. +.##.....##.#. + +#.#..#### +.##..#..# +.##..#..# +#.#..#### +###...... +#.#.#.### +..##.##.# +.#.#.##.. +.#.#.##.. +..##.##.# +#.#.#.#.# + +####..##..# +..##..#.##. +#####...##. +#..##.#.#.. +####..##### +.####..#### +#.#.##.#..# +####...#### +##.#.#..... +......#.... +##...###..# +..#.#..#..# +..#.#..#..# +##...###..# +......#.... + +.....#. +#..#..# +..#.#.# +####... +#..#... +.##..#. +#..###. +.##.... +.##.... + +...######..##..## +.#...#....####... +###..#..##....##. +#.....#.###..###. +#.....#.###..###. +###..#..##....##. +.#.#.#....####... +...######..##..## +.##..#.....##.... +####.#.########## +...####.#.#..#.#. +.##.#.#..#....#.. +.###.#.....##.... +..#...#.##....##. +.##...#..##..##.. + +.#..#.#.. +.......## +######.#. +#.##.###. +#....#.## +#....###. +######.#. +.####.... +.####.#.. +######.#. +#....###. + +.####....####.#.# +.#..#.##.#..#.### +#.##.#..#.##.#..# +..##......##..### +##.########.###.. +.####....####.#.# +#....#..#....#.## +................# +#....####....##.# +#....####....#..# +..............#.# +..##..##..##..... +......##.......#. + +.#..#.. +.#..#.. +##..... +..#.#.# +##.##.. +.###.## +...##.# +#.#.### +#.#.### +#..##.# +.###.## +##.##.. +..#.#.# +##..... +.#..#.. + +..#....#..# +##.##..#..# +###...##..# +.....#..##. +##...#..##. +##.####.... +#####...... +##.###.#..# +##......... +..###.##.## +###.#.#.... +###...##### +..##.#..... + +..####### +.#####... +###..##.. +#..##.#.. +.##...... +#..##.#.# +###.###.. +.#.#.#... +.#.#.#... +###.###.. +#..##.#.# +.##...... +#..##.#.. +###..##.. +.#####... +..####### +.######## + +######.##..#.## +#####.###.#..#. +..#.######.##.# +.#.#.##...##... +###..##.##....# +###..##...##... +..#....#..#.... +##..##.#.#..##. +##..##.#.#..##. +..#....#..#.... +###..##...##... + +###.#.##..#.##.## +###.#.##..#.##.## +.##..##.####.###. +##...##.##.....## +..#.##......#.#.. +.#####..#.###..## +.#..##..#.#..#.## +.##.#.#....#..##. +.###.#.#.###..### +#.#.#.###.#.#.##. +#.#.#.###.#.#.#.. + +#..#.########.# +.#.#####....... +#...#...#.#.... +.####....##..#. +.###.....##..#. +#...#...#.#.... +.#.#####....... +#..#.########.# +#..#.########.# + +#.#....#### +...#####..# +..######### +.#.#.#.#..# +......#.##. +.##.##..##. +###.##..##. + +##..##...###.#. +##..##...###.#. +....#####.##.#. +##.#####...#.## +#..#..#.#.##### +..#...#.#.##### +##.#..#.....### +#..#...######## +.#..##..#####.# +##..#....#.#... +##..#....#.#..# + +.########.##..#.. +.###..###.####... +.########..##.#.. +.###..###.#.#..## +####..####....... +..#.##.#...####.. +###....###....#.. +##.#..#.####...## +.#......#...#..## +.###..###.#.###.. +##.#.##.##.####.. +...#..#....#..#.. +.#......#.#.##.## + +#.#...##. +#.#...##. +##..###.# +.###.#.#. +##....### +#.....#.. +.######.. +###.##.#. +##....### +.##.####. +.......## +.......## +.##.####. +##....### +###..#.#. +.######.. +#.....#.. + +..##.#.#.##..#.#. +##.#.#.#.....#.#. +#..####.#.###..#. +.#.#.#...##.##### +.#.#.#..###.##### +#..####.#.###..#. +##.#.#.#.....#.#. +..##.#.#.##..#.#. +##.#.##.########. +....#.#..#....#.. +....#.#..#....#.. + +#..##..#.##.# +.#....#.####. +###..####..## +.#....##....# +.........##.. +..####...##.. +..#..#..#..#. +...##....##.. +#......#....# +...##........ +...##....##.. + +.#.....#..#..## +#..##..####..## +##.##.#...##.## +.##.###.#..##.# +.##.###.#..##.# +##.##.#...##.## +#..##..####..## +.#.....#..#..## +#.#.##.#.#.#.## +..#......#.###. +##..#..##.####. +.#..#...###..#. +.#......###..#. + +..##...####.#.. +#########..#### +.####.#.###.### +.####..##.#.#.. +######.###..### +.#####.###..### +#.##.#.#..##... +.#..#.#.#.#..## +.......#...##.. +.#..#.#...#.... +##..##.##.##### + +..##.## +....#.. +....#.. +..##.## +..#..## +##...#. +..###.# +###.##. +.####.# + +.#..#..###..#.. +..##.##.#.....# +......#.###.#.# +........#.#.#.. +#######....#... +######..#...##. +#.##.#...#.##.# +.####.#..##..#. +.####......#### +#.##.##....###. +......###.####. +......###.####. +#.##.##....###. + +..#..#.#..###..## +#####.#..######.. +..#....#.#######. +#.#.####...###### +..###..#.####..#. +##.######..##.#.. +##..####...#..#.. +..#.#.##..##.#..# +####...####.....# +####.##...##..#.. +#####.#..###....# +..##.#.####..#..# +..##.#.####..#..# + +###.##.#..#.##.## +##....#.##.#....# +..##..#.##.#..##. +##..#...#....#..# +...###.####.###.. +....#.#....#.#... +###.###.##.###.## + +..##........# +.####..##..## +##..###..###. +.#..#..#...#. +#....##..##.. +#....#....#.. +######.##.### + +..#...###..## +.##..##....#. +.#.#.#####... +.#.#.#####... +.##..##....#. +..#...###.### +..#....#.#### +#...#..##.#.. +#...#..##.#.. +..#....#.#### +..#...###.### +.##..##....#. +.#.#.#####... + +#.##### +...#..# +####..# +.#.#..# +#..#### +#.##### +#...... +#.##..# +#.##..# +#...... +#..#### + +#####.####.#####. +....#......#...#. +.#..###..###..#.# +.##.#..##..#.##.. +##..#.#..#.#..##. +################. +..###.#..#.###... +###..#.##.#..###. +###..#.##.#..###. + +#......#.##.# +..#..#..####. +.....##..##.. +....####.#..# +.####.#..##.. +#.#.###...... +.##....###### +#####.##....# +...####..##.. +...####..##.. +#####.##....# +.##....###### +#.#.###...... + +..#..#.## +.##.#..#. +.##..#### +###...#.# +.##.##.## +.#.#..#.. +##..##.## +##..##.#. +#.###.... +#.##.#.#. +.###..##. +.#.#.##.# +...#.##.# +...#.##.# +.#.#.##.# + +.........#.##.# +...........##.. +.#.##.#....###. +.#....#.#.#..## +#.####.#..####. +...##.....##... +...##....#..#.. +#.#..#.#.###.#. +...##....##...# +.#.##.#..##.### +.#.##.#..####.. +.##..##......## +.##..##......## +.#.##.#..####.. +.#.##.#..##.### +...##.....#...# +#.#..#.#.###.#. + +..#..#.##.##. +....####.#### +..#..#.#..... +####......##. +####.#.#...#. +##..#........ +..##.#.#.#..# + +#..##.... +.#.##.... +##....##. +#.#.#.##. +.####.##. +###..#..# +#.#.#.##. +.#.#.#### +..#.#.##. +.##..#### +#####.##. +.#.#.#### +.#...#### +.#.#.#### +.#.#.#### +#####.##. +.##..#### + +#.###.##.## +#.###.##.## +..#.#....#. +####..##..# +......##..# +##......... +####.#..#.# +.###..##..# +#.......... + +#..#...#...##.#.# +#..#.#.#....#.#.# +.#.#####...#..#.# +.#.##...#.#.##.## +.#.##...#.#.##.## +.#.#####...#..#.# +#..#.#.#....#.#.# +#.##...#...##.#.# +..#..###.#....##. +#..#.#..#.##....# +..###.##..#####.# +..###....###.#### +..###....###.#### + +.##.###..#.#... +####.#.##..###. +...##...#.###.# +####..###.###.. +....#..#.#.#..# +#..#.#.##...... +#..#.#.##...... + +...##########.... +#.#..######..#.## +#...#..##..#...## +##...######...### +##...#.##.#...### +#####.#..#.###### +..#.##....##.#... +..###.####.###... +.#.#.######.#.#.. +..#####..#####... +######.##.####### +#...##....##...## +.#..########..#.. +#...########...## +#............#.## +#.###.#..#.###.## +.##.##.##.##.##.. + +.#....#.....#.# +###..###.#...#. +###..###.#...#. +.#....#.....#.# +.#.##.#.###..## +..#..#....##### +#.#..#.#...#.#. +##########.###. +.#....#.#.##### +.#.##.#.#...##. +###..###..#..#. +.#....#.##.##.# +##....##.....#. +...##.....####. +##....#....#### + +.#..#.##...#. +##..##...#.#. +##..##...#.#. +.#..#.##...#. +.####..##...# +###.###...##. +##..####...#. +#######....## +######.#.###. +.......##..## +######.###.## +..##...###... +#....#.#..### +######.#...#. +#.##.#####... + +#..#..#...#.# +.##.####.#.#. +.###.##.##### +...#.####.### +.....#####.#. +.....#####.#. +..##.####.### +#####..##.### +#####..##.### +..##.####.### +.....#####.#. +.....#####.#. +...#.####.### + +..#.### +####.## +...#### +.##.... +#..##.. +####... +.###... + +..##...#### +#...##.#... +#.#.#.##... +#.#.#.##... +#...##.#... +..##...###. +##..#..#... +##..###.... +..#.....### +....###..## +#.#..###.#. +.#.#..##.## +.#.#..##.## + +##.##.### +...#####. +###.#...# +##.###.## +..##..##. +...#.###. +.....#### +..#.##... +.##.#.... +....###.. +....#...# +##...#..# +##...#..# + +#####...# +#####.### +####..##. +#..#.##.# +.##.##.#. +.##.##.#. +#..#.##.# +####..##. +#####.### +#####...# +####.#.## +.....#... +#####..#. +#..#..#.. +.##..#### +##.#.#... +#..#..#.. + +##.#... +##...#. +##..##. +###.#.# +....#.# +..#.### +..#.### +....#.# +###.#.# +##..##. +##...#. +##.#..# +...#... + +#####..###.#.###. +#####..###.#.###. +.#..#.##..#.#.... +.#.#....####..... +...##..###.####.# +.#####..#...##..# +.#####..#...##..# +...##.####.####.# +.#.#....####..... +.#..#.##..#.#.... +#####..###.#.###. + +..####.###.##.# +.#...##...#.##. +#...###....#... +#...#..#.#...## +#..##..#.#...## +#...###....#... +.#...##...#.##. +..####.###.##.# +###.###...##### +#.##.#..#####.# +#.##.#..#####.# + +..####.#..###.# +..####.#..###.# +#..##.###...### +.#...#...##...# +..#..#####..##. +..#..####...##. +.#...#...##...# +#..##.###...### +..####.#..###.# + +#.######.##..##.# +#...##...##..##.. +##.####.########. +#.##..##.##..##.# +#..####..######.. +####..####....### +###....####..#### +.##....##..##..## +.##.##.##..##..## +###.##.####..#### +.#......#.#..#.#. +...#..#...#..#... +#.##..##.#.##...# +.########......## +#........#....#.. +#..#..#..#....#.. +##......##.##.##. + +...........#.#.#. +.#..#.#..##.#.... +.#..#.#..##.#.... +...........#.#.#. +.#..#....#.##...# +..##.#.#..##.#... +.####...#####...# +#....###.#####.#. +######.###..##.#. +.####.##.#..#.... +.#..#..##.....#.# +..##..#..####.##. +######.#...###... +#....##.#..#...#. +..##.....#.###... + +##..#.# +#...#.# +#..###. +#...##. +.###.#. +##.#.## +...##.# +.#.##.. +.#.##.. +...##.# +##.#.## +.###.#. +#...##. +#..###. +#...#.# + +#.#..#. +##.##.# +.#....# +#.####. +#.####. +.#....# +##.##.# +#.#..#. +.##..#. +#..##.. +##....# +.#....# +#...... + +.####.#..## +.#..#..##.. +######.#### +#.##.####.. +#......##.. +.####..#... +#....###### +..##..#.... +##..####### +#....#.#... +.####.##### +######.##.. +######.#### +..##...#### +.####...... +######.#.## +..##....### + +##.#.## +##..#.# +....#.# +##.#.## +##.#.## +....#.# +###.#.# +##.#.## +##.#### +....#.. +##.#... +..##### +##.#.## + +##.#.###. +##...###. +##..#.### +#.#...#.# +.#....### +.#.####.. +...#.#### +.#...#### +.#..##.#. +#..#...## +.##...#.# +#.##..#.. +.#...#... +....###.. +....###.. +.#...#... +#.##..#.. + +.#....#.. +##....#.. +#...#.#.. +#..#....# +.####.... +.#.###.## +.##.###.# +.##.###.# +.#.###.## + +###..#....# +...######## +###.#...... +##..##....# +####.###### +##..#.#..#. +..###.#..#. +..#.#.####. +....#.#..#. +.......##.. +#####.####. +##.#######. +###.###..## + +#..#...########.. +#######...##...## +.##...#........#. +....###..####..## +.##.............. +#..##..########.. +....##..#....#..# +.##.#..##....##.. +#..#.###..##..### +....##....##....# +....#...##..##..# + +.#.#....#.#.##.#. +..###..###..##..# +##..#..#..##..##. +....####......... +.#.#.##.#.#....#. +#.########.#..#.# +.##......##....## +..########......# +#..#.##.#..####.. +#..#.##.#..#..#.. +..#.#..#.#..##..# +....####......#.. +##.######.######. +#.#.####.#.####.# +#..######..#..#.. + +######.###..####. +######.....##.#.. +####..##.##....## +####...####.#.##. +#####.#.##.###.#. +....##..##.##..#. +......######.###. +####..#.#.###...# +.##.#.#.####.##.# + +#..##..###..### +..#..#...#..#.. +.........####.. +#......##.##.## +..####..#....#. +...##.....##... +#.####.##.##.## +..........##... +...##...##..##. +.#....#...##... +.#....#.#....#. +.#....#......#. +##....##..##..# + +....#..#... +..##....##. +..########. +##.#.##.#.# +...##..##.. +##...##...# +..########. +..#..##..#. +###.......# +##.#.##.#.# +##.######.# + +##..##.#......... +##....#..###..### +..###..##...##... +....#..#......... +.#.####..#......# +##...#....##..##. +##.#..#..#.#..#.# +....#..#.#.####.# +####.#.##.##..##. + +#....####....## +#.##.#..##..##. +#....#.##....## +.####..#..##..# +#######.##..##. +.####..######.# +######.##.##.## +##..##.##....## +.#..#.#..####.. +.####.#..#..#.. +########..##..# +.#..#..#..##..# +#....#....##... +#.##.#.#.#..#.# +######..#....#. +.........#..#.. +#....#.###..### + +##..######..##.## +#...#..#.#...#..# +###.######.#####. +..##......##..### +#.#........#.#.#. +..###.##.###..#.. +..###.##.###..#.. + +#.#..#.#.#. +###..###..# +..####...## +#..##..#### +.#....#.#.# +#.####.###. +.##..##...# +##....####. +########..# +##....##.## +##.....#.#. +#..##..##.. +..####....# +###..###... +#..##..#### +##....###.. +##....###.. + +####..#..#..# +.#####....### +#.##..#..#..# +#...##....##. +.############ +#..#..####..# +#######..#### +.######..#### +.######..#### +##.....##.... +.##.##....##. +#.#.##.##.##. +#.#....##.... +..#.......... +.##.##.##.##. + +.####.#.##. +##..#####.. +...#...#### +..##..#.... +......##### +#....####.# +.#..#..#..# +..##....### +.#..#...### +..##...##.. +.####...#.# +.####...#.# +..##...##.. +.#..#...### +..##....### +.#..#..#..# +#....####.# + +..#..#...######## +#.####.###......# +.........#.#..#.# +.######..###..### +##.##.##......... +##.##.##.#.#..#.# +#.####.#####..### +.######.###....## +#.#..#.#.#.#..#.# +........###....## +.........#.#..#.. +########...####.. +#.#..#.##.#....#. + +##...###.#..#.# +..###.##.##.### +...#..#.####..# +..####.##.#.... +..#.##...#..#.. +###...#.#.....# +###...#.#.....# +..#.##...#..#.. +..####.##.#.... +......#.####..# +..###.##.##.### + +..####...#### +#.#..#.##.##. +.#....#.##### +...#....##..# +..####...#..# +..#..#..#.##. +##########..# +.#.##.#.#.##. +##....###.##. +.######.#.##. +#......#..... + +##.##......#. +##..#.##..##. +##..#.##..##. +##.##......#. +####.###....# +...#...#.#... +...##...#.#.. +#.##..#.#...# +.........#### +...#.#####.## +########....# +###..####.#.# +..#.#.###.... + +#.#.##.###. +#.######.## +..######..# +#........## +##########. +#..#..#..#. +#..#..#..#. + +##..###.#.# +......##### +.#..#.##... +#...###.... +######.#### +##..##..### +.####.#.### +#.##.#.#.#. +#....#..### +.#..#.....# +.#..#.....# +#....#..### +#.##.#.#.#. +.####.#.### +##..##..### + +#..#.###... +###.....### +.....###.## +......##... +.##.#.###.. +.##.#.###.. +......##... +.....###.## +###.....### +#..#.###... +....#..#### +#..##..#... +......####. + +#.#....## +#.#....## +###.#.#.. +###..#### +...##..#. +#.###...# +####...## +####..### +#.###...# +...##..#. +###..#### + +....#.#..##..#.#. +..##.####..####.. +#..###.#....#.### +###.###..##..###. +#.#.....####..... +.....####..####.. +.#............... +##...###....###.. +..#.#.#......#.#. +..#.#.#......#.#. +##...###....###.. +.#............... +.....####..####.. +#.#.....####..... +###.###..##..###. + +#.##.#..#...# +#.##.#..#.#.# +.#..#...#..## +#.##.#....#.# +#.##.####.#.. +......####### +##..##.##.... + +####... +##..#.. +..#.#.. +..#.#.. +#####.# +...#... +.##..#. +##.#.## +####... +##..#.. +##.#.## +###...# +##.##.. +..#.... +...##.# +..#.#.# +..#.#.# + +.#.###. +...#.#. +....### +##....# +##....# +....### +...#.#. +.#..##. +###.##. +###.### +###.### + +.##...#.. +.##...#.# +.###.##.# +..####.#. +#..#.#.#. +..#...#.. +##...#..# +#.##.#.## +...##.### +#..#.#.## +#..#.#.## +...##.### +#.##.#.## +##...#..# +..#...#.. + +.#.##..##.#..#. +.#.######.#..#. +........#...... +..###..###....# +...#.##.#...... +..###..###....# +#.##....##.##.# +##........####. +##.#.##.#.####. + +.###### +..#.... +..#.##. +###.... +#..#... +####..# +#.#.... +#.#.##. +##..... +##.#### +###.... +###.... +.#..##. +#..#### +#..#### +.#..##. +###.... + +##..#..#....# +##..#..##.### +##..#..##.### +##..#..#....# +###.#......#. +....#..#.###. +###..###.#... +####.#.#####. +..##.######.# +##.#..##.#.## +##..#####..#. +##.#.###..#.. +...#####...## +.#..#..##.#.. +..#......#.## +..#.#####.... +##...#.#.#### + +####..##.#.##.#.# +##.##.########### +...##....##..##.. +####.###..####..# +...#.####.#..#.## +.......#.#.##.#.# +.....#.#.#..#.#.# + +..#...##... +.###.#..#.# +.#.##.##.## +.#..######. +.##.#.##.#. +.##.######. +#...#....#. +..######### +.#..##..##. +.#.#.####.# +#..######## +##.#......# +.#..######. +##...#..#.. +#####....## +#.###....## +##...#..#.. + +.##.##.##..#..... +#.##.#########.## +##..##..####.#.## +#.####...#.####.. +......#.#.##..#.. +#....##..#..#..## +....#.#....#.#### +....#.#....#.#### +#....##..#..#..## +......#.#.##..#.. +#.####...#.###... +##..##..####.#.## +#.##.#########.## +.##.##.##..#..... +....#.##..##.#... + +#.#.##.#.#... +..#.##.#....# +####..####.#. +..#.##.#...#. +#.##..##.#... +#..####..#.## +.#.#..#.#.#.# +#.######.#..# +.#......#.... +..#.##.#...#. +.#.#..#.#.#.. +.#..##..#.#.# +.###..###.### +..........##. +.########.#.. +.#..##..#.#.# +.#..##..#.### + +.....#..#.#....## +.....#..#.#.#..## +###....#........# +###....#.#.#.#### +...#.#..#.##.###. +..#.####...#....# +######...##.#.#.. +..##.####.####..# +..#######.##.##.. +##...#.#####..#.# +..#..#.##.#.#.#.. +...#..#.....#.### +##..#.#.##..####. +##....#...#...#.. +...#.###...###..# +##.##.#.##.###.#. +..#.#....#.#.##.# + +..#..#...#..#..#. +.#.....#..##....# +..###.#.#....##.. +#..#..#..###.##.# +###...##.###.##.# +#..##..###.#....# +.###.######.#..#. +###.#..#....####. +...#..#..#..#..#. +##.#..###.#...... +.##.#..###.###### +....#.##..##.##.# +..###...####....# +..#...#...##.##.# +..#...#.#.##.##.# + +....#.#.. +......#.. +.##.#.... +....#.### +####..##. +.#.#.##.# +.##.##... +.#.#.#.## +.#.#.#.## + +#....#.#. +..##..#.. +..##..#.# +#....#.#. +##..###.. +##..###.. +#....#### + +#######.#.. +#..#.#..##. +#..#.#.#..# +.##.....##. +.##...##... +#..#..##... +.....##.#.# +.....##..#. +.....##..#. +.....##.### +#..#..##... +.##...##... +.##.....##. + +###..##..###. +..#.####.#... +..#.####.#..# +###..##..###. +##........### +#.##.##.##.## +#.########.## + +###..## +...##.. +..#..#. +##.##.# +###..## +..####. +#####.# diff --git a/2023/src/bin/day01.rs b/2023/src/bin/day01.rs index 412db06..1629bf4 100644 --- a/2023/src/bin/day01.rs +++ b/2023/src/bin/day01.rs @@ -40,21 +40,21 @@ fn part2(parsed: &Parsed) -> usize { .sum() } -#[cfg(test)] -const TEST_INPUT_2: &str = "two1nine +boilerplate! { + TEST_INPUT == "\ +1abc2 +pqr3stu8vwx +a1b2c3d4e5f +treb7uchet", + TEST_INPUT_2 == "\ +two1nine eightwothree abcone2threexyz xtwone3four 4nineeightseven2 zoneight234 -7pqrstsixteen"; - -boilerplate! { - TEST_INPUT == "1abc2 -pqr3stu8vwx -a1b2c3d4e5f -treb7uchet", - tests: { +7pqrstsixteen" + for tests: { part1: { TEST_INPUT => 142 }, part2: { TEST_INPUT_2 => 281 }, }, diff --git a/2023/src/bin/day02.rs b/2023/src/bin/day02.rs index 0b552b0..04824bb 100644 --- a/2023/src/bin/day02.rs +++ b/2023/src/bin/day02.rs @@ -49,8 +49,8 @@ Game 1: 3 blue, 4 red; 1 red, 2 green, 6 blue; 2 green Game 2: 1 blue, 2 green; 3 green, 4 blue, 1 red; 1 green, 1 blue Game 3: 8 green, 6 blue, 20 red; 5 blue, 4 red, 13 green; 5 green, 1 red Game 4: 1 green, 3 red, 6 blue; 3 green, 6 red; 3 green, 15 blue, 14 red -Game 5: 6 red, 1 blue, 3 green; 2 blue, 1 red, 2 green", - tests: { +Game 5: 6 red, 1 blue, 3 green; 2 blue, 1 red, 2 green" + for tests: { part1: { TEST_INPUT => 8 }, part2: { TEST_INPUT => 2286 }, }, diff --git a/2023/src/bin/day03.rs b/2023/src/bin/day03.rs index f10239b..3571f02 100644 --- a/2023/src/bin/day03.rs +++ b/2023/src/bin/day03.rs @@ -92,8 +92,8 @@ boilerplate! { ..592..... ......755. ...$.*.... -.664.598..", - tests: { +.664.598.." + for tests: { part1: { TEST_INPUT => 4361 }, part2: { TEST_INPUT => 467835 }, }, diff --git a/2023/src/bin/day04.rs b/2023/src/bin/day04.rs index a2062ed..62069e0 100644 --- a/2023/src/bin/day04.rs +++ b/2023/src/bin/day04.rs @@ -46,8 +46,8 @@ Card 2: 13 32 20 16 61 | 61 30 68 82 17 32 24 19 Card 3: 1 21 53 59 44 | 69 82 63 72 16 21 14 1 Card 4: 41 92 73 84 69 | 59 84 76 51 58 5 54 83 Card 5: 87 83 26 28 32 | 88 30 70 12 93 22 82 36 -Card 6: 31 18 13 56 72 | 74 77 10 23 35 67 36 11", - tests: { +Card 6: 31 18 13 56 72 | 74 77 10 23 35 67 36 11" + for tests: { part1: { TEST_INPUT => 13 }, part2: { TEST_INPUT => 30 }, }, diff --git a/2023/src/bin/day05.rs b/2023/src/bin/day05.rs index 5e46ea8..b53cb19 100644 --- a/2023/src/bin/day05.rs +++ b/2023/src/bin/day05.rs @@ -116,8 +116,8 @@ temperature-to-humidity map: humidity-to-location map: 60 56 37 -56 93 4", - tests: { +56 93 4" + for tests: { part1: { TEST_INPUT => 35 }, part2: { TEST_INPUT => 46 }, }, diff --git a/2023/src/bin/day06.rs b/2023/src/bin/day06.rs index 95949d3..aaf5518 100644 --- a/2023/src/bin/day06.rs +++ b/2023/src/bin/day06.rs @@ -29,8 +29,8 @@ fn part2((_, (time, distance)): &Parsed) -> usize { boilerplate! { TEST_INPUT == "\ Time: 7 15 30 -Distance: 9 40 200", - tests: { +Distance: 9 40 200" + for tests: { part1: { TEST_INPUT => 288 }, part2: { TEST_INPUT => 71503 }, }, diff --git a/2023/src/bin/day07.rs b/2023/src/bin/day07.rs index 2e3084b..874240b 100644 --- a/2023/src/bin/day07.rs +++ b/2023/src/bin/day07.rs @@ -93,8 +93,8 @@ boilerplate! { T55J5 684 KK677 28 KTJJT 220 -QQQJA 483", - tests: { +QQQJA 483" + for tests: { part1: { TEST_INPUT => 6440 }, part2: { TEST_INPUT => 5905 }, }, diff --git a/2023/src/bin/day08.rs b/2023/src/bin/day08.rs index ace2368..15cc776 100644 --- a/2023/src/bin/day08.rs +++ b/2023/src/bin/day08.rs @@ -75,8 +75,15 @@ fn part2(parsed: &Parsed) -> usize { parsed.1.iter().filter(|&&n| ends_with(n, b'A')).fold(1, |acc, n| lcm(acc, steps_until(parsed, *n))) } -#[cfg(test)] -const TEST_INPUT_P2: &str = "LR +boilerplate! { + TEST_INPUT == "\ +LLR + +AAA = (BBB, BBB) +BBB = (AAA, ZZZ) +ZZZ = (ZZZ, ZZZ)", + TEST_INPUT_P2 == "\ +LR 11A = (11B, XXX) 11B = (XXX, 11Z) @@ -85,15 +92,8 @@ const TEST_INPUT_P2: &str = "LR 22B = (22C, 22C) 22C = (22Z, 22Z) 22Z = (22B, 22B) -XXX = (XXX, XXX)"; - -boilerplate! { - TEST_INPUT == "LLR - -AAA = (BBB, BBB) -BBB = (AAA, ZZZ) -ZZZ = (ZZZ, ZZZ)", - tests: { +XXX = (XXX, XXX)" + for tests: { part1: { TEST_INPUT => 6 }, part2: { TEST_INPUT_P2 => 6 }, }, diff --git a/2023/src/bin/day09.rs b/2023/src/bin/day09.rs index 2b170c1..18fd183 100644 --- a/2023/src/bin/day09.rs +++ b/2023/src/bin/day09.rs @@ -56,8 +56,8 @@ boilerplate! { TEST_INPUT == "\ 0 3 6 9 12 15 1 3 6 10 15 21 -10 13 16 21 30 45", - tests: { +10 13 16 21 30 45" + for tests: { part1: { TEST_INPUT => 114 }, part2: { TEST_INPUT => 2 }, }, diff --git a/2023/src/bin/day10.rs b/2023/src/bin/day10.rs index aaf8f54..4fa2b97 100644 --- a/2023/src/bin/day10.rs +++ b/2023/src/bin/day10.rs @@ -128,8 +128,8 @@ boilerplate! { 7S-7| L|7|| -L-J| -L|-JF", - tests: { +L|-JF" + for tests: { part1: { TEST_INPUT => 4 }, part2: { INPUT_P2 => 4, diff --git a/2023/src/bin/day11.rs b/2023/src/bin/day11.rs index 5e3221b..99fd001 100644 --- a/2023/src/bin/day11.rs +++ b/2023/src/bin/day11.rs @@ -61,8 +61,8 @@ boilerplate! { .........# .......... .......#.. -#...#.....", - tests: { +#...#....." + for tests: { part1: { TEST_INPUT => 374 }, }, bench1 == 9623138, diff --git a/2023/src/bin/day12.rs b/2023/src/bin/day12.rs index f0e0d69..0daaf91 100644 --- a/2023/src/bin/day12.rs +++ b/2023/src/bin/day12.rs @@ -122,8 +122,8 @@ boilerplate! { ?#?#?#?#?#?#?#? 1,3,1,6 ????.#...#... 4,1,1 ????.######..#####. 1,6,5 -?###???????? 3,2,1", - tests: { +?###???????? 3,2,1" + for tests: { part1: { TEST_INPUT => 21 }, part2: { TEST_INPUT => 525152 }, }, diff --git a/2023/src/bin/day13.rs b/2023/src/bin/day13.rs new file mode 100644 index 0000000..1f1b639 --- /dev/null +++ b/2023/src/bin/day13.rs @@ -0,0 +1,71 @@ +#![feature(test, try_blocks)] +extern crate test; +use aoc2023::{boilerplate, common::*}; + +const DAY: usize = 13; +type Parsed<'a> = Vec>>; + +fn parse_input(raw: &str) -> Parsed { + raw.split("\n\n").map(|block| block.lines().map(|l| l.as_bytes().to_vec()).collect()).collect() +} + +fn find_reflection(block: &[Vec]) -> Option { + 'outer: for i in 0..block.len() - 1 { + let mut offset = 0; + loop { + match try { (block.get(i.checked_sub(offset)?)?, block.get(i + 1 + offset)?) } { + None => return Some(i + 1), + Some((a, b)) if a == b => offset += 1, + Some(_) => continue 'outer, + } + } + } + None +} + +fn part1(blocks: &Parsed) -> usize { + blocks.iter().map(|block| find_reflection(block).map(|n| n * 100).or_else(|| find_reflection(&transpose(&block))).unwrap()).sum() +} + +fn transpose(orig: &[Vec]) -> Vec> { + let mut out = vec![vec![0; orig.len()]; orig[0].len()]; + for i in 0..orig.len() { + for j in 0..orig[0].len() { + out[j][i] = orig[i][j]; + } + } + out +} + +fn part2(parsed: &Parsed) -> usize { + unimplemented!() +} + +boilerplate! { + TEST_INPUT_HORIZONTAL == "\ +#...##..# +#....#..# +..##..### +#####.##. +#####.##. +..##..### +#....#..#", + TEST_INPUT_VERTICAL == "\ +#.##..##. +..#.##.#. +##......# +##......# +..#.##.#. +..##..##. +#.#.##.#." + for tests: { + part1: { + TEST_INPUT_HORIZONTAL => 400, + TEST_INPUT_VERTICAL => 5, + }, + part2: { TEST_INPUT_VERTICAL => 0 }, + }, + bench1 == 37561, + bench2 == 0, + bench_parse: Vec::len => 100, +} diff --git a/2023/src/teststuff.rs b/2023/src/teststuff.rs index 6782724..103d0a6 100644 --- a/2023/src/teststuff.rs +++ b/2023/src/teststuff.rs @@ -1,8 +1,8 @@ #[macro_export] macro_rules! boilerplate { ( - TEST_INPUT == $ti: literal, - tests: { + $($tin: ident == $ti: literal),+ + for tests: { $($part: ident: { $($tpi: expr $(,$ati: expr)* => $to: expr),+$(,)? }),*$(,)? }, $(unittests: { @@ -24,7 +24,9 @@ macro_rules! boilerplate { use super::*; use aoc2023::*; - const TEST_INPUT: &str = $ti; + $( + const $tin: &str = $ti; + )+ $($($(paste::paste! { #[test]