diff options
author | Alexandre Jesus <adbjesus@gmail.com> | 2024-01-03 19:23:30 +0000 |
---|---|---|
committer | Alexandre Jesus <adbjesus@gmail.com> | 2024-01-03 19:23:30 +0000 |
commit | 22a3cb76fefbfa8c444f1ae39a8a4304ad3950ba (patch) | |
tree | 4027330e67eb34b6d500857b1856e65005088437 | |
parent | caf416319e8807e0648b3e8ad12fdbfa813f669a (diff) | |
download | aoc2023-22a3cb76fefbfa8c444f1ae39a8a4304ad3950ba.tar.gz aoc2023-22a3cb76fefbfa8c444f1ae39a8a4304ad3950ba.zip |
day13
-rw-r--r-- | data/13/example.txt | 15 | ||||
-rw-r--r-- | data/13/input.txt | 1387 | ||||
-rw-r--r-- | day13.lisp | 46 |
3 files changed, 1448 insertions, 0 deletions
diff --git a/data/13/example.txt b/data/13/example.txt new file mode 100644 index 0000000..3b6b5cc --- /dev/null +++ b/data/13/example.txt @@ -0,0 +1,15 @@ +#.##..##. +..#.##.#. +##......# +##......# +..#.##.#. +..##..##. +#.#.##.#. + +#...##..# +#....#..# +..##..### +#####.##. +#####.##. +..##..### +#....#..# diff --git a/data/13/input.txt b/data/13/input.txt new file mode 100644 index 0000000..2384d2a --- /dev/null +++ b/data/13/input.txt @@ -0,0 +1,1387 @@ +.####.#...##.#. +...###.##.#.#.. +...###.##.#.#.. +.####.#...#..#. +..##......#..#. +#.#...#.##...## +.#.#.#..##..##. +#..##...#####.# +.#.#.#.#..##.#. +.....###.#.#..# +.....###.#.#..# + +.#.###..... +#..#.##...# +.#.....#.#. +.#.....#.#. +#..#.##...# +.#.###..... +##.#..##.## +#....##..#. +.##.##.#.## +...#..###.# +...#..###.# +.##.##.#.## +#....##..#. +####..##.## +.#.###..... +#..#.##...# +.#.....#.#. + +###....##.... +####..#..#..# +..###.####.## +..#..######.. +...#.######.# +#####.#.##.## +##.#..#..#..# +##....####... +....#......#. +.....#.##.#.. +##...##..##.. +...##.#..#.## +##..###..###. + +.##.#...##. +.#.######## +.##.#.#.##. +#.##..#.... +####.##.... +####.##.... +#.##..#.... +.##.#.#.##. +.#.######## +.##.#...##. +..####.#### +.##.###.### +.#..#.#.##. +#.####..##. +...#..#.... + +.....##..#. +.##..##.#.# +#..#...#### +####.....## +#..#.##.... +#####.....# +#####.....# +#..#.##.... +####.#...## +#..#...#### +.##..##.#.# +.....##..#. +....##.##.. + +#####.. +.##.#.. +.##.... +.##...# +.##.... +#..#### +..#.#.# +#####.. +#####.# +.##...# +.##.##. +.##.##. +.##...# + +.##.#.##.##.##.## +.##.####....###.. +.##.#.#.#.##..##. +#..#.#..#.#.##.#. +....####...####.. +#..##.#...######. +....#.#.......... +#..#.##.####..### +#####...##......# +....###..##.##.## +####..###..####.. +.##..##..#.####.# +#..##..##..#..#.. +.##..#.#.#..##..# +####..####.####.# +####.....###..### +#..#..##.##.##.## + +.#..#.#.##### +#.##.#.#.#.## +#.##.#.#.#.## +.#..#.#.#.### +##..##..###.. +##.####.##### +.##.#.#...### + +.###.#.###.###..# +...####.####..#.# +#..####.####..#.# +.###.#.###.###..# +...###..#..##.... +.#.#####.###..### +#.#.#####.#.##### +.##.###.#...###.. +.##.#.....##..##. +#..##.####...##.. +#.#.#..#....#.### +..#...#...##..##. +##..#.######...## +###.#.####..#..## +...#..##..##...## +###....##.#..#..# +###....##.#..#..# + +##.###..####..# +#.###.###.##..# +..##...##..##.# +..##...##..##.# +#.###.###.##..# +##.###..####..# +....#####.##### +##..#....#.#..# +##.#..#.#...#.. +.##.#..##.#.### +.##.#..##.#.### +#..#..#.#...#.. +##..#....#.#..# + +.###.#....##....# +#.##.##........## +...###.#..##..#.# +...###.#..##..#.# +#.##.##........## +.###.#....##....# +.###..#.##..##.#. +.###.#...####...# +####.....####.... +###...##...#..##. +.#..#.#.#.##.#.#. + +#.#..#. +#.#..#. +#...... +###..## +##.##.# +..####. +#...... +##..... +.##..## +..#..#. +..#..#. +.##..## +...##.. + +##.#########..##. +...#.####.#.##..# +##.#...#..##..##. +....#..###.##.#.# +....#..###.##.#.# +##.#...#..#...##. +...#.####.#.##..# +##.#########..##. +##...####...##... +###...##..###.#.# +...#.#..##.#..... +.........#####... +....##..#.#.##.## +...#.#.###.....#. +...##..#.##.#.#.# +##...##....#.#### +###....###......# + +..##.##.##......# +.###....###....## +#.###..###.####.# +.##########.##.## +...##..##........ +###......###..### +.##########....## +.#.######.#.##.#. +.....##.....##... +####.##.####..### +...#....#........ +.##.#..#.##.....# +..##.##.##......# + +####.## +.##..#. +..###.# +.##.#.# +###.#.. +##...## +##...## +#####.. +.##.#.# +..###.# +.##..#. +####.## +####.## +.##..#. +..###.# + +#.###.. +.....## +..#.... +.#.##.. +..#.### +..#..## +.#.##.. + +#..#.###....##### +##.####.####.#### +#...###..#..#.##. +..###.#.##.....#. +..#....####..#### +...#.###.#.##.##. +.#...###.#..##### +.#.#...##.#...... +.##.##..#.....##. +.#..#.#...##.#..# +.#....##.##.##..# +###..####.###.... +###..####.###.... + +######.#.##.... +.####.#..##.##. +.####.##..#.... +.####.#.#.##### +#....#..####..# +.####...#.#.... +..........##..# +..##..#.#####.# +######.#...#### +#.##.##.....##. +.#..#...##.#### +..........##### +#.##.#####.#..# + +#####.# +##.##.# +#.#.### +...##.# +######. +......# +......# +######. +...##.# +#.#.### +##.##.# + +.#..#.#####...#.. +#######.#.#.....# +#....#...#.#...## +######...###...## +.#..#..###..#..## +#....##..#...##.# +.####..##.###.##. +.#..#.##.###..#.. +#....#.#.##.##.#. +.#..#.#...#.##... +.####.##.#.#....# +.......#.##.#.##. +.......#.##.#.#.. +.####.##.#.#....# +.#..#.#...#.##... + +##.#### +..#.... +###.... +.##.... +#.#.... +#.#.... +..#.... +###.##. +#..#### +#.##### +###.... +#..#### +.###### +##.#### +.#..... + +###.##....##.## +##.##......##.# +####...##...### +....#.#..#.#... +....#.....##... +#####..##..#### +###..##..##..## +###..#.##.#..## +###..#....#..## +#####.####.#### +..#.#..##..#.#. +..#..#.##.#..#. +##............# + +###.#.##.#.#.#. +###.#.##.###.#. +##..#...##....# +.#..###.###..## +#.#......###.## +........##.##.# +........##.##.# +#.#......###.## +.#..###.###..## +##..#...##....# +###.#.##.###.#. +###.#.##.#.#.#. +.#..#.#...#.### +.....##.#.##.#. +.#.###.#.###.## +.#.#.....###.#. +##....####.#.## + +###......###. +##.######.### +###.####.###. +##..#..#..##. +..##....##... +###..##..###. +####....##### +####.##.####. +##.##..##.##. +#...####...#. +...#....#.... +...#....#.... +..#.#..#.#..# + +.##..##.###..## +.##.#...##.#.#. +.##.#...##.#.#. +.##..##.###..## +#...#.#..####.. +.#.#....#.#.... +#..##..#..##... +##....####..#.. +.#.....#.###..# +..#....#.#...#. +.##...#.#..#.## +...##.#..###### +.###.......#### +.###.......#### +...##.#...##### + +.#........#.##. +#.##.#...##.#.# +###.####...##.# +###.####..###.# +#.##.#...##.#.# +.#........#.##. +...#.##.#.#.##. +#.####.###.#### +.#...##.##.###. +.....#..#.####. +##.##.##..##..# +.....#..#.....# +##.##.#.#####.. +##.##.#.#####.. +.....#..#.....# +##.##.##..##..# +.....#..#.####. + +######.##.### +.#..##.##.##. +#.#.##.##.##. +#.#..#.##.#.. +....#.####.#. +#...#..##..#. +####.#....#.# +.###.######.# +####.###.##.# +....###..###. +..###.####.## +..###.####.## +....###..###. + +..##..##..# +..###.#.... +##....#.... +###.#.#.##. +##.####.##. +##...##.##. +...##..#### +##.#####... +...#.##.... +..#####.##. +...#..##..# +..#.#..#### +##.....#### +...##.#.##. +..#####.##. +.....#.#..# +##.##...##. + +#......##.##.## +..####..#####.. +..#..#...#..#.. +.######.##.#... +..#..#....##### +...##....###### +.........#.##.. +.##..##.#...... +####.####.#.### + +#......##......## +..####....####... +..#..#....#..#..# +...##......##.... +################. +.#....#..#....#.. +...##......##.... +.#....#..#....#.. +##....####....##. +..#..#....#..#... +..#..#....#..#..# +##.##.####.##.##. +###..######..###. +..####....####... +...##......##.... +####.######.##### +.#.##.#..#.##.#.# + +...##.##.##.. +##..........# +##..##..##..# +..#.######.#. +##...####...# +...##.##.##.. +###..####..## +##...####...# +...##.#..##.. +....##..##... +##..#.##.#..# + +.#.##.####.##.#.. +##..###..###..##. +##..##....##..##. +#.#.##....##.#.#. +#.#.###..###.#.#. +##...##..##...### +#..#.##..##.#..## +....#.#..#.#....# +....#.#..#.#..... + +.##.#.....#...### +###..#.####..#### +##....#..####.... +#..###..#.#..#### +..#.####.####.##. +.##....##...#.##. +.##....##...#.##. +..#.####.####.##. +#..###..#.#..#### +##....#..####.... +###..#.####..#### + +##..#.#..#.#. +##.###.##.### +#######..#### +##..##....##. +##.####..#### +#####..###.## +####...##...# +....###..###. +..##..#..#..# +..#..##..##.. +##.##.#..#.## +###.###..###. +...##.####.## +##.###.##.### +...#...##...# +..#....##.... +.....#....#.. + +..#.##.## +..#..#### +#...#.##. +#...#.##. +..#..#### +..#.##.## +######... +#.##..#.. +.#.....#. +###.###.# +#.##..### +.#..#..#. +###.##... +###..#... +###..#... +###..#... +.#..#..#. + +###.###.##. +###.###.##. +##.#.##..#. +....#.##.## +.#.##.##.## +###....#### +###.##..#.. + +####.#..##..#.# +.......######.# +####.##.....#.. +####.##.....#.. +.......######.# +####.#..##..#.# +.##.####.#.#.#. +######....#.#.# +.......#....#.. +###...###.##### +#..#..#####.### +......##.##.#.. +.##.###.###...# +####...###.#### +#####.###...#.# + +#####.... +#...##### +#....#### +#..##..## +#..##..## +#....#.## +#...##### +#####.... +#..#..#.. +.#....### +##.#..#.. +.#...#### +###.#.### +##.#..... +##...#.## + +....#.#.#...... +.....#.#####... +....###..#.#... +..#...#..##.### +####...##..#### +.##...##.###.## +#..#..#........ +#..###..##..... +.....####...#.. +.##.#.#.###.### +####.##.#.#.### +.....#.#.....## +########...#### +#..###..###..## +.##.###.#..#### + +.#.#..##.#.#.#. +....##.....##.. +#.#.####..####. +#..#..##.###... +#..#..##.###... +#.#.####.#####. +....##.....##.. +.#.#..##.#.#.#. +.#####..#..#### +#....#.#..##..# +#..#.#..##.#..# +#.##..#..#.#..# +.####..##.#..#. +.####..##.#..#. +#.##..#..#.#..# +#..#.#..##.#..# +#....#.#..##..# + +#..#######..#.#.. +#.#...#.###..#### +##....###.###.### +.........#.#..... +.#.#..####...##.. +#.#.##.#.###...## +#.#.#...####..... +#.#.#...####..... +#.#.##.#.###...## +.#.#..####...#... +.........#.#..... +##....###.###.### +#.#...#.###..#### +#..#######..#.#.. +##...#.####....## + +....######. +###.....#.# +###.....#.# +.#..######. +.#..######. +###.....#.# +###.....#.# +....######. +.#####.###. +#..#......# +##....##.## +.#.#.#..#.# +.####....## +##...#.#.#. +#...###..#. + +########..### +....###....## +....###.##.## +####......... +....####..### +#..##..####.. +######.####.# +#..#...#..#.. +####...####.. +.##.....##..# +#..########## +#..#..######. +.##.#..#..#.. + +#.##.####.#.... +#.##.####.#.... +##...##.##..### +..#..#...#.#..# +#.#....#.##...# +.#.####.#...#.# +####.#.#....### +.##.#.####...## +.##.#.####...## +####.#.#.#..### +.#.####.#...#.# +#.#....#.##...# +..#..#...#.#..# +##...##.##..### +#.##.####.#.... + +###..## +###..## +#..##.# +.##.... +.##.... +#..##.# +####.## + +....#...#..#. +.##..#..#.#.# +####.##.##.#. +###.###..#... +#.#.#...###.# +#.#.#...###.# +###.###..#... +####.##.##.#. +.##..#..#.#.# +....#...#.##. +#.###.##.##.# +#.###.##.##.# +....#...#.##. +.##..#..#.#.# +####.##.##.#. + +..#..#........# +...##....#.#... +##....###...#.# +##....##.###.#. +...##...#.#.#.. +........####### +##....##.#..... +..............# +#########.##.#. +........#.#.##. +#########..##.. +.######..##..#. +..####..###..#. +..####.....#... +..####...##.... + +..#####.### +...####.### +.....#.#... +.####..##.# +##...#..### +##...#..### +.####..##.# + +#..##.###.####.## +########.##..##.# +.##....##.####.## +#######.#......#. +####..##...#....# +####..########### +....############# +......##.##..##.# +#######..##..##.. +#..##.#...#..#... +.##.#.##.##..##.# +.##..###..#..#..# +....#.##........# +.....##.#.####.#. +.##.#.##........# + +.##....#...#.#... +.##....#...#.#... +..#...###.#####.. +.####...#..#..##. +##.###.#.....##.. +.....##.#..#.#.## +.#.##....##.#.#.. +#..........####.. +#.....###.##...## + +#.###..##.. +.#..#.#..## +###..##.... +###..##.... +.#..#.#.### +#.###..##.. +####.#..### + +.....#.####..#..# +.....#.####..#..# +..#.#..###.#..#.# +####..#####.##... +..#.##..###.....# +##...#.###.#..#.# +###.#.#...#...### +.###.....#.##..#. +.###....##.##..#. + +...#...#..#.##..# +#..##.#..####.##. +.##..#.#..##..##. +..##..###....#..# +.#.....###.#.#### +###..#.#.##...##. +###..#.####...##. + +##.##.. +..#.... +.#.#... +##.#### +##.#### +...#... +..#.... +##.##.. +#.##### +##..#.. +.#.#... +..#.#.. +###.### +....### +.##.#.. +#..#.## +##...## + +###.#....#.## +#..#.#..#.#.. +#..#.#..#.#.. +###.#....#.## +#.###....###. +.##...#....## +...#.####.#.. +##..##..##..# +..#..####..#. +.##..####..## +##..#....#..# +..##.#..#.##. +.##.#....#.## + +..####### +...##.##. +##.#.#### +#.#..#..# +.#.##.... +#.##.#..# +...###### +#..###### +#.##.#..# + +######......... +.##..##..##..## +.......##..##.. +.#.#...#.##..## +#.#.##...#....# +.##..#.....##.. +.##..#.....##.. +#.#.##...#....# +.###...#.##..## + +####..#.##.#. +###.#.#.##.#. +#.##..#.##.#. +....#..#..#.. +.#.###.####.# +##..#.######. +.#.##.#.##.#. +#.##..######. +#.##..######. +.#.##.#.##.#. +##..#.######. +.#.###.####.# +....#..#..#.. +#.##..#.##.#. +#.#.#.#.##.#. +####..#.##.#. +.#..#.#.##.#. + +.#........#.. +#.###..###.## +.#..####..#.. +#.#.#..#.#.## +.#.#.##.#.#.. +.##..##..##.. +#...####...## +..#.#..#.#... +...#.##.#.... +#..#....#..#. +..#.####.#... +.##########.. +.#........#.. +#..#....#..## +..##....##... + +.##..###...#... +.##.##.######## +#.#.#..#..#..#. +.#......###..## +....######.##.# +.#.##......##.. +##.#...###.##.# +##.#...###.##.# +.#.##......##.. +....######.##.# +.#......###..## + +.##...##. +#..#.###. +####..... +#..###### +.##..#..# +.##.##### +....##### + +.###...#####.###. +..##...#..##..##. +..##..#..#...#..# +##..###.#.#.#.##. +##..##.#.#......# +##..###...##.###. +........##.###..# +.####.#....###..# +#.##.###..#..###. +.........#.#.#..# +##..##.#.##..###. +##..##.#.##..###. +.........#.#.#..# + +....#......#... +....###..###... +.....######.... +##.#.#....#.#.# +##.....##.....# +..##..#..#..##. +..####....###.. + +.....#.#..# +#####.##### +#..######## +#..#.###### +#....#..##. +.##.#..#..# +#..#..##### + +#.##.#..# +##..#.##. +..###.##. +..#...##. +#.#...##. +###...... +###...... +#.#...##. +.##...##. + +.......#. +.......#. +.#..#.#.. +.####...# +..##..#.# +########. +.####.#.# +..##..... +..##...#. +#....#..# +##..##.## +######... +.#..#.#.# +#.##.###. +#.##.##.. +....#...# +######.## + +#..#..#........#. +....##..#.##.#..# +....##.#..##..#.# +.....#...#..#...# +####..#.##..##.#. +.##.#####....#### +....#.#.##..##.#. +...######....#### +######..##..##..# + +###.#.. +####..# +..#.... +###.##. +...#..# +..#.##. +###.##. +###.... +..#.##. + +.#..###....#... +##...#...###... +.#..#..##...#.# +.#..#..##...#.# +##...#....##... +.#..###....#... +###..###..#.#.# +#.##.#.#.#####. +#......##...#.# +###....#.#.#.#. +###....#.#.#.#. +#......##...#.# +#.##.#.#.#####. +###..###..#.#.# +.#..###....#... +##...#....##... +.#..#..##...#.# + +..##.#. +##.##.. +..##.#. +...##.# +#.##### +..###.# +..#.##. +###.### +##...#. +..####. +..####. +##...#. +###.### + +.##.#...#.##. +#.####.####.# +####...#.#..# +.##.#.######. +######...##.# +.....#..#.#.. +.....#..#.#.. +######...##.# +.##.#.######. + +.###.#.#. +...#.##.. +##.....## +###..#.#. +#.#..##.. +...#..##. +.......#. +.......#. +...##.##. +...##.##. +.......#. +.......#. +...#..##. + +...##....####.##. +.##..###.#...#### +###..###.####.##. +.######.#....#### +########....#.##. +..#..#..##..#.... +.##..##...#...... +..#..#..##.###..# +#.####.##.#...... + +#.#..#####..#.. +##.##.####..### +#......#.##.#.# +###..####.##... +#.#..#.###...#. +.#.##.#.#.#.### +##.##.##..#.### +.##..##.#####.. +#......#.##.... +#......#.##.... +.##..##.#####.. +##.##.##..#.### +.#.##.#.#.#.### +#.#..#.###...#. +###..####.##... +#......#.##.#.# +##.##.####..### + +####..##### +.....#..### +#..####.#.. +.......##.. +#..#..#.### +####....... +.....#.#.## +#..##..#... +.##...##..# +.......###. +.##..##..## +....#....## +####.#.##.# +#####.####. +#####.###.. + +#..#.####.#.#.. +#.#####.#.##### +##.#...##.#...# +#..#.##...#.##. +#..#.##...#.##. +##.#...##.#...# +#.#####.#.##### +#..#.####.#.#.. +#..#.######.### +.....####....## +.##.....##.#### +......#.##..##. +......#.##..##. +.##.....##.#### +.....####.....# +#..#.######.### +#..#.####.#.#.. + +#.#...### +#.#####.. +.###..... +.###..... +#.#####.. +#.#...### +.#.....#. +.#..###.# +.#..###.# +.#.....#. +#.#...### +#.#####.. +.#.#..... + +..........### +..##....#.### +..##....#..## +..........### +.####...#.... +.####.######. +##..##.###### +.####.....##. +.####.##.###. + +######..##. +.#..#..#..# +#######.##. +######..##. +.####.##..# +.####.#.... +.####...##. +.#..#.##### +##..####### +.####.#.... +#.##.##.... +..##....##. +.#..#.##### +##..##..##. +.####...##. +#.##.##..#. +#....###..# + +#...#..#....#.##. +..........###.##. +....#.#.###..#..# +.###...######.##. +.###....#####.##. +....#.#.###..#..# +..........###.##. +#...#..#....#.##. +##.###.###...#### +#......#...#.#..# +..#..##.......... +.###.###.##...##. +..##.#####..##### +....#.##.#.##.... +....##.#..#.##..# +...#####....##..# +....#.###..#.#### + +...######...# +##.##..##.##. +##.#....#.### +####.##.##### +#..........## +....#........ +.####..####.# +.#.##..##.#.. +#....##....## +#..........## +....####..... +##.##..##.### +##.##..##.### + +###..## +##.#.#. +..#...# +##..#.. +#####.# +###..#. +###.... + +#####.# +...#### +.##.... +...#..# +#.#.... +.###### +###.... +###.... +.###### + +..#..####.. +####.####.# +####.####.# +..#...###.. +##...#.#.#. +...####...# +....#...##. +..#.###.#.# +#######.##. +...#...##.# +..#.#.#...# +####.#....# +.....#..#.# + +######..# +..##...#. +##..##.#. +#....###. +#....##.. +##..##.#. +..##...#. + +#.##..# +#####.. +##.##.. +##.##.. +#####.. +#.##..# +.###.## +.#.##.. +.###.## +.##..## +#.#.### +.#..... +##.##.. +.###### +.#.#### + +####..#..#..### +..#.########.#. +####...##...### +...##########.. +..#..........#. +###.########.## +..#..##..##..#. +##..#.####.#..# +##.#.##..##.#.# +###.###..###.## +####.##..##.### +..#....###...#. +..##.#....#.##. +##..##.##.##..# +...##########.. +######.##.##### +###..........## + +#.....#...#..#... +##.#...#..#..#..# +##.###.########## +##.##.########### +#.##...#.#.##.#.# +#.#.............. +..##.....##..##.. +##..#......##.... +##.##.#.#.####.#. +##..#.#.#.####.#. +##..#......##.... + +......#.##.#... +#.##.#......#.# +......####.#... +.#..#.#....#.#. +##..###.##.###. +.#..#.#....#.#. +#....##....##.. +.####..####..## +.####.#....#.## + +#####.#.##.#. +...##...##.#. +...##...##.#. +#####.####.#. +####...#....# +####.....###. +##....###.##. +##...##...### +..###...##.#. +.....#.#.##.. +...#.##...... +####..#####.. +###.#....##.. +..######..### +....##...#..# + +.##.###....#### +#......#..##### +..#..#..#.##..# +#...##.####.... +.###...####.... +.###...####.... +#...##.####.... +..#..#..#.##..# +#.....##..##### + +#..##..#.#.#..# +....#.#.##.##.# +....#.#.#.####. +####.#.....##.# +.##...#.#..###. +.##...#.#..###. +####.#.....##.# +....#.#.#.####. +....#.#.#..##.# +#..##..#.#.#..# +####.#...##.#.# +#####..#.###..# +.....#.#.#.##.. +#..##.##.###.#. +#..#...##.#.#.# +....##.###.#..# +.##.###.....##. + +.#..#.##.####..## +#..##..#.#.#...## +#...#.#.##.#.##.# +##..###....#.###. +.###...#.#.####.# +.###...#.#.####.# +##..##.....#.###. +#...#.#.##.#.##.# +#..##..#.#.#...## +.#..#.##.####..## +.#....###..##...# +#.#.######..##### +...#.#..##...#### +.#.#####.....##.. +##.#.#.##.###.... +##.#.#.##.###.... +.#.#####.....##.. + +.#..#.#.#.##. +##..##.#..... +#....#.#.#### +#.##.#.#..##. +..##..#...... +##..##.##.##. +#....#.#..##. +######..##### +..##....##..# +#.##.#..##..# +.........#### +..##..#.##..# +.#..#..##.... +....#...##### +##..##..#.##. +.####.####..# +##..##.###### + +#....#..# +###..#... +##.###### +..##..#.# +..####.## +##...#### +##.#..### +.....#.#. +..##...#. +...#.###. +####..### +......### +...#....# +#####.#.# +..#.#..#. +..#.#..#. +#####.#.# + +#######...#....#. +###.#..##..#..#.. +#.###.#..#..##..# +#.###.#..#..##..# +###.#..##..#..#.. +#######...#....#. +#...#.#.##.####.# +..#.#.#.##.#..### +#.#...#.###....## +.######.....##... +#..#.#.##.##..##. +.##..#.##.#....#. +#.##..######..### +#...#.#..######## +#.###.#.......... + +#..#..#..##..#..# +#.############### +####..##....##..# +##.####......#### +..#####..##..#### +#.##..#..##..#..# +###.####.##.####. +##.#..#......#..# +.###..#.#..#.#..# +.#.#..#..##..#..# +##.####......#### +.##.##.#.##.#.##. +.######.####.#### + +#.#....#. +###..#..# +###..#..# +#.#....#. +.####..#. +..##..### +..#.#..#. +#..#..##. +.###.###. +...#..#.. +...#....# +###.#.### +....#.#.# +##.#.##.# +##.####.# +#..####.# +##.#.##.# + +......# +#####.# +......# +####.#. +.##...# +#..#.#. +.###.## +.....#. +.##.... +.##.... +.....#. + +...###.#.....##.. +#.######.#....... +#.##.###.#....... +...###.#.....##.. +.#..##..#.###..## +#..###.####...### +#####.#...#.##... +#####.#..###.#### +#########.#.##### +.#####....##..### +##.#..#..####..## diff --git a/day13.lisp b/day13.lisp new file mode 100644 index 0000000..861950c --- /dev/null +++ b/day13.lisp @@ -0,0 +1,46 @@ +(defun read-maps (filespec) + (with-open-file (stream filespec) + (loop for line = (read-line stream nil) + while line + collect (loop collect line + while (setf line (read-line stream nil)) + while (> (length line) 0))))) + +(defun count-diff (list1 list2) + (loop for string1 in list1 + for string2 in list2 + sum (loop for c1 across string1 + for c2 across string2 + sum (if (equal c1 c2) 0 1)))) + +(defun find-horizontal-mirror (map &optional (ndiff 0)) + (loop for prev = () then (cons (car rem) prev) + for rem on map + for i upto (length map) + if (and prev rem (= ndiff (count-diff prev rem))) + return i)) + +(defun rotate-map (map) + (loop for i below (length (first map)) + collect (coerce (loop for line in map collect (aref line i)) '(string)))) + +(defun find-vertical-mirror (map &optional (ndiff 0)) + (find-horizontal-mirror (rotate-map map) ndiff)) + +(defun solve (filespec &optional (ndiff 0)) + (let ((maps (read-maps filespec))) + (loop for map in maps + as aux = (find-horizontal-mirror map ndiff) + if aux + sum (* 100 aux) + else + sum (find-vertical-mirror map ndiff)))) + +(defun solve1 (filespec) (solve filespec)) + +(defun solve2 (filespec) (solve filespec 1)) + +(print (solve1 "data/13/example.txt")) ;; 405 +(print (solve1 "data/13/input.txt")) ;; 30535 +(print (solve2 "data/13/example.txt")) ;; 400 +(print (solve2 "data/13/input.txt")) ;; 30844 |