From 01432b8e0f0bde920bd6ac8d42bac9c43cab6eb8 Mon Sep 17 00:00:00 2001 From: Pim Kunis Date: Wed, 13 Dec 2023 15:50:49 +0100 Subject: [PATCH] add day 13 --- 23/elixir/inputs/day13.txt | 1385 ++++++++++++++++++++++++++++ 23/elixir/inputs/day13_example.txt | 15 + 23/elixir/lib/days/day13.ex | 56 ++ 3 files changed, 1456 insertions(+) create mode 100644 23/elixir/inputs/day13.txt create mode 100644 23/elixir/inputs/day13_example.txt create mode 100644 23/elixir/lib/days/day13.ex diff --git a/23/elixir/inputs/day13.txt b/23/elixir/inputs/day13.txt new file mode 100644 index 0000000..90797da --- /dev/null +++ b/23/elixir/inputs/day13.txt @@ -0,0 +1,1385 @@ +#.#.####.#.#.## +.#.##..##.#...# +.#..#..#..#.#.. +.##..##..##.#.# +....####....... +##...##...##..# +##...##...##..# +....####....... +.##..##..##.#.# +.#..#..#..#.#.. +.#.##..##.#...# +#.#.####.#.#.#. +..#.#..#.#....# +##.#.##.#.####. +..#..##..#....# +#..#.##.#..#.## +#.#.####.#.#... + +..#.....##. +.#..#..##.# +.......###. +####.##.#.# +###.###.... +###.###.... +####.##.#.# +.......#### +.#..#..##.# +..#.....##. +..#.....##. +.#..#..##.# +.......#### + +##.#.##...####. +#####..#...##.. +##.##.#.#####.# +.##.#..##..##.. +###..#.#####.#. +###..#.#####.#. +.##.#..##..##.. +##.##.#.#####.# +#####..#...##.. +##.#.##..#####. +...#...#....### +##.#.###.###..# +..#.###.#.#.... +####...#.#.#... +.#..#....##.#.# +....####.###.## +....####.###.## + +...#.###.###### +..##.##.##.##.# +####.#....#..#. +.#...#.#.#.##.# +.#..#.#.####### +##..#.#.####### +.#...#.#.#.##.# + +..##..##... +..#.##.#.## +...#.#.#... +##.#.####.. +...###.#.## +######.#.## +######..#.# + +.#..###.# +.###.##.# +....###.# +.######.. +...#.#.#. +...#.#.#. +.######.. +....###.# +.###.##.# +.#..###.# +####...## +..##.#..# +..##....# +####...## +.#..###.# + +##..####### +.#..#.#..#. +##..####### +.####..##.. +#....#.##.# +..##.#.##.# +#....###### + +##.###.#...## +######..##.## +######..##.## +##.###.#...## +.##.####...#. +####.##.#.#.. +##..###...### +#......#.#... +#...###.##.## +.#####...##.. +.##..###..... +.##.......#.. +#.######.##.. + +...#..........#.. +###.###....###.## +##.###.####.###.# +..###.#.##.#.###. +...##.#.##.#.##.. +#####........#### +..#.#.##..##.#.#. +..#####.##.#####. +...#...####...#.. +##..##..##..##..# +....#.##..##.#... +..#.####..####.#. +...##.##..##.##.. +..##..........##. +.....#..##..#..#. +###.#........#.## +..#...#.##.#...#. + +....####... +.##..##.### +.##..##.### +....####... +..#..#..... +####.#.###. +.###.###.## +...##...#.. +#...####.## +..#.####### +##..####.## + +..#######.# +##.#.###... +##.....##.# +#.#.###...# +...#..##.#. +...#..##.#. +#.#.###...# +##.....#..# +##.#.###... +..#######.# +#.##..#.#.# +#.##.##..## +#.##.##..## +#.##..#.#.# +..#######.# +##.#.###... +##.....#..# + +..#...#..#...#..# +########...##.##. +.#..#.#.#.#.##### +..##...##..##.... +.......########## +.#..#.##.#.#..##. +########...###..# +..##...###.##.... +#....#..#.#...... +##..###..#....... +##..##.##.##..##. + +####...## +......##. +.##.#.#.. +.......#. +.##.###.. +.##.##.#. +#..##.##. +....#.#.. +...#..#.. +.##..#... +.##.###.. +#..##..#. +#..##..#. + +##.#... +.###... +###...# +##.###. +...#... +...#.#. +###.### +....#.# +....#.# + +..#.#.#.......# +..#.#.#.......# +.#.#.#.#####.## +.##..###.#.#### +#.######.#.#.#. +#####.####.#.## +#####.####.#.## +#.######.#.#.#. +.##..###.#.#.## + +..#..#.##.# +..#..#.##.# +...#.#.#.## +.#...#..... +##...##.... +..#.#..#.#. +..#..#.#... +...#####... +...##.#..#. + +.##.######... +.....####.#.. +#..##.#..#.## +.##.###.#.### +#..#.####..## +....#..#.#... +####....#.... +####..##..... +.##.#....#### +###.###...#.. +.##......#... +.##..#..##.## +#..#..#.###.. +.....###..### +....#....#.## +.##..######## +.##..#.###... + +.#.####.#.##...## +..#.##.#......#.# +..#.##.#......#.# +.#.####.#.##...## +##..##..#...#..#. +#...##...##.###.. +##......##.#...#. + +#....##.#....## +#....#...#.#... +..##..#.#.##### +.#.##.#####.### +.#.##.#####.### +..##..#.#..#### +#....#...#.#... +#....##.#....## +.###.##.#...#.. +.#..###...#..## +#...#..###.#... +..###.##.##..## +#...##....#.#.. + +.##...#.....### +#..###.#..##### +#..#......###.. +.##.#####.##... +.##.#.##.#.#### +.....#.##.##... +#######.####.## +.......#.####.. +####..#..#..... +####...##.#.... +#.##.....##.#.. +....#####...#.. +....#.#.###.... +.##.#####.##### +.......##.#.### +#..#####.....## +#####.##.....## + +....#.##. +##..#.... +##...##.# +##......# +..#.#.##. +..#...### +......### +..#.#.##. +##......# +##...##.# +##..#.... +....#.##. +####..... + +.#..##. +#.#.### +#..#... +#...##. +####..# +#..#.## +#..#.## +####..# +....##. +#..#... +#.#.### +.#..##. +##..### +##..### +.#..##. +#.#.### +#..#... + +#..##..#....####. +..####..#.....##. +.#.##.#.####...## +.#....#...#...### +........#...####. +.##...#.##.##..## +#..##..##...#.... +..#..#...##..#... +#..##..#...#####. +.##..##.###..#.#. +.##..##.###..#.#. +#..##..#...#####. +..#..#...##..#... + +#....##.####.## +#...##.######.# +.##.#.##.##.##. +..##...#....#.. +#..#..#........ +#.#..#.######.# +#.##..#.####.#. +###.#.##.##.##. +#..#.#........# +#..#.#........# +###.#.##.##.##. +#.##..#.####.#. +#.#..#.######.# + +###.....###.##. +.....##.#.#..#. +.....##.#.#..#. +###....####.##. +...#...#..##.#. +..##.#...#....# +####.##.#..#... +######.##.#.### +######.#...#.#. +...#.#.####.### +###..##...#..## + +.###.#..####..#.# +.#...#.########## +#...###..##..#.#. +#...###..##..#.#. +.#...#.########## +.###.#..####..#.# +..###...#..###..# +..###...#..####.# +.###.#..####..#.# +.#...#.########## +#...###..##..#.#. + +##..##..# +...#..#.. +#.##..##. +.#..##..# +##..##..# +.#..##..# +#.##..##. +.#..##..# +..##..##. + +..#.##....#.. +#.#....#.#... +....##....... +..######..... +.########.#.. +#..#..#..#### +##......##... +#..#..#..##.. +..######..#.. +.##.##.##..## +..######..... +...#..#...#.. +##..##..##... + +....#..##..#..... +.#.#.#....#.#.#.. +.#.....##.....#.. +...######.###.... +....#.#..#.#..... +#.##..####..##.## +..#..........#... +##....#..#....### +.....#.##.#...... +###...#..#...#### +##.#.#.##.#.#.### +.##.########.##.. +..#....##....#... + +#..##..#.#.##.. +.#.##.#..##.### +###..####.#.### +.#.##.#......#. +.#.##.#......#. +###..####.#.#.# +.#.##.#..##.### +#..##..#.#.##.. +##.##.##.##..#. + +....#..##...### +......###.#.### +.##.###....#.## +....###.#..#.#. +....#.#.#.##.#. +#..##.#..#.##.. +#..##.#..#..#.. + +###.###..#.##.. +..####..###.... +..#..#..##..... +##.....#.....## +###......##...# +..#...#.##.###. +..#.....###..#. +..#.....###..#. +..#...#.##.###. +###......##...# +##.....#.....## +..#..#..#...... +..####..###.... +###.###..#.##.. +#####.......... + +...#..#.... +#...##...## +##..##..### +###.##.#### +...#..#...# +...#..#...# +###.##.#### +##..##..### +#...##...## +...#..#.... +#..#..#..## +#...##...## +#.#....#.#. +#..####..#. +##.#..##### + +.###..#.####.##.# +.#.#.##.##.###### +####.#.##........ +#..#.#.##....##.. +#..#.#.##....##.. +####.#.##........ +.#.#.##.##.###### +.###..#.####.##.# +.#.#..#.##.#....# +...###.#...#.#### +##..#####.##....# +.#.##.#..#.###### +.#.#.####..#....# +....##.##.#.####. +.##.##..##.#....# +....#.#.#.###..## +..##.###.....##.. + +......# +.#....# +#..#.#. +#..#.#. +.#....# +......# +#.###.# + +####...## +.....#### +..#..#..# +##.#.##.# +#.....#.. +##.####.. +..#....#. +#####..## +##.##.... +##...##.# +##.#.#... +##.#.#... +##...##.# + +#.#.#.. +#.#.#.. +###..## +..##.#. +##.#... +.##..#. +###..#. +###..#. +.##..#. +#..#... +..##.#. + +..#.#.##.#.#. +..###.##.###. +..####..####. +..#...##...#. +##.#..##..#.# +##..........# +###.#.##.#.## +..##########. +##..........# +#.##.####.##. +######..##### +..##.####.##. +##..#.##.#..# +#####.##.#### +...#..##..#.. + +#.#....#.#..... +.#.#....#.#.### +##.####.##.#### +....##....##.## +.#..##..#..#... +###....####.#.. +....##.....##.. +#.#.##.#.##..## +##..##..##.##.. +...#..#....##.. +##......###..## + +.#..###..#..### +.#..###..#..### +#.####..##.#..# +###...##.#.#.#. +.##....####.... +..#......##.##. +#.####..#.#.... +#...##..##..#.# +...###...#...## +.#..##.#...#... +.####.#..#..##. +.####.#..#..##. +.#..##.#...#... +...###...#...## +#...##.###..#.# + +######.#..#..#### +##.#...###....... +#..#####.#...##.# +#..#####.#...##.# +##.#...###....... +######.#..#..#### +#...#..###...#.#. +.###.####..#.#.#. +##.#.#...##.###.. +...#...####...#.# +...#...####...#.# +##.#.#...##.###.. +.###.####..#.#.#. +#...#..###...#.#. +######.#..#..##.# + +.#....#...##. +.##..#.#..#.# +#.##..#.##... +##.###.#.##.. +##.###.#.##.. +#.##..#.##... +.##..#.#..#.# +.#....#...##. +..##..###.... +..###...#..#. +#...##..###.. +.#..##.##.##. +.##.##.#...## +.#...#..#.... +.#...#..#.... +.##.##.#..### +.#..##.##.##. + +##......# +...####.. +..#....#. +..#.##.#. +..#.##.#. +..##..##. +##......# +##......# +..#.##.#. +#........ +##.####.# +..#....#. +##.####.# + +....####...## +###..#.##..## +###....##..## +....####...## +#..#.#..##.## +.#.#.#...#.## +##.#..#...... +..#.##.###... +#...#.#####.# +....##..#.... +###...###.### +###...###.### +....##..#.... +#...#.#####.# +..#.##.###... + +.#.##...#.#..## +...####.###.#.. +######.###..#.. +....#...#.#..#. +....#...#.#..#. +######.###..#.. +...####.###.#.. +.#.##...#.#..## +..#.#.###...... +#.#.#.##.#.###. +##....####..### +..##..#..####.. +.....###..#.#.# +##.###.###....# +#.#.#.#.#..#... +#...#.#.#..#... +##.###.###....# + +..##..#.#...#..## +####.####..#####. +####.####..#####. +.###..#.#...#..## +#....##.##.###..# +....#.###.#...#.. +#.##.#....###..## +.#......###..#... +.####.#.#.####### +##.#.#.###.#..#.. +#..#.###..#.###.# +##.......##...#.. +##.......##...#.. +#..#.###..#.###.# +##.#.#.###.#..#.. + +.#.#####......... +.##.#.#.#..####.. +#..#.#..####..### +###.##.#....##... +###...######..### +####.##.####..### +.#.##.#.#.######. +..####.########## +..####.########## +.#.##.#.#.######. +####.##.####..### +###...######..### +.##.##.#....##... +#..#.#..####..### +.##.#.#.#..####.. + +#.#.##.#.###..##. +..##..##..#..#### +#.##..##.#.###..# +##.####.##...#### +###....###..##..# +...#..#...#..#### +#.#.##.#.###..##. +.##.##.##.#..#..# +##..##..###..#..# +#..#..#..##..#..# +..######...###..# +##..##..####.#..# +#..#..#..####.##. +##########.##.... +##..##..###.#..#. + +#....#...#... +.####.#...... +##..###.#..#. +#....###.##.# +..##....#..#. +..##..##.##.# +.####..##..## +......#...... +.#..#..###### + +###..###...#. +..##..##.##.. +##.#.##..#### +##.##..#####. +#.##...#.#.#. +..##...##..#. +...##..##.#.. +##.#.##..###. +##...#....##. +##...#....##. +##.#.##..###. + +#....#.## +#.##.#..# +##..##.#. +.#..#.... +.#..#..#. +##..###.. +##..###.. +.#..#..#. +.#..#.... +##..##.#. +#.##.#..# +#....#..# +##..##### +.####...# +######.#. + +.###..###...##.## +#..#..#..#....#.. +#.#.##.#.#.###.#. +.#.#..#.#.#...### +#...##...#...#..# +###.##.###....### +...#..#...#..#### +##.####.##...#.#. +...#..#...####### +..........#.###.# +.###..###.#.#.#.# +.#..##..#..###.#. +#...##...#....#.# +###.##.####.##### +###.##.####.#.### + +.......##.#.. +.#.##.#..#.## +#####..###.#. +##...###.##.# +....###.#.... +.....###.##.# +...####..#... +..#.#...#...# +###..#.##.#.# +###..#.##.#.# +..#.#...#...# + +...##.. +.#..##. +##...## +####..# +#...#.# +.....#. +..#.##. +####.## +####.## +..#.##. +...#.#. +#...#.# +####..# +##...## +.#..##. +...##.. +...##.. + +.##.#..####.. +##........### +.#..#..#..#.. +#.#.####.#.## +..##.##.##... +.##.#..#.##.. +.#.#.##.#.#.. + +####..##### +....##..... +...####.... +##.######## +###.##.#### +.########.. +..#....#... +..##..##... +###....#### +...#..#.... +..#.##.#... +....##..... +#..####..## + +#..#..##..#.... +...#.##..#..### +..#####...#..## +..#####...#..## +...#.##..#..### +#..#..##..#.... +##.#..#........ +###..#.######.. +##.#.#.##...##. +##..##..#.###.. +#..##....#..... +.#..##..##.#.## +.#.##..#..##... + +.##.##....# +##.##.#...# +.###.#..#.. +###.#.##### +##.#.#.#..# +#.#######.. +#..#..#..## +#.#..####.# +#.#..####.# +#..#..#..## +#########.. +##.#.#.#..# +###.#.##### +.###.#..#.. +##.##.#...# +.##.##....# +.##.##....# + +#.#..#### +###...### +#....#.## +##.###### +#.##.#.## +.####.### +...###... +.#.#..#.. +##.#..### +##.###### +##..##### + +...#..... +...#..#.. +######... +##.#.#.## +###..#... +.#.##.#.. +##....... +.#.#.#### +#..##.### +.###..... +#..###### + +.#..##... +#...####. +.#.#.#### +....#..## +....#..## +.#.#.#### +#...####. +.#..##... +..###.... +##.#..##. +.#####..# +##.....## +.##....## +.##....## +##.....#. + +####.#.## +.##.#.... +#####..## +.....#... +.##....## +#..#.#.## +####..#.. +#..#.##.. +.##.####. + +...#.#.##...##... +##....#.#.######. +##.#.#....#.##.#. +###..##.#.##..##. +###.....######### +..##.#.#...####.. +.#.#.......####.. +###.#.#.#...##... +##.########....## + +###.##.#. +.#.###... +######.#. +.#.#...## +.#.#....# +######.#. +.#.###... +###.##.#. +###.#..## +..######. +#.##...## +..####.## +.#.....#. +.#.....#. +..####.## +#.##...## +..######. + +.#.##.#........ +#####.#...##... +##.#.####.##.## +#####.#.#....#. +#.####...#..#.. +..#.#####.##.## +##.#.#...#..#.. +.#.#.##..#..#.. +.###....#.##.#. +#..#.##.##..##. +#.#.##...#..#.. +###...#..#..#.. +###...#..#..#.. +#.#.##...#..#.. +#..#.##.##..##. +.###....#.##.#. +...#.##..#..#.. + +###.....# +#.#.#.##. +#.##.##.# +...###### +...###### +#.##.#### +#.#.#.##. +###.....# +#.##.##.. +#.##.##.. +###.....# +#.#.#.##. +#.##.#### + +...#....#...#.. +.####...###.#.# +####....######. +#...####...##.# +##.######.###.. +#.#.####.#.##.# +...##..##...##. +..#.####.#....# +####.##.####..# +..............# +.###....###.#.# +#.###..###.##.. +#.###..###.##.. +.###....###.#.# +..............# + +#...#.####.#.#. +.#.##..##..##.# +#....######.... +#.###..##..###. +##.#.#....#.#.# +..#.##.##.##.#. +..#.##.##.##.#. +##.#.#....#.#.# +#.###..##..###. +#....######.... +.#.##..##..##.# + +###.... +...#### +##..... +#...##. +#..#### +###.... +..##### + +......##.#.##.#.# +..#####.##....##. +##.#..#.#.####.#. +..##.####..##..## +####..#.#..##..#. +##.#...#........# +..##...#...##...# +####...#.#.##.#.# +###...##..#..#..# +###.#####..##..## +....###.##....##. +....#..##.#..#..# +..#.##..#......#. +...#.#.....##.... +..#...###..##..## + +###.#########.# +...######..#.#. +...######..#.#. +###.#########.# +..#.....###.### +.##.###.#..#... +....#.#...#.#.# +#####.#...##.#. +#.##.##.##.#### +#.##.##.#..#### +#####.#...##.#. + +####.#.##.# +##.#.##..## +##.#.##..## +###..#.##.# +..####.##.# +##.#...##.. +#.#.####### +#......##.. +.#...#.##.# +.#.##.#..#. +.#....####. +##...##..## +.#..###..## + +##......##.## +#####..##.### +..#..###.#### +####.....#### +####..###...# +##.#.#...#... +#####.##...## +..###.#####.. +##.##.....### + +.###..##..# +.###..##..# +...##...##. +..##.#.#### +##.#.##.#.. +.##...#..## +##.#.#.###. +##..##..##. +##.....##.. +.##...#..#. +..##.###### +..#.##..... +..#.##..... +..##.###### +.###..#..#. + +#.####.#..##..#.. +##....##..#####.. +#..##..##....##.. +.#.##.#..#....### +###..######..#... +##.##.###.##..#.. +..#..#....#...### +.##..##.##.#.#### +.##..##..##.###.. +.#....#.#..#.##.. +#..##..#####.#... +#..##..###.#####. +.#....#.####.##.. +...##...#.#...#.. +.######.####.#... + +##....##.#.## +#..###.#.##.. +.##.......##. +.##...#.#.### +.#.....#.##.. +.###...#..##. +.###...#..##. +.#.....#.##.. +.##...#.#.### +.##.......##. +#..###.#.##.. +##....##.#.## +##....##.#.## +#..#.#.#.##.. +.##.......##. + +##..##...##.#..#. +##..##...##.#..#. +#.##.###.#.##..#. +#....########.##. +........#.###.### +.####..####.#.#.. +#....##.#...#..## +##..###..#..#..## +#.##.#..###.#.... +######.#..##.#.## +#.....####..##..# +..##..##...#.##.. +##..###...#..##.. +######.######.##. +#....######...##. + +.#..#.# +####... +..###.# +..###.# +.###... +.#..#.# +#.##### +..##..# +#.....# +#.#..## +#.#.### +.#.#.#. +..#.### +.....## +#...... +###...# +###...# + +.#######. +########. +###..###. +#......## +###..###. +..#..#..# +.#....#.# +#.####.## +#.####.## +.#....#.# +..#..#..# +###..###. +#......## +###..###. +########. +.#######. +##....##. + +.#..####. +.#..####. +.####.#.# +..###.##. +...####.# +###.....# +.#.###.## +.....##.. +.....##.. +.#.###.## +###.....# +#..####.# +..###.##. + +....#.# +....#.# +.###.#. +.##...# +..##... +#.#..## +#####.# +#####.# +#.#..## +..##... +.##...# +.###... +....#.# + +#......##..#..#.. +.###.##.##.#..#.# +#......#.#..##..# +#.#..#.#..######. +........##.####.# +##....##.##.##.## +#.#..#.#.#..##..# +#.#..#.###..##..# +###..####.######. +..####..#.#....#. +#.#..#.####.##.## +###..######....## +.#.##.#.##.#..#.# +.#....#..#..##..# +#.####.##.#....#. + +#.#...####.#.#### +#.#...##.#.#.#### +.###.#.####..#### +..#.#.#...##.#... +###...######.##.. +#....##.#...#...# +#.#...#..#..##... +#..#.....###..#.. +#.#..#..##.#.#..# +...#..##......### +##....########.## +###.#...#.....### +.#####..##..#..## +.#####..##..#..## +###.#...#.....### +##....########.## +...#..##......### + +#..####..## +.#.####.#.. +.#..##..#.. +#........## +#..####..## +.###.####.. +##.#..#.### +.##.##.##.. +..##..##... +#.##..##.## +#..#..#..## +#.##..##.## +.#......#.. +#..####..## +###.##.#### +..######... +.##....##.. + +.#..##. +.###### +.#.#### +.###### +.#..... +.#.#### +#.##### +..##..# +..#.... +.##.##. +....##. +....##. +.##.##. +..#.... +#.##..# + +...####.### +#..#...#... +###.###.#.# +###.###.#.# +#..#...#... +...#.##.### +...#.##.### +#..#...#... +###.###.#.# + +......####..#..## +......####..#..## +#.##..##..#..#... +.####..#....#.#.# +..##.#..#..###..# +####...#.#.....#. +#.#.#..###..#.... +##.#.####...###.# +.####.#...###.#.# +.##...#.#..###.## +..##..##.##..#.## +#.##.#.#.#....#.. +##.#.####....##.. +##.#.####....###. +#.##.#.#.#....#.. + +#.#..#.#...#..#.. +.....##..###.##.# +##...###.##...... +#.##..#..##.##.## +....####.####.... +####.#.#.##..#... +##.##.#..##.###.. +###.#.#.##...#... +.#....#.#.###.... +#..###.##........ +........#...##### +........#...##### +#..###.##........ +.#....#.#.###.... +###.#.#.##...#... + +#..##..#### +.#.#...#### +#.#..##.##. +#..###.#..# +#.....##### +#.#....#..# +##..#.#.##. +.#..#.#.##. +#.#....#..# +#.....##### +#..###.#..# +#.#..##.##. +.#.#...#### + +.###..### +##.####.# +.#......# +.#......# +##.####.# +.###..### +..#.####. +###.##.## +..######. + +####..#...##. +.##.##.###### +#..##..#.#..# +...##..#.#..# +.##.##.###### +####..#...##. +.##.#.#.#.##. +...#.#.##.##. +#.#....#..##. +....##.#..... +.#.###..##### +.#..####..##. +..###...##..# +...##.####..# +##..####..##. +..##.##..#..# +.#....#...##. + +#.##.###.#### +#.#.##.###.## +###.#####.#.. +#.#....#.#.## +..##.....#.## +##..###...### +#..#..#...#.. +#..#..#...#.. +.#..###...### + +#.##### +.#..... +.#.#..# +.#..##. +.##.... +..#.... +.#..##. + +..##.##.##### +####....##.## +..##.#.....#. +..###..##.#.# +#....##...### +...####...### +...#.##...### +#....##...### +..###..##.#.# +..##.#.....#. +####....##.## +..##.##.##### +..##.##.##### + +##.#### +.#..### +.#..### +##.#### +#..##.. +..#.##. +.##.### +#...#.. +#..#### +###.#.. +##...## +##..#.. +#..##.. + +.####..#####..# +#..#....#..#### +#..######..#..# +#####..######## +...#....#...##. +##..####..##..# +#...#..#...#..# + +.##..##.###...##. +.##..##.###...##. +......##.###.#..# +....##...#...#..# +...#.....##.#..#. +#####.#.......#.# +.##.#.#.#...##.#. + +.#...## +#..#### +#.#.##. +...###. +.##..## +#####.. +..#.... +..#.... +#####.. +.##..## +...###. +#.#.##. +...#### +.#...## +.#...## + +#.##..##.#####..# +.#......#.#.##... +.#......#.#.##... +#.##..##.######.# +.##.##.##.#...#.# +####..####.#####. +...........#.##.. +###....####..#.## +.#......#.###..#. +##......##..##### +#.######.#....##. +.##....##...#..#. +#.##..##.#...#... + +####.#.#.##.# +####...###### +....#........ +#..#.#.#....# +#..#....####. +#..#.####..## +#..#.#..#..#. +#######..##.. +#..#..##....# +######.##..## +.##..#..#.... +####...##..## +.##..#.#....# diff --git a/23/elixir/inputs/day13_example.txt b/23/elixir/inputs/day13_example.txt new file mode 100644 index 0000000..3b6b5cc --- /dev/null +++ b/23/elixir/inputs/day13_example.txt @@ -0,0 +1,15 @@ +#.##..##. +..#.##.#. +##......# +##......# +..#.##.#. +..##..##. +#.#.##.#. + +#...##..# +#....#..# +..##..### +#####.##. +#####.##. +..##..### +#....#..# diff --git a/23/elixir/lib/days/day13.ex b/23/elixir/lib/days/day13.ex new file mode 100644 index 0000000..be03897 --- /dev/null +++ b/23/elixir/lib/days/day13.ex @@ -0,0 +1,56 @@ +defmodule AOC.Day13 do + use AOC.Day, day: 13 + + def parse_input(lines) do + lines + |> Enum.chunk_by(&(&1 == "")) + |> Enum.reject(&(&1 == [""])) + |> Enum.map(fn pattern -> + Enum.map(pattern, &String.to_charlist/1) + end) + end + + def find_horizontal_reflection(pattern, required_differences) do + Enum.find(1..(length(pattern) - 1), fn cut_size -> + {upper_pattern, lower_pattern} = Enum.split(pattern, cut_size) + + upper_pattern = + upper_pattern + |> Enum.reverse() + |> List.flatten() + + lower_pattern = List.flatten(lower_pattern) + + differences = + Enum.zip(upper_pattern, lower_pattern) + |> Enum.count(fn {symbol1, symbol2} -> symbol1 != symbol2 end) + + differences == required_differences + end) + end + + def find_vertical_reflection(pattern, required_differences) do + pattern + |> List.zip() + |> Enum.map(&Tuple.to_list/1) + |> find_horizontal_reflection(required_differences) + end + + def calculate_summary(patterns, required_differences) do + Enum.map(patterns, fn pattern -> + case find_horizontal_reflection(pattern, required_differences) do + nil -> find_vertical_reflection(pattern, required_differences) + x -> 100 * x + end + end) + |> Enum.sum() + end + + def part1(input) do + calculate_summary(input, 0) + end + + def part2(input) do + calculate_summary(input, 1) + end +end