From 22a3cb76fefbfa8c444f1ae39a8a4304ad3950ba Mon Sep 17 00:00:00 2001 From: Alexandre Jesus Date: Wed, 3 Jan 2024 19:23:30 +0000 Subject: day13 --- data/13/example.txt | 15 + data/13/input.txt | 1387 +++++++++++++++++++++++++++++++++++++++++++++++++++ day13.lisp | 46 ++ 3 files changed, 1448 insertions(+) create mode 100644 data/13/example.txt create mode 100644 data/13/input.txt create mode 100644 day13.lisp 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 -- cgit v1.2.3