From 3fae7cf6782a99a9977eb261679769d42be030cd Mon Sep 17 00:00:00 2001 From: Lea Date: Wed, 13 Dec 2023 10:54:39 +0100 Subject: [PATCH] day 12 --- Cargo.lock | 8 + day_13/input.txt | 1407 +++++++++++++++++++++++++++++++++++++ day_13/part_1/Cargo.toml | 8 + day_13/part_1/src/main.rs | 57 ++ day_13/part_2/Cargo.toml | 8 + day_13/part_2/src/main.rs | 75 ++ 6 files changed, 1563 insertions(+) create mode 100644 day_13/input.txt create mode 100644 day_13/part_1/Cargo.toml create mode 100644 day_13/part_1/src/main.rs create mode 100644 day_13/part_2/Cargo.toml create mode 100644 day_13/part_2/src/main.rs diff --git a/Cargo.lock b/Cargo.lock index 9e33264..1e971dd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -52,6 +52,14 @@ dependencies = [ "regex", ] +[[package]] +name = "day_13-1" +version = "0.1.0" + +[[package]] +name = "day_13-2" +version = "0.1.0" + [[package]] name = "day_2-1" version = "0.1.0" diff --git a/day_13/input.txt b/day_13/input.txt new file mode 100644 index 0000000..54d6dec --- /dev/null +++ b/day_13/input.txt @@ -0,0 +1,1407 @@ +.#.#### +##..#.# +##..#.# +.#.#### +..#..#. +####.#. +#.#.#.# +.#..#.# +##.##.. +#.#..#. +#.#.... + +.##.....#....#. +.##.....#....#. +..#.#..##....## +...###...#..#.. +#..##.....##... +.#.#...#.####.# +#.#.....######. +##..###...##... +#..#..##..##..# +.##.#.#........ +#..#..##..##..# +#####.#.##.###. +.#....##.#..#.# +..##.#...#..#.. +#..####..#..#.. + +.##......## +.##......## +.#.#.##.#.# +#.########. +#.##....##. +#.######.#. +####....### +##.#.##.#.# +###......## +...######.. +####.##.### + +....#.### +#.#..#### +##....... +##....... +#.#..#### +....#.### +#..##.#.# +#.##...#. +#.##..#.# +####..#.. +#.#.###.# +#.#..##.# +####..#.. +#.##..#.# +#.##...#. + +##.####.# +.###.#### +###...### +###...### +.###.#### +#..####.# +..###..#. +##..#..#. +####...#. +#....#.#. +...#..... +#....#.## +#.#.#.##. +#.#.#.##. +#....#.## +...#..... +#....#.#. + +.##..#..#..#..# +#....##.##.##.# +......#..###### +......#..###### +#....##.##.##.# +.##..#..#..#..# +######..#.#.### +.#..#.....#.#.. +#...#..#.#.##.# +.###....#..###. +.###....#..###. +#...#..#.#.##.# +.#..#.....#.#.. +######..#.#.### +.#...#..#..#..# + +.######.#.#..#. +#..##....##..## +#.#.#.###.#..#. +#.#.#.###.#..#. +#..##....##..## +.######...#..#. +#.#.#..#..####. +#.#...######### +.....###.##..## +.#.#....###..## +.#...#...#....# + +#.##.#......#.# +#.##.#......#.# +..##.#.......#. +.##.##.##.##... +#.#.##...#.#### +##...#.##.#.##. +.#..#.##.#.#..# +.#..#.##.#.#..# +##...#.##.#.##. +#...##...#.#### +.##.##.##.##... +..##.#.......#. +#.##.#......#.# + +..#..#..#..#. +##.#.####.#.# +####......### +#####.##.#### +..#.#.##.#.#. +####..##..### +...#......#.. +##.###..###.. +...#..##..#.. +##.##.##.##.# +##.###..###.# +####......### +..#.##..##.#. +##..........# +##.##....##.# + +.#.#....#.#...... +...##..##.......# +#..######..#.##.. +.###....###.##... +.#.#.##.#.#..#... +..###..###....... +###..##..####.### +#..##..##..##.#.. +....#.##....#...# +###.#..#.###.#.#. +#.#......#.##..#. +#.#......#.##..#. +###.#..#.###.#.#. + +#.##..##...##.. +##.#.#.####..## +##..#..#.#.##.# +##.###.##...... +####...####..## +##.#.#.####..## +##.#.#.####..## +####...####..## +##.###.##...... +##..#..#.#.##.# +##.#.#.####..## +#.##..##...##.. +#...#.######### +.##.###.#.#..#. +......####.#### + +##..##. +.##.... +.##.... +##..##. +#.###.# +#.##..# +.###### +.###### +#.##..# +#.###.# +.#..##. + +....#.. +##.#.## +..#.#.. +....### +##.#.## +##.#### +###.... +##.##.. +....#.. +.....## +#####.. +##..... +....#.# +####.## +##..#.. + +.#.##.#.....#.#.# +###..###.#####... +###..###.#####... +.#.##.#.....#.#.# +.#....#..#.###... +#.#..#.#####..##. +#.####.##......#. +##.##.##.##.##..# +###...##.##....## +#.####.#####.#### +##.##.##.##...... +#########.#.####. +###..####..###... + +#..####..#..#..## +###.##.####.#.##. +..######.....#.## +###.##.#####...#. +#.#....#.#.#....# +##.####.###.#.#.. +###....###.#.#.## +###.##.####.##### +...#..#....##...# +...#..#....##...# +###.##.####.##### +###....###.#.#.## +##.####.###.###.. +#.#....#.#.#....# +###.##.#####...#. + +####..##. +####...## +.....###. +...###### +######... +....#.... +####..#.# +####..#.# +....#.... +######... +...####.# +.....###. +####...## + +#...#..#. +#...#..#. +####....# +#..###### +...###### +###...... +...##..## +###.####. +#.#....#. + +.####.. +##.#.#. +##.#.#. +.####.. +#..#..# +.....## +.#.#..# +..#.#.# +..#.#.# +.#.#..# +.....## +#..#..# +.#.##.. + +#.#.#....##.. +.####.#.####. +.####.#..###. +#.#.#....##.. +..#...###.... +..#...###.... +#.#.#....##.. +.####.#..###. +.####.#.####. +#.#.#....##.. +##.#.####...# +..#..#..#.##. +##.#######..# +.##..####...# +###..##....## +.######.##... +.#..#.##..##. + +......# +##...#. +.#....# +.#....# +.#...#. +......# +#..###. +...#..# +#.#..## +#.#...# +#..##.# +#..##.# +#.#...# +#.#..## +...#..# +#..###. +......# + +##..#.#.... +####..#.##. +#.#.#..#### +..#....#..# +..#....#..# +#.#.#..#### +####..#.##. +##..#.#.... +####...###. +#....###### +#...###...# +..#####..#. +..##.###.#. +..##.###.#. +..###.#..#. + +..........#.### +..######...##.# +.#......#...... +#.##..##.#..... +##.####.##.#.## +#...##...###..# +#...##...###..# +##.####.##.#.## +#.##..##.#..#.. + +..#.......##.#. +#.#.#...####..# +.#..##.#.#.#.## +.#..##.#.#.#.## +#.#.#...####..# +..#.......##.#. +..#..#####....# +.#.#.#......### +.#.###......### + +...#.##.# +....#..#. +#..##..## +...###### +.#.#....# +.#.#....# +...###### +#..##..## +....#..#. +#..#.##.# +###..##.. + +.#.####.#.... +#.#....#.#... +###....##.### +#.##..##.#.## +.#.#..#.#.### +#.######.#... +#.##..##.#### + +##.#.## +#...... +#...#.# +####.## +.#.#..# +...#### +...#### +.#.#..# +####.## +#...#.# +#...... +##.#.## +.#..#.. +#..#..# +#.....# + +#.########.#. +..##....##..# +..##....##..# +#.########.#. +.##..##..##.# +#.##....##.#. +.#.....#..#.# +...#.##.#.... +#..........#. +.#...##...#.. +.##.#..#.##.. + +.##..#..#.##.#. +#..#.##...##... +#######..####.. +#######..####.. +#..#.##...##... +.##..#..#.##.#. +.#.....#.#....# +......###.#..## +.......#.###.#. +####.##..#..#.# +....#.#.##.#..# +######.######.. +....#..##.###.. + +##.#....#.. +##.#...##.. +.###.##.#.# +##.####.... +...##....#. +..#....#.#. +.....##..## +.#..####... +.#..####... +.....##..## +..#....#.#. +...##....#. +##.####.... +.###.##.#.# +##.#...##.. + +##.####.# +.#.####.# +.#.####.# +##..##..# +####..### +##.####.# +#.#....#. + +...#..##. +......##. +#...##### +#..#.#### +...###### +.#.###### +##...#..# +###..#### +##..#.... + +###..###. +####.#.#. +..#..##.# +###.#...# +......##. +..###.### +..#...### +##..#.#.# +##....... +..#...... +######... +#####...# +##..##.## +###....#. +###.#.### +#####..## +#####.### + +..#..###... +..#...##... +##..###.##. +#.#..###..# +.####...##. +#.###.#.### +..##.....## +#.#..##.#.# +######.#.#. +.####..#..# +.##.##..... +..#......## +..#......## + +..#...##...#..# +..####..####... +.#.#.#..#.#.#.. +###.#.##.#.###. +..##.####.##... +#..###..###..#. +#....####....#. +..#.######.#... +..#.######.#... +#....####....#. +#..###..###..#. +..##.####.##... +###.#.##.#.###. +.#.#.#..#.#.#.. +..####..####..# +..#...##...#..# +##.##.##.##.##. + +.###..#.# +..#...#.# +##.####.. +#..#.#### +....##... +....##... +#..#.#### +#..####.. +..#...#.# +.###..#.# +.###..#.# + +#..##..##...##... +........######### +##....########### +#.#..#.#.#.#..#.# +.##..##..##....## +###..############ +#########...##... +.#.##.#.######### +..#..#..###....## +###..#####.#..#.# +.#.##.#..######.# +..#..#..#..#..#.. +..####..##..##..# +#.####.########## +##.##.##.#.####.# +..####..#..#..#.. +########...####.. + +..#.#....#.#..##. +###.###.##.###..# +##.#......#.##..# +#....####....#..# +.##.#....#.##.##. +.#....##....#.##. +....######....... +#....#..#....#..# +##.#.#..#.#.##### +#.#...##...#.#### +#.##.####.##.#..# +#####.##.######## +.##..#..#..##.##. +.###......###.... +#..#.#..#.#..#..# + +#.#.#.#.#.####. +...########..## +..#.###.###..## +..#.#.#.###..## +#...#..#...##.. +.##..########## +#..#.....##..## + +#.###..##.#...... +#.###..##.#...... +.#.#...#....#..#. +#.#####..###..... +#####......#.###. +....#.###.#...### +....##.#.#.##..#. +#.##.#...#...##.# +..##..#.######### +#.#..###.#..###.# +#.#..###.#..##### +..##..#.######### +#.##.#...#...##.# +....##.#.#.##..#. +....#.###.#...### +#####......#.###. +#.#####..###..... + +......# +....#.# +#..#.#. +.#.#### +.#.#### +#..#.#. +....#.# +......# +.####.# + +....#.##.##..##.. +####..#.##.#.##.# +.#.....#.###....# +###.####......... +#.##.#.#..###..## +##.#.####.####### +####.##.#....##.. +#######.#....##.. +##.#.####.####### +#.##.#.#..###..## +###.####......... + +###..#...##...#.. +..#.####.##.####. +##.#..#......#..# +..#..#........#.. +###.#.########.#. +##.#...######...# +###.############. +##.#.#..####..#.# +##..#.#.####.#.#. +..#...#..##..#... +###.#####..#####. +#.#.###.####.###. +##..###.####.###. + +##.##.####..##.## +###..####..#..#.. +#.####.##..##.#.. +..####..#..#...#. +##.##.##....#...# +#.#..#.####.#.#.. +............#...# +#..##..#...#..##. +#......#.##...##. +.#.##.#.###.##..# +##.##.####.####.# +##.##.####.####.# +.#.##.#.###.##..# +#......#.##...##. +#..##..#...##.##. +............#...# +#.#..#.####.#.#.. + +.##..###.####..#. +.###...####.###.. +##...#..##.#.###. +##.##.#.##.##.#.# +##.##...##.##.#.# +#.##...#..##.##.. +.###....#####.#.. +..####.#..#..###. +..####.#..#..###. +.###....#####.#.. +#.##...#..##.##.. +##.##...##.##.#.# +##.##.#.##.##.#.# + +##.##..###. +##.##.#..#. +......#...# +......#...# +##.##.#..#. +##.##..###. +###....#.#. +#.#..#..#.. +#.##...#.#. +..####.###. +..####.##.. +#.##...#.#. +#.#..#..#.. +###....#.#. +##.##..###. +##.##.#..#. +......#...# + +###.############. +...#.#.######.#.# +##.......##...... +##.....#....#.... +####....####....# +..##.##.#..#.##.# +...######..###### +####.##..##..##.# +#...##..#..#..##. +..#.#.#..##..#.#. +.....#.#....#.#.. +#####..#.##.#..## +...#..##....##..# +####...#.##.#...# +###.#..#....#..#. + +....##..#.#.. +....#...##### +....#...#.### +.##..#...#... +....###.####. +#..##.#.##... +####..#####.. +#####..#.##.. +####...##.... +#####.#...### +#..###.####.. +.##.####..### +####.###..### +....#...#.... +.##...####### + +...###### +#.#..##.. +.#.###### +#...##### +..####### +#####..## +#.#.####. +.#...##.. +.#..#..#. +#...#..#. +.###.##.# +..##.##.# +..##.##.# +.###.##.# +#...#..#. + +##...#. +##...#. +.###### +###...# +.#.#.#. +...#.#. +#..#.## +#..#.## +...#.#. +.#.#.#. +##....# +.###### +##...#. + +##..#..## +##.#..... +##...##.. +#.###.... +###..#.## +#####.### +##.####.. +#####.### +....#.### +..##...## +..####... +..###.... +...###### +#######.. +###..#... + +####....##### +#####...#.##. +......#.##..# +....####.#### +....##...#..# +#..#.#....#.. +.....#...#..# +########..... +#######.#.##. +#..##..#.#..# +#..##.....##. +.....##.#.##. +.##.#.#.#.##. +########.#### +#..#...#..##. + +.#####.#.## +.#####.#.## +...#......# +.#.#..###.# +###.###.#.# +###..#...## +##.#####... +##..##..#.# +..##.####.# +#.#.#..#### +#.#.#..#### +..##.####.# +##..##..#.# +##.#####... +###..#...## +##..###.#.# +.#.#..###.# + +##......##### +#..#..#..##.# +#.#.##.#.#### +##..##..##..# +..#....#...## +###########.. +..######..##. +#.....#..#..# +.##....##..## +###.##.###... +#........#..# +##..##..###.. +##..##..###.. + +#.#..#.#..#.#.. +#.##.#.#..#.#.# +#.##.#.#..#.#.# +#.#..#.#..#.#.. +...#...#..#...# +...##..#..#..## +..#...#....#... +.##.#.######.#. +.....#......#.. +#######....#### +#.#.###.##.###. +##...#......#.. +#.##.#.####.#.# +#.###..#..#..## +###..##....##.. +#.###..#..##.## +#.#.....##..... + +...#.#..#.#...... +##..#....#..####. +#####....######## +##.#......#.####. +#.#...##...#.##.# +##..........####. +#.##########.##.# +.#####..#.###..## +.############..## + +..#.##..# +..#.##..# +.###..#.. +##.#..##. +#...#.#.. +###.#..#. +##.#.#### +..#...#.. +##.#....# +..###.#.. +#.#.###.# +.#.#####. +...#....# +...#....# +.#.#####. +#.#.###.# +..###.#.# + +..#...#.# +.#....#.# +#..#####. +..#####.. +...##...# +#.##..... +#.##..... +...##...# +#.#####.. +#..#####. +.#....#.# +..#...#.# +.#..#.##. +.#..#.##. +..#...#.# + +.#.####.##.#### +##.....#..##### +#.#.#......#### +##.#.#.#..##### +.#.########.##. +#.....##....##. +.#..#....##.##. +#..#.#....##.## +##.###.####.##. +##.##....#..... +#.##.##.####..# +.##..###.#..... +.##..###.#..... + +......#..#. +.......#..# +.......#..# +......#.... +######.#### +#.##.##.... +#######.##. +######.#..# +######..#.. +#########.. +......####. +#.##.###... +######.#.## +##..##.#... +#######.... +..##...#### +.......##.. + +.##.#####..#. +##.#..#.#.... +.#.###.##.#.# +##.###.....#. +..#..#.###..# +##..#.#....## +##..#.#....## +..#..#.###..# +##.###.....#. +.#.###.##.#.# +##.#..#.#.... +.##..####..#. +.##..####..#. + +#...#..##.#.#.. +#.#..##.####.#. +#.#..##.####.#. +#...#..##.#.#.. +.#.#...#..###.# +......#.....### +....##..#.##### +##...####.#.##. +#...#...##..### +...###.##..##.# +...##..##..##.# + +###..####.. +###..####.. +##....#.... +.####.###.. +###.###.#.. +##.###..### +....#.#..## +#.#..#..#.. +..#...##### +.#.####.... +##......##. + +##.##.#.#.. +###.#..##.. +..##.##.##. +#.#..#.#.## +#.###....#. +#..#.#...## +...##.###.# +...##.###.# +#..#.#....# +#.###....#. +#.#..#.#.## +..##.##.##. +###.#..##.. +##.##.#.#.. +.###.#..##. +#.####..#.# +#.####..#.# + +####....####... +...#....#...#.. +..##....##..... +...##..##....## +....####....#.. +#...####...#... +.#...##...#.### +.#........#.... +.....##........ +#..........#... +.#.#.##.#.#.### +##..#..#.###.## +.##......##..## +###.#..#.###.## +#...####...#... +..##....##..### +#.#.####.#.#... + +####..#.. +....####. +......##. +.##...### +.##...### +......#.. +....####. +####..#.. +.##.##.#. +.##..#.#. +#######.# +....###.# +######..# + +#.##.#..#.. +#.##.##.#.. +#.##.##.#.. +..##....#.. +..##...#.#. +#....###.## +..##...##.# +.#..#..##.# +#.##.##...# + +.#.########.#.. +####.......###. +#.###.##.###.## +..#........#..# +...##....##.... +###..#..#..###. +##.########.### +##.########.### +###..#..#..###. + +...##.....# +.##..##.... +..####..##. +#..##..#.## +#..##..#.#. +###..####.. +.#..#.#.### +.##..##.#.# +##....##### +..#..#....# +##....##..# +.#.##.#.### +...##...##. +##....###.. +##....###.. +...##...##. +.#.##.#.### + +#....######.# +#.##.#..#.#.# +.####.#...##. +#######.##... +##..#####.#.. +......###...# +......###...# +##..##.##.#.. +#######.##... +.####.#...##. +#.##.#..#.#.# +#....######.# +..##..###.#.. + +..####...##.. +.##..##..##.. +#.#..#.#....# +##....##....# +#.#..#.##..## +#.####.#.##.# +##.##..#.##.# +########....# +...##...####. + +##..... +..#.##. +###.### +.#.#### +.###..# +.###..# +.#.#### + +#....####.### +#....####.### +.#..#...##.## +#.##.#...#### +.#..##..#.... +.#..#.#...#.. +.####...##... +#.##.#.#.#.#. +..##...#####. +##..##.##.##. +#....###.#..# +.#..#.#..##.# +.......#.#... +.#..#.#.####. +......#..#... +##..##..##.#. +.#..#..#.###. + +#.#######.#.#.. +..#.#...#...#.. +#......#...#.## +##..##....###.. +.#.##.###.##### +###..#.#..##... +###..#.#...#... +##.#.##.##..### +.####.##..#..#. +..#####...##.## +..#####...##.## +.####.##..#..#. +##.#.##.##..### +###..#.#...#... +###..#.#..##... + +##.##.##.###.#..# +##.###.#..##..##. +.###..#.##..###.# +#.#...##.#####..# +..#.#.....#..#### +#...#.#..####.##. +#.#...####.#.#### +..#.#.#..##.#.##. +....##..##..##### +.#..##...#.###..# +.##.#..#..#.##..# +.##.#..#..#.##..# +.#..##...#.###..# +....##..##..##### +..#.#.#..##.#.##. + +####... +#.##### +..##### +####... +#....## +.###.## +.#..#.. +###.### +##...## +.###.## +#.##### + +..######... +.#......#.. +#....#...#. +##......### +.##....##.# +...####...# +.#.#..#.#.# +.#..##..#.. +#........#. +#.#.##.#.## +.#.####.#.# +.#.#..#.#.. +.#.####.#.. +.#.####.#.. +.#.#..#.#.. + +##.#......#.##. +##.#......#.##. +####......##### +###..#..#..###. +...#......#...# +#...#.##.#...#. +##....##....##. +##.###..###.##. +.###......##..# +...########.... +###.#....#.###. +..###....###..# +#.#.#.##.#.#.#. + +.######.######.## +.#.##.#...##...#. +##....####..####. +.##..##........## +#.#..#.#.####.#.# +##.##.###....###. +.#....#.#....#.#. +.#.##.#.#....#.#. +..#..#..######..# +########..##.#### +...##............ +#.####.#......#.# +..#..#..######..# + +.#.##...... +...##...... +..#..##.#.. +..#.#..###. +....#...#.. +#.#..##..## +...##.#.### +..#.###..#. +..#.###..#. +...##.#.### +#.#..##..## +....#...#.. +..#.#..###. + +#..#.####.#..## +#..###..###..#. +#.#.#.##.#.#.## +##..#.##.#..### +.##.##..#..##.. +..#..#..#..#... +##..#....#..### +.##.#....#.##.# +...#..##..#...# +....#....#....# +.....#..#...... +..#.#....#.#... +..##......##... +..##......##... +..#.#....#.#... +.....#..#...... +....#....#....# + +.##..#. +.##..#. +#.#.### +..##... +.#...#. +#####.. +#.#.### +#.#.### +#####.. +.#...#. +...#... + +###..#..### +.....#...## +......#.#.. +..#.#...#.. +...###.#### +##.##...##. +..###...### +##...#.#..# +#.##.##..#. +..#...#.#.. +...#.#..#.. +...#.#..#.. +..#...#.#.. + +.....##.. +....#..#. +.....##.. +#..#.##.# +####....# +.##...... +#..###.## + +.#..##.###### +#.#..##.#.##. +#.#..##.#.##. +.#..##.###### +.####..#..... +.#.#.#.#.#..# +####...#...#. + +#..#... +...#... +.###.#. +..#.##. +..#.#.# +.##.##. +.##.##. +..#.#.# +..#.##. +.###.#. +...#... +#..#... +...###. +#....## +.###### + +.##...#.# +####....# +...####.# +#..#.#### +.##.##.## +#####.#.# +....##### +.##.##.#. +.##..##.# +#..#.#### +.##...##. +#..#..### +#..#..### + +..#...# +..#...# +.###### +.##.#.# +.#.#.#. +#...##. +......# +#...#.# +#...#.# +......# +#...##. +.#.#.#. +.##...# +.###### +..#...# + +###.##. +..##... +.#.#..# +.#.#... +..##... +###.##. +###...# +.#..... +#...#.# +...##.# +...##.# +#...#.# +.#..... +###...# +###.##. + +....#..#. +##.###### +##.#....# +..###..## +..#..##.# +.....##.. +##.#.##.# +..##.##.# +###..##.. + +###..##.##.#. +###..##.##.## +######.#.#.## +####.#..#.#.# +...#.#.##.### +##..##.#..... +....##.#..##. +........#.#.. +...#....#.##. +###.####..... +...##...#.### +####..#.###.. +....#..#..##. +##.####...#.# +...#.......#. + +..#.#.. +..##### +..##### +..#.#.. +##..#.. +...#.## +.###### +.###..# +.####.# +.###### +...#.## + +.####..####.#..## +##..#..#..###.#.. +#...#..#...#.#.## +.#.##..##.#.##..# +#..#.##.#..#..... +.#..#..#..#...... +.#.######.#..#... +##.##..##.##.#... +.###....###.##### + +..###..#.##.. +..###..#.#... +...#.#..##### +#####.###.#.# +...#.#..#.#.# +#####..###.#. +##.....##.#.. + +....##. +.#.#### +.###### +.#.#..# +#.##..# +...#### +.###### +#...##. +##..##. +#...##. +#...##. +.###### +...#### + +##....##. +##...##.. +##.####.# +..##..##. +..##..##. +##.##.#.# +##...##.. +##....##. +....##.## +..#...### +...##.##. +...#...## +#####..#. + +##.#.#. +#..#.#. +..#...# +##.#... +...#... +.###... +.#.###. +.#..#.. +.#..#.. +.#.###. +.###... +...#... +##.#... +..#...# +#..#.#. + +.###....# +#..##..## +#.####### +#.#...... +##...##.. +..##....# +#....##.. +###...... +#.#.####. +....####. +#####..## +.##...... +..##....# +####.##.# +.###.##.# + +.##.##.##..##.##. +.##.#.########.#. +.##.####.##.####. +#..######..###### +.......##..##.... +..#..##########.. +....#.##.##.##.#. +#..#.##.####.##.# +####..#......#..# + +#..####..##.. +.#..##..#..#. +.#......#..#. +..##..##....# +...#..#...... +#..#..#..##.. +.#......#..#. +#........##.. +...####...... +.###..###..## +...#..#...... +#..####..##.. +..#....#....# +#........##.# +.###..###..## + +#.#..##..#.#..... +#.#..##..#.#.##.. +...#.##.#...#..#. +.#........####.## +#.##.##.##.#...## +..#.####.#.....#. +####.##.######.## +###.#..#.###..### +..##.##.##...#..# +..##.##.##...#..# +###.#..#.###..### diff --git a/day_13/part_1/Cargo.toml b/day_13/part_1/Cargo.toml new file mode 100644 index 0000000..fc5dc21 --- /dev/null +++ b/day_13/part_1/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "day_13-1" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/day_13/part_1/src/main.rs b/day_13/part_1/src/main.rs new file mode 100644 index 0000000..2f381b9 --- /dev/null +++ b/day_13/part_1/src/main.rs @@ -0,0 +1,57 @@ +fn main() { + let input = include_str!("../../input.txt").trim(); + let mut result = 0; + + 'balls: for section in input.split("\n\n") { + let grid: Vec> = section + .lines() + .map(|line| line.chars().map(|c| c == '#').collect::>()) + .collect::>>(); + + // Vertical + for mut i in 0..(grid.len() - 1) as i32 { + let res_val = (i + 1) * 100; + let mut j = (i + 1) as i32; + + 'nuts: loop { + if i < 0 || j >= grid.len() as i32 { + result += res_val; + continue 'balls; + } + + for k in 0..grid[i as usize].len() { + if grid[i as usize][k] != grid[j as usize][k] { + break 'nuts; + } + } + + i -= 1; + j += 1; + } + } + + // Horizontal + for mut i in 0..(grid[0].len() - 1) as i32 { + let res_val = i + 1; + let mut j = (i + 1) as i32; + + 'nuts: loop { + if i < 0 || j >= grid[0].len() as i32 { + result += res_val; + continue 'balls; + } + + for k in 0..grid.len() { + if grid[k][i as usize] != grid[k][j as usize] { + break 'nuts; + } + } + + i -= 1; + j += 1; + } + } + } + + println!("Result: {result}"); +} diff --git a/day_13/part_2/Cargo.toml b/day_13/part_2/Cargo.toml new file mode 100644 index 0000000..a651791 --- /dev/null +++ b/day_13/part_2/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "day_13-2" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/day_13/part_2/src/main.rs b/day_13/part_2/src/main.rs new file mode 100644 index 0000000..d1eae1d --- /dev/null +++ b/day_13/part_2/src/main.rs @@ -0,0 +1,75 @@ +fn main() { + let input = include_str!("../../input.txt").trim(); + let mut result = 0; + + 'balls: for section in input.split("\n\n") { + let grid: Vec> = section + .lines() + .map(|line| line.chars().map(|c| c == '#').collect::>()) + .collect::>>(); + + // Vertical + for mut i in 0..(grid.len() - 1) as i32 { + let res_val = (i + 1) * 100; + let mut j = (i + 1) as i32; + let mut error_allowed = true; + + 'nuts: loop { + if i < 0 || j >= grid.len() as i32 { + if !error_allowed { + result += res_val; + continue 'balls; + } else { + break 'nuts; + } + } + + for k in 0..grid[i as usize].len() { + if grid[i as usize][k] != grid[j as usize][k] { + if error_allowed { + error_allowed = false; + } else { + break 'nuts; + } + } + } + + i -= 1; + j += 1; + } + } + + // Horizontal + for mut i in 0..(grid[0].len() - 1) as i32 { + let res_val = i + 1; + let mut j = (i + 1) as i32; + let mut error_allowed = true; + + 'nuts: loop { + if i < 0 || j >= grid[0].len() as i32 { + if !error_allowed { + result += res_val; + continue 'balls; + } else { + break 'nuts; + } + } + + for k in 0..grid.len() { + if grid[k][i as usize] != grid[k][j as usize] { + if error_allowed { + error_allowed = false; + } else { + break 'nuts; + } + } + } + + i -= 1; + j += 1; + } + } + } + + println!("Result: {result}"); +}