From e9ac699e67bdd36a8c94682b57a3d2dc3d8d560f Mon Sep 17 00:00:00 2001 From: Jose Caban <43381096+AssKoala@users.noreply.github.com> Date: Sun, 30 Nov 2025 20:28:10 -0500 Subject: [PATCH] Initial Commit --- 2022/AdventOfCode.sln | 317 ++ 2022/Day01CSharp/Day01CSharp.csproj | 8 + 2022/Day01CSharp/Program.cs | 45 + .../Properties/launchSettings.json | 8 + 2022/Day01CSharp/data/example.txt | 14 + 2022/Day01CSharp/data/input.txt | 2247 ++++++++ 2022/Day01CSharp/problem.txt | 55 + 2022/Day02CSharp/Day02CSharp.csproj | 8 + 2022/Day02CSharp/Program.cs | 133 + .../Properties/launchSettings.json | 8 + 2022/Day02CSharp/data/example.txt | 3 + 2022/Day02CSharp/data/input.txt | 2500 +++++++++ 2022/Day02CSharp/problem.txt | 48 + 2022/Day03CSharp/Day03CSharp.csproj | 8 + 2022/Day03CSharp/Program.cs | 243 + .../Properties/launchSettings.json | 8 + 2022/Day03CSharp/example-input01.txt | 6 + 2022/Day03CSharp/problem.txt | 62 + 2022/Day03CSharp/puzzle-input01.txt | 300 + 2022/Day04CSharp/Day04CSharp.csproj | 10 + 2022/Day04CSharp/Program.cs | 121 + .../Properties/launchSettings.json | 8 + 2022/Day04CSharp/example-input.txt | 6 + 2022/Day04CSharp/problem.txt | 59 + 2022/Day04CSharp/puzzle-input.txt | 1000 ++++ 2022/Day05CSharp/Day05CSharp.csproj | 10 + 2022/Day05CSharp/Program.cs | 233 + .../Properties/launchSettings.json | 8 + 2022/Day05CSharp/example-input.txt | 9 + 2022/Day05CSharp/problem.txt | 106 + 2022/Day05CSharp/puzzle-input.txt | 513 ++ 2022/Day06CSharp/Day06CSharp.csproj | 10 + 2022/Day06CSharp/Program.cs | 53 + .../Properties/launchSettings.json | 8 + 2022/Day06CSharp/problem.txt | 48 + 2022/Day06CSharp/puzzle-input.txt | 1 + 2022/Day07CSharp/Day07CSharp.csproj | 10 + 2022/Day07CSharp/Program.cs | 205 + .../Properties/launchSettings.json | 8 + 2022/Day07CSharp/example-input.txt | 23 + 2022/Day07CSharp/problem.txt | 99 + 2022/Day07CSharp/puzzle-input.txt | 986 ++++ 2022/Day08CSharp/Day08CSharp.csproj | 10 + 2022/Day08CSharp/Program.cs | 203 + .../Properties/launchSettings.json | 8 + 2022/Day08CSharp/example-input.txt | 5 + 2022/Day08CSharp/problem.txt | 72 + 2022/Day08CSharp/puzzle-input.txt | 99 + 2022/Day09CSharp/Day09CSharp.csproj | 10 + 2022/Day09CSharp/Program.cs | 264 + .../Properties/launchSettings.json | 8 + 2022/Day09CSharp/example-input.txt | 8 + 2022/Day09CSharp/example-input2.txt | 8 + 2022/Day09CSharp/problem.txt | 685 +++ 2022/Day09CSharp/puzzle-input.txt | 2000 +++++++ 2022/Day10CSharp/Day10CSharp.csproj | 10 + 2022/Day10CSharp/Program.cs | 231 + .../Properties/launchSettings.json | 8 + 2022/Day10CSharp/example-input1.txt | 3 + 2022/Day10CSharp/example-input2.txt | 146 + 2022/Day10CSharp/problem.txt | 321 ++ 2022/Day10CSharp/puzzle-input.txt | 137 + 2022/Day11CSharp/Day11CSharp.csproj | 10 + 2022/Day11CSharp/Program.cs | 319 ++ .../Properties/launchSettings.json | 8 + 2022/Day11CSharp/example-input.txt | 27 + 2022/Day11CSharp/problem.txt | 307 + 2022/Day11CSharp/puzzle-input.txt | 55 + 2022/Day12CSharp/Day12CSharp.csproj | 10 + 2022/Day12CSharp/Program.cs | 279 + .../Properties/launchSettings.json | 8 + 2022/Day12CSharp/example-input.txt | 5 + 2022/Day12CSharp/problem.txt | 57 + 2022/Day12CSharp/puzzle-input.txt | 41 + 2022/Day13CSharp/Day13CSharp.csproj | 10 + 2022/Day13CSharp/Program.cs | 334 ++ .../Properties/launchSettings.json | 8 + 2022/Day13CSharp/example-input.txt | 23 + 2022/Day13CSharp/gen-input.txt | 449 ++ 2022/Day13CSharp/problem.txt | 148 + 2022/Day13CSharp/puzzle-input.txt | 449 ++ 2022/Day14CSharp/Day14CSharp.csproj | 10 + 2022/Day14CSharp/Program.cs | 264 + .../Properties/launchSettings.json | 8 + 2022/Day14CSharp/example-input.txt | 2 + 2022/Day14CSharp/problem.txt | 163 + 2022/Day14CSharp/puzzle-input.txt | 148 + 2022/Day15CSharp/Day15CSharp.csproj | 10 + 2022/Day15CSharp/Program.cs | 413 ++ .../Properties/launchSettings.json | 8 + 2022/Day15CSharp/example-input.txt | 14 + 2022/Day15CSharp/problem.txt | 113 + 2022/Day15CSharp/puzzle-input.txt | 29 + 2022/Day16CSharp/Day16CSharp.csproj | 10 + 2022/Day16CSharp/Program.cs | 427 ++ .../Properties/launchSettings.json | 8 + 2022/Day16CSharp/example-input.txt | 10 + 2022/Day16CSharp/problem.txt | 146 + 2022/Day16CSharp/puzzle-input.txt | 58 + 2022/Day17CSharp/Day17CSharp.csproj | 10 + 2022/Day17CSharp/Program.cs | 107 + .../Properties/launchSettings.json | 8 + 2022/Day17CSharp/example-input.txt | 1 + 2022/Day17CSharp/problem.txt | 337 ++ 2022/Day17CSharp/puzzle-input.txt | 1 + 2022/Day18CSharp/Day18CSharp.csproj | 10 + 2022/Day18CSharp/Program.cs | 344 ++ .../Properties/launchSettings.json | 8 + 2022/Day18CSharp/example-input-simple.txt | 2 + 2022/Day18CSharp/example-input.txt | 13 + 2022/Day18CSharp/problem.txt | 44 + 2022/Day18CSharp/puzzle-input.txt | 2879 ++++++++++ 2022/Day19CSharp/Day19CSharp.csproj | 10 + 2022/Day19CSharp/Program.cs | 2 + .../Properties/launchSettings.json | 8 + 2022/Day19CSharp/example-input.txt | 2 + 2022/Day19CSharp/problem.txt | 169 + 2022/Day19CSharp/puzzle-input.txt | 30 + 2022/Day20CSharp/Advent2022_Day20.cs | 176 + 2022/Day20CSharp/Day20CSharp.csproj | 10 + .../Properties/launchSettings.json | 8 + 2022/Day20CSharp/example-input.txt | 7 + 2022/Day20CSharp/problem.txt | 107 + 2022/Day20CSharp/puzzle-input.txt | 5000 +++++++++++++++++ 2022/Day21CSharp/Advent2022_Day21.cs | 242 + 2022/Day21CSharp/Day21CSharp.csproj | 10 + .../Properties/launchSettings.json | 8 + 2022/Day21CSharp/example-input.txt | 15 + 2022/Day21CSharp/problem.txt | 58 + 2022/Day21CSharp/puzzle-input.txt | 2597 +++++++++ 2023/AdventCommon/AdventCommon.csproj | 9 + 2023/AdventCommon/PuzzleInput.cs | 35 + 2023/AdventOfCode.sln | 55 + 2023/Day01CSharp/Day01CSharp.csproj | 14 + 2023/Day01CSharp/Program.cs | 129 + .../Properties/launchSettings.json | 8 + 2023/Day01CSharp/example-input-2.txt | 7 + 2023/Day01CSharp/example-input.txt | 4 + 2023/Day01CSharp/puzzle-input.txt | 1000 ++++ 2023/Day02CSharp/Day02CSharp.csproj | 14 + 2023/Day02CSharp/Program.cs | 147 + .../Properties/launchSettings.json | 8 + 2023/Day02CSharp/example-input.txt | 5 + 2023/Day02CSharp/puzzle-input.txt | 100 + 2023/Day03CSharp/Day03CSharp.csproj | 14 + 2023/Day03CSharp/Program.cs | 156 + .../Properties/launchSettings.json | 8 + 2023/Day03CSharp/example-input.txt | 10 + 2023/Day03CSharp/puzzle-input.txt | 140 + 2023/Day04CSharp/Day04CSharp.csproj | 14 + 2023/Day04CSharp/Program.cs | 151 + .../Properties/launchSettings.json | 8 + 2023/Day04CSharp/example-input.txt | 6 + 2023/Day04CSharp/puzzle-input.txt | 201 + 2023/Day05CSharp/Day05CSharp.csproj | 14 + 2023/Day05CSharp/Program.cs | 173 + .../Properties/launchSettings.json | 8 + 2023/Day05CSharp/example-input.txt | 33 + 2023/Day05CSharp/puzzle-input.txt | 258 + 2024/AdventCommon/AdventCommon.csproj | 9 + 2024/AdventCommon/ParsedInput.cs | 31 + 2024/AdventCommon/PuzzleInput.cs | 35 + 2024/AdventOfCode.sln | 67 + 2024/Day01CSharp/Day01CSharp.csproj | 14 + 2024/Day01CSharp/Program.cs | 97 + .../Properties/launchSettings.json | 8 + 2024/Day01CSharp/example-input.txt | 6 + 2024/Day01CSharp/puzzle-input.txt | 1000 ++++ 2024/Day02CSharp/Day02CSharp.csproj | 14 + 2024/Day02CSharp/Program.cs | 141 + .../Properties/launchSettings.json | 8 + 2024/Day02CSharp/example-input.txt | 6 + 2024/Day02CSharp/puzzle-input.txt | 1000 ++++ 2024/Day03CSharp/Day03CSharp.csproj | 14 + 2024/Day03CSharp/Program.cs | 171 + .../Properties/launchSettings.json | 8 + 2024/Day03CSharp/example-input.txt | 1 + 2024/Day03CSharp/example-input2.txt | 1 + 2024/Day03CSharp/puzzle-input.txt | 6 + 2024/Day04CSharp/Day04CSharp.csproj | 14 + 2024/Day04CSharp/Program.cs | 197 + .../Properties/launchSettings.json | 8 + 2024/Day04CSharp/example-input.txt | 10 + 2024/Day04CSharp/puzzle-input.txt | 140 + 2024/Day05CSharp/Day05CSharp.csproj | 14 + 2024/Day05CSharp/Program.cs | 196 + .../Properties/launchSettings.json | 8 + 2024/Day05CSharp/example-input.txt | 28 + 2024/Day05CSharp/puzzle-input.txt | 1380 +++++ 2024/Day06CSharp/Day06CSharp.csproj | 14 + 2024/Day06CSharp/Program.cs | 334 ++ .../Properties/launchSettings.json | 8 + 2024/Day06CSharp/example-input.txt | 10 + 2024/Day06CSharp/puzzle-input.txt | 130 + 2024/Day07CSharp/Day07CSharp.csproj | 14 + 2024/Day07CSharp/Program.cs | 98 + .../Properties/launchSettings.json | 8 + 2024/Day07CSharp/example-input.txt | 9 + 2024/Day07CSharp/puzzle-input.txt | 850 +++ 2025/.gitignore | 3 + 2025/AdventHelpers/AdventHelpers.vcxproj | 167 + .../AdventHelpers.vcxproj.filters | 33 + .../AdventHelpers/AdventOfCodeSolution.h | 13 + .../include/AdventHelpers/InputFileHelper.h | 35 + 2025/AdventHelpers/source/InputFileHelper.cpp | 42 + .../AdventHelpersTester.cpp | 36 + .../AdventHelpersTester.vcxproj | 140 + .../AdventHelpersTester.vcxproj.filters | 22 + 2025/AdventOfCode.slnx | 8 + 209 files changed, 39737 insertions(+) create mode 100644 2022/AdventOfCode.sln create mode 100644 2022/Day01CSharp/Day01CSharp.csproj create mode 100644 2022/Day01CSharp/Program.cs create mode 100644 2022/Day01CSharp/Properties/launchSettings.json create mode 100644 2022/Day01CSharp/data/example.txt create mode 100644 2022/Day01CSharp/data/input.txt create mode 100644 2022/Day01CSharp/problem.txt create mode 100644 2022/Day02CSharp/Day02CSharp.csproj create mode 100644 2022/Day02CSharp/Program.cs create mode 100644 2022/Day02CSharp/Properties/launchSettings.json create mode 100644 2022/Day02CSharp/data/example.txt create mode 100644 2022/Day02CSharp/data/input.txt create mode 100644 2022/Day02CSharp/problem.txt create mode 100644 2022/Day03CSharp/Day03CSharp.csproj create mode 100644 2022/Day03CSharp/Program.cs create mode 100644 2022/Day03CSharp/Properties/launchSettings.json create mode 100644 2022/Day03CSharp/example-input01.txt create mode 100644 2022/Day03CSharp/problem.txt create mode 100644 2022/Day03CSharp/puzzle-input01.txt create mode 100644 2022/Day04CSharp/Day04CSharp.csproj create mode 100644 2022/Day04CSharp/Program.cs create mode 100644 2022/Day04CSharp/Properties/launchSettings.json create mode 100644 2022/Day04CSharp/example-input.txt create mode 100644 2022/Day04CSharp/problem.txt create mode 100644 2022/Day04CSharp/puzzle-input.txt create mode 100644 2022/Day05CSharp/Day05CSharp.csproj create mode 100644 2022/Day05CSharp/Program.cs create mode 100644 2022/Day05CSharp/Properties/launchSettings.json create mode 100644 2022/Day05CSharp/example-input.txt create mode 100644 2022/Day05CSharp/problem.txt create mode 100644 2022/Day05CSharp/puzzle-input.txt create mode 100644 2022/Day06CSharp/Day06CSharp.csproj create mode 100644 2022/Day06CSharp/Program.cs create mode 100644 2022/Day06CSharp/Properties/launchSettings.json create mode 100644 2022/Day06CSharp/problem.txt create mode 100644 2022/Day06CSharp/puzzle-input.txt create mode 100644 2022/Day07CSharp/Day07CSharp.csproj create mode 100644 2022/Day07CSharp/Program.cs create mode 100644 2022/Day07CSharp/Properties/launchSettings.json create mode 100644 2022/Day07CSharp/example-input.txt create mode 100644 2022/Day07CSharp/problem.txt create mode 100644 2022/Day07CSharp/puzzle-input.txt create mode 100644 2022/Day08CSharp/Day08CSharp.csproj create mode 100644 2022/Day08CSharp/Program.cs create mode 100644 2022/Day08CSharp/Properties/launchSettings.json create mode 100644 2022/Day08CSharp/example-input.txt create mode 100644 2022/Day08CSharp/problem.txt create mode 100644 2022/Day08CSharp/puzzle-input.txt create mode 100644 2022/Day09CSharp/Day09CSharp.csproj create mode 100644 2022/Day09CSharp/Program.cs create mode 100644 2022/Day09CSharp/Properties/launchSettings.json create mode 100644 2022/Day09CSharp/example-input.txt create mode 100644 2022/Day09CSharp/example-input2.txt create mode 100644 2022/Day09CSharp/problem.txt create mode 100644 2022/Day09CSharp/puzzle-input.txt create mode 100644 2022/Day10CSharp/Day10CSharp.csproj create mode 100644 2022/Day10CSharp/Program.cs create mode 100644 2022/Day10CSharp/Properties/launchSettings.json create mode 100644 2022/Day10CSharp/example-input1.txt create mode 100644 2022/Day10CSharp/example-input2.txt create mode 100644 2022/Day10CSharp/problem.txt create mode 100644 2022/Day10CSharp/puzzle-input.txt create mode 100644 2022/Day11CSharp/Day11CSharp.csproj create mode 100644 2022/Day11CSharp/Program.cs create mode 100644 2022/Day11CSharp/Properties/launchSettings.json create mode 100644 2022/Day11CSharp/example-input.txt create mode 100644 2022/Day11CSharp/problem.txt create mode 100644 2022/Day11CSharp/puzzle-input.txt create mode 100644 2022/Day12CSharp/Day12CSharp.csproj create mode 100644 2022/Day12CSharp/Program.cs create mode 100644 2022/Day12CSharp/Properties/launchSettings.json create mode 100644 2022/Day12CSharp/example-input.txt create mode 100644 2022/Day12CSharp/problem.txt create mode 100644 2022/Day12CSharp/puzzle-input.txt create mode 100644 2022/Day13CSharp/Day13CSharp.csproj create mode 100644 2022/Day13CSharp/Program.cs create mode 100644 2022/Day13CSharp/Properties/launchSettings.json create mode 100644 2022/Day13CSharp/example-input.txt create mode 100644 2022/Day13CSharp/gen-input.txt create mode 100644 2022/Day13CSharp/problem.txt create mode 100644 2022/Day13CSharp/puzzle-input.txt create mode 100644 2022/Day14CSharp/Day14CSharp.csproj create mode 100644 2022/Day14CSharp/Program.cs create mode 100644 2022/Day14CSharp/Properties/launchSettings.json create mode 100644 2022/Day14CSharp/example-input.txt create mode 100644 2022/Day14CSharp/problem.txt create mode 100644 2022/Day14CSharp/puzzle-input.txt create mode 100644 2022/Day15CSharp/Day15CSharp.csproj create mode 100644 2022/Day15CSharp/Program.cs create mode 100644 2022/Day15CSharp/Properties/launchSettings.json create mode 100644 2022/Day15CSharp/example-input.txt create mode 100644 2022/Day15CSharp/problem.txt create mode 100644 2022/Day15CSharp/puzzle-input.txt create mode 100644 2022/Day16CSharp/Day16CSharp.csproj create mode 100644 2022/Day16CSharp/Program.cs create mode 100644 2022/Day16CSharp/Properties/launchSettings.json create mode 100644 2022/Day16CSharp/example-input.txt create mode 100644 2022/Day16CSharp/problem.txt create mode 100644 2022/Day16CSharp/puzzle-input.txt create mode 100644 2022/Day17CSharp/Day17CSharp.csproj create mode 100644 2022/Day17CSharp/Program.cs create mode 100644 2022/Day17CSharp/Properties/launchSettings.json create mode 100644 2022/Day17CSharp/example-input.txt create mode 100644 2022/Day17CSharp/problem.txt create mode 100644 2022/Day17CSharp/puzzle-input.txt create mode 100644 2022/Day18CSharp/Day18CSharp.csproj create mode 100644 2022/Day18CSharp/Program.cs create mode 100644 2022/Day18CSharp/Properties/launchSettings.json create mode 100644 2022/Day18CSharp/example-input-simple.txt create mode 100644 2022/Day18CSharp/example-input.txt create mode 100644 2022/Day18CSharp/problem.txt create mode 100644 2022/Day18CSharp/puzzle-input.txt create mode 100644 2022/Day19CSharp/Day19CSharp.csproj create mode 100644 2022/Day19CSharp/Program.cs create mode 100644 2022/Day19CSharp/Properties/launchSettings.json create mode 100644 2022/Day19CSharp/example-input.txt create mode 100644 2022/Day19CSharp/problem.txt create mode 100644 2022/Day19CSharp/puzzle-input.txt create mode 100644 2022/Day20CSharp/Advent2022_Day20.cs create mode 100644 2022/Day20CSharp/Day20CSharp.csproj create mode 100644 2022/Day20CSharp/Properties/launchSettings.json create mode 100644 2022/Day20CSharp/example-input.txt create mode 100644 2022/Day20CSharp/problem.txt create mode 100644 2022/Day20CSharp/puzzle-input.txt create mode 100644 2022/Day21CSharp/Advent2022_Day21.cs create mode 100644 2022/Day21CSharp/Day21CSharp.csproj create mode 100644 2022/Day21CSharp/Properties/launchSettings.json create mode 100644 2022/Day21CSharp/example-input.txt create mode 100644 2022/Day21CSharp/problem.txt create mode 100644 2022/Day21CSharp/puzzle-input.txt create mode 100644 2023/AdventCommon/AdventCommon.csproj create mode 100644 2023/AdventCommon/PuzzleInput.cs create mode 100644 2023/AdventOfCode.sln create mode 100644 2023/Day01CSharp/Day01CSharp.csproj create mode 100644 2023/Day01CSharp/Program.cs create mode 100644 2023/Day01CSharp/Properties/launchSettings.json create mode 100644 2023/Day01CSharp/example-input-2.txt create mode 100644 2023/Day01CSharp/example-input.txt create mode 100644 2023/Day01CSharp/puzzle-input.txt create mode 100644 2023/Day02CSharp/Day02CSharp.csproj create mode 100644 2023/Day02CSharp/Program.cs create mode 100644 2023/Day02CSharp/Properties/launchSettings.json create mode 100644 2023/Day02CSharp/example-input.txt create mode 100644 2023/Day02CSharp/puzzle-input.txt create mode 100644 2023/Day03CSharp/Day03CSharp.csproj create mode 100644 2023/Day03CSharp/Program.cs create mode 100644 2023/Day03CSharp/Properties/launchSettings.json create mode 100644 2023/Day03CSharp/example-input.txt create mode 100644 2023/Day03CSharp/puzzle-input.txt create mode 100644 2023/Day04CSharp/Day04CSharp.csproj create mode 100644 2023/Day04CSharp/Program.cs create mode 100644 2023/Day04CSharp/Properties/launchSettings.json create mode 100644 2023/Day04CSharp/example-input.txt create mode 100644 2023/Day04CSharp/puzzle-input.txt create mode 100644 2023/Day05CSharp/Day05CSharp.csproj create mode 100644 2023/Day05CSharp/Program.cs create mode 100644 2023/Day05CSharp/Properties/launchSettings.json create mode 100644 2023/Day05CSharp/example-input.txt create mode 100644 2023/Day05CSharp/puzzle-input.txt create mode 100644 2024/AdventCommon/AdventCommon.csproj create mode 100644 2024/AdventCommon/ParsedInput.cs create mode 100644 2024/AdventCommon/PuzzleInput.cs create mode 100644 2024/AdventOfCode.sln create mode 100644 2024/Day01CSharp/Day01CSharp.csproj create mode 100644 2024/Day01CSharp/Program.cs create mode 100644 2024/Day01CSharp/Properties/launchSettings.json create mode 100644 2024/Day01CSharp/example-input.txt create mode 100644 2024/Day01CSharp/puzzle-input.txt create mode 100644 2024/Day02CSharp/Day02CSharp.csproj create mode 100644 2024/Day02CSharp/Program.cs create mode 100644 2024/Day02CSharp/Properties/launchSettings.json create mode 100644 2024/Day02CSharp/example-input.txt create mode 100644 2024/Day02CSharp/puzzle-input.txt create mode 100644 2024/Day03CSharp/Day03CSharp.csproj create mode 100644 2024/Day03CSharp/Program.cs create mode 100644 2024/Day03CSharp/Properties/launchSettings.json create mode 100644 2024/Day03CSharp/example-input.txt create mode 100644 2024/Day03CSharp/example-input2.txt create mode 100644 2024/Day03CSharp/puzzle-input.txt create mode 100644 2024/Day04CSharp/Day04CSharp.csproj create mode 100644 2024/Day04CSharp/Program.cs create mode 100644 2024/Day04CSharp/Properties/launchSettings.json create mode 100644 2024/Day04CSharp/example-input.txt create mode 100644 2024/Day04CSharp/puzzle-input.txt create mode 100644 2024/Day05CSharp/Day05CSharp.csproj create mode 100644 2024/Day05CSharp/Program.cs create mode 100644 2024/Day05CSharp/Properties/launchSettings.json create mode 100644 2024/Day05CSharp/example-input.txt create mode 100644 2024/Day05CSharp/puzzle-input.txt create mode 100644 2024/Day06CSharp/Day06CSharp.csproj create mode 100644 2024/Day06CSharp/Program.cs create mode 100644 2024/Day06CSharp/Properties/launchSettings.json create mode 100644 2024/Day06CSharp/example-input.txt create mode 100644 2024/Day06CSharp/puzzle-input.txt create mode 100644 2024/Day07CSharp/Day07CSharp.csproj create mode 100644 2024/Day07CSharp/Program.cs create mode 100644 2024/Day07CSharp/Properties/launchSettings.json create mode 100644 2024/Day07CSharp/example-input.txt create mode 100644 2024/Day07CSharp/puzzle-input.txt create mode 100644 2025/.gitignore create mode 100644 2025/AdventHelpers/AdventHelpers.vcxproj create mode 100644 2025/AdventHelpers/AdventHelpers.vcxproj.filters create mode 100644 2025/AdventHelpers/include/AdventHelpers/AdventOfCodeSolution.h create mode 100644 2025/AdventHelpers/include/AdventHelpers/InputFileHelper.h create mode 100644 2025/AdventHelpers/source/InputFileHelper.cpp create mode 100644 2025/AdventHelpersTester/AdventHelpersTester.cpp create mode 100644 2025/AdventHelpersTester/AdventHelpersTester.vcxproj create mode 100644 2025/AdventHelpersTester/AdventHelpersTester.vcxproj.filters create mode 100644 2025/AdventOfCode.slnx diff --git a/2022/AdventOfCode.sln b/2022/AdventOfCode.sln new file mode 100644 index 0000000..5a2c968 --- /dev/null +++ b/2022/AdventOfCode.sln @@ -0,0 +1,317 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.4.33110.190 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Day01CSharp", "Day01CSharp\Day01CSharp.csproj", "{52963D0A-9F5C-4E6E-8620-0322D0FE4DF7}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Day02CSharp", "Day02CSharp\Day02CSharp.csproj", "{BF1382F9-9CF8-4BE9-8C39-1DC96F15350D}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Day03CSharp", "Day03CSharp\Day03CSharp.csproj", "{F920B90D-7A1B-4714-BF3C-86ACFE1FA507}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Day04CSharp", "Day04CSharp\Day04CSharp.csproj", "{2CC555B8-E56F-47C0-BB1C-17B50AB68B6D}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Day05CSharp", "Day05CSharp\Day05CSharp.csproj", "{1641E176-E81A-407B-8FAB-42CF263EC16F}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Day06CSharp", "Day06CSharp\Day06CSharp.csproj", "{581B6EF1-F942-4FC0-B9E9-A4A7006F8580}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Day07CSharp", "Day07CSharp\Day07CSharp.csproj", "{DECE90F6-0433-4445-AA7E-B83C08956989}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Day08CSharp", "Day08CSharp\Day08CSharp.csproj", "{BD0173FF-6D40-4CF1-8F80-72C6EDFFFAD6}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Day09CSharp", "Day09CSharp\Day09CSharp.csproj", "{C9F4271E-C48E-419F-A012-9DF69B494D80}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Day10CSharp", "Day10CSharp\Day10CSharp.csproj", "{401194D0-F437-4F68-93E9-1B0D3154C188}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Day11CSharp", "Day11CSharp\Day11CSharp.csproj", "{24F119F6-D911-4788-8201-90D78B8B412F}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Day12CSharp", "Day12CSharp\Day12CSharp.csproj", "{22F3EF10-5B81-4429-A2D3-1F22E9F9884F}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Day13CSharp", "Day13CSharp\Day13CSharp.csproj", "{97784C9A-D173-4921-A65D-8EBC7DBB30BC}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Day14CSharp", "Day14CSharp\Day14CSharp.csproj", "{F6BB67DD-29FE-4B81-9B7B-F4060B235F1E}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Day15CSharp", "Day15CSharp\Day15CSharp.csproj", "{F871B744-890F-424A-94DB-3F91BB767913}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Day16CSharp", "Day16CSharp\Day16CSharp.csproj", "{01843057-4F63-4FC8-B337-9DBBB9D595C1}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Day17CSharp", "Day17CSharp\Day17CSharp.csproj", "{98A314D7-7C12-44F5-B6CC-DA7E04D769B9}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Day18CSharp", "Day18CSharp\Day18CSharp.csproj", "{08281E46-F20B-496B-9ACE-60BFF7542910}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Day19CSharp", "Day19CSharp\Day19CSharp.csproj", "{24A19897-7748-41E4-9EC5-BAC5D16221C2}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Day20CSharp", "Day20CSharp\Day20CSharp.csproj", "{3A837080-9F9E-40F1-B284-353772853337}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Day21CSharp", "Day21CSharp\Day21CSharp.csproj", "{7A16DECF-F78A-4614-BA4B-68D478C9456B}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {52963D0A-9F5C-4E6E-8620-0322D0FE4DF7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {52963D0A-9F5C-4E6E-8620-0322D0FE4DF7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {52963D0A-9F5C-4E6E-8620-0322D0FE4DF7}.Debug|x64.ActiveCfg = Debug|Any CPU + {52963D0A-9F5C-4E6E-8620-0322D0FE4DF7}.Debug|x64.Build.0 = Debug|Any CPU + {52963D0A-9F5C-4E6E-8620-0322D0FE4DF7}.Debug|x86.ActiveCfg = Debug|Any CPU + {52963D0A-9F5C-4E6E-8620-0322D0FE4DF7}.Debug|x86.Build.0 = Debug|Any CPU + {52963D0A-9F5C-4E6E-8620-0322D0FE4DF7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {52963D0A-9F5C-4E6E-8620-0322D0FE4DF7}.Release|Any CPU.Build.0 = Release|Any CPU + {52963D0A-9F5C-4E6E-8620-0322D0FE4DF7}.Release|x64.ActiveCfg = Release|Any CPU + {52963D0A-9F5C-4E6E-8620-0322D0FE4DF7}.Release|x64.Build.0 = Release|Any CPU + {52963D0A-9F5C-4E6E-8620-0322D0FE4DF7}.Release|x86.ActiveCfg = Release|Any CPU + {52963D0A-9F5C-4E6E-8620-0322D0FE4DF7}.Release|x86.Build.0 = Release|Any CPU + {BF1382F9-9CF8-4BE9-8C39-1DC96F15350D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BF1382F9-9CF8-4BE9-8C39-1DC96F15350D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BF1382F9-9CF8-4BE9-8C39-1DC96F15350D}.Debug|x64.ActiveCfg = Debug|Any CPU + {BF1382F9-9CF8-4BE9-8C39-1DC96F15350D}.Debug|x64.Build.0 = Debug|Any CPU + {BF1382F9-9CF8-4BE9-8C39-1DC96F15350D}.Debug|x86.ActiveCfg = Debug|Any CPU + {BF1382F9-9CF8-4BE9-8C39-1DC96F15350D}.Debug|x86.Build.0 = Debug|Any CPU + {BF1382F9-9CF8-4BE9-8C39-1DC96F15350D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BF1382F9-9CF8-4BE9-8C39-1DC96F15350D}.Release|Any CPU.Build.0 = Release|Any CPU + {BF1382F9-9CF8-4BE9-8C39-1DC96F15350D}.Release|x64.ActiveCfg = Release|Any CPU + {BF1382F9-9CF8-4BE9-8C39-1DC96F15350D}.Release|x64.Build.0 = Release|Any CPU + {BF1382F9-9CF8-4BE9-8C39-1DC96F15350D}.Release|x86.ActiveCfg = Release|Any CPU + {BF1382F9-9CF8-4BE9-8C39-1DC96F15350D}.Release|x86.Build.0 = Release|Any CPU + {F920B90D-7A1B-4714-BF3C-86ACFE1FA507}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F920B90D-7A1B-4714-BF3C-86ACFE1FA507}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F920B90D-7A1B-4714-BF3C-86ACFE1FA507}.Debug|x64.ActiveCfg = Debug|Any CPU + {F920B90D-7A1B-4714-BF3C-86ACFE1FA507}.Debug|x64.Build.0 = Debug|Any CPU + {F920B90D-7A1B-4714-BF3C-86ACFE1FA507}.Debug|x86.ActiveCfg = Debug|Any CPU + {F920B90D-7A1B-4714-BF3C-86ACFE1FA507}.Debug|x86.Build.0 = Debug|Any CPU + {F920B90D-7A1B-4714-BF3C-86ACFE1FA507}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F920B90D-7A1B-4714-BF3C-86ACFE1FA507}.Release|Any CPU.Build.0 = Release|Any CPU + {F920B90D-7A1B-4714-BF3C-86ACFE1FA507}.Release|x64.ActiveCfg = Release|Any CPU + {F920B90D-7A1B-4714-BF3C-86ACFE1FA507}.Release|x64.Build.0 = Release|Any CPU + {F920B90D-7A1B-4714-BF3C-86ACFE1FA507}.Release|x86.ActiveCfg = Release|Any CPU + {F920B90D-7A1B-4714-BF3C-86ACFE1FA507}.Release|x86.Build.0 = Release|Any CPU + {2CC555B8-E56F-47C0-BB1C-17B50AB68B6D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2CC555B8-E56F-47C0-BB1C-17B50AB68B6D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2CC555B8-E56F-47C0-BB1C-17B50AB68B6D}.Debug|x64.ActiveCfg = Debug|Any CPU + {2CC555B8-E56F-47C0-BB1C-17B50AB68B6D}.Debug|x64.Build.0 = Debug|Any CPU + {2CC555B8-E56F-47C0-BB1C-17B50AB68B6D}.Debug|x86.ActiveCfg = Debug|Any CPU + {2CC555B8-E56F-47C0-BB1C-17B50AB68B6D}.Debug|x86.Build.0 = Debug|Any CPU + {2CC555B8-E56F-47C0-BB1C-17B50AB68B6D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2CC555B8-E56F-47C0-BB1C-17B50AB68B6D}.Release|Any CPU.Build.0 = Release|Any CPU + {2CC555B8-E56F-47C0-BB1C-17B50AB68B6D}.Release|x64.ActiveCfg = Release|Any CPU + {2CC555B8-E56F-47C0-BB1C-17B50AB68B6D}.Release|x64.Build.0 = Release|Any CPU + {2CC555B8-E56F-47C0-BB1C-17B50AB68B6D}.Release|x86.ActiveCfg = Release|Any CPU + {2CC555B8-E56F-47C0-BB1C-17B50AB68B6D}.Release|x86.Build.0 = Release|Any CPU + {1641E176-E81A-407B-8FAB-42CF263EC16F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1641E176-E81A-407B-8FAB-42CF263EC16F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1641E176-E81A-407B-8FAB-42CF263EC16F}.Debug|x64.ActiveCfg = Debug|Any CPU + {1641E176-E81A-407B-8FAB-42CF263EC16F}.Debug|x64.Build.0 = Debug|Any CPU + {1641E176-E81A-407B-8FAB-42CF263EC16F}.Debug|x86.ActiveCfg = Debug|Any CPU + {1641E176-E81A-407B-8FAB-42CF263EC16F}.Debug|x86.Build.0 = Debug|Any CPU + {1641E176-E81A-407B-8FAB-42CF263EC16F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1641E176-E81A-407B-8FAB-42CF263EC16F}.Release|Any CPU.Build.0 = Release|Any CPU + {1641E176-E81A-407B-8FAB-42CF263EC16F}.Release|x64.ActiveCfg = Release|Any CPU + {1641E176-E81A-407B-8FAB-42CF263EC16F}.Release|x64.Build.0 = Release|Any CPU + {1641E176-E81A-407B-8FAB-42CF263EC16F}.Release|x86.ActiveCfg = Release|Any CPU + {1641E176-E81A-407B-8FAB-42CF263EC16F}.Release|x86.Build.0 = Release|Any CPU + {581B6EF1-F942-4FC0-B9E9-A4A7006F8580}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {581B6EF1-F942-4FC0-B9E9-A4A7006F8580}.Debug|Any CPU.Build.0 = Debug|Any CPU + {581B6EF1-F942-4FC0-B9E9-A4A7006F8580}.Debug|x64.ActiveCfg = Debug|Any CPU + {581B6EF1-F942-4FC0-B9E9-A4A7006F8580}.Debug|x64.Build.0 = Debug|Any CPU + {581B6EF1-F942-4FC0-B9E9-A4A7006F8580}.Debug|x86.ActiveCfg = Debug|Any CPU + {581B6EF1-F942-4FC0-B9E9-A4A7006F8580}.Debug|x86.Build.0 = Debug|Any CPU + {581B6EF1-F942-4FC0-B9E9-A4A7006F8580}.Release|Any CPU.ActiveCfg = Release|Any CPU + {581B6EF1-F942-4FC0-B9E9-A4A7006F8580}.Release|Any CPU.Build.0 = Release|Any CPU + {581B6EF1-F942-4FC0-B9E9-A4A7006F8580}.Release|x64.ActiveCfg = Release|Any CPU + {581B6EF1-F942-4FC0-B9E9-A4A7006F8580}.Release|x64.Build.0 = Release|Any CPU + {581B6EF1-F942-4FC0-B9E9-A4A7006F8580}.Release|x86.ActiveCfg = Release|Any CPU + {581B6EF1-F942-4FC0-B9E9-A4A7006F8580}.Release|x86.Build.0 = Release|Any CPU + {DECE90F6-0433-4445-AA7E-B83C08956989}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DECE90F6-0433-4445-AA7E-B83C08956989}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DECE90F6-0433-4445-AA7E-B83C08956989}.Debug|x64.ActiveCfg = Debug|Any CPU + {DECE90F6-0433-4445-AA7E-B83C08956989}.Debug|x64.Build.0 = Debug|Any CPU + {DECE90F6-0433-4445-AA7E-B83C08956989}.Debug|x86.ActiveCfg = Debug|Any CPU + {DECE90F6-0433-4445-AA7E-B83C08956989}.Debug|x86.Build.0 = Debug|Any CPU + {DECE90F6-0433-4445-AA7E-B83C08956989}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DECE90F6-0433-4445-AA7E-B83C08956989}.Release|Any CPU.Build.0 = Release|Any CPU + {DECE90F6-0433-4445-AA7E-B83C08956989}.Release|x64.ActiveCfg = Release|Any CPU + {DECE90F6-0433-4445-AA7E-B83C08956989}.Release|x64.Build.0 = Release|Any CPU + {DECE90F6-0433-4445-AA7E-B83C08956989}.Release|x86.ActiveCfg = Release|Any CPU + {DECE90F6-0433-4445-AA7E-B83C08956989}.Release|x86.Build.0 = Release|Any CPU + {BD0173FF-6D40-4CF1-8F80-72C6EDFFFAD6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BD0173FF-6D40-4CF1-8F80-72C6EDFFFAD6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BD0173FF-6D40-4CF1-8F80-72C6EDFFFAD6}.Debug|x64.ActiveCfg = Debug|Any CPU + {BD0173FF-6D40-4CF1-8F80-72C6EDFFFAD6}.Debug|x64.Build.0 = Debug|Any CPU + {BD0173FF-6D40-4CF1-8F80-72C6EDFFFAD6}.Debug|x86.ActiveCfg = Debug|Any CPU + {BD0173FF-6D40-4CF1-8F80-72C6EDFFFAD6}.Debug|x86.Build.0 = Debug|Any CPU + {BD0173FF-6D40-4CF1-8F80-72C6EDFFFAD6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BD0173FF-6D40-4CF1-8F80-72C6EDFFFAD6}.Release|Any CPU.Build.0 = Release|Any CPU + {BD0173FF-6D40-4CF1-8F80-72C6EDFFFAD6}.Release|x64.ActiveCfg = Release|Any CPU + {BD0173FF-6D40-4CF1-8F80-72C6EDFFFAD6}.Release|x64.Build.0 = Release|Any CPU + {BD0173FF-6D40-4CF1-8F80-72C6EDFFFAD6}.Release|x86.ActiveCfg = Release|Any CPU + {BD0173FF-6D40-4CF1-8F80-72C6EDFFFAD6}.Release|x86.Build.0 = Release|Any CPU + {C9F4271E-C48E-419F-A012-9DF69B494D80}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C9F4271E-C48E-419F-A012-9DF69B494D80}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C9F4271E-C48E-419F-A012-9DF69B494D80}.Debug|x64.ActiveCfg = Debug|Any CPU + {C9F4271E-C48E-419F-A012-9DF69B494D80}.Debug|x64.Build.0 = Debug|Any CPU + {C9F4271E-C48E-419F-A012-9DF69B494D80}.Debug|x86.ActiveCfg = Debug|Any CPU + {C9F4271E-C48E-419F-A012-9DF69B494D80}.Debug|x86.Build.0 = Debug|Any CPU + {C9F4271E-C48E-419F-A012-9DF69B494D80}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C9F4271E-C48E-419F-A012-9DF69B494D80}.Release|Any CPU.Build.0 = Release|Any CPU + {C9F4271E-C48E-419F-A012-9DF69B494D80}.Release|x64.ActiveCfg = Release|Any CPU + {C9F4271E-C48E-419F-A012-9DF69B494D80}.Release|x64.Build.0 = Release|Any CPU + {C9F4271E-C48E-419F-A012-9DF69B494D80}.Release|x86.ActiveCfg = Release|Any CPU + {C9F4271E-C48E-419F-A012-9DF69B494D80}.Release|x86.Build.0 = Release|Any CPU + {401194D0-F437-4F68-93E9-1B0D3154C188}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {401194D0-F437-4F68-93E9-1B0D3154C188}.Debug|Any CPU.Build.0 = Debug|Any CPU + {401194D0-F437-4F68-93E9-1B0D3154C188}.Debug|x64.ActiveCfg = Debug|Any CPU + {401194D0-F437-4F68-93E9-1B0D3154C188}.Debug|x64.Build.0 = Debug|Any CPU + {401194D0-F437-4F68-93E9-1B0D3154C188}.Debug|x86.ActiveCfg = Debug|Any CPU + {401194D0-F437-4F68-93E9-1B0D3154C188}.Debug|x86.Build.0 = Debug|Any CPU + {401194D0-F437-4F68-93E9-1B0D3154C188}.Release|Any CPU.ActiveCfg = Release|Any CPU + {401194D0-F437-4F68-93E9-1B0D3154C188}.Release|Any CPU.Build.0 = Release|Any CPU + {401194D0-F437-4F68-93E9-1B0D3154C188}.Release|x64.ActiveCfg = Release|Any CPU + {401194D0-F437-4F68-93E9-1B0D3154C188}.Release|x64.Build.0 = Release|Any CPU + {401194D0-F437-4F68-93E9-1B0D3154C188}.Release|x86.ActiveCfg = Release|Any CPU + {401194D0-F437-4F68-93E9-1B0D3154C188}.Release|x86.Build.0 = Release|Any CPU + {24F119F6-D911-4788-8201-90D78B8B412F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {24F119F6-D911-4788-8201-90D78B8B412F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {24F119F6-D911-4788-8201-90D78B8B412F}.Debug|x64.ActiveCfg = Debug|Any CPU + {24F119F6-D911-4788-8201-90D78B8B412F}.Debug|x64.Build.0 = Debug|Any CPU + {24F119F6-D911-4788-8201-90D78B8B412F}.Debug|x86.ActiveCfg = Debug|Any CPU + {24F119F6-D911-4788-8201-90D78B8B412F}.Debug|x86.Build.0 = Debug|Any CPU + {24F119F6-D911-4788-8201-90D78B8B412F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {24F119F6-D911-4788-8201-90D78B8B412F}.Release|Any CPU.Build.0 = Release|Any CPU + {24F119F6-D911-4788-8201-90D78B8B412F}.Release|x64.ActiveCfg = Release|Any CPU + {24F119F6-D911-4788-8201-90D78B8B412F}.Release|x64.Build.0 = Release|Any CPU + {24F119F6-D911-4788-8201-90D78B8B412F}.Release|x86.ActiveCfg = Release|Any CPU + {24F119F6-D911-4788-8201-90D78B8B412F}.Release|x86.Build.0 = Release|Any CPU + {22F3EF10-5B81-4429-A2D3-1F22E9F9884F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {22F3EF10-5B81-4429-A2D3-1F22E9F9884F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {22F3EF10-5B81-4429-A2D3-1F22E9F9884F}.Debug|x64.ActiveCfg = Debug|Any CPU + {22F3EF10-5B81-4429-A2D3-1F22E9F9884F}.Debug|x64.Build.0 = Debug|Any CPU + {22F3EF10-5B81-4429-A2D3-1F22E9F9884F}.Debug|x86.ActiveCfg = Debug|Any CPU + {22F3EF10-5B81-4429-A2D3-1F22E9F9884F}.Debug|x86.Build.0 = Debug|Any CPU + {22F3EF10-5B81-4429-A2D3-1F22E9F9884F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {22F3EF10-5B81-4429-A2D3-1F22E9F9884F}.Release|Any CPU.Build.0 = Release|Any CPU + {22F3EF10-5B81-4429-A2D3-1F22E9F9884F}.Release|x64.ActiveCfg = Release|Any CPU + {22F3EF10-5B81-4429-A2D3-1F22E9F9884F}.Release|x64.Build.0 = Release|Any CPU + {22F3EF10-5B81-4429-A2D3-1F22E9F9884F}.Release|x86.ActiveCfg = Release|Any CPU + {22F3EF10-5B81-4429-A2D3-1F22E9F9884F}.Release|x86.Build.0 = Release|Any CPU + {97784C9A-D173-4921-A65D-8EBC7DBB30BC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {97784C9A-D173-4921-A65D-8EBC7DBB30BC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {97784C9A-D173-4921-A65D-8EBC7DBB30BC}.Debug|x64.ActiveCfg = Debug|Any CPU + {97784C9A-D173-4921-A65D-8EBC7DBB30BC}.Debug|x64.Build.0 = Debug|Any CPU + {97784C9A-D173-4921-A65D-8EBC7DBB30BC}.Debug|x86.ActiveCfg = Debug|Any CPU + {97784C9A-D173-4921-A65D-8EBC7DBB30BC}.Debug|x86.Build.0 = Debug|Any CPU + {97784C9A-D173-4921-A65D-8EBC7DBB30BC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {97784C9A-D173-4921-A65D-8EBC7DBB30BC}.Release|Any CPU.Build.0 = Release|Any CPU + {97784C9A-D173-4921-A65D-8EBC7DBB30BC}.Release|x64.ActiveCfg = Release|Any CPU + {97784C9A-D173-4921-A65D-8EBC7DBB30BC}.Release|x64.Build.0 = Release|Any CPU + {97784C9A-D173-4921-A65D-8EBC7DBB30BC}.Release|x86.ActiveCfg = Release|Any CPU + {97784C9A-D173-4921-A65D-8EBC7DBB30BC}.Release|x86.Build.0 = Release|Any CPU + {F6BB67DD-29FE-4B81-9B7B-F4060B235F1E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F6BB67DD-29FE-4B81-9B7B-F4060B235F1E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F6BB67DD-29FE-4B81-9B7B-F4060B235F1E}.Debug|x64.ActiveCfg = Debug|Any CPU + {F6BB67DD-29FE-4B81-9B7B-F4060B235F1E}.Debug|x64.Build.0 = Debug|Any CPU + {F6BB67DD-29FE-4B81-9B7B-F4060B235F1E}.Debug|x86.ActiveCfg = Debug|Any CPU + {F6BB67DD-29FE-4B81-9B7B-F4060B235F1E}.Debug|x86.Build.0 = Debug|Any CPU + {F6BB67DD-29FE-4B81-9B7B-F4060B235F1E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F6BB67DD-29FE-4B81-9B7B-F4060B235F1E}.Release|Any CPU.Build.0 = Release|Any CPU + {F6BB67DD-29FE-4B81-9B7B-F4060B235F1E}.Release|x64.ActiveCfg = Release|Any CPU + {F6BB67DD-29FE-4B81-9B7B-F4060B235F1E}.Release|x64.Build.0 = Release|Any CPU + {F6BB67DD-29FE-4B81-9B7B-F4060B235F1E}.Release|x86.ActiveCfg = Release|Any CPU + {F6BB67DD-29FE-4B81-9B7B-F4060B235F1E}.Release|x86.Build.0 = Release|Any CPU + {F871B744-890F-424A-94DB-3F91BB767913}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F871B744-890F-424A-94DB-3F91BB767913}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F871B744-890F-424A-94DB-3F91BB767913}.Debug|x64.ActiveCfg = Debug|Any CPU + {F871B744-890F-424A-94DB-3F91BB767913}.Debug|x64.Build.0 = Debug|Any CPU + {F871B744-890F-424A-94DB-3F91BB767913}.Debug|x86.ActiveCfg = Debug|Any CPU + {F871B744-890F-424A-94DB-3F91BB767913}.Debug|x86.Build.0 = Debug|Any CPU + {F871B744-890F-424A-94DB-3F91BB767913}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F871B744-890F-424A-94DB-3F91BB767913}.Release|Any CPU.Build.0 = Release|Any CPU + {F871B744-890F-424A-94DB-3F91BB767913}.Release|x64.ActiveCfg = Release|Any CPU + {F871B744-890F-424A-94DB-3F91BB767913}.Release|x64.Build.0 = Release|Any CPU + {F871B744-890F-424A-94DB-3F91BB767913}.Release|x86.ActiveCfg = Release|Any CPU + {F871B744-890F-424A-94DB-3F91BB767913}.Release|x86.Build.0 = Release|Any CPU + {01843057-4F63-4FC8-B337-9DBBB9D595C1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {01843057-4F63-4FC8-B337-9DBBB9D595C1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {01843057-4F63-4FC8-B337-9DBBB9D595C1}.Debug|x64.ActiveCfg = Debug|Any CPU + {01843057-4F63-4FC8-B337-9DBBB9D595C1}.Debug|x64.Build.0 = Debug|Any CPU + {01843057-4F63-4FC8-B337-9DBBB9D595C1}.Debug|x86.ActiveCfg = Debug|Any CPU + {01843057-4F63-4FC8-B337-9DBBB9D595C1}.Debug|x86.Build.0 = Debug|Any CPU + {01843057-4F63-4FC8-B337-9DBBB9D595C1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {01843057-4F63-4FC8-B337-9DBBB9D595C1}.Release|Any CPU.Build.0 = Release|Any CPU + {01843057-4F63-4FC8-B337-9DBBB9D595C1}.Release|x64.ActiveCfg = Release|Any CPU + {01843057-4F63-4FC8-B337-9DBBB9D595C1}.Release|x64.Build.0 = Release|Any CPU + {01843057-4F63-4FC8-B337-9DBBB9D595C1}.Release|x86.ActiveCfg = Release|Any CPU + {01843057-4F63-4FC8-B337-9DBBB9D595C1}.Release|x86.Build.0 = Release|Any CPU + {98A314D7-7C12-44F5-B6CC-DA7E04D769B9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {98A314D7-7C12-44F5-B6CC-DA7E04D769B9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {98A314D7-7C12-44F5-B6CC-DA7E04D769B9}.Debug|x64.ActiveCfg = Debug|Any CPU + {98A314D7-7C12-44F5-B6CC-DA7E04D769B9}.Debug|x64.Build.0 = Debug|Any CPU + {98A314D7-7C12-44F5-B6CC-DA7E04D769B9}.Debug|x86.ActiveCfg = Debug|Any CPU + {98A314D7-7C12-44F5-B6CC-DA7E04D769B9}.Debug|x86.Build.0 = Debug|Any CPU + {98A314D7-7C12-44F5-B6CC-DA7E04D769B9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {98A314D7-7C12-44F5-B6CC-DA7E04D769B9}.Release|Any CPU.Build.0 = Release|Any CPU + {98A314D7-7C12-44F5-B6CC-DA7E04D769B9}.Release|x64.ActiveCfg = Release|Any CPU + {98A314D7-7C12-44F5-B6CC-DA7E04D769B9}.Release|x64.Build.0 = Release|Any CPU + {98A314D7-7C12-44F5-B6CC-DA7E04D769B9}.Release|x86.ActiveCfg = Release|Any CPU + {98A314D7-7C12-44F5-B6CC-DA7E04D769B9}.Release|x86.Build.0 = Release|Any CPU + {08281E46-F20B-496B-9ACE-60BFF7542910}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {08281E46-F20B-496B-9ACE-60BFF7542910}.Debug|Any CPU.Build.0 = Debug|Any CPU + {08281E46-F20B-496B-9ACE-60BFF7542910}.Debug|x64.ActiveCfg = Debug|Any CPU + {08281E46-F20B-496B-9ACE-60BFF7542910}.Debug|x64.Build.0 = Debug|Any CPU + {08281E46-F20B-496B-9ACE-60BFF7542910}.Debug|x86.ActiveCfg = Debug|Any CPU + {08281E46-F20B-496B-9ACE-60BFF7542910}.Debug|x86.Build.0 = Debug|Any CPU + {08281E46-F20B-496B-9ACE-60BFF7542910}.Release|Any CPU.ActiveCfg = Release|Any CPU + {08281E46-F20B-496B-9ACE-60BFF7542910}.Release|Any CPU.Build.0 = Release|Any CPU + {08281E46-F20B-496B-9ACE-60BFF7542910}.Release|x64.ActiveCfg = Release|Any CPU + {08281E46-F20B-496B-9ACE-60BFF7542910}.Release|x64.Build.0 = Release|Any CPU + {08281E46-F20B-496B-9ACE-60BFF7542910}.Release|x86.ActiveCfg = Release|Any CPU + {08281E46-F20B-496B-9ACE-60BFF7542910}.Release|x86.Build.0 = Release|Any CPU + {24A19897-7748-41E4-9EC5-BAC5D16221C2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {24A19897-7748-41E4-9EC5-BAC5D16221C2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {24A19897-7748-41E4-9EC5-BAC5D16221C2}.Debug|x64.ActiveCfg = Debug|Any CPU + {24A19897-7748-41E4-9EC5-BAC5D16221C2}.Debug|x64.Build.0 = Debug|Any CPU + {24A19897-7748-41E4-9EC5-BAC5D16221C2}.Debug|x86.ActiveCfg = Debug|Any CPU + {24A19897-7748-41E4-9EC5-BAC5D16221C2}.Debug|x86.Build.0 = Debug|Any CPU + {24A19897-7748-41E4-9EC5-BAC5D16221C2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {24A19897-7748-41E4-9EC5-BAC5D16221C2}.Release|Any CPU.Build.0 = Release|Any CPU + {24A19897-7748-41E4-9EC5-BAC5D16221C2}.Release|x64.ActiveCfg = Release|Any CPU + {24A19897-7748-41E4-9EC5-BAC5D16221C2}.Release|x64.Build.0 = Release|Any CPU + {24A19897-7748-41E4-9EC5-BAC5D16221C2}.Release|x86.ActiveCfg = Release|Any CPU + {24A19897-7748-41E4-9EC5-BAC5D16221C2}.Release|x86.Build.0 = Release|Any CPU + {3A837080-9F9E-40F1-B284-353772853337}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3A837080-9F9E-40F1-B284-353772853337}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3A837080-9F9E-40F1-B284-353772853337}.Debug|x64.ActiveCfg = Debug|Any CPU + {3A837080-9F9E-40F1-B284-353772853337}.Debug|x64.Build.0 = Debug|Any CPU + {3A837080-9F9E-40F1-B284-353772853337}.Debug|x86.ActiveCfg = Debug|Any CPU + {3A837080-9F9E-40F1-B284-353772853337}.Debug|x86.Build.0 = Debug|Any CPU + {3A837080-9F9E-40F1-B284-353772853337}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3A837080-9F9E-40F1-B284-353772853337}.Release|Any CPU.Build.0 = Release|Any CPU + {3A837080-9F9E-40F1-B284-353772853337}.Release|x64.ActiveCfg = Release|Any CPU + {3A837080-9F9E-40F1-B284-353772853337}.Release|x64.Build.0 = Release|Any CPU + {3A837080-9F9E-40F1-B284-353772853337}.Release|x86.ActiveCfg = Release|Any CPU + {3A837080-9F9E-40F1-B284-353772853337}.Release|x86.Build.0 = Release|Any CPU + {7A16DECF-F78A-4614-BA4B-68D478C9456B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7A16DECF-F78A-4614-BA4B-68D478C9456B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7A16DECF-F78A-4614-BA4B-68D478C9456B}.Debug|x64.ActiveCfg = Debug|Any CPU + {7A16DECF-F78A-4614-BA4B-68D478C9456B}.Debug|x64.Build.0 = Debug|Any CPU + {7A16DECF-F78A-4614-BA4B-68D478C9456B}.Debug|x86.ActiveCfg = Debug|Any CPU + {7A16DECF-F78A-4614-BA4B-68D478C9456B}.Debug|x86.Build.0 = Debug|Any CPU + {7A16DECF-F78A-4614-BA4B-68D478C9456B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7A16DECF-F78A-4614-BA4B-68D478C9456B}.Release|Any CPU.Build.0 = Release|Any CPU + {7A16DECF-F78A-4614-BA4B-68D478C9456B}.Release|x64.ActiveCfg = Release|Any CPU + {7A16DECF-F78A-4614-BA4B-68D478C9456B}.Release|x64.Build.0 = Release|Any CPU + {7A16DECF-F78A-4614-BA4B-68D478C9456B}.Release|x86.ActiveCfg = Release|Any CPU + {7A16DECF-F78A-4614-BA4B-68D478C9456B}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {7804CACE-3D3B-412B-9B09-0CE1615242F4} + EndGlobalSection +EndGlobal diff --git a/2022/Day01CSharp/Day01CSharp.csproj b/2022/Day01CSharp/Day01CSharp.csproj new file mode 100644 index 0000000..d453e9a --- /dev/null +++ b/2022/Day01CSharp/Day01CSharp.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp3.1 + + + diff --git a/2022/Day01CSharp/Program.cs b/2022/Day01CSharp/Program.cs new file mode 100644 index 0000000..a8c83d9 --- /dev/null +++ b/2022/Day01CSharp/Program.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; + + +namespace Day01CSharp +{ + internal class Program + { + static void Main(string[] args) + { + var fileName = @"data\input.txt"; + + List elves = new List(); + int elfNum = 0; + + using (StreamReader reader = File.OpenText(fileName)) + { + elfNum = 0; + int currentTotal = 0; + + while (!reader.EndOfStream) + { + string line = reader.ReadLine(); + + int result; + if (Int32.TryParse(line, out result)) + { + currentTotal += result; + } + else + { + elves.Add(currentTotal); + currentTotal = 0; + } + } + } + + elves.Sort(); + Console.WriteLine("Part01: " + elves[elves.Count-1]); + Console.WriteLine("Part02: " + (elves[elves.Count - 1] + elves[elves.Count - 3] + elves[elves.Count - 2])); + } + } +} diff --git a/2022/Day01CSharp/Properties/launchSettings.json b/2022/Day01CSharp/Properties/launchSettings.json new file mode 100644 index 0000000..5ee5821 --- /dev/null +++ b/2022/Day01CSharp/Properties/launchSettings.json @@ -0,0 +1,8 @@ +{ + "profiles": { + "Day01CSharp": { + "commandName": "Project", + "workingDirectory": "C:\\dev\\DevSandbox\\AdventOfCode\\2022\\Day01CSharp" + } + } +} \ No newline at end of file diff --git a/2022/Day01CSharp/data/example.txt b/2022/Day01CSharp/data/example.txt new file mode 100644 index 0000000..7522025 --- /dev/null +++ b/2022/Day01CSharp/data/example.txt @@ -0,0 +1,14 @@ +1000 +2000 +3000 + +4000 + +5000 +6000 + +7000 +8000 +9000 + +10000 \ No newline at end of file diff --git a/2022/Day01CSharp/data/input.txt b/2022/Day01CSharp/data/input.txt new file mode 100644 index 0000000..978347b --- /dev/null +++ b/2022/Day01CSharp/data/input.txt @@ -0,0 +1,2247 @@ +4920 +3254 +4147 +1193 +6516 +4361 +7068 +2021 + +5147 +3535 +5087 +3676 +2012 +5515 +3254 +6597 +1571 +4836 +2302 +5546 +5926 + +33932 +34239 + +2989 +2837 +7396 +1093 +2634 +1270 +5592 +5228 +3083 +5264 +6445 +2625 + +5939 +1245 +4147 +4351 +2047 +2433 +2041 +6812 +5043 +1363 +3471 +2099 +4456 + +5249 +5322 +1297 +6462 +3596 +5742 +4119 +4856 +4419 +4071 +1881 +5903 +2574 + +1983 +10553 +10555 + +2443 +3676 +8079 +2691 +6848 +4439 +6587 +4672 +5953 +1978 +2141 + +6699 +8038 +1545 +8160 +2361 +1513 +2444 +2635 + +2193 +10187 +1997 +7141 +2982 +8262 +3156 +6427 + +3291 +11556 +8033 +6924 +4059 +11793 + +4241 +7720 +11519 +1930 +1659 +4582 + +1167 +7765 +1452 +5466 +2916 +7414 +7644 +7578 +7782 +8510 + +2055 +4368 +8859 +7446 +4466 +6374 +8121 +4476 + +19642 + +19756 +5503 +14960 + +4799 +5211 +4360 +1295 +3856 +6242 +3197 +6332 +1329 +2584 +6941 +4153 + +4130 +3289 +9140 +10120 +9562 +2483 +3198 +1540 + +3764 +6195 +3962 +2765 +3811 +6694 +5667 +1709 +1007 +2703 +3485 +5100 + +4352 +10564 +2729 +13578 +8897 +1396 + +1865 +3363 +9827 +5101 +10333 +10859 +9143 + +4576 +5370 +5898 +3229 +6016 +2574 +6930 +1579 +4669 +4410 +5337 +3386 +4421 + +13015 + +1013 +4228 +4247 +7369 +1096 +1950 +1494 +8525 +5925 + +5823 +10568 +5268 +5641 +8785 +8912 +11094 + +3701 +7367 +4385 +1044 +6149 +5902 +6205 +5365 +3754 +5535 +1966 + +4156 +3499 +1315 +6321 +6612 +6275 +5276 +2117 +1091 +6259 +5949 +1402 +5676 + +2666 +3431 +1510 +1538 +5468 +5875 +2070 +2420 +6821 +5849 +4449 +5432 + +9337 +9238 +10464 +18552 + +1056 +1365 +4071 +6581 +8270 +8159 +4364 +10736 + +13028 +5826 +15980 +1732 + +4907 +1882 +2683 +4719 +6456 +4857 +3197 +3984 +6449 +1717 +3283 +2715 +2252 +5069 + +7361 +1862 +2943 +4939 +5375 +3804 +4085 +5671 +1140 +6735 +7910 + +5454 +7196 +3747 +7054 +6389 +5787 +3422 +8084 + +1198 +5173 +4483 +5275 +3420 +4796 +1514 +3205 +5510 +4683 +3785 +4222 +2131 +4425 +1931 + +2594 +5933 +1319 +2874 +4539 +1193 +5652 +3871 +2600 +4212 +2348 +2111 +3311 +1681 +5117 + +6937 +17934 +17547 +2205 + +42207 + +6720 +6831 +6117 +2506 +6390 +4117 +4812 +3119 +1987 +4894 +6729 +2925 + +1550 +4970 +9656 +2906 +4751 +4784 +3288 +1539 +6215 + +13027 +7811 + +13850 +10753 +9981 +6324 +8115 +5881 + +2785 +3097 +5700 +7471 +2245 +1150 +4556 +4785 +4330 +1712 +2390 + +7365 +10126 +10230 +1976 +9301 +3661 +4866 +3911 + +9208 +4236 + +5215 +4476 +1319 +6105 +2743 +1735 +1610 +4354 +5339 +4826 +1489 +2898 +1072 +3521 +4336 + +4177 +2762 +2087 +6521 +6893 +3577 +7723 +2294 +2385 +6868 +1147 + +7065 +4183 +5277 +6239 +4471 +1189 +2783 +5953 +2786 +4267 + +7666 +6953 +1481 +3649 +1268 +3699 +6362 +8463 + +1434 +3282 +2479 +4298 +6695 +5707 +4198 +5617 +4400 +2994 +6123 +3441 +3812 + +1111 +5657 +1365 +1757 +6355 +1177 +8456 + +11258 +16273 +11668 + +9867 +4242 +3920 +16447 + +4729 +2607 +6532 +18556 + +4987 +1410 +2881 +1961 +4058 +6807 +8387 +7758 +8795 +1634 + +5811 +3892 +1859 +5744 +7245 +7066 +7375 +1742 +5995 +4319 +2355 +7222 + +30020 +4029 + +2245 +10974 +15372 +11623 +8432 + +5880 +1996 +1971 +7875 +2174 +2978 +1786 +8332 +4276 +6803 + +8215 +6053 +8517 +2425 +1812 +2557 +10348 +10246 + +8700 +4591 +5793 +5434 +1458 +6606 +5761 +1648 +5021 +4404 + +3989 +2400 +7776 +7197 +7806 +10582 +5900 +2718 + +6068 +1539 +3141 +1477 +1361 +2208 +5090 +1580 +5947 +5951 +1812 +5378 +5804 +5638 +5312 + +4474 + +6360 +4525 +4855 +5021 +2959 +2477 +1713 +4434 +5802 +2204 +3335 +4492 +5826 +1206 + +7145 +13093 +1498 +3252 +15314 + +15174 +16365 +10100 +16604 + +4036 +2335 +1372 +1133 +2751 +3091 +6276 +5167 +3319 +4853 +4026 +2350 +3211 +6027 + +11739 +7968 +6276 +8105 +3422 +11562 +8058 + +2984 +3205 +5476 +4377 +2200 +1591 +2800 +4601 +1739 +1870 +4023 +5599 +4632 +3303 +3697 + +4576 +9316 +10427 +7702 +9754 +7615 +9315 +4370 + +2000 +1421 +2054 +2815 +5331 +7931 +2738 +5269 +2244 +6796 + +6883 +6480 +3511 +3224 +5486 +2885 +3548 +3682 +4470 +3239 +4827 + +7184 +9580 +1999 +5737 +4811 +8568 +4239 +8467 +4792 + +5675 +1990 + +7726 +7866 +7754 +4629 +2569 +1105 +3469 +2908 +4192 +1816 + +2930 + +6502 +4540 +7235 +1575 +1751 +3699 +2286 +3611 +2691 +6626 +5485 + +3321 +2330 +7310 +6679 +4025 +4145 +9370 +6441 +1327 + +24773 +14248 +13194 + +9446 +3038 +2831 +8834 +10732 +6122 +4841 + +4822 +7182 +5859 +5728 +6185 +4275 +1019 +6577 +5643 +3033 + +5994 +2414 +3017 +5058 +1935 +1636 +1966 +4632 +5037 +5616 +4686 +4674 + +3106 +3734 +5023 +6156 +1402 +3712 +5019 +2790 +5008 +1117 +4757 +6008 +6083 +6105 + +4042 +7107 +4882 +6935 +1690 +4427 +2346 +2091 +4643 +7097 +1904 +7194 + +7018 +9025 +8470 +1859 +6322 +2228 +4829 +8897 +3612 + +4117 +1656 +4928 +1508 +2667 +5532 +3710 +1773 +2931 +3233 +5294 +4164 +3833 +3720 + +3205 +4498 +2911 +2405 +3073 +3954 +2897 +1747 +6012 +3894 +1809 +2322 +3037 +5080 +5642 + +3140 +5499 +5095 +6787 +3287 +3524 +4932 +4821 +1057 +4864 +6707 +7472 + +5519 +3772 +1426 +4295 +2918 +7749 +5899 +7046 +5555 +2867 +1064 + +1971 +3997 +5732 +4127 +4844 +2388 +1309 +4246 +2785 +4623 +5799 +1165 +6172 +4262 + +1318 +8142 +2241 +4760 +9674 +7419 +2466 +9273 +4574 + +5856 +10375 +4046 +3409 +3969 +1271 +5278 +10492 + +4411 +9597 +12144 +2427 + +4018 +4157 +4235 +5785 +1726 +3441 +3494 +2447 +2416 +1356 +4728 +2650 +1420 +3683 +6067 + +3769 +1302 +6345 +3071 +4966 +6099 +1066 +1948 +2674 +5848 +4272 +2711 +2567 + +4066 +5354 +4973 +2435 +1151 +6678 +7956 +2725 +2172 +2648 +7726 + +63544 + +1256 +2627 +3268 +1701 +2103 +7434 +6935 +4158 +7310 +7216 + +7434 +1593 +7501 +3760 +7249 +5345 +9441 +3406 +9592 + +2511 +2482 +1766 +9599 +8843 +6432 + +3421 +12279 +9467 +9661 +6077 +9176 + +8657 +10880 +5285 +2282 +10026 +12772 + +3429 +18733 +19003 +18209 + +2400 +2510 +7381 +5964 +7067 +2650 +5307 +5720 +6347 +2560 +2390 +2234 + +3697 +7063 +5301 +4810 +6678 +5790 +4261 +4821 +5487 +4627 +2179 +1027 + +1973 +3070 +9879 +9967 +2733 +9319 +6399 +4461 + +4723 +9562 +7588 +7196 +3824 +1905 +8669 +4492 +7704 + +5398 +1366 +5587 +1844 +2427 +5769 +2745 +4341 +5241 +3022 +1191 +3413 +5526 +4169 +5318 + +9256 +4411 +1592 +13192 +4358 +9164 + +7206 +7377 +7405 +1241 +3520 +5421 +3194 +4398 +3130 +5747 +6801 + +12096 +2497 +20171 + +5536 +7608 +2823 +1961 +2687 +3633 +6242 +6972 +7026 +1085 + +10337 +6821 +6278 +3563 +2464 +6734 +7147 + +2400 +12892 +3748 +5040 +5681 + +2532 +5143 +2574 +6472 +2021 +5125 +3776 +8805 +6445 +3160 + +7993 +6130 +6896 +6724 +7419 +2792 +5791 +6427 +4395 +6613 + +7106 +13784 +4687 +15507 +3789 + +3061 +6658 +1152 +2153 +6665 +1414 +6942 +2606 +3136 +2106 +1490 +1605 + +6954 +1563 +5337 +4028 +6357 +4377 +5792 +4925 +3155 +3641 +6769 +6480 +3676 + +1041 +9317 +8433 +2701 +1870 +3803 +4461 +3651 +1847 + +10910 +19670 +11716 +2659 + +30352 +37138 + +2741 +2776 +3832 +1542 +1385 +3447 +1681 +1679 +6921 +3434 +2774 +4910 +3359 + +44970 + +10466 +9800 +5115 +10656 +8959 +3555 +6151 +7096 + +6669 +3371 +8649 +4635 +2564 +3714 +6048 +8654 + +6230 +4718 +4207 +5314 +4518 +1065 +4725 +6019 +2797 +4288 +4029 +3672 +2512 + +3881 +1051 +2385 +5596 +1953 +7430 +6124 +6435 +4912 +5542 +3065 +2922 + +6876 +2410 +4472 +7486 +8062 +1372 +2127 +7337 +4843 +1839 + +3585 +1739 +6284 +1589 +5500 +4682 +5124 +4157 +6309 +1914 +2043 +1691 +3933 +4278 + +48042 + +27627 + +4220 +9458 +2713 +12240 +5604 +9996 + +3802 +2081 +4904 +2395 +9205 +8506 +9188 +3693 +8222 + +5853 +7805 +2995 +6765 +5048 +4460 +3794 +9113 + +2421 +1181 +5120 +8593 +6641 +10469 +5194 +4767 + +3459 +4322 +3296 +3622 +1420 +3414 +3680 +5727 +3483 +2965 +1417 +2860 +1743 + +4817 +1158 +5766 +5219 +5055 +2484 +7972 +6099 +1731 +2216 + +36658 +3338 + +1081 +5733 +4818 +1560 +5590 +2215 +4505 +4471 +5901 +5834 +4002 +5859 +2445 +4658 +4556 + +8269 +7294 +7352 +7380 +9460 +6372 +8648 +6618 +7778 + +69108 + +52043 + +16928 +9493 +7073 +9232 + +36109 + +25778 +22161 +15828 + +23126 +7109 +20725 + +6380 +11963 +4847 +6354 +4437 +6647 +1278 + +5930 +15725 +11475 +4706 +12984 + +7420 +1030 +7593 +7902 +4344 +1520 +3027 +6204 +4103 +6199 + +17865 +15923 + +16670 +9704 + +2354 +1376 +5056 +3104 +5934 +2299 +3214 +3786 +1727 +2574 +3473 +2426 +6118 +2895 + +4435 +5251 +5620 +1039 +9111 +6395 +5653 +2114 +3735 + +4151 +1954 + +7553 +1365 +1914 +3190 +4396 +2290 +8059 +3254 +5528 +4298 +3695 + +4130 +4640 +4609 +2811 +6073 +1476 +1889 +3669 +3970 +3863 +4748 +3903 +1699 +1475 + +1236 +7190 +7388 +5200 +7390 +6388 +4237 +4342 +3193 +4708 +7428 +3973 + +6924 +1230 +7064 +8178 +3986 +6749 + +4804 +12669 +1208 + +6625 +21505 + +9146 +9529 +5586 +6100 +10556 +7956 +10460 +9844 + +11697 +11348 +2478 +10217 +6636 +6448 +8675 + +25248 +9578 +9518 + +4018 +7182 +4052 +6927 +6074 +9328 +8946 +2990 +5905 + +6265 +1753 +2832 +1328 +1040 +2234 +4591 +3957 +2883 +2156 +6484 +5892 +1400 + +11460 +8980 + +1626 +2372 +4687 +4361 +5427 +3107 +4195 +4750 +5762 +5131 +4347 +4604 +5367 +5049 + +8771 +4447 +11562 +11357 +3490 +5191 +11245 + +5340 +4060 +6914 +1465 +5552 +2484 +1314 +5044 +5446 +7148 +7413 + +3658 +1992 +1405 +2408 +4732 +4367 +4477 +2757 +6126 +3019 +5295 +3555 +3489 +1670 + +5298 +1153 +2587 +2501 +5053 +3473 +1222 +4376 +1528 +5163 +2148 +5111 +5360 + +3654 +7299 +4196 +6508 +5188 +1451 +2970 +7436 +3752 +1463 +3004 + +2218 +3967 +13801 + +2905 +5730 +8246 +3238 +8283 +1817 +5717 +2050 +3033 +7024 + +13225 + +4113 +1536 +1935 +5294 +1429 +6227 +4352 +1741 +3702 +3583 +1746 +4498 +4600 +5223 + +2939 +1815 +3936 +4177 +5087 +2151 +1101 +3220 +3280 +1104 +3710 +2461 +1079 +5821 +2299 + +9133 +1472 +9518 +10487 +2535 +2882 +9019 +5445 + +1519 +3504 +2016 +3903 +1396 +4158 +4499 +3551 +5869 +5805 +4985 +5626 +2101 +5564 +1920 + +8909 +3061 +1554 +9214 +2214 +3839 +5463 +3025 + +13113 +7001 +7878 +7473 +4632 +9713 + +12079 +5527 +7112 +15090 +6110 + +2423 +1251 +2605 +4267 +1819 +4976 +5864 +1677 +5819 +3128 +2901 +5665 +4239 +1135 +5022 + +3242 +2569 +2199 +3475 +3838 +4515 +5104 +3400 +5847 +5754 +3766 +5976 +5465 +1326 +2820 + +6669 +3409 +8307 +8101 +3769 +7944 +4695 +5969 +4531 +8144 + +7915 +7036 +4332 +3717 +7142 +5777 +1765 +4516 +8328 +3440 + +4283 +3570 +3917 +1671 +13566 + +6007 +2622 +6782 +9384 +6651 +1636 +10266 +2683 + +4425 +2789 +1206 +1324 +2941 +6085 +1017 +1710 +3248 +5484 +3193 +3266 +5762 +3926 +4172 + +10087 +3406 +7523 +5129 +6069 +4631 +10565 + +4711 +6580 +3245 +5589 +5361 +3810 +1208 +1960 +2564 +1354 +3978 +2440 +6301 + +1912 +33251 + +4071 +5039 +6133 +5988 +4864 +5953 +1776 +6238 +4617 +6283 +6686 + +10629 +4063 + +7886 +8940 +3968 +13414 +3542 +9180 + +1012 +5976 +3504 +2715 +5482 +4879 +6052 +1062 +6876 +5507 +4518 +4634 +3293 + +12435 + +5018 +4235 +1768 +6136 +2944 +6098 +6039 +4739 +1870 +4001 +3478 +5745 +6129 +6018 + +1412 +7072 +9099 +5758 +7383 +1312 +3496 +8862 +4325 + +6348 +4566 +2054 +4692 +6145 +5419 +4235 +1091 +2433 +3423 +5381 +1650 +3118 + +7621 +4387 +5645 +1502 +5285 +5116 +6103 +6749 +5313 +5591 +3739 + +6922 +2673 +3933 +3779 +1772 +4773 +4117 +5296 +1712 +5970 +1992 +3869 +2128 + +1305 +1387 +1874 +6006 +4866 +1694 +4304 +5758 +3096 +3531 +5273 +5840 +5746 +5572 +4729 + +3413 +5862 +2239 +6896 +5741 +3893 +6685 +8634 +6773 + +9685 +18275 +1035 +2999 + +3523 +2985 +3303 +3491 +5727 +4046 +7155 +5662 +5964 +1286 +5169 +3176 + +1588 +1482 +4705 +1511 +3635 +2773 +1685 +3255 +2154 +3983 +5567 +5999 +3924 + +7725 +3225 +6714 +2505 +4132 +8122 +4194 +2492 +4798 + +2503 +2536 +1909 +2676 +1259 +2355 +2899 +3061 +1542 +2766 +1498 +5745 +1170 +1892 +5936 + +4059 +7751 +3507 +1772 +5088 +1392 +5732 +3007 +2912 +6057 + +12803 +7942 +6537 + +5456 +1562 +2053 +1370 +7834 +5704 +6388 +7821 +5168 +7429 +5940 + +1701 +5490 +7563 +7803 +5344 +3898 +4668 +1001 +7633 +1182 +1713 + +9171 +6427 +4119 +11031 + +1366 +3723 +2434 +2755 +9399 +5883 +6909 +9368 +7756 + +10765 +3448 +7301 +6743 +10407 +8591 +5634 + +1132 +5100 +7951 +2316 +7428 +9116 +1598 +6209 +5194 + +5004 +3732 +4988 +2590 +2364 +3542 +4872 +4514 +4678 +2772 +5542 +6008 +5023 +4086 +5174 + +1037 +2764 +3730 +1264 +5390 +1941 +5856 +1126 +4767 +1252 +2539 +2821 +4954 +5228 +5775 + +11792 +36472 + +7907 +8488 +7081 +3119 +4463 +9741 + +6587 +5554 +9309 +3336 +4141 +4610 +1182 +7537 + +20224 + +1026 +1730 +7595 +2967 +2759 +5733 +8474 +3173 + +1722 +5030 +3662 +3944 +5346 +6226 +2951 +5273 +4734 +3872 +5489 +2007 +1976 +4426 + +14062 +33048 + +36699 +6652 + +10243 + +13954 +10710 +1170 +9527 +14741 + +4947 +6505 +3906 +3225 +9995 +7317 +3873 +7802 + +10134 +11466 + +3819 +3241 +1596 +3889 +2652 +2038 +5812 +4717 +5398 +5237 +5451 +5827 +2238 +5467 +5205 + +6844 +10182 +7740 +10144 +9078 +8502 +4118 +6710 + +6383 +6161 +7490 +7004 +1194 +4324 +3169 +4960 +7767 +7279 +6494 + +1070 +7216 +8708 +2739 +7850 +9436 +7196 +8420 +6297 + +18873 +9777 +2820 +13284 + +2447 +3969 +2686 +5276 +3988 +3482 +5262 +3450 +3498 +1932 +5784 +2430 +2858 +2490 +4443 diff --git a/2022/Day01CSharp/problem.txt b/2022/Day01CSharp/problem.txt new file mode 100644 index 0000000..6e42745 --- /dev/null +++ b/2022/Day01CSharp/problem.txt @@ -0,0 +1,55 @@ +--- Day 1: Calorie Counting --- + +Santa's reindeer typically eat regular reindeer food, but they need a lot of magical energy to deliver presents on Christmas. For that, their favorite snack is a special type of star fruit that only grows deep in the jungle. The Elves have brought you on their annual expedition to the grove where the fruit grows. + +To supply enough magical energy, the expedition needs to retrieve a minimum of fifty stars by December 25th. Although the Elves assure you that the grove has plenty of fruit, you decide to grab any fruit you see along the way, just in case. + +Collect stars by solving puzzles. Two puzzles will be made available on each day in the Advent calendar; the second puzzle is unlocked when you complete the first. Each puzzle grants one star. Good luck! + +The jungle must be too overgrown and difficult to navigate in vehicles or access from the air; the Elves' expedition traditionally goes on foot. As your boats approach land, the Elves begin taking inventory of their supplies. One important consideration is food - in particular, the number of Calories each Elf is carrying (your puzzle input). + +The Elves take turns writing down the number of Calories contained by the various meals, snacks, rations, etc. that they've brought with them, one item per line. Each Elf separates their own inventory from the previous Elf's inventory (if any) by a blank line. + +For example, suppose the Elves finish writing their items' Calories and end up with the following list: + +1000 +2000 +3000 + +4000 + +5000 +6000 + +7000 +8000 +9000 + +10000 + +This list represents the Calories of the food carried by five Elves: + + The first Elf is carrying food with 1000, 2000, and 3000 Calories, a total of 6000 Calories. + The second Elf is carrying one food item with 4000 Calories. + The third Elf is carrying food with 5000 and 6000 Calories, a total of 11000 Calories. + The fourth Elf is carrying food with 7000, 8000, and 9000 Calories, a total of 24000 Calories. + The fifth Elf is carrying one food item with 10000 Calories. + +In case the Elves get hungry and need extra snacks, they need to know which Elf to ask: they'd like to know how many Calories are being carried by the Elf carrying the most Calories. In the example above, this is 24000 (carried by the fourth Elf). + +Find the Elf carrying the most Calories. How many total Calories is that Elf carrying? + +Your puzzle answer was 69177. +--- Part Two --- + +By the time you calculate the answer to the Elves' question, they've already realized that the Elf carrying the most Calories of food might eventually run out of snacks. + +To avoid this unacceptable situation, the Elves would instead like to know the total Calories carried by the top three Elves carrying the most Calories. That way, even if one of those Elves runs out of snacks, they still have two backups. + +In the example above, the top three Elves are the fourth Elf (with 24000 Calories), then the third Elf (with 11000 Calories), then the fifth Elf (with 10000 Calories). The sum of the Calories carried by these three elves is 45000. + +Find the top three Elves carrying the most Calories. How many Calories are those Elves carrying in total? + +Your puzzle answer was 207456. + +Both parts of this puzzle are complete! They provide two gold stars: ** \ No newline at end of file diff --git a/2022/Day02CSharp/Day02CSharp.csproj b/2022/Day02CSharp/Day02CSharp.csproj new file mode 100644 index 0000000..d453e9a --- /dev/null +++ b/2022/Day02CSharp/Day02CSharp.csproj @@ -0,0 +1,8 @@ + + + + Exe + netcoreapp3.1 + + + diff --git a/2022/Day02CSharp/Program.cs b/2022/Day02CSharp/Program.cs new file mode 100644 index 0000000..a6f1c8e --- /dev/null +++ b/2022/Day02CSharp/Program.cs @@ -0,0 +1,133 @@ +using System; +using System.IO; + +namespace Day02CSharp +{ + internal class Program + { + enum Hand + { + Rock = 1, Paper = 2, Scissors = 3 + } + + static Hand GetHand(int i) + { + switch (i) + { + case 1: + return Hand.Rock; + case 2: + return Hand.Paper; + case 3: + return Hand.Scissors; + default: + throw new ArgumentOutOfRangeException(); + } + } + + static int GetScore(Hand left, Hand right) + { + if (left == right) return 3; + + if ( left == Hand.Rock && right == Hand.Paper + || left == Hand.Paper && right == Hand.Scissors + || left == Hand.Scissors && right == Hand.Rock + ) { return 6; } + + return 0; + } + + static int GetBeater(Hand h) + { + switch (h) + { + case Hand.Rock: return (int)Hand.Paper; + case Hand.Scissors: return (int)Hand.Rock; + case Hand.Paper: return (int)Hand.Scissors; + default: throw new ArgumentOutOfRangeException(); + } + } + + static int GetLoser(Hand h) + { + switch (h) + { + case Hand.Rock: return (int)Hand.Scissors; + case Hand.Scissors: return (int)Hand.Paper; + case Hand.Paper: return (int)Hand.Rock; + default: throw new ArgumentOutOfRangeException(); + } + } + + static void Main(string[] args) + { + Part01(); + Part02(); + } + + private static void Part01() + { + var fileName = @"data\input.txt"; + int currentScore = 0; + + using (StreamReader reader = File.OpenText(fileName)) + { + while (!reader.EndOfStream) + { + string line = reader.ReadLine(); + var split = line.Split(' ', StringSplitOptions.RemoveEmptyEntries); + if (split.Length == 2) + { + int enemy = split[0][0] - 'A' + 1; + int yours = split[1][0] - 'X' + 1; + + // Add in selected shape + currentScore += yours; + currentScore += GetScore(GetHand(enemy), GetHand(yours)); + } + } + } + + Console.WriteLine(currentScore); + } + + private static void Part02() + { + var fileName = @"data\input.txt"; + int currentScore = 0; + + using (StreamReader reader = File.OpenText(fileName)) + { + while (!reader.EndOfStream) + { + string line = reader.ReadLine(); + var split = line.Split(' ', StringSplitOptions.RemoveEmptyEntries); + if (split.Length == 2) + { + int enemy = split[0][0] - 'A' + 1; + int yours = split[1][0]; + + switch (yours) + { + case 'X': // lose + currentScore += GetLoser(GetHand(enemy)); + break; + case 'Y': // draw + currentScore += enemy + 3; + break; + case 'Z': // win + currentScore += GetBeater(GetHand(enemy)) + 6; + break; + default: + throw new ArgumentOutOfRangeException(); + + } + + } + } + } + + Console.WriteLine(currentScore); + } + } +} diff --git a/2022/Day02CSharp/Properties/launchSettings.json b/2022/Day02CSharp/Properties/launchSettings.json new file mode 100644 index 0000000..a3f44c0 --- /dev/null +++ b/2022/Day02CSharp/Properties/launchSettings.json @@ -0,0 +1,8 @@ +{ + "profiles": { + "Day02CSharp": { + "commandName": "Project", + "workingDirectory": "C:\\dev\\DevSandbox\\AdventOfCode\\2022\\Day02CSharp" + } + } +} \ No newline at end of file diff --git a/2022/Day02CSharp/data/example.txt b/2022/Day02CSharp/data/example.txt new file mode 100644 index 0000000..663384c --- /dev/null +++ b/2022/Day02CSharp/data/example.txt @@ -0,0 +1,3 @@ +A Y +B X +C Z \ No newline at end of file diff --git a/2022/Day02CSharp/data/input.txt b/2022/Day02CSharp/data/input.txt new file mode 100644 index 0000000..040e209 --- /dev/null +++ b/2022/Day02CSharp/data/input.txt @@ -0,0 +1,2500 @@ +B X +B Z +B Z +A Y +B X +A Y +C Y +A Y +C X +B X +A Y +B Z +A Y +A X +B X +A Y +A Y +B Y +A Y +A Y +A Y +B Y +C Y +A Y +A Y +C X +B Z +B Z +C Z +B Z +A Y +A Y +B Z +A Y +B X +A Y +A Y +A Y +C Z +A Y +C Y +B X +A Y +A Y +A Y +B X +A X +B Y +B Z +A Y +A Y +A Y +B Z +A Y +A Y +B Y +B X +C Y +B Z +C Z +A Y +C X +B Z +A Z +C X +A Y +A Y +A Z +B Z +A Y +A Y +B Y +B Z +A Y +A Y +C X +B X +A Y +B Z +A Y +B Y +B Y +A Y +B Y +B Z +B X +B Y +B X +B Z +B Z +A Y +A Y +A Z +A X +A Y +B Z +A Y +B X +A X +A Y +B X +A X +A Z +B Z +A Y +A Y +A Y +B Z +A Y +B X +A Y +A Y +B Z +B Y +A X +C Y +C Y +A Y +B X +B X +B Z +B Z +B Y +B Y +B Z +B Z +B X +B Z +B Z +B Z +A Y +A Y +B Z +B Z +B X +A Y +C Z +B Z +B X +B Z +A X +A Y +B X +B X +A Y +B X +B Z +B Z +A Z +B Y +A Y +B X +A Y +C Y +B Y +A Y +A Y +B Y +B X +A Y +B X +B Z +A Y +B Z +B X +B X +A Y +A Y +B Z +A Z +B Z +C Z +B Z +C X +A Y +A Y +A Y +A Y +A Y +A Z +B Z +B Y +C Y +A X +C Y +A Y +A X +B Z +A Y +C Z +A Y +A Y +A Z +C Y +C Y +A Y +A Y +A Y +B Z +B Z +B X +B X +B Y +A Y +A X +B Z +B X +B Z +A Y +B Z +A X +B Z +A Y +A Y +B Z +A X +B Y +A Y +A Y +A Y +B X +A Y +C Z +B Y +B X +A Y +B Z +A Y +A Y +A Y +B Z +A Z +C Y +A Y +A Y +B Z +A Y +A Y +A Y +B Z +A Z +A Y +A Y +A Y +A Y +A Y +A Y +B X +A Y +B X +A Y +C Z +B Z +A Y +A Y +B Z +A Y +A Y +B Z +A Y +A Y +A Y +B Z +A Z +A Y +A Y +C Y +A Y +A Y +A Y +B Z +A Y +A Z +B Z +C Y +B Y +B Z +B Z +C X +A Y +A X +B Y +A Y +B Z +A X +B Y +C Y +B Z +A Y +A Y +B X +A Y +B Z +B Z +B X +B Z +A Y +A Y +A Y +A Y +A Y +A Y +B Y +A Y +A Y +A Y +A Y +A Y +B Z +A Y +A Y +A Y +A Y +A Y +B Y +B Y +A Y +A Z +A Y +A Y +A Y +B X +B Z +A X +A Z +A Y +B X +A Z +A Y +B X +A X +B X +A Y +A Y +B X +B X +A Y +B X +A Y +A Y +B Y +B Z +A Y +A Y +B Z +C X +B X +B Z +B Z +A Y +A X +A Y +A Y +C Y +A Y +B Z +C Y +C Y +A Y +A Y +B X +A Y +A Y +A Y +A Y +A X +A Y +B Y +B Z +A Y +B Z +B X +C Y +B Z +B X +B Z +A Y +A Y +A Z +A Y +C Y +B Z +A Y +A Y +B Y +B Z +B Z +A X +A Y +B Z +A Y +B X +A Y +A Y +B Z +B X +B Z +A Y +A Y +B Y +B Z +B X +A Y +B X +A Y +A Y +A Y +A Y +A Y +B Z +A Y +B Y +A Z +B X +B Z +B X +A Y +B X +A Y +B Y +B Y +A Y +C Z +C Y +A Y +B Z +B X +A Y +A Y +A Y +A Y +B Y +B Z +B Z +A Y +A Y +A Y +A Y +B X +A Y +B Y +B Z +A Y +B Z +B Z +B Z +A Y +B Z +B Z +B X +B Z +A Y +B Z +A Y +B X +B Z +A Y +A Y +A Y +C Y +B Z +C Z +A Y +B Z +C Y +A Y +A Y +A Y +B Z +A Y +A Y +B X +B X +A X +A Y +A Y +B X +B X +A X +A Y +A Y +A X +B X +B Y +A Y +A Y +B X +B Z +B X +A Y +B X +B Y +A Y +B Y +B X +A Z +A Y +A Y +B X +A X +A Z +B X +A Y +A X +B X +A Y +A Y +A Y +A Y +A Y +B Y +A Y +B X +B Y +B Z +B Y +A Y +A Y +A Y +A Y +B Y +A Y +A X +B Y +A Y +B Z +A Y +A Z +A Y +A Y +A Y +C Z +A Y +A Y +B X +B X +C Z +A Y +B Z +A X +B X +A Y +B Z +A Y +B Z +A Y +A Y +B Z +A X +A X +B X +B Y +B Z +B Z +C Z +A Y +A X +A Y +C X +A Y +B X +B X +B Z +A Y +A Z +A Y +C Z +B Z +B Y +B Z +C Y +C X +A Y +B X +B Z +A Y +B X +B Y +A Y +A Y +A Y +A Y +B Z +C Y +B Y +C X +A Y +A Y +B Z +C Y +B Z +A Y +A X +A Y +A Y +A Y +A Y +B X +C Y +A Y +A Y +B X +A Y +B X +B Y +C Z +A Y +A Y +A Y +A Y +B Z +B X +C Y +B X +A Y +A Z +C Y +A X +A Y +B Z +B Z +A Y +A Y +C Y +A Y +B X +C Z +B Z +A X +A Y +A Y +B Z +B Z +A Y +B X +B X +B X +A Y +B X +B Z +A Y +A Y +A Y +A Y +C Y +A Y +C Z +A X +B Z +B X +A Y +B X +A Y +B Y +A Y +A Z +A Y +A Y +B Z +B Y +B X +B Z +A Y +A Y +A Y +A Y +A Y +A Y +A Y +A Y +C Z +B Z +B X +A Y +A Z +B Y +A Y +A Y +B Y +A Y +B Y +B X +A Y +A Z +A Y +A Y +A Y +A Y +A Z +A Y +B Z +A Y +A Y +B Z +B Z +A Y +C Z +B X +A Y +C Y +B X +A Y +B X +B Z +B Z +A Y +A Y +A Y +A X +B X +B X +A Y +B Y +B Y +A Y +A X +A Y +B Z +C Y +A Y +C Z +B Z +C Y +B X +A Z +A Y +A Y +A Y +A Y +C X +B X +B X +A Z +B Y +A Y +A Y +B X +A Y +A Y +A X +B X +C Z +B X +C Y +A X +B X +C Y +C X +A Y +A Y +B Y +C Y +A Y +B X +B Z +A X +A Y +B X +B Z +B Z +B X +B Z +B Y +A Y +A Y +A Y +A Y +A Y +A Z +B Y +A X +B X +C Y +A Y +B Y +A Y +B X +A Y +A Y +A Y +A Y +A Y +A Y +B Z +B Z +A Y +A Y +A Y +C Z +A Y +A Y +A Z +B Z +C Y +B Z +A Y +B Z +A X +A Y +B X +B Z +A Y +A Y +A Y +A Y +B X +B Y +C Z +A Y +A Y +A Y +C Z +A X +B Z +B X +C Y +B X +B X +A Y +C Y +B X +A Z +A Y +B X +A Y +A Y +B Z +A Y +A Y +A Y +B Y +A Y +A Y +A Y +A Y +B X +C Y +A Y +A Y +A Y +A Y +A Y +B Z +B X +B Z +A Y +B X +A Y +B X +C Y +A Y +A Y +A Y +C Y +A Z +A Y +A Y +B Y +B Z +B Z +A Y +B X +A Y +B X +C Y +A Y +B X +B X +B X +A Y +B Y +A Y +A Y +B X +B X +A Y +A Y +C Y +A Y +B Z +A Y +A Y +B Z +A Y +C Y +B X +A Y +A Y +A Y +B X +B X +B X +A Y +B Z +B Z +B X +B Z +A Y +B X +B Z +A Y +A Y +C Z +B X +B X +C Z +C Y +A Y +C Z +A Y +A X +B Z +A Y +A Y +A Y +B Z +B Z +B Z +A Y +A Y +B Z +C Y +A Y +A X +B Z +A Y +A Y +B Z +B Z +C Y +C Z +A Y +A X +B Z +C Z +B Y +B X +B X +B X +B Y +B X +A Y +B X +B Z +B Z +A Y +B Z +A Y +A Y +A Y +B X +A Y +A Y +B X +A Y +A Y +A Y +A Y +A Z +B X +A Y +B Z +A Y +A Y +B Z +A Y +A Y +A Y +A X +A Z +A Y +B Y +C Y +A Y +A Y +A Y +C Y +A Y +B X +A Y +B Z +B X +B Z +A Y +B Z +A Z +B X +A Y +A Z +B X +B X +B Z +A Y +A Y +B Z +A Z +A Y +C Y +A Y +A Y +B Z +B Z +B X +C Y +B X +A Y +B X +B Y +B Y +C Z +A Y +A Y +B Z +B X +A Y +A X +A Y +A Z +A Y +B Y +A X +A Y +B Y +A Y +B X +A Y +A Y +A Y +A Y +B Z +A Y +A Y +A Y +B X +A Y +B Y +A Y +A Y +B X +B Y +B X +B Z +A X +A Y +B X +B Z +A Y +B Y +B Y +A X +C Y +B Z +B X +A Y +B Z +A X +B Y +B X +A Y +C Y +B Z +B X +A Y +B Z +C Z +A Y +A Y +A Y +A Y +B X +B X +A X +A Y +A Y +A Y +A X +C Y +C X +B Z +A Y +A Y +B X +A Y +A Y +C Y +B X +A X +B X +C X +A Z +A Y +C Z +A Y +A Y +B Z +B Z +C Y +A Y +A Y +B X +B X +A Y +C X +A X +A Y +A Y +A Y +B Y +A Y +A Y +B X +A Y +B Z +C X +A Y +B X +A Y +A X +A Y +A X +B X +A Y +A Y +A Y +B Y +B Z +B Z +B X +B Z +A Y +B Z +A Y +B Z +C Z +A Z +A Z +B X +A X +B Z +B Z +A X +B X +C X +C X +A X +A Y +A X +B Z +C Y +B X +B Z +B X +A Y +A Y +A Y +B X +B Z +B Z +B Z +A Y +A Y +B Y +B Z +A Y +A Y +C Y +A Y +A X +A Y +A Y +A Y +B Z +B Z +A Y +B X +A Y +A Y +A Y +A Y +A X +A Y +B Z +A Y +A Y +B Z +A Y +A Y +A Y +B X +A Y +C Y +B X +A Y +A X +A Y +B Z +B Z +B Z +B Z +B Z +A Z +B Z +A Z +C Y +B X +B Y +A X +B X +B X +A Y +A Y +A Y +A Y +B Y +A Y +A Y +A X +A Y +B Y +B X +C Y +B X +C X +A Y +B Z +A Y +A Y +B Z +A Y +A Y +B X +A Y +C Y +A Y +A Y +A Y +C Z +A X +B Y +A Y +C Y +A Y +B Z +A Y +B Z +B X +A Y +A Y +C Y +A Y +B Y +B Z +A Y +B X +A Y +A Y +C Y +C X +A Y +B Z +A Y +B X +B Z +B X +B X +A Y +A Z +B X +A Z +A Y +C Y +B Y +B X +A Y +A Y +A Y +B X +B Z +B Y +B X +A Y +A Y +A Y +A Y +A X +A Y +B X +A Y +B Z +B Z +B X +A Y +A Y +C X +B Z +B Z +B Y +A Z +B Y +B Y +C Z +A X +B X +B X +A Y +A Y +B X +A Y +B Z +B X +B X +C X +B Z +A Y +A Y +B X +B Z +A Y +B Y +A Y +B X +B X +B X +B Y +A Y +B Z +A Y +B Y +B Z +B X +B X +A Y +A Y +A Y +C Y +B X +B Z +A Z +A Y +A Z +A Y +A Y +B Z +A Y +B Z +C Z +B X +A Y +B Z +A Y +A X +B Y +A X +C Y +B Z +B Z +A Y +A X +B Z +C Z +B Z +A Y +A Y +A Y +A Y +A Y +B Z +A Y +A Y +B Z +A Y +A Y +A Y +A Y +B X +B Z +A Y +A Y +C Y +B Z +A Y +C Y +C Z +B Z +A Y +A Y +C Z +B Z +B Y +B X +A Y +A Y +B Z +A Y +C X +B Z +B X +B Z +B X +B Z +B Z +B Z +A Y +A Y +A Y +C Y +A Y +A Y +B Z +B X +B X +A Y +A Y +A X +A Y +A Y +A X +B X +B Y +B Z +A Y +A X +C Z +A Y +C Y +B X +A X +B Z +A Y +B Z +B Z +B X +A Y +A Y +C Z +A Y +A X +A Y +A Y +C Z +A Y +B X +A Z +B Z +B X +A Y +A X +A Y +A Z +B X +B Z +A Y +B Y +A Y +A Y +A Y +A Y +A Y +A Y +B X +C Y +A X +B Z +B X +B X +A Y +A Y +B X +A Y +C Y +A Y +A Y +B X +A Y +C X +A Y +B Z +B X +A Y +A X +C X +A Y +A Y +B Y +A Y +B Z +C Z +B X +B Y +C X +A Y +B X +A Y +B X +B Z +B Y +A Y +A Y +A Y +A Y +A Y +A Y +A Y +B X +A Y +A Y +B Z +B Z +A Y +C Y +B X +A Y +A Y +A Y +B X +A Y +B Z +A Y +B X +B Y +B X +B Y +B X +B Z +A X +B Z +C Z +B Y +A Y +A X +A Z +B Z +B Z +B Z +A Y +A Y +A Y +A Y +A Y +B Z +A Y +A Y +B Y +A Y +A Y +C Z +B Y +C Y +A Y +B Z +A Y +B Z +A Y +B X +A Z +B Z +A Y +A Y +A Y +A Y +A Y +A Y +A Y +A Y +A Y +B Z +B X +A Y +B Z +A Y +A Z +A Y +B Y +A Y +B X +B X +B Z +A Y +A Y +A Y +B Z +B Y +A Y +B X +C Z +A X +B Z +B X +A Y +A Y +A Z +B X +A X +A Y +C Y +C Y +A Y +A Y +A Y +A Y +B Z +B X +B X +A Y +B X +A Y +B X +A Y +A X +B X +B Z +A Y +B X +B X +B Z +B Y +A Y +B Z +A Y +A Y +A Y +A Y +B Y +B Y +B X +B Y +B X +B X +A Y +C X +A X +B X +A Y +B Z +A Y +A Y +B Z +B X +A Y +B Z +B X +B Z +A Y +A Y +A Y +A Y +B Y +B Z +A X +B Z +B X +A Y +A Y +C Z +A Y +B X +B Z +A Y +A Y +C X +A Y +C Y +A Z +A Y +B Y +B X +A Y +B Z +A Y +A Y +A Y +A Y +A X +B Z +B X +B Z +A Y +A Y +B X +A Y +C Z +B X +B X +A Y +A Y +B X +B Y +A Y +A Y +A Y +B Z +A X +A Y +A Y +A Y +A Y +B X +B Z +C Y +B Z +B X +A Y +B Z +A Y +B Z +A Y +C X +A Y +A Y +C Y +A Y +A Y +A Y +A Y +A Y +B X +B Y +A X +A Y +B Z +C Y +A Y +A Y +B X +A X +A X +B X +A Y +A Y +A Y +A X +C Y +B X +A Y +A Y +A Y +A Y +A Y +A Y +B Z +A Y +B Z +C Y +A Y +A Y +A Y +A Y +B Z +B Z +A X +A Y +A X +A X +A Y +A Y +B Z +B X +A Y +A Y +B X +B Y +C Z +A X +A X +A Y +B X +A Y +B X +B Z +A Y +B X +A Y +A Y +B Z +B X +B X +B X +A Y +A Y +B Z +B Z +A Y +B Y +A Y +A Y +A Y +A Y +B X +A X +B Y +B X +A Y +C X +B Z +B X +A Y +B X +B X +B X +B Y +B Y +A Y +A Z +B Z +C Y +A Y +A Y +A Z +A X +A Y +C Y +A Y +B Z +A Y +C Y +C Y +B Z +A Y +B Z +B Z +A Y +B Z +A Y +C Y +B Z +B X +B X +A Y +A Y +C Y +A Y +A Y +A Y +A X +A Y +A Y +A Y +C Z +B X +B Y +B X +A Y +A Y +C Y +A Y +A Y +A Y +B Z +B Y +A X +B Z +A Y +A Y +C Y +A Y +A Y +C Y +B X +B X +A Y +C Z +A Y +A Y +A Y +C Y +B Y +B Z +B Y +C X +A Y +B Y +C Y +B Z +A Y +B X +B X +A Y +A Y +A Y +B Y +B Y +A Y +A Y +B X +A Y +B Y +A Y +A Y +B Z +B Z +A Z +B X +B Z +B X +A Y +A Y +B Z +B Z +C Y +A Y +B Z +B Y +A Y +B X +B Z +B Z +A X +B X +A Y +A Z +B Z +A Y +B X +A Y +A Y +A Y +B X +B X +B Z +A Y +A Y +A X +C X +A Y +A X +B Z +B Z +A Y +C Y +B Z +B Z +B Y +B Z +A X +A Y +A Y +B Z +B X +A Y +C Z +A X +A Y +B Z +B X +C Y +A Y +A Y +B Y +B X +A Z +B X +A Y +A Y +B Z +C Z +B Z +B Z +A Y +A Y +A Y +B X +A Y +A X +C X +A Y +A Y +B Z +A Y +B Y +B X +A Z +A Y +A Y +A Y +C Y +B X +B Y +A Y +B Y +C Z +B X +B Z +B Z +B X +A Y +B Z +B X +A Y +A X +B Y +A Y +A Z +B X +B Z +A Y +C Z +B X +B Z +A Y +A X +A Y +B Z +B Z +A X +C Y +B X +C Z +B Y +A X +B X +C Y +A Y +B Y +B Z +A Y +A Y +A Y +A Y +B Y +B Z +B X +B X +A Y +A Z +B X +A Y +A Y +A Y +A X +B Z +C Z +C Y +B X +A Y +A Y +A Y +C X +B Z +B Z +A Y +A X +B X +A Y +B X +A X +B X +B Z +B X +B X +A Y +A Y +B X +A Y +A Y +A Y +B Z +B Y +B Z +A Y +A Y +A Y +B Z +A Y +A Y +A Y +C Y +B Y +B Z +A Y +B X +B Z +B Y +B X +A Y +A Y +A Y +A Y +C Z +A Y +A X +A Y +A Y +A Y +A Y +B Z +B Z +B Z +C Y +A Y +A Y +A Y +A Z +A Y +C Y +A Y +A Y +B Z +A Y +A Y +A Y +B X +A Y +B Y +A Y +A Y +B Z +B X +A Y +A Y +B Y +B X +A Y +B X +A Y +A Y +A Y +A Z +A Y +B X +B Y +B X +C Y +B Z +A X +A Y +A Y +A Y +B Z +B X +B X +B Z +B Y +A Y +A Z +A Y +C Z +B X +A Y +B Z +B Z +B Y +B X +A Y +C X +A Y +A Y +A Y +A Y +B Z +B Z +A Y +A Y +A Y +B Z +A Y +A Y +A Y +A Y +A Y +A Y +A Y +B X +A Y +C Y +B Z +B Z +A Y +A Y +A Y +B Y +A X +B Z +A X +B Z +B Y +A Y +B Z +B X +B X +A Y +A Y +A Y +B Z +A Y +A Y +B X +B X +A Y +B X +A Y +B X +A Y +B Z +A Y +B X +A Z +B Z +A Y +C Y +A Y +A Y +C Y +A Y +A Y +A X +A Y +C Y +A Y +A Y +B X +A Y +A Y +B X +C Y +A Y +B X +C Z +B Z +B Y +A Y +B Z +B Y +A X +A X +A Y +A Y +A Y +B X +B Z +C Y +B X +B Z +A Y +A Y +A Y +A Y +B X +B Y +C Y +A Y +A Y +A Y +B Z +B Y +A Y +B X +B Z +A Y +A Y +A Y +A Y +B Y +A X +A X +B Z +B Y +C Y +B Z +B Z +A Y +A Y +B Z +A Y +B Z +C X +A Y +A Y +B Y +A Y +B Z +A Y +B Z +B Z +A Y +A Y +C Z +C Y +A Y +A Y +C Y +A Y +C Y +A Y +B Z +A Y +B X +A X +B Z +A Y +A Y +A Y +B Z +A Z +C Y +A Y +A Y +A Y +B X +B X +A Y +A Y +A X +A Y +B Y +B X +B X +A Y +A Y +C Y +A Z +A Y +B X +B X +B Z +A Y +A Y +B Y +C Y +B X +A Y +A Y +A Y +A Y +A X +B X +A Y +A Y +B Z +A X +C Y +B X +A Y +B Z +A Y +A Y +C Y +A Y +A X +A Y +A Y +B Z +A Y +C Z +A Y +B X +B X +B Y +B Z +A Y +A Y +A Y +B Z +A Y +B Z +A Y +A X +A Z +A Y +C Z +B X +A Y +B Z +B Y +A Y +B X +B Z +B Z +B Z +A Y +A X +B Y +B X +A Y +A Y +A Y +B X +A Y +A Y +B Z +A Y +C Y +B X +A Y +A Y +C Z +B Z +A Y +B Z +B Z +B Z +A Y +B Z +B Y +A Y +A Y +C Y +A Y +B Y +A Y +B X +A Y +C Z +A Y +B X +A X +A Y +A Y +B Z +A Y +B X +B Z +B X +A Y +A Y +A Y +A Y +B Z +A Y +B Z +A Y +A Y +C Y +A Y +C Y +B X +B X +A Y +A X +B Z +B X +A Y +A Y +A Y +A Y +B Y +C Y +A X +B X +A Y +C Y +B Y +A Y +B Y +B Z +A Y +B Z +B X +A Y +B X +A Y +C Y +A Y +B X +B Z +A Y +A Y +A Y +A X +A Y +A Z +C Z +A Y +B Z +A Y +B X +B X +A Y +C Y +C Y +A Y +A Y +B Y +A Y +C Z +B Z +C Y +B X +A Y +B Z +A Y +B X +C Y +B X +A Y +A Y +B X +B Z +A Y +B Z +C Y +B X +A Y +B Z +A Y +B Z +B Z +B Z +A Y +A Y +A Y diff --git a/2022/Day02CSharp/problem.txt b/2022/Day02CSharp/problem.txt new file mode 100644 index 0000000..d735b12 --- /dev/null +++ b/2022/Day02CSharp/problem.txt @@ -0,0 +1,48 @@ +--- Day 2: Rock Paper Scissors --- + +The Elves begin to set up camp on the beach. To decide whose tent gets to be closest to the snack storage, a giant Rock Paper Scissors tournament is already in progress. + +Rock Paper Scissors is a game between two players. Each game contains many rounds; in each round, the players each simultaneously choose one of Rock, Paper, or Scissors using a hand shape. Then, a winner for that round is selected: Rock defeats Scissors, Scissors defeats Paper, and Paper defeats Rock. If both players choose the same shape, the round instead ends in a draw. + +Appreciative of your help yesterday, one Elf gives you an encrypted strategy guide (your puzzle input) that they say will be sure to help you win. "The first column is what your opponent is going to play: A for Rock, B for Paper, and C for Scissors. The second column--" Suddenly, the Elf is called away to help with someone's tent. + +The second column, you reason, must be what you should play in response: X for Rock, Y for Paper, and Z for Scissors. Winning every time would be suspicious, so the responses must have been carefully chosen. + +The winner of the whole tournament is the player with the highest score. Your total score is the sum of your scores for each round. The score for a single round is the score for the shape you selected (1 for Rock, 2 for Paper, and 3 for Scissors) plus the score for the outcome of the round (0 if you lost, 3 if the round was a draw, and 6 if you won). + +Since you can't be sure if the Elf is trying to help you or trick you, you should calculate the score you would get if you were to follow the strategy guide. + +For example, suppose you were given the following strategy guide: + +A Y +B X +C Z + +This strategy guide predicts and recommends the following: + + In the first round, your opponent will choose Rock (A), and you should choose Paper (Y). This ends in a win for you with a score of 8 (2 because you chose Paper + 6 because you won). + In the second round, your opponent will choose Paper (B), and you should choose Rock (X). This ends in a loss for you with a score of 1 (1 + 0). + The third round is a draw with both players choosing Scissors, giving you a score of 3 + 3 = 6. + +In this example, if you were to follow the strategy guide, you would get a total score of 15 (8 + 1 + 6). + +What would your total score be if everything goes exactly according to your strategy guide? + +Your puzzle answer was 15337. +--- Part Two --- + +The Elf finishes helping with the tent and sneaks back over to you. "Anyway, the second column says how the round needs to end: X means you need to lose, Y means you need to end the round in a draw, and Z means you need to win. Good luck!" + +The total score is still calculated in the same way, but now you need to figure out what shape to choose so the round ends as indicated. The example above now goes like this: + + In the first round, your opponent will choose Rock (A), and you need the round to end in a draw (Y), so you also choose Rock. This gives you a score of 1 + 3 = 4. + In the second round, your opponent will choose Paper (B), and you choose Rock so you lose (X) with a score of 1 + 0 = 1. + In the third round, you will defeat your opponent's Scissors with Rock for a score of 1 + 6 = 7. + +Now that you're correctly decrypting the ultra top secret strategy guide, you would get a total score of 12. + +Following the Elf's instructions for the second column, what would your total score be if everything goes exactly according to your strategy guide? + +Your puzzle answer was 11696. + +Both parts of this puzzle are complete! They provide two gold stars: ** \ No newline at end of file diff --git a/2022/Day03CSharp/Day03CSharp.csproj b/2022/Day03CSharp/Day03CSharp.csproj new file mode 100644 index 0000000..3370449 --- /dev/null +++ b/2022/Day03CSharp/Day03CSharp.csproj @@ -0,0 +1,8 @@ + + + + Exe + net7.0 + + + diff --git a/2022/Day03CSharp/Program.cs b/2022/Day03CSharp/Program.cs new file mode 100644 index 0000000..aec99b4 --- /dev/null +++ b/2022/Day03CSharp/Program.cs @@ -0,0 +1,243 @@ +using System; +using System.IO; +using System.Collections.Generic; +using System.Collections; +using System.Net.Mail; + +namespace Day03CSharp +{ + internal class Program + { + + static int GetValue(char c) + { + if (c >= 'a' && c <= 'z') + { + return (int)c - (int)'a' + 1; + } + else if (c >= 'A' && c <= 'Z') + { + return (int)c - (int)'A' + 27; + } + else + { + throw new InvalidDataException("Compartment contains character that isnt an ascii english letter"); + } + } + + class Rucksack + { + public Dictionary left = new Dictionary(); + public Dictionary right = new Dictionary(); + + public Rucksack() + { + + } + + public Rucksack(string line) + { + if (line.Length % 2 != 0) + { + throw new ArgumentException("string used to load rucksack isnt even in length"); + } + + var fillFunc = delegate (char c, Dictionary dict) + { + if (!((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))) + { + throw new ArgumentOutOfRangeException("Input isn't a<->z or A<->Z"); + } + + if (!dict.ContainsKey(c)) + { + dict.Add(c, 0); + } + + dict[c]++; + }; + + // fill the left compartment + for (int i = 0; i < line.Length / 2; i++) + { + fillFunc(line[i], left); + } + + // fill the right + for (int i = line.Length / 2; i < line.Length; i++) + { + fillFunc(line[i], right); + } + } + + public char Duplicate + { + get + { + foreach (var c in left.Keys) + { + if (right.ContainsKey(c)) + { + return c; + } + } + + throw new InvalidDataException("Left and right compartment are missing a duplicate character"); + } + } + + public int DuplicateValue + { + get + { + return GetValue(Duplicate); + } + } + + public bool Contains(char c) + { + return left.ContainsKey(c) || right.ContainsKey(c); + } + + public List Keys + { + get + { + var list = new List(); + foreach (var c in left.Keys) + { + list.Add(c); + } + + foreach(var c in right.Keys) + { + if (!list.Contains(c)) + { + list.Add(c); + } + } + + list.Sort(); + + return list; + } + } + } + + static List GetRucksacks(string fileName) + { + List list = new List(); + + using (StreamReader reader = File.OpenText(fileName)) + { + while (!reader.EndOfStream) + { + string line = reader.ReadLine(); + Rucksack r = new Rucksack(line); + list.Add(r); + } + } + + return list; + } + + /**************************************** + // part 01 + */ + + static void Part01(string fileName) + { + var list = GetRucksacks(fileName); + + // We have all the rucksacks, add up the stuff + int sum = 0; + foreach (var r in list) + { + sum += r.DuplicateValue; + } + + Console.WriteLine("Priority Sum: " + sum); + } + + /**************************************** + // Part 02 + */ + + class Group + { + public Group() { } + public Rucksack[] rucksacks = new Rucksack[3]; + + public char Duplicate + { + get + { + var list = rucksacks[0].Keys; + + foreach (var key in list) + { + if (rucksacks[1].Contains(key) && rucksacks[2].Contains(key)) + { + return key; + } + } + + throw new InvalidDataException(); + } + } + + public int DuplicateValue + { + get + { + return GetValue(Duplicate); + } + } + } + + static List GetGroups(string fileName) + { + var list = GetRucksacks(fileName); + + if (list.Count % 3 != 0) + { + throw new InvalidDataException("List of rucksacks isn't divisible by 3, cant create groups"); + } + + List groups = new List(); + + for (int i = 0; i < list.Count; i+=3) + { + var group = new Group(); + + group.rucksacks[0] = list[i+0]; + group.rucksacks[1] = list[i+1]; + group.rucksacks[2] = list[i+2]; + + groups.Add(group); + } + + return groups; + } + + static void Part02(string fileName) + { + var groups = GetGroups(fileName); + int sum = 0; + foreach (var group in groups) + { + sum += group.DuplicateValue; + } + + Console.WriteLine("Group Priority: " + sum); + } + + static void Main(string[] args) + { + //const string fileName = @"example-input01.txt"; + const string fileName = @"puzzle-input01.txt"; + Part01(fileName); + Part02(fileName); + } + } +} diff --git a/2022/Day03CSharp/Properties/launchSettings.json b/2022/Day03CSharp/Properties/launchSettings.json new file mode 100644 index 0000000..f9cdd4e --- /dev/null +++ b/2022/Day03CSharp/Properties/launchSettings.json @@ -0,0 +1,8 @@ +{ + "profiles": { + "Day03CSharp": { + "commandName": "Project", + "workingDirectory": "C:\\dev\\DevSandbox\\AdventOfCode\\2022\\Day03CSharp" + } + } +} \ No newline at end of file diff --git a/2022/Day03CSharp/example-input01.txt b/2022/Day03CSharp/example-input01.txt new file mode 100644 index 0000000..40543a9 --- /dev/null +++ b/2022/Day03CSharp/example-input01.txt @@ -0,0 +1,6 @@ +vJrwpWtwJgWrhcsFMMfFFhFp +jqHRNqRjqzjGDLGLrsFMfFZSrLrFZsSL +PmmdzqPrVvPwwTWBwg +wMqvLMZHhHMvwLHjbvcjnnSBnvTQFn +ttgJtRGJQctTZtZT +CrZsJsPPZsGzwwsLwLmpwMDw \ No newline at end of file diff --git a/2022/Day03CSharp/problem.txt b/2022/Day03CSharp/problem.txt new file mode 100644 index 0000000..c9394ef --- /dev/null +++ b/2022/Day03CSharp/problem.txt @@ -0,0 +1,62 @@ +--- Day 3: Rucksack Reorganization --- + +One Elf has the important job of loading all of the rucksacks with supplies for the jungle journey. Unfortunately, that Elf didn't quite follow the packing instructions, and so a few items now need to be rearranged. + +Each rucksack has two large compartments. All items of a given type are meant to go into exactly one of the two compartments. The Elf that did the packing failed to follow this rule for exactly one item type per rucksack. + +The Elves have made a list of all of the items currently in each rucksack (your puzzle input), but they need your help finding the errors. Every item type is identified by a single lowercase or uppercase letter (that is, a and A refer to different types of items). + +The list of items for each rucksack is given as characters all on a single line. A given rucksack always has the same number of items in each of its two compartments, so the first half of the characters represent items in the first compartment, while the second half of the characters represent items in the second compartment. + +For example, suppose you have the following list of contents from six rucksacks: + +vJrwpWtwJgWrhcsFMMfFFhFp +jqHRNqRjqzjGDLGLrsFMfFZSrLrFZsSL +PmmdzqPrVvPwwTWBwg +wMqvLMZHhHMvwLHjbvcjnnSBnvTQFn +ttgJtRGJQctTZtZT +CrZsJsPPZsGzwwsLwLmpwMDw + + The first rucksack contains the items vJrwpWtwJgWrhcsFMMfFFhFp, which means its first compartment contains the items vJrwpWtwJgWr, while the second compartment contains the items hcsFMMfFFhFp. The only item type that appears in both compartments is lowercase p. + The second rucksack's compartments contain jqHRNqRjqzjGDLGL and rsFMfFZSrLrFZsSL. The only item type that appears in both compartments is uppercase L. + The third rucksack's compartments contain PmmdzqPrV and vPwwTWBwg; the only common item type is uppercase P. + The fourth rucksack's compartments only share item type v. + The fifth rucksack's compartments only share item type t. + The sixth rucksack's compartments only share item type s. + +To help prioritize item rearrangement, every item type can be converted to a priority: + + Lowercase item types a through z have priorities 1 through 26. + Uppercase item types A through Z have priorities 27 through 52. + +In the above example, the priority of the item type that appears in both compartments of each rucksack is 16 (p), 38 (L), 42 (P), 22 (v), 20 (t), and 19 (s); the sum of these is 157. + +Find the item type that appears in both compartments of each rucksack. What is the sum of the priorities of those item types? + +--- Part Two --- + +As you finish identifying the misplaced items, the Elves come to you with another issue. + +For safety, the Elves are divided into groups of three. Every Elf carries a badge that identifies their group. For efficiency, within each group of three Elves, the badge is the only item type carried by all three Elves. That is, if a group's badge is item type B, then all three Elves will have item type B somewhere in their rucksack, and at most two of the Elves will be carrying any other item type. + +The problem is that someone forgot to put this year's updated authenticity sticker on the badges. All of the badges need to be pulled out of the rucksacks so the new authenticity stickers can be attached. + +Additionally, nobody wrote down which item type corresponds to each group's badges. The only way to tell which item type is the right one is by finding the one item type that is common between all three Elves in each group. + +Every set of three lines in your list corresponds to a single group, but each group can have a different badge item type. So, in the above example, the first group's rucksacks are the first three lines: + +vJrwpWtwJgWrhcsFMMfFFhFp +jqHRNqRjqzjGDLGLrsFMfFZSrLrFZsSL +PmmdzqPrVvPwwTWBwg + +And the second group's rucksacks are the next three lines: + +wMqvLMZHhHMvwLHjbvcjnnSBnvTQFn +ttgJtRGJQctTZtZT +CrZsJsPPZsGzwwsLwLmpwMDw + +In the first group, the only item type that appears in all three rucksacks is lowercase r; this must be their badges. In the second group, their badge item type must be Z. + +Priorities for these items must still be found to organize the sticker attachment efforts: here, they are 18 (r) for the first group and 52 (Z) for the second group. The sum of these is 70. + +Find the item type that corresponds to the badges of each three-Elf group. What is the sum of the priorities of those item types? diff --git a/2022/Day03CSharp/puzzle-input01.txt b/2022/Day03CSharp/puzzle-input01.txt new file mode 100644 index 0000000..12fb1b8 --- /dev/null +++ b/2022/Day03CSharp/puzzle-input01.txt @@ -0,0 +1,300 @@ +qFdBBvtHHfvRlfvsqldvqjPpQmnQmjnjjjTRTLGRNG +ZCWhhCsJCzSJzSbzgsmPTGNNPPNGjgLTLjgn +WJZsbJMwJcszJcScwhVltFwBFBlqddvFdHDfqq +crtTsGTtqFThGQGCrsjTwdNJwpRdnJJwffRClpSf +PWVBPVHLvHHVgvZWBzmPpnfRSJJRQnSRflRPSNSl +gmzBzDgzmZQWLDLLgVmDrqGhsscrqDMGhcqtqcFr +HsbcdVrsbVbcLfPqqQsqqtPj +mMBFzZRnmFMRBDnDFBGZDGdDqLjtdQtPtgfPfttgtqgq +BZvZZdJMBFdJhSvhbhchcHll +GNRSqRfcNTpfGCcqjfzBpDQPWBzgDpQsPWzW +rrSdnVHlbMdLdBDzgtBtBmQt +rbFwwnLFLFwlMLrFwFhMVLrGNSTfZTRhfTqjGJRRZTCNcf +QWTnQCnWNNWmTnSPQwmqDbcscbpcjPjVPbrjpq +vJhzZNlNNgdzgzJdlGzHHcHDpjsHqrvbVrbvrD +RzRdRlhLgtCwCWSLnN +SFTJFTTwTVVSJBnSTdvNNfWbZCZWNZCNNhBv +srLrcHDcsjtLcLLcrLctjlcvbDNhmWCvNhZWGZZhNvhZmb +rclgtMPrrSgVTgJCng +DbrhDzcDffbzNbZvZWSSqSTNSVWv +gCPltPmCPglFnPFwtGPhGPwTCTdZZWZVRvWqdRqVVdTdvR +hLBhlmlstcffBzrpfj +wFLLmhMfwZLDwmMNRhZwRLDvJgldbJHPdQvcQHHJQPgH +bjrVrTSSJdQHcVll +CGCSsCCBpspBrqbSttpbqWmWZRmfFRZhZMNNLFqFLm +zWGjjBHGjzzTWMjhtDDWtPPlJZPJpvqQrmZTqQQpmr +RFbVLcBVLRcRVcCsCCqvpCZqmplqQJmPrlvQ +FLNRRSSRgScSVLLLNdFdwjHjnftBtGMgMjzHgzjWjj +znVSqnqbqzSbzTHqDDZmlcFcnhDMnDmn +LtjsvdvLJdjfFwRRCCMlChwCpMcclCcZ +LgvjjfjFQVgNTgWq +SJRJRFFCMSsGRMMwtZJRCVTgqgTVgTBCVpjTjmmWlB +ccvnnpnDVqTcBVTV +vPHprdHdpnzHSMsSrMRZJGws +GddGrcGNHnGvnCHddvCSWqTSWsTwTWShbHlhhb +gDPzLRVZgQfpRRFQDDVFDfzhSzsTBqqqnqbhnWTSSlST +QVFfFgRQQgLtgffZRfpFPfntjrcrjCmtCdMMmjMdJJJNtm +jjmNcpGCNmDqqsBfnZnGGGRLsZ +lrmlVWlQQtWllgtbQVrWBnZsJgsRLfZLhZBBBffL +rWMVQtrFlbFlSSMHVSdHHNHdcdDcddzppzzm +bTpjpjcVTLmphbLppJwqzqwJLqqzzzgRLJ +sdHNbrvNHrqPvZZZPRww +bNQCrCNtNsSlhffhVhpVWFCW +lpNnpMMZZDbNbnBjcrbjvScFmbGj +wqhdqVqdscrjdLsv +HQftVqWCfhwqtCCjWwfqzzVPZRJQgMlggZMMMZTNMNTnNRTN +fvvGbFtVmtTwgtMT +WcCcClzPCCcczJJScPWWZzBDmwbhBBHSghgDDMTHMDBD +nWPljWzZWnbcbRsNFjFFdFdVjFsj +NQrcLNmQGRfGLHHLZgbbnpjZJJJndbgnlv +DWtThDWtzzhltWTwjbdpvjbgqjgg +VtSPFWtBPBFSFBWCStshWBmlRfHfMRcfQLQLLlmCrCcN +pbmwqJnqSJVwwDPCjZZzrZfD +QtssBTvNdNvNtQvQGpGhdjPjDjczZDfjhgPPDcgjgr +GltptQpMGNNpRWlWFVFHJFHLWH +ZLLsDGGVhZcQQLhrLshrVFwHnWqJnWMnJJJnqfWfGn +jMlPdTlPlgCgFpngFWFnJfpw +TlTNbdSSTSTmTjPMTCdBPjBMrLDczsZcNrDhRNDRQRLLRVVz +HDLpBqDVVTvwGDDNRT +PlVWjfhsPMMmWtlFNTrhrrvCCCTNNbvw +lsglfgVJmsfMjJfSqSzdZnLgqcnLnp +pfCDJWBpfDffpJLgQJzzVzNrgNgNgNhNzmVr +ZnnGZbGTPZnsnRFdTlbrwdrNzrrmmWwmwVwttH +GbPGRvTnZljWnpqSMMCjqJQSCf +ZgnFgwggznFrfrwfHhNMMr +pctLCLRhPHBLMLWfBL +JJcdJcQCCJmQJppmlgndnFslsVnsvghZ +WpMgTppWGSWWJmJDpJcJJhqm +zZzjZNHvNjPvNsbZLbRLzsPcqhVJSVttdwhwmdRhtdJRVd +sLbvvCZCPSSSbbPfNlQQTQGBllCTnMnWQn +fwbwswddwSbBfDBggMBPDPhHcPWDmhHhmWnWPC +FQFlzLCzQTlrTTzvltFqFrmhPHjnhhnnchcJWcRRmRRq +lpLzlFZzCltrTNlTztQLZfSMGBNdSBVwbBNVSMSbVs +FMmgbTFdgLSgFQdjrRPrQBPDdj +ZqqWRvsfGrrPvvPC +wZzwnqccRwRNNpRSMztSMMFbgzLTFS +qTwBPfTfqQDMDrssHdvtRHccHMjR +gWSZGWzGFhnFFgnhNsRHtRdsVjZcRjHs +jgplhpJJFgnDrrwfqprwDP +CWhMSRfWhVVnRSZnVVdsLQqQMzGqLBvGMQqczv +PHbpNwrjJplttvcclLlQzzDszc +NrJbJrFNNJNPrmwrtbjtNmCfSWfWhSZZfSWCsfShfFVR +VLhRPLGLRPRSStRRLwfGqfmDwbmqbqqDlD +rBSFvppnzTbwDwlDcFWm +MJrnJTMvMsrTsPtshRNPZdSLhL +BZBrRCrnCQBBnZfGqhGGMMRcthMhMG +TLjsCdDCPTvNssjdsPsDgsgqGcPHczchtHczWzPWzzlWhG +gsTpsdNbvNNjNSpsNDTsmCnSVQFmSFwZnQBnmnQQ +llbsNsWrmbrGbWCNtBjcCFBzQFZBCFjF +LdSpwgdqSgzwJdRdLMRHLjQQjHjFHctjHBDTZj +gSppgpSJMhpzwrhblfbhhlWlnW +DwhTvvsJZWsBnDzPpBLbFp +GHtNGRGNdzbMBBtmBt +NljlCSVSHdjGSQRGlCQSCswqfWzhZfTcfzcJvshJ +lmsGNFsDGqCbFQBbffjjwpzptw +hRQdvdrvrvSngWnvnHrTMfzfzRtftzwVTwwpzB +HnSSWrvLJvWJGFDsmFLPDFcQ +bwwpGphpLghpTvpWphvJlFLJqqltjSjVlSStSR +cmszZdDdBZzcNcDCDcNsmNMcqVjMJStFRJltVPVrlVPjVJll +HcdmcCzzzQcHNcsCdpnGnhwGgnRggHvbbR +CfMBbwBGbMbDCFrDvhFFDT +mjzRjjRdSmjPnzFZgnnrTT +cmSsVcHjLHTwMfLBpBpBwM +whqqfZzgHvhSzzVNVDbpDbmbVbNpJD +GcQFntGTCCcCTMCTGBlJsJsDDWpRbWBsJpNS +FnPcrGFFdddMnCnTqgqgqPHfLjLqgSzz +zMSzzjssFdGnszRtNftqqwFHbbZw +RRPLVrgrwHqBqgwt +rPWmLCTCQlCQQmmrWLrQShJshhzdhhJjcSjlzRds +lvgvCDfPqLHppqpCCDJncbntttbBtBBVHjwtrB +TdddszSQsWcngjzVbcVZ +hRWsTRTGQhNRGhRTFSWmlpgfqlvLmplPqvvGgv +LbWFLQdWWPwWSjSHPHRfppHHDRpggR +zmqqNNzlzmnzzNCmVCmtBzpfGsfpBgDgspprcfcfsrRB +qNNVNJtNmmmNzznVJzvCTDZWhvZZjZFbWQQhFhbZSw +DjdHqJVVhHVZjhDHPWtDtZLFBRBFmSRTFSbwmRRTffTTJf +NNznnGlgMQsnQzNclzpfSRSMRmfPMmFRwBwB +vzrcGcNcPPvHvHPt +wLCcmZwWTNtZNdMSMGSCnJGGMB +RFbHsPhVvFPRjlshhrnQnGjQGSdSqJfqnQBM +HhzVlFHhPwzScmSTgL +TNlBhDNvNBFpJgpPPpDQ +jjfCdCZZqsCZsbdqPgFGGMRzSFMqQMRS +jnWPtWssCtWcmZbbtstvnrrvhVBhTNNhBHlBlL +DZwNWPDzPVWbJngrQjrNnrQcMg +GRRfttLBhhvTvmLmFcFcgFFSnjWrnsrG +TLthBWtTRLHqhlLLfmhBqVPDJVdPwzJCPPZHwdDdVd +GGVhrVSMQwQqfVssVvnWFgvgWn +jtlcRBBtQRmpWsjzFCvzWnvF +QPcRbpppDmNDtPPblZMfhZdDwdMrqSSGrq +ZRrdtBdQvQsWnnfWFZsF +bJLcMzNDLbMgwfnGMWFv +lpvhmzNDmDmlNbzbmrVVPrHRCPHQBVCP +rZllQrsRWrlQswccMVbGbVbTdcQQ +NtJCntLSHCjznfLTcGGGqWMdWM +jCtzzSFthhSSSjPJrFDlvWrlDZRpwpRZ +mQmbLjbrLQjLmTtwwWBTTvWjtt +BHSqdHclHHNFlppNqWPwfwDvTfDPPtCw +ddSGMGHcdcMhMZnBbmbZmgGJJg +lvvBzvDnlzjfPnfjnQPlldRbVbRqbqqCgsqqVpQQgVqc +NNFtGNMtTNFmJNGNZtZMwVRTTcsCpVTbbgCbgRhscp +FGNGZMtNLWmmJWGFWJGLSNtPrPnBfDzzvjnDBzpnvDBLnv +fwvQRFQvQqwpwNJrwN +BstDnBjhjBhnshSptpJzWqNppbfr +CsDjCdZcBCDcjnfDHfhnfggZMGlgQVmgMTRmgVGMMl +MwlBVqVlsgnmzwJsvjhWZhGPvjvRRWzG +QNQpQpftHdHHCHGfSpCrQNdSrDRDhchhjvjcPrRRWrPvhZjv +LtLSCTSGfHGdGwswnqsggssTqV +qDDCHjzjznTvWshZQWfnZZ +PFFmmNMMtNMVFtczcFPJNrLhZwQZQsSvvSvWvGQQJQssss +tFzrrPPNNFlzVrpRTpblRDqjTpDC +DWDrrBdpmdpBrCgDthdtfcHsqJsCqscqwfsjzHcq +TNLNFNSTQNQTSnlMcczVJjVzsqLDDfJJ +TFPZQRvvlMSPPtRWDtmDRWrBGr +LWGVZdrvWdpLGWRsjPMsHmdHdHldlj +zJzznChzzzCSfTgMhCPDmlDCbmlsmjDDQj +nSTTJhJtnShNtzwhgNrGRRWZZRvMWMtVrqGp +PbPmtNmBbPlqBvqlDJBT +LpGVDzVpVZqqSTvq +pMnWGLRLRppnGpGndrGPtgDCjMPmbPgCQmPPNN +sqcZcbZZpcZspcCCRMmznWGWdLWhwDRGTTWggT +NjFSJgVHrvfVtrGzWdSznDwLSTLn +jFrBNVVjBFNvHrFHBlBFFpMslPgPcpMPmcQPPZCgpP +frddqsThtsTfTbPcvhsrbsRLpRBNRpmDpGmRGcRNLpGp +QWJHCJwWzlHZQZHQCJJRzRqnLDGRGpnGBRnNDN +CVwHCClJjQgWCZVZQgMwSdthjrqvrSPPhdbqtPhs +TvdphBBhhhCgdLNNJJJLWz +fVcsqRVrPcnJWgDnJN +JlqsRJtssZwqwVtPwltRPsHHbFTwTFbpjHhQjTQbvpTF +cQSnPDDQJGNzwnNpZb +RHDrssVRDHRgsRFHRlrVwzzpNGZlfZdppZdwGNZb +sHCHtDgtCjVVLFChqPMhBCMcSTqB +hdbQbqcCCQcqFbCbVdcWCQQlRMBtGlRHBtBMpHhpHThZMR +LLsSLLfgJPrgPnssnmlZtlZpHGHVGfZVtZpl +PvmvgmvvnzmrSsSLJDqDNzqFDQdDwzWWbV +HNNjnLbpLGHvWJDhdWWPpWDW +lVcSNgcSVclhRlPZPRCDCR +cqmSQrwwrrVSrtQFqVNmFwjQnvjHzBbLLGjfjzHTzvnH +QmvWVppPHQQvbbvmSHSpPzfzwnWMTZFFzwFMCzLnwT +jGBljlNNjgDtGDrNjjtjqqDRnMzRLnFzCFnMfRfMzCnttF +jqNrrGdJcdgLjqDqBrDQbbmhdQQmmpPbphmbVv +ZHQCggVHHRDWvbfjGptVtLvL +nnFwnwrDDMShnhFrFLLLpjvPlPGGtLGb +dcNSMhrrTDCBCsWgCTQW +HqDDLGtDdCnhfDnwnV +PmlJsJTPlbdBTzTnzhnnCCWWzV +lSPjMScggsScgjSMMbqHLFGrRLGHRZZtdrcG +ZVVtNNppdZSdLtCPqnHhqJJFtb +zgwwQBfwmGgSrDfgrrGBggzHCnbJbqbCJFnqhHBhnHHCqJ +rvrzfmlRrgDgmrzfggvwzvdjjcccLjMjVcVcsVLjVSZR +dppcLRHpphchhNhSddjzHzWQWQLtrMsrWQCWCsMZssCZ +JGfBfJJfBqvGVlVbDBwDBDBfZnrQsMQtssMttssDsQMWZncn +qPVwlgPBmjpPhcmS +zGPnzBgPzPnPlHZlDDHnZBNCvrtcjcjmMcFzNcNFmFdc +qQpfsLTTSspqTfJdmdCtMjdtjvJcmr +bfQqqSrswLLrfpLTqprfTnDVDVBBbgHPDHnhDPgDbV +JssTnsdFztZLdNJnNtTsLNZGqlbGFBqrGMHqHBcFBqMFMH +CCgSfgPSvSfhpShSRppCdfrlqGHGGcHmclmqbbqbqlPc +wvVSVjQSSQhRVvfQChvZZsdtJstjLNLZDJnLss +CmfNNNZNqDrnDjMhZM +gdczzGtdFcddtWQgGGMnVhnjJwnrJFDPTwMP +dlvcdzdHtzQSLRSfmhLSqv +ZpFFLcHFZZRRmJVZgD +PzhrtQntzcrjCRJtbtRgBsBRVR +zdzWfCzhQzlhWfWhlvpFNlpSqcMSHHMv +NrrMgMhNQhNjQrtqtPtwVtZpggPw +TfRLndnLFCRFTFbbRDHwpVqqBBwsHwZsfH +TJFRdLlRThrlcvZcvQ +scrwRVjbQvQBzsBC +gMfVqNnVmnCBQDTvdn +SMqhWqVlmWSmqMVRSJjjpcFrcLpJrR +HtSQHQntHsHMrtHnGfHQVVzLvSBSVvVVSFNJzzVN +cmPRmpqlpPmcgTlTpjJNjjVDvDRFNVVBFD +hlmCpmqmpgqpZTlcdQHFQfbHHZttwMQwtr +VpWgbgfwCjbftwVPPpGQFQhzTBQTBGPzqFTS +dbRbDcRrsnsRrLZmLRDZldDZqTNTGqqFFzGGhSTNTFTzNmNT +MlLdHlDDHrHclMMrCwgHCCwWwCbCCjjg +GGNLhfDMVcVrcGsT +jSJQFjHbwPFSvQSHwZFvHSHrqCCrrTsqBwNBrcBNsVTsqq +QjZSjZJZPvNRZJQPnSZbJZRWLfnmgDlmhdhWgWLdMdfmhM +CgGnzPNggCJtNTgTZTPZzZZvvcDcDDdqDFcJssJDHDqvHq +jhhrrLVlmLRRnRflfVbFHHHqdVsDqcvbHVDb +jWfWwrlmRRnQmPzZNGZPBNCQTB +NzDDhwNmhvtrGmNCvWRVbcRRVTcHHcVFTbwV +LgsPlLsQgQdJsLdldtpgFFTMbnFqTcMbHqFcPncq +dgsJsLLLggljrhtGNNtSjvGm +ptzSrZtzhsmmtPrhLFRFnjnnLMsnfLRL +HvwVDHwWWgGDGdHgqVDWDMnRnTjFNTNjfLJvRRRRRR +DwDgWgQbDDDHwBBBWdwQGVHhlhlZZSSmztfcppSBhzZcZp +CWmWRzlMJqWDWqCJbqDlCBBVLMQHVMGrfMVtQZrsLL +SnhPdFFPNZsBBdHtVQ +SSPcFFgnwnSpwvcSjwzCqRzTmJbpJCRBmbbD +wQbqGWWSqwrbGWWWGjbNMJPfgfnnDmPnPNLfjN +tJFztRZCvVRCztZFZRVgmMhmgNLfRfnmDPNPhm +BFCVZzpVFlHCdbQqcTcGlJbbSG +tttfLPZZQZTlZPHHPWgMVvBnjmvjnjgGBQ +FzcNDDDrNzprrrshprhFJtVGVnjtjGvnhvVnnjnjGM +RDqJNszDPfdqPtlT +QCJdMjCQbdBjSbTHDsbWDDwHTP +zlvlmqzqGfgdNzLldrHwwPGpWDrPGZWprr +gfVfRczVqcRzmdcSQMjQSQCSjQCQ +RhhCGhRBShjjRfpwppFTfFHZHZZD +qzdqzlnPPctPdmtPdTZbwQvvwqvHHvZpwZ +nVTVTcsWmWSRhhRVrGVB +GmshRMnzqRGsPNwMwcrrpcVV +CDCbFCLvCgfDSFLslgDpwpLtTwwcPtNNtTTprt +JvSFbSbbFllJlgDvlJbgdRhRdqzBGnzshZnRRRnHBZ +ShJhtcsvvvQbnnsccVTLVTppWqddpVnLWp +NdzPrPZgPMNNrmzpTzpTCjWfzCpzVL +dZgHmZRPPZRlZmrPDtDRccvbtQQbJbRS +wqjLjwhznhBLqLWGfvSlvcmlrJsqrtJTJJ +PwbpFPQDRCDrDJTrTmvs +gbZVFbZHgwHbCdpCRMnffNLhWnnzMdzLLW +RVVGSNTTRlNqHblBNB +JfwJMvLLZwLsMJwWMJfwLHBqzFlvzpBQcqzblFbBqblq +wMCZJsgJCCCnsMHrgLLjSPSVTgShtRjTPhRRmt +lmQSSWdMHHLWgWqD +ZZtVGGGJrJvGVCwfgHNLccmNFFcqtc +vrCGPhvrTPdRBnsRTmmp +dDMDDjzCQjwCCcDgjSLLLsLNlmpplN +FqrHFTFRLCLVFBmS +JhHJhHRThrfPZPvhnTZZbWdwdwDDWtDzJDtbMtCW +ghwDzJRDwHmPthncSPncLLsPcvnv +MWCrNTCHrMVjQQMQcSdnpTLnFFdTcnTc +qbWMfWfNrWVQWfbjVBbqMfwDtqzmhmRRzGhtHhHhRwZh +fmSmnjTjrlzGlTzJdH +BrhRRQMrgQvgFFhQQbwpFvGGdZqZJqpJqHVpJGJLHdLJ +ggbDwQMsvsMQrFMFcWSPSCPmSsPfnnmP +cmNVbMrrrjcHDRcvfW +wQGdFfSThFsLhhHWvDCWDCJRCCjd +LtpStGhqrrpnfnpp +bvcccTqbgvpGndJtgdsgNd +wDQwQhtQhQRmSmjsJndJdBBJBJnlLS +hwhmRrzFVjtwzDmrVFrvPCcCMVPPvfqpCCTVVb +jRrRNPNRWjPRWPRQNjQjThTCzBBzDCFBGzgDFGGQ +dnppLwmwCnvtlqltvtnTGBThGhdFZhgzDzGccD +MvnqpLlMqCqCHMjWPPHMSHSs +NNpNNvpvBdtTrMFFMhSSwzjzchzwhzwL +VVndHqflQZZZgHSLLhjzRSmZRhcR +glGgnqbQlngnWCGJpJprtrtFrdPPGs +WqwRjzGtRzZZRRGjWBJzjwmfMTHGGssTTDsrLmmmQLMD +SNdvSdFlSNNhSPFFcPFclbQQslHmfHTDsTQMLgDTmHQQ +CNcCFvpdnWpjWwJf +PVPnVHcnRncGZqbVzHVPnnLbSMjwrzWMjSwDtWwWtwWhwDWz +pTfsQCshCllpglWWSjBMSQSrMrjM +hvpvppggCpJTvTmshgfsmZRRHqbcLPHZmPLRnmPZ +LQbhVZZmZhZjBdbGmgHqnHTmvqgnnWHr +SzCfDFFNRfsSFFMFfvprvpWzqzgqTwHTvp +CDNDFJgMDSQhjVdPJLQG +plpdLdpjjrrHJJjLrrHLFdbzzCcvzgFgcwggzPMFvvcMhM +GRtSBQNsQlMPRzRlzw +ZSTtsmBlmjLLpnpH +hglGNVSdNSghzSgCBhDFLBMBtFMMFtHtbtLL +frQZccRcqGFmFHrJ +nvfGZwvTwGTfQwvfTwfgnCSlpdnzgzslppCsCV +snTSPbQnTTnQgbmsTJsLfZwjffhpLnGRjpGfjL +dcNWcNHHlNtWHHlCtltWNFNMLZwjpGfpmrZfrFprrRGpwZfp +HmdNWCmDMVvQPDgqJs +GGFtSngQLfnSnQffgPnRgFRGRwmRJvwbBbJDwjvTbjrwhJvJ +WHClslcNNWcqNWlCZdcHsVrThBwBjbhDTDBhrvDZJTwm +NWVqqcHHNpsNcNVdVlhCMlHQQMQQzLfzQPttFGPMLSLgtF diff --git a/2022/Day04CSharp/Day04CSharp.csproj b/2022/Day04CSharp/Day04CSharp.csproj new file mode 100644 index 0000000..d439800 --- /dev/null +++ b/2022/Day04CSharp/Day04CSharp.csproj @@ -0,0 +1,10 @@ + + + + Exe + net7.0 + enable + enable + + + diff --git a/2022/Day04CSharp/Program.cs b/2022/Day04CSharp/Program.cs new file mode 100644 index 0000000..407791c --- /dev/null +++ b/2022/Day04CSharp/Program.cs @@ -0,0 +1,121 @@ +//const string fileName = @"example-input.txt"; +using System.Collections.Generic; +using System.Text.Unicode; + +const string puzzleFileName = @"puzzle-input.txt"; +const string exampleFileName = @"example-input.txt"; + +var exampleData = new LoadedData(exampleFileName); +var puzzleData = new LoadedData(puzzleFileName); + +Console.WriteLine(String.Format("Part01, ExampleFullyContains: {0}, PuzzleFullyContains {1}", exampleData.GetFullyContainsCount(), puzzleData.GetFullyContainsCount())); +Console.WriteLine(String.Format("Part02, ExampleOverlaps: {0}, PuzzleOverlaps {1}", exampleData.GetOverlapsCount(), puzzleData.GetOverlapsCount())); + +class LoadedData +{ + public class Assignment + { + public struct Range + { + public Range() { } + public Range(int l, int r) + { + Low = l; High = r; + } + + public int Low { get; set; } + public int High { get; set; } + } + + public Range Left; + public Range Right; + + public bool FullyContains + { + get + { + if ( Left.Low >= Right.Low && Left.High <= Right.High + || Right.Low >= Left.Low && Right.High <= Left.High) + { + return true; + } + + return false; + } + } + + public bool Overlaps + { + get + { + if (Left.High < Right.Low || Right.High < Left.Low) + { + return false; + } + + return true; + } + } + } + + public List Assignments = new List(); + + public int GetFullyContainsCount() + { + int count = 0; + + foreach (var a in Assignments) + { + if (a.FullyContains) count++; + } + + return count; + } + + public int GetOverlapsCount() + { + int count = 0; + + foreach (var a in Assignments) + { + if (a.Overlaps) count++; + } + + return count; + } + + public LoadedData(string fileName) + { + using (StreamReader reader = File.OpenText(fileName)) + { + while (!reader.EndOfStream) + { + string? line = reader.ReadLine(); + + if (line == null) + { + throw new InvalidDataException(); + } + + var ranges = line.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries); + + if (ranges.Length != 2) + { + throw new InvalidDataException(); + } + + var rangeLeft = ranges[0].Split('-'); + var rangeRight = ranges[1].Split('-'); + + Assignment a = new Assignment(); + a.Left.Low = Int32.Parse(rangeLeft[0]); + a.Left.High = Int32.Parse(rangeLeft[1]); + a.Right.Low = Int32.Parse(rangeRight[0]); + a.Right.High = Int32.Parse(rangeRight[1]); + + Assignments.Add(a); + } + } + } +} + diff --git a/2022/Day04CSharp/Properties/launchSettings.json b/2022/Day04CSharp/Properties/launchSettings.json new file mode 100644 index 0000000..0f6344c --- /dev/null +++ b/2022/Day04CSharp/Properties/launchSettings.json @@ -0,0 +1,8 @@ +{ + "profiles": { + "Day04CSharp": { + "commandName": "Project", + "workingDirectory": "C:\\dev\\DevSandbox\\AdventOfCode\\2022\\Day04CSharp" + } + } +} \ No newline at end of file diff --git a/2022/Day04CSharp/example-input.txt b/2022/Day04CSharp/example-input.txt new file mode 100644 index 0000000..935059c --- /dev/null +++ b/2022/Day04CSharp/example-input.txt @@ -0,0 +1,6 @@ +2-4,6-8 +2-3,4-5 +5-7,7-9 +2-8,3-7 +6-6,4-6 +2-6,4-8 \ No newline at end of file diff --git a/2022/Day04CSharp/problem.txt b/2022/Day04CSharp/problem.txt new file mode 100644 index 0000000..0faed47 --- /dev/null +++ b/2022/Day04CSharp/problem.txt @@ -0,0 +1,59 @@ +--- Day 4: Camp Cleanup --- + +Space needs to be cleared before the last supplies can be unloaded from the ships, and so several Elves have been assigned the job of cleaning up sections of the camp. Every section has a unique ID number, and each Elf is assigned a range of section IDs. + +However, as some of the Elves compare their section assignments with each other, they've noticed that many of the assignments overlap. To try to quickly find overlaps and reduce duplicated effort, the Elves pair up and make a big list of the section assignments for each pair (your puzzle input). + +For example, consider the following list of section assignment pairs: + +2-4,6-8 +2-3,4-5 +5-7,7-9 +2-8,3-7 +6-6,4-6 +2-6,4-8 + +For the first few pairs, this list means: + + Within the first pair of Elves, the first Elf was assigned sections 2-4 (sections 2, 3, and 4), while the second Elf was assigned sections 6-8 (sections 6, 7, 8). + The Elves in the second pair were each assigned two sections. + The Elves in the third pair were each assigned three sections: one got sections 5, 6, and 7, while the other also got 7, plus 8 and 9. + +This example list uses single-digit section IDs to make it easier to draw; your actual list might contain larger numbers. Visually, these pairs of section assignments look like this: + +.234..... 2-4 +.....678. 6-8 + +.23...... 2-3 +...45.... 4-5 + +....567.. 5-7 +......789 7-9 + +.2345678. 2-8 +..34567.. 3-7 + +.....6... 6-6 +...456... 4-6 + +.23456... 2-6 +...45678. 4-8 + +Some of the pairs have noticed that one of their assignments fully contains the other. For example, 2-8 fully contains 3-7, and 6-6 is fully contained by 4-6. In pairs where one assignment fully contains the other, one Elf in the pair would be exclusively cleaning sections their partner will already be cleaning, so these seem like the most in need of reconsideration. In this example, there are 2 such pairs. + +In how many assignment pairs does one range fully contain the other? + +--- Part Two --- + +It seems like there is still quite a bit of duplicate work planned. Instead, the Elves would like to know the number of pairs that overlap at all. + +In the above example, the first two pairs (2-4,6-8 and 2-3,4-5) don't overlap, while the remaining four pairs (5-7,7-9, 2-8,3-7, 6-6,4-6, and 2-6,4-8) do overlap: + + 5-7,7-9 overlaps in a single section, 7. + 2-8,3-7 overlaps all of the sections 3 through 7. + 6-6,4-6 overlaps in a single section, 6. + 2-6,4-8 overlaps in sections 4, 5, and 6. + +So, in this example, the number of overlapping assignment pairs is 4. + +In how many assignment pairs do the ranges overlap? diff --git a/2022/Day04CSharp/puzzle-input.txt b/2022/Day04CSharp/puzzle-input.txt new file mode 100644 index 0000000..007b3ae --- /dev/null +++ b/2022/Day04CSharp/puzzle-input.txt @@ -0,0 +1,1000 @@ +51-88,52-87 +41-55,22-56 +6-74,74-86 +51-98,52-86 +8-77,3-94 +76-76,77-97 +29-42,29-35 +59-97,60-60 +9-86,27-86 +58-85,59-85 +23-41,26-39 +87-91,74-93 +13-83,83-84 +16-82,15-82 +15-95,14-96 +1-1,2-93 +3-87,2-74 +6-47,7-78 +47-68,47-92 +4-64,5-68 +14-14,8-45 +38-52,52-53 +8-19,25-85 +34-80,35-81 +64-64,64-80 +28-54,53-64 +10-97,16-98 +9-94,93-95 +15-67,16-67 +7-83,8-83 +6-95,90-99 +2-4,3-52 +21-50,20-50 +47-49,15-47 +4-38,7-38 +5-72,13-59 +7-82,2-7 +3-85,4-91 +11-79,6-9 +87-94,77-88 +10-10,8-12 +44-59,58-60 +94-97,5-90 +30-73,29-30 +1-87,10-78 +16-53,6-9 +26-88,27-53 +21-68,67-69 +49-62,50-61 +20-32,10-34 +28-29,21-31 +47-55,89-98 +84-85,23-85 +10-54,11-54 +52-92,19-51 +66-85,48-98 +43-44,44-85 +44-97,43-58 +24-76,68-70 +35-52,13-53 +46-62,43-80 +2-99,21-58 +29-73,28-29 +56-71,56-71 +16-80,14-81 +22-64,16-63 +42-59,42-74 +39-79,39-79 +21-98,20-98 +48-49,49-97 +9-88,10-88 +72-73,51-72 +7-81,6-82 +68-70,15-69 +98-99,70-75 +82-82,16-82 +38-42,38-80 +96-99,1-95 +46-92,45-45 +38-44,37-45 +94-97,93-96 +7-59,43-58 +2-86,85-87 +17-26,22-26 +6-68,5-10 +8-91,91-99 +7-93,13-93 +61-92,61-81 +40-67,30-68 +25-53,38-50 +2-64,3-98 +58-70,58-68 +57-89,57-89 +32-69,31-76 +14-90,4-90 +58-82,32-86 +47-70,46-69 +5-82,3-5 +7-47,42-43 +98-98,1-99 +60-84,60-83 +10-38,9-91 +12-98,10-99 +57-74,56-56 +11-96,10-11 +25-92,24-24 +61-82,99-99 +52-67,54-56 +2-81,1-81 +48-49,1-47 +22-68,36-69 +2-90,7-89 +24-57,31-56 +1-65,46-63 +1-87,39-86 +78-82,80-99 +66-68,35-74 +13-92,14-93 +32-80,32-40 +98-98,4-99 +98-98,2-7 +28-28,28-81 +27-53,15-54 +3-84,1-1 +3-34,9-31 +40-97,19-96 +13-60,7-60 +24-76,40-75 +91-92,5-91 +40-42,8-41 +73-75,28-74 +95-95,44-96 +13-16,16-74 +22-71,21-71 +7-7,5-15 +1-80,4-81 +36-71,37-72 +84-85,68-85 +16-63,12-12 +11-50,4-49 +30-94,10-95 +2-73,2-98 +10-85,10-85 +49-58,30-59 +48-67,15-32 +31-69,32-68 +71-94,70-98 +10-93,9-93 +5-5,6-95 +71-89,70-71 +41-66,6-42 +7-90,6-90 +78-79,17-78 +83-84,2-84 +2-99,1-99 +65-86,66-82 +44-49,44-46 +58-90,90-91 +7-38,8-97 +14-74,88-99 +54-91,53-88 +34-56,34-76 +13-55,14-55 +64-64,63-76 +24-89,4-92 +69-83,68-70 +11-92,10-95 +41-63,35-63 +42-65,43-64 +26-64,64-78 +25-47,16-20 +14-54,13-55 +77-77,76-93 +15-15,16-85 +67-71,66-70 +9-17,12-18 +12-95,12-95 +70-76,29-70 +6-13,7-12 +9-77,8-12 +57-94,7-57 +86-87,87-90 +45-89,63-98 +45-55,63-93 +81-82,7-81 +7-77,76-78 +19-58,9-19 +1-93,2-92 +57-83,56-58 +2-98,4-98 +1-18,1-9 +39-74,27-44 +5-73,3-95 +36-62,94-95 +62-73,61-81 +33-63,53-62 +34-45,33-33 +13-25,12-12 +91-92,25-91 +19-23,41-85 +4-10,24-92 +29-35,35-80 +19-23,22-76 +4-70,5-52 +4-90,3-89 +49-84,19-85 +7-65,6-6 +37-81,31-37 +18-77,76-76 +20-88,87-89 +16-91,79-90 +82-84,39-83 +3-23,39-47 +26-94,95-99 +8-98,7-9 +4-54,21-27 +5-78,20-79 +21-52,22-35 +4-53,2-77 +26-71,18-71 +11-71,12-12 +10-77,9-9 +88-97,41-87 +60-97,96-98 +2-7,8-60 +59-63,60-63 +81-82,31-81 +92-92,86-93 +75-82,16-75 +32-76,33-33 +69-93,70-93 +25-59,24-57 +56-57,41-69 +56-94,55-74 +6-94,28-58 +44-93,45-92 +44-44,44-92 +33-45,46-56 +4-55,11-54 +11-98,12-99 +35-61,37-61 +2-3,8-99 +2-2,4-29 +29-49,21-49 +4-17,19-85 +47-75,47-92 +11-12,11-98 +84-85,21-84 +55-99,54-96 +24-28,4-32 +22-88,21-23 +12-93,11-92 +13-80,13-79 +89-91,3-90 +16-72,57-59 +16-82,82-82 +26-39,13-19 +72-78,73-77 +18-87,96-98 +73-90,60-73 +44-44,3-95 +5-94,4-95 +28-68,29-49 +13-72,14-73 +10-99,5-98 +25-38,11-48 +30-98,97-99 +12-91,13-92 +1-85,2-20 +6-6,8-98 +16-86,86-94 +6-99,3-99 +77-81,3-76 +1-30,9-14 +43-74,42-43 +33-93,32-92 +3-68,4-69 +2-96,2-21 +65-81,80-88 +19-19,20-93 +14-41,32-34 +34-80,34-82 +3-81,9-82 +72-96,72-99 +16-43,42-60 +8-88,54-60 +92-94,93-95 +80-95,80-95 +81-82,29-81 +12-85,13-43 +5-93,91-92 +34-78,51-65 +10-75,9-75 +61-65,33-77 +18-18,19-97 +69-80,70-81 +90-92,68-91 +4-29,5-30 +71-80,70-83 +4-85,5-84 +99-99,26-87 +8-35,35-97 +64-66,30-65 +24-85,21-86 +4-9,10-92 +4-29,3-5 +11-72,11-72 +76-78,62-80 +38-80,48-79 +30-86,2-90 +14-98,15-87 +11-39,7-39 +6-99,7-7 +45-87,13-18 +13-84,12-12 +79-80,79-94 +22-81,23-29 +6-7,7-54 +8-75,9-19 +62-89,62-76 +54-99,53-99 +21-74,5-75 +44-44,46-81 +34-92,34-92 +94-94,11-95 +4-95,13-94 +65-68,67-97 +13-52,12-13 +3-17,17-18 +24-94,67-95 +57-74,56-56 +31-58,18-41 +71-78,70-71 +80-90,80-89 +64-75,4-65 +19-70,46-69 +2-5,4-79 +52-95,73-96 +28-57,15-90 +21-59,53-58 +10-27,6-10 +21-98,58-97 +81-93,82-93 +81-84,50-82 +19-29,20-25 +95-97,1-96 +3-65,38-39 +24-98,25-97 +42-69,15-43 +50-51,37-50 +17-97,16-84 +26-58,41-57 +25-66,24-24 +21-61,57-69 +7-83,6-84 +43-76,51-75 +26-30,32-87 +55-55,56-56 +41-58,57-87 +49-82,48-83 +25-46,45-45 +7-88,1-94 +8-89,7-8 +9-18,11-12 +19-94,94-97 +2-98,1-1 +40-60,41-85 +13-14,13-99 +30-34,29-33 +22-22,21-21 +27-28,25-27 +5-23,16-22 +37-54,54-72 +16-21,25-42 +33-70,47-70 +57-65,57-64 +78-78,15-79 +44-49,44-98 +27-56,20-33 +81-85,71-95 +91-92,1-92 +52-76,50-51 +21-94,21-94 +20-94,21-28 +57-60,59-98 +21-42,22-62 +48-48,42-52 +27-86,21-94 +63-96,63-96 +1-71,1-71 +5-48,47-80 +90-91,28-90 +13-67,13-65 +97-97,13-98 +6-20,7-55 +1-65,2-65 +83-98,98-99 +11-46,45-69 +6-68,6-55 +52-73,53-74 +77-82,77-80 +89-98,6-98 +63-65,17-64 +8-26,1-8 +11-79,3-12 +7-95,2-99 +92-99,50-93 +14-84,83-83 +1-99,1-99 +47-76,46-77 +3-55,2-56 +43-79,79-94 +14-64,43-65 +58-63,59-62 +5-99,2-5 +64-66,6-65 +17-91,16-90 +82-92,91-93 +15-77,16-47 +27-98,59-91 +18-93,17-90 +11-26,17-82 +75-83,66-83 +14-66,2-8 +21-73,74-89 +21-88,22-89 +40-40,60-84 +6-61,13-62 +9-96,7-7 +12-84,7-99 +14-70,9-17 +44-44,15-43 +1-55,2-56 +26-91,25-92 +76-87,36-86 +1-52,52-93 +28-41,27-40 +51-95,67-71 +49-78,34-79 +30-38,30-31 +7-99,6-6 +49-80,14-50 +7-98,9-92 +15-80,14-80 +10-86,8-11 +28-35,27-74 +1-9,10-60 +4-63,9-62 +36-37,36-36 +54-73,54-94 +24-91,92-92 +48-50,16-49 +26-41,26-41 +18-20,19-46 +11-16,16-88 +40-79,27-40 +4-53,4-53 +30-40,56-59 +97-99,2-98 +92-94,10-93 +12-64,12-64 +78-84,13-67 +25-27,26-65 +50-87,27-88 +32-57,18-33 +92-93,24-93 +1-12,12-33 +7-99,6-97 +14-58,3-57 +17-45,18-90 +9-35,29-34 +2-78,46-77 +3-39,23-39 +82-87,10-94 +64-75,64-74 +26-99,25-99 +15-97,96-98 +44-45,26-44 +52-97,34-38 +19-42,7-20 +9-72,31-73 +12-12,11-53 +4-4,6-90 +76-99,98-98 +53-55,54-95 +64-69,8-73 +11-97,14-98 +43-82,83-83 +14-47,13-47 +60-64,59-78 +87-88,1-87 +3-82,5-65 +4-4,5-98 +10-85,84-86 +37-99,37-99 +15-89,16-88 +10-97,9-99 +35-92,97-97 +77-97,78-98 +1-79,5-80 +26-35,27-65 +3-98,4-98 +63-63,1-64 +63-97,67-84 +5-7,9-69 +16-32,17-44 +12-98,13-13 +6-87,49-86 +91-91,24-92 +23-87,23-87 +10-26,16-26 +48-72,3-73 +38-39,38-61 +79-79,54-80 +42-42,43-48 +4-99,11-96 +17-70,18-49 +46-96,85-95 +13-77,14-14 +33-35,34-37 +38-43,42-43 +19-94,5-94 +24-26,25-91 +4-90,4-90 +94-99,30-40 +29-89,30-93 +63-95,20-96 +5-71,4-4 +31-54,21-54 +88-89,4-88 +5-88,2-98 +6-98,19-46 +2-63,96-98 +61-95,61-95 +22-79,21-65 +44-87,43-86 +18-93,34-92 +35-42,41-43 +5-73,16-72 +76-80,52-76 +11-20,7-75 +1-92,9-92 +81-83,45-82 +56-86,55-56 +27-62,18-22 +13-13,12-80 +30-69,31-87 +8-96,1-3 +53-53,52-78 +59-99,58-94 +48-71,5-48 +21-40,40-41 +37-64,40-65 +5-84,6-83 +4-98,12-99 +73-85,69-87 +46-79,21-47 +25-27,26-26 +9-17,8-90 +19-19,20-34 +59-98,58-58 +1-9,9-78 +3-3,4-92 +88-89,46-88 +3-91,2-91 +34-44,45-84 +1-88,2-89 +18-96,6-99 +48-79,39-83 +73-88,41-73 +3-93,6-60 +15-94,93-93 +12-80,11-79 +14-23,51-77 +23-24,3-28 +36-60,6-60 +43-48,44-57 +13-96,6-92 +54-91,53-92 +6-76,5-64 +5-28,26-29 +3-63,5-64 +20-49,30-49 +8-97,6-9 +4-72,8-71 +57-67,56-88 +51-65,25-65 +1-8,3-9 +64-91,64-99 +82-93,92-94 +53-74,4-96 +40-40,41-76 +11-85,52-84 +33-44,44-89 +3-95,95-96 +15-49,48-90 +17-96,95-97 +94-96,3-95 +2-92,3-93 +66-70,65-66 +6-82,53-82 +1-36,3-37 +78-84,71-85 +21-74,15-21 +21-68,42-89 +36-92,65-92 +59-83,59-81 +8-80,93-93 +16-93,5-13 +6-40,5-41 +2-13,13-98 +59-73,25-60 +52-75,68-74 +31-43,32-67 +22-71,22-70 +26-26,27-79 +21-22,23-87 +56-98,17-57 +48-49,13-48 +19-54,19-92 +11-38,10-11 +39-51,46-71 +2-58,57-57 +20-87,45-84 +25-37,21-26 +82-83,4-82 +72-96,73-96 +28-90,27-95 +1-4,3-98 +57-77,1-78 +27-88,21-88 +11-51,51-81 +40-94,79-93 +6-52,52-53 +17-98,18-77 +33-33,4-34 +15-38,8-8 +2-16,22-42 +1-95,96-96 +90-95,13-90 +10-63,9-97 +5-7,5-11 +6-94,93-93 +19-46,46-99 +19-72,20-73 +54-55,55-64 +10-96,7-7 +2-80,1-80 +8-96,6-9 +3-27,1-2 +6-77,5-76 +22-42,3-18 +4-5,3-4 +28-67,66-68 +1-94,99-99 +11-13,10-12 +79-80,74-79 +31-83,35-84 +63-63,59-67 +86-88,45-87 +2-93,2-52 +1-6,6-39 +16-70,27-37 +72-95,94-98 +3-82,3-81 +8-77,7-78 +7-8,9-96 +64-65,64-65 +35-88,34-89 +8-97,7-98 +2-94,4-95 +50-51,4-50 +5-98,1-4 +56-93,1-92 +33-33,34-98 +46-88,66-87 +35-97,34-97 +4-96,1-4 +68-72,69-72 +58-85,59-95 +18-96,72-97 +19-32,20-94 +16-63,15-63 +47-47,9-46 +96-97,18-97 +21-89,5-21 +9-42,20-41 +34-94,19-93 +60-76,59-80 +76-80,77-78 +13-94,23-94 +30-88,22-89 +34-34,35-87 +92-98,40-93 +20-99,20-99 +5-90,6-29 +6-78,40-79 +46-73,44-74 +1-96,37-95 +21-91,91-95 +6-85,3-85 +13-64,79-89 +41-82,81-90 +7-84,8-36 +23-30,23-30 +28-29,29-55 +98-99,13-98 +28-89,88-98 +95-98,94-94 +78-78,79-97 +81-81,81-82 +2-89,1-90 +27-29,28-62 +17-95,36-86 +1-99,3-97 +10-99,11-46 +24-53,23-83 +34-47,17-33 +7-66,7-89 +24-55,20-32 +40-41,18-40 +17-59,33-60 +59-82,60-62 +4-4,3-60 +25-94,24-94 +30-42,41-43 +69-69,5-68 +23-84,24-83 +13-71,13-76 +10-84,7-7 +57-86,51-61 +66-68,62-67 +9-85,10-86 +29-97,4-98 +95-96,46-95 +2-50,1-3 +24-72,6-24 +61-61,29-60 +24-28,24-72 +5-97,2-98 +1-88,16-72 +38-38,37-38 +18-94,66-93 +35-36,36-48 +45-98,45-99 +17-84,85-98 +26-26,25-34 +78-80,29-79 +31-43,30-30 +25-35,29-73 +20-93,27-92 +28-90,29-91 +17-32,31-32 +14-56,7-55 +39-96,3-12 +97-97,35-98 +18-34,35-51 +32-79,9-84 +30-32,13-31 +27-95,31-96 +30-30,31-44 +37-82,38-81 +8-85,7-62 +4-99,5-5 +11-13,12-64 +20-96,19-79 +52-72,29-53 +40-74,73-74 +15-54,16-36 +3-96,4-95 +13-14,16-87 +22-41,39-42 +60-65,59-59 +74-80,15-74 +61-61,4-60 +38-84,39-84 +6-16,6-6 +1-96,96-97 +1-98,97-98 +2-99,1-99 +25-96,12-24 +30-62,30-63 +4-88,5-89 +8-86,7-7 +12-97,4-97 +81-88,80-88 +8-82,6-6 +94-96,3-95 +2-98,1-99 +53-92,75-85 +18-18,19-95 +23-39,23-39 +5-94,93-93 +62-96,26-97 +1-98,35-97 +39-53,8-53 +10-67,9-66 +85-90,14-81 +10-69,11-39 +69-74,39-96 +12-35,12-35 +25-56,24-64 +20-76,75-77 +13-78,10-13 +3-43,43-80 +52-71,21-84 +40-48,33-96 +3-98,9-98 +29-38,37-39 +18-27,26-26 +6-82,4-89 +18-56,19-57 +28-76,6-77 +12-73,11-46 +10-40,11-41 +99-99,34-91 +32-91,91-94 +38-53,27-60 +36-88,35-89 +3-68,2-53 +6-85,6-85 +47-49,6-56 +31-92,30-92 +6-42,11-43 +1-1,9-64 +48-65,24-47 +18-65,2-5 +28-86,1-27 +4-26,5-94 +15-75,14-15 +11-48,10-19 +13-75,14-75 +51-90,47-89 +60-92,13-95 +14-57,14-57 +5-96,4-5 +27-33,20-32 +15-49,1-48 +44-70,43-56 +62-90,88-88 +38-58,13-80 +9-94,8-93 +42-88,42-52 +39-91,42-92 +4-74,75-81 +73-75,72-77 +49-78,50-67 +22-64,9-23 +3-89,55-60 +64-88,76-87 +29-60,60-92 +56-99,98-98 +45-96,19-95 +48-65,49-66 +59-88,90-91 +43-78,20-20 +24-65,15-24 +70-76,67-70 +24-99,25-98 +76-98,75-77 +34-56,34-56 +70-86,85-86 +33-98,32-99 +27-30,28-29 +72-99,72-97 +4-33,1-33 +22-95,21-96 +13-19,22-59 +59-77,6-59 +5-59,3-5 +20-61,60-62 +9-98,10-99 +11-91,19-86 +2-93,4-42 +33-41,61-65 +4-98,4-72 +50-68,13-51 +97-98,21-97 +21-72,22-71 +37-84,2-85 +2-85,18-85 +42-96,41-97 +29-84,52-66 +20-98,57-89 +3-91,3-91 +38-80,39-79 +89-89,11-88 +10-40,40-70 +39-80,38-87 +62-63,52-62 +1-52,2-52 +97-97,2-97 +5-59,58-58 +31-59,28-70 +27-88,21-24 +13-41,13-84 +3-42,3-42 +70-94,69-93 +16-53,15-52 +90-96,13-57 +63-75,60-76 +87-87,4-55 +3-44,4-85 +7-98,10-87 +2-65,3-65 +27-93,27-92 +35-54,34-53 +40-75,98-99 +14-14,13-53 +16-16,17-97 +39-96,41-96 +70-72,71-97 +35-35,32-36 +48-84,85-95 +7-81,11-81 +31-94,31-94 +1-2,4-72 +3-99,3-99 +92-94,21-28 +39-73,38-83 +6-57,6-57 +68-90,67-98 +9-81,10-82 +57-81,57-81 +16-59,57-60 +10-42,2-43 +14-77,12-15 +88-88,3-87 +88-89,13-89 +68-69,7-69 +63-92,92-98 +37-87,85-86 +4-56,5-22 +15-52,51-51 +92-93,74-92 +9-98,7-10 +17-17,18-53 +55-88,61-72 +38-81,65-78 +98-99,59-73 +17-22,18-22 +69-94,68-69 +84-85,6-84 +12-12,13-95 +8-34,7-8 +2-38,3-38 +20-29,28-80 +21-52,22-52 +36-91,90-92 +5-90,4-91 +1-41,1-36 +3-76,10-98 +14-41,2-14 +18-64,19-64 +37-93,83-92 +31-36,32-60 +53-83,47-84 +2-89,70-77 +28-83,84-84 +31-59,58-71 +10-98,10-87 +19-80,20-81 +11-17,9-18 +29-76,48-52 +10-33,33-65 +20-83,68-99 +14-43,13-13 +44-71,62-70 +59-63,49-64 +14-94,94-95 +5-89,2-2 +83-95,84-95 +2-9,8-93 +63-69,68-68 +73-75,5-74 +82-92,91-93 +5-5,4-57 +35-39,35-83 +71-83,56-83 +87-87,8-88 +95-98,2-30 +10-60,59-89 +13-23,25-93 +73-86,22-85 +32-47,46-90 +5-79,3-16 +20-92,28-69 +30-31,19-31 +41-70,9-36 +1-49,2-98 +1-96,41-96 +44-50,44-71 +1-28,2-27 +13-93,74-92 +37-38,31-37 +4-79,3-80 +14-50,37-37 +5-68,46-68 +23-63,22-63 +3-94,1-3 diff --git a/2022/Day05CSharp/Day05CSharp.csproj b/2022/Day05CSharp/Day05CSharp.csproj new file mode 100644 index 0000000..d439800 --- /dev/null +++ b/2022/Day05CSharp/Day05CSharp.csproj @@ -0,0 +1,10 @@ + + + + Exe + net7.0 + enable + enable + + + diff --git a/2022/Day05CSharp/Program.cs b/2022/Day05CSharp/Program.cs new file mode 100644 index 0000000..2d18667 --- /dev/null +++ b/2022/Day05CSharp/Program.cs @@ -0,0 +1,233 @@ + +using System.Net; +using System.Runtime.CompilerServices; +using static LoadedData; + +const string puzzleFileName = @"puzzle-input.txt"; +const string exampleFileName = @"example-input.txt"; + +Part01(); +Part02(); + + +static void Part01() +{ + Console.WriteLine("\n****** UNORDERED ******\n"); + + var exampleData = new LoadedData(exampleFileName); + var puzzleData = new LoadedData(puzzleFileName); + + Console.WriteLine("exmample top crates"); + exampleData.PrintTopCrates(); + Console.WriteLine("performing ops"); + exampleData.PerformOperationsUnordered(exampleData.Operations.Count); + Console.WriteLine("exmample top crates"); + exampleData.PrintTopCrates(); + + Console.WriteLine("\n****** PUZZLE ******\n"); + + Console.WriteLine("puzzle top crates"); + puzzleData.PrintTopCrates(); + Console.WriteLine("performing ops"); + puzzleData.PerformOperationsUnordered(puzzleData.Operations.Count); + Console.WriteLine("puzzle top crates"); + puzzleData.PrintTopCrates(); +} + +static void Part02() +{ + Console.WriteLine("\n****** ORDERED ******\n"); + + var exampleData = new LoadedData(exampleFileName); + var puzzleData = new LoadedData(puzzleFileName); + + Console.WriteLine("exmample top crates"); + exampleData.PrintTopCrates(); + Console.WriteLine("performing ops"); + exampleData.PerformOperationsOrdered(exampleData.Operations.Count); + Console.WriteLine("exmample top crates"); + exampleData.PrintTopCrates(); + + Console.WriteLine("\n****** PUZZLE ******\n"); + + Console.WriteLine("puzzle top crates"); + puzzleData.PrintTopCrates(); + Console.WriteLine("performing ops"); + puzzleData.PerformOperationsOrdered(puzzleData.Operations.Count); + Console.WriteLine("puzzle top crates"); + puzzleData.PrintTopCrates(); +} + +class LoadedData +{ + public class Crate + { + public Crate(char c) + { + Name = c; + } + public char Name { get; set; } + } + + public List[] Crates { get; set; } + public int StackCount { get { return Crates.Length; } } + + public class Operation + { + public Operation(int crateCount, int sourceStack, int destinationStack) + { + CrateCount = crateCount; + SourceStack = sourceStack; + DestinationStack = destinationStack; + } + + public int CrateCount { get; set; } + public int SourceStack { get; set; } + public int DestinationStack { get; set; } + } + + public List Operations { get; set; } = new List(); + private int operationIndex = 0; + + public void PrintTopCrates() + { + string printout = ""; + foreach (var stack in Crates) + { + printout += String.Format("{0}", stack[stack.Count - 1].Name); + } + + Console.WriteLine(printout); + } + + public void PerformOperationsUnordered(int count) + { + if (operationIndex + count > Operations.Count) + { + throw new ArgumentOutOfRangeException("Too many operations requested"); + } + + if (count > 0) + { + for (; operationIndex < Operations.Count; operationIndex++) + { + Operation op = Operations[operationIndex]; + + for (int i = 0; i < op.CrateCount; i++) + { + int sourceIndex = op.SourceStack - 1; + int destinationIndex = op.DestinationStack - 1; + + var crate = Crates[sourceIndex][Crates[sourceIndex].Count - 1]; + Crates[sourceIndex].RemoveAt(Crates[sourceIndex].Count - 1); + Crates[destinationIndex].Add(crate); + } + } + } + } + + public void PerformOperationsOrdered(int count) + { + if (operationIndex + count > Operations.Count) + { + throw new ArgumentOutOfRangeException("Too many operations requested"); + } + + if (count > 0) + { + for (; operationIndex < Operations.Count; operationIndex++) + { + Operation op = Operations[operationIndex]; + + int sourceIndex = op.SourceStack - 1; + int destinationIndex = op.DestinationStack - 1; + int destStackIndex = Crates[destinationIndex].Count; + + for (int i = 0; i < op.CrateCount; i++) + { + var crate = Crates[sourceIndex][Crates[sourceIndex].Count - 1]; + Crates[sourceIndex].RemoveAt(Crates[sourceIndex].Count - 1); + Crates[destinationIndex].Insert(destStackIndex, crate); + } + } + } + } + + public LoadedData(string fileName) + { + using (StreamReader reader = File.OpenText(fileName)) + { + while (!reader.EndOfStream) + { + string? line = reader.ReadLine(); + + if (line == null || (line.Length+1) % 4 != 0) + { + throw new InvalidDataException(); + } + + // It's the first line, create the list + if (Crates == null) + { + int length = (line.Length+1) / 4; + Crates = new List[length]; + for (int i = 0; i < Crates.Length; i++) + { + Crates[i] = new List(); + } + } + + // Validate line length + if ((StackCount*4)-1 > line.Length) + { + throw new ArgumentOutOfRangeException(); + } + + // Check for the crate number line + if (Char.IsAsciiDigit(line[1])) + { + break; + } + + // Read in each crate + for (int i = 0; i < StackCount; i++) + { + // Read in the entry + char c = line[(i * 4) + 1]; + + if (c != ' ') + { + if (!Char.IsLetter(c)) + { + throw new InvalidDataException(); + } + + Crates[i].Insert(0, new Crate(c)); + } + } + } + + // Read in the empty line + reader.ReadLine(); + + while (!reader.EndOfStream) + { + string? line = reader.ReadLine(); + + if (line == null) + { + throw new InvalidDataException(); + } + + var split = line.Split(' ', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries); + + if (split.Length < 5) + { + throw new InvalidDataException(); + } + + Operations.Add(new Operation(Int32.Parse(split[1]), Int32.Parse(split[3]), Int32.Parse(split[5]))); + } + } + } +} \ No newline at end of file diff --git a/2022/Day05CSharp/Properties/launchSettings.json b/2022/Day05CSharp/Properties/launchSettings.json new file mode 100644 index 0000000..c7e990d --- /dev/null +++ b/2022/Day05CSharp/Properties/launchSettings.json @@ -0,0 +1,8 @@ +{ + "profiles": { + "Day05CSharp": { + "commandName": "Project", + "workingDirectory": "C:\\dev\\DevSandbox\\AdventOfCode\\2022\\Day05CSharp" + } + } +} \ No newline at end of file diff --git a/2022/Day05CSharp/example-input.txt b/2022/Day05CSharp/example-input.txt new file mode 100644 index 0000000..814e919 --- /dev/null +++ b/2022/Day05CSharp/example-input.txt @@ -0,0 +1,9 @@ + [D] +[N] [C] +[Z] [M] [P] + 1 2 3 + +move 1 from 2 to 1 +move 3 from 1 to 3 +move 2 from 2 to 1 +move 1 from 1 to 2 \ No newline at end of file diff --git a/2022/Day05CSharp/problem.txt b/2022/Day05CSharp/problem.txt new file mode 100644 index 0000000..ae77870 --- /dev/null +++ b/2022/Day05CSharp/problem.txt @@ -0,0 +1,106 @@ +--- Day 5: Supply Stacks --- + +The expedition can depart as soon as the final supplies have been unloaded from the ships. Supplies are stored in stacks of marked crates, but because the needed supplies are buried under many other crates, the crates need to be rearranged. + +The ship has a giant cargo crane capable of moving crates between stacks. To ensure none of the crates get crushed or fall over, the crane operator will rearrange them in a series of carefully-planned steps. After the crates are rearranged, the desired crates will be at the top of each stack. + +The Elves don't want to interrupt the crane operator during this delicate procedure, but they forgot to ask her which crate will end up where, and they want to be ready to unload them as soon as possible so they can embark. + +They do, however, have a drawing of the starting stacks of crates and the rearrangement procedure (your puzzle input). For example: + + [D] +[N] [C] +[Z] [M] [P] + 1 2 3 + +move 1 from 2 to 1 +move 3 from 1 to 3 +move 2 from 2 to 1 +move 1 from 1 to 2 + +In this example, there are three stacks of crates. Stack 1 contains two crates: crate Z is on the bottom, and crate N is on top. Stack 2 contains three crates; from bottom to top, they are crates M, C, and D. Finally, stack 3 contains a single crate, P. + +Then, the rearrangement procedure is given. In each step of the procedure, a quantity of crates is moved from one stack to a different stack. In the first step of the above rearrangement procedure, one crate is moved from stack 2 to stack 1, resulting in this configuration: + +[D] +[N] [C] +[Z] [M] [P] + 1 2 3 + +In the second step, three crates are moved from stack 1 to stack 3. Crates are moved one at a time, so the first crate to be moved (D) ends up below the second and third crates: + + [Z] + [N] + [C] [D] + [M] [P] + 1 2 3 + +Then, both crates are moved from stack 2 to stack 1. Again, because crates are moved one at a time, crate C ends up below crate M: + + [Z] + [N] +[M] [D] +[C] [P] + 1 2 3 + +Finally, one crate is moved from stack 1 to stack 2: + + [Z] + [N] + [D] +[C] [M] [P] + 1 2 3 + +The Elves just need to know which crate will end up on top of each stack; in this example, the top crates are C in stack 1, M in stack 2, and Z in stack 3, so you should combine these together and give the Elves the message CMZ. + +After the rearrangement procedure completes, what crate ends up on top of each stack? + +--- Part Two --- + +As you watch the crane operator expertly rearrange the crates, you notice the process isn't following your prediction. + +Some mud was covering the writing on the side of the crane, and you quickly wipe it away. The crane isn't a CrateMover 9000 - it's a CrateMover 9001. + +The CrateMover 9001 is notable for many new and exciting features: air conditioning, leather seats, an extra cup holder, and the ability to pick up and move multiple crates at once. + +Again considering the example above, the crates begin in the same configuration: + + [D] +[N] [C] +[Z] [M] [P] + 1 2 3 + +Moving a single crate from stack 2 to stack 1 behaves the same as before: + +[D] +[N] [C] +[Z] [M] [P] + 1 2 3 + +However, the action of moving three crates from stack 1 to stack 3 means that those three moved crates stay in the same order, resulting in this new configuration: + + [D] + [N] + [C] [Z] + [M] [P] + 1 2 3 + +Next, as both crates are moved from stack 2 to stack 1, they retain their order as well: + + [D] + [N] +[C] [Z] +[M] [P] + 1 2 3 + +Finally, a single crate is still moved from stack 1 to stack 2, but now it's crate C that gets moved: + + [D] + [N] + [Z] +[M] [C] [P] + 1 2 3 + +In this example, the CrateMover 9001 has put the crates in a totally different order: MCD. + +Before the rearrangement process finishes, update your simulation so that the Elves know where they should stand to be ready to unload the final supplies. After the rearrangement procedure completes, what crate ends up on top of each stack? diff --git a/2022/Day05CSharp/puzzle-input.txt b/2022/Day05CSharp/puzzle-input.txt new file mode 100644 index 0000000..485d187 --- /dev/null +++ b/2022/Day05CSharp/puzzle-input.txt @@ -0,0 +1,513 @@ +[D] [N] [F] +[H] [F] [L] [J] [H] +[R] [H] [F] [V] [G] [H] +[Z] [Q] [Z] [W] [L] [J] [B] +[S] [W] [H] [B] [H] [D] [C] [M] +[P] [R] [S] [G] [J] [J] [W] [Z] [V] +[W] [B] [V] [F] [G] [T] [T] [T] [P] +[Q] [V] [C] [H] [P] [Q] [Z] [D] [W] + 1 2 3 4 5 6 7 8 9 + +move 1 from 3 to 9 +move 2 from 2 to 1 +move 3 from 5 to 4 +move 1 from 1 to 8 +move 1 from 3 to 9 +move 1 from 5 to 7 +move 1 from 5 to 3 +move 4 from 4 to 2 +move 2 from 3 to 4 +move 1 from 3 to 2 +move 6 from 1 to 5 +move 1 from 4 to 3 +move 1 from 3 to 9 +move 4 from 2 to 4 +move 4 from 8 to 7 +move 3 from 2 to 6 +move 1 from 2 to 7 +move 5 from 5 to 6 +move 1 from 5 to 8 +move 5 from 8 to 7 +move 7 from 4 to 6 +move 15 from 6 to 4 +move 1 from 8 to 7 +move 1 from 1 to 5 +move 1 from 2 to 4 +move 2 from 4 to 8 +move 1 from 5 to 2 +move 5 from 6 to 4 +move 2 from 2 to 1 +move 1 from 9 to 4 +move 1 from 6 to 9 +move 3 from 9 to 3 +move 3 from 4 to 3 +move 1 from 6 to 1 +move 5 from 3 to 4 +move 2 from 8 to 5 +move 1 from 3 to 6 +move 1 from 6 to 2 +move 1 from 2 to 8 +move 6 from 4 to 2 +move 1 from 2 to 7 +move 1 from 5 to 3 +move 4 from 9 to 3 +move 1 from 9 to 1 +move 3 from 1 to 6 +move 1 from 9 to 7 +move 14 from 7 to 6 +move 1 from 8 to 3 +move 4 from 2 to 6 +move 3 from 3 to 8 +move 9 from 4 to 9 +move 1 from 1 to 5 +move 2 from 5 to 8 +move 3 from 8 to 2 +move 4 from 2 to 6 +move 1 from 3 to 9 +move 10 from 6 to 1 +move 5 from 9 to 8 +move 1 from 9 to 3 +move 6 from 1 to 8 +move 3 from 7 to 4 +move 2 from 4 to 5 +move 2 from 9 to 8 +move 15 from 8 to 3 +move 3 from 7 to 9 +move 8 from 4 to 3 +move 2 from 5 to 9 +move 6 from 6 to 5 +move 6 from 5 to 8 +move 1 from 7 to 8 +move 6 from 9 to 2 +move 5 from 2 to 4 +move 6 from 3 to 5 +move 5 from 5 to 8 +move 1 from 5 to 7 +move 1 from 9 to 7 +move 2 from 6 to 4 +move 12 from 8 to 2 +move 7 from 2 to 4 +move 3 from 7 to 5 +move 3 from 5 to 7 +move 3 from 7 to 9 +move 2 from 9 to 7 +move 1 from 9 to 3 +move 2 from 7 to 4 +move 3 from 1 to 9 +move 4 from 6 to 5 +move 6 from 2 to 8 +move 14 from 4 to 9 +move 7 from 9 to 6 +move 9 from 9 to 2 +move 1 from 5 to 8 +move 5 from 6 to 3 +move 3 from 1 to 9 +move 3 from 8 to 9 +move 1 from 8 to 3 +move 5 from 2 to 5 +move 1 from 4 to 9 +move 2 from 6 to 1 +move 2 from 3 to 6 +move 3 from 8 to 3 +move 2 from 6 to 3 +move 1 from 4 to 9 +move 4 from 3 to 6 +move 7 from 6 to 9 +move 10 from 9 to 2 +move 10 from 3 to 2 +move 7 from 2 to 8 +move 2 from 1 to 7 +move 13 from 3 to 7 +move 7 from 5 to 1 +move 1 from 9 to 6 +move 4 from 8 to 4 +move 2 from 3 to 2 +move 4 from 4 to 6 +move 1 from 3 to 4 +move 5 from 6 to 5 +move 3 from 5 to 7 +move 12 from 2 to 5 +move 7 from 5 to 6 +move 2 from 8 to 3 +move 7 from 6 to 2 +move 3 from 9 to 6 +move 1 from 6 to 7 +move 1 from 4 to 9 +move 2 from 7 to 6 +move 13 from 7 to 4 +move 3 from 7 to 5 +move 1 from 9 to 6 +move 12 from 4 to 3 +move 1 from 8 to 1 +move 2 from 6 to 4 +move 1 from 7 to 9 +move 2 from 9 to 8 +move 12 from 3 to 5 +move 1 from 8 to 2 +move 15 from 5 to 6 +move 2 from 4 to 6 +move 1 from 9 to 6 +move 5 from 5 to 4 +move 4 from 4 to 2 +move 2 from 1 to 5 +move 4 from 1 to 5 +move 1 from 8 to 6 +move 7 from 5 to 2 +move 22 from 2 to 3 +move 9 from 6 to 3 +move 1 from 1 to 8 +move 1 from 8 to 7 +move 23 from 3 to 6 +move 2 from 2 to 4 +move 1 from 7 to 8 +move 1 from 8 to 2 +move 19 from 6 to 9 +move 2 from 2 to 4 +move 4 from 4 to 6 +move 13 from 6 to 8 +move 12 from 9 to 1 +move 2 from 5 to 9 +move 2 from 4 to 8 +move 1 from 2 to 7 +move 1 from 7 to 1 +move 4 from 6 to 2 +move 10 from 1 to 9 +move 1 from 6 to 7 +move 11 from 8 to 2 +move 6 from 3 to 6 +move 1 from 7 to 2 +move 1 from 1 to 8 +move 2 from 6 to 7 +move 7 from 6 to 3 +move 9 from 3 to 1 +move 7 from 9 to 6 +move 1 from 8 to 7 +move 4 from 2 to 6 +move 1 from 8 to 3 +move 6 from 6 to 5 +move 9 from 9 to 3 +move 5 from 6 to 1 +move 1 from 7 to 8 +move 2 from 8 to 4 +move 1 from 4 to 2 +move 1 from 4 to 5 +move 2 from 5 to 6 +move 1 from 6 to 9 +move 9 from 1 to 4 +move 4 from 4 to 6 +move 2 from 4 to 7 +move 7 from 2 to 8 +move 5 from 6 to 7 +move 6 from 3 to 8 +move 8 from 1 to 9 +move 3 from 5 to 2 +move 2 from 3 to 9 +move 3 from 9 to 4 +move 7 from 2 to 3 +move 1 from 7 to 2 +move 10 from 3 to 2 +move 6 from 9 to 4 +move 1 from 3 to 1 +move 1 from 1 to 8 +move 4 from 8 to 5 +move 10 from 8 to 4 +move 2 from 8 to 9 +move 7 from 4 to 9 +move 6 from 2 to 6 +move 3 from 6 to 5 +move 4 from 4 to 9 +move 8 from 7 to 5 +move 1 from 9 to 2 +move 7 from 2 to 1 +move 4 from 9 to 8 +move 2 from 6 to 3 +move 2 from 3 to 2 +move 13 from 5 to 7 +move 5 from 4 to 9 +move 5 from 1 to 7 +move 3 from 5 to 8 +move 17 from 7 to 2 +move 15 from 2 to 6 +move 15 from 9 to 5 +move 1 from 9 to 5 +move 4 from 8 to 6 +move 1 from 4 to 6 +move 5 from 4 to 7 +move 5 from 2 to 7 +move 18 from 6 to 2 +move 2 from 7 to 6 +move 10 from 2 to 8 +move 2 from 2 to 3 +move 11 from 8 to 7 +move 7 from 7 to 5 +move 9 from 7 to 5 +move 3 from 7 to 5 +move 2 from 1 to 7 +move 4 from 2 to 1 +move 30 from 5 to 1 +move 1 from 3 to 1 +move 35 from 1 to 9 +move 2 from 2 to 5 +move 2 from 8 to 3 +move 20 from 9 to 2 +move 3 from 7 to 9 +move 1 from 3 to 6 +move 5 from 5 to 3 +move 18 from 2 to 5 +move 4 from 5 to 8 +move 7 from 9 to 7 +move 1 from 6 to 2 +move 3 from 8 to 5 +move 6 from 3 to 5 +move 3 from 7 to 4 +move 2 from 2 to 3 +move 1 from 4 to 5 +move 2 from 4 to 5 +move 4 from 7 to 2 +move 26 from 5 to 6 +move 2 from 2 to 7 +move 1 from 2 to 9 +move 1 from 7 to 8 +move 1 from 5 to 3 +move 2 from 8 to 3 +move 11 from 9 to 3 +move 6 from 3 to 4 +move 27 from 6 to 4 +move 33 from 4 to 3 +move 4 from 6 to 8 +move 1 from 2 to 8 +move 1 from 7 to 3 +move 4 from 8 to 9 +move 1 from 8 to 6 +move 34 from 3 to 8 +move 1 from 8 to 5 +move 1 from 2 to 9 +move 8 from 3 to 9 +move 3 from 5 to 4 +move 1 from 6 to 5 +move 27 from 8 to 9 +move 1 from 3 to 4 +move 1 from 5 to 7 +move 3 from 8 to 1 +move 11 from 9 to 1 +move 1 from 7 to 5 +move 11 from 9 to 3 +move 1 from 5 to 1 +move 1 from 8 to 7 +move 2 from 9 to 2 +move 1 from 2 to 1 +move 1 from 2 to 7 +move 2 from 8 to 2 +move 6 from 3 to 8 +move 1 from 4 to 2 +move 7 from 1 to 2 +move 1 from 7 to 1 +move 19 from 9 to 1 +move 3 from 2 to 9 +move 10 from 1 to 4 +move 2 from 9 to 1 +move 1 from 7 to 9 +move 7 from 1 to 6 +move 10 from 4 to 3 +move 14 from 1 to 7 +move 2 from 9 to 1 +move 3 from 4 to 6 +move 9 from 7 to 6 +move 1 from 3 to 5 +move 4 from 8 to 5 +move 10 from 6 to 8 +move 3 from 5 to 6 +move 10 from 3 to 4 +move 4 from 3 to 7 +move 1 from 5 to 9 +move 2 from 7 to 9 +move 1 from 1 to 9 +move 6 from 2 to 4 +move 1 from 5 to 3 +move 11 from 4 to 9 +move 3 from 4 to 9 +move 1 from 2 to 7 +move 2 from 3 to 5 +move 1 from 3 to 2 +move 7 from 7 to 2 +move 2 from 5 to 8 +move 8 from 2 to 1 +move 2 from 6 to 8 +move 9 from 6 to 8 +move 3 from 8 to 2 +move 3 from 2 to 6 +move 9 from 9 to 5 +move 3 from 5 to 8 +move 5 from 9 to 4 +move 3 from 6 to 4 +move 1 from 6 to 3 +move 3 from 1 to 6 +move 3 from 6 to 9 +move 17 from 8 to 5 +move 12 from 5 to 4 +move 21 from 4 to 3 +move 1 from 4 to 9 +move 7 from 5 to 4 +move 22 from 3 to 7 +move 3 from 1 to 8 +move 3 from 9 to 1 +move 4 from 4 to 6 +move 1 from 6 to 2 +move 3 from 4 to 1 +move 1 from 6 to 7 +move 4 from 9 to 3 +move 2 from 5 to 7 +move 1 from 9 to 6 +move 2 from 6 to 9 +move 8 from 7 to 9 +move 1 from 6 to 2 +move 1 from 9 to 3 +move 4 from 3 to 4 +move 14 from 7 to 4 +move 1 from 3 to 2 +move 3 from 7 to 8 +move 12 from 8 to 9 +move 8 from 4 to 1 +move 1 from 7 to 4 +move 2 from 5 to 1 +move 3 from 2 to 9 +move 17 from 9 to 3 +move 6 from 9 to 1 +move 1 from 9 to 2 +move 13 from 3 to 9 +move 4 from 3 to 1 +move 3 from 9 to 1 +move 22 from 1 to 9 +move 1 from 8 to 1 +move 6 from 9 to 5 +move 4 from 1 to 9 +move 3 from 1 to 9 +move 4 from 4 to 8 +move 4 from 4 to 2 +move 1 from 4 to 3 +move 3 from 8 to 9 +move 1 from 3 to 4 +move 1 from 1 to 3 +move 1 from 8 to 2 +move 1 from 5 to 8 +move 4 from 2 to 1 +move 1 from 8 to 7 +move 10 from 9 to 6 +move 1 from 7 to 9 +move 1 from 2 to 3 +move 1 from 6 to 1 +move 3 from 5 to 7 +move 1 from 8 to 7 +move 1 from 6 to 1 +move 1 from 2 to 4 +move 1 from 5 to 2 +move 19 from 9 to 2 +move 1 from 4 to 7 +move 1 from 3 to 7 +move 3 from 7 to 9 +move 4 from 1 to 2 +move 10 from 9 to 4 +move 1 from 5 to 8 +move 3 from 6 to 4 +move 1 from 3 to 4 +move 10 from 2 to 8 +move 12 from 2 to 5 +move 3 from 5 to 9 +move 5 from 6 to 5 +move 5 from 1 to 4 +move 22 from 4 to 3 +move 3 from 8 to 7 +move 1 from 7 to 2 +move 3 from 2 to 9 +move 19 from 3 to 5 +move 2 from 7 to 8 +move 7 from 5 to 6 +move 5 from 9 to 6 +move 1 from 9 to 3 +move 16 from 5 to 1 +move 2 from 3 to 1 +move 3 from 7 to 3 +move 7 from 8 to 4 +move 2 from 8 to 1 +move 5 from 5 to 9 +move 1 from 5 to 2 +move 1 from 2 to 3 +move 1 from 8 to 5 +move 4 from 5 to 7 +move 2 from 3 to 8 +move 2 from 1 to 5 +move 4 from 7 to 6 +move 6 from 4 to 7 +move 4 from 9 to 8 +move 14 from 6 to 7 +move 8 from 1 to 7 +move 7 from 1 to 3 +move 3 from 5 to 9 +move 28 from 7 to 5 +move 1 from 1 to 8 +move 4 from 8 to 3 +move 9 from 3 to 1 +move 1 from 9 to 5 +move 6 from 3 to 2 +move 10 from 1 to 6 +move 1 from 1 to 9 +move 5 from 9 to 7 +move 14 from 5 to 3 +move 1 from 4 to 1 +move 1 from 7 to 2 +move 1 from 7 to 1 +move 1 from 1 to 7 +move 3 from 8 to 5 +move 4 from 6 to 3 +move 3 from 7 to 2 +move 15 from 3 to 6 +move 16 from 5 to 7 +move 4 from 2 to 8 +move 1 from 3 to 1 +move 5 from 7 to 3 +move 12 from 6 to 4 +move 4 from 8 to 5 +move 1 from 4 to 2 +move 2 from 5 to 3 +move 8 from 6 to 3 +move 7 from 4 to 5 +move 9 from 7 to 6 +move 1 from 7 to 9 +move 1 from 1 to 9 +move 1 from 1 to 9 +move 5 from 2 to 8 +move 5 from 8 to 2 +move 11 from 5 to 9 +move 1 from 4 to 2 +move 4 from 9 to 6 +move 12 from 3 to 7 +move 3 from 4 to 9 +move 14 from 6 to 2 +move 2 from 2 to 4 +move 2 from 3 to 5 +move 10 from 7 to 2 +move 1 from 4 to 8 +move 1 from 2 to 7 +move 28 from 2 to 9 +move 4 from 7 to 5 +move 1 from 2 to 4 +move 6 from 5 to 1 +move 2 from 4 to 3 +move 1 from 8 to 1 +move 40 from 9 to 1 +move 10 from 1 to 6 +move 5 from 3 to 5 +move 1 from 9 to 8 +move 3 from 6 to 7 +move 11 from 1 to 2 +move 9 from 2 to 3 +move 3 from 5 to 1 +move 4 from 7 to 1 +move 2 from 2 to 4 +move 2 from 5 to 8 +move 19 from 1 to 7 +move 8 from 3 to 2 +move 14 from 1 to 8 +move 14 from 7 to 1 +move 4 from 6 to 5 +move 1 from 1 to 9 diff --git a/2022/Day06CSharp/Day06CSharp.csproj b/2022/Day06CSharp/Day06CSharp.csproj new file mode 100644 index 0000000..d439800 --- /dev/null +++ b/2022/Day06CSharp/Day06CSharp.csproj @@ -0,0 +1,10 @@ + + + + Exe + net7.0 + enable + enable + + + diff --git a/2022/Day06CSharp/Program.cs b/2022/Day06CSharp/Program.cs new file mode 100644 index 0000000..ff2c888 --- /dev/null +++ b/2022/Day06CSharp/Program.cs @@ -0,0 +1,53 @@ + +string[] examples = +{ + "mjqjpqmgbljsphdztnvjfqwrcgsmlb", + "bvwbjplbgvbhsrlpgdmjqwftvncz", + "nppdvjthqldpwncqszvftbrmjlhg", + "nznrnfrfntjfmvfwmzdfjlvtqnbhcprsg", + "zcfzfwzzqfrljwzlrfnpqdbhtmscgvjw", +}; + +int[] uniqueCount = { 4, 14 }; + +/**** Part 01 ***/ +foreach (var unique in uniqueCount) +{ + Console.WriteLine(String.Format("\nFinding based on {0} unique consequetive characters", unique)); + + // Perform ops on examples + foreach (string example in examples) + { + PrintFirstUniqueIndex(example, unique); + } + + // Do it on the real puzzle + string fileName = "puzzle-input.txt"; + using (StreamReader reader = File.OpenText(fileName)) + { + string? line = reader.ReadLine(); + if (line != null) + { + PrintFirstUniqueIndex(line, unique); + } + else + { + throw new InvalidDataException(); + } + } +} + +void PrintFirstUniqueIndex(string str, int uniqueLength) +{ + for (int i = 0; i < str.Length; i++) + { + var substr = str.Substring(i, uniqueLength); + if (substr.Distinct().Count() == uniqueLength) + { + Console.WriteLine("Unique Index Start: " + (i+uniqueLength)); + return; + } + } + + throw new InvalidDataException(); +} diff --git a/2022/Day06CSharp/Properties/launchSettings.json b/2022/Day06CSharp/Properties/launchSettings.json new file mode 100644 index 0000000..85488d4 --- /dev/null +++ b/2022/Day06CSharp/Properties/launchSettings.json @@ -0,0 +1,8 @@ +{ + "profiles": { + "Day06CSharp": { + "commandName": "Project", + "workingDirectory": "C:\\dev\\DevSandbox\\AdventOfCode\\2022\\Day06CSharp" + } + } +} \ No newline at end of file diff --git a/2022/Day06CSharp/problem.txt b/2022/Day06CSharp/problem.txt new file mode 100644 index 0000000..ed4f02d --- /dev/null +++ b/2022/Day06CSharp/problem.txt @@ -0,0 +1,48 @@ +--- Day 6: Tuning Trouble --- + +The preparations are finally complete; you and the Elves leave camp on foot and begin to make your way toward the star fruit grove. + +As you move through the dense undergrowth, one of the Elves gives you a handheld device. He says that it has many fancy features, but the most important one to set up right now is the communication system. + +However, because he's heard you have significant experience dealing with signal-based systems, he convinced the other Elves that it would be okay to give you their one malfunctioning device - surely you'll have no problem fixing it. + +As if inspired by comedic timing, the device emits a few colorful sparks. + +To be able to communicate with the Elves, the device needs to lock on to their signal. The signal is a series of seemingly-random characters that the device receives one at a time. + +To fix the communication system, you need to add a subroutine to the device that detects a start-of-packet marker in the datastream. In the protocol being used by the Elves, the start of a packet is indicated by a sequence of four characters that are all different. + +The device will send your subroutine a datastream buffer (your puzzle input); your subroutine needs to identify the first position where the four most recently received characters were all different. Specifically, it needs to report the number of characters from the beginning of the buffer to the end of the first such four-character marker. + +For example, suppose you receive the following datastream buffer: + +mjqjpqmgbljsphdztnvjfqwrcgsmlb + +After the first three characters (mjq) have been received, there haven't been enough characters received yet to find the marker. The first time a marker could occur is after the fourth character is received, making the most recent four characters mjqj. Because j is repeated, this isn't a marker. + +The first time a marker appears is after the seventh character arrives. Once it does, the last four characters received are jpqm, which are all different. In this case, your subroutine should report the value 7, because the first start-of-packet marker is complete after 7 characters have been processed. + +Here are a few more examples: + + bvwbjplbgvbhsrlpgdmjqwftvncz: first marker after character 5 + nppdvjthqldpwncqszvftbrmjlhg: first marker after character 6 + nznrnfrfntjfmvfwmzdfjlvtqnbhcprsg: first marker after character 10 + zcfzfwzzqfrljwzlrfnpqdbhtmscgvjw: first marker after character 11 + +How many characters need to be processed before the first start-of-packet marker is detected? + +--- Part Two --- + +Your device's communication system is correctly detecting packets, but still isn't working. It looks like it also needs to look for messages. + +A start-of-message marker is just like a start-of-packet marker, except it consists of 14 distinct characters rather than 4. + +Here are the first positions of start-of-message markers for all of the above examples: + + mjqjpqmgbljsphdztnvjfqwrcgsmlb: first marker after character 19 + bvwbjplbgvbhsrlpgdmjqwftvncz: first marker after character 23 + nppdvjthqldpwncqszvftbrmjlhg: first marker after character 23 + nznrnfrfntjfmvfwmzdfjlvtqnbhcprsg: first marker after character 29 + zcfzfwzzqfrljwzlrfnpqdbhtmscgvjw: first marker after character 26 + +How many characters need to be processed before the first start-of-message marker is detected? diff --git a/2022/Day06CSharp/puzzle-input.txt b/2022/Day06CSharp/puzzle-input.txt new file mode 100644 index 0000000..e2ce064 --- /dev/null +++ b/2022/Day06CSharp/puzzle-input.txt @@ -0,0 +1 @@ +bvsvcsssfwwdttzpzqqnjjmbbmpbmpmffnttjllzbblvlvqllcwwqpwwhcclqqhmhbhlbbmtmdmgmpggcmcnmcmfcfddvmmcncrcncbbtssdnnhmmfmfrmrbbzllgtllfnnwhwtwzwjjrsrgsrsbbnjjbhjbbjpplslrssdwswrrcsszpplpfplflnnvdvmvjmmgpghphlhphnhffgqgfgzgddstdsdjjgqglqggtgvgrrgtrtllrvrmmnggftgtdtrttgqttcrcqqjqcqwccdzdldrdbbbmrbbnmmwrmmbcchnhmhchddhpphdhzhbbnvbbtctwcwbcwcfclcwwzvwvddbsdsfftgtqggjllwjwppmvvswsjwsscdcrrbggqzqqbhhjwhjwjtjvttpnpdplljplpqpzqzrqrmqmvvsvrvppfgfzfqffvsfvfcvcddjcddzssgfgtffhtfhthntnvvzhzwhzhbbnvvbtbqtqcqnqwnnvpvwwcqcgqqwrwlwbwrbbjcbbqqpddtbddcldccddjssvnvlnnmggmbbchcdcqqdsdqsdqdvdpvvvbzvbvrrjdrjrbjbrbttqzttmffwcfcnnbjnbbjmmgtmgmgdgdpgdglgzzvnzzztjjwbwvvhbhwbbnbhbddwcwvcvjcvjjnnjqjqjzqjjbgbmbjjnqnqddgfgwfgwfftntvnvtvhvlvslsffhvvwnnhshchmmlwmmwvvnhnggzllphllbqqtgqqffhwwnwzztnzttftptnppdpjdjwdwhdddgqglqldqdzzslsggstsrrcsrcclqqrsqrqjqhhjwjggrjgjnjtjwtwjtjrrvnnbddzqzzfnnbvvmfvmvwvggmsgsrggcjjtftpfflzfzccdgcgzcgzcggrbgbngnpnfngfnfqqfzfbfsbfsslqsstvvfmvfvrrvdrddrlrjlrrngrrgfgvgdggnttqqjbjwbwwchhddpmmcvcppjttbzbrzrdzztgtrrchhhbnnqfnfjnnpncnbnvnfnwwsllvrvddhwdwndnjdjbjttmggfvggjhghrhggczgzttbnttjmmdhdrrnnmppwtwdtdbtdbdffpqplqqfbffjssllmwmnmffcnczzrnznzmmwcmwwpbpcbbfdfrrznnzwnnmjnngmngmgpgrppnhnjhhjnhjhfhbffcfhccvzccnrrsggtjtdtjjqqdmqqcggmzzrhzrrbnnlqqtlqtqhhcffrpffgcfgcgncgnggjgzgvzvtztctmtgmmfwwttrntrtqtptzpzjpjqjffpvffvdfvvjhhggfhfrhrwhhwshsnhshbbjzbjzzlvlfvffmrfffngfgpglgjjsbbvzzjsjvsslgsgsfggwjgjlgjgsjgsstvstvstsffdqdpqddrsrmmjbbqbffzbzjjvzvrvcvhhsjsrrmccgqqjnnplnnrprhppslsqszzpvzvggsqscqqbwqqccsdsswqswwqcqzqddbhhmggswggzllccwvwjjpqqrpplrprgrllfwfmwmhhcmmnppfffvtffndnsdnsnbsnsgnsncnzzwrrqrwwzhzbzbnbqbjjrhhjjjbcjjffmwffjnfjfbbjtbbjhjvhvshvhwvwhvwvwfwwwfvvlddqnnlttqssnpsprpwwttlwtwrwfflggvjggwswgwgtgccdjdtdldrdcdsspjpvjpvvfttjrjdrrjppddbdvdjdwdvdssrhsszsjzzfccmwcwzzlnljlppjdjsdjdhdttrdtdtvddslsmmjnmmhzmhhmwmvmcvclvlnndtdrrfdrfrvfvsfvsszfsfdsfdsfsnsdsnsbsddsdwwzbbfqqhrhmrmzmhzhbbpptptffvtvhhwqqtgtdthhrqrrvttprtprrbcblsmbwqqpffmwnqmrdwvjszzhhhffpqsphcgqhlmsgnmmjsdhbfjscztgfvhnlbcmccrfcbnrwcpvgzztvpjdplmncrbvpzwtdnpfwcpvcbzvbtpqmgztsblnchzlphtzgfqcwnrbpcdhbcgzsbgdmbhhrsjqcngfddwvwvldbftgccbjzrrqjcnhbdfgmpdhdgfqzmnpmjgtgwvqlbwgjzjppgmcjzrfzgnbjjbvmshllzjppscwjzjqnbvrppzlshfvtvnpwljrghhwdhfgtcrstnqtqdzfhvgbrrzfdwgtjpjccwrphsdrsjlrlbnrtdbnhpdtshmqlpjqjdlwvrrflwqhcmnsrmcdnfcnwwqmdjlqmqvpgggrjrvfwtwnmhrgzztvmnqczvgmvpcldgfwmtmnsvdshrjmtsgfstjllmqqmpttfhjnsjflcmnpqtqnvtpbgjjhlwqzmrgrbvcsjvprbtqdrnvrgfjdrlhdjsvhhzvllzgfbdwbtqbqzpllpcmcdrfmrsfnwvvmhcqjblnczltcmmmbqwpztqmdpprwphfwgwnsvnzsldnvbsbcdprnztpbmlfzcwpdvcwbsdflrcvsqlswctvlpvshqpwvtcjbtfnmgwtgsvtqhqdzzfhwznggpsmsmzlzrzqcdbqcnhpwhjbhvnqrcwnvpspwqmsqhdbchgrfcmznchwvftgvbldnvtpgmthbmpvccqwbjnjpzhrstscncsrdzsptzvlzjwnpzshmzbhrhgmnwmjmzvvvbgdjshgnqcmdmjrnhqzwtzpjvdczqzccvpvpqnftvpcwgzrzmmnhjnphfntbgjnscwqjcgfcrhjdsjbqfgzhsftghwwwvjwmhfhbwrwmnfrhcggcrjtjsqndrgsbvddqtwhctltzswmtsgwjgsbvvsvzfhbptjqbvbblzhcmnpcjpgzfhstsnlfvmqbdjhszhwhbqztvfdhnbnmppwvzjpnrhtbgthrdprjpqwpthqwzdnhpngflcmhnrmsbdlfwhjbfgrhfzspmfvvtqrwldzvblbtlwqfgfflvmvthbvdzzbtmmpzchgmldmgnhrfhhjwstbqqrzhmqsbqhjzdmjmllmjgqhhjghgsvrbmrbfjdzghmwpszfmslfwcjrftbqjgbbzddtvjmsgwmhhdzwtwvrgqctvwbwjqvssdvfprjsdgsgwbfmzwzmbnlzbfdqvwbrzpgvngqhfqzfqqsvmtgvsqwrplhfnsqhtvtbbqmpbjlcsfjgngwrztlrjbmcjddjsnbgcpnhdtngzhzvhzpjfcblhglhzfsjdgjdqvvppfrdftfbfldwqjznvrdqdnfscgvhztjwlqgqbjmlsbcrldjhnrsfgthlhplvwgmdnplrtpdvrqbpvnbpzfzwlvrrscvmgzhlcdwglwwrgzqsjqsqfblqljltbvvjwbpmfqjvldspgsbjrdbbwzjntlpqgvdjfvsjznczsppzwfvblffqqhwmhzdzztbvbsjhvjtjrptrdvrbbpnpncltqnhdvwjgzcmdtnbnhlmptjsqlzlpztnrtclgsmgvrvggtzfhpwgjgwtrnshmcpvhprpnrvgprspmwhchlhhsvwpvjdmjrlnjdchngrdgpwzsgqsjnqnqwsctzvsmqgvrpffffcfshbhmqbffwvcjqscrwhbfflwslspwjgdbvcgbtwldzffrdhrlbssjbcsjgbhprgspnjdbmnshzqwdvtnzsrfwbqfrgnlmpvqrrmmmcshzltqbwffprbwqbfthtvszqzcbbljtfjqmwpqssjtdpqlrfmpchrqmdpbsdjcdmglnlgnwvhclqfmbwhtljmscnzzqtwtjqsqrmmnssmqhqjvdlpmstmpwmrcfjbjrchrgvqqzbvtzpcbdvchvghnflllqddlttjwtnfhgqjjgtgsnhpvnwhcbljstshmhpwbqthvngqzrmqpmwqnvrfblpjlqgczfmtwvmlbzslqwdzhfccmrvjwfnwzgpbvgdgttdgtjdlvrmpbdhwjsvvsjqpclrnbtzphvmpfqhhqdmbmqzwphnzzfqjsqvdvbvnpmtnzpdsfzmbttssnssrtpmpvgrrzvcljtqtrqnfmmtsnvtrsjgcmqnttcmp diff --git a/2022/Day07CSharp/Day07CSharp.csproj b/2022/Day07CSharp/Day07CSharp.csproj new file mode 100644 index 0000000..d439800 --- /dev/null +++ b/2022/Day07CSharp/Day07CSharp.csproj @@ -0,0 +1,10 @@ + + + + Exe + net7.0 + enable + enable + + + diff --git a/2022/Day07CSharp/Program.cs b/2022/Day07CSharp/Program.cs new file mode 100644 index 0000000..a33dafb --- /dev/null +++ b/2022/Day07CSharp/Program.cs @@ -0,0 +1,205 @@ +// See https://aka.ms/new-console-template for more information +using System.ComponentModel; +using System.Drawing; +using System.Xml; + +Console.WriteLine("Hello, World!"); + +Directory exampleRoot = LoadData("example-input.txt"); +Directory puzzleRoot = LoadData("puzzle-input.txt"); + +Console.WriteLine(String.Format("Part01: Example({0}), Puzzle({1})", Part01(exampleRoot, 100000), Part01(puzzleRoot, 100000))); + +Console.WriteLine(String.Format("Part02: Example({0}), Puzzle({1})" , Part02(exampleRoot, 70000000 - exampleRoot.Size, 30000000, exampleRoot.Size) + , Part02(puzzleRoot, 70000000 - puzzleRoot.Size, 30000000, puzzleRoot.Size))); + +int Part01(Directory root, int maxsize) +{ + int returnSize = 0; + int size = 0; + + foreach (var file in root.Files) + { + size += file.Size; + } + foreach (var subdir in root.SubDirectories) + { + size += subdir.Size; + } + + if (size < maxsize) returnSize += size; + + foreach (var subdir in root.SubDirectories) + { + returnSize += Part01(subdir, maxsize); + } + + return returnSize; +} + +int Part02(Directory root, int unusedSpace, int targetUnusedSpace, int returnSize) +{ + if (unusedSpace + root.Size > targetUnusedSpace) + { + returnSize = Int32.Min(returnSize, root.Size); + } + + + foreach (var subdir in root.SubDirectories) + { + returnSize = Int32.Min(returnSize, Part02(subdir, unusedSpace, targetUnusedSpace, returnSize)); + } + + return returnSize; +} + +Directory LoadData(string fileName) +{ + Directory root = new Directory("/", null); + Directory currentDir = root; + + using (StreamReader reader = System.IO.File.OpenText(fileName)) + { + while (!reader.EndOfStream) + { + string? line = reader.ReadLine(); + if (line == null) throw new InvalidDataException(); + if (line.Length == 0) continue; + + // We should be reading commands here + if (line.StartsWith('$')) + { + var split = line.Split(' '); + + if (split[1].StartsWith("cd")) + { + if (split.Length != 3) + { + throw new InvalidDataException(); + } + currentDir = HandleChangeDirectory(reader, split[2], currentDir); + } + else if (split[1].StartsWith("ls")) + { + currentDir = HandleListDirectory(reader, currentDir); + } + } + else + { + throw new InvalidDataException(); + } + } + + } + + return root; +} + +Directory HandleListDirectory(StreamReader reader, Directory currentDir) +{ + while (!reader.EndOfStream && reader.Peek() != '$') + { + string? line = reader.ReadLine(); + if (line == null) throw new InvalidDataException(); + + var split = line.Split(" "); + + int size = 0; + + if (split[0].StartsWith("dir")) + { + if (currentDir.SubDirectories.Exists(x => x.Name.StartsWith(split[1]))) + { + throw new InvalidDataException(); + } + currentDir.SubDirectories.Add(new Directory(split[1], currentDir)); + } + else if (Int32.TryParse(split[0], out size)) + { + if (currentDir.Files.Exists(x => x.Name == split[1])) + { + throw new InvalidDataException(); + } + currentDir.Files.Add(new File(split[1], size)); + } + else + { throw new InvalidDataException(); } + } + + return currentDir; +} + +Directory HandleChangeDirectory(StreamReader reader, string argument, Directory currentDir) +{ + switch (argument) + { + case "/": + while (currentDir != null && !currentDir.Name.StartsWith("/")) + { + if (currentDir.Parent == null) throw new InvalidDataException(); + currentDir = currentDir.Parent; + } + return currentDir; + + case "..": + if (currentDir.Parent == null) + { + throw new InvalidDataException(); + } + + currentDir = currentDir.Parent; + return currentDir; + + default: + foreach (var subdir in currentDir.SubDirectories) + { + if (subdir.Name == argument) + { + currentDir = subdir; + return currentDir; + } + } + throw new InvalidDataException(); + } +} + +class File +{ + public string Name { get; set; } + public int Size { get; set; } + + public File(string name, int size) + { + Name = name; + Size = size; + } +} +class Directory +{ + public List SubDirectories { get; set; } = new List(); + public List Files { get; set; } = new List(); + public Directory? Parent { get; set; } = null; + + public string Name { get; set; } + + public Directory(string name, Directory parent) { Name = name; Parent = parent; } + + public int Size + { + get + { + int size = 0; + + foreach (var subdir in SubDirectories) + { + size += subdir.Size; + } + foreach (var file in Files) + { + size += file.Size; + } + + return size; + } + } +} \ No newline at end of file diff --git a/2022/Day07CSharp/Properties/launchSettings.json b/2022/Day07CSharp/Properties/launchSettings.json new file mode 100644 index 0000000..3d7f928 --- /dev/null +++ b/2022/Day07CSharp/Properties/launchSettings.json @@ -0,0 +1,8 @@ +{ + "profiles": { + "Day07CSharp": { + "commandName": "Project", + "workingDirectory": "C:\\dev\\DevSandbox\\AdventOfCode\\2022\\Day07CSharp" + } + } +} \ No newline at end of file diff --git a/2022/Day07CSharp/example-input.txt b/2022/Day07CSharp/example-input.txt new file mode 100644 index 0000000..4d95bdd --- /dev/null +++ b/2022/Day07CSharp/example-input.txt @@ -0,0 +1,23 @@ +$ cd / +$ ls +dir a +14848514 b.txt +8504156 c.dat +dir d +$ cd a +$ ls +dir e +29116 f +2557 g +62596 h.lst +$ cd e +$ ls +584 i +$ cd .. +$ cd .. +$ cd d +$ ls +4060174 j +8033020 d.log +5626152 d.ext +7214296 k \ No newline at end of file diff --git a/2022/Day07CSharp/problem.txt b/2022/Day07CSharp/problem.txt new file mode 100644 index 0000000..fdce371 --- /dev/null +++ b/2022/Day07CSharp/problem.txt @@ -0,0 +1,99 @@ +--- Day 7: No Space Left On Device --- + +You can hear birds chirping and raindrops hitting leaves as the expedition proceeds. Occasionally, you can even hear much louder sounds in the distance; how big do the animals get out here, anyway? + +The device the Elves gave you has problems with more than just its communication system. You try to run a system update: + +$ system-update --please --pretty-please-with-sugar-on-top +Error: No space left on device + +Perhaps you can delete some files to make space for the update? + +You browse around the filesystem to assess the situation and save the resulting terminal output (your puzzle input). For example: + +$ cd / +$ ls +dir a +14848514 b.txt +8504156 c.dat +dir d +$ cd a +$ ls +dir e +29116 f +2557 g +62596 h.lst +$ cd e +$ ls +584 i +$ cd .. +$ cd .. +$ cd d +$ ls +4060174 j +8033020 d.log +5626152 d.ext +7214296 k + +The filesystem consists of a tree of files (plain data) and directories (which can contain other directories or files). The outermost directory is called /. You can navigate around the filesystem, moving into or out of directories and listing the contents of the directory you're currently in. + +Within the terminal output, lines that begin with $ are commands you executed, very much like some modern computers: + + cd means change directory. This changes which directory is the current directory, but the specific result depends on the argument: + cd x moves in one level: it looks in the current directory for the directory named x and makes it the current directory. + cd .. moves out one level: it finds the directory that contains the current directory, then makes that directory the current directory. + cd / switches the current directory to the outermost directory, /. + ls means list. It prints out all of the files and directories immediately contained by the current directory: + 123 abc means that the current directory contains a file named abc with size 123. + dir xyz means that the current directory contains a directory named xyz. + +Given the commands and output in the example above, you can determine that the filesystem looks visually like this: + +- / (dir) + - a (dir) + - e (dir) + - i (file, size=584) + - f (file, size=29116) + - g (file, size=2557) + - h.lst (file, size=62596) + - b.txt (file, size=14848514) + - c.dat (file, size=8504156) + - d (dir) + - j (file, size=4060174) + - d.log (file, size=8033020) + - d.ext (file, size=5626152) + - k (file, size=7214296) + +Here, there are four directories: / (the outermost directory), a and d (which are in /), and e (which is in a). These directories also contain files of various sizes. + +Since the disk is full, your first step should probably be to find directories that are good candidates for deletion. To do this, you need to determine the total size of each directory. The total size of a directory is the sum of the sizes of the files it contains, directly or indirectly. (Directories themselves do not count as having any intrinsic size.) + +The total sizes of the directories above can be found as follows: + + The total size of directory e is 584 because it contains a single file i of size 584 and no other directories. + The directory a has total size 94853 because it contains files f (size 29116), g (size 2557), and h.lst (size 62596), plus file i indirectly (a contains e which contains i). + Directory d has total size 24933642. + As the outermost directory, / contains every file. Its total size is 48381165, the sum of the size of every file. + +To begin, find all of the directories with a total size of at most 100000, then calculate the sum of their total sizes. In the example above, these directories are a and e; the sum of their total sizes is 95437 (94853 + 584). (As in this example, this process can count files more than once!) + +Find all of the directories with a total size of at most 100000. What is the sum of the total sizes of those directories? + +--- Part Two --- + +Now, you're ready to choose a directory to delete. + +The total disk space available to the filesystem is 70000000. To run the update, you need unused space of at least 30000000. You need to find a directory you can delete that will free up enough space to run the update. + +In the example above, the total size of the outermost directory (and thus the total amount of used space) is 48381165; this means that the size of the unused space must currently be 21618835, which isn't quite the 30000000 required by the update. Therefore, the update still requires a directory with total size of at least 8381165 to be deleted before it can run. + +To achieve this, you have the following options: + + Delete directory e, which would increase unused space by 584. + Delete directory a, which would increase unused space by 94853. + Delete directory d, which would increase unused space by 24933642. + Delete directory /, which would increase unused space by 48381165. + +Directories e and a are both too small; deleting them would not free up enough space. However, directories d and / are both big enough! Between these, choose the smallest: d, increasing unused space by 24933642. + +Find the smallest directory that, if deleted, would free up enough space on the filesystem to run the update. What is the total size of that directory? diff --git a/2022/Day07CSharp/puzzle-input.txt b/2022/Day07CSharp/puzzle-input.txt new file mode 100644 index 0000000..6fa0c80 --- /dev/null +++ b/2022/Day07CSharp/puzzle-input.txt @@ -0,0 +1,986 @@ +$ cd / +$ ls +dir bnl +dir dmpsnhdh +272080 dncdssn.hdr +dir fcnqg +6067 hjpmqrq +dir jvwtm +dir ldztz +dir lmmw +dir wthvqw +dir zpdnprb +$ cd bnl +$ ls +dir dhw +dir dmpsnhdh +dir lmw +dir vgbqbrst +$ cd dhw +$ ls +237421 vccwmhl +$ cd .. +$ cd dmpsnhdh +$ ls +dir chf +dir mjpbhjm +dir zwhpwp +$ cd chf +$ ls +4679 lmw.wmp +217367 wwnfv.qqr +dir zfgznbz +$ cd zfgznbz +$ ls +179409 cnj.gdn +171574 vglqg +$ cd .. +$ cd .. +$ cd mjpbhjm +$ ls +dir crf +dir hqnj +dir lmw +18783 lmw.rwr +302608 twpq +166891 vqczlg +$ cd crf +$ ls +32183 dltmqht +240428 frqqdsr.hbf +224910 sgtnrvrt +$ cd .. +$ cd hqnj +$ ls +261723 cgstb +77979 dmpsnhdh.cmd +$ cd .. +$ cd lmw +$ ls +50307 fcqrwd +$ cd .. +$ cd .. +$ cd zwhpwp +$ ls +141133 gdngm.mps +$ cd .. +$ cd .. +$ cd lmw +$ ls +dir dvv +267473 jmqgrh.dlz +295139 rrqjwpm +$ cd dvv +$ ls +114536 gmlmbrrw.wdm +102061 lmw +$ cd .. +$ cd .. +$ cd vgbqbrst +$ ls +105102 dmpsnhdh.bgl +269054 gmwgjf.fzz +dir jbdtpnw +245266 jzsjvgl +216220 lmw.gtb +dir rflp +dir twpq +$ cd jbdtpnw +$ ls +27543 cjvvmzp +$ cd .. +$ cd rflp +$ ls +137601 frqqdsr.hbf +83444 rrqjwpm +$ cd .. +$ cd twpq +$ ls +dir rlbsdj +36846 tnrqzjdd +$ cd rlbsdj +$ ls +56078 bvndq +$ cd .. +$ cd .. +$ cd .. +$ cd .. +$ cd dmpsnhdh +$ ls +dir fnpwwhtj +dir lmw +9090 mgjpsvl.jlh +186374 pbb.zln +$ cd fnpwwhtj +$ ls +dir cgp +$ cd cgp +$ ls +81938 hjpmqrq +281971 jvszf +151057 wmr.bnf +$ cd .. +$ cd .. +$ cd lmw +$ ls +dir bfbv +56929 pbb.zln +dir rrqjwpm +dir sngm +$ cd bfbv +$ ls +92667 qrrttb.jgp +$ cd .. +$ cd rrqjwpm +$ ls +25739 cqljn.zqw +91325 dncdssn.hdr +$ cd .. +$ cd sngm +$ ls +282163 jgrj +dir lmw +237524 lmw.dff +153497 lmw.ntg +dir lqd +dir szn +143535 tvpvc.qpr +98326 vbfgh +$ cd lmw +$ ls +32484 dncdssn.hdr +dir glwr +$ cd glwr +$ ls +144719 frqqdsr.hbf +$ cd .. +$ cd .. +$ cd lqd +$ ls +231401 dncdssn.hdr +dir jnjqmvg +dir lmw +199704 rrqjwpm +$ cd jnjqmvg +$ ls +104947 trpsrfjz.brg +$ cd .. +$ cd lmw +$ ls +230298 rrqjwpm.nnv +158947 wfv.qrb +$ cd .. +$ cd .. +$ cd szn +$ ls +197974 frqqdsr.hbf +$ cd .. +$ cd .. +$ cd .. +$ cd .. +$ cd fcnqg +$ ls +251609 dncdssn.hdr +289497 jdjmftqs +228459 qbmthcq +$ cd .. +$ cd jvwtm +$ ls +dir dmpsnhdh +47959 pbb.zln +dir tlr +dir twpq +dir wbgcsw +dir zjmldjdh +$ cd dmpsnhdh +$ ls +247567 bnl +102471 bnl.wdm +80054 fhqvp.hfm +dir llhp +dir mnsbh +dir mpplsfjp +20844 mtvl.lmp +$ cd llhp +$ ls +180255 dmpsnhdh +$ cd .. +$ cd mnsbh +$ ls +267627 dmpsnhdh +$ cd .. +$ cd mpplsfjp +$ ls +dir bnl +233742 tcnpvqc.tdr +$ cd bnl +$ ls +243223 fcqrwd +$ cd .. +$ cd .. +$ cd .. +$ cd tlr +$ ls +dir vcsngm +dir wndmt +$ cd vcsngm +$ ls +36434 czs.dnv +$ cd .. +$ cd wndmt +$ ls +dir fvmtfcqd +dir nvdb +dir nwqqgl +dir sbspgnpm +$ cd fvmtfcqd +$ ls +237025 nzttjt.rzh +$ cd .. +$ cd nvdb +$ ls +235328 dnrqwqtp.vfc +51984 rhblt.mfz +51332 rjhvhw +$ cd .. +$ cd nwqqgl +$ ls +203534 cjghw +dir cljbrh +$ cd cljbrh +$ ls +133820 lmw.dnd +$ cd .. +$ cd .. +$ cd sbspgnpm +$ ls +270010 hjpmqrq +$ cd .. +$ cd .. +$ cd .. +$ cd twpq +$ ls +dir dmpsnhdh +dir hbchdjjp +247649 hjpmqrq +29891 rrqjwpm +72407 twpq.crb +$ cd dmpsnhdh +$ ls +251490 dncdssn.hdr +222231 hjpmqrq +102058 pbb.zln +$ cd .. +$ cd hbchdjjp +$ ls +70058 dprrmd.qcd +230958 tsdbl.bnq +$ cd .. +$ cd .. +$ cd wbgcsw +$ ls +292028 bhtfcf +dir bnl +dir bqq +dir ctnlpgt +247888 hblhfvwj +dir hbqm +277949 pbb.zln +106225 rrqjwpm +125927 ssqpmlfb.gwm +dir zqmjwsgz +dir zwwphs +$ cd bnl +$ ls +dir fbbr +240500 frqqdsr.hbf +dir mzfrdl +25137 srqlww.mcj +dir tqgrdz +dir ztrnq +$ cd fbbr +$ ls +84414 mjbw.dhs +$ cd .. +$ cd mzfrdl +$ ls +135647 bccwgn +dir cjdptqgh +dir hwdnrqns +dir prq +$ cd cjdptqgh +$ ls +147946 mdgl.drz +11972 pbb.zln +$ cd .. +$ cd hwdnrqns +$ ls +dir dmpsnhdh +$ cd dmpsnhdh +$ ls +254432 phthmn +$ cd .. +$ cd .. +$ cd prq +$ ls +75827 dmpsnhdh.rtl +$ cd .. +$ cd .. +$ cd tqgrdz +$ ls +251475 bjwnll.rlw +$ cd .. +$ cd ztrnq +$ ls +208497 bnl.dtr +179376 gqnbswcj.hht +$ cd .. +$ cd .. +$ cd bqq +$ ls +202201 bnl.lbm +$ cd .. +$ cd ctnlpgt +$ ls +269484 vsfvzrpr +$ cd .. +$ cd hbqm +$ ls +74455 bvnfz +42748 pbb.zln +$ cd .. +$ cd zqmjwsgz +$ ls +146194 pbb.zln +$ cd .. +$ cd zwwphs +$ ls +209587 mtbzd.nwb +$ cd .. +$ cd .. +$ cd zjmldjdh +$ ls +dir cdq +dir mdclfbs +dir tfc +132043 wrm +$ cd cdq +$ ls +289173 twpq.mrn +$ cd .. +$ cd mdclfbs +$ ls +64639 bnl.jwf +dir hpdgt +72868 hznfj.nmj +159467 lmw.bfz +$ cd hpdgt +$ ls +52760 fcqrwd +54661 tzgt.hvh +$ cd .. +$ cd .. +$ cd tfc +$ ls +185481 bwntlh +18925 fcqrwd +$ cd .. +$ cd .. +$ cd .. +$ cd ldztz +$ ls +128430 bwz.fcz +dir dmpsnhdh +dir lbqgz +dir znrnj +$ cd dmpsnhdh +$ ls +238193 dncdssn.hdr +285939 hwfngq.dpw +$ cd .. +$ cd lbqgz +$ ls +171931 vgrp +$ cd .. +$ cd znrnj +$ ls +153738 vmwwbjqd +$ cd .. +$ cd .. +$ cd lmmw +$ ls +dir bqqnsfdj +163303 fcqrwd +43453 frqqdsr.hbf +33319 hjpmqrq +dir rlpcqtzg +$ cd bqqnsfdj +$ ls +dir bnl +2251 hjpmqrq +14707 rrqjwpm +dir tlnbvhdl +$ cd bnl +$ ls +33357 bnl.fqp +151237 bnl.vbs +40294 dmpsnhdh.hwz +76455 dncdssn.hdr +290341 hjpmqrq +dir lmw +dir nqw +$ cd lmw +$ ls +dir sfj +$ cd sfj +$ ls +156532 fcqrwd +$ cd .. +$ cd .. +$ cd nqw +$ ls +59928 dncdssn.hdr +$ cd .. +$ cd .. +$ cd tlnbvhdl +$ ls +183301 hjpmqrq +$ cd .. +$ cd .. +$ cd rlpcqtzg +$ ls +258638 dqt.mlc +$ cd .. +$ cd .. +$ cd wthvqw +$ ls +224501 pbb.zln +$ cd .. +$ cd zpdnprb +$ ls +dir bnl +dir ffg +dir jljlwpsv +212081 lrzc.lhj +dir rrqjwpm +dir twpq +dir vlgsrtm +$ cd bnl +$ ls +124009 hjgjf +74860 hjpmqrq +84996 lrdl.swf +dir pnzmp +$ cd pnzmp +$ ls +dir btbtlrs +128636 nfzf +$ cd btbtlrs +$ ls +107651 hhzbwd.wzj +$ cd .. +$ cd .. +$ cd .. +$ cd ffg +$ ls +57918 jwzbs.tnt +$ cd .. +$ cd jljlwpsv +$ ls +188175 dmpsnhdh.nnb +46693 fcqrwd +111557 pbb.zln +$ cd .. +$ cd rrqjwpm +$ ls +dir bftw +dir ccsfws +87225 mccw +290654 pbb.zln +147394 twzqc.pbz +52983 wsvgf +dir wwfgbzqh +$ cd bftw +$ ls +dir brl +167154 crs +dir lmw +dir rrqjwpm +dir twpq +174963 twpq.wjl +dir vnfhb +dir wcldzp +$ cd brl +$ ls +297937 wspcnp +$ cd .. +$ cd lmw +$ ls +166695 mcjql.jrv +$ cd .. +$ cd rrqjwpm +$ ls +198762 mwn +$ cd .. +$ cd twpq +$ ls +141835 jlwf.hcd +$ cd .. +$ cd vnfhb +$ ls +128626 tvmwhq.wfn +$ cd .. +$ cd wcldzp +$ ls +dir ncq +dir twpq +$ cd ncq +$ ls +dir wrtw +$ cd wrtw +$ ls +133331 fcqrwd +$ cd .. +$ cd .. +$ cd twpq +$ ls +151811 fcqrwd +$ cd .. +$ cd .. +$ cd .. +$ cd ccsfws +$ ls +100548 twpq.ppm +$ cd .. +$ cd wwfgbzqh +$ ls +dir lmw +dir mfms +dir pjbjgbcl +204154 qtflzwm +226500 vdmjj.htj +dir wzqbwr +$ cd lmw +$ ls +dir bgl +95150 dncdssn.hdr +119653 frqqdsr.hbf +97941 hjpmqrq +dir jqthwzj +$ cd bgl +$ ls +dir lmw +dir rrqjwpm +$ cd lmw +$ ls +233655 wmdldvbz +$ cd .. +$ cd rrqjwpm +$ ls +242918 frqqdsr.hbf +227581 hjpmqrq +dir hsvnmlp +dir nsch +25524 pbb.zln +dir qlgg +dir twpq +67453 twpq.fms +$ cd hsvnmlp +$ ls +264517 pbb.zln +$ cd .. +$ cd nsch +$ ls +7898 cmsdzh +233270 dmpsnhdh.bsq +101256 frl +133902 jzvh.vdv +dir lmw +dir sgjsg +130245 wcftvft +$ cd lmw +$ ls +69572 bnjnc.csp +$ cd .. +$ cd sgjsg +$ ls +38856 tnzpz.tbq +$ cd .. +$ cd .. +$ cd qlgg +$ ls +276013 frbstg.pzb +$ cd .. +$ cd twpq +$ ls +136454 fhwz.bqb +94099 rglp +114026 tsrt.cbd +26252 zhclpzm.rqf +$ cd .. +$ cd .. +$ cd .. +$ cd jqthwzj +$ ls +128200 lmw.btl +$ cd .. +$ cd .. +$ cd mfms +$ ls +274935 dmpsnhdh +76547 lchwq.dsd +215701 pbb.zln +dir rmwtvjt +$ cd rmwtvjt +$ ls +74490 hjpmqrq +$ cd .. +$ cd .. +$ cd pjbjgbcl +$ ls +231757 cjcpwwc.wbf +dir cswvftzs +dir jtvtg +dir lmw +dir tnctbjr +dir tqsrfhdr +$ cd cswvftzs +$ ls +dir dchqnbns +dir smf +$ cd dchqnbns +$ ls +94111 szl.hqs +$ cd .. +$ cd smf +$ ls +dir dlnsgvl +dir zglt +$ cd dlnsgvl +$ ls +dir dsz +$ cd dsz +$ ls +156473 hjpmqrq +$ cd .. +$ cd .. +$ cd zglt +$ ls +295383 frgg.sdp +$ cd .. +$ cd .. +$ cd .. +$ cd jtvtg +$ ls +202254 bftv.rqb +58419 lmw +$ cd .. +$ cd lmw +$ ls +8097 fcqrwd +$ cd .. +$ cd tnctbjr +$ ls +250830 frqqdsr.hbf +dir gzrcqr +$ cd gzrcqr +$ ls +dir fnzgsnv +$ cd fnzgsnv +$ ls +117215 hjpmqrq +$ cd .. +$ cd .. +$ cd .. +$ cd tqsrfhdr +$ ls +96381 lmw +$ cd .. +$ cd .. +$ cd wzqbwr +$ ls +149066 dmpsnhdh.vnd +dir dpbcgfdr +dir swp +14495 twpq.gsb +dir zhj +$ cd dpbcgfdr +$ ls +12909 dmpsnhdh +dir jvn +173491 mnhpr.lpr +222018 rfqfjmd.jqq +205077 wbbdrpr.hzj +dir wzpbbbhm +$ cd jvn +$ ls +117656 vqddrqlq.nfd +233109 vqqvh.swz +$ cd .. +$ cd wzpbbbhm +$ ls +143534 pbb.zln +$ cd .. +$ cd .. +$ cd swp +$ ls +131295 pbb.zln +$ cd .. +$ cd zhj +$ ls +166268 pbb.zln +33734 rrqjwpm.blg +$ cd .. +$ cd .. +$ cd .. +$ cd .. +$ cd twpq +$ ls +dir bppvlwqs +dir bvh +dir rmcdr +dir tdn +2230 whb.lfb +dir wwtwnvh +$ cd bppvlwqs +$ ls +195026 hvlhgsw +279259 rrqjwpm +$ cd .. +$ cd bvh +$ ls +dir lmw +$ cd lmw +$ ls +66958 pdqnd +$ cd .. +$ cd .. +$ cd rmcdr +$ ls +dir dmpsnhdh +182930 grj +dir pmrdhrth +119725 qpcqclqh +77890 sjgfjz +142855 twpq +dir zbmcrvbh +$ cd dmpsnhdh +$ ls +dir rrqjwpm +188474 zgjzpbl.vgv +$ cd rrqjwpm +$ ls +dir bnl +dir lmw +7598 vsntvs.pdv +$ cd bnl +$ ls +245600 lmw.mgf +$ cd .. +$ cd lmw +$ ls +73396 hjpmqrq +$ cd .. +$ cd .. +$ cd .. +$ cd pmrdhrth +$ ls +173155 rrqjwpm.pjw +178530 smgpzs.qtj +$ cd .. +$ cd zbmcrvbh +$ ls +124201 fcqrwd +135578 hjpmqrq +54356 hnztplsp.qlh +dir lmw +58350 pbb.zln +dir qfrvdm +dir rcg +15267 rwbzjpt.djn +$ cd lmw +$ ls +dir bbbll +28362 bfgfwlf.wvg +229637 dmpndms.fln +146121 dncdssn.hdr +131039 frqqdsr.hbf +152805 hjpmqrq +dir mlz +$ cd bbbll +$ ls +169940 dncdssn.hdr +216888 pbb.zln +248369 tjpmlr.vmf +$ cd .. +$ cd mlz +$ ls +115167 bhfv.fts +$ cd .. +$ cd .. +$ cd qfrvdm +$ ls +284564 pbb.zln +$ cd .. +$ cd rcg +$ ls +dir sqzjz +$ cd sqzjz +$ ls +116435 jrstpcpl.zsq +$ cd .. +$ cd .. +$ cd .. +$ cd .. +$ cd tdn +$ ls +143971 cmg +133317 fcqrwd +dir pstpclp +133161 tddv +$ cd pstpclp +$ ls +267351 hjpmqrq +86930 rrqjwpm.dvl +$ cd .. +$ cd .. +$ cd wwtwnvh +$ ls +256584 frqqdsr.hbf +114564 twpq.wrd +$ cd .. +$ cd .. +$ cd vlgsrtm +$ ls +148089 bnl.jzj +119796 cjfphsfw.hnd +197668 cpw +dir dmpsnhdh +dir fjsglr +dir lmw +dir lqgrft +9231 pltdltrs +dir rmdp +109777 rncfff.fll +dir vgjzqjpq +dir ztnqnfnq +$ cd dmpsnhdh +$ ls +dir lltnrdtv +dir scthsg +$ cd lltnrdtv +$ ls +179511 pcvmpz +90913 tbr +$ cd .. +$ cd scthsg +$ ls +dir rrqjwpm +$ cd rrqjwpm +$ ls +188629 fcqrwd +$ cd .. +$ cd .. +$ cd .. +$ cd fjsglr +$ ls +139754 fcqrwd +dir pnsjwfzc +$ cd pnsjwfzc +$ ls +113848 lmw +$ cd .. +$ cd .. +$ cd lmw +$ ls +54999 dmpsnhdh +dir ffhcf +251476 frqqdsr.hbf +dir jpgqspqw +198972 nhfclq.pbh +180380 nqmjnvc.fvr +dir pfsjwmbc +213768 rcvccgcd +$ cd ffhcf +$ ls +40478 svmwstq.sjj +$ cd .. +$ cd jpgqspqw +$ ls +22181 hjpmqrq +$ cd .. +$ cd pfsjwmbc +$ ls +dir bcvchw +$ cd bcvchw +$ ls +225892 bnl.nwc +$ cd .. +$ cd .. +$ cd .. +$ cd lqgrft +$ ls +dir rrqjwpm +dir twpq +$ cd rrqjwpm +$ ls +54786 fcqrwd +3053 tthhqjm.ntd +$ cd .. +$ cd twpq +$ ls +109355 bnl +dir lmw +dir mhgqt +301291 rrqjwpm.lrm +271233 twpq.srp +$ cd lmw +$ ls +dir lmw +dir lngbszqm +$ cd lmw +$ ls +139640 pbb.zln +$ cd .. +$ cd lngbszqm +$ ls +98279 mqvq.gsj +283599 rvjd.dvt +$ cd .. +$ cd .. +$ cd mhgqt +$ ls +208165 fcqrwd +$ cd .. +$ cd .. +$ cd .. +$ cd rmdp +$ ls +dir bqn +170956 fcqrwd +90954 snnttp.gld +$ cd bqn +$ ls +75628 hdrgbrpc +$ cd .. +$ cd .. +$ cd vgjzqjpq +$ ls +dir bnl +dir wpfw +$ cd bnl +$ ls +25911 pbb.zln +$ cd .. +$ cd wpfw +$ ls +247784 bzll.ltc +$ cd .. +$ cd .. +$ cd ztnqnfnq +$ ls +dir dtpzsrfc +214055 srgzhp.nlr +$ cd dtpzsrfc +$ ls +142652 bhgwj diff --git a/2022/Day08CSharp/Day08CSharp.csproj b/2022/Day08CSharp/Day08CSharp.csproj new file mode 100644 index 0000000..d439800 --- /dev/null +++ b/2022/Day08CSharp/Day08CSharp.csproj @@ -0,0 +1,10 @@ + + + + Exe + net7.0 + enable + enable + + + diff --git a/2022/Day08CSharp/Program.cs b/2022/Day08CSharp/Program.cs new file mode 100644 index 0000000..621bcd8 --- /dev/null +++ b/2022/Day08CSharp/Program.cs @@ -0,0 +1,203 @@ +// See https://aka.ms/new-console-template for more information +using System.Collections; + +var exampleData = new LoadedData("example-input.txt"); +var puzzleData = new LoadedData("puzzle-input.txt"); + +exampleData.Print(); + +Console.WriteLine(String.Format("Part01, visibility: Example({0}), Puzzle({1})", exampleData.VisibleCount, puzzleData.VisibleCount)); + +Console.WriteLine(String.Format("Part01, Scenic Score: Example({0}), Puzzle({1})", exampleData.ScenicScore, puzzleData.ScenicScore)); + +class LoadedData +{ + public List> TreeData { get; } = new List>(); + + public void Print() + { + string toPrint = ""; + for (int j = 0; j < TreeData.Count; j++) + { + for (int i = 0; i < TreeData[j].Count; i++) + { + toPrint += TreeData[j][i]; + } + toPrint += "\n"; + } + + Console.WriteLine(toPrint); + } + + public LoadedData(string fileName) + { + TreeData = new List>(); + + using (StreamReader reader = System.IO.File.OpenText(fileName)) + { + while (!reader.EndOfStream) + { + string? line = reader.ReadLine(); + if (line == null) + { + throw new InvalidDataException(); + } + + List list = new List(); + foreach (char c in line) + { + list.Add((int)(c - '0')); + } + + TreeData.Add(list); + } + } + } + + public int VisibleCount + { + get + { + int visible = 0; + + // Check the inside + for (int j = 1; j < TreeData.Count-1; j++) + { + for (int i = 1; i < TreeData[0].Count-1; i++) + { + if (IsVisible(i,j)) { visible++; } + } + } + + // Add the top row and bottom row + visible += TreeData[0].Count * 2; + + // Add the two sides + visible += (TreeData.Count-2)*2; + return visible; + } + } + + private bool IsVisible(int i, int j) + { + int baseHeight = TreeData[j][i]; + + bool visUp = true, visRight = true, visLeft = true, visDown = true; + + // Up + for (int y = 0, x=i; y < j; y++) + { + if (baseHeight <= TreeData[y][x]) + { + visUp = false; + break; + } + } + if (visUp) return true; + + // Right + for (int x = i+1, y=j; x < TreeData[i].Count; x++) + { + if (baseHeight <= TreeData[y][x]) + { + visRight = false; + break; + } + } + if (visRight) return true; + + // Left + for (int x = 0, y = j; x < i; x++) + { + if (baseHeight <= TreeData[y][x]) + { + visLeft = false; + break; + } + } + if (visLeft) return true; + + // Down + for (int y = j+1, x = i; y < TreeData.Count; y++) + { + if (baseHeight <= TreeData[y][x]) + { + visDown = false; + break; + } + } + if (visDown) return true; + + return false; + } + + public int ScenicScore + { + get + { + int result = 0; + for (int j = 1; j < TreeData.Count - 1; j++) + { + for (int i = 1; i < TreeData[0].Count - 1; i++) + { + result = Int32.Max(result, GetScenicScore(i, j)); + } + } + + return result; + } + } + + private int GetScenicScore(int i, int j) + { + int baseHeight = TreeData[j][i]; + int viewUp=0, viewDown=0, viewLeft=0, viewRight=0; + + // Up + for (int y = j-1, x = i; y >= 0; y--) + { + viewUp++; + if (TreeData[y][x] >= baseHeight) + { + break; + } + } + + // Right + for (int x = i + 1, y = j; x < TreeData[i].Count; x++) + { + viewRight++; + if (TreeData[y][x] >= baseHeight) + { + break; + } + } + + // Left + for (int x = i-1, y = j; x >= 0; x--) + { + viewLeft++; + if (TreeData[y][x] >= baseHeight) + { + break; + } + } + + // Down + for (int y = j + 1, x = i; y < TreeData.Count; y++) + { + viewDown++; + if (TreeData[y][x] >= baseHeight) + { + break; + } + } + + return viewUp * viewDown * viewLeft * viewRight; + + } +} + + + + diff --git a/2022/Day08CSharp/Properties/launchSettings.json b/2022/Day08CSharp/Properties/launchSettings.json new file mode 100644 index 0000000..b80af26 --- /dev/null +++ b/2022/Day08CSharp/Properties/launchSettings.json @@ -0,0 +1,8 @@ +{ + "profiles": { + "Day08CSharp": { + "commandName": "Project", + "workingDirectory": "C:\\dev\\DevSandbox\\AdventOfCode\\2022\\Day08CSharp" + } + } +} \ No newline at end of file diff --git a/2022/Day08CSharp/example-input.txt b/2022/Day08CSharp/example-input.txt new file mode 100644 index 0000000..963a102 --- /dev/null +++ b/2022/Day08CSharp/example-input.txt @@ -0,0 +1,5 @@ +30373 +25512 +65332 +33549 +35390 \ No newline at end of file diff --git a/2022/Day08CSharp/problem.txt b/2022/Day08CSharp/problem.txt new file mode 100644 index 0000000..77bdf67 --- /dev/null +++ b/2022/Day08CSharp/problem.txt @@ -0,0 +1,72 @@ +--- Day 8: Treetop Tree House --- + +The expedition comes across a peculiar patch of tall trees all planted carefully in a grid. The Elves explain that a previous expedition planted these trees as a reforestation effort. Now, they're curious if this would be a good location for a tree house. + +First, determine whether there is enough tree cover here to keep a tree house hidden. To do this, you need to count the number of trees that are visible from outside the grid when looking directly along a row or column. + +The Elves have already launched a quadcopter to generate a map with the height of each tree (your puzzle input). For example: + +30373 +25512 +65332 +33549 +35390 + +Each tree is represented as a single digit whose value is its height, where 0 is the shortest and 9 is the tallest. + +A tree is visible if all of the other trees between it and an edge of the grid are shorter than it. Only consider trees in the same row or column; that is, only look up, down, left, or right from any given tree. + +All of the trees around the edge of the grid are visible - since they are already on the edge, there are no trees to block the view. In this example, that only leaves the interior nine trees to consider: + + The top-left 5 is visible from the left and top. (It isn't visible from the right or bottom since other trees of height 5 are in the way.) + The top-middle 5 is visible from the top and right. + The top-right 1 is not visible from any direction; for it to be visible, there would need to only be trees of height 0 between it and an edge. + The left-middle 5 is visible, but only from the right. + The center 3 is not visible from any direction; for it to be visible, there would need to be only trees of at most height 2 between it and an edge. + The right-middle 3 is visible from the right. + In the bottom row, the middle 5 is visible, but the 3 and 4 are not. + +With 16 trees visible on the edge and another 5 visible in the interior, a total of 21 trees are visible in this arrangement. + +Consider your map; how many trees are visible from outside the grid? + +--- Part Two --- + +Content with the amount of tree cover available, the Elves just need to know the best spot to build their tree house: they would like to be able to see a lot of trees. + +To measure the viewing distance from a given tree, look up, down, left, and right from that tree; stop if you reach an edge or at the first tree that is the same height or taller than the tree under consideration. (If a tree is right on the edge, at least one of its viewing distances will be zero.) + +The Elves don't care about distant trees taller than those found by the rules above; the proposed tree house has large eaves to keep it dry, so they wouldn't be able to see higher than the tree house anyway. + +In the example above, consider the middle 5 in the second row: + +30373 +25512 +65332 +33549 +35390 + + Looking up, its view is not blocked; it can see 1 tree (of height 3). + Looking left, its view is blocked immediately; it can see only 1 tree (of height 5, right next to it). + Looking right, its view is not blocked; it can see 2 trees. + Looking down, its view is blocked eventually; it can see 2 trees (one of height 3, then the tree of height 5 that blocks its view). + +A tree's scenic score is found by multiplying together its viewing distance in each of the four directions. For this tree, this is 4 (found by multiplying 1 * 1 * 2 * 2). + +However, you can do even better: consider the tree of height 5 in the middle of the fourth row: + +30373 +25512 +65332 +33549 +35390 + + Looking up, its view is blocked at 2 trees (by another tree with a height of 5). + Looking left, its view is not blocked; it can see 2 trees. + Looking down, its view is also not blocked; it can see 1 tree. + Looking right, its view is blocked at 2 trees (by a massive tree of height 9). + +This tree's scenic score is 8 (2 * 2 * 1 * 2); this is the ideal spot for the tree house. + +Consider each tree on your map. What is the highest scenic score possible for any tree? + diff --git a/2022/Day08CSharp/puzzle-input.txt b/2022/Day08CSharp/puzzle-input.txt new file mode 100644 index 0000000..df5c066 --- /dev/null +++ b/2022/Day08CSharp/puzzle-input.txt @@ -0,0 +1,99 @@ +404310113342042430523206553054613026452223317713352040314520532034136044035422242052404520323121423 +120022131035104020413264056552251024207112052153646716635163015540126546334604634352130343204203212 +114444043404350333465355412140536532335724647116565610572546474626506052303052063065052530351012030 +212240414554223531015555065165021520410363021033163304514155663733352116600665403462501544352500033 +324144130111224105125305614015103771206061460425505011635353313773273343325122626415203015344311232 +113245430241150240464126012614135430370003075735010164413125456766205302613425655024334411031155403 +441245002130523346005210411662277072426351216071200446765701447237330324567025204602342520044502121 +214045553122025654652221354616163561012500762010384874262074144065234401637722263412266464251452314 +420554052436551160102504245073471242400253801258004372606111667766236046654353552356241642235535400 +230444034403653045355316273427144521155460537330375254634265217831710133466511570022515061342332314 +215330305636623403455371527067601715250678103470620507380025232122252031461570076036342312211025412 +152531154664324333510065716166433534816054420634864077383448250450766671674224724566465113516230555 +214332343546262452365454705617472281546633211772075171047360414071436550632720021764434561305210301 +111443005611044613477737043746056557178022072372401206038184673647422320773366100676006211551510212 +133313521334520014277727658110473505777283286103991788280475205774027243280366061162025220015443455 +155404252050544375401645717463634684248661783289138494563725362778686756122861113531553244022156404 +101264441110131756443257557872335606716942314559648922296471179061870856246756574324520340610552502 +552345216103355364312158072306454410946149736569151493634487672710443362287688034427626033035266435 +032116136355447236216431376728258285654613995348237354962282338329733408310145842020562245054642441 +224363655451243141363087456580326751652471257429153117112342588642859256252141665722503521125022565 +203656402177710126565314466702484652152875481365818345352121487714962821315157703464343750046056642 +556042122224622324270101114885994351144861589211656115175234527658398149331284812500044434453264665 +333402317273401421323318415855844499641764213948757537893227517242385296970317342824206711503004500 +341045445002443367084450562962259886574728664877676766689484955395194385797583863611332250124025511 +530441155216276525375870173389743919985448259629562325456237285529598688811050240824703721074602060 +320021441136216827813607342916845194696625696785568454728524752386544154132864251748117643644612016 +356236015127477502168551236473444979246675949449587984562945859468987964451443376640177554302403555 +521032161450418348764563917129159623593365988455562286236885389659621188427923285451742156213351116 +161327255665606701821864175493119539272489637754729983857664245665796727199928145136462257620362465 +324256011240774073378929732467468357478524626995373968674237767743387885552216853467388044247756643 +342275312602047038565615877434724873572784389557789777857693948752846554139723438258054200025014665 +051242516637708146638198373275222758924486548779744574439965559638384373152521363134036477637737533 +643152555635778437871298236855485688298578349488385645847564753765967563925377954286572876073532255 +052252355510464443878597562686999366353446874577654743895687373779864325297372128203202721414431575 +003626454683627045725543215594452394956436955758673339474559874959389629573279978978206522053161354 +627516237702078544682942119397343558584845947957956986767739349699889797692213624665730454802067156 +200457151510133551651137637224323537736454384779467644967339586954746668462789875763614758041306350 +335154370506881211537946276895249658859666595888979499974679997597784647296794417997582782381025574 +417013603706282285595672445598476844553485594594694865577988599545878778554434654896767653370600163 +151076753567166396584462282676939868463579768879699478585698835334464668886671938943507604626741055 +316424603540766436474549593426596456855354984858479546978868766769885893482223982736645038024543705 +004215748043040351658449499986735473677885875695647795765956883964888467568526739498861211513560376 +277541056808037332121324298298467888439897499685669789559864468637637659443647357982947036001076457 +301501750655275336942638945358964763536465468989488667796645858846573465972686416787340853151245644 +712676410408042175645992725856638455389978885467555675756857577896385395967245722641824067046404672 +127263578732604583334129426765554856475867757556696788664596649687355745252374587569983167874135470 +372567082480204357437552435378439546954796599589886886999448548554873566373887522667838861416626063 +504053336576743468622556295365645349984889785678558796559694969799447958394395964464961434514564147 +064634031154473874813798648457894764786965996797567598577449556796733655629459883126531875350855667 +400242382466736377478123774763774843994888788596767997699956676943467867843525339987287625323107646 +574363428370183567442332638863797996446594766875586998755697498794589458457898531351415551433522556 +412167557672308712367589426397979758975789888776586986996554696687355758873775853874897420702317101 +770303703378804536976332878328747387584568459887597696678765458466869646823658768383568726667515101 +452233157246118285247999798264378649666585777768676869779576767654376979948352929633336613662437752 +445720367378533569416697754293496373467957556998785966978548459859767957423835655379853826412537652 +743314715884636853952588482996464655775879867757788958998964888966363788982234644268286248732605364 +421252340411081749754123523897998635856478675875579877695848758757598799352859935972592464121200154 +240060534144421235633966383826944588955556569877797756857998594637769364656894472644372534212151333 +030406408132303595787173445575575686448657959549968444868588895645466777395756386243943041550563144 +273114334761050642652349846942498578754978859865947785499768464999467827979546133588431400553072571 +545140256541065084978642274659978546685549897854997987959494546787556536925383718147440765477035264 +213551156551872738118554524476466757347767578664548796858878373885346253453663631131187832513353720 +031302225003187455433275258559853476398764745884957978785699446894568423546775622669458815340346707 +622067430504086108575211657573256737949367744989999457768543933556446848583667956928715425470730162 +242111564658304088777519536233444248435478893367596684875833738467857765957226924427228481325217576 +364055473230737526383625952385867723976677963779587753646766774437577338682519314383352032477133503 +321304645532064452197673316923724578983475574649393989787463485775923766996461422676353215802454115 +233105015700144131749152169592849597799334664843639757588555464399727868723189114371617811204424461 +200116461554525361612654498296559659356483355845588365383658756592935783639172813284867400343573434 +063667611325433422432889612288938865635845895684777885359355942764253445159748552521586663111276320 +602227464555468655756429585352455445365885785394937349896765628578363566623445953670505237256637361 +565061226117741561827365137945864958743698627664964883854386585344264536463794276685706331233201162 +022104543457075344433186746554898622888662879483534875732366545699493494249416960261188772111451356 +436620604222365732527426815953936962792895744565572436255439745543587676567692850112721235162354066 +131524412733104587364628695894553856954929535227798584623638988936368718849285573225440174764501540 +542435561362065510830610739646131257342496749563278998673868857392617956152266780580611770145235126 +403602071007077303754367568233894922487258962426625788335236293726841614813262288087316403413301325 +653365633721421431240238511233988284565865357732839935658824268124333235971843281322245237465244640 +306442137750441441547377231538498282333378867895866774269433657996442236932105133474315101276433026 +026362613577242456258634050671963436933444863559863424588962566983574869370120588454323506304034454 +324415624033560610606167505705335537131257342423913353449125925341756615871358508731521557026114366 +444331064667665623244155236812366396427328522481655365283852878951317624280585607560532023416160531 +356100663130344012403254770320017162464663432371564992618187659799885888814177114132251720346235260 +335255502200627412653317161700362276552642826696514719212976746877872577501286045667131741121615252 +432342461115176570456177856545043415022291419917157172495246595828707718465323075462216735351424603 +052014513044443630413221560860665817858636725794462229844935048786680202681024216170152252502634130 +020320466436640542335164431658623622013245024685776848188641088056885388363367731111662103514422342 +243313636453126262451331254501288620001007675817755413767166283281358125642646705337503156330264143 +322052011503256425407127570260816542455843672731851386601352556410113100252536057366522542640013024 +122243505446640664755657664365330525660042002157156113773258264460845541635501120634115505113335223 +400325240315062161366031440416477741684364564857378773141186841270761406731633364031611642530523212 +033035153153462216052744630367426463087060858055232515783208471176613722677126341566006053644200442 +235202335236553544540304237444375273744171216804617062750281644425671760635002322246613220112112312 +424551125551101552103143451563560236361153202606118476772167626160624534653670012136420410040115003 +433115113101302300404521334255672566234211040710503455555073775502462316364453256460002143312311050 +113231445145014641142635155170110005103066306721236312425606163376276006132006331601341420241440202 +124001123533434316253543204160331101266365020140476416102251147360064153500112411356634011134351330 +004034442142153246064264662030666771573157310340000724745700036734054206654603230345313434140344030 +321402405400252420216445132115124427151235102635446313422013474177203430646340442422400002232222342 diff --git a/2022/Day09CSharp/Day09CSharp.csproj b/2022/Day09CSharp/Day09CSharp.csproj new file mode 100644 index 0000000..d439800 --- /dev/null +++ b/2022/Day09CSharp/Day09CSharp.csproj @@ -0,0 +1,10 @@ + + + + Exe + net7.0 + enable + enable + + + diff --git a/2022/Day09CSharp/Program.cs b/2022/Day09CSharp/Program.cs new file mode 100644 index 0000000..20e0c64 --- /dev/null +++ b/2022/Day09CSharp/Program.cs @@ -0,0 +1,264 @@ +// See https://aka.ms/new-console-template for more information +using System.Reflection; + +Part01(); +Part02(); + +void Part01() +{ + Simulation exampleSim = new Simulation(2); + Simulation puzzleSim = new Simulation(2); + + exampleSim.LoadDataFile("example-input.txt"); + exampleSim.SimulateAll(0, 5, 0, 5); + Console.WriteLine("Part01, Example Visited: " + exampleSim.TailVisitedCount); + + puzzleSim.LoadDataFile("puzzle-input.txt"); + puzzleSim.SimulateAll(-50, 50, -50, 50); + Console.WriteLine("Part01, Puzzle Visited: " + puzzleSim.TailVisitedCount); +} + +void Part02() +{ + Simulation exampleSim = new Simulation(10); + Simulation example2Sim = new Simulation(10); + Simulation puzzleSim = new Simulation(10); + + exampleSim.LoadDataFile("example-input.txt"); + exampleSim.SimulateAll(0, 6, 0, 5, false); + Console.WriteLine("Part02, Example Visited: " + exampleSim.TailVisitedCount); + + example2Sim.LoadDataFile("example-input2.txt"); + example2Sim.SimulateAll(-15,15,-10,10, false); + Console.WriteLine("Part02, Example2 Visited: " + example2Sim.TailVisitedCount); + + puzzleSim.LoadDataFile("puzzle-input.txt"); + puzzleSim.SimulateAll(-50, 50, -50, 50); + Console.WriteLine("Part02, Puzzle Visited: " + puzzleSim.TailVisitedCount); +} + +class Position +{ + public int x; + public int y; + + public Position() : this(0,0) { } + public Position(int x, int y) + { + this.x = x; + this.y = y; + } + + public Position(Position other) : this(other.x, other.y) { } + + public override bool Equals(object? obj) + { + if (!(obj is Position)) return false; + Position p = (Position)obj; + + return p.x == x & p.y == y; + } + + public override int GetHashCode() + { + return x ^ y; + } + + public double distanceFrom(Position p) + { + return Math.Sqrt(Math.Pow(p.x - x, 2) + Math.Pow(p.y - y, 2)); + } + + public void distanceFrom(Position p, out int x, out int y) + { + x = p.x - this.x; + y = p.y - this.y; + } +} + +class RopeBridge +{ + public Position Head { + get + { + return rope[0]; + } + } + + public Position Tail + { + get + { + return rope[rope.Count - 1]; + } + set + { + rope[rope.Count - 1] = value; + } + } + + List rope = new List(); + + public RopeBridge(int bridgeLength) + { + for (int i = 0; i < bridgeLength; i++) + { + rope.Add(new Position()); + } + } + + private void UpdateKnot(Position parent, int index) + { + double distance = rope[index - 1].distanceFrom(rope[index]); + + if (distance >= 2) + { + int x, y; + rope[index].distanceFrom(parent, out x, out y); + + if (x > 0) rope[index].x++; + if (y > 0) rope[index].y++; + if (x < 0) rope[index].x--; + if (y < 0) rope[index].y--; + + // Only update if it actually moved + if (index + 1 < rope.Count) + { + UpdateKnot(rope[index], index + 1); + } + } + } + + public void MoveHead(char direction) + { + Position oldHead = new Position(Head); + switch (direction) + { + case 'U': + Head.y++; + break; + case 'D': + Head.y--; + break; + case 'L': + Head.x--; + break; + case 'R': + Head.x++; + break; + default: + throw new InvalidDataException(); + } + + UpdateKnot(Head, 1); + } + + public void PrintBridge(int x_min, int x_max, int y_min, int y_max) + { + for (int j = y_max; j >= y_min; j--) + { + for (int i = x_min; i < x_max; i++) + { + var index = rope.IndexOf(new Position(i, j)); + + if (index != -1) + { + var query = rope.Where(pos => pos.x == i && pos.y == j); + + if (query.Count() > 1) + { + for (index = 0; index < rope.Count; index++) + { + if (rope[index].x == i && rope[index].y == j) + { + break; + } + } + } + + if (index == 0) + { + Console.Write('H'); + } + else if (index + 1 == rope.Count) + { + Console.Write('T'); + } + else + { + Console.Write(index); + } + } + else + { + Console.Write('.'); + } + } + Console.WriteLine(); + } + + Console.WriteLine(); + } + +} + +class Simulation +{ + RopeBridge bridge; + Dictionary visited = new Dictionary(); + List> simulationSteps = new List>(); + + public Simulation(int bridgeLength) + { + bridge = new RopeBridge(bridgeLength); + } + + public void LoadDataFile(string filename) + { + using (StreamReader reader = System.IO.File.OpenText(filename)) + { + while (!reader.EndOfStream) + { + string? line = reader.ReadLine(); + if (line == null) throw new InvalidDataException(); + + var split = line.Split(' '); + if (!Char.IsAsciiLetter(split[0][0])) throw new InvalidDataException(); + if (!Char.IsAsciiDigit(split[1][0])) throw new InvalidDataException(); + + simulationSteps.Add(new Tuple(split[0][0], Int32.Parse(split[1]))); + } + } + } + + public int TailVisitedCount + { + get { return visited.Count; } + } + + public void SimulateAll(int x_min, int x_max, int y_min, int y_max, bool print = false) + { + if (print) bridge.PrintBridge(x_min, x_max, y_min, y_max); + + foreach (var pair in simulationSteps) + { + if (print) Console.WriteLine(String.Format(" === {0} {1} ===", pair.Item1, pair.Item2)); + + Simulate(pair.Item1, pair.Item2, x_min, x_max, y_min, y_max, print); + } + } + + public void Simulate(char direction, int count, int x_min, int x_max, int y_min, int y_max, bool print = false) + { + // Visit initial state always + visited.TryAdd(new Position(bridge.Tail), true); + + for (int i = 0; i < count; i++) + { + bridge.MoveHead(direction); + visited.TryAdd(new Position(bridge.Tail), true); + + if (print) bridge.PrintBridge(x_min, x_max, y_min, y_max); + } + } +} \ No newline at end of file diff --git a/2022/Day09CSharp/Properties/launchSettings.json b/2022/Day09CSharp/Properties/launchSettings.json new file mode 100644 index 0000000..2c5fe4d --- /dev/null +++ b/2022/Day09CSharp/Properties/launchSettings.json @@ -0,0 +1,8 @@ +{ + "profiles": { + "Day09CSharp": { + "commandName": "Project", + "workingDirectory": "C:\\dev\\DevSandbox\\AdventOfCode\\2022\\Day09CSharp" + } + } +} \ No newline at end of file diff --git a/2022/Day09CSharp/example-input.txt b/2022/Day09CSharp/example-input.txt new file mode 100644 index 0000000..28cf97a --- /dev/null +++ b/2022/Day09CSharp/example-input.txt @@ -0,0 +1,8 @@ +R 4 +U 4 +L 3 +D 1 +R 4 +D 1 +L 5 +R 2 \ No newline at end of file diff --git a/2022/Day09CSharp/example-input2.txt b/2022/Day09CSharp/example-input2.txt new file mode 100644 index 0000000..39040bb --- /dev/null +++ b/2022/Day09CSharp/example-input2.txt @@ -0,0 +1,8 @@ +R 5 +U 8 +L 8 +D 3 +R 17 +D 10 +L 25 +U 20 \ No newline at end of file diff --git a/2022/Day09CSharp/problem.txt b/2022/Day09CSharp/problem.txt new file mode 100644 index 0000000..7c8370f --- /dev/null +++ b/2022/Day09CSharp/problem.txt @@ -0,0 +1,685 @@ +--- Day 9: Rope Bridge --- + +This rope bridge creaks as you walk along it. You aren't sure how old it is, or whether it can even support your weight. + +It seems to support the Elves just fine, though. The bridge spans a gorge which was carved out by the massive river far below you. + +You step carefully; as you do, the ropes stretch and twist. You decide to distract yourself by modeling rope physics; maybe you can even figure out where not to step. + +Consider a rope with a knot at each end; these knots mark the head and the tail of the rope. If the head moves far enough away from the tail, the tail is pulled toward the head. + +Due to nebulous reasoning involving Planck lengths, you should be able to model the positions of the knots on a two-dimensional grid. Then, by following a hypothetical series of motions (your puzzle input) for the head, you can determine how the tail will move. + +Due to the aforementioned Planck lengths, the rope must be quite short; in fact, the head (H) and tail (T) must always be touching (diagonally adjacent and even overlapping both count as touching): + +.... +.TH. +.... + +.... +.H.. +..T. +.... + +... +.H. (H covers T) +... + +If the head is ever two steps directly up, down, left, or right from the tail, the tail must also move one step in that direction so it remains close enough: + +..... ..... ..... +.TH.. -> .T.H. -> ..TH. +..... ..... ..... + +... ... ... +.T. .T. ... +.H. -> ... -> .T. +... .H. .H. +... ... ... + +Otherwise, if the head and tail aren't touching and aren't in the same row or column, the tail always moves one step diagonally to keep up: + +..... ..... ..... +..... ..H.. ..H.. +..H.. -> ..... -> ..T.. +.T... .T... ..... +..... ..... ..... + +..... ..... ..... +..... ..... ..... +..H.. -> ...H. -> ..TH. +.T... .T... ..... +..... ..... ..... + +You just need to work out where the tail goes as the head follows a series of motions. Assume the head and the tail both start at the same position, overlapping. + +For example: + +R 4 +U 4 +L 3 +D 1 +R 4 +D 1 +L 5 +R 2 + +This series of motions moves the head right four steps, then up four steps, then left three steps, then down one step, and so on. After each step, you'll need to update the position of the tail if the step means the head is no longer adjacent to the tail. Visually, these motions occur as follows (s marks the starting position as a reference point): + +== Initial State == + +...... +...... +...... +...... +H..... (H covers T, s) + +== R 4 == + +...... +...... +...... +...... +TH.... (T covers s) + +...... +...... +...... +...... +sTH... + +...... +...... +...... +...... +s.TH.. + +...... +...... +...... +...... +s..TH. + +== U 4 == + +...... +...... +...... +....H. +s..T.. + +...... +...... +....H. +....T. +s..... + +...... +....H. +....T. +...... +s..... + +....H. +....T. +...... +...... +s..... + +== L 3 == + +...H.. +....T. +...... +...... +s..... + +..HT.. +...... +...... +...... +s..... + +.HT... +...... +...... +...... +s..... + +== D 1 == + +..T... +.H.... +...... +...... +s..... + +== R 4 == + +..T... +..H... +...... +...... +s..... + +..T... +...H.. +...... +...... +s..... + +...... +...TH. +...... +...... +s..... + +...... +....TH +...... +...... +s..... + +== D 1 == + +...... +....T. +.....H +...... +s..... + +== L 5 == + +...... +....T. +....H. +...... +s..... + +...... +....T. +...H.. +...... +s..... + +...... +...... +..HT.. +...... +s..... + +...... +...... +.HT... +...... +s..... + +...... +...... +HT.... +...... +s..... + +== R 2 == + +...... +...... +.H.... (H covers T) +...... +s..... + +...... +...... +.TH... +...... +s..... + +After simulating the rope, you can count up all of the positions the tail visited at least once. In this diagram, s again marks the starting position (which the tail also visited) and # marks other positions the tail visited: + +..##.. +...##. +.####. +....#. +s###.. + +So, there are 13 positions the tail visited at least once. + +Simulate your complete hypothetical series of motions. How many positions does the tail of the rope visit at least once? + +Your puzzle answer was 6090. + +The first half of this puzzle is complete! It provides one gold star: * +--- Part Two --- + +A rope snaps! Suddenly, the river is getting a lot closer than you remember. The bridge is still there, but some of the ropes that broke are now whipping toward you as you fall through the air! + +The ropes are moving too quickly to grab; you only have a few seconds to choose how to arch your body to avoid being hit. Fortunately, your simulation can be extended to support longer ropes. + +Rather than two knots, you now must simulate a rope consisting of ten knots. One knot is still the head of the rope and moves according to the series of motions. Each knot further down the rope follows the knot in front of it using the same rules as before. + +Using the same series of motions as the above example, but with the knots marked H, 1, 2, ..., 9, the motions now occur as follows: + +== Initial State == + +...... +...... +...... +...... +H..... (H covers 1, 2, 3, 4, 5, 6, 7, 8, 9, s) + +== R 4 == + +...... +...... +...... +...... +1H.... (1 covers 2, 3, 4, 5, 6, 7, 8, 9, s) + +...... +...... +...... +...... +21H... (2 covers 3, 4, 5, 6, 7, 8, 9, s) + +...... +...... +...... +...... +321H.. (3 covers 4, 5, 6, 7, 8, 9, s) + +...... +...... +...... +...... +4321H. (4 covers 5, 6, 7, 8, 9, s) + +== U 4 == + +...... +...... +...... +....H. +4321.. (4 covers 5, 6, 7, 8, 9, s) + +...... +...... +....H. +.4321. +5..... (5 covers 6, 7, 8, 9, s) + +...... +....H. +....1. +.432.. +5..... (5 covers 6, 7, 8, 9, s) + +....H. +....1. +..432. +.5.... +6..... (6 covers 7, 8, 9, s) + +== L 3 == + +...H.. +....1. +..432. +.5.... +6..... (6 covers 7, 8, 9, s) + +..H1.. +...2.. +..43.. +.5.... +6..... (6 covers 7, 8, 9, s) + +.H1... +...2.. +..43.. +.5.... +6..... (6 covers 7, 8, 9, s) + +== D 1 == + +..1... +.H.2.. +..43.. +.5.... +6..... (6 covers 7, 8, 9, s) + +== R 4 == + +..1... +..H2.. +..43.. +.5.... +6..... (6 covers 7, 8, 9, s) + +..1... +...H.. (H covers 2) +..43.. +.5.... +6..... (6 covers 7, 8, 9, s) + +...... +...1H. (1 covers 2) +..43.. +.5.... +6..... (6 covers 7, 8, 9, s) + +...... +...21H +..43.. +.5.... +6..... (6 covers 7, 8, 9, s) + +== D 1 == + +...... +...21. +..43.H +.5.... +6..... (6 covers 7, 8, 9, s) + +== L 5 == + +...... +...21. +..43H. +.5.... +6..... (6 covers 7, 8, 9, s) + +...... +...21. +..4H.. (H covers 3) +.5.... +6..... (6 covers 7, 8, 9, s) + +...... +...2.. +..H1.. (H covers 4; 1 covers 3) +.5.... +6..... (6 covers 7, 8, 9, s) + +...... +...2.. +.H13.. (1 covers 4) +.5.... +6..... (6 covers 7, 8, 9, s) + +...... +...... +H123.. (2 covers 4) +.5.... +6..... (6 covers 7, 8, 9, s) + +== R 2 == + +...... +...... +.H23.. (H covers 1; 2 covers 4) +.5.... +6..... (6 covers 7, 8, 9, s) + +...... +...... +.1H3.. (H covers 2, 4) +.5.... +6..... (6 covers 7, 8, 9, s) + +Now, you need to keep track of the positions the new tail, 9, visits. In this example, the tail never moves, and so it only visits 1 position. However, be careful: more types of motion are possible than before, so you might want to visually compare your simulated rope to the one above. + +Here's a larger example: + +R 5 +U 8 +L 8 +D 3 +R 17 +D 10 +L 25 +U 20 + +These motions occur as follows (individual steps are not shown): + +== Initial State == + +.......................... +.......................... +.......................... +.......................... +.......................... +.......................... +.......................... +.......................... +.......................... +.......................... +.......................... +.......................... +.......................... +.......................... +.......................... +...........H.............. (H covers 1, 2, 3, 4, 5, 6, 7, 8, 9, s) +.......................... +.......................... +.......................... +.......................... +.......................... + +== R 5 == + +.......................... +.......................... +.......................... +.......................... +.......................... +.......................... +.......................... +.......................... +.......................... +.......................... +.......................... +.......................... +.......................... +.......................... +.......................... +...........54321H......... (5 covers 6, 7, 8, 9, s) +.......................... +.......................... +.......................... +.......................... +.......................... + +== U 8 == + +.......................... +.......................... +.......................... +.......................... +.......................... +.......................... +.......................... +................H......... +................1......... +................2......... +................3......... +...............54......... +..............6........... +.............7............ +............8............. +...........9.............. (9 covers s) +.......................... +.......................... +.......................... +.......................... +.......................... + +== L 8 == + +.......................... +.......................... +.......................... +.......................... +.......................... +.......................... +.......................... +........H1234............. +............5............. +............6............. +............7............. +............8............. +............9............. +.......................... +.......................... +...........s.............. +.......................... +.......................... +.......................... +.......................... +.......................... + +== D 3 == + +.......................... +.......................... +.......................... +.......................... +.......................... +.......................... +.......................... +.......................... +.........2345............. +........1...6............. +........H...7............. +............8............. +............9............. +.......................... +.......................... +...........s.............. +.......................... +.......................... +.......................... +.......................... +.......................... + +== R 17 == + +.......................... +.......................... +.......................... +.......................... +.......................... +.......................... +.......................... +.......................... +.......................... +.......................... +................987654321H +.......................... +.......................... +.......................... +.......................... +...........s.............. +.......................... +.......................... +.......................... +.......................... +.......................... + +== D 10 == + +.......................... +.......................... +.......................... +.......................... +.......................... +.......................... +.......................... +.......................... +.......................... +.......................... +.......................... +.......................... +.......................... +.......................... +.......................... +...........s.........98765 +.........................4 +.........................3 +.........................2 +.........................1 +.........................H + +== L 25 == + +.......................... +.......................... +.......................... +.......................... +.......................... +.......................... +.......................... +.......................... +.......................... +.......................... +.......................... +.......................... +.......................... +.......................... +.......................... +...........s.............. +.......................... +.......................... +.......................... +.......................... +H123456789................ + +== U 20 == + +H......................... +1......................... +2......................... +3......................... +4......................... +5......................... +6......................... +7......................... +8......................... +9......................... +.......................... +.......................... +.......................... +.......................... +.......................... +...........s.............. +.......................... +.......................... +.......................... +.......................... +.......................... + +Now, the tail (9) visits 36 positions (including s) at least once: + +.......................... +.......................... +.......................... +.......................... +.......................... +.......................... +.......................... +.......................... +.......................... +#......................... +#.............###......... +#............#...#........ +.#..........#.....#....... +..#..........#.....#...... +...#........#.......#..... +....#......s.........#.... +.....#..............#..... +......#............#...... +.......#..........#....... +........#........#........ +.........########......... + +Simulate your complete series of motions on a larger rope with ten knots. How many positions does the tail of the rope visit at least once? diff --git a/2022/Day09CSharp/puzzle-input.txt b/2022/Day09CSharp/puzzle-input.txt new file mode 100644 index 0000000..96f76bf --- /dev/null +++ b/2022/Day09CSharp/puzzle-input.txt @@ -0,0 +1,2000 @@ +U 1 +D 1 +L 1 +U 2 +L 1 +D 2 +L 2 +U 2 +L 1 +R 2 +U 2 +D 1 +R 2 +U 1 +R 1 +U 1 +R 1 +U 2 +L 1 +U 2 +D 1 +R 1 +U 2 +D 1 +U 2 +D 2 +U 2 +D 1 +R 1 +D 2 +L 2 +R 2 +L 1 +R 2 +D 2 +L 2 +U 1 +D 2 +R 2 +L 2 +R 2 +D 2 +R 1 +D 1 +L 1 +D 1 +L 2 +D 1 +R 1 +L 1 +U 2 +L 2 +U 1 +D 1 +U 1 +D 1 +L 2 +D 2 +L 2 +U 1 +R 2 +D 1 +U 1 +R 2 +L 1 +R 1 +L 1 +R 2 +L 1 +U 2 +R 1 +L 1 +U 1 +D 2 +R 1 +D 2 +L 1 +U 2 +D 2 +L 2 +U 1 +L 1 +D 1 +L 2 +U 2 +R 2 +U 1 +D 2 +L 1 +D 2 +R 1 +L 1 +R 1 +D 2 +U 1 +R 1 +L 1 +U 2 +R 2 +L 1 +R 2 +L 1 +R 1 +L 2 +U 1 +R 2 +D 2 +U 1 +D 1 +L 2 +D 1 +R 3 +D 1 +L 3 +D 1 +R 2 +D 1 +R 2 +U 3 +L 2 +U 2 +D 2 +L 3 +R 3 +U 3 +R 3 +L 1 +R 2 +L 2 +R 3 +U 2 +D 3 +L 3 +D 1 +R 2 +U 1 +D 2 +U 2 +L 1 +U 2 +R 2 +D 2 +L 3 +D 1 +L 1 +R 1 +D 3 +L 2 +R 2 +L 2 +R 2 +D 1 +R 2 +L 3 +U 1 +R 2 +D 2 +R 1 +D 2 +R 2 +L 3 +U 1 +L 2 +U 1 +D 3 +L 1 +U 1 +D 3 +U 2 +L 1 +U 3 +D 2 +R 2 +U 3 +L 3 +D 1 +U 3 +R 1 +U 2 +L 2 +D 1 +U 1 +D 3 +R 1 +D 3 +U 3 +L 3 +R 2 +D 3 +L 2 +U 3 +L 1 +D 3 +L 2 +D 1 +R 3 +L 1 +R 3 +U 2 +L 3 +D 1 +R 2 +L 1 +U 1 +L 3 +R 3 +U 2 +D 2 +U 2 +R 1 +L 3 +U 3 +L 1 +R 3 +D 3 +L 2 +D 3 +U 1 +L 3 +D 3 +R 2 +U 3 +D 1 +R 1 +L 1 +U 4 +L 2 +U 3 +R 3 +U 1 +D 2 +R 4 +U 1 +L 1 +U 3 +R 2 +D 4 +U 3 +D 1 +U 1 +L 1 +U 3 +R 4 +L 1 +R 4 +L 1 +R 2 +L 4 +D 1 +L 4 +R 2 +D 2 +R 2 +U 1 +D 2 +L 4 +D 1 +R 3 +D 2 +U 3 +D 4 +L 3 +U 2 +R 4 +U 4 +D 2 +L 2 +D 1 +U 3 +L 2 +R 4 +L 1 +U 3 +L 2 +R 3 +U 1 +R 4 +D 3 +L 3 +D 1 +U 4 +L 4 +D 3 +R 1 +L 1 +D 2 +L 1 +R 4 +D 2 +L 3 +D 4 +L 4 +U 2 +D 1 +U 4 +D 4 +U 2 +D 2 +R 4 +L 2 +D 4 +U 2 +L 1 +D 4 +U 3 +D 3 +R 2 +D 1 +U 4 +R 2 +U 3 +D 1 +R 1 +L 1 +D 1 +L 3 +R 4 +U 2 +L 4 +D 3 +L 2 +R 4 +L 3 +U 3 +L 1 +D 4 +R 1 +L 2 +D 1 +R 2 +L 1 +R 4 +L 1 +R 3 +U 2 +D 1 +R 2 +L 1 +D 5 +U 1 +D 2 +R 5 +U 4 +L 1 +D 2 +R 3 +U 2 +D 1 +L 4 +D 5 +R 4 +D 2 +R 3 +D 5 +L 2 +R 5 +U 2 +L 4 +R 4 +U 3 +D 3 +R 1 +U 4 +D 2 +U 2 +L 3 +D 4 +L 4 +D 2 +U 5 +R 1 +U 4 +L 2 +U 3 +R 5 +D 4 +U 5 +R 2 +D 5 +R 3 +U 1 +R 4 +L 3 +D 1 +L 1 +R 5 +L 5 +D 2 +U 5 +D 5 +R 5 +U 3 +D 4 +R 4 +U 2 +L 1 +D 3 +U 3 +R 4 +U 4 +D 1 +L 1 +R 2 +L 5 +R 1 +L 3 +D 1 +U 5 +R 1 +U 4 +D 5 +L 5 +R 2 +L 4 +U 1 +L 5 +D 2 +R 2 +D 1 +R 4 +D 5 +L 3 +D 3 +L 4 +U 5 +L 3 +R 4 +D 4 +R 2 +U 4 +R 4 +D 3 +U 3 +L 3 +R 1 +D 4 +U 1 +R 1 +D 1 +R 4 +D 3 +L 5 +U 1 +D 1 +U 5 +L 5 +D 3 +U 6 +D 5 +U 5 +D 1 +L 5 +D 4 +L 2 +R 6 +U 3 +R 6 +D 6 +U 5 +D 3 +L 1 +R 2 +U 2 +D 4 +U 6 +D 1 +U 1 +D 2 +U 3 +L 1 +U 6 +D 4 +L 6 +U 5 +D 4 +U 3 +R 6 +U 5 +R 2 +U 3 +D 6 +L 5 +U 2 +D 4 +L 4 +D 4 +R 6 +U 4 +L 3 +U 4 +R 6 +D 1 +U 4 +R 1 +L 1 +U 3 +D 6 +L 2 +D 2 +U 3 +R 5 +D 1 +R 3 +U 6 +L 2 +R 2 +U 4 +L 5 +D 4 +U 4 +R 4 +D 5 +L 1 +R 2 +U 4 +L 5 +D 6 +R 2 +L 2 +D 6 +L 1 +R 1 +U 3 +L 4 +D 4 +U 5 +L 3 +D 2 +U 2 +L 1 +R 3 +L 4 +U 6 +L 2 +U 2 +D 3 +L 5 +R 1 +D 1 +U 1 +D 6 +L 6 +D 6 +U 2 +D 6 +L 3 +U 2 +L 6 +D 2 +L 4 +R 5 +D 2 +U 3 +R 1 +D 4 +U 2 +R 5 +D 6 +R 7 +U 5 +L 6 +U 5 +L 2 +R 1 +L 3 +R 6 +U 2 +L 3 +U 7 +R 1 +D 2 +U 4 +R 2 +L 3 +D 2 +U 3 +D 7 +U 2 +L 4 +R 6 +D 5 +R 7 +U 1 +D 3 +U 7 +R 2 +U 4 +D 2 +L 7 +D 2 +U 4 +D 3 +R 4 +U 6 +L 7 +R 7 +L 3 +D 3 +U 1 +L 5 +U 5 +R 2 +U 7 +L 2 +U 2 +D 1 +R 3 +U 1 +L 4 +U 4 +D 4 +U 1 +L 2 +R 5 +D 4 +L 4 +U 3 +R 1 +D 2 +R 7 +D 2 +U 5 +D 1 +U 4 +R 7 +L 4 +R 6 +L 7 +R 2 +D 6 +U 7 +R 1 +D 7 +L 3 +D 2 +L 7 +R 4 +L 2 +D 3 +R 2 +U 6 +L 6 +U 2 +R 2 +U 7 +R 7 +D 5 +U 6 +D 7 +R 6 +D 7 +R 2 +U 7 +L 6 +R 6 +U 1 +D 2 +L 1 +R 3 +D 4 +U 3 +R 6 +D 3 +U 3 +D 5 +L 5 +U 4 +R 6 +D 4 +U 7 +L 3 +U 6 +R 7 +D 8 +R 5 +L 4 +D 2 +L 4 +U 8 +R 2 +D 6 +U 4 +D 6 +U 1 +D 7 +U 7 +L 4 +R 2 +L 7 +D 8 +L 2 +D 7 +R 4 +L 3 +D 8 +R 7 +D 8 +U 7 +D 4 +L 1 +U 1 +D 1 +L 3 +D 4 +L 7 +U 8 +D 2 +R 8 +L 1 +D 8 +L 1 +D 4 +U 1 +R 8 +D 2 +L 6 +D 4 +U 4 +R 1 +U 8 +D 1 +U 8 +R 5 +D 8 +L 7 +D 8 +U 6 +D 2 +R 6 +U 8 +L 5 +U 2 +R 4 +L 2 +D 4 +L 5 +D 4 +R 7 +D 5 +L 4 +R 5 +L 4 +D 6 +L 2 +R 1 +U 8 +R 6 +D 8 +U 2 +R 3 +U 5 +R 2 +D 2 +R 2 +D 4 +U 5 +D 2 +L 2 +U 6 +D 3 +R 8 +U 7 +L 7 +D 2 +U 2 +L 8 +D 5 +U 1 +D 7 +L 6 +D 3 +U 3 +D 5 +R 2 +U 7 +L 3 +U 8 +R 9 +D 9 +U 2 +D 7 +L 1 +R 7 +L 8 +U 3 +D 4 +L 2 +R 2 +D 6 +U 6 +R 5 +U 4 +D 6 +R 7 +D 4 +U 1 +D 6 +R 8 +L 6 +R 7 +D 4 +U 5 +D 2 +R 9 +U 5 +L 9 +D 8 +U 1 +L 7 +R 4 +L 8 +R 6 +U 8 +D 9 +U 8 +D 1 +U 6 +L 2 +R 2 +L 9 +D 2 +R 8 +L 1 +U 1 +L 1 +D 8 +U 7 +L 9 +U 4 +R 2 +U 6 +D 5 +R 1 +L 2 +R 1 +L 7 +R 4 +D 2 +L 1 +U 1 +D 3 +U 4 +R 2 +D 7 +L 4 +U 1 +L 1 +D 8 +U 7 +D 6 +U 8 +L 3 +D 2 +R 8 +U 3 +D 5 +U 5 +D 3 +U 2 +L 1 +R 8 +D 2 +L 4 +U 6 +D 2 +L 7 +U 9 +L 3 +D 1 +U 7 +L 4 +U 3 +L 8 +R 9 +D 2 +L 8 +U 9 +R 3 +D 3 +U 7 +D 9 +R 1 +U 8 +R 4 +L 1 +D 9 +L 6 +U 6 +R 3 +D 4 +U 5 +R 5 +L 3 +R 3 +L 7 +U 7 +R 3 +D 4 +R 3 +L 9 +D 2 +U 1 +L 2 +D 10 +R 4 +D 5 +U 1 +R 9 +L 4 +R 7 +D 10 +U 8 +L 8 +R 7 +L 3 +D 6 +L 8 +D 3 +U 7 +D 2 +L 6 +U 1 +R 5 +D 2 +L 7 +D 3 +L 5 +U 10 +R 2 +U 7 +R 7 +L 3 +U 4 +L 5 +D 9 +L 10 +U 5 +L 8 +R 4 +D 6 +U 9 +R 3 +L 4 +R 10 +L 8 +U 5 +D 10 +L 10 +U 7 +L 7 +R 6 +U 2 +D 10 +R 1 +L 9 +U 2 +R 9 +U 10 +D 5 +U 3 +L 3 +D 9 +R 6 +U 9 +R 3 +L 4 +D 2 +R 6 +D 3 +U 7 +D 6 +U 6 +L 5 +D 5 +R 3 +D 5 +R 5 +D 6 +R 9 +L 9 +D 3 +L 3 +U 4 +L 9 +D 8 +L 1 +D 7 +L 6 +U 9 +R 5 +L 8 +D 4 +R 4 +D 9 +R 7 +D 2 +L 4 +U 10 +R 6 +D 2 +R 9 +U 6 +D 2 +R 7 +L 6 +U 8 +D 6 +U 5 +L 1 +R 3 +D 9 +U 2 +D 9 +L 2 +R 6 +L 4 +U 8 +L 10 +D 11 +L 2 +R 6 +U 9 +L 7 +D 1 +U 10 +R 3 +L 10 +U 1 +R 7 +L 2 +U 3 +D 4 +U 10 +D 8 +R 6 +D 2 +U 7 +L 1 +U 5 +D 3 +U 11 +D 1 +R 9 +U 7 +R 5 +L 6 +U 10 +D 7 +U 2 +D 8 +R 10 +D 10 +U 5 +D 2 +U 4 +R 2 +L 10 +U 8 +L 5 +R 3 +U 6 +R 6 +U 2 +R 8 +L 2 +D 6 +R 11 +D 3 +U 6 +D 6 +R 1 +U 4 +D 8 +L 5 +R 11 +D 3 +U 6 +R 1 +L 7 +D 8 +R 7 +L 6 +R 4 +L 1 +U 4 +R 2 +L 3 +R 4 +U 2 +R 8 +L 7 +U 1 +D 11 +L 5 +U 10 +D 3 +L 4 +D 9 +U 8 +R 10 +L 10 +R 4 +D 1 +U 1 +L 6 +D 11 +L 9 +U 1 +D 1 +L 10 +U 11 +R 4 +L 9 +D 5 +U 6 +L 3 +R 5 +U 4 +R 9 +D 11 +L 5 +U 6 +L 2 +D 8 +R 2 +L 10 +U 9 +D 8 +R 10 +D 5 +U 6 +R 2 +L 11 +D 1 +R 4 +D 6 +U 3 +D 12 +L 3 +D 9 +R 2 +L 9 +U 2 +D 3 +L 2 +D 3 +L 8 +D 9 +U 10 +D 8 +R 11 +U 9 +L 4 +U 8 +L 6 +D 12 +L 5 +U 2 +L 5 +R 5 +U 7 +L 4 +U 1 +L 10 +D 6 +R 3 +L 4 +U 1 +L 3 +D 8 +U 1 +D 6 +L 6 +R 9 +D 7 +U 12 +R 12 +U 12 +L 3 +R 4 +L 3 +D 7 +U 3 +D 12 +U 8 +L 10 +D 11 +R 3 +U 3 +L 11 +U 3 +R 11 +U 6 +R 10 +U 11 +D 4 +R 8 +L 2 +U 3 +D 9 +L 3 +R 7 +D 10 +L 11 +R 9 +L 1 +D 3 +R 1 +D 2 +L 4 +R 4 +L 11 +D 7 +L 7 +U 6 +L 12 +R 2 +L 8 +D 9 +U 5 +L 11 +R 1 +U 12 +R 5 +L 5 +D 11 +R 12 +L 10 +R 8 +D 3 +U 9 +R 6 +L 3 +U 13 +D 13 +L 9 +U 6 +D 6 +U 9 +L 9 +R 4 +L 13 +R 2 +U 10 +L 4 +U 7 +D 8 +U 8 +L 3 +U 10 +L 6 +D 1 +R 10 +U 2 +R 12 +L 5 +R 7 +L 11 +D 1 +R 2 +D 4 +R 5 +L 5 +U 2 +D 10 +U 5 +R 6 +U 10 +R 3 +U 13 +R 9 +D 2 +L 4 +R 11 +U 3 +D 6 +R 10 +D 4 +L 1 +U 4 +D 1 +U 12 +D 5 +L 8 +U 3 +R 11 +U 12 +L 11 +R 8 +L 4 +R 12 +D 3 +L 11 +R 1 +L 12 +R 2 +D 10 +R 10 +L 4 +U 4 +D 4 +U 7 +D 6 +L 9 +R 12 +L 7 +D 2 +R 11 +L 5 +D 8 +L 3 +D 1 +L 5 +R 7 +L 10 +U 9 +R 11 +D 13 +L 12 +R 9 +D 1 +L 2 +D 13 +L 5 +R 10 +D 12 +R 10 +L 13 +R 8 +L 5 +R 9 +U 1 +R 3 +D 4 +U 6 +D 2 +L 6 +U 1 +D 8 +U 9 +D 2 +R 9 +D 10 +U 12 +L 14 +U 4 +L 6 +D 3 +U 7 +R 5 +D 13 +R 1 +D 11 +U 10 +L 1 +U 3 +L 9 +U 2 +L 14 +D 14 +L 11 +R 9 +L 12 +R 10 +D 14 +R 3 +D 10 +R 3 +U 3 +D 13 +L 6 +D 5 +L 7 +U 14 +D 7 +U 13 +L 12 +U 13 +R 7 +L 4 +D 8 +R 3 +U 7 +L 1 +D 14 +U 7 +D 12 +U 12 +D 5 +L 3 +U 5 +D 13 +U 12 +L 9 +R 8 +D 8 +R 4 +U 11 +R 10 +D 8 +L 6 +R 7 +D 12 +U 10 +L 10 +D 8 +L 9 +R 11 +D 8 +L 10 +D 14 +L 6 +R 6 +L 10 +R 10 +U 14 +R 4 +U 1 +R 3 +U 11 +L 3 +R 4 +D 11 +U 12 +D 6 +L 5 +R 3 +D 4 +U 4 +D 10 +R 11 +D 10 +L 2 +D 7 +L 6 +D 2 +R 9 +L 1 +R 3 +D 1 +U 10 +D 14 +L 9 +D 8 +U 7 +D 12 +R 2 +U 3 +D 9 +L 5 +D 8 +R 15 +U 6 +L 10 +R 1 +D 3 +U 5 +R 10 +U 5 +L 1 +U 9 +D 9 +R 8 +D 7 +U 1 +R 12 +U 15 +D 2 +U 9 +L 7 +D 11 +R 10 +U 8 +L 8 +D 2 +L 1 +R 2 +L 11 +D 1 +R 8 +D 3 +L 3 +D 15 +R 9 +U 3 +L 13 +U 3 +D 6 +L 7 +R 8 +D 10 +U 6 +R 15 +D 8 +U 1 +D 2 +R 6 +U 2 +R 5 +L 8 +D 12 +U 1 +L 4 +D 1 +R 5 +L 14 +R 9 +L 9 +U 9 +L 11 +U 8 +R 2 +U 4 +D 2 +R 12 +U 13 +D 10 +L 10 +D 5 +L 9 +R 10 +L 10 +R 14 +L 6 +D 8 +R 4 +D 2 +L 11 +R 1 +U 11 +R 9 +L 13 +D 9 +L 14 +R 15 +U 15 +L 6 +U 3 +D 15 +L 5 +D 4 +U 2 +L 4 +D 7 +L 14 +R 2 +L 5 +U 8 +L 3 +U 10 +R 7 +L 12 +U 13 +L 14 +R 3 +U 13 +L 13 +U 16 +D 10 +R 10 +U 8 +L 4 +R 9 +D 4 +L 4 +U 4 +D 10 +L 11 +R 1 +L 11 +U 11 +R 2 +U 11 +R 7 +L 6 +D 6 +U 11 +L 5 +U 8 +R 8 +L 7 +R 11 +D 2 +R 4 +L 16 +U 10 +D 2 +U 2 +R 13 +U 7 +L 2 +R 7 +U 13 +R 3 +L 7 +R 10 +D 10 +L 3 +R 13 +L 10 +U 11 +L 8 +R 14 +U 7 +D 15 +L 9 +R 6 +L 6 +R 16 +D 10 +L 13 +R 5 +L 7 +D 1 +R 3 +D 16 +U 11 +R 16 +L 15 +U 10 +R 6 +D 7 +R 3 +D 4 +L 1 +D 11 +R 14 +U 16 +L 14 +U 11 +L 16 +R 10 +L 10 +U 16 +R 12 +L 6 +U 3 +R 5 +L 10 +U 3 +D 16 +L 15 +U 8 +L 7 +R 12 +L 2 +U 15 +L 1 +D 9 +U 7 +D 8 +L 2 +R 14 +L 9 +D 2 +U 7 +R 2 +D 8 +U 9 +L 4 +D 9 +U 6 +L 13 +D 15 +L 2 +D 15 +L 10 +R 7 +D 10 +L 4 +U 16 +D 7 +R 8 +D 13 +R 4 +L 5 +U 8 +R 15 +U 10 +R 17 +U 8 +L 5 +D 11 +L 2 +U 13 +D 12 +L 3 +U 4 +R 16 +D 4 +L 5 +D 3 +L 16 +R 16 +L 16 +U 10 +L 13 +R 14 +L 7 +U 3 +D 15 +U 11 +D 8 +L 3 +D 3 +U 6 +D 14 +U 1 +L 3 +D 7 +U 14 +R 17 +U 1 +R 16 +U 11 +R 17 +D 10 +R 8 +D 5 +L 14 +R 1 +L 3 +D 17 +R 4 +U 9 +D 1 +U 13 +R 4 +L 3 +U 9 +R 11 +U 5 +R 5 +D 14 +U 12 +L 7 +R 2 +L 15 +D 17 +R 16 +D 3 +L 8 +D 11 +L 1 +U 2 +D 7 +L 11 +R 14 +L 5 +R 17 +U 11 +L 12 +D 14 +L 11 +D 13 +L 12 +R 1 +D 11 +R 2 +L 2 +D 17 +U 5 +R 4 +D 14 +L 14 +D 9 +L 13 +D 12 +R 2 +L 10 +R 7 +U 11 +L 16 +U 12 +R 9 +U 1 +R 17 +U 4 +L 7 +U 1 +L 7 +R 1 +D 5 +L 8 +U 11 +D 4 +U 5 +L 15 +D 3 +L 6 +R 4 +D 1 +R 9 +L 18 +R 6 +L 6 +U 16 +R 16 +D 16 +L 1 +U 13 +R 16 +D 6 +R 15 +U 8 +D 14 +U 5 +D 16 +U 14 +L 13 +R 18 +L 6 +U 5 +R 14 +U 18 +L 10 +D 3 +U 5 +D 15 +R 1 +L 12 +R 1 +L 9 +U 8 +L 14 +U 9 +L 9 +D 5 +R 3 +L 8 +D 18 +L 13 +D 15 +R 15 +U 4 +D 17 +L 17 +U 9 +R 1 +L 13 +R 8 +D 9 +U 15 +L 11 +D 6 +L 14 +D 6 +L 6 +U 8 +D 18 +U 3 +R 1 +L 18 +U 16 +L 11 +D 6 +L 16 +U 13 +R 15 +U 10 +D 4 +L 3 +D 1 +U 1 +L 9 +U 16 +L 8 +R 8 +D 2 +U 13 +R 15 +U 9 +L 7 +D 11 +R 17 +D 8 +U 9 +R 7 +D 7 +R 6 +L 10 +U 5 +L 3 +D 4 +L 1 +U 15 +R 8 +U 17 +L 2 +R 9 +U 15 +D 7 +R 3 +L 10 +U 18 +L 16 +R 15 +L 1 +R 18 +L 8 +D 15 +U 6 +D 11 +R 11 +U 7 +R 9 +L 10 +D 7 +L 7 +U 13 +R 14 +U 9 +D 13 +R 11 +U 17 +D 13 +R 17 +D 19 +L 9 +U 12 +L 16 +D 9 +U 15 +R 5 +D 13 +L 17 +D 3 +R 18 +D 12 +U 9 +D 13 +R 7 +U 18 +R 1 +U 10 +R 11 +U 15 +L 5 +D 15 +R 10 +D 18 +L 8 +U 4 +D 15 +R 11 +U 11 +D 17 +U 2 +R 6 +U 13 +R 8 +D 9 +U 19 +D 8 +U 5 +D 10 +U 18 +L 7 +D 2 +R 13 +D 11 +R 14 +L 14 +R 11 +U 11 +D 13 +L 4 +R 2 +U 18 +L 4 +D 3 +L 15 +U 6 +R 16 +L 13 +D 3 +U 14 +R 5 +U 15 +L 7 +R 5 +U 11 +L 16 +R 5 +L 1 +U 9 +D 7 +R 8 +L 11 +R 6 +L 16 +U 19 +R 2 +D 10 +L 15 +D 7 +U 19 +D 1 +U 5 +L 3 diff --git a/2022/Day10CSharp/Day10CSharp.csproj b/2022/Day10CSharp/Day10CSharp.csproj new file mode 100644 index 0000000..d439800 --- /dev/null +++ b/2022/Day10CSharp/Day10CSharp.csproj @@ -0,0 +1,10 @@ + + + + Exe + net7.0 + enable + enable + + + diff --git a/2022/Day10CSharp/Program.cs b/2022/Day10CSharp/Program.cs new file mode 100644 index 0000000..0e71f4e --- /dev/null +++ b/2022/Day10CSharp/Program.cs @@ -0,0 +1,231 @@ +// See https://aka.ms/new-console-template for more information +Console.WriteLine("Hello, World!"); + +var exampleInstructions01 = Instruction.LoadInstructions("example-input1.txt"); +var exampleInstructions02 = Instruction.LoadInstructions("example-input2.txt"); +var puzzleInstructions = Instruction.LoadInstructions("puzzle-input.txt"); + +// Part 01 +outputSignalStrength(exampleInstructions02, 20, 40); +outputSignalStrength(puzzleInstructions, 20, 40); + +// Part 02 +Console.Write(" === Writing Example Output === "); +renderOnCrt(exampleInstructions02); +Console.WriteLine(); + +Console.WriteLine(); +Console.Write(" === Writing Puzzle Output === "); +renderOnCrt(puzzleInstructions); +Console.WriteLine(); + +bool ShouldDrawSprite(int position, int cycle) +{ + return (position + 0) % 40 == cycle % 40 + || (position - 1) % 40 == cycle % 40 + || (position + 1) % 40 == cycle % 40; +} + +void Draw(int spritePosition, CPU cpu) +{ + if (cpu.Cycle % 40 == 0) Console.WriteLine(); + + if (ShouldDrawSprite(spritePosition, cpu.Cycle)) + { + Console.Write('#'); + } + else + { + Console.Write('.'); + } +} + +void renderOnCrt(List instructions) +{ + int spritePosition; + CPU cpu = new CPU(); + + foreach (var i in instructions) + { + spritePosition = cpu.GetRegisterValue('X'); + + if (i.CycleCount() == 1) + { + Draw(spritePosition, cpu); + cpu.Execute(i); + } + else if (i.CycleCount() == 2) + { + Draw(spritePosition, cpu); + cpu.Cycle++; + Draw(spritePosition, cpu); + cpu.Execute(i); + cpu.Cycle--; + } + else throw new InvalidDataException(); + + } + + +} + +void outputSignalStrength(List list, int init, int step) +{ + CPU cpu = new CPU(); + int nextSignal = init; + List strengthList = new List(); + + Console.WriteLine(" === Listing signals ==="); + foreach (var l in list) + { + int oldValue = cpu.GetRegisterValue('X'); + + cpu.Execute(l); + + if (cpu.Cycle >= nextSignal) + { + int strength = nextSignal * oldValue; + + Console.WriteLine(String.Format("Cycle({0}): SignalStrength({1})", nextSignal, strength)); + strengthList.Add(strength); + nextSignal += step; + } + } + + int strengthSum = 0; + foreach (var s in strengthList) + { + strengthSum += s; + } + Console.WriteLine("Strength Sum: " + strengthSum); + Console.WriteLine(); +} + +class CPU +{ + public int Cycle + { + get; set; + } + private int registerX; + + public CPU() + { + Cycle = 0; + registerX = 1; + } + + public int GetRegisterValue(char registerName) + { + switch (registerName) + { + case 'X': + return registerX; + default: + throw new ArgumentException(); + } + } + + public void SetRegisterValue(char registerName, int value) + { + switch (registerName) + { + case 'X': + registerX = value; + break; + default: throw new ArgumentException(); + } + } + + public void Execute(Instruction i) + { + i.Execute(this); + } +} + +abstract class Instruction +{ + public virtual void Execute(CPU cpu, params int[] list) + { + cpu.Cycle += CycleCount(); + } + + public abstract int CycleCount(); + + static Instruction ParseInstruction(string line) + { + if (line.StartsWith("noop")) + { + return new NoopInstruction(); + } + if (line.StartsWith("addx")) + { + var split = line.Split(' '); + + return new AddInstruction('X', Int32.Parse(split[1])); + } + + throw new InvalidDataException(); + } + + public static List LoadInstructions(string filename) + { + List list = new List(); + + using (StreamReader reader = System.IO.File.OpenText(filename)) + { + while (!reader.EndOfStream) + { + string? line = reader.ReadLine(); + if (line == null) throw new InvalidDataException(); + + list.Add(ParseInstruction(line)); + } + } + + return list; + } +} + +class NoopInstruction : Instruction +{ + public override void Execute(CPU cpu, params int[] list) + { + base.Execute(cpu, list); + } + + public override int CycleCount() + { + return 1; + } +} + +class AddInstruction : Instruction +{ + public AddInstruction(char register, int value) + { + Value = value; + Register = register; + } + public int Value + { + get; set; + } + + public char Register + { + get; set; + } + + public override void Execute(CPU cpu, params int[] list) + { + base.Execute(cpu, list); + + cpu.SetRegisterValue(Register, cpu.GetRegisterValue(Register) + Value); + } + + public override int CycleCount() + { + return 2; + } +} \ No newline at end of file diff --git a/2022/Day10CSharp/Properties/launchSettings.json b/2022/Day10CSharp/Properties/launchSettings.json new file mode 100644 index 0000000..d7a56d9 --- /dev/null +++ b/2022/Day10CSharp/Properties/launchSettings.json @@ -0,0 +1,8 @@ +{ + "profiles": { + "Day10CSharp": { + "commandName": "Project", + "workingDirectory": "C:\\dev\\DevSandbox\\AdventOfCode\\2022\\Day10CSharp" + } + } +} \ No newline at end of file diff --git a/2022/Day10CSharp/example-input1.txt b/2022/Day10CSharp/example-input1.txt new file mode 100644 index 0000000..65e6fc3 --- /dev/null +++ b/2022/Day10CSharp/example-input1.txt @@ -0,0 +1,3 @@ +noop +addx 3 +addx -5 \ No newline at end of file diff --git a/2022/Day10CSharp/example-input2.txt b/2022/Day10CSharp/example-input2.txt new file mode 100644 index 0000000..37294ac --- /dev/null +++ b/2022/Day10CSharp/example-input2.txt @@ -0,0 +1,146 @@ +addx 15 +addx -11 +addx 6 +addx -3 +addx 5 +addx -1 +addx -8 +addx 13 +addx 4 +noop +addx -1 +addx 5 +addx -1 +addx 5 +addx -1 +addx 5 +addx -1 +addx 5 +addx -1 +addx -35 +addx 1 +addx 24 +addx -19 +addx 1 +addx 16 +addx -11 +noop +noop +addx 21 +addx -15 +noop +noop +addx -3 +addx 9 +addx 1 +addx -3 +addx 8 +addx 1 +addx 5 +noop +noop +noop +noop +noop +addx -36 +noop +addx 1 +addx 7 +noop +noop +noop +addx 2 +addx 6 +noop +noop +noop +noop +noop +addx 1 +noop +noop +addx 7 +addx 1 +noop +addx -13 +addx 13 +addx 7 +noop +addx 1 +addx -33 +noop +noop +noop +addx 2 +noop +noop +noop +addx 8 +noop +addx -1 +addx 2 +addx 1 +noop +addx 17 +addx -9 +addx 1 +addx 1 +addx -3 +addx 11 +noop +noop +addx 1 +noop +addx 1 +noop +noop +addx -13 +addx -19 +addx 1 +addx 3 +addx 26 +addx -30 +addx 12 +addx -1 +addx 3 +addx 1 +noop +noop +noop +addx -9 +addx 18 +addx 1 +addx 2 +noop +noop +addx 9 +noop +noop +noop +addx -1 +addx 2 +addx -37 +addx 1 +addx 3 +noop +addx 15 +addx -21 +addx 22 +addx -6 +addx 1 +noop +addx 2 +addx 1 +noop +addx -10 +noop +noop +addx 20 +addx 1 +addx 2 +addx 2 +addx -6 +addx -11 +noop +noop +noop \ No newline at end of file diff --git a/2022/Day10CSharp/problem.txt b/2022/Day10CSharp/problem.txt new file mode 100644 index 0000000..6411eb3 --- /dev/null +++ b/2022/Day10CSharp/problem.txt @@ -0,0 +1,321 @@ +--- Day 10: Cathode-Ray Tube --- + +You avoid the ropes, plunge into the river, and swim to shore. + +The Elves yell something about meeting back up with them upriver, but the river is too loud to tell exactly what they're saying. They finish crossing the bridge and disappear from view. + +Situations like this must be why the Elves prioritized getting the communication system on your handheld device working. You pull it out of your pack, but the amount of water slowly draining from a big crack in its screen tells you it probably won't be of much immediate use. + +Unless, that is, you can design a replacement for the device's video system! It seems to be some kind of cathode-ray tube screen and simple CPU that are both driven by a precise clock circuit. The clock circuit ticks at a constant rate; each tick is called a cycle. + +Start by figuring out the signal being sent by the CPU. The CPU has a single register, X, which starts with the value 1. It supports only two instructions: + + addx V takes two cycles to complete. After two cycles, the X register is increased by the value V. (V can be negative.) + noop takes one cycle to complete. It has no other effect. + +The CPU uses these instructions in a program (your puzzle input) to, somehow, tell the screen what to draw. + +Consider the following small program: + +noop +addx 3 +addx -5 + +Execution of this program proceeds as follows: + + At the start of the first cycle, the noop instruction begins execution. During the first cycle, X is 1. After the first cycle, the noop instruction finishes execution, doing nothing. + At the start of the second cycle, the addx 3 instruction begins execution. During the second cycle, X is still 1. + During the third cycle, X is still 1. After the third cycle, the addx 3 instruction finishes execution, setting X to 4. + At the start of the fourth cycle, the addx -5 instruction begins execution. During the fourth cycle, X is still 4. + During the fifth cycle, X is still 4. After the fifth cycle, the addx -5 instruction finishes execution, setting X to -1. + +Maybe you can learn something by looking at the value of the X register throughout execution. For now, consider the signal strength (the cycle number multiplied by the value of the X register) during the 20th cycle and every 40 cycles after that (that is, during the 20th, 60th, 100th, 140th, 180th, and 220th cycles). + +For example, consider this larger program: + +addx 15 +addx -11 +addx 6 +addx -3 +addx 5 +addx -1 +addx -8 +addx 13 +addx 4 +noop +addx -1 +addx 5 +addx -1 +addx 5 +addx -1 +addx 5 +addx -1 +addx 5 +addx -1 +addx -35 +addx 1 +addx 24 +addx -19 +addx 1 +addx 16 +addx -11 +noop +noop +addx 21 +addx -15 +noop +noop +addx -3 +addx 9 +addx 1 +addx -3 +addx 8 +addx 1 +addx 5 +noop +noop +noop +noop +noop +addx -36 +noop +addx 1 +addx 7 +noop +noop +noop +addx 2 +addx 6 +noop +noop +noop +noop +noop +addx 1 +noop +noop +addx 7 +addx 1 +noop +addx -13 +addx 13 +addx 7 +noop +addx 1 +addx -33 +noop +noop +noop +addx 2 +noop +noop +noop +addx 8 +noop +addx -1 +addx 2 +addx 1 +noop +addx 17 +addx -9 +addx 1 +addx 1 +addx -3 +addx 11 +noop +noop +addx 1 +noop +addx 1 +noop +noop +addx -13 +addx -19 +addx 1 +addx 3 +addx 26 +addx -30 +addx 12 +addx -1 +addx 3 +addx 1 +noop +noop +noop +addx -9 +addx 18 +addx 1 +addx 2 +noop +noop +addx 9 +noop +noop +noop +addx -1 +addx 2 +addx -37 +addx 1 +addx 3 +noop +addx 15 +addx -21 +addx 22 +addx -6 +addx 1 +noop +addx 2 +addx 1 +noop +addx -10 +noop +noop +addx 20 +addx 1 +addx 2 +addx 2 +addx -6 +addx -11 +noop +noop +noop + +The interesting signal strengths can be determined as follows: + + During the 20th cycle, register X has the value 21, so the signal strength is 20 * 21 = 420. (The 20th cycle occurs in the middle of the second addx -1, so the value of register X is the starting value, 1, plus all of the other addx values up to that point: 1 + 15 - 11 + 6 - 3 + 5 - 1 - 8 + 13 + 4 = 21.) + During the 60th cycle, register X has the value 19, so the signal strength is 60 * 19 = 1140. + During the 100th cycle, register X has the value 18, so the signal strength is 100 * 18 = 1800. + During the 140th cycle, register X has the value 21, so the signal strength is 140 * 21 = 2940. + During the 180th cycle, register X has the value 16, so the signal strength is 180 * 16 = 2880. + During the 220th cycle, register X has the value 18, so the signal strength is 220 * 18 = 3960. + +The sum of these signal strengths is 13140. + +Find the signal strength during the 20th, 60th, 100th, 140th, 180th, and 220th cycles. What is the sum of these six signal strengths? + +--- Part Two --- + +It seems like the X register controls the horizontal position of a sprite. Specifically, the sprite is 3 pixels wide, and the X register sets the horizontal position of the middle of that sprite. (In this system, there is no such thing as "vertical position": if the sprite's horizontal position puts its pixels where the CRT is currently drawing, then those pixels will be drawn.) + +You count the pixels on the CRT: 40 wide and 6 high. This CRT screen draws the top row of pixels left-to-right, then the row below that, and so on. The left-most pixel in each row is in position 0, and the right-most pixel in each row is in position 39. + +Like the CPU, the CRT is tied closely to the clock circuit: the CRT draws a single pixel during each cycle. Representing each pixel of the screen as a #, here are the cycles during which the first and last pixel in each row are drawn: + +Cycle 1 -> ######################################## <- Cycle 40 +Cycle 41 -> ######################################## <- Cycle 80 +Cycle 81 -> ######################################## <- Cycle 120 +Cycle 121 -> ######################################## <- Cycle 160 +Cycle 161 -> ######################################## <- Cycle 200 +Cycle 201 -> ######################################## <- Cycle 240 + +So, by carefully timing the CPU instructions and the CRT drawing operations, you should be able to determine whether the sprite is visible the instant each pixel is drawn. If the sprite is positioned such that one of its three pixels is the pixel currently being drawn, the screen produces a lit pixel (#); otherwise, the screen leaves the pixel dark (.). + +The first few pixels from the larger example above are drawn as follows: + +Sprite position: ###..................................... + +Start cycle 1: begin executing addx 15 +During cycle 1: CRT draws pixel in position 0 +Current CRT row: # + +During cycle 2: CRT draws pixel in position 1 +Current CRT row: ## +End of cycle 2: finish executing addx 15 (Register X is now 16) +Sprite position: ...............###...................... + +Start cycle 3: begin executing addx -11 +During cycle 3: CRT draws pixel in position 2 +Current CRT row: ##. + +During cycle 4: CRT draws pixel in position 3 +Current CRT row: ##.. +End of cycle 4: finish executing addx -11 (Register X is now 5) +Sprite position: ....###................................. + +Start cycle 5: begin executing addx 6 +During cycle 5: CRT draws pixel in position 4 +Current CRT row: ##..# + +During cycle 6: CRT draws pixel in position 5 +Current CRT row: ##..## +End of cycle 6: finish executing addx 6 (Register X is now 11) +Sprite position: ..........###........................... + +Start cycle 7: begin executing addx -3 +During cycle 7: CRT draws pixel in position 6 +Current CRT row: ##..##. + +During cycle 8: CRT draws pixel in position 7 +Current CRT row: ##..##.. +End of cycle 8: finish executing addx -3 (Register X is now 8) +Sprite position: .......###.............................. + +Start cycle 9: begin executing addx 5 +During cycle 9: CRT draws pixel in position 8 +Current CRT row: ##..##..# + +During cycle 10: CRT draws pixel in position 9 +Current CRT row: ##..##..## +End of cycle 10: finish executing addx 5 (Register X is now 13) +Sprite position: ............###......................... + +Start cycle 11: begin executing addx -1 +During cycle 11: CRT draws pixel in position 10 +Current CRT row: ##..##..##. + +During cycle 12: CRT draws pixel in position 11 +Current CRT row: ##..##..##.. +End of cycle 12: finish executing addx -1 (Register X is now 12) +Sprite position: ...........###.......................... + +Start cycle 13: begin executing addx -8 +During cycle 13: CRT draws pixel in position 12 +Current CRT row: ##..##..##..# + +During cycle 14: CRT draws pixel in position 13 +Current CRT row: ##..##..##..## +End of cycle 14: finish executing addx -8 (Register X is now 4) +Sprite position: ...###.................................. + +Start cycle 15: begin executing addx 13 +During cycle 15: CRT draws pixel in position 14 +Current CRT row: ##..##..##..##. + +During cycle 16: CRT draws pixel in position 15 +Current CRT row: ##..##..##..##.. +End of cycle 16: finish executing addx 13 (Register X is now 17) +Sprite position: ................###..................... + +Start cycle 17: begin executing addx 4 +During cycle 17: CRT draws pixel in position 16 +Current CRT row: ##..##..##..##..# + +During cycle 18: CRT draws pixel in position 17 +Current CRT row: ##..##..##..##..## +End of cycle 18: finish executing addx 4 (Register X is now 21) +Sprite position: ....................###................. + +Start cycle 19: begin executing noop +During cycle 19: CRT draws pixel in position 18 +Current CRT row: ##..##..##..##..##. +End of cycle 19: finish executing noop + +Start cycle 20: begin executing addx -1 +During cycle 20: CRT draws pixel in position 19 +Current CRT row: ##..##..##..##..##.. + +During cycle 21: CRT draws pixel in position 20 +Current CRT row: ##..##..##..##..##..# +End of cycle 21: finish executing addx -1 (Register X is now 20) +Sprite position: ...................###.................. + +Allowing the program to run to completion causes the CRT to produce the following image: + +##..##..##..##..##..##..##..##..##..##.. +###...###...###...###...###...###...###. +####....####....####....####....####.... +#####.....#####.....#####.....#####..... +######......######......######......#### +#######.......#######.......#######..... + +Render the image given by your program. What eight capital letters appear on your CRT? diff --git a/2022/Day10CSharp/puzzle-input.txt b/2022/Day10CSharp/puzzle-input.txt new file mode 100644 index 0000000..af9f457 --- /dev/null +++ b/2022/Day10CSharp/puzzle-input.txt @@ -0,0 +1,137 @@ +noop +addx 22 +addx -17 +addx 1 +addx 4 +addx 17 +addx -16 +addx 4 +addx 1 +addx 21 +addx -17 +addx -10 +noop +addx 17 +addx -1 +addx 5 +addx -1 +noop +addx 4 +addx 1 +noop +addx -37 +addx 5 +addx 27 +addx -22 +addx -2 +addx 2 +addx 5 +addx 2 +addx 5 +noop +noop +addx -2 +addx 5 +addx 16 +addx -11 +addx -2 +addx 2 +addx 5 +addx 2 +addx -8 +addx 9 +addx -38 +addx 5 +addx 20 +addx -16 +addx 8 +addx -5 +addx 1 +addx 4 +noop +noop +addx 5 +addx -2 +noop +noop +addx 18 +noop +addx -8 +addx 2 +addx 7 +addx -2 +noop +noop +noop +noop +noop +addx -35 +noop +addx 32 +addx -26 +addx 12 +addx -8 +addx 3 +noop +addx 2 +addx 16 +addx -24 +addx 11 +addx 3 +addx -17 +addx 17 +addx 5 +addx 2 +addx -15 +addx 22 +addx 3 +noop +addx -40 +noop +addx 2 +noop +addx 3 +addx 13 +addx -6 +addx 10 +addx -9 +addx 2 +addx 22 +addx -15 +addx 8 +addx -7 +addx 2 +addx 5 +addx 2 +addx -32 +addx 33 +addx 2 +addx 5 +addx -39 +addx -1 +addx 3 +addx 4 +addx 1 +addx 4 +addx 21 +addx -20 +addx 2 +addx 12 +addx -4 +noop +noop +noop +noop +noop +addx 4 +noop +noop +noop +addx 6 +addx -27 +addx 31 +noop +noop +noop +noop +noop diff --git a/2022/Day11CSharp/Day11CSharp.csproj b/2022/Day11CSharp/Day11CSharp.csproj new file mode 100644 index 0000000..d439800 --- /dev/null +++ b/2022/Day11CSharp/Day11CSharp.csproj @@ -0,0 +1,10 @@ + + + + Exe + net7.0 + enable + enable + + + diff --git a/2022/Day11CSharp/Program.cs b/2022/Day11CSharp/Program.cs new file mode 100644 index 0000000..01b07ba --- /dev/null +++ b/2022/Day11CSharp/Program.cs @@ -0,0 +1,319 @@ + + +using System; +using System.Numerics; + +Part01(); +Console.WriteLine(); +Part02(); + +void Part01() +{ + Console.WriteLine("!! === Part 1 === !!"); + var exampleMonkeys = Monkey.LoadMonkeys("example-input.txt"); + var puzzleMonkeys = Monkey.LoadMonkeys("puzzle-input.txt"); + + Simulation exampleSim = new Simulation(exampleMonkeys); + Simulation puzzleSim = new Simulation(puzzleMonkeys); + + Console.WriteLine(" === Example ==="); + exampleSim.ProcessRound(20); + exampleSim.PrintMonkeys(); + Console.WriteLine("Monkey business: " + exampleSim.MonkeyBusiness); + + Console.WriteLine(); + + Console.WriteLine(" === Puzzle ==="); + puzzleSim.ProcessRound(20); + puzzleSim.PrintMonkeys(); + Console.WriteLine("Monkey business: " + puzzleSim.MonkeyBusiness); +} + +void Part02() +{ + Console.WriteLine("!! === Part 2 === !!"); + var exampleMonkeys = Monkey.LoadMonkeys("example-input.txt"); + var puzzleMonkeys = Monkey.LoadMonkeys("puzzle-input.txt"); + + Simulation exampleSim = new Simulation(exampleMonkeys); + Simulation puzzleSim = new Simulation(puzzleMonkeys); + + Console.WriteLine(" === Example ==="); + exampleSim.ProcessRound(10000, false, true); + exampleSim.PrintMonkeys(); + Console.WriteLine("Monkey business: " + exampleSim.MonkeyBusiness); + + Console.WriteLine(); + + Console.WriteLine(" === Puzzle ==="); + puzzleSim.ProcessRound(10000, false, true); + puzzleSim.PrintMonkeys(); + Console.WriteLine("Monkey business: " + puzzleSim.MonkeyBusiness); +} + +class Simulation +{ + private List Monkeys { get; set; } + private bool AutoDropWorry { get; set; } + public Simulation(List monkeys) + { + Monkeys = monkeys; + } + + public BigInteger MonkeyBusiness + { + get + { + var list = new List(Monkeys); + list.Sort(); + BigInteger left = list[list.Count - 1].InspectedCount; + BigInteger right = list[list.Count - 2].InspectedCount; + + return left * right; + } + } + + public void ProcessRound(int rounds = 1, bool part01 = true, bool printProgress = false) + { + int mod = Monkeys[0].Test.divisibility; + for (int i = 1 ; i < Monkeys.Count; i++) + { + mod *= Monkeys[i].Test.divisibility; + } + + if (printProgress) + { + Console.Write("Processing: "); + Console.Out.Flush(); + + } + + for (int round = 0; round < rounds; round++) + { + if (printProgress && round % 100 == 0) + { + Console.Write(String.Format("{0}%..", (float)round / rounds * 100)); + Console.Out.Flush(); + } + foreach (Monkey m in Monkeys) + { + var oldItemList = m.Items; + m.Items = new List(); + m.InspectedCount += oldItemList.Count; + + foreach (var item in oldItemList) + { + var i = item; + + // Worry operation + i = m.Operation.GetNewValue(i); + + // Bored + if (part01) i /= 3; + else i = i % mod; + + // Test + int dest = m.Test.DoTest(i); + Monkeys[dest].Items.Add(i); + } + } + } + if (printProgress) Console.WriteLine("..Done!"); + } + + public void PrintMonkeys() + { + for (int i = 0; i < Monkeys.Count; i++) + { + Console.Write(String.Format("Monkey {0} Inspected({1}), Items: ", i, Monkeys[i].InspectedCount)); + + bool first = true; + foreach (var item in Monkeys[i].Items) + { + if (!first) + { + Console.Write(", "); + } + first = false; + Console.Write(item); + } + + Console.WriteLine(); + } + } +} + +class Operation +{ + public Operation(char op, string value) + { + this.op = op; + this.value = value; + } + + public BigInteger GetNewValue(BigInteger worryLevel) + { + BigInteger realVal; + + if (!BigInteger.TryParse(value, out realVal)) + { + realVal = worryLevel; + } + + switch (op) + { + case '+': + return worryLevel + realVal; + case '-': + return worryLevel - realVal; + case '*': + return worryLevel * realVal; + case '/': + return worryLevel / realVal; + default: + throw new InvalidDataException(); + } + } + + public static Operation Parse(string line) + { + if (!line.Trim().StartsWith("Operation:")) + throw new InvalidDataException(); + + var split = line.Split('=')[1].Split(' ', StringSplitOptions.RemoveEmptyEntries); + + char op = split[1][0]; + string value = split[2]; + + return new Operation(op, value); + } + + private char op; + private string value; +} + +class Test +{ + public Test(string[] line) + { + if (line.Length != 3) + { + throw new InvalidDataException(); + } + + string[] split; + + // Get the divis by val + split = line[0].Split(' '); + divisibility = Int32.Parse(split[split.Length - 1]); + + // True + split = line[1].Split(' '); + trueMonkeyTarget = Int32.Parse(split[split.Length - 1]); + + // False + split = line[2].Split(' '); + falseMonkeyTarget = Int32.Parse(split[split.Length - 1]); + } + + public int divisibility { get; set; } + private int trueMonkeyTarget { get; set; } + private int falseMonkeyTarget { get; set; } + + public int DoTest(BigInteger worryLevel) + { + if (worryLevel % divisibility == 0) + { + return trueMonkeyTarget; + } + else + { + return falseMonkeyTarget; + } + } +} + +class Monkey : IComparable +{ + public List Items { get; set; } = new List(); + + public Operation Operation { get; set; } + + public Test Test { get; set; } + + public int InspectedCount { get; set; } = 0; + + public Monkey(string[] lines) + { + for (int i = 0; i < lines.Length; i++) + { + string line = lines[i]; + + if (line.Trim().StartsWith("Operation:")) + { + Operation = Operation.Parse(line); + } + else if (line.Trim().StartsWith("Starting items:")) + { + var entries = line.Split(':')[1].Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries); + foreach (var entry in entries) + { + int val = int.Parse(entry); + Items.Add(val); + } + } + else if (line.Trim().StartsWith("Test:")) + { + string[] testLines = new string[3]; + testLines[0] = line; + testLines[1] = lines[i+1]; + testLines[2] = lines[i+2]; + + Test = new Test(testLines); + } + } + + if (Operation == null || Test == null) throw new InvalidDataException(); + } + + public static List LoadMonkeys(string filename) + { + List monkeys = new List(); + + using (StreamReader reader = System.IO.File.OpenText(filename)) + { + while (!reader.EndOfStream) + { + string? line = reader.ReadLine(); + if (line == null) throw new InvalidDataException(); + + if (line.StartsWith("Monkey")) + { + string[] lines = new string[5]; + for (int i = 0; i < lines.Length; i++) + { + string? newLine = reader.ReadLine(); + if (newLine == null) throw new InvalidDataException(); + lines[i] = newLine; + } + monkeys.Add(new Monkey(lines)); + } + } + } + + return monkeys; + } + + public int CompareTo(object? obj) + { + if (obj == null) throw new InvalidDataException(); + + Monkey Temp = (Monkey)obj; + if (this.InspectedCount < Temp.InspectedCount) + return -1; + if (this.InspectedCount > Temp.InspectedCount) + return 1; + else + return 0; + } +} diff --git a/2022/Day11CSharp/Properties/launchSettings.json b/2022/Day11CSharp/Properties/launchSettings.json new file mode 100644 index 0000000..1ae1e1a --- /dev/null +++ b/2022/Day11CSharp/Properties/launchSettings.json @@ -0,0 +1,8 @@ +{ + "profiles": { + "Day11CSharp": { + "commandName": "Project", + "workingDirectory": "C:\\dev\\DevSandbox\\AdventOfCode\\2022\\Day11CSharp" + } + } +} \ No newline at end of file diff --git a/2022/Day11CSharp/example-input.txt b/2022/Day11CSharp/example-input.txt new file mode 100644 index 0000000..aa6f21a --- /dev/null +++ b/2022/Day11CSharp/example-input.txt @@ -0,0 +1,27 @@ +Monkey 0: + Starting items: 79, 98 + Operation: new = old * 19 + Test: divisible by 23 + If true: throw to monkey 2 + If false: throw to monkey 3 + +Monkey 1: + Starting items: 54, 65, 75, 74 + Operation: new = old + 6 + Test: divisible by 19 + If true: throw to monkey 2 + If false: throw to monkey 0 + +Monkey 2: + Starting items: 79, 60, 97 + Operation: new = old * old + Test: divisible by 13 + If true: throw to monkey 1 + If false: throw to monkey 3 + +Monkey 3: + Starting items: 74 + Operation: new = old + 3 + Test: divisible by 17 + If true: throw to monkey 0 + If false: throw to monkey 1 \ No newline at end of file diff --git a/2022/Day11CSharp/problem.txt b/2022/Day11CSharp/problem.txt new file mode 100644 index 0000000..abf234b --- /dev/null +++ b/2022/Day11CSharp/problem.txt @@ -0,0 +1,307 @@ +--- Day 11: Monkey in the Middle --- + +As you finally start making your way upriver, you realize your pack is much lighter than you remember. Just then, one of the items from your pack goes flying overhead. Monkeys are playing Keep Away with your missing things! + +To get your stuff back, you need to be able to predict where the monkeys will throw your items. After some careful observation, you realize the monkeys operate based on how worried you are about each item. + +You take some notes (your puzzle input) on the items each monkey currently has, how worried you are about those items, and how the monkey makes decisions based on your worry level. For example: + +Monkey 0: + Starting items: 79, 98 + Operation: new = old * 19 + Test: divisible by 23 + If true: throw to monkey 2 + If false: throw to monkey 3 + +Monkey 1: + Starting items: 54, 65, 75, 74 + Operation: new = old + 6 + Test: divisible by 19 + If true: throw to monkey 2 + If false: throw to monkey 0 + +Monkey 2: + Starting items: 79, 60, 97 + Operation: new = old * old + Test: divisible by 13 + If true: throw to monkey 1 + If false: throw to monkey 3 + +Monkey 3: + Starting items: 74 + Operation: new = old + 3 + Test: divisible by 17 + If true: throw to monkey 0 + If false: throw to monkey 1 + +Each monkey has several attributes: + + Starting items lists your worry level for each item the monkey is currently holding in the order they will be inspected. + Operation shows how your worry level changes as that monkey inspects an item. (An operation like new = old * 5 means that your worry level after the monkey inspected the item is five times whatever your worry level was before inspection.) + Test shows how the monkey uses your worry level to decide where to throw an item next. + If true shows what happens with an item if the Test was true. + If false shows what happens with an item if the Test was false. + +After each monkey inspects an item but before it tests your worry level, your relief that the monkey's inspection didn't damage the item causes your worry level to be divided by three and rounded down to the nearest integer. + +The monkeys take turns inspecting and throwing items. On a single monkey's turn, it inspects and throws all of the items it is holding one at a time and in the order listed. Monkey 0 goes first, then monkey 1, and so on until each monkey has had one turn. The process of each monkey taking a single turn is called a round. + +When a monkey throws an item to another monkey, the item goes on the end of the recipient monkey's list. A monkey that starts a round with no items could end up inspecting and throwing many items by the time its turn comes around. If a monkey is holding no items at the start of its turn, its turn ends. + +In the above example, the first round proceeds as follows: + +Monkey 0: + Monkey inspects an item with a worry level of 79. + Worry level is multiplied by 19 to 1501. + Monkey gets bored with item. Worry level is divided by 3 to 500. + Current worry level is not divisible by 23. + Item with worry level 500 is thrown to monkey 3. + Monkey inspects an item with a worry level of 98. + Worry level is multiplied by 19 to 1862. + Monkey gets bored with item. Worry level is divided by 3 to 620. + Current worry level is not divisible by 23. + Item with worry level 620 is thrown to monkey 3. +Monkey 1: + Monkey inspects an item with a worry level of 54. + Worry level increases by 6 to 60. + Monkey gets bored with item. Worry level is divided by 3 to 20. + Current worry level is not divisible by 19. + Item with worry level 20 is thrown to monkey 0. + Monkey inspects an item with a worry level of 65. + Worry level increases by 6 to 71. + Monkey gets bored with item. Worry level is divided by 3 to 23. + Current worry level is not divisible by 19. + Item with worry level 23 is thrown to monkey 0. + Monkey inspects an item with a worry level of 75. + Worry level increases by 6 to 81. + Monkey gets bored with item. Worry level is divided by 3 to 27. + Current worry level is not divisible by 19. + Item with worry level 27 is thrown to monkey 0. + Monkey inspects an item with a worry level of 74. + Worry level increases by 6 to 80. + Monkey gets bored with item. Worry level is divided by 3 to 26. + Current worry level is not divisible by 19. + Item with worry level 26 is thrown to monkey 0. +Monkey 2: + Monkey inspects an item with a worry level of 79. + Worry level is multiplied by itself to 6241. + Monkey gets bored with item. Worry level is divided by 3 to 2080. + Current worry level is divisible by 13. + Item with worry level 2080 is thrown to monkey 1. + Monkey inspects an item with a worry level of 60. + Worry level is multiplied by itself to 3600. + Monkey gets bored with item. Worry level is divided by 3 to 1200. + Current worry level is not divisible by 13. + Item with worry level 1200 is thrown to monkey 3. + Monkey inspects an item with a worry level of 97. + Worry level is multiplied by itself to 9409. + Monkey gets bored with item. Worry level is divided by 3 to 3136. + Current worry level is not divisible by 13. + Item with worry level 3136 is thrown to monkey 3. +Monkey 3: + Monkey inspects an item with a worry level of 74. + Worry level increases by 3 to 77. + Monkey gets bored with item. Worry level is divided by 3 to 25. + Current worry level is not divisible by 17. + Item with worry level 25 is thrown to monkey 1. + Monkey inspects an item with a worry level of 500. + Worry level increases by 3 to 503. + Monkey gets bored with item. Worry level is divided by 3 to 167. + Current worry level is not divisible by 17. + Item with worry level 167 is thrown to monkey 1. + Monkey inspects an item with a worry level of 620. + Worry level increases by 3 to 623. + Monkey gets bored with item. Worry level is divided by 3 to 207. + Current worry level is not divisible by 17. + Item with worry level 207 is thrown to monkey 1. + Monkey inspects an item with a worry level of 1200. + Worry level increases by 3 to 1203. + Monkey gets bored with item. Worry level is divided by 3 to 401. + Current worry level is not divisible by 17. + Item with worry level 401 is thrown to monkey 1. + Monkey inspects an item with a worry level of 3136. + Worry level increases by 3 to 3139. + Monkey gets bored with item. Worry level is divided by 3 to 1046. + Current worry level is not divisible by 17. + Item with worry level 1046 is thrown to monkey 1. + +After round 1, the monkeys are holding items with these worry levels: + +Monkey 0: 20, 23, 27, 26 +Monkey 1: 2080, 25, 167, 207, 401, 1046 +Monkey 2: +Monkey 3: + +Monkeys 2 and 3 aren't holding any items at the end of the round; they both inspected items during the round and threw them all before the round ended. + +This process continues for a few more rounds: + +After round 2, the monkeys are holding items with these worry levels: +Monkey 0: 695, 10, 71, 135, 350 +Monkey 1: 43, 49, 58, 55, 362 +Monkey 2: +Monkey 3: + +After round 3, the monkeys are holding items with these worry levels: +Monkey 0: 16, 18, 21, 20, 122 +Monkey 1: 1468, 22, 150, 286, 739 +Monkey 2: +Monkey 3: + +After round 4, the monkeys are holding items with these worry levels: +Monkey 0: 491, 9, 52, 97, 248, 34 +Monkey 1: 39, 45, 43, 258 +Monkey 2: +Monkey 3: + +After round 5, the monkeys are holding items with these worry levels: +Monkey 0: 15, 17, 16, 88, 1037 +Monkey 1: 20, 110, 205, 524, 72 +Monkey 2: +Monkey 3: + +After round 6, the monkeys are holding items with these worry levels: +Monkey 0: 8, 70, 176, 26, 34 +Monkey 1: 481, 32, 36, 186, 2190 +Monkey 2: +Monkey 3: + +After round 7, the monkeys are holding items with these worry levels: +Monkey 0: 162, 12, 14, 64, 732, 17 +Monkey 1: 148, 372, 55, 72 +Monkey 2: +Monkey 3: + +After round 8, the monkeys are holding items with these worry levels: +Monkey 0: 51, 126, 20, 26, 136 +Monkey 1: 343, 26, 30, 1546, 36 +Monkey 2: +Monkey 3: + +After round 9, the monkeys are holding items with these worry levels: +Monkey 0: 116, 10, 12, 517, 14 +Monkey 1: 108, 267, 43, 55, 288 +Monkey 2: +Monkey 3: + +After round 10, the monkeys are holding items with these worry levels: +Monkey 0: 91, 16, 20, 98 +Monkey 1: 481, 245, 22, 26, 1092, 30 +Monkey 2: +Monkey 3: + +... + +After round 15, the monkeys are holding items with these worry levels: +Monkey 0: 83, 44, 8, 184, 9, 20, 26, 102 +Monkey 1: 110, 36 +Monkey 2: +Monkey 3: + +... + +After round 20, the monkeys are holding items with these worry levels: +Monkey 0: 10, 12, 14, 26, 34 +Monkey 1: 245, 93, 53, 199, 115 +Monkey 2: +Monkey 3: + +Chasing all of the monkeys at once is impossible; you're going to have to focus on the two most active monkeys if you want any hope of getting your stuff back. Count the total number of times each monkey inspects items over 20 rounds: + +Monkey 0 inspected items 101 times. +Monkey 1 inspected items 95 times. +Monkey 2 inspected items 7 times. +Monkey 3 inspected items 105 times. + +In this example, the two most active monkeys inspected items 101 and 105 times. The level of monkey business in this situation can be found by multiplying these together: 10605. + +Figure out which monkeys to chase by counting how many items they inspect over 20 rounds. What is the level of monkey business after 20 rounds of stuff-slinging simian shenanigans? + +Your puzzle answer was 57838. + +The first half of this puzzle is complete! It provides one gold star: * +--- Part Two --- + +You're worried you might not ever get your items back. So worried, in fact, that your relief that a monkey's inspection didn't damage an item no longer causes your worry level to be divided by three. + +Unfortunately, that relief was all that was keeping your worry levels from reaching ridiculous levels. You'll need to find another way to keep your worry levels manageable. + +At this rate, you might be putting up with these monkeys for a very long time - possibly 10000 rounds! + +With these new rules, you can still figure out the monkey business after 10000 rounds. Using the same example above: + +== After round 1 == +Monkey 0 inspected items 2 times. +Monkey 1 inspected items 4 times. +Monkey 2 inspected items 3 times. +Monkey 3 inspected items 6 times. + +== After round 20 == +Monkey 0 inspected items 99 times. +Monkey 1 inspected items 97 times. +Monkey 2 inspected items 8 times. +Monkey 3 inspected items 103 times. + +== After round 1000 == +Monkey 0 inspected items 5204 times. +Monkey 1 inspected items 4792 times. +Monkey 2 inspected items 199 times. +Monkey 3 inspected items 5192 times. + +== After round 2000 == +Monkey 0 inspected items 10419 times. +Monkey 1 inspected items 9577 times. +Monkey 2 inspected items 392 times. +Monkey 3 inspected items 10391 times. + +== After round 3000 == +Monkey 0 inspected items 15638 times. +Monkey 1 inspected items 14358 times. +Monkey 2 inspected items 587 times. +Monkey 3 inspected items 15593 times. + +== After round 4000 == +Monkey 0 inspected items 20858 times. +Monkey 1 inspected items 19138 times. +Monkey 2 inspected items 780 times. +Monkey 3 inspected items 20797 times. + +== After round 5000 == +Monkey 0 inspected items 26075 times. +Monkey 1 inspected items 23921 times. +Monkey 2 inspected items 974 times. +Monkey 3 inspected items 26000 times. + +== After round 6000 == +Monkey 0 inspected items 31294 times. +Monkey 1 inspected items 28702 times. +Monkey 2 inspected items 1165 times. +Monkey 3 inspected items 31204 times. + +== After round 7000 == +Monkey 0 inspected items 36508 times. +Monkey 1 inspected items 33488 times. +Monkey 2 inspected items 1360 times. +Monkey 3 inspected items 36400 times. + +== After round 8000 == +Monkey 0 inspected items 41728 times. +Monkey 1 inspected items 38268 times. +Monkey 2 inspected items 1553 times. +Monkey 3 inspected items 41606 times. + +== After round 9000 == +Monkey 0 inspected items 46945 times. +Monkey 1 inspected items 43051 times. +Monkey 2 inspected items 1746 times. +Monkey 3 inspected items 46807 times. + +== After round 10000 == +Monkey 0 inspected items 52166 times. +Monkey 1 inspected items 47830 times. +Monkey 2 inspected items 1938 times. +Monkey 3 inspected items 52013 times. + +After 10000 rounds, the two most active monkeys inspected items 52166 and 52013 times. Multiplying these together, the level of monkey business in this situation is now 2713310158. + +Worry levels are no longer divided by three after each item is inspected; you'll need to find another way to keep your worry levels manageable. Starting again from the initial state in your puzzle input, what is the level of monkey business after 10000 rounds? diff --git a/2022/Day11CSharp/puzzle-input.txt b/2022/Day11CSharp/puzzle-input.txt new file mode 100644 index 0000000..84597a1 --- /dev/null +++ b/2022/Day11CSharp/puzzle-input.txt @@ -0,0 +1,55 @@ +Monkey 0: + Starting items: 77, 69, 76, 77, 50, 58 + Operation: new = old * 11 + Test: divisible by 5 + If true: throw to monkey 1 + If false: throw to monkey 5 + +Monkey 1: + Starting items: 75, 70, 82, 83, 96, 64, 62 + Operation: new = old + 8 + Test: divisible by 17 + If true: throw to monkey 5 + If false: throw to monkey 6 + +Monkey 2: + Starting items: 53 + Operation: new = old * 3 + Test: divisible by 2 + If true: throw to monkey 0 + If false: throw to monkey 7 + +Monkey 3: + Starting items: 85, 64, 93, 64, 99 + Operation: new = old + 4 + Test: divisible by 7 + If true: throw to monkey 7 + If false: throw to monkey 2 + +Monkey 4: + Starting items: 61, 92, 71 + Operation: new = old * old + Test: divisible by 3 + If true: throw to monkey 2 + If false: throw to monkey 3 + +Monkey 5: + Starting items: 79, 73, 50, 90 + Operation: new = old + 2 + Test: divisible by 11 + If true: throw to monkey 4 + If false: throw to monkey 6 + +Monkey 6: + Starting items: 50, 89 + Operation: new = old + 3 + Test: divisible by 13 + If true: throw to monkey 4 + If false: throw to monkey 3 + +Monkey 7: + Starting items: 83, 56, 64, 58, 93, 91, 56, 65 + Operation: new = old + 5 + Test: divisible by 19 + If true: throw to monkey 1 + If false: throw to monkey 0 \ No newline at end of file diff --git a/2022/Day12CSharp/Day12CSharp.csproj b/2022/Day12CSharp/Day12CSharp.csproj new file mode 100644 index 0000000..d439800 --- /dev/null +++ b/2022/Day12CSharp/Day12CSharp.csproj @@ -0,0 +1,10 @@ + + + + Exe + net7.0 + enable + enable + + + diff --git a/2022/Day12CSharp/Program.cs b/2022/Day12CSharp/Program.cs new file mode 100644 index 0000000..d5a25f4 --- /dev/null +++ b/2022/Day12CSharp/Program.cs @@ -0,0 +1,279 @@ +// See https://aka.ms/new-console-template for more information +using System.Runtime.CompilerServices; + +Part01(); +Part02(); + +void Part01() +{ + Console.WriteLine("!! === Part 1 === !!"); + + Console.WriteLine(" === Example ==="); + Tuple exampleStart, exampleEnd; + var exampleHeightMap = HeightMap.LoadHeightMap("example-input.txt", out exampleStart, out exampleEnd); + var exampleGraph = exampleHeightMap.ToGraph(); + exampleGraph.PrintShortestPath(exampleStart, exampleEnd); + + Console.WriteLine(); + + Console.WriteLine(" === Puzzle ==="); + Tuple puzzleStart, puzzleEnd; + var puzzleHeightMap = HeightMap.LoadHeightMap("puzzle-input.txt", out puzzleStart, out puzzleEnd); + var puzzleGraph = puzzleHeightMap.ToGraph(); + puzzleGraph.PrintShortestPath(puzzleStart, puzzleEnd); +} + +void Part02() +{ + Console.WriteLine("!! === Part 2 === !!"); + + Console.WriteLine(" === Example ==="); + Tuple exampleStart, exampleEnd; + var exampleHeightMap = HeightMap.LoadHeightMap("example-input.txt", out exampleStart, out exampleEnd); + var exampleGraph = exampleHeightMap.ToGraph(); + Console.WriteLine("Shortest steps from anywhere: {0}", exampleGraph.GetShortestNumberOfStepsAnywhere(0, exampleEnd)); + + Console.WriteLine(); + + Console.WriteLine(" === Puzzle ==="); + Tuple puzzleStart, puzzleEnd; + var puzzleHeightMap = HeightMap.LoadHeightMap("puzzle-input.txt", out puzzleStart, out puzzleEnd); + var puzzleGraph = puzzleHeightMap.ToGraph(); + Console.WriteLine("Shortest steps from anywhere: {0}", puzzleGraph.GetShortestNumberOfStepsAnywhere(0, puzzleEnd)); + +} + +class GraphNode +{ + public int Height { get; set; } + public Tuple Coordinates { get; set; } + + public List AdjacentNodes { get; set; } = new List(); + + public bool Explored { get; set; } + + public GraphNode(int height, Tuple coordinates) + { + Height = height; + Coordinates = coordinates; + } + + public void Reset() + { + Explored = false; + } +} + +class Graph +{ + public Dictionary, GraphNode> Vertices { get; set; } = new Dictionary, GraphNode>(); + + public GraphNode GetAt(Tuple index) + { + return Vertices[index]; + } + + public int GetShortestNumberOfStepsAnywhere(int startingHeight, Tuple end) + { + int minSteps = int.MaxValue; + + foreach (var g in Vertices) + { + if (g.Value.Height == startingHeight) + { + minSteps = Math.Min(minSteps, GetShortestNumberOfSteps(g.Value.Coordinates, end)); + } + } + + return minSteps; + } + + public GraphNode GetAt(int x, int y) + { + return GetAt(new Tuple(x, y)); + } + + public int GetShortestNumberOfSteps(Tuple start, Tuple end) + { + Dictionary, Tuple> path = new Dictionary, Tuple>(); + + BFS(start, end, path); + + return path[end].Item2; + } + + public void PrintShortestPath(Tuple start, Tuple end) + { + Console.WriteLine("Shortest path from ({0},{1}) to ({2},{3}): {4} steps", start.Item1, start.Item2, end.Item1, end.Item2, GetShortestNumberOfSteps(start, end)); + } + + public bool BFS(Tuple start, Tuple end, Dictionary, Tuple> path) + { + Queue queue = new Queue(); + int visited = 0; + + // label all verts as unexplored + foreach (var g in Vertices) + { + g.Value.Reset(); + path.Add(g.Value.Coordinates, new Tuple(null, int.MaxValue)); + } + + // Get the root + GraphNode root = GetAt(start); + + Vertices[root.Coordinates].Explored = true; + path[root.Coordinates] = new Tuple(path[root.Coordinates].Item1, 0); + queue.Enqueue(root); + + while (queue.Count != 0) + { + GraphNode v = queue.Dequeue(); + + // We done if we found it + if (v.Coordinates.Equals(end)) + { + return true; + } + + foreach (var w in v.AdjacentNodes) + { + if (!w.Explored) + { + visited++; + //Console.WriteLine("Visited: ({0},{1}). Count: {2}", w.Coordinates.Item1, w.Coordinates.Item2, visited); + w.Explored = true; + path[w.Coordinates] = new Tuple(v, path[v.Coordinates].Item2 + 1); + queue.Enqueue(w); + } + } + } + + return false; + } +} + +class HeightMap +{ + public Graph ToGraph() + { + Graph graph = new Graph(); + + // Add in all the verts + for (int j = 0; j < heightmap.Count; j++) + { + for (int i = 0; i < heightmap[0].Count; i++) + { + GraphNode gn = new GraphNode(GetHeight(i, j), new Tuple(i, j)); + graph.Vertices.Add(gn.Coordinates, gn); + } + } + + // Create the edges + for (int j = 0; j < heightmap.Count; j++) + { + for (int i = 0; i < heightmap[0].Count; i++) + { + Tuple current = new Tuple(i, j); + Tuple result = new Tuple(0, 0); + + char[] edges = { 'u', 'd', 'l', 'r' }; + + foreach (var edge in edges) + { + if (CanGo(edge, i, j, out result)) + { + graph.Vertices[current].AdjacentNodes.Add(graph.Vertices[result]); + } + } + } + } + + return graph; + } + + private HeightMap() + { + + } + + public int GetHeight(int x, int y) + { + return heightmap[y][x]; + } + + public bool CanGo(char direction, int x, int y, out Tuple newSpot) + { + int currentHeight = GetHeight(x, y); + + switch (direction) + { + case 'u': + newSpot = new Tuple(x, y - 1); + return (y > 0 && currentHeight >= GetHeight(x, y - 1) - 1); + + case 'd': + newSpot = new Tuple(x, y + 1); + return (y < heightmap.Count - 1 && currentHeight >= GetHeight(x, y + 1) - 1); + + case 'l': + newSpot = new Tuple(x - 1, y); + return (x > 0 && currentHeight >= GetHeight(x - 1, y) - 1); + + case 'r': + newSpot = new Tuple(x + 1, y); + return (x < heightmap[0].Count - 1 && currentHeight >= GetHeight(x + 1, y) - 1); + default: + throw new ArgumentException(); + } + } + + private List> heightmap = new List>(); + + public static HeightMap LoadHeightMap(string filename, out Tuple outStartPoint, out Tuple outEndPoint) + { + HeightMap hm = new HeightMap(); + Tuple? startPoint = null; + Tuple? endPoint = null; + + using (StreamReader reader = System.IO.File.OpenText(filename)) + { + while (!reader.EndOfStream) + { + string? line = reader.ReadLine(); + if (line == null) throw new InvalidDataException(); + + List row = new List(); + + foreach (char c in line) + { + if (!char.IsLetter(c)) throw new InvalidDataException(); + + if (c == 'S') + { + row.Add('a' - 'a'); + startPoint = new Tuple(row.Count - 1, hm.heightmap.Count); + } + else if (c == 'E') + { + row.Add('z' - 'a'); + endPoint = new Tuple(row.Count - 1, hm.heightmap.Count); + } + else + { + row.Add(c - 'a'); + } + } + + hm.heightmap.Add(row); + } + } + + + if (startPoint == null || endPoint == null) throw new InvalidDataException(); + outStartPoint = startPoint; + outEndPoint = endPoint; + + return hm; + } +} \ No newline at end of file diff --git a/2022/Day12CSharp/Properties/launchSettings.json b/2022/Day12CSharp/Properties/launchSettings.json new file mode 100644 index 0000000..b1c59fd --- /dev/null +++ b/2022/Day12CSharp/Properties/launchSettings.json @@ -0,0 +1,8 @@ +{ + "profiles": { + "Day12CSharp": { + "commandName": "Project", + "workingDirectory": "C:\\dev\\DevSandbox\\AdventOfCode\\2022\\Day12CSharp" + } + } +} \ No newline at end of file diff --git a/2022/Day12CSharp/example-input.txt b/2022/Day12CSharp/example-input.txt new file mode 100644 index 0000000..361c8cd --- /dev/null +++ b/2022/Day12CSharp/example-input.txt @@ -0,0 +1,5 @@ +Sabqponm +abcryxxl +accszExk +acctuvwj +abdefghi \ No newline at end of file diff --git a/2022/Day12CSharp/problem.txt b/2022/Day12CSharp/problem.txt new file mode 100644 index 0000000..b786c06 --- /dev/null +++ b/2022/Day12CSharp/problem.txt @@ -0,0 +1,57 @@ +--- Day 12: Hill Climbing Algorithm --- + +You try contacting the Elves using your handheld device, but the river you're following must be too low to get a decent signal. + +You ask the device for a heightmap of the surrounding area (your puzzle input). The heightmap shows the local area from above broken into a grid; the elevation of each square of the grid is given by a single lowercase letter, where a is the lowest elevation, b is the next-lowest, and so on up to the highest elevation, z. + +Also included on the heightmap are marks for your current position (S) and the location that should get the best signal (E). Your current position (S) has elevation a, and the location that should get the best signal (E) has elevation z. + +You'd like to reach E, but to save energy, you should do it in as few steps as possible. During each step, you can move exactly one square up, down, left, or right. To avoid needing to get out your climbing gear, the elevation of the destination square can be at most one higher than the elevation of your current square; that is, if your current elevation is m, you could step to elevation n, but not to elevation o. (This also means that the elevation of the destination square can be much lower than the elevation of your current square.) + +For example: + +Sabqponm +abcryxxl +accszExk +acctuvwj +abdefghi + +Here, you start in the top-left corner; your goal is near the middle. You could start by moving down or right, but eventually you'll need to head toward the e at the bottom. From there, you can spiral around to the goal: + +v..v<<<< +>v.vv<<^ +.>vv>E^^ +..v>>>^^ +..>>>>>^ + +In the above diagram, the symbols indicate whether the path exits each square moving up (^), down (v), left (<), or right (>). The location that should get the best signal is still E, and . marks unvisited squares. + +This path reaches the goal in 31 steps, the fewest possible. + +What is the fewest steps required to move from your current position to the location that should get the best signal? + +--- Part Two --- + +As you walk up the hill, you suspect that the Elves will want to turn this into a hiking trail. The beginning isn't very scenic, though; perhaps you can find a better starting point. + +To maximize exercise while hiking, the trail should start as low as possible: elevation a. The goal is still the square marked E. However, the trail should still be direct, taking the fewest steps to reach its goal. So, you'll need to find the shortest path from any square at elevation a to the square marked E. + +Again consider the example from above: + +Sabqponm +abcryxxl +accszExk +acctuvwj +abdefghi + +Now, there are six choices for starting position (five marked a, plus the square marked S that counts as being at elevation a). If you start at the bottom-left square, you can reach the goal most quickly: + +...v<<<< +...vv<<^ +...v>E^^ +.>v>>>^^ +>^>>>>>^ + +This path reaches the goal in only 29 steps, the fewest possible. + +What is the fewest steps required to move starting from any square with elevation a to the location that should get the best signal? diff --git a/2022/Day12CSharp/puzzle-input.txt b/2022/Day12CSharp/puzzle-input.txt new file mode 100644 index 0000000..805e02a --- /dev/null +++ b/2022/Day12CSharp/puzzle-input.txt @@ -0,0 +1,41 @@ +abaaaaaaaaccccccccccccccccccaaaaaccccaaaaaaccccccccccccccccccccccaaaaaaaaaacccccccccccccccccccccccccccccccaaaaaccccccccccccccccccccccccccccccccccccccccccaaaaaa +abaaaaaaaacccccccccccccccccccaaaaaccccaaaacccccaaaacccccccccccccccaaaaaaaaaacccccccccccccccccccccccccccccaaaaaaccccccccccccccccccccccccccccccccccccccccccccaaaa +abccaaaaaaccccccccccccccccccaaaaaaccccaaaaccccaaaaaccccccccccaaaaaaaaaaaaaaacccccccccccccccccccccccccccccaaaacccccccccccccccccccccccccccccaaaccccccccccccccaaaa +abcaaaaaaaccccccccccccccccccaaaaccccccaccaccccaaaaaacccccccccaaaaaaaaaaaaaaacccccccccccccccccccccacccccccccaacccccccccccccccccccccccccccccaaaccccccccccccccaaaa +abccaacccaccccccccccccccccccccaaacccccccccccccaaaaaaccccccccccaaaaaaaaacaaacccccccccccccccccccaaaacccccccccccccccccccccccccaacccccccaaccccaaacccccccccccccaaaaa +abcaaaaaacccccccccccccccccccccccccccccccccccccaaaaaccccccccccaaaaaaaaaaccccaacaaccccccccccccccaaaaaacccccccccccccccccccccccaacccccccaaaacaaaaccccccccccccccaccc +abccaaaaacccccccccccccccccccccccccccccccccccaaccaaacccccccccaaaaaaaaaaaacccaaaaccccccccccccccccaaaaacccccccccccccccaacaaaaaaacccccccaaaaaaaaacccccccccccccccccc +abccaaaaaacccccccccccccccccccccccccccccaaacaaaccccccccccccccaaaaaaaaaaacccaaaaacccccccccccccccaaaaacccccccccccccaaaaaccaaaaaaaaccccccaaaaaalllllllcccaacccccccc +abccaaaaaaccccccaaaaacccccccccaaaccccccaaaaaaaccccccccccccccaaacaaacaaacccaaaaaaccccccccccccccaccaaccccccccccccccaaaaacaaaaaaaaajkkkkkkkkkklllllllccccaaaaacccc +abccaaaaacccccccaaaaacccccccccaaaaccccccaaaaaaccccccccaacaacccccaaacccccccacaaaaccccccccaaaccccccccccccccccccccccaaaaaccaaaaaaajjkkkkkkkkkkllssllllcccaaaaacccc +abcccaaaaccccccaaaaaacccccccccaaaaccccccaaaaaaaaccccccaaaaacccccaaccccccccccaacccccccccaaaacccccccccccccccaaccccaaaaaccaaaaaacjjjjkkkkkkkkssssssslllccaaaaccccc +abcccccccccccccaaaaaacccccccccaaaccccccaaaaaaaaacaaccccaaaaacccccccccccccccaaccccccccccaaaaccccccccccccccaaacccccccaaccaaaaaajjjjrrrrrrsssssssssslllcccaaaccccc +abcccccccccccccaaaaaacccccccccccccccccaaaaaaaaaaaaaaacaaaaaacccccccccccaaacaacccccccccccaaaccccaaacccccaaaaaaaaccccccccaacaaajjjrrrrrrrsssssuusssslmcccaaaacccc +abcccccccccccccccaacccccccccccccccaacaaaacaaaccaaaaaacaaaaccccccccccccccaaaaaccccccccccccccccccaaaaacccaaaaaaaaccccccccccccaajjjrrrruuurssuuuuvsqqmmcddaaaacccc +abccccccccccccccccccccccccccccccccaaaaacccaaacccaaaaccccaaccccccccccccccaaaaaaacccccccccccccccaaaaaaccccaaaaaacccccccccccccccjjrrruuuuuuuuuuuuvvqqmmmdddccccccc +abcccccccccccccccccccccccacccccccccaaaaaccaaacccaaaaccccccccccccccccccccaaaaaaacccccccccccccccaaaaaaccccaaaaaacccccccccaaccccjjjrrtuuuuuuuuyyvvvqqmmmddddcccccc +abccccccccccccccccccccaaaaccccccccaaaaaacccccaacaccacccccccccccccccccccaaaaaaccccccccccccccccccaaaaaccccaaaaaaccccccccaaaccccjjjrrttuxxxuuxyyyvvqqmmmmdddcccccc +abcccccccccaacccccccccaaaaaaccccccaaaaccccccaaaccccccccccccccccccccccccaacaaaccccccccccccccccccaacaaccccaaccaaccccaaaaaaaccccjjjrrtttxxxxxyyyyvvqqqmmmddddccccc +abccccccccaaaacccccccccaaaacccccccccaaccccccaaacaaaccccccccccccccccccaaccccaacccccccccccccccccccccccccccccccccccccaaaaaaaaaacijjqrtttxxxxxyyyvvvqqqqmmmdddccccc +abcccccacaaaaaccccccccaaaaaccccccccccccccaaaaaaaaaacccccccccccccccccaaaccccccccccccccccccccccccccccccccccccccccccccaaaaaaaaaciiiqqqttxxxxxyyyvvvvqqqqmmmdddcccc +SbcccccaaaaaaaaaacccccaacaaccccccccccccccaaaaaaaaaccccccccccccccaaacaaacccccccccccccccccccccccccccccccccccccccccccccaaaaaaaciiiqqqtttxxxEzzyyyyvvvqqqmmmdddcccc +abcccccaaaaaaaaaaccccccccccccaaccccccccccccaaaaaccccccccccccccccaaaaaaaaaacccccccaacccccccccccccaacccccccccccccccccaaaaaaccciiiqqqttxxxxyyyyyyyyvvvqqqmmmeddccc +abcccccccaaaaaacccccccccccaaaaccccccccccaaaaaaaaacccccccaaaacccccaaaaaaaaacccccaaaaccccccccccaacaaaccccccccccccccccaaaaaaaciiiqqqtttxxyyyyyyyyyvvvvqqqnnneeeccc +abcccccccaaaaaacccccccccccaaaaaaccccccccaaaaaaaaaaccccccaaaaccccccaaaaaaaccccccaaaaaaccccccccaaaaacccccccccccccccccaaccaaaciiiqqtttxxxxwwyyywwvvvvrrrnnnneeeccc +abcccccccaaaaaaccccccccccccaaaaacccccccaaaaaaacaaaccccccaaaacccccaaaaaacccccccccaaaaccccccccccaaaaaaccccaaccccccccccccccaaciiqqqtttxxxwwwyywwwwvvrrrrnnneeecccc +abccccccaaaaaaaaccccccccccaaaaaccccccccaaaaaaccccccccccccaaacccccaaaaaaacccccccaaaaaccccccccaaaaaaaaacccaaccccccccccccccccciiqqqtttttwwswwyywwrrrrrrnnnneeecccc +abccccccccccccacccccccccccaccaaccccaaccaaaaaacccccccccccaccccccccaaacaaacccccccaacaaccccccccaaaaacaaaaaaaacccccccccaacccccciiqqqqttssssswwwwwrrrrnnnnnneeeecccc +abcccccccccccccccccccccccccccccaaaaaaccccaacccccccaaacaaacccccccccccccaacaaacccccccccccccccccccaaaccaaaaaaaaccccaacaacccccciiiqqpppsssssswwwwrrrnnnnneeeeeccccc +abcccccccccccccccccccccccccccccaaaaaaaccccccccccccaaaaaaaccccccccccccccccaaacccccccccccccccccccaaaccaaaaaaaaacccaaaaacccccchhhhppppppppssswwwrroonnfeeeeacccccc +abccccccccccccccccccccaaaaaccccaaaaaaaaccccccccccccaaaaaaccccccccccccccaaaaaaaacccccccccccccccccccccaaaaaaaaaccccaaaaaaccccchhhhhpppppppsssssrroonfffeeaaaacccc +abccccccccccccccccccccaaaaacccccaaaaaaaccccccccccccaaaaaaaaccccccccccccaaaaaaaacccccccccccccccccccccaaaaaacccccaaaaaaaacccccchhhhhhhppppsssssrooofffffaaaaacccc +abcccccaacaaacccccccccaaaaaacccaaaaaacccccccccccccaaaaaaaaacccccccccccccaaaaacccccccccccccccccccccccaaaaaaaccccaaaaaccaccccccchhhhhhhhpppssssrooofffcaaaaaccccc +abcccccaaaaaacccccccccaaaaaacccaaaaaaccccccccccccaaaaaaaaaacccccccccccccaaaaaaccccccccccccccccccccccaccaaaccccccacaaaccaacccccccchhhhhgppooooooofffcaaaaacccccc +abcccccaaaaaacccccccccaaaaaaccccccaaacaacccccccccaaacaaaccccccccccaaacccaaaaaaccccccccccccccccccccccccccaaacccccccaaacaaaccccccccccchgggoooooooffffcaaaaaaccccc +abaccccaaaaaaaccccccccccaaccccccccaaaaaacccccccccccccaaaccccccccccaaaaccaaaccacaacaacccccccccccccccccccccccccccccccaaaaaaaaccccccccccggggoooooffffccaccaaaccccc +abacccaaaaaaaaccccccccccccccccccccaaaaaccccccccccccccaacccccccaaacaaaacccaaccccaaaaacccccccccccccccccccaacaacccccccaaaaaaaacccccccccccggggggggfffcccccccccccccc +abacccaaaaaaaaccccccccaaacccccccccaaaaaaccccccccccccccccccccccaaacaaaacaaaaccccaaaaaaccccccccaaccccccccaaaaaccccccccaaaaaaacccccccccccaaggggggffcccccccccccccca +abcccccccaaacccccccccaaaaaaccccccaaaaaaaacccccccccccccccccccaaaaaaaaaaaaaaaccccaaaaaaccccccacaaaacccccccaaaaacccccccaaaaaccccccccccccaaacgggggaccccccccccccccaa +abcccccccaaccccccccccaaaaaaccccccaaaaaaaacccccccaaacccccccccaaaaaaaaaaaaaaaacccaaaaaaccccccaaaaaaccccccaaaaaaccccccaaaaaaacccccccccccaaaccccaaaccccccccccaaacaa +abcccccccccccccccccccaaaaaccccccccccaaccccccccaaaaaccccccccccaaaaaaaaaaaaaaaaccccaaaccccccccaaaacccccccaaaaccccccccccccaaccccccccccccccccccccccccccccccccaaaaaa +abccccccccccccccccccccaaaaacccccccccaaccccccccaaaaaacccccccccaaaaaaaaaaaaaaaacccccccccccccccaaaacccccccccaacccccccccccccccccccccccccccccccccccccccccccccccaaaaa diff --git a/2022/Day13CSharp/Day13CSharp.csproj b/2022/Day13CSharp/Day13CSharp.csproj new file mode 100644 index 0000000..d439800 --- /dev/null +++ b/2022/Day13CSharp/Day13CSharp.csproj @@ -0,0 +1,10 @@ + + + + Exe + net7.0 + enable + enable + + + diff --git a/2022/Day13CSharp/Program.cs b/2022/Day13CSharp/Program.cs new file mode 100644 index 0000000..cb575d0 --- /dev/null +++ b/2022/Day13CSharp/Program.cs @@ -0,0 +1,334 @@ +// See https://aka.ms/new-console-template for more information +using System.Collections.Generic; +using System.ComponentModel; +using System.Runtime.CompilerServices; +using System.Windows.Markup; + + +Part01(); +Console.WriteLine(); +Part02(); + +void Part01() +{ + Console.WriteLine("!! === Part 1 === !!"); + Console.WriteLine(" === Example Data ==="); + var examplePackets = ReadPacketPairs("example-input.txt"); + //PrintPackets(examplePackets); + Console.WriteLine("Sum of combined pair indices: " + GetSumOfOrderedPairs(examplePackets)); + + Console.WriteLine(" === Puzzle Data ==="); + var puzzlePackets = ReadPacketPairs("puzzle-input.txt"); + //PrintPackets(puzzlePackets); + Console.WriteLine("Sum of combined pair indices: " + GetSumOfOrderedPairs(puzzlePackets)); +} + +void Part02() +{ + Console.WriteLine("!! === Part 2 === !!"); + Console.WriteLine(" === Example Data ==="); + var examplePackets = ReadPackets("example-input.txt"); + InsertDividers(examplePackets); + examplePackets.Sort(); + PrintPart02Sln(examplePackets); + + Console.WriteLine(" === Puzzle Data ==="); + var puzzlePackets = ReadPackets("puzzle-input.txt"); + InsertDividers(puzzlePackets); + puzzlePackets.Sort(); + PrintPart02Sln(puzzlePackets); +} + +void PrintPart02Sln(List packets) +{ + var dividers = GetDividers(); + int first = -1; + int second = -1; + int index = 1; + + foreach (var packet in packets) + { + if (packet.CompareTo(dividers.Data.Item1) == 0) first = index; + if (packet.CompareTo(dividers.Data.Item2) == 0) second = index; + + index++; + } + + Console.WriteLine("Dividers at {0} and {1}. Key: {2}", first, second, first * second); +} + +int GetSumOfOrderedPairs(List packetPairs) +{ + int sum = 0, index = 1; + foreach (var packet in packetPairs) + { + if (packet.IsCorrectlyOrdered()) sum += index; + index++; + } + + return sum; +} + +void InsertDividers(List packets) +{ + PacketPair pair = GetDividers(); + packets.Add(pair.Data.Item1); + packets.Add(pair.Data.Item2); +} + +PacketPair GetDividers() +{ + return new PacketPair("[[2]]", "[[6]]"); +} + +void PrintPacketPairs(List packets) +{ + Console.WriteLine("- Printing packets -"); + foreach (var packet in packets) Console.WriteLine(String.Format("{0} {1} correctly ordered.", packet.ToString(), packet.IsCorrectlyOrdered() ? "is" : "is NOT")); + //foreach (var packet in packets) + //{ + // Console.WriteLine(packet.Data.Item1.ToString()); + // Console.WriteLine(packet.Data.Item2.ToString()); + // Console.WriteLine(); + //} + Console.WriteLine("- Done -"); +} + +List ReadPackets(string filename) +{ + List packets = new List(); + + foreach (var pair in ReadPacketPairs(filename)) + { + if (pair == null) throw new InvalidDataException(); + + packets.Add(pair.Data.Item1); + packets.Add(pair.Data.Item2); + } + + return packets; +} + +List ReadPacketPairs(string filename) +{ + List packets = new List(); + + using (StreamReader reader = System.IO.File.OpenText(filename)) + { + while (!reader.EndOfStream) + { + // Read the next two lines + string? left = reader.ReadLine(); + string? right = reader.ReadLine(); + + if (left == null || right == null) throw new InvalidDataException(); + + packets.Add(new PacketPair(left, right)); + + // Read the empty line + reader.ReadLine(); + } + } + + return packets; +} + +class PacketPair +{ + public PacketPair(string dataLeft, string dataRight) + { + ListData left = Parse(dataLeft); + ListData right = Parse(dataRight); + + Data = new Tuple(left, right); + } + + private int Parse(ListData list, string data, int currentIndex) + { + if (data[currentIndex] != '[') throw new InvalidDataException(); + + for (int i = currentIndex+1; i < data.Length; i++) + { + if (data[i] == ',') continue; + + if (data[i] == '[') + { + ListData newList = new ListData(); + // Found a list + i = Parse(newList, data, i); + + list.Values.Add(newList); + } + else if (Char.IsDigit(data[i])) + { + int strlen = 0; + for (int j = i; Char.IsDigit(data[j]); j++,strlen++); + + list.Values.Add(new IntegerData(Int32.Parse(data.Substring(i, strlen)))); + + while (data[i] != ',' && data[i] != ']') i++; + if (data[i] == ',') + { + // Move to the next piece of data + continue; + } + else if (data[i] == ']') + { + // We're done with the values of this object, we can exit + return i; + } + } + else if (data[i] == ']') + { + return i; + } + } + + throw new InvalidDataException(); + } + + private ListData Parse(string data) + { + ListData list = new ListData(); + + Parse(list, data, 0); + + return list; + } + + public Tuple Data {get; set;} + + public bool IsCorrectlyOrdered() + { + return Data.Item1.CompareTo(Data.Item2) <= 0; + } + + public override string ToString() + { + return Data.Item1.ToString() + " vs " + Data.Item2.ToString(); + } +} + +class IntegerData : IComparable +{ + public IntegerData(int value) + { + Value = value; + } + + public int Value { get; set;} + + public int CompareTo(object? right) + { + var integerData = right as IntegerData; + var listData = right as ListData; + + if (integerData != null) + { + return Value.CompareTo(integerData.Value); + } + else if (listData != null) + { + ListData leftList = new ListData(); + leftList.Values.Add(this); + return leftList.CompareTo(listData); + } + else + { + throw new InvalidDataException(); + } + } + + public override string ToString() + { + return Value.ToString(); + } +} + +class ListData : IComparable +{ + public List Values { get; set;} = new List(); + + public int CompareTo(object? obj) + { + var integerData = obj as IntegerData; + var listData = obj as ListData; + + if (integerData != null) + { + ListData rightList = new ListData(); + rightList.Values.Add(integerData); + return CompareLists(this, rightList); + } + else if (listData != null) + { + return CompareLists(this, listData); + } + else + { + throw new InvalidDataException(); + } + } + + int CompareLists(ListData left, ListData right) + { + if (left.Values.Count == 0 && right.Values.Count == 0) + { + return 0; + } + else if (left.Values.Count == 0) + { + return -1; + } + else if (left.Values.Count > 0 && right.Values.Count == 0) + { + return 1; + } + else + { + for (int i = 0; ; i++) + { + if (i < left.Values.Count && i < right.Values.Count) + { + var result = left.Values[i].CompareTo(right.Values[i]); + + if (result != 0) return result; + } + else if (i == left.Values.Count && i == right.Values.Count) + { + return 0; + } + else if (i >= left.Values.Count) + { + return -1; + } + else if (i >= right.Values.Count) + { + return 1; + } + else + { + throw new InvalidOperationException(); + } + } + } + } + + public override string ToString() + { + string str = ""; + + str += '['; + + for (int i = 0; i < Values.Count; i++) + { + if (i > 0) str += ','; + + str += Values[i].ToString(); + } + str += "]"; + + return str; + } +} + diff --git a/2022/Day13CSharp/Properties/launchSettings.json b/2022/Day13CSharp/Properties/launchSettings.json new file mode 100644 index 0000000..b1ceda5 --- /dev/null +++ b/2022/Day13CSharp/Properties/launchSettings.json @@ -0,0 +1,8 @@ +{ + "profiles": { + "Day13CSharp": { + "commandName": "Project", + "workingDirectory": "C:\\dev\\DevSandbox\\AdventOfCode\\2022\\Day13CSharp" + } + } +} \ No newline at end of file diff --git a/2022/Day13CSharp/example-input.txt b/2022/Day13CSharp/example-input.txt new file mode 100644 index 0000000..6439c56 --- /dev/null +++ b/2022/Day13CSharp/example-input.txt @@ -0,0 +1,23 @@ +[1,1,3,1,1] +[1,1,5,1,1] + +[[1],[2,3,4]] +[[1],4] + +[9] +[[8,7,6]] + +[[4,4],4,4] +[[4,4],4,4,4] + +[7,7,7,7] +[7,7,7] + +[] +[3] + +[[[]]] +[[]] + +[1,[2,[3,[4,[5,6,7]]]],8,9] +[1,[2,[3,[4,[5,6,0]]]],8,9] \ No newline at end of file diff --git a/2022/Day13CSharp/gen-input.txt b/2022/Day13CSharp/gen-input.txt new file mode 100644 index 0000000..13fc0c4 --- /dev/null +++ b/2022/Day13CSharp/gen-input.txt @@ -0,0 +1,449 @@ +[[0,5,[[],[],2,[7,9]]],[[8,8,3,[6,3,8,9,1]],[2,0,10,7,10],4,10,[9,[1,8],4,[4,0,5,10],[4,0,8,8]]],[9,10],[],[0,[[]],4,10]] +[[],[4,7,3,6,[2,[10],[2,5,10],5,2]],[[1,10,[6,9],3],[6,10,8,[1],[10,7,3]],[[7],[10,9,9,2],1,7],7],[3,7,9,[[4],0]],[[4],[[9],0,9,[]],[7,[],[],[5,7]]]] + +[[10,[[10,7,3,0,10],10],[[8,7,7,2,8]],0],[0,7,4],[2,10,[],[8,[7,10,10],1,0],[2,8,6]]] +[[[7,6,5,[]],[[10,0,4,1,6],[5,9,10,6],[1,5]],[7,[6],[10,5,6,7,1]]],[2,[3,[7],[4],7,[4,4]],[],0,[]],[5,[1,6,6],[8,9,[1,1]],[5]]] + +[[[[3,9],5,[5],[0],5],[],[4,[6,2,2],[10],[],7]],[[],0]] +[[],[[3],6],[10,[[4,1,10],[2,7,6,0],[0,8,9],[7,0,3,4,4],7],[[7],3,[3,2],[],4]],[[[10,2,7,8]]],[10]] + +[[10,6,7,0,[1,7]],[[[3,5,9,1,10],[],1,2,[0,9]]],[4,1,[4,4]],[1,2,2,5],[[5,[8],[]],7,[1,3,[4,1],5],[[10,7,9,2,2],[]],[[3,0,10,7],0,[],[0,3,9,7,3]]]] +[[[],[4,[5],4,[5,5,8,9,1]],[7,10,[8,8,6,2],[],[3,3,6,2]],[3,3]],[],[5,[4,[10,6,6],[]],[[0],[4,7,0],[2,9],[9,4,3,8]]],[[3,[7,0,2,10,3],1,10,10],0,9,[[8,1]],[2]],[8,[[10,2],5,[0],[8,3]],[5,[4,1],[9,8],[0],9]]] + +[[8]] +[[[[6,5,8,3],1,[1,5,5,5],[9,5,0,1],[7,0,0,4]],[[6],10,[3,2]],3,6,[10]],[4,[3,[1],10,[5,5,7,3]],[[6,2,5,0,5],[0],[7,5,4],[4,9]],[]],[],[[[4]],[4,[5,3,6,5,0],[2,6,1,6]],2,[[4,2,8,1],[6,2,7],[7,7,10,7],2],2]] + +[[],[],[[[7,9,4,8]],[[5,1]],[7,[8],[9,1,5,4],2,[]],4],[2],[[[2,10],[9,7],[3,6,9,9,7],5,2],8,0]] +[[],[0,1,6]] + +[[[[2,8],7,[]],[[7,6,10,3,2],3],4],[],[[[4,10],4,[1,3,8]],5,4],[[7],7],[]] +[[[]],[0],[3,[7,[5,3,2,5,6],2,[3,1],10],[8,10,[3,8]],7]] + +[[4],[[[7,9,8],3,6],[[],8,[2]]]] +[[[8,3,[3,5]],0],[3,[[9,2],[2],7,1],10],[[3,[0,6,6],10,[5],[1,7,0]]],[],[6]] + +[[6,8],[7,[[],[1,4,3,6],[7,8,9,2,10],8,7],8,9],[6,7,[[10]],[[4,8,9]]],[[[6,3,6,1]],[[8,10,10,0,5],[1,4,4,7,5],1,[0,2,1],5]],[5,5,[[2],10,[],6]]] +[[[[],4,7,0,7],[[1,2],0,[7,1,4],[6,2],[8,6,2,1]],0]] + +[[2,[[5,4,10],3,[9,0,8,7,4],4,6]],[[[8,10,7]],[2,[]],5],[[]],[4,9,[],7],[9,[[6],0,[]],[7,[],2],0]] +[[[[5,5,0,2,9],6,2,1],[10],[[4],[10,6,6,10],[]]],[],[6,[]],[0,1]] + +[[9,6,[3],[1,5,[9,2,4],[4,1,6],[]],[[]]]] +[[5],[9,[],3,8]] + +[[8,[[7],1,8,[2,6,4],8]],[]] +[[],[],[[0,[],9,[0]],[[3],[4,6],[8,6,5,8,0]],6],[],[]] + +[[10,0,[[],5,[4,4,10,9,8]],8],[],[3,[[0,3]]]] +[[[[0,9,4],[7,3,9,4]],[4,[0,5,7,10,3],0,9]]] + +[[[[0,8,8,0,4],[7,10,5,10,6],9,8,10],[[0],[],[0],10]],[9,8,[[8,7,5,5,10]]],[1,[10,4,1,[10,4,10,0,1]]],[[[1,9],9,5],3,1,[[7,6]],[]]] +[[3,1,[[9,5,8],7],[3]],[[9],7,4,[]]] + +[[7,3]] +[[[[4,2],[3,3],4,7,[1,2]],5],[[6,[2,9],[10,3,6,4,2],[2],3]]] + +[[[6,[]],[[4]]],[],[3,[[7,2,1],[],[8,9,9,10],[9],10],9,1]] +[[[1,7,[7]],10],[[6,8,2,[0,9],2]]] + +[[[2],9],[[[2],[5,4,0,9]],[10,3,2,[0,0]],[[1,6,10,0,1],[3,5,6,7],[8],[1]]],[[8],[6,10],8],[9,0]] +[[]] + +[[[],[4,3],6,[[],[9,5,3,9],[9,5],2,3],5],[4,[2,2,9,6,5],2],[[],2,[[],[5,6,6]],[10,[7,2,4,2,9],8]]] +[[5,[7,[],[0,4,3,10],4,9],10,[[4,8]],10],[[[2,5,5],6,0,[5],[9,3,2,10]],[[5,4,8],[3],[1]]]] + +[[5,[[7,2,1,10,0]],[1,[4,0,5]]],[0],[[],10,[]],[10,[[9,3],[0],3],[7,9,3,[]],1]] +[[[4,2],1,4,7],[[[],9,[3,5,8,7,6]]],[[6,3,4,[8,2,5,2,5],[9,8,3,1,9]],1,[[10,9]],[[1,4,1],1,8,[2],[10,3]],10],[[[],1,1,[]],0,9],[7,[6,[7,2,2,6,0],7,5],[[3,10,10,0],1,[1,8,4],[1,1]],[[7,7,6,2,4],2]]] + +[[5,7],[],[6,[4,8]],[8,[3,[10,2,0,5,6],[9,0,7,8,8],[0]]],[2,4,7,[]]] +[[],[4,[5,0,3,6]],[5],[]] + +[[1,1,8],[[[1,10,3],1,[6,6,6],6]]] +[[[4,10],0,9,[[1],[3,5],[10],4,[7]],1]] + +[[[0,5,10,2]],[[]]] +[[[8]],[[[8,9,0]],10,[[9,7,5,3,6],[9,7,3]]],[6],[2,[[4,7],[6,9,8],[10,0,8,0,0],[9,4,3,10]]]] + +[[[],[[],7,[10,1,8,4,0],6,[10,2,2,6]],[[5,7,10],[9,9,5,5,0],6,[6,2],10]],[],[]] +[[],[7],[[[7,3],6,8,9,[2]],[[7,8,6,2],[],9],3,[[9,0,8,10],9,[1,9,7,0],[6,9,1],8]]] + +[[8,[[10,8,5],[],[4,0,6]]]] +[[3,4,[0,3,7],2],[[2,6,9,4,0],[1,[6,10],10,[4,5,1,9],0],[10]],[7,[[0,2],[3,5,10,1],9,[6,9,0,1]],8,9],[],[[[1,10,8,10,7],[4,9,5,2,1],5],10,4,7]] + +[[[[9,9,4,6,8]],3,2,10,6],[[[2,0],6,[9,10,0,1],[1,0,7,7,1]],[9,10,3,[1]]],[4,6,2,[2,2,5,[9],3],4],[[8],10,[9,[],[],[1]],8,[[],3]],[4,4,[10],7]] +[[[9,[9],[4,0,10],[3,0,4,4]],8,[0,[4,8,0,5],[5,2],[0]],8,1],[6,0],[5,0,3,4],[[[2]],1],[]] + +[[[10,3],6,6,10]] +[[[7]],[],[[0,[0,3,7],[],[5,0,2,6]],[2,[8,9,3,9]],[]]] + +[[],[[1,8,[0,10,3,7,2],5]],[[9,[4,7,7,6,10],[4,9,3]]],[[[9,4,4,9]]],[[[9,6,8,1]],2,4,[],5]] +[[1,[],[10,6],9]] + +[[3,1,4,8],[[],[1]],[]] +[[2,[5,[]],[]],[[2,1,8,6,[4,10,2,7,3]],4,[[9,0,2,3,7],8,10,4],5,[[],[10,9]]],[[4,[9,6,3,9],2,0]],[[[3]],[]]] + +[[1,[9],[[],4,[7,9,9],[1,4],[2,6,4]],3,2],[[],6],[[[0,7,3,2],2,2,[5],[3,7,8,3]],10,1],[[[],[],0,[0],[7,4,5]]],[[9,[3,3],[6,8],[10]],2]] +[[9,7,[],[0],0]] + +[[],[[5,5],[9],10,2],[],[[6,4,[5,6,9,1,2],2,8]]] +[[[[8,3,5,10,1],[3,4]],[9],[[3,10],9,7,[]],6],[2,10,[10,2,0],[0],[1,1,[2,4,0,8],[7,1,6,3],[8,10,8,1,4]]],[[[0,9]],[[7,2,1,3,4],6,[7,5]]],[8,10],[7,6]] + +[[],[[[10,8,8,6,2],2,10,[8,6,7,7,3]],9,1,[[3],9,9],[[5,2,9],2,0,[10,1],5]],[[],6,1],[[[3,2,4,7,3],[],9,[9,2,3],3]],[[[]],1,7]] +[[7,[[7,2,8,9],9],[8,[0,3],[3,5],[5,8]]],[9,[0,3,10,1],[[4,8],4,[3,7,5],[6,2]],[[],6,[5,2]]]] + +[[],[0,[[0,0,1,3,8]],6]] +[[10,6,8,8,[]],[9,[[7,4,8,1,4],6,[7,4,5],1],[[7,3,10,5],2],[[1],0,1,7],[6]],[[7,[4,7,9,6],[9],[6,3,3,3]],[6,[10,0,5,8],10,1,6],7,[9,0,2,1,9]]] + +[[1,[[4,1]],7],[],[[6,0,5,[9,10,0,6,0]]],[[6,[],[]],[[9,2],9,7],7],[8,10]] +[[[6,4,8],[8],0,[5],2],[7,6,7,1],[10,10]] + +[[[[10,8,9,6,10],5,4,0,8],[[7,1,5,0,8],[2,5,5,4,2]],[[2,2]]],[[[6,2],1,[],3],[8,3,5,1],[[7],[0,4,2],4,[0,2,6],[1,6,3]]],[6,[3,0,[6,8]]],[[[9],[6],9,[2,3,9]],5,[7,[8]]]] +[[5,4]] + +[[[[],[2,1,4,2],3],[1,9,[8,2,4,10]],[5]],[[1,2,[10],7],10]] +[[7,[],[[10,5],5,1],[5]],[3,3],[1,7],[[[1],9],1],[9,[[7,2,6,6,0],[]],[],[]]] + +[[1],[[],3,[4]],[0,9],[[[10,10,6,8,9],4,3]]] +[[[10,10,4,3,[7,10,7]]],[[3,10,9,[8,6,10,5],1],[[7,7],1,0],[5,[4,8,7],6,4,5],1,[[3,5,5,8],[5,9]]]] + +[[0,4],[[]],[[4,3,1,4],2,[8,2,1],1]] +[[[0,[4]],[[0,6,0],4,8],[10],5],[],[[4,[10,1,8]],8,[]],[7],[]] + +[[[[7,7,3,4],[4,5,0,8],2,[1,6,5,10]],[[2,0,1],10,[2],4],1,2,[10,[7,7,7,2],[]]]] +[[[10,[8,3,0,5,4],6,3,[4]],2],[[10,6,[],[10]],2,5],[[]],[[],[8]]] + +[[[7,5]],[[[7,5,4,1,2],8,9,[7,10,6],10],[[8,3,2],[1,1,5,4,4],2],0,5,6],[],[5,7],[5]] +[[3,[[4,2],5,10,8],10,[[5,8,8],3,[6]]],[[[4,7,9,3,4],0,[9],4],[[9,9,3]],[10,6,[3,9,10,1]],2],[9,8]] + +[[5],[7,10,[7,[7,5,5,10]],[[3,8,9,10],[],[3,6],5,5]]] +[[[],6,[[],7,5,[6,3,2,10,5]]],[]] + +[[[[4],5],[10,4,[6,2,1,3,3]],8,[[]],1]] +[[5,[]],[[[3,7,7],[2],2]],[6,7,[[6,1,3,5,8],[0,0],2,[10,8]],[9,[2,10,5,0]],4],[0,1,[1,[7,1]],9,[6,1,2]]] + +[[8],[[[7,7,6,3]],6,5],[[6,10,2,1],[[],9],[5,[],7,3,[9,4,0,2]],[[10,1,9,1,2],9,8]],[]] +[[],[[3,[7,1],0,6,[3,8,3,10,4]],9],[6,4],[10,[9,8,[2,6,0],[2,3,0,0]],[[10,7],[9],3],8],[10,[],[8,[3,5,0,9,1]]]] + +[[10,3,4,9,3]] +[[[4,[7,9,9,2,7],[],[],4],3],[1,9],[]] + +[[10],[[[0,4,2]],3,8],[7,[0,[2,10,4,3],[5,1,5],2,10],[7,[],1,[],[1,9,7,4,7]]]] +[[5,[3,[7,6]],[6,7],2],[4,[2,[]],[[6,10,4,10],[5,1,0],10,5,1],[[4,10,0,7,5],4]],[]] + +[[[[6],10],1,[[10]],9],[7,4,10,10],[2,0,[8,0]],[8,9],[6,[[10,2,7,0,1],1,[0,5,3,7,2],[6]],4]] +[[[[],[2,2,6,0],[5,10,0,10,0]],3,[[3,7],3],5],[],[[],3],[7,[[7,4,8],9,2,[2]],[[1,3],[5,3,2],10],[10,3,[10,6,9,3]],[7,[9,6,0]]]] + +[[2,[[3,8,10,9,7],[2,5],[],10,0],[1,8,2,[]]],[10,[5,[2,8,2],5,3]]] +[[],[0,[]],[[1,[],[0,7,0,1,8],[]],[[4,1,8,5],[5,10]]]] + +[[[[3,9,9,9,7],3],[0,[6,2,6,4,7],2,[7,9,9,7,8],[0,3,1,5]],[1,[2],[8,5,8,8,10],[7,3,2,10],[2,7,8]],7],[[],7,3,[9,6]],[[2,[0,8]],[1,4,[8,3,0,10]]]] +[[[]]] + +[[8,2,3,1,0],[2,[5,[3,5,0,3],7],3,[1]],[10,[[9,4,0],3,[2,0],6],[[]],10]] +[[[[9,3,0],[6,9,6,10],2,[],[5,9]],0],[3,5,[],[4,9,[0,0]]]] + +[[6,2,[6,[4,0],[4,5,8,7,1]],[[0,0,1],[9,5,3,1],2,[5],[1,5,7,4]],4],[8,[],[[0],[],[4,5]]],[6,[[10]],1,[1,5,1,10,[7,5,8,2,7]],[[7,1,2,1]]],[6,2,7,[6,[4,3]],[[7],10,[3],4]]] +[[[[3,1,4,10,3],3],8],[3],[1,[5,[5],8,[9,10]],[[]],[4,[1],8,[]],[[],5]]] + +[[[10,6],[[1],6,0],[9,2,2],[4,[4,6,10,7,9]],6],[],[[],3,1,4,10],[]] +[[[10,[4,1,7,7],9]],[[[3],[4],[1,3,0]],8],[[7],[6,[0,6,0],[1,8,5,3],[0]],0,6],[],[9]] + +[[1,1,[6,[],6,[2,4,10],[9,10,4,3,7]],7,2]] +[[[[0,9,2,6],[0,10,1,8,7],[10,10,6,1],5,[9,2,9,1]],[3],5,10],[0,[[3,1,10,8],[],[],[7,9]],[[10,1,2,10]]],[[1,[10]],[],[[2,4,0,1,5],1,4,3],9,[2,[3,7],[],8]]] + +[[[6,1,7,7],4,[[6]],[[6],[9,4],[3]]],[[],[[10,0,2],[9,1,10,1,6],1,[1,8,2],[]]],[],[[],9,[6,0,2],[[],3,9,[6],[1,0,6]]],[[2,[6,7,7,6,7],2,[4,0,0,3,2]],[7],[8,[4,10,0,7,2]],0,4]] +[[4,[[10],2],[]],[[3,[2],[10,0],2],6,2],[[3,[],[],[5,5],6],[0,6],5,[3],[7,[3,8,1,3],6,10]]] + +[[],[1,[[],4,[1,10],[5,6,7],[7,8,1,2]]],[[8,1],[0,[]],2,[]]] +[[[[5,5,5],9,9],[],[0,[4,6,9],9,7],4],[[[],0],8,[1,[0,0,10,9,4],[3,5]]],[[8,1],[[]],[[3,5],3,[4,10],4],[9,[8,0,6,10,7],[3,4],10],7]] + +[[3,[[0,0,10,10,0],6,[7,8,5,10,9],[3,5,1],[10,1,9,7]],7,[10,3,[0,5,8]],10]] +[[],[[],[[10],8,[3,5,2],[10,4,0]]]] + +[[1,8,[[],1,7]],[4],[[[2,6,8,10],0,3,5],[[8,6,7],9,[],[4,2,2,1,0]]],[6,10,0,[[8,0,6,4],[9,7]],5]] +[[2,[3,[5,0,9],7],[[1,4],1,2,[10,8,8,0]],[4,8,2,4]],[9,[],[[3,4,6],[2],[4,6,10,5],0],4]] + +[[6,4,[2,[9,5,8,2,1],10,5],[[6,7,8]],2],[],[]] +[[1,[5]]] + +[[],[5],[5,[2,[0]],[[5,0,3],4,8,0],3,1]] +[[9],[[[8,8,3,5],[1,1,2],10]],[1],[[[]],[[8,6,8,9,8],7],[10,4,10,[1,3,3,7]],4],[]] + +[] +[[[[]],5,[9,[],9,[6,4,1,3]],7],[10,5],[2,9,[[4,1]],6,3],[[6,1,[4,0,10],[3],2],4,[]],[[5],[[2,1,8,7,6],9],[6,6,[10,7,6,5,8],[2,6]],[],7]] + +[10,6,2,5] +[10,6,2,5,4] + +[[[],6],[],[],[]] +[[],[[],[5,2,[9],[]],2]] + +[[1,1,1,2],[],[[9,6,2,9]],[],[7,7,1,[8,4],5]] +[[[7,7,0,4,[2,9,4,7,1]],2,10,[10,[],[5],6],3],[[],[[7],[10,10,4,9,0],[10],1],[],[[10,0,10,9,1],[0,8,2,10],4]],[6],[],[2,5,3]] + +[[],[[2,8,[1],[5,2,5,2],[2,9]],[10],[10,6,7,[0,4,8,10,2],[]],[]],[[10,[2,2,0,5],2],[[6,0,3,8,5],[9],[],10],[],[[8,7,10],6,8,3]],[[[5],5,5,[0,3],[10,3]],[1,4,5,[]]],[1,2]] +[[[[],8,4,8]],[],[]] + +[[[[10,4,6],[],1,[]],[[3,4],[7,5,4,2],[],0,[10,10]],[[0],[6],[6,5,2,10,4],3,6],[[8,10,4,3],2,0,[3,4,8]],5],[[[3],7,3,[5,5,4,2]]]] +[[[7],1,7]] + +[[0,6],[[],[[9,8,10,2],[0,9,5]]],[2,[],9,[[],8,[2,4]]],[4,6,0,3,4],[[[3]],0]] +[[[[6]],5],[[9,[6,10,0,7],[3,8,7,4]],0,[],[[1],[7,4]]],[[[1,5,6],6]]] + +[[3],[[[7,7,2,0,7]],[0,4,10,7,[10,0,4,1,6]],[[4,7,9],5],[[6]],7],[[[5],[],[],[1,5,10,6],3]]] +[[5,[7,3,[9,4,10,7],[1,4,10,4],[]],[9,2,1]],[1,7,[[],[0]],7,0],[],[2,[[5,1,0,7]]]] + +[[8],[7,0],[6,5,[[],[],8,[5],1],7,[]]] +[[8],[],[7]] + +[[[],[[6,1,6,9,8],1],[[8,7,8,0],10,[8],8]],[[[]],[[6,6,9,5],[0,2],7,3,[5,9]]],[]] +[[],[0,[[],[7,5],[3,10,7],7],[[9,4],10],[[5,7,8,7]],[]],[],[8,9,3,6]] + +[[[[9,8],6],3,0,[[3,7],[5,1,0,2],10]],[7]] +[[],[],[6,0,10,[],[2]],[[[1]],[7,3,[10,10]]]] + +[[8,[8,10,6,4,10],[],1,[[8,0,1],9]],[0,0,3],[],[[[],[3,6],8,[]],1]] +[[9,[[6,3,3,7],5,[2,9,5,8,0],[6,7,8,4],10],[3,4,[8,4,1,10,10]]]] + +[[2,[[4],[0,8,3,10,4]]]] +[[[2,[0]],[5,[3,4,1,0],6,[1],1],3,4,9],[6,1,3,6],[7,[10,0,1,[8,10,8,0,6]],9,[[8,4,2],0,6,8,0]],[],[[[6,0,6,8],1]]] + +[[6,[[9,10,4,3,9],1],9],[[[9,2],[],[3,2]],[[4,7,8,3,5],0,[5],[10,5,6,0,6],[2,10,3,6,8]],[6,[]],[5,[4,5,9,10],[1,0,1]]],[[[2,1,9,9],[10,6,4,1,8],[],5,[2,10]],8,[[1,1,8],4,[2,4,0]],7]] +[[10,[1,[2,3,0,6,9],1,[],[8,4,1,6,1]],3],[[[2],[]],[],7],[],[2,6],[10,4,6,6,[[],[9,8]]]] + +[[10],[[9,[8,9,5],3,9],7],[[[9,8,10,5],3,6],10,5,10],[5,1]] +[[2,3,[]],[1,[[2,1],5,3,[7],0],5,[]],[[],[1,4,[]],[6,[1,4,8,3],9,[2,3],8],10,3]] + +[[[],[9]],[[[7,2],9,[4,8,6],[0,3,9],[8,8,1,4,1]],7]] +[[2,[10,6,[5,0,9,5]],10],[[[3,3],6],[[6,8,2,5],[8,6,0,5]],[[1,7],4]],[0,[[3],[]],[[2,6,9,1],9,[4,2,5,0,2],9,[7]],[9,7,6,[2,2,9,5]],6],[[3,4,[6,9]],2,[4],3,[[1,9],[0,2]]]] + +[9,0,10,9,1] +[9,0,10,9] + +[[[5],[7,0,9,2],2],[[3,[0],[]]],[6,[]]] +[[3,[2,[0,4,5,1],[9,0]]],[9,2,[6],[3]]] + +[[[9],[0]],[1],[[[4,5]],3,10,5,10],[8,9,0,1],[[2,[10,5,5,2,3],[9,2,1,0,4]],[1,10,7,[10,9,7,4]],1,1]] +[[0,2],[8,[[9,4,9,2],10,[9,8],4],7,5,6],[6,5]] + +[[],[4,[[7,1,3,7]],[]],[],[[[],2,[3],3],[[7,0],6],3,[7,4],[]]] +[[4,8,6,2],[[[]],6,10,[[4,10,5,0,1],6,6],[]],[1]] + +[[[[7,8,0,9,3],[8]],[[6,10],[10],2,0,1]],[],[[1,[3,9,4],0,[]],[[],2],[8,[8],[5,7],[],9],[2,10],7],[3,[2,[3,8,5],3,2],6],[[1,[3],[4,10,3],5,[6,5]],[[]],2,[],4]] +[[[],[6,6,[10],7],[10,[10,8],5,[10,8,3]],[5,10,4,8]],[3,10,6],[[[2,2],[5,2],[3,0,10,0,4]],[[8,9,2,9,0],1],1,[[10],6,0,8]],[8,[10,6,[1,3,9]],7,8,[3,[6,10],[7,6,4,5,1],[10],3]]] + +[[[[5,9],[1,1]],3],[],[6]] +[[6,[9,7],[[6,0,7,10],[10,6],[4,3,3,7],10,[4,6,4,4,10]]],[1,[[2,0,0],[7,0,10,1,7],[9]],[10],4],[[8,10,9,[6,7,0,2,7],10],[[6]],[],[9],[]]] + +[[0,7,[[3],[0,3,6,8],[7,8,4]],[]],[3,[9,5],9,[4,5,[6,8,2],[7,3],7]],[]] +[[],[[[3],[5,7,10,7],9,[3,9,6,5,7]],[[10],[4,3,10,9,3],[]]],[[[0,5,7,3,2]]]] + +[[10,7,0],[],[1,5,7,[],5],[1,4,[0,4,[3],[2]]],[[4],7,7,[9,1],9]] +[[2,[2,[],[5,7,2,1,6],[8,9],[7,7]],[]],[1,3,[[],[3,9]],[6,2]]] + +[[3,3,0,[4]],[],[[7,0,[2,1,5,4,1],7,[0]]],[8,[6,3,4,7],10,[3]]] +[[[1,[1,8,8,10,0],[5,7,6],[5,1],8],[3,0]],[[7,[],9,6,[9]],4,[[2,3,0],6],[],5],[10,[],[[],10,[5,9,3,2]],[1,3,[],0]],[6,[[2],1,4,3,4],7,2],[1,[[3],10,3],6,9,[[3,8,3,8],2,[4],9,9]]] + +[[[8,[3,8],[0,5],[8,8,2,4,7]],[4,[4]]],[1,7,8,2],[[1,7],[[3],3,[8,3],[6,4,2]],3,[[8,3,6,9,1],[4],[6,5,1]],[[3,6,1,5]]]] +[[4],[]] + +[[5,[[0,9],[10,10,10,2,2],[1,5,8,2],[8,4,9,0]],9],[[6,[8,8,5,4,7],8,[],[7,9]],8,[],[[7],7,8,[2,2,0]]],[[[2,4],7],[8,6,[],[9,1]],[],[10],[[6,7,0,5,5],4,7,[5,1,9,10]]],[],[[[1,3,1,0],[7,7]],[6]]] +[[[[8]],6,[[6],[],9]],[[[1,3],2,4,9,7],[5,[4],0,1],6],[5],[[],1,[],[[8,1,2,10,7],[7,9],9,5,4],1],[]] + +[[[],5]] +[[4,[],9,6],[2,1,[[4,5,10,0,1],10,1]],[],[7,[[2,2]],9,[[3,0,7,5,1],[1,10],2,[]]]] + +[[[9,4,[2,2,5,1]],[7,0,[9,2,1,9,6],5,[7,8,0,5]],[[8]]]] +[[[4,6],[[],[],3]],[],[[[4],9,[9,2,5]],[6,[1,7,6],[9,3,1,2,9]],[[2,3,0],4,0],[2,4,[0]],4],[10,[3,10,6],[1,10,5],9]] + +[[[0,8,2],6,[[4,0,4,7],[1],[2,8]],[[3],10,5,4,[8,0,9,4,0]],8]] +[[[],[],5,[[8,0]],0],[9,6]] + +[[[]],[10,4],[10]] +[[],[[3,[]],[6,[6,6,2,2]]],[[0,9,10,7,[8,4]],6,5,[[1,8,2,2,10],9]],[[[8,7,0],5,3],4]] + +[[],[4,[6,[2]],[[3,10],[3,2,0],3],[[],10,[9,8,0,2,9]]]] +[[[[6,1,0,10],9],[6,[2,4,10,10,10],3,6,[6]],[],7,5],[[],[7,[10],5],[[2,3,2],0],1],[[[],10,5],[[7],[],5,[8,1]],3,10]] + +[[9],[4,[3,5],7,4,7],[[],[5,2,[1,4,0]],[6,[1,9,3,3],[]],6,10]] +[[[[3,2,0,5],4],[7,[3],[6,7,0,5],0]],[9,4,9,2],[[]],[[[2,7]],[10,9,8],8],[]] + +[[],[4,[6,10],6,[[],7],[[3,0,5]]]] +[[[[1,3]]]] + +[[],[[[],9],[5,[2,8],[6,7]]]] +[[8,4]] + +[[4,[2,2,[1,8,3,6,5]]],[2]] +[[5,4,[[7,4,8]],1,0],[10,[],[[1]],[5,[]]]] + +[[10],[],[3,1,[[],0,0],0],[[9,6],2,[[9,9,8,2]]]] +[[10,[4],[[],[5,5],7,[3,1,2,10,0],10],1],[3],[[],9]] + +[[[[5,6,8,3]],1,[5],10],[[[2,3,5,3,6],0,10,[2,3,7]],[]]] +[[[[],[2,1,10],[],[4]],[[6,1,1],10,4]]] + +[[8,[9,[2],[0,6,2,3,7]],4]] +[[[3,[6,5,1,6,10],[1,5,4,1,3]],[7],[],[10,10,4],[[9,4],[7,4],0,2,[2,5,6,7,4]]],[[],[8,4,3,[0,7,6,7,5],6],[[10]],[[1,7,9,5,8],[1,4,5,9,6]]],[6,2,[]],[]] + +[[[[2,7],0,[2],[0,0,0,10],[]]],[2,[[2,8,9,3,3],4,4],9,[1],[10,3,[8,7],[9,6],5]],[[[],[9],[6,5,3]]],[[0,[7,3,0],[],[]]]] +[[],[[4,0,[5,0],[8,9,4],[10,6,9,6,1]],[0,[1,3,10,9],0,5],1]] + +[[[10],[[9,1,1,3],8,10,6],[[0,7,6,7],8,[7,10],[10,8,0,2,8],[7,7,10,1]],8,[2,0,[4,9,6],4,[2,5,5]]],[10]] +[[10,[],5],[3]] + +[[[[3,5,7,8,5]]],[[[8],[2,7,8,2],[8,6],[5,9,10,2]]],[[],[[]],10,[[7,5],6,[]],[9,[5,3,8,0],5,5,2]]] +[[[[9],4]],[5,9,8,[]],[[]]] + +[[],[[[4,2,4]]],[4,9,8,[3,0,[3,6,3,1,5]]]] +[[7,[[1,9,7,5,0]],[]],[1,[6],3,9],[3,2,1,[[2]],8],[[[10,5],[8],10]]] + +[[],[8,5,[[]]],[],[[9,0],[],2,9,8]] +[[2,0,[5,3],6],[[],[10,[0,5,9,9,10],7,[5,8,1,8],[8]]]] + +[[[]],[[0,6,[7,8,0],3,[9,6,2,5,2]]]] +[[],[[],[]],[[[],2]],[1,9,2,8,6]] + +[[],[[[9,2,5],[3],3],1],[7,[[]],[7,6,[7]],[[],[8,0,2,9,9],5,7],1],[[2,[7,4,4],3],[[6,9],[1,10,0,7]],[5],10,3],[]] +[[[],[[0,4,5,4,6],1]]] + +[[2,5,6],[[[4,7,4,6]],8,4,4,[[8,4,3],[5,1,8],5,[6,4,0,6,0]]]] +[[6,[[1,5],0,3,7],[],[]],[],[[[1,3,8,0],[6,2,1,0],9,1]],[0,[[0,9,1,7]],[0,1,[1,6]],7]] + +[[[3,[4,2,8,0]],0],[0,[[8,3,5]],[7,7,[],10,[0,2,2,4,6]]],[6,[[6,9,8]],[0,[4,9,6,0,9]],[],6]] +[[],[6,10,[],[[0,1,5],1],0],[[]]] + +[[[[3,10,1,6],[5,0,9,9],[10,10,10]],6,[3,9],8],[[[1,7,2,6],[],9],6,3,[8,9,[5,5],[0,5,9,4,5],[]]],[10],[[2,0],[[0,1,2],[],[10,5,2],4],2,[[6],[],0,[1,5],2]]] +[[[9,6,[5,8,9]]]] + +[[4,[[7,0],1,[8,0],1,7],[],[[2],[1,6],[0,5,3],[0]],[[8,10,5]]]] +[[3,6,[[],2,1],4,[[1],5,9,[10,0,0,5]]],[[1,[2,1],6,10,1],8,[3,[4,0],4,1],[]]] + +[[6,9,1],[],[2,4],[[2,5,[]],[[6,7,10,5],4,9],5]] +[[[0,3,4,8,[0,9]],8,10],[[[4,0],[8,8,2,9],[],5,1],[5,[0,0,5,9],[5,10],7],8,[4,[3,0,4,7,0],5],[[9]]],[5,1,6,10],[]] + +[[6,[1,2,10,[]]],[[],10,1,9,[[9,5,7],3,[4,5,10,5],5,[1]]],[]] +[[[[10,7],1,1,4],10,6,[7],[10,5,[]]],[1],[[[8,2,5,7],[],[],8],[],[6,4,[],[10,8]]],[9,1]] + +[[4,[[],1],[5,[6],0,1,[9,0]],[[7,6,2,1,10],[0,5],[3,4],1,[8,2,4]],[9,3,1,[]]],[]] +[[[[0],1,[5],7,[4,0,1,7,1]],[10,10,[1,9,9,4,6],9],[[4],6,[0,0,10,0]],4]] + +[[0,10,[0,[10,10,6,7,1]],4,[[0],[7,10,5]]],[]] +[[10,[],6,[10],[10,[2,5,4],3,3,0]],[9]] + +[[],[[[7,1,2,9,4]],8,[8,5,7,3,[9,10,4,9,1]],[3,[6],[1],7],10]] +[[[],[0,8,[3,6]],10,[[10,0],[6,8,5],2,8,[5,10,2,0,5]],10],[[[6,0]],5,8]] + +[[7,[[10,0,4],7],[0,[3,7,7,10,3],10,[2,4,2,0,10],6]]] +[[5,5,9]] + +[[3,[10,[10],4,0]],[[[3,7,7],[0],[]],0],[[10,6,9,7],[5,[3,7]],[[7,9,8],0,5],10],[],[0,5,10,8]] +[[0,[10,1],10],[8],[7,[4,3,5,[2,5,6,3]],[[2,0,10,4],[7],[9,9,6],[1,5]]],[]] + +[[],[],[7,[2,9,0]],[]] +[[[[3,5,0],9],1,7,9],[1,[[9,2],[5,3,0,10],[9],0,[0,8]],[[10,0],7,[4,8],1,0],[[7,7,3]]]] + +[[],[],[],[],[[4,1,6,[],10],[[7,2,2,1,1],[],[5],[8,8,7]],1]] +[[0,[[8,9],[10,0,9],5,5]],[[]]] + +[[10,[10,9,[10,0,2,2,2]]],[[1,5,[10,9,7,6]],3]] +[[0,6],[10,[[4,5,7,0],3],2],[]] + +[[[[8,10,3]],[[10,3,10,4,0],5,[1,5],2],3],[6,[5,[3,10,3,4],[1,1,10,0,6],2],10,[],[[10],7,6,2,10]],[[[7,10],4,2,[],[5,0]]]] +[[],[]] + +[[[3,[10,2]],[[2]]],[[[8,5],[0],4,[],[5]],[4,[7,2],[9,1,8,7],[7,7],5],[],[10,[8,7,5,3],3,[],[8,4,2,7,2]],[[1,8,4,5]]]] +[[0,[3,8,9,8],[1,6,1]],[[],[],[0,[4],5,5,[1,7]]],[3,[[6,1],2],[],[[7,10,4,4],[6,9,9]]]] + +[[7,[9,9],7,6]] +[[1,[]],[[],0],[3,[6],[[6],1,5,3]],[1,[],[[5,4,9,10],5,5],[],[[1]]]] + +[[6,0]] +[[[[2,3],4,[6,4,5,5]],9]] + +[[5,10],[10,6,[0,[7,4],[2,3,6]],0]] +[[3,[3,3,1,[5,2,1,5],[8,6,2]],[[9,10,4],2]],[7,[[5]]],[[]],[6,[],[[10,2,7]],[[9,7,3,6]]],[[[8,7,7,5,5]],5,8,2]] + +[[6,9],[3,[1,9,[]],10]] +[[[]],[3,10,[[2,4,2,1],7,9,3,[0,7,1,7,4]]],[[8,5,[],[0,2,7],9],7,7,[],[[],[9,7,7,2],[10,0,3,2]]],[[],[4,[6],6,[0,7,1,4,3]],2,[[1,6],0,[6]]],[[],1,[4,10,[3,8,9,2,8],5],[0,1,8,[3,4],8],[[10,8,2],1]]] + +[[9],[]] +[[9,[1,7,4]],[[[6,10,3,3,4],8,1,[8,2,2,1,1],2],[[4,9,9,0],[9,1],[7]]]] + +[[7,[[0,4,7],[5,1,9,7,6]],5]] +[[5,1,[[4,7,0,8,4],0],3,[]],[[[2,1],[8,3]]],[[],[],[[4,7],3,4,1,[5,6,6,0]]],[[4,9,10],2,[6,[1,10,9]]]] + +[[[4,[8,8,4,2],[2]],[[5,8,4,5,6],[2,4]],2],[[],8,[[6,1,0,9,0]],[2,6,[7,1,10,9,7],6,3]],[[0,6,[6,5]],10,10]] +[[3,[9,[6,2,1,7],9,5],8,9],[],[],[]] + +[[6],[],[7],[[[6,4,0],[10,7,1,2,0],[7,6,7,7],[3,6,10]],8]] +[[3,4,1],[4,4],[],[[1],5,5,10,[]],[[8,0],[8],[[5,1,10],3],[4],[[10,2,3],3,5]]] + +[[3,[1,2,[10,2,4,4],[],5]],[0,[],6],[10,[],[[],[1,4,10]],2]] +[[1,[5,[7,7,6],[10,8,10],9,[8,8,10]]],[],[[[3],[7]],[9,[4]],7]] + +[[8,3,[7,4,8,[7,3,0]],10]] +[[[8,0],[7],2]] + +[[[0],[6,8,9,2,[6]]],[[[2],10,3,[2]],8,2,2,3],[[5,5,[10,10,3,7],[9,1,7,8,7]],[10,1],[[1,10,7],6,[8,5,1,6],5]],[]] +[[[],2]] + +[[],[[4]]] +[[0,10,4],[[2],0,10],[]] + +[[[],[4],[[],7,5],0,[10,8]],[[9,[9,1,5,6,4],6,10,[2,1,9]],4],[[],[]],[6,[[]],0,5]] +[[7,[1,2,0]]] + +[[9],[[[9,3],8,[4,2,7,2,2],2,[10,6,1,0,8]],[3,2],[9],[7]],[[0],[[4,7],[],3,[],3],2,9,[]],[[],9,[2],3]] +[[3,2,[[7,0,3],[9],[1]],[8]],[],[[[],[10,8,4]],9,[],[]]] + +[[4,8,[6,3,[9]]],[[[],3,6,[7,3,3],[5,3,8]],[9,[],5,6,[6,0,2,4,4]],2,8],[]] +[[10,7,8,7,3],[[[9,8,2,1],[0,5],[9]]],[[[7,3,7,7,3]]],[[7,[],8],[9],[2,[1,4,8],[3,4,2,4,5],[],9],[9,[7]]],[[],5,[9,[10,6,5],[0,2,8]]]] + +[[1,[0],1],[]] +[[[[7,5,2,5,8],[8,10,1,4,6],10,[10,10,5,1],8],[[2,4,8,1],[],3,0,[2,4]],[[2,0],7,7,[4,3,6]],6],[],[[[6],1],[0,[0,9,3],3]],[5,6,7]] + +[[[],[],[[4,0,3],[],[3,3],[1,2,5,4,6],[5,8,0]],[7,[5],10,10,1]]] +[[],[[[1,1,5,3],6],4,8,7],[1,[[7],[]],10,0,[]],[[[],[5,2,2,5,4],8],8,2],[5,[9,[10,5,2,9,8],8],10,10]] + +[[3],[[[6,4]],9,1],[6,8]] +[[],[[[5],[5,3,2,10,7],10,[7,9,1,5],2],[6,8,[6,8,1,0,10]],[[]]],[[],4,[[],[5,2,10,1],0,8],4,10],[[],[3,[0,6,0],[5,1,4,4],3,[3,1,9,2]],[3,2,3,2,[6,6,7,6,5]],[],9]] + +[[5,9,3,[],[9,7,[]]]] +[[[0,9,8,[10,3],[10]],1,[3,[10,3,4,5],[8,4,2,3,6],[9,8,10,5,8]],[8,[5,3,7],[6,2,2],[5,9],[7,9,4]],[10,5,10]],[3],[1,0,[[8,8],[]]],[9,[],[5,8,[5,2,9,2,0],[10,4]],[[9,9,8,4,0],5],[]],[[[],[8,2]],[[9,9,6,6,7],[4],2,[]],[7,9]]] + +[[[6,[1],6,[1],9],[7,[6,2,1],[3,1,1,7]],[[9,5,1],5,[1,2,2,8,5],2,2]],[[]],[[9,6,4,0]]] +[[[],[[2],[1,5],[7,10,0,9,2],8,9]],[4,[8],4,6]] + +[[2,6,6],[10,10,4]] +[[[[1,7],5,0],3,10,3],[1,[7],0,[[9,6,3],[10,0,5,7],[10],[5,10]],3],[10,[]],[5,[6,2,10,7,[1]]]] + +[[3,[3,2,[8,6,2,6,10],[0],[]],[]],[5,[[],[8],[8],[8,5,2],[9,8,10,8,9]],7,[0,[7,6,7,2]],9]] +[[],[4],[[[10],[2,3,4],[7,3,4,0]],3,[10]],[3,[[4],6,10],[3,10,7,[],3]],[5,4,0,[],6]] + +[[[[0,7]],[9],[[],[],5,[7,6,8,0]],3]] +[[3,[[3,5],6,8],7],[[[3,4]],[],[0,[8,3,2,3,3],0,[5,10,3,7],[0,6]],[[2,2,3,10,10],9,[0],[]],[]]] + +[[3],[5,7,10,10]] +[[10],[],[[0,[9,2,9,0],[5],[7,6,2],[7,3,6,4,9]],10,[8],2,7],[[[7,3,2,3,9],[7,5,2,9],[10,10,3,4,8],[2,7,9,8],0],[[10,3,1,1],[0],6]]] + +[[[10,7,8]],[[],[1,[8,4,0]],2,7],[],[[[8,9,6]]]] +[[[]],[3,0]] + +[[6,4,[2,9,10],[[5],4,[],7],2]] +[[],[4,9,3,10],[4],[[[10,7],4,[8,10,4,2]],6,[5,3,5,1,[7,9,4]],[[]],[]]] + +[[7,[[4,7],7,[2,8,2]],5,7,[[5,0,7,8,0]]],[[5]],[[0,[3,9]],8,[1,4,2],[[10,1,3,5,0],[4],[],3]],[[[6,4],[4,9,9,4]],[],[]]] +[[5,[0,[6,8,7,3],2],[9,4,[7],[0,3,7]],3],[3,[[9,6]],[[],[4,7,6,8,0]]],[2,5],[9,2,5]] + +[[[[1,3]],8],[5,8,6,[0,[6,6,4],[]],7],[[7],[[],3,7,1],[],[[9,10,6],[5],[6,7,6],[3,3,3,8],[]],[[],7]],[],[7,[8,[1,8,1,0]],[4,1,[2,5],1],[[6,10]]]] +[[[10,9,[0,10,10,1]],[[9],[10,0,2],4,9]],[[[4,8]],0,[5,[3],4,3,4],3],[],[],[[]]] + +[[4,6,[[10,0,2,6],[3,5,8],3],3],[],[],[],[8]] +[[[],[[],4,10],9],[[3,[],[8,6,9],9,1],1,10,[[1,4,6],[0],2],[[1,7,9,7,0],[3,10],2,[2],[2,9]]]] + +[[],[[1,[6,2,10]]],[],[[[7,9,2,8],[5,1,2],9],3,[10]]] +[[[2]],[10,[10,6,8],8,[8,0,10,2],10]] + +[[2,8]] +[[[[5],[9,9,6],[1,8],[5,4,6,0,2]],[[5,9],[]],[7,[4,2,3,4],6]],[],[1,9,7,[6]]] diff --git a/2022/Day13CSharp/problem.txt b/2022/Day13CSharp/problem.txt new file mode 100644 index 0000000..b65d1a6 --- /dev/null +++ b/2022/Day13CSharp/problem.txt @@ -0,0 +1,148 @@ +--- Day 13: Distress Signal --- + +You climb the hill and again try contacting the Elves. However, you instead receive a signal you weren't expecting: a distress signal. + +Your handheld device must still not be working properly; the packets from the distress signal got decoded out of order. You'll need to re-order the list of received packets (your puzzle input) to decode the message. + +Your list consists of pairs of packets; pairs are separated by a blank line. You need to identify how many pairs of packets are in the right order. + +For example: + +[1,1,3,1,1] +[1,1,5,1,1] + +[[1],[2,3,4]] +[[1],4] + +[9] +[[8,7,6]] + +[[4,4],4,4] +[[4,4],4,4,4] + +[7,7,7,7] +[7,7,7] + +[] +[3] + +[[[]]] +[[]] + +[1,[2,[3,[4,[5,6,7]]]],8,9] +[1,[2,[3,[4,[5,6,0]]]],8,9] + +Packet data consists of lists and integers. Each list starts with [, ends with ], and contains zero or more comma-separated values (either integers or other lists). Each packet is always a list and appears on its own line. + +When comparing two values, the first value is called left and the second value is called right. Then: + + If both values are integers, the lower integer should come first. If the left integer is lower than the right integer, the inputs are in the right order. If the left integer is higher than the right integer, the inputs are not in the right order. Otherwise, the inputs are the same integer; continue checking the next part of the input. + If both values are lists, compare the first value of each list, then the second value, and so on. If the left list runs out of items first, the inputs are in the right order. If the right list runs out of items first, the inputs are not in the right order. If the lists are the same length and no comparison makes a decision about the order, continue checking the next part of the input. + If exactly one value is an integer, convert the integer to a list which contains that integer as its only value, then retry the comparison. For example, if comparing [0,0,0] and 2, convert the right value to [2] (a list containing 2); the result is then found by instead comparing [0,0,0] and [2]. + +Using these rules, you can determine which of the pairs in the example are in the right order: + +== Pair 1 == +- Compare [1,1,3,1,1] vs [1,1,5,1,1] + - Compare 1 vs 1 + - Compare 1 vs 1 + - Compare 3 vs 5 + - Left side is smaller, so inputs are in the right order + +== Pair 2 == +- Compare [[1],[2,3,4]] vs [[1],4] + - Compare [1] vs [1] + - Compare 1 vs 1 + - Compare [2,3,4] vs 4 + - Mixed types; convert right to [4] and retry comparison + - Compare [2,3,4] vs [4] + - Compare 2 vs 4 + - Left side is smaller, so inputs are in the right order + +== Pair 3 == +- Compare [9] vs [[8,7,6]] + - Compare 9 vs [8,7,6] + - Mixed types; convert left to [9] and retry comparison + - Compare [9] vs [8,7,6] + - Compare 9 vs 8 + - Right side is smaller, so inputs are not in the right order + +== Pair 4 == +- Compare [[4,4],4,4] vs [[4,4],4,4,4] + - Compare [4,4] vs [4,4] + - Compare 4 vs 4 + - Compare 4 vs 4 + - Compare 4 vs 4 + - Compare 4 vs 4 + - Left side ran out of items, so inputs are in the right order + +== Pair 5 == +- Compare [7,7,7,7] vs [7,7,7] + - Compare 7 vs 7 + - Compare 7 vs 7 + - Compare 7 vs 7 + - Right side ran out of items, so inputs are not in the right order + +== Pair 6 == +- Compare [] vs [3] + - Left side ran out of items, so inputs are in the right order + +== Pair 7 == +- Compare [[[]]] vs [[]] + - Compare [[]] vs [] + - Right side ran out of items, so inputs are not in the right order + +== Pair 8 == +- Compare [1,[2,[3,[4,[5,6,7]]]],8,9] vs [1,[2,[3,[4,[5,6,0]]]],8,9] + - Compare 1 vs 1 + - Compare [2,[3,[4,[5,6,7]]]] vs [2,[3,[4,[5,6,0]]]] + - Compare 2 vs 2 + - Compare [3,[4,[5,6,7]]] vs [3,[4,[5,6,0]]] + - Compare 3 vs 3 + - Compare [4,[5,6,7]] vs [4,[5,6,0]] + - Compare 4 vs 4 + - Compare [5,6,7] vs [5,6,0] + - Compare 5 vs 5 + - Compare 6 vs 6 + - Compare 7 vs 0 + - Right side is smaller, so inputs are not in the right order + +What are the indices of the pairs that are already in the right order? (The first pair has index 1, the second pair has index 2, and so on.) In the above example, the pairs in the right order are 1, 2, 4, and 6; the sum of these indices is 13. + +Determine which pairs of packets are already in the right order. What is the sum of the indices of those pairs? + +--- Part Two --- + +Now, you just need to put all of the packets in the right order. Disregard the blank lines in your list of received packets. + +The distress signal protocol also requires that you include two additional divider packets: + +[[2]] +[[6]] + +Using the same rules as before, organize all packets - the ones in your list of received packets as well as the two divider packets - into the correct order. + +For the example above, the result of putting the packets in the correct order is: + +[] +[[]] +[[[]]] +[1,1,3,1,1] +[1,1,5,1,1] +[[1],[2,3,4]] +[1,[2,[3,[4,[5,6,0]]]],8,9] +[1,[2,[3,[4,[5,6,7]]]],8,9] +[[1],4] +[[2]] +[3] +[[4,4],4,4] +[[4,4],4,4,4] +[[6]] +[7,7,7] +[7,7,7,7] +[[8,7,6]] +[9] + +Afterward, locate the divider packets. To find the decoder key for this distress signal, you need to determine the indices of the two divider packets and multiply them together. (The first packet is at index 1, the second packet is at index 2, and so on.) In this example, the divider packets are 10th and 14th, and so the decoder key is 140. + +Organize all of the packets into the correct order. What is the decoder key for the distress signal? diff --git a/2022/Day13CSharp/puzzle-input.txt b/2022/Day13CSharp/puzzle-input.txt new file mode 100644 index 0000000..13fc0c4 --- /dev/null +++ b/2022/Day13CSharp/puzzle-input.txt @@ -0,0 +1,449 @@ +[[0,5,[[],[],2,[7,9]]],[[8,8,3,[6,3,8,9,1]],[2,0,10,7,10],4,10,[9,[1,8],4,[4,0,5,10],[4,0,8,8]]],[9,10],[],[0,[[]],4,10]] +[[],[4,7,3,6,[2,[10],[2,5,10],5,2]],[[1,10,[6,9],3],[6,10,8,[1],[10,7,3]],[[7],[10,9,9,2],1,7],7],[3,7,9,[[4],0]],[[4],[[9],0,9,[]],[7,[],[],[5,7]]]] + +[[10,[[10,7,3,0,10],10],[[8,7,7,2,8]],0],[0,7,4],[2,10,[],[8,[7,10,10],1,0],[2,8,6]]] +[[[7,6,5,[]],[[10,0,4,1,6],[5,9,10,6],[1,5]],[7,[6],[10,5,6,7,1]]],[2,[3,[7],[4],7,[4,4]],[],0,[]],[5,[1,6,6],[8,9,[1,1]],[5]]] + +[[[[3,9],5,[5],[0],5],[],[4,[6,2,2],[10],[],7]],[[],0]] +[[],[[3],6],[10,[[4,1,10],[2,7,6,0],[0,8,9],[7,0,3,4,4],7],[[7],3,[3,2],[],4]],[[[10,2,7,8]]],[10]] + +[[10,6,7,0,[1,7]],[[[3,5,9,1,10],[],1,2,[0,9]]],[4,1,[4,4]],[1,2,2,5],[[5,[8],[]],7,[1,3,[4,1],5],[[10,7,9,2,2],[]],[[3,0,10,7],0,[],[0,3,9,7,3]]]] +[[[],[4,[5],4,[5,5,8,9,1]],[7,10,[8,8,6,2],[],[3,3,6,2]],[3,3]],[],[5,[4,[10,6,6],[]],[[0],[4,7,0],[2,9],[9,4,3,8]]],[[3,[7,0,2,10,3],1,10,10],0,9,[[8,1]],[2]],[8,[[10,2],5,[0],[8,3]],[5,[4,1],[9,8],[0],9]]] + +[[8]] +[[[[6,5,8,3],1,[1,5,5,5],[9,5,0,1],[7,0,0,4]],[[6],10,[3,2]],3,6,[10]],[4,[3,[1],10,[5,5,7,3]],[[6,2,5,0,5],[0],[7,5,4],[4,9]],[]],[],[[[4]],[4,[5,3,6,5,0],[2,6,1,6]],2,[[4,2,8,1],[6,2,7],[7,7,10,7],2],2]] + +[[],[],[[[7,9,4,8]],[[5,1]],[7,[8],[9,1,5,4],2,[]],4],[2],[[[2,10],[9,7],[3,6,9,9,7],5,2],8,0]] +[[],[0,1,6]] + +[[[[2,8],7,[]],[[7,6,10,3,2],3],4],[],[[[4,10],4,[1,3,8]],5,4],[[7],7],[]] +[[[]],[0],[3,[7,[5,3,2,5,6],2,[3,1],10],[8,10,[3,8]],7]] + +[[4],[[[7,9,8],3,6],[[],8,[2]]]] +[[[8,3,[3,5]],0],[3,[[9,2],[2],7,1],10],[[3,[0,6,6],10,[5],[1,7,0]]],[],[6]] + +[[6,8],[7,[[],[1,4,3,6],[7,8,9,2,10],8,7],8,9],[6,7,[[10]],[[4,8,9]]],[[[6,3,6,1]],[[8,10,10,0,5],[1,4,4,7,5],1,[0,2,1],5]],[5,5,[[2],10,[],6]]] +[[[[],4,7,0,7],[[1,2],0,[7,1,4],[6,2],[8,6,2,1]],0]] + +[[2,[[5,4,10],3,[9,0,8,7,4],4,6]],[[[8,10,7]],[2,[]],5],[[]],[4,9,[],7],[9,[[6],0,[]],[7,[],2],0]] +[[[[5,5,0,2,9],6,2,1],[10],[[4],[10,6,6,10],[]]],[],[6,[]],[0,1]] + +[[9,6,[3],[1,5,[9,2,4],[4,1,6],[]],[[]]]] +[[5],[9,[],3,8]] + +[[8,[[7],1,8,[2,6,4],8]],[]] +[[],[],[[0,[],9,[0]],[[3],[4,6],[8,6,5,8,0]],6],[],[]] + +[[10,0,[[],5,[4,4,10,9,8]],8],[],[3,[[0,3]]]] +[[[[0,9,4],[7,3,9,4]],[4,[0,5,7,10,3],0,9]]] + +[[[[0,8,8,0,4],[7,10,5,10,6],9,8,10],[[0],[],[0],10]],[9,8,[[8,7,5,5,10]]],[1,[10,4,1,[10,4,10,0,1]]],[[[1,9],9,5],3,1,[[7,6]],[]]] +[[3,1,[[9,5,8],7],[3]],[[9],7,4,[]]] + +[[7,3]] +[[[[4,2],[3,3],4,7,[1,2]],5],[[6,[2,9],[10,3,6,4,2],[2],3]]] + +[[[6,[]],[[4]]],[],[3,[[7,2,1],[],[8,9,9,10],[9],10],9,1]] +[[[1,7,[7]],10],[[6,8,2,[0,9],2]]] + +[[[2],9],[[[2],[5,4,0,9]],[10,3,2,[0,0]],[[1,6,10,0,1],[3,5,6,7],[8],[1]]],[[8],[6,10],8],[9,0]] +[[]] + +[[[],[4,3],6,[[],[9,5,3,9],[9,5],2,3],5],[4,[2,2,9,6,5],2],[[],2,[[],[5,6,6]],[10,[7,2,4,2,9],8]]] +[[5,[7,[],[0,4,3,10],4,9],10,[[4,8]],10],[[[2,5,5],6,0,[5],[9,3,2,10]],[[5,4,8],[3],[1]]]] + +[[5,[[7,2,1,10,0]],[1,[4,0,5]]],[0],[[],10,[]],[10,[[9,3],[0],3],[7,9,3,[]],1]] +[[[4,2],1,4,7],[[[],9,[3,5,8,7,6]]],[[6,3,4,[8,2,5,2,5],[9,8,3,1,9]],1,[[10,9]],[[1,4,1],1,8,[2],[10,3]],10],[[[],1,1,[]],0,9],[7,[6,[7,2,2,6,0],7,5],[[3,10,10,0],1,[1,8,4],[1,1]],[[7,7,6,2,4],2]]] + +[[5,7],[],[6,[4,8]],[8,[3,[10,2,0,5,6],[9,0,7,8,8],[0]]],[2,4,7,[]]] +[[],[4,[5,0,3,6]],[5],[]] + +[[1,1,8],[[[1,10,3],1,[6,6,6],6]]] +[[[4,10],0,9,[[1],[3,5],[10],4,[7]],1]] + +[[[0,5,10,2]],[[]]] +[[[8]],[[[8,9,0]],10,[[9,7,5,3,6],[9,7,3]]],[6],[2,[[4,7],[6,9,8],[10,0,8,0,0],[9,4,3,10]]]] + +[[[],[[],7,[10,1,8,4,0],6,[10,2,2,6]],[[5,7,10],[9,9,5,5,0],6,[6,2],10]],[],[]] +[[],[7],[[[7,3],6,8,9,[2]],[[7,8,6,2],[],9],3,[[9,0,8,10],9,[1,9,7,0],[6,9,1],8]]] + +[[8,[[10,8,5],[],[4,0,6]]]] +[[3,4,[0,3,7],2],[[2,6,9,4,0],[1,[6,10],10,[4,5,1,9],0],[10]],[7,[[0,2],[3,5,10,1],9,[6,9,0,1]],8,9],[],[[[1,10,8,10,7],[4,9,5,2,1],5],10,4,7]] + +[[[[9,9,4,6,8]],3,2,10,6],[[[2,0],6,[9,10,0,1],[1,0,7,7,1]],[9,10,3,[1]]],[4,6,2,[2,2,5,[9],3],4],[[8],10,[9,[],[],[1]],8,[[],3]],[4,4,[10],7]] +[[[9,[9],[4,0,10],[3,0,4,4]],8,[0,[4,8,0,5],[5,2],[0]],8,1],[6,0],[5,0,3,4],[[[2]],1],[]] + +[[[10,3],6,6,10]] +[[[7]],[],[[0,[0,3,7],[],[5,0,2,6]],[2,[8,9,3,9]],[]]] + +[[],[[1,8,[0,10,3,7,2],5]],[[9,[4,7,7,6,10],[4,9,3]]],[[[9,4,4,9]]],[[[9,6,8,1]],2,4,[],5]] +[[1,[],[10,6],9]] + +[[3,1,4,8],[[],[1]],[]] +[[2,[5,[]],[]],[[2,1,8,6,[4,10,2,7,3]],4,[[9,0,2,3,7],8,10,4],5,[[],[10,9]]],[[4,[9,6,3,9],2,0]],[[[3]],[]]] + +[[1,[9],[[],4,[7,9,9],[1,4],[2,6,4]],3,2],[[],6],[[[0,7,3,2],2,2,[5],[3,7,8,3]],10,1],[[[],[],0,[0],[7,4,5]]],[[9,[3,3],[6,8],[10]],2]] +[[9,7,[],[0],0]] + +[[],[[5,5],[9],10,2],[],[[6,4,[5,6,9,1,2],2,8]]] +[[[[8,3,5,10,1],[3,4]],[9],[[3,10],9,7,[]],6],[2,10,[10,2,0],[0],[1,1,[2,4,0,8],[7,1,6,3],[8,10,8,1,4]]],[[[0,9]],[[7,2,1,3,4],6,[7,5]]],[8,10],[7,6]] + +[[],[[[10,8,8,6,2],2,10,[8,6,7,7,3]],9,1,[[3],9,9],[[5,2,9],2,0,[10,1],5]],[[],6,1],[[[3,2,4,7,3],[],9,[9,2,3],3]],[[[]],1,7]] +[[7,[[7,2,8,9],9],[8,[0,3],[3,5],[5,8]]],[9,[0,3,10,1],[[4,8],4,[3,7,5],[6,2]],[[],6,[5,2]]]] + +[[],[0,[[0,0,1,3,8]],6]] +[[10,6,8,8,[]],[9,[[7,4,8,1,4],6,[7,4,5],1],[[7,3,10,5],2],[[1],0,1,7],[6]],[[7,[4,7,9,6],[9],[6,3,3,3]],[6,[10,0,5,8],10,1,6],7,[9,0,2,1,9]]] + +[[1,[[4,1]],7],[],[[6,0,5,[9,10,0,6,0]]],[[6,[],[]],[[9,2],9,7],7],[8,10]] +[[[6,4,8],[8],0,[5],2],[7,6,7,1],[10,10]] + +[[[[10,8,9,6,10],5,4,0,8],[[7,1,5,0,8],[2,5,5,4,2]],[[2,2]]],[[[6,2],1,[],3],[8,3,5,1],[[7],[0,4,2],4,[0,2,6],[1,6,3]]],[6,[3,0,[6,8]]],[[[9],[6],9,[2,3,9]],5,[7,[8]]]] +[[5,4]] + +[[[[],[2,1,4,2],3],[1,9,[8,2,4,10]],[5]],[[1,2,[10],7],10]] +[[7,[],[[10,5],5,1],[5]],[3,3],[1,7],[[[1],9],1],[9,[[7,2,6,6,0],[]],[],[]]] + +[[1],[[],3,[4]],[0,9],[[[10,10,6,8,9],4,3]]] +[[[10,10,4,3,[7,10,7]]],[[3,10,9,[8,6,10,5],1],[[7,7],1,0],[5,[4,8,7],6,4,5],1,[[3,5,5,8],[5,9]]]] + +[[0,4],[[]],[[4,3,1,4],2,[8,2,1],1]] +[[[0,[4]],[[0,6,0],4,8],[10],5],[],[[4,[10,1,8]],8,[]],[7],[]] + +[[[[7,7,3,4],[4,5,0,8],2,[1,6,5,10]],[[2,0,1],10,[2],4],1,2,[10,[7,7,7,2],[]]]] +[[[10,[8,3,0,5,4],6,3,[4]],2],[[10,6,[],[10]],2,5],[[]],[[],[8]]] + +[[[7,5]],[[[7,5,4,1,2],8,9,[7,10,6],10],[[8,3,2],[1,1,5,4,4],2],0,5,6],[],[5,7],[5]] +[[3,[[4,2],5,10,8],10,[[5,8,8],3,[6]]],[[[4,7,9,3,4],0,[9],4],[[9,9,3]],[10,6,[3,9,10,1]],2],[9,8]] + +[[5],[7,10,[7,[7,5,5,10]],[[3,8,9,10],[],[3,6],5,5]]] +[[[],6,[[],7,5,[6,3,2,10,5]]],[]] + +[[[[4],5],[10,4,[6,2,1,3,3]],8,[[]],1]] +[[5,[]],[[[3,7,7],[2],2]],[6,7,[[6,1,3,5,8],[0,0],2,[10,8]],[9,[2,10,5,0]],4],[0,1,[1,[7,1]],9,[6,1,2]]] + +[[8],[[[7,7,6,3]],6,5],[[6,10,2,1],[[],9],[5,[],7,3,[9,4,0,2]],[[10,1,9,1,2],9,8]],[]] +[[],[[3,[7,1],0,6,[3,8,3,10,4]],9],[6,4],[10,[9,8,[2,6,0],[2,3,0,0]],[[10,7],[9],3],8],[10,[],[8,[3,5,0,9,1]]]] + +[[10,3,4,9,3]] +[[[4,[7,9,9,2,7],[],[],4],3],[1,9],[]] + +[[10],[[[0,4,2]],3,8],[7,[0,[2,10,4,3],[5,1,5],2,10],[7,[],1,[],[1,9,7,4,7]]]] +[[5,[3,[7,6]],[6,7],2],[4,[2,[]],[[6,10,4,10],[5,1,0],10,5,1],[[4,10,0,7,5],4]],[]] + +[[[[6],10],1,[[10]],9],[7,4,10,10],[2,0,[8,0]],[8,9],[6,[[10,2,7,0,1],1,[0,5,3,7,2],[6]],4]] +[[[[],[2,2,6,0],[5,10,0,10,0]],3,[[3,7],3],5],[],[[],3],[7,[[7,4,8],9,2,[2]],[[1,3],[5,3,2],10],[10,3,[10,6,9,3]],[7,[9,6,0]]]] + +[[2,[[3,8,10,9,7],[2,5],[],10,0],[1,8,2,[]]],[10,[5,[2,8,2],5,3]]] +[[],[0,[]],[[1,[],[0,7,0,1,8],[]],[[4,1,8,5],[5,10]]]] + +[[[[3,9,9,9,7],3],[0,[6,2,6,4,7],2,[7,9,9,7,8],[0,3,1,5]],[1,[2],[8,5,8,8,10],[7,3,2,10],[2,7,8]],7],[[],7,3,[9,6]],[[2,[0,8]],[1,4,[8,3,0,10]]]] +[[[]]] + +[[8,2,3,1,0],[2,[5,[3,5,0,3],7],3,[1]],[10,[[9,4,0],3,[2,0],6],[[]],10]] +[[[[9,3,0],[6,9,6,10],2,[],[5,9]],0],[3,5,[],[4,9,[0,0]]]] + +[[6,2,[6,[4,0],[4,5,8,7,1]],[[0,0,1],[9,5,3,1],2,[5],[1,5,7,4]],4],[8,[],[[0],[],[4,5]]],[6,[[10]],1,[1,5,1,10,[7,5,8,2,7]],[[7,1,2,1]]],[6,2,7,[6,[4,3]],[[7],10,[3],4]]] +[[[[3,1,4,10,3],3],8],[3],[1,[5,[5],8,[9,10]],[[]],[4,[1],8,[]],[[],5]]] + +[[[10,6],[[1],6,0],[9,2,2],[4,[4,6,10,7,9]],6],[],[[],3,1,4,10],[]] +[[[10,[4,1,7,7],9]],[[[3],[4],[1,3,0]],8],[[7],[6,[0,6,0],[1,8,5,3],[0]],0,6],[],[9]] + +[[1,1,[6,[],6,[2,4,10],[9,10,4,3,7]],7,2]] +[[[[0,9,2,6],[0,10,1,8,7],[10,10,6,1],5,[9,2,9,1]],[3],5,10],[0,[[3,1,10,8],[],[],[7,9]],[[10,1,2,10]]],[[1,[10]],[],[[2,4,0,1,5],1,4,3],9,[2,[3,7],[],8]]] + +[[[6,1,7,7],4,[[6]],[[6],[9,4],[3]]],[[],[[10,0,2],[9,1,10,1,6],1,[1,8,2],[]]],[],[[],9,[6,0,2],[[],3,9,[6],[1,0,6]]],[[2,[6,7,7,6,7],2,[4,0,0,3,2]],[7],[8,[4,10,0,7,2]],0,4]] +[[4,[[10],2],[]],[[3,[2],[10,0],2],6,2],[[3,[],[],[5,5],6],[0,6],5,[3],[7,[3,8,1,3],6,10]]] + +[[],[1,[[],4,[1,10],[5,6,7],[7,8,1,2]]],[[8,1],[0,[]],2,[]]] +[[[[5,5,5],9,9],[],[0,[4,6,9],9,7],4],[[[],0],8,[1,[0,0,10,9,4],[3,5]]],[[8,1],[[]],[[3,5],3,[4,10],4],[9,[8,0,6,10,7],[3,4],10],7]] + +[[3,[[0,0,10,10,0],6,[7,8,5,10,9],[3,5,1],[10,1,9,7]],7,[10,3,[0,5,8]],10]] +[[],[[],[[10],8,[3,5,2],[10,4,0]]]] + +[[1,8,[[],1,7]],[4],[[[2,6,8,10],0,3,5],[[8,6,7],9,[],[4,2,2,1,0]]],[6,10,0,[[8,0,6,4],[9,7]],5]] +[[2,[3,[5,0,9],7],[[1,4],1,2,[10,8,8,0]],[4,8,2,4]],[9,[],[[3,4,6],[2],[4,6,10,5],0],4]] + +[[6,4,[2,[9,5,8,2,1],10,5],[[6,7,8]],2],[],[]] +[[1,[5]]] + +[[],[5],[5,[2,[0]],[[5,0,3],4,8,0],3,1]] +[[9],[[[8,8,3,5],[1,1,2],10]],[1],[[[]],[[8,6,8,9,8],7],[10,4,10,[1,3,3,7]],4],[]] + +[] +[[[[]],5,[9,[],9,[6,4,1,3]],7],[10,5],[2,9,[[4,1]],6,3],[[6,1,[4,0,10],[3],2],4,[]],[[5],[[2,1,8,7,6],9],[6,6,[10,7,6,5,8],[2,6]],[],7]] + +[10,6,2,5] +[10,6,2,5,4] + +[[[],6],[],[],[]] +[[],[[],[5,2,[9],[]],2]] + +[[1,1,1,2],[],[[9,6,2,9]],[],[7,7,1,[8,4],5]] +[[[7,7,0,4,[2,9,4,7,1]],2,10,[10,[],[5],6],3],[[],[[7],[10,10,4,9,0],[10],1],[],[[10,0,10,9,1],[0,8,2,10],4]],[6],[],[2,5,3]] + +[[],[[2,8,[1],[5,2,5,2],[2,9]],[10],[10,6,7,[0,4,8,10,2],[]],[]],[[10,[2,2,0,5],2],[[6,0,3,8,5],[9],[],10],[],[[8,7,10],6,8,3]],[[[5],5,5,[0,3],[10,3]],[1,4,5,[]]],[1,2]] +[[[[],8,4,8]],[],[]] + +[[[[10,4,6],[],1,[]],[[3,4],[7,5,4,2],[],0,[10,10]],[[0],[6],[6,5,2,10,4],3,6],[[8,10,4,3],2,0,[3,4,8]],5],[[[3],7,3,[5,5,4,2]]]] +[[[7],1,7]] + +[[0,6],[[],[[9,8,10,2],[0,9,5]]],[2,[],9,[[],8,[2,4]]],[4,6,0,3,4],[[[3]],0]] +[[[[6]],5],[[9,[6,10,0,7],[3,8,7,4]],0,[],[[1],[7,4]]],[[[1,5,6],6]]] + +[[3],[[[7,7,2,0,7]],[0,4,10,7,[10,0,4,1,6]],[[4,7,9],5],[[6]],7],[[[5],[],[],[1,5,10,6],3]]] +[[5,[7,3,[9,4,10,7],[1,4,10,4],[]],[9,2,1]],[1,7,[[],[0]],7,0],[],[2,[[5,1,0,7]]]] + +[[8],[7,0],[6,5,[[],[],8,[5],1],7,[]]] +[[8],[],[7]] + +[[[],[[6,1,6,9,8],1],[[8,7,8,0],10,[8],8]],[[[]],[[6,6,9,5],[0,2],7,3,[5,9]]],[]] +[[],[0,[[],[7,5],[3,10,7],7],[[9,4],10],[[5,7,8,7]],[]],[],[8,9,3,6]] + +[[[[9,8],6],3,0,[[3,7],[5,1,0,2],10]],[7]] +[[],[],[6,0,10,[],[2]],[[[1]],[7,3,[10,10]]]] + +[[8,[8,10,6,4,10],[],1,[[8,0,1],9]],[0,0,3],[],[[[],[3,6],8,[]],1]] +[[9,[[6,3,3,7],5,[2,9,5,8,0],[6,7,8,4],10],[3,4,[8,4,1,10,10]]]] + +[[2,[[4],[0,8,3,10,4]]]] +[[[2,[0]],[5,[3,4,1,0],6,[1],1],3,4,9],[6,1,3,6],[7,[10,0,1,[8,10,8,0,6]],9,[[8,4,2],0,6,8,0]],[],[[[6,0,6,8],1]]] + +[[6,[[9,10,4,3,9],1],9],[[[9,2],[],[3,2]],[[4,7,8,3,5],0,[5],[10,5,6,0,6],[2,10,3,6,8]],[6,[]],[5,[4,5,9,10],[1,0,1]]],[[[2,1,9,9],[10,6,4,1,8],[],5,[2,10]],8,[[1,1,8],4,[2,4,0]],7]] +[[10,[1,[2,3,0,6,9],1,[],[8,4,1,6,1]],3],[[[2],[]],[],7],[],[2,6],[10,4,6,6,[[],[9,8]]]] + +[[10],[[9,[8,9,5],3,9],7],[[[9,8,10,5],3,6],10,5,10],[5,1]] +[[2,3,[]],[1,[[2,1],5,3,[7],0],5,[]],[[],[1,4,[]],[6,[1,4,8,3],9,[2,3],8],10,3]] + +[[[],[9]],[[[7,2],9,[4,8,6],[0,3,9],[8,8,1,4,1]],7]] +[[2,[10,6,[5,0,9,5]],10],[[[3,3],6],[[6,8,2,5],[8,6,0,5]],[[1,7],4]],[0,[[3],[]],[[2,6,9,1],9,[4,2,5,0,2],9,[7]],[9,7,6,[2,2,9,5]],6],[[3,4,[6,9]],2,[4],3,[[1,9],[0,2]]]] + +[9,0,10,9,1] +[9,0,10,9] + +[[[5],[7,0,9,2],2],[[3,[0],[]]],[6,[]]] +[[3,[2,[0,4,5,1],[9,0]]],[9,2,[6],[3]]] + +[[[9],[0]],[1],[[[4,5]],3,10,5,10],[8,9,0,1],[[2,[10,5,5,2,3],[9,2,1,0,4]],[1,10,7,[10,9,7,4]],1,1]] +[[0,2],[8,[[9,4,9,2],10,[9,8],4],7,5,6],[6,5]] + +[[],[4,[[7,1,3,7]],[]],[],[[[],2,[3],3],[[7,0],6],3,[7,4],[]]] +[[4,8,6,2],[[[]],6,10,[[4,10,5,0,1],6,6],[]],[1]] + +[[[[7,8,0,9,3],[8]],[[6,10],[10],2,0,1]],[],[[1,[3,9,4],0,[]],[[],2],[8,[8],[5,7],[],9],[2,10],7],[3,[2,[3,8,5],3,2],6],[[1,[3],[4,10,3],5,[6,5]],[[]],2,[],4]] +[[[],[6,6,[10],7],[10,[10,8],5,[10,8,3]],[5,10,4,8]],[3,10,6],[[[2,2],[5,2],[3,0,10,0,4]],[[8,9,2,9,0],1],1,[[10],6,0,8]],[8,[10,6,[1,3,9]],7,8,[3,[6,10],[7,6,4,5,1],[10],3]]] + +[[[[5,9],[1,1]],3],[],[6]] +[[6,[9,7],[[6,0,7,10],[10,6],[4,3,3,7],10,[4,6,4,4,10]]],[1,[[2,0,0],[7,0,10,1,7],[9]],[10],4],[[8,10,9,[6,7,0,2,7],10],[[6]],[],[9],[]]] + +[[0,7,[[3],[0,3,6,8],[7,8,4]],[]],[3,[9,5],9,[4,5,[6,8,2],[7,3],7]],[]] +[[],[[[3],[5,7,10,7],9,[3,9,6,5,7]],[[10],[4,3,10,9,3],[]]],[[[0,5,7,3,2]]]] + +[[10,7,0],[],[1,5,7,[],5],[1,4,[0,4,[3],[2]]],[[4],7,7,[9,1],9]] +[[2,[2,[],[5,7,2,1,6],[8,9],[7,7]],[]],[1,3,[[],[3,9]],[6,2]]] + +[[3,3,0,[4]],[],[[7,0,[2,1,5,4,1],7,[0]]],[8,[6,3,4,7],10,[3]]] +[[[1,[1,8,8,10,0],[5,7,6],[5,1],8],[3,0]],[[7,[],9,6,[9]],4,[[2,3,0],6],[],5],[10,[],[[],10,[5,9,3,2]],[1,3,[],0]],[6,[[2],1,4,3,4],7,2],[1,[[3],10,3],6,9,[[3,8,3,8],2,[4],9,9]]] + +[[[8,[3,8],[0,5],[8,8,2,4,7]],[4,[4]]],[1,7,8,2],[[1,7],[[3],3,[8,3],[6,4,2]],3,[[8,3,6,9,1],[4],[6,5,1]],[[3,6,1,5]]]] +[[4],[]] + +[[5,[[0,9],[10,10,10,2,2],[1,5,8,2],[8,4,9,0]],9],[[6,[8,8,5,4,7],8,[],[7,9]],8,[],[[7],7,8,[2,2,0]]],[[[2,4],7],[8,6,[],[9,1]],[],[10],[[6,7,0,5,5],4,7,[5,1,9,10]]],[],[[[1,3,1,0],[7,7]],[6]]] +[[[[8]],6,[[6],[],9]],[[[1,3],2,4,9,7],[5,[4],0,1],6],[5],[[],1,[],[[8,1,2,10,7],[7,9],9,5,4],1],[]] + +[[[],5]] +[[4,[],9,6],[2,1,[[4,5,10,0,1],10,1]],[],[7,[[2,2]],9,[[3,0,7,5,1],[1,10],2,[]]]] + +[[[9,4,[2,2,5,1]],[7,0,[9,2,1,9,6],5,[7,8,0,5]],[[8]]]] +[[[4,6],[[],[],3]],[],[[[4],9,[9,2,5]],[6,[1,7,6],[9,3,1,2,9]],[[2,3,0],4,0],[2,4,[0]],4],[10,[3,10,6],[1,10,5],9]] + +[[[0,8,2],6,[[4,0,4,7],[1],[2,8]],[[3],10,5,4,[8,0,9,4,0]],8]] +[[[],[],5,[[8,0]],0],[9,6]] + +[[[]],[10,4],[10]] +[[],[[3,[]],[6,[6,6,2,2]]],[[0,9,10,7,[8,4]],6,5,[[1,8,2,2,10],9]],[[[8,7,0],5,3],4]] + +[[],[4,[6,[2]],[[3,10],[3,2,0],3],[[],10,[9,8,0,2,9]]]] +[[[[6,1,0,10],9],[6,[2,4,10,10,10],3,6,[6]],[],7,5],[[],[7,[10],5],[[2,3,2],0],1],[[[],10,5],[[7],[],5,[8,1]],3,10]] + +[[9],[4,[3,5],7,4,7],[[],[5,2,[1,4,0]],[6,[1,9,3,3],[]],6,10]] +[[[[3,2,0,5],4],[7,[3],[6,7,0,5],0]],[9,4,9,2],[[]],[[[2,7]],[10,9,8],8],[]] + +[[],[4,[6,10],6,[[],7],[[3,0,5]]]] +[[[[1,3]]]] + +[[],[[[],9],[5,[2,8],[6,7]]]] +[[8,4]] + +[[4,[2,2,[1,8,3,6,5]]],[2]] +[[5,4,[[7,4,8]],1,0],[10,[],[[1]],[5,[]]]] + +[[10],[],[3,1,[[],0,0],0],[[9,6],2,[[9,9,8,2]]]] +[[10,[4],[[],[5,5],7,[3,1,2,10,0],10],1],[3],[[],9]] + +[[[[5,6,8,3]],1,[5],10],[[[2,3,5,3,6],0,10,[2,3,7]],[]]] +[[[[],[2,1,10],[],[4]],[[6,1,1],10,4]]] + +[[8,[9,[2],[0,6,2,3,7]],4]] +[[[3,[6,5,1,6,10],[1,5,4,1,3]],[7],[],[10,10,4],[[9,4],[7,4],0,2,[2,5,6,7,4]]],[[],[8,4,3,[0,7,6,7,5],6],[[10]],[[1,7,9,5,8],[1,4,5,9,6]]],[6,2,[]],[]] + +[[[[2,7],0,[2],[0,0,0,10],[]]],[2,[[2,8,9,3,3],4,4],9,[1],[10,3,[8,7],[9,6],5]],[[[],[9],[6,5,3]]],[[0,[7,3,0],[],[]]]] +[[],[[4,0,[5,0],[8,9,4],[10,6,9,6,1]],[0,[1,3,10,9],0,5],1]] + +[[[10],[[9,1,1,3],8,10,6],[[0,7,6,7],8,[7,10],[10,8,0,2,8],[7,7,10,1]],8,[2,0,[4,9,6],4,[2,5,5]]],[10]] +[[10,[],5],[3]] + +[[[[3,5,7,8,5]]],[[[8],[2,7,8,2],[8,6],[5,9,10,2]]],[[],[[]],10,[[7,5],6,[]],[9,[5,3,8,0],5,5,2]]] +[[[[9],4]],[5,9,8,[]],[[]]] + +[[],[[[4,2,4]]],[4,9,8,[3,0,[3,6,3,1,5]]]] +[[7,[[1,9,7,5,0]],[]],[1,[6],3,9],[3,2,1,[[2]],8],[[[10,5],[8],10]]] + +[[],[8,5,[[]]],[],[[9,0],[],2,9,8]] +[[2,0,[5,3],6],[[],[10,[0,5,9,9,10],7,[5,8,1,8],[8]]]] + +[[[]],[[0,6,[7,8,0],3,[9,6,2,5,2]]]] +[[],[[],[]],[[[],2]],[1,9,2,8,6]] + +[[],[[[9,2,5],[3],3],1],[7,[[]],[7,6,[7]],[[],[8,0,2,9,9],5,7],1],[[2,[7,4,4],3],[[6,9],[1,10,0,7]],[5],10,3],[]] +[[[],[[0,4,5,4,6],1]]] + +[[2,5,6],[[[4,7,4,6]],8,4,4,[[8,4,3],[5,1,8],5,[6,4,0,6,0]]]] +[[6,[[1,5],0,3,7],[],[]],[],[[[1,3,8,0],[6,2,1,0],9,1]],[0,[[0,9,1,7]],[0,1,[1,6]],7]] + +[[[3,[4,2,8,0]],0],[0,[[8,3,5]],[7,7,[],10,[0,2,2,4,6]]],[6,[[6,9,8]],[0,[4,9,6,0,9]],[],6]] +[[],[6,10,[],[[0,1,5],1],0],[[]]] + +[[[[3,10,1,6],[5,0,9,9],[10,10,10]],6,[3,9],8],[[[1,7,2,6],[],9],6,3,[8,9,[5,5],[0,5,9,4,5],[]]],[10],[[2,0],[[0,1,2],[],[10,5,2],4],2,[[6],[],0,[1,5],2]]] +[[[9,6,[5,8,9]]]] + +[[4,[[7,0],1,[8,0],1,7],[],[[2],[1,6],[0,5,3],[0]],[[8,10,5]]]] +[[3,6,[[],2,1],4,[[1],5,9,[10,0,0,5]]],[[1,[2,1],6,10,1],8,[3,[4,0],4,1],[]]] + +[[6,9,1],[],[2,4],[[2,5,[]],[[6,7,10,5],4,9],5]] +[[[0,3,4,8,[0,9]],8,10],[[[4,0],[8,8,2,9],[],5,1],[5,[0,0,5,9],[5,10],7],8,[4,[3,0,4,7,0],5],[[9]]],[5,1,6,10],[]] + +[[6,[1,2,10,[]]],[[],10,1,9,[[9,5,7],3,[4,5,10,5],5,[1]]],[]] +[[[[10,7],1,1,4],10,6,[7],[10,5,[]]],[1],[[[8,2,5,7],[],[],8],[],[6,4,[],[10,8]]],[9,1]] + +[[4,[[],1],[5,[6],0,1,[9,0]],[[7,6,2,1,10],[0,5],[3,4],1,[8,2,4]],[9,3,1,[]]],[]] +[[[[0],1,[5],7,[4,0,1,7,1]],[10,10,[1,9,9,4,6],9],[[4],6,[0,0,10,0]],4]] + +[[0,10,[0,[10,10,6,7,1]],4,[[0],[7,10,5]]],[]] +[[10,[],6,[10],[10,[2,5,4],3,3,0]],[9]] + +[[],[[[7,1,2,9,4]],8,[8,5,7,3,[9,10,4,9,1]],[3,[6],[1],7],10]] +[[[],[0,8,[3,6]],10,[[10,0],[6,8,5],2,8,[5,10,2,0,5]],10],[[[6,0]],5,8]] + +[[7,[[10,0,4],7],[0,[3,7,7,10,3],10,[2,4,2,0,10],6]]] +[[5,5,9]] + +[[3,[10,[10],4,0]],[[[3,7,7],[0],[]],0],[[10,6,9,7],[5,[3,7]],[[7,9,8],0,5],10],[],[0,5,10,8]] +[[0,[10,1],10],[8],[7,[4,3,5,[2,5,6,3]],[[2,0,10,4],[7],[9,9,6],[1,5]]],[]] + +[[],[],[7,[2,9,0]],[]] +[[[[3,5,0],9],1,7,9],[1,[[9,2],[5,3,0,10],[9],0,[0,8]],[[10,0],7,[4,8],1,0],[[7,7,3]]]] + +[[],[],[],[],[[4,1,6,[],10],[[7,2,2,1,1],[],[5],[8,8,7]],1]] +[[0,[[8,9],[10,0,9],5,5]],[[]]] + +[[10,[10,9,[10,0,2,2,2]]],[[1,5,[10,9,7,6]],3]] +[[0,6],[10,[[4,5,7,0],3],2],[]] + +[[[[8,10,3]],[[10,3,10,4,0],5,[1,5],2],3],[6,[5,[3,10,3,4],[1,1,10,0,6],2],10,[],[[10],7,6,2,10]],[[[7,10],4,2,[],[5,0]]]] +[[],[]] + +[[[3,[10,2]],[[2]]],[[[8,5],[0],4,[],[5]],[4,[7,2],[9,1,8,7],[7,7],5],[],[10,[8,7,5,3],3,[],[8,4,2,7,2]],[[1,8,4,5]]]] +[[0,[3,8,9,8],[1,6,1]],[[],[],[0,[4],5,5,[1,7]]],[3,[[6,1],2],[],[[7,10,4,4],[6,9,9]]]] + +[[7,[9,9],7,6]] +[[1,[]],[[],0],[3,[6],[[6],1,5,3]],[1,[],[[5,4,9,10],5,5],[],[[1]]]] + +[[6,0]] +[[[[2,3],4,[6,4,5,5]],9]] + +[[5,10],[10,6,[0,[7,4],[2,3,6]],0]] +[[3,[3,3,1,[5,2,1,5],[8,6,2]],[[9,10,4],2]],[7,[[5]]],[[]],[6,[],[[10,2,7]],[[9,7,3,6]]],[[[8,7,7,5,5]],5,8,2]] + +[[6,9],[3,[1,9,[]],10]] +[[[]],[3,10,[[2,4,2,1],7,9,3,[0,7,1,7,4]]],[[8,5,[],[0,2,7],9],7,7,[],[[],[9,7,7,2],[10,0,3,2]]],[[],[4,[6],6,[0,7,1,4,3]],2,[[1,6],0,[6]]],[[],1,[4,10,[3,8,9,2,8],5],[0,1,8,[3,4],8],[[10,8,2],1]]] + +[[9],[]] +[[9,[1,7,4]],[[[6,10,3,3,4],8,1,[8,2,2,1,1],2],[[4,9,9,0],[9,1],[7]]]] + +[[7,[[0,4,7],[5,1,9,7,6]],5]] +[[5,1,[[4,7,0,8,4],0],3,[]],[[[2,1],[8,3]]],[[],[],[[4,7],3,4,1,[5,6,6,0]]],[[4,9,10],2,[6,[1,10,9]]]] + +[[[4,[8,8,4,2],[2]],[[5,8,4,5,6],[2,4]],2],[[],8,[[6,1,0,9,0]],[2,6,[7,1,10,9,7],6,3]],[[0,6,[6,5]],10,10]] +[[3,[9,[6,2,1,7],9,5],8,9],[],[],[]] + +[[6],[],[7],[[[6,4,0],[10,7,1,2,0],[7,6,7,7],[3,6,10]],8]] +[[3,4,1],[4,4],[],[[1],5,5,10,[]],[[8,0],[8],[[5,1,10],3],[4],[[10,2,3],3,5]]] + +[[3,[1,2,[10,2,4,4],[],5]],[0,[],6],[10,[],[[],[1,4,10]],2]] +[[1,[5,[7,7,6],[10,8,10],9,[8,8,10]]],[],[[[3],[7]],[9,[4]],7]] + +[[8,3,[7,4,8,[7,3,0]],10]] +[[[8,0],[7],2]] + +[[[0],[6,8,9,2,[6]]],[[[2],10,3,[2]],8,2,2,3],[[5,5,[10,10,3,7],[9,1,7,8,7]],[10,1],[[1,10,7],6,[8,5,1,6],5]],[]] +[[[],2]] + +[[],[[4]]] +[[0,10,4],[[2],0,10],[]] + +[[[],[4],[[],7,5],0,[10,8]],[[9,[9,1,5,6,4],6,10,[2,1,9]],4],[[],[]],[6,[[]],0,5]] +[[7,[1,2,0]]] + +[[9],[[[9,3],8,[4,2,7,2,2],2,[10,6,1,0,8]],[3,2],[9],[7]],[[0],[[4,7],[],3,[],3],2,9,[]],[[],9,[2],3]] +[[3,2,[[7,0,3],[9],[1]],[8]],[],[[[],[10,8,4]],9,[],[]]] + +[[4,8,[6,3,[9]]],[[[],3,6,[7,3,3],[5,3,8]],[9,[],5,6,[6,0,2,4,4]],2,8],[]] +[[10,7,8,7,3],[[[9,8,2,1],[0,5],[9]]],[[[7,3,7,7,3]]],[[7,[],8],[9],[2,[1,4,8],[3,4,2,4,5],[],9],[9,[7]]],[[],5,[9,[10,6,5],[0,2,8]]]] + +[[1,[0],1],[]] +[[[[7,5,2,5,8],[8,10,1,4,6],10,[10,10,5,1],8],[[2,4,8,1],[],3,0,[2,4]],[[2,0],7,7,[4,3,6]],6],[],[[[6],1],[0,[0,9,3],3]],[5,6,7]] + +[[[],[],[[4,0,3],[],[3,3],[1,2,5,4,6],[5,8,0]],[7,[5],10,10,1]]] +[[],[[[1,1,5,3],6],4,8,7],[1,[[7],[]],10,0,[]],[[[],[5,2,2,5,4],8],8,2],[5,[9,[10,5,2,9,8],8],10,10]] + +[[3],[[[6,4]],9,1],[6,8]] +[[],[[[5],[5,3,2,10,7],10,[7,9,1,5],2],[6,8,[6,8,1,0,10]],[[]]],[[],4,[[],[5,2,10,1],0,8],4,10],[[],[3,[0,6,0],[5,1,4,4],3,[3,1,9,2]],[3,2,3,2,[6,6,7,6,5]],[],9]] + +[[5,9,3,[],[9,7,[]]]] +[[[0,9,8,[10,3],[10]],1,[3,[10,3,4,5],[8,4,2,3,6],[9,8,10,5,8]],[8,[5,3,7],[6,2,2],[5,9],[7,9,4]],[10,5,10]],[3],[1,0,[[8,8],[]]],[9,[],[5,8,[5,2,9,2,0],[10,4]],[[9,9,8,4,0],5],[]],[[[],[8,2]],[[9,9,6,6,7],[4],2,[]],[7,9]]] + +[[[6,[1],6,[1],9],[7,[6,2,1],[3,1,1,7]],[[9,5,1],5,[1,2,2,8,5],2,2]],[[]],[[9,6,4,0]]] +[[[],[[2],[1,5],[7,10,0,9,2],8,9]],[4,[8],4,6]] + +[[2,6,6],[10,10,4]] +[[[[1,7],5,0],3,10,3],[1,[7],0,[[9,6,3],[10,0,5,7],[10],[5,10]],3],[10,[]],[5,[6,2,10,7,[1]]]] + +[[3,[3,2,[8,6,2,6,10],[0],[]],[]],[5,[[],[8],[8],[8,5,2],[9,8,10,8,9]],7,[0,[7,6,7,2]],9]] +[[],[4],[[[10],[2,3,4],[7,3,4,0]],3,[10]],[3,[[4],6,10],[3,10,7,[],3]],[5,4,0,[],6]] + +[[[[0,7]],[9],[[],[],5,[7,6,8,0]],3]] +[[3,[[3,5],6,8],7],[[[3,4]],[],[0,[8,3,2,3,3],0,[5,10,3,7],[0,6]],[[2,2,3,10,10],9,[0],[]],[]]] + +[[3],[5,7,10,10]] +[[10],[],[[0,[9,2,9,0],[5],[7,6,2],[7,3,6,4,9]],10,[8],2,7],[[[7,3,2,3,9],[7,5,2,9],[10,10,3,4,8],[2,7,9,8],0],[[10,3,1,1],[0],6]]] + +[[[10,7,8]],[[],[1,[8,4,0]],2,7],[],[[[8,9,6]]]] +[[[]],[3,0]] + +[[6,4,[2,9,10],[[5],4,[],7],2]] +[[],[4,9,3,10],[4],[[[10,7],4,[8,10,4,2]],6,[5,3,5,1,[7,9,4]],[[]],[]]] + +[[7,[[4,7],7,[2,8,2]],5,7,[[5,0,7,8,0]]],[[5]],[[0,[3,9]],8,[1,4,2],[[10,1,3,5,0],[4],[],3]],[[[6,4],[4,9,9,4]],[],[]]] +[[5,[0,[6,8,7,3],2],[9,4,[7],[0,3,7]],3],[3,[[9,6]],[[],[4,7,6,8,0]]],[2,5],[9,2,5]] + +[[[[1,3]],8],[5,8,6,[0,[6,6,4],[]],7],[[7],[[],3,7,1],[],[[9,10,6],[5],[6,7,6],[3,3,3,8],[]],[[],7]],[],[7,[8,[1,8,1,0]],[4,1,[2,5],1],[[6,10]]]] +[[[10,9,[0,10,10,1]],[[9],[10,0,2],4,9]],[[[4,8]],0,[5,[3],4,3,4],3],[],[],[[]]] + +[[4,6,[[10,0,2,6],[3,5,8],3],3],[],[],[],[8]] +[[[],[[],4,10],9],[[3,[],[8,6,9],9,1],1,10,[[1,4,6],[0],2],[[1,7,9,7,0],[3,10],2,[2],[2,9]]]] + +[[],[[1,[6,2,10]]],[],[[[7,9,2,8],[5,1,2],9],3,[10]]] +[[[2]],[10,[10,6,8],8,[8,0,10,2],10]] + +[[2,8]] +[[[[5],[9,9,6],[1,8],[5,4,6,0,2]],[[5,9],[]],[7,[4,2,3,4],6]],[],[1,9,7,[6]]] diff --git a/2022/Day14CSharp/Day14CSharp.csproj b/2022/Day14CSharp/Day14CSharp.csproj new file mode 100644 index 0000000..d439800 --- /dev/null +++ b/2022/Day14CSharp/Day14CSharp.csproj @@ -0,0 +1,10 @@ + + + + Exe + net7.0 + enable + enable + + + diff --git a/2022/Day14CSharp/Program.cs b/2022/Day14CSharp/Program.cs new file mode 100644 index 0000000..a8e19d1 --- /dev/null +++ b/2022/Day14CSharp/Program.cs @@ -0,0 +1,264 @@ +using System.Drawing; + +Part01(); +Part02(); + +void Part01() +{ + var exampleCave = new Cave("example-input.txt"); + exampleCave.PrintCave(); + int result = exampleCave.DropUntilOverflow(); + exampleCave.PrintCave(); + Console.WriteLine("Example Number of Sand: {0}", result); + + var puzzleCave = new Cave("puzzle-input.txt"); + puzzleCave.PrintCave(); + result = puzzleCave.DropUntilOverflow(); + puzzleCave.PrintCave(); + Console.WriteLine("Puzzle Number of Sand: {0}", result); +} + +void Part02() +{ + var exampleCave = new Cave("example-input.txt"); + exampleCave.PrintCave(); + int result = exampleCave.DropUntilSourceIsPlugged(); + exampleCave.PrintCave(); + Console.WriteLine("Example Number of Sand: {0}", result); + + var puzzleCave = new Cave("puzzle-input.txt"); + puzzleCave.PrintCave(); + result = puzzleCave.DropUntilSourceIsPlugged(); + puzzleCave.PrintCave(); + Console.WriteLine("Puzzle Number of Sand: {0}", result); +} + +class Cave +{ + public enum BlockType + { + None, + Sand, + Rock, + SandSource + } + public Dictionary CaveData = new Dictionary(); + public Point SandSource { get; set; } = new Point(500, 0); + + public Cave(string filename) + { + using (StreamReader reader = System.IO.File.OpenText(filename)) + { + while (!reader.EndOfStream) + { + string? line = reader.ReadLine(); + if (line == null) { throw new InvalidDataException(); } + + var vectors = line.Split("->", StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries); + + Point lastPoint = ReadPoint(vectors[0]); + for (int i = 1; i < vectors.Length; i++) + { + Point nextPoint = ReadPoint(vectors[i]); + CaveData[nextPoint] = BlockType.Rock; + + int dir; + if (lastPoint.X != nextPoint.X) + { + if (lastPoint.X < nextPoint.X) + { + dir = 1; + } + else + { + dir = -1; + } + + while (lastPoint.X != nextPoint.X) + { + CaveData[lastPoint] = BlockType.Rock; + lastPoint.X += dir; + } + } + else if (lastPoint.Y != nextPoint.Y) + { + if (lastPoint.Y < nextPoint.Y) + { + dir = 1; + } + else + { + dir = -1; + } + + while (lastPoint.Y != nextPoint.Y) + { + CaveData[lastPoint] = BlockType.Rock; + lastPoint.Y += dir; + } + } + else + { + throw new InvalidDataException(); + } + } + } + } + + if (CaveData.ContainsKey(SandSource)) + { + throw new InvalidDataException(); + } + + CaveData[SandSource] = BlockType.SandSource; + FindBounds(); + TrueBottom = Bounds.Y + Bounds.Height + 2; + } + + public void PrintCave() + { + PrintCave(new Point(-1, -1)); + } + + public void PrintCave(Point sand) + { + int x_min = Bounds.Left, x_max = x_min + Bounds.Width, y_min = Bounds.Top, y_max = y_min + Bounds.Height; + + for (int y = y_min; y <= y_max; y++) + { + for (int x = x_min; x <= x_max; x++) + { + var point = new Point(x, y); + + if (sand == point) + { + Console.Write('o'); + } + else if (CaveData.ContainsKey(point)) + { + var item = CaveData[point]; + + if (item == BlockType.Rock) + { + Console.Write("#"); + } + else if (item == BlockType.Sand) + { + Console.Write("o"); + } + else if (item == BlockType.SandSource) + { + Console.Write("+"); + } + else + { + throw new InvalidDataException(); + } + } + else + { + Console.Write('.'); + } + } + Console.WriteLine(); + } + } + + public int DropUntilOverflow() + { + int count = 0; + + while(!DropSand()) { count++; } + + return count; + } + + public int DropUntilSourceIsPlugged() + { + int count = 0; + + while (CaveData[SandSource] != BlockType.Sand) + { + DropSand(false); + count++; + } + + return count; + } + + public bool DropSand(bool returnEarly = true, bool printEachStep = false) + { + Point sandPosition = new Point(SandSource.X, SandSource.Y); + + do + { + if (printEachStep) PrintCave(sandPosition); + + Point down = new Point(sandPosition.X, sandPosition.Y + 1); + Point downLeft = new Point(sandPosition.X - 1, sandPosition.Y + 1); + Point downRight = new Point(sandPosition.X + 1, sandPosition.Y + 1); + + if (!CaveData.ContainsKey(down) && down.Y != TrueBottom) + { + sandPosition = down; + } + else if (!CaveData.ContainsKey(downLeft) && downLeft.Y != TrueBottom) + { + sandPosition = downLeft; + } + else if (!CaveData.ContainsKey(downRight) && downRight.Y != TrueBottom) + { + sandPosition = downRight; + } + else + { + // Cant go anywhere, so need to stop + CaveData[sandPosition] = BlockType.Sand; + return false; + } + + // Fell off the world + if (!Bounds.Contains(sandPosition)) + { + FindBounds(); + if (returnEarly) + return true; + } + + } while (true); + } + + private Rectangle Bounds { get; set; } + private int TrueBottom { get; set; } + + private void FindBounds() + { + int x_min = int.MaxValue; + int x_max = int.MinValue; + int y_min = 0; // sand always starts at 0 + int y_max = int.MinValue; + + foreach (var item in CaveData) + { + if (item.Value == BlockType.None) throw new InvalidDataException(); + + x_min = Int32.Min(item.Key.X, x_min); + x_max = Int32.Max(item.Key.X, x_max); + y_min = Int32.Min(item.Key.Y, y_min); + y_max = Int32.Max(item.Key.Y, y_max); + } + + Bounds = new Rectangle(x_min, y_min, x_max-x_min, y_max-y_min); + } + + private Point ReadPoint(string s) + { + Point p = new Point(); + var split = s.Split(',', StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries); + + p.X = Int32.Parse(split[0]); + p.Y = Int32.Parse(split[1]); + + return p; + } +} \ No newline at end of file diff --git a/2022/Day14CSharp/Properties/launchSettings.json b/2022/Day14CSharp/Properties/launchSettings.json new file mode 100644 index 0000000..6f21512 --- /dev/null +++ b/2022/Day14CSharp/Properties/launchSettings.json @@ -0,0 +1,8 @@ +{ + "profiles": { + "Day14CSharp": { + "commandName": "Project", + "workingDirectory": "C:\\dev\\DevSandbox\\AdventOfCode\\2022\\Day14CSharp" + } + } +} \ No newline at end of file diff --git a/2022/Day14CSharp/example-input.txt b/2022/Day14CSharp/example-input.txt new file mode 100644 index 0000000..ccd34c4 --- /dev/null +++ b/2022/Day14CSharp/example-input.txt @@ -0,0 +1,2 @@ +498,4 -> 498,6 -> 496,6 +503,4 -> 502,4 -> 502,9 -> 494,9 \ No newline at end of file diff --git a/2022/Day14CSharp/problem.txt b/2022/Day14CSharp/problem.txt new file mode 100644 index 0000000..0d2c02f --- /dev/null +++ b/2022/Day14CSharp/problem.txt @@ -0,0 +1,163 @@ +--- Day 14: Regolith Reservoir --- + +The distress signal leads you to a giant waterfall! Actually, hang on - the signal seems like it's coming from the waterfall itself, and that doesn't make any sense. However, you do notice a little path that leads behind the waterfall. + +Correction: the distress signal leads you behind a giant waterfall! There seems to be a large cave system here, and the signal definitely leads further inside. + +As you begin to make your way deeper underground, you feel the ground rumble for a moment. Sand begins pouring into the cave! If you don't quickly figure out where the sand is going, you could quickly become trapped! + +Fortunately, your familiarity with analyzing the path of falling material will come in handy here. You scan a two-dimensional vertical slice of the cave above you (your puzzle input) and discover that it is mostly air with structures made of rock. + +Your scan traces the path of each solid rock structure and reports the x,y coordinates that form the shape of the path, where x represents distance to the right and y represents distance down. Each path appears as a single line of text in your scan. After the first point of each path, each point indicates the end of a straight horizontal or vertical line to be drawn from the previous point. For example: + +498,4 -> 498,6 -> 496,6 +503,4 -> 502,4 -> 502,9 -> 494,9 + +This scan means that there are two paths of rock; the first path consists of two straight lines, and the second path consists of three straight lines. (Specifically, the first path consists of a line of rock from 498,4 through 498,6 and another line of rock from 498,6 through 496,6.) + +The sand is pouring into the cave from point 500,0. + +Drawing rock as #, air as ., and the source of the sand as +, this becomes: + + + 4 5 5 + 9 0 0 + 4 0 3 +0 ......+... +1 .......... +2 .......... +3 .......... +4 ....#...## +5 ....#...#. +6 ..###...#. +7 ........#. +8 ........#. +9 #########. + +Sand is produced one unit at a time, and the next unit of sand is not produced until the previous unit of sand comes to rest. A unit of sand is large enough to fill one tile of air in your scan. + +A unit of sand always falls down one step if possible. If the tile immediately below is blocked (by rock or sand), the unit of sand attempts to instead move diagonally one step down and to the left. If that tile is blocked, the unit of sand attempts to instead move diagonally one step down and to the right. Sand keeps moving as long as it is able to do so, at each step trying to move down, then down-left, then down-right. If all three possible destinations are blocked, the unit of sand comes to rest and no longer moves, at which point the next unit of sand is created back at the source. + +So, drawing sand that has come to rest as o, the first unit of sand simply falls straight down and then stops: + +......+... +.......... +.......... +.......... +....#...## +....#...#. +..###...#. +........#. +......o.#. +#########. + +The second unit of sand then falls straight down, lands on the first one, and then comes to rest to its left: + +......+... +.......... +.......... +.......... +....#...## +....#...#. +..###...#. +........#. +.....oo.#. +#########. + +After a total of five units of sand have come to rest, they form this pattern: + +......+... +.......... +.......... +.......... +....#...## +....#...#. +..###...#. +......o.#. +....oooo#. +#########. + +After a total of 22 units of sand: + +......+... +.......... +......o... +.....ooo.. +....#ooo## +....#ooo#. +..###ooo#. +....oooo#. +...ooooo#. +#########. + +Finally, only two more units of sand can possibly come to rest: + +......+... +.......... +......o... +.....ooo.. +....#ooo## +...o#ooo#. +..###ooo#. +....oooo#. +.o.ooooo#. +#########. + +Once all 24 units of sand shown above have come to rest, all further sand flows out the bottom, falling into the endless void. Just for fun, the path any new sand takes before falling forever is shown here with ~: + +.......+... +.......~... +......~o... +.....~ooo.. +....~#ooo## +...~o#ooo#. +..~###ooo#. +..~..oooo#. +.~o.ooooo#. +~#########. +~.......... +~.......... +~.......... + +Using your scan, simulate the falling sand. How many units of sand come to rest before sand starts flowing into the abyss below? + +Your puzzle answer was 832. + +The first half of this puzzle is complete! It provides one gold star: * +--- Part Two --- + +You realize you misread the scan. There isn't an endless void at the bottom of the scan - there's floor, and you're standing on it! + +You don't have time to scan the floor, so assume the floor is an infinite horizontal line with a y coordinate equal to two plus the highest y coordinate of any point in your scan. + +In the example above, the highest y coordinate of any point is 9, and so the floor is at y=11. (This is as if your scan contained one extra rock path like -infinity,11 -> infinity,11.) With the added floor, the example above now looks like this: + + ...........+........ + .................... + .................... + .................... + .........#...##..... + .........#...#...... + .......###...#...... + .............#...... + .............#...... + .....#########...... + .................... +<-- etc #################### etc --> + +To find somewhere safe to stand, you'll need to simulate falling sand until a unit of sand comes to rest at 500,0, blocking the source entirely and stopping the flow of sand into the cave. In the example above, the situation finally looks like this after 93 units of sand come to rest: + +............o............ +...........ooo........... +..........ooooo.......... +.........ooooooo......... +........oo#ooo##o........ +.......ooo#ooo#ooo....... +......oo###ooo#oooo...... +.....oooo.oooo#ooooo..... +....oooooooooo#oooooo.... +...ooo#########ooooooo... +..ooooo.......ooooooooo.. +######################### + +Using your scan, simulate the falling sand until the source of the sand becomes blocked. How many units of sand come to rest? diff --git a/2022/Day14CSharp/puzzle-input.txt b/2022/Day14CSharp/puzzle-input.txt new file mode 100644 index 0000000..03ea5b7 --- /dev/null +++ b/2022/Day14CSharp/puzzle-input.txt @@ -0,0 +1,148 @@ +481,122 -> 481,125 -> 476,125 -> 476,129 -> 491,129 -> 491,125 -> 485,125 -> 485,122 +475,119 -> 475,113 -> 475,119 -> 477,119 -> 477,113 -> 477,119 -> 479,119 -> 479,114 -> 479,119 -> 481,119 -> 481,115 -> 481,119 -> 483,119 -> 483,113 -> 483,119 +489,148 -> 493,148 +471,152 -> 475,152 +490,23 -> 490,13 -> 490,23 -> 492,23 -> 492,17 -> 492,23 -> 494,23 -> 494,18 -> 494,23 -> 496,23 -> 496,22 -> 496,23 -> 498,23 -> 498,21 -> 498,23 -> 500,23 -> 500,18 -> 500,23 -> 502,23 -> 502,15 -> 502,23 -> 504,23 -> 504,22 -> 504,23 -> 506,23 -> 506,18 -> 506,23 -> 508,23 -> 508,19 -> 508,23 +492,60 -> 492,63 -> 486,63 -> 486,71 -> 502,71 -> 502,63 -> 496,63 -> 496,60 +504,158 -> 504,162 -> 503,162 -> 503,170 -> 511,170 -> 511,162 -> 507,162 -> 507,158 +490,23 -> 490,13 -> 490,23 -> 492,23 -> 492,17 -> 492,23 -> 494,23 -> 494,18 -> 494,23 -> 496,23 -> 496,22 -> 496,23 -> 498,23 -> 498,21 -> 498,23 -> 500,23 -> 500,18 -> 500,23 -> 502,23 -> 502,15 -> 502,23 -> 504,23 -> 504,22 -> 504,23 -> 506,23 -> 506,18 -> 506,23 -> 508,23 -> 508,19 -> 508,23 +490,23 -> 490,13 -> 490,23 -> 492,23 -> 492,17 -> 492,23 -> 494,23 -> 494,18 -> 494,23 -> 496,23 -> 496,22 -> 496,23 -> 498,23 -> 498,21 -> 498,23 -> 500,23 -> 500,18 -> 500,23 -> 502,23 -> 502,15 -> 502,23 -> 504,23 -> 504,22 -> 504,23 -> 506,23 -> 506,18 -> 506,23 -> 508,23 -> 508,19 -> 508,23 +486,146 -> 490,146 +490,23 -> 490,13 -> 490,23 -> 492,23 -> 492,17 -> 492,23 -> 494,23 -> 494,18 -> 494,23 -> 496,23 -> 496,22 -> 496,23 -> 498,23 -> 498,21 -> 498,23 -> 500,23 -> 500,18 -> 500,23 -> 502,23 -> 502,15 -> 502,23 -> 504,23 -> 504,22 -> 504,23 -> 506,23 -> 506,18 -> 506,23 -> 508,23 -> 508,19 -> 508,23 +490,23 -> 490,13 -> 490,23 -> 492,23 -> 492,17 -> 492,23 -> 494,23 -> 494,18 -> 494,23 -> 496,23 -> 496,22 -> 496,23 -> 498,23 -> 498,21 -> 498,23 -> 500,23 -> 500,18 -> 500,23 -> 502,23 -> 502,15 -> 502,23 -> 504,23 -> 504,22 -> 504,23 -> 506,23 -> 506,18 -> 506,23 -> 508,23 -> 508,19 -> 508,23 +490,23 -> 490,13 -> 490,23 -> 492,23 -> 492,17 -> 492,23 -> 494,23 -> 494,18 -> 494,23 -> 496,23 -> 496,22 -> 496,23 -> 498,23 -> 498,21 -> 498,23 -> 500,23 -> 500,18 -> 500,23 -> 502,23 -> 502,15 -> 502,23 -> 504,23 -> 504,22 -> 504,23 -> 506,23 -> 506,18 -> 506,23 -> 508,23 -> 508,19 -> 508,23 +475,119 -> 475,113 -> 475,119 -> 477,119 -> 477,113 -> 477,119 -> 479,119 -> 479,114 -> 479,119 -> 481,119 -> 481,115 -> 481,119 -> 483,119 -> 483,113 -> 483,119 +504,158 -> 504,162 -> 503,162 -> 503,170 -> 511,170 -> 511,162 -> 507,162 -> 507,158 +518,31 -> 518,35 -> 517,35 -> 517,38 -> 529,38 -> 529,35 -> 522,35 -> 522,31 +490,100 -> 495,100 +481,122 -> 481,125 -> 476,125 -> 476,129 -> 491,129 -> 491,125 -> 485,125 -> 485,122 +500,141 -> 505,141 +499,84 -> 499,80 -> 499,84 -> 501,84 -> 501,77 -> 501,84 -> 503,84 -> 503,75 -> 503,84 -> 505,84 -> 505,83 -> 505,84 +475,119 -> 475,113 -> 475,119 -> 477,119 -> 477,113 -> 477,119 -> 479,119 -> 479,114 -> 479,119 -> 481,119 -> 481,115 -> 481,119 -> 483,119 -> 483,113 -> 483,119 +518,31 -> 518,35 -> 517,35 -> 517,38 -> 529,38 -> 529,35 -> 522,35 -> 522,31 +490,23 -> 490,13 -> 490,23 -> 492,23 -> 492,17 -> 492,23 -> 494,23 -> 494,18 -> 494,23 -> 496,23 -> 496,22 -> 496,23 -> 498,23 -> 498,21 -> 498,23 -> 500,23 -> 500,18 -> 500,23 -> 502,23 -> 502,15 -> 502,23 -> 504,23 -> 504,22 -> 504,23 -> 506,23 -> 506,18 -> 506,23 -> 508,23 -> 508,19 -> 508,23 +495,57 -> 499,57 +489,133 -> 489,134 -> 494,134 +488,106 -> 493,106 +519,57 -> 523,57 +481,122 -> 481,125 -> 476,125 -> 476,129 -> 491,129 -> 491,125 -> 485,125 -> 485,122 +493,141 -> 498,141 +504,54 -> 508,54 +494,97 -> 494,92 -> 494,97 -> 496,97 -> 496,91 -> 496,97 -> 498,97 -> 498,88 -> 498,97 -> 500,97 -> 500,94 -> 500,97 +474,150 -> 478,150 +494,97 -> 494,92 -> 494,97 -> 496,97 -> 496,91 -> 496,97 -> 498,97 -> 498,88 -> 498,97 -> 500,97 -> 500,94 -> 500,97 +498,54 -> 502,54 +489,139 -> 494,139 +518,31 -> 518,35 -> 517,35 -> 517,38 -> 529,38 -> 529,35 -> 522,35 -> 522,31 +510,41 -> 510,42 -> 521,42 -> 521,41 +490,23 -> 490,13 -> 490,23 -> 492,23 -> 492,17 -> 492,23 -> 494,23 -> 494,18 -> 494,23 -> 496,23 -> 496,22 -> 496,23 -> 498,23 -> 498,21 -> 498,23 -> 500,23 -> 500,18 -> 500,23 -> 502,23 -> 502,15 -> 502,23 -> 504,23 -> 504,22 -> 504,23 -> 506,23 -> 506,18 -> 506,23 -> 508,23 -> 508,19 -> 508,23 +480,150 -> 484,150 +494,97 -> 494,92 -> 494,97 -> 496,97 -> 496,91 -> 496,97 -> 498,97 -> 498,88 -> 498,97 -> 500,97 -> 500,94 -> 500,97 +518,31 -> 518,35 -> 517,35 -> 517,38 -> 529,38 -> 529,35 -> 522,35 -> 522,31 +490,23 -> 490,13 -> 490,23 -> 492,23 -> 492,17 -> 492,23 -> 494,23 -> 494,18 -> 494,23 -> 496,23 -> 496,22 -> 496,23 -> 498,23 -> 498,21 -> 498,23 -> 500,23 -> 500,18 -> 500,23 -> 502,23 -> 502,15 -> 502,23 -> 504,23 -> 504,22 -> 504,23 -> 506,23 -> 506,18 -> 506,23 -> 508,23 -> 508,19 -> 508,23 +494,97 -> 494,92 -> 494,97 -> 496,97 -> 496,91 -> 496,97 -> 498,97 -> 498,88 -> 498,97 -> 500,97 -> 500,94 -> 500,97 +504,158 -> 504,162 -> 503,162 -> 503,170 -> 511,170 -> 511,162 -> 507,162 -> 507,158 +501,51 -> 505,51 +504,158 -> 504,162 -> 503,162 -> 503,170 -> 511,170 -> 511,162 -> 507,162 -> 507,158 +498,104 -> 503,104 +477,148 -> 481,148 +510,48 -> 514,48 +475,119 -> 475,113 -> 475,119 -> 477,119 -> 477,113 -> 477,119 -> 479,119 -> 479,114 -> 479,119 -> 481,119 -> 481,115 -> 481,119 -> 483,119 -> 483,113 -> 483,119 +490,23 -> 490,13 -> 490,23 -> 492,23 -> 492,17 -> 492,23 -> 494,23 -> 494,18 -> 494,23 -> 496,23 -> 496,22 -> 496,23 -> 498,23 -> 498,21 -> 498,23 -> 500,23 -> 500,18 -> 500,23 -> 502,23 -> 502,15 -> 502,23 -> 504,23 -> 504,22 -> 504,23 -> 506,23 -> 506,18 -> 506,23 -> 508,23 -> 508,19 -> 508,23 +490,23 -> 490,13 -> 490,23 -> 492,23 -> 492,17 -> 492,23 -> 494,23 -> 494,18 -> 494,23 -> 496,23 -> 496,22 -> 496,23 -> 498,23 -> 498,21 -> 498,23 -> 500,23 -> 500,18 -> 500,23 -> 502,23 -> 502,15 -> 502,23 -> 504,23 -> 504,22 -> 504,23 -> 506,23 -> 506,18 -> 506,23 -> 508,23 -> 508,19 -> 508,23 +475,119 -> 475,113 -> 475,119 -> 477,119 -> 477,113 -> 477,119 -> 479,119 -> 479,114 -> 479,119 -> 481,119 -> 481,115 -> 481,119 -> 483,119 -> 483,113 -> 483,119 +483,152 -> 487,152 +492,60 -> 492,63 -> 486,63 -> 486,71 -> 502,71 -> 502,63 -> 496,63 -> 496,60 +475,119 -> 475,113 -> 475,119 -> 477,119 -> 477,113 -> 477,119 -> 479,119 -> 479,114 -> 479,119 -> 481,119 -> 481,115 -> 481,119 -> 483,119 -> 483,113 -> 483,119 +494,97 -> 494,92 -> 494,97 -> 496,97 -> 496,91 -> 496,97 -> 498,97 -> 498,88 -> 498,97 -> 500,97 -> 500,94 -> 500,97 +492,60 -> 492,63 -> 486,63 -> 486,71 -> 502,71 -> 502,63 -> 496,63 -> 496,60 +490,23 -> 490,13 -> 490,23 -> 492,23 -> 492,17 -> 492,23 -> 494,23 -> 494,18 -> 494,23 -> 496,23 -> 496,22 -> 496,23 -> 498,23 -> 498,21 -> 498,23 -> 500,23 -> 500,18 -> 500,23 -> 502,23 -> 502,15 -> 502,23 -> 504,23 -> 504,22 -> 504,23 -> 506,23 -> 506,18 -> 506,23 -> 508,23 -> 508,19 -> 508,23 +516,54 -> 520,54 +490,23 -> 490,13 -> 490,23 -> 492,23 -> 492,17 -> 492,23 -> 494,23 -> 494,18 -> 494,23 -> 496,23 -> 496,22 -> 496,23 -> 498,23 -> 498,21 -> 498,23 -> 500,23 -> 500,18 -> 500,23 -> 502,23 -> 502,15 -> 502,23 -> 504,23 -> 504,22 -> 504,23 -> 506,23 -> 506,18 -> 506,23 -> 508,23 -> 508,19 -> 508,23 +475,119 -> 475,113 -> 475,119 -> 477,119 -> 477,113 -> 477,119 -> 479,119 -> 479,114 -> 479,119 -> 481,119 -> 481,115 -> 481,119 -> 483,119 -> 483,113 -> 483,119 +494,102 -> 499,102 +490,23 -> 490,13 -> 490,23 -> 492,23 -> 492,17 -> 492,23 -> 494,23 -> 494,18 -> 494,23 -> 496,23 -> 496,22 -> 496,23 -> 498,23 -> 498,21 -> 498,23 -> 500,23 -> 500,18 -> 500,23 -> 502,23 -> 502,15 -> 502,23 -> 504,23 -> 504,22 -> 504,23 -> 506,23 -> 506,18 -> 506,23 -> 508,23 -> 508,19 -> 508,23 +504,158 -> 504,162 -> 503,162 -> 503,170 -> 511,170 -> 511,162 -> 507,162 -> 507,158 +490,23 -> 490,13 -> 490,23 -> 492,23 -> 492,17 -> 492,23 -> 494,23 -> 494,18 -> 494,23 -> 496,23 -> 496,22 -> 496,23 -> 498,23 -> 498,21 -> 498,23 -> 500,23 -> 500,18 -> 500,23 -> 502,23 -> 502,15 -> 502,23 -> 504,23 -> 504,22 -> 504,23 -> 506,23 -> 506,18 -> 506,23 -> 508,23 -> 508,19 -> 508,23 +518,31 -> 518,35 -> 517,35 -> 517,38 -> 529,38 -> 529,35 -> 522,35 -> 522,31 +494,97 -> 494,92 -> 494,97 -> 496,97 -> 496,91 -> 496,97 -> 498,97 -> 498,88 -> 498,97 -> 500,97 -> 500,94 -> 500,97 +513,51 -> 517,51 +492,60 -> 492,63 -> 486,63 -> 486,71 -> 502,71 -> 502,63 -> 496,63 -> 496,60 +481,122 -> 481,125 -> 476,125 -> 476,129 -> 491,129 -> 491,125 -> 485,125 -> 485,122 +499,84 -> 499,80 -> 499,84 -> 501,84 -> 501,77 -> 501,84 -> 503,84 -> 503,75 -> 503,84 -> 505,84 -> 505,83 -> 505,84 +518,31 -> 518,35 -> 517,35 -> 517,38 -> 529,38 -> 529,35 -> 522,35 -> 522,31 +494,97 -> 494,92 -> 494,97 -> 496,97 -> 496,91 -> 496,97 -> 498,97 -> 498,88 -> 498,97 -> 500,97 -> 500,94 -> 500,97 +489,133 -> 489,134 -> 494,134 +490,23 -> 490,13 -> 490,23 -> 492,23 -> 492,17 -> 492,23 -> 494,23 -> 494,18 -> 494,23 -> 496,23 -> 496,22 -> 496,23 -> 498,23 -> 498,21 -> 498,23 -> 500,23 -> 500,18 -> 500,23 -> 502,23 -> 502,15 -> 502,23 -> 504,23 -> 504,22 -> 504,23 -> 506,23 -> 506,18 -> 506,23 -> 508,23 -> 508,19 -> 508,23 +490,23 -> 490,13 -> 490,23 -> 492,23 -> 492,17 -> 492,23 -> 494,23 -> 494,18 -> 494,23 -> 496,23 -> 496,22 -> 496,23 -> 498,23 -> 498,21 -> 498,23 -> 500,23 -> 500,18 -> 500,23 -> 502,23 -> 502,15 -> 502,23 -> 504,23 -> 504,22 -> 504,23 -> 506,23 -> 506,18 -> 506,23 -> 508,23 -> 508,19 -> 508,23 +507,57 -> 511,57 +492,60 -> 492,63 -> 486,63 -> 486,71 -> 502,71 -> 502,63 -> 496,63 -> 496,60 +504,158 -> 504,162 -> 503,162 -> 503,170 -> 511,170 -> 511,162 -> 507,162 -> 507,158 +499,84 -> 499,80 -> 499,84 -> 501,84 -> 501,77 -> 501,84 -> 503,84 -> 503,75 -> 503,84 -> 505,84 -> 505,83 -> 505,84 +475,119 -> 475,113 -> 475,119 -> 477,119 -> 477,113 -> 477,119 -> 479,119 -> 479,114 -> 479,119 -> 481,119 -> 481,115 -> 481,119 -> 483,119 -> 483,113 -> 483,119 +477,152 -> 481,152 +490,23 -> 490,13 -> 490,23 -> 492,23 -> 492,17 -> 492,23 -> 494,23 -> 494,18 -> 494,23 -> 496,23 -> 496,22 -> 496,23 -> 498,23 -> 498,21 -> 498,23 -> 500,23 -> 500,18 -> 500,23 -> 502,23 -> 502,15 -> 502,23 -> 504,23 -> 504,22 -> 504,23 -> 506,23 -> 506,18 -> 506,23 -> 508,23 -> 508,19 -> 508,23 +494,97 -> 494,92 -> 494,97 -> 496,97 -> 496,91 -> 496,97 -> 498,97 -> 498,88 -> 498,97 -> 500,97 -> 500,94 -> 500,97 +480,146 -> 484,146 +499,84 -> 499,80 -> 499,84 -> 501,84 -> 501,77 -> 501,84 -> 503,84 -> 503,75 -> 503,84 -> 505,84 -> 505,83 -> 505,84 +510,54 -> 514,54 +490,23 -> 490,13 -> 490,23 -> 492,23 -> 492,17 -> 492,23 -> 494,23 -> 494,18 -> 494,23 -> 496,23 -> 496,22 -> 496,23 -> 498,23 -> 498,21 -> 498,23 -> 500,23 -> 500,18 -> 500,23 -> 502,23 -> 502,15 -> 502,23 -> 504,23 -> 504,22 -> 504,23 -> 506,23 -> 506,18 -> 506,23 -> 508,23 -> 508,19 -> 508,23 +475,119 -> 475,113 -> 475,119 -> 477,119 -> 477,113 -> 477,119 -> 479,119 -> 479,114 -> 479,119 -> 481,119 -> 481,115 -> 481,119 -> 483,119 -> 483,113 -> 483,119 +460,155 -> 474,155 -> 474,154 +495,152 -> 499,152 +492,60 -> 492,63 -> 486,63 -> 486,71 -> 502,71 -> 502,63 -> 496,63 -> 496,60 +507,45 -> 511,45 +499,27 -> 499,28 -> 519,28 +495,106 -> 500,106 +490,23 -> 490,13 -> 490,23 -> 492,23 -> 492,17 -> 492,23 -> 494,23 -> 494,18 -> 494,23 -> 496,23 -> 496,22 -> 496,23 -> 498,23 -> 498,21 -> 498,23 -> 500,23 -> 500,18 -> 500,23 -> 502,23 -> 502,15 -> 502,23 -> 504,23 -> 504,22 -> 504,23 -> 506,23 -> 506,18 -> 506,23 -> 508,23 -> 508,19 -> 508,23 +494,97 -> 494,92 -> 494,97 -> 496,97 -> 496,91 -> 496,97 -> 498,97 -> 498,88 -> 498,97 -> 500,97 -> 500,94 -> 500,97 +510,41 -> 510,42 -> 521,42 -> 521,41 +499,84 -> 499,80 -> 499,84 -> 501,84 -> 501,77 -> 501,84 -> 503,84 -> 503,75 -> 503,84 -> 505,84 -> 505,83 -> 505,84 +492,60 -> 492,63 -> 486,63 -> 486,71 -> 502,71 -> 502,63 -> 496,63 -> 496,60 +481,122 -> 481,125 -> 476,125 -> 476,129 -> 491,129 -> 491,125 -> 485,125 -> 485,122 +490,23 -> 490,13 -> 490,23 -> 492,23 -> 492,17 -> 492,23 -> 494,23 -> 494,18 -> 494,23 -> 496,23 -> 496,22 -> 496,23 -> 498,23 -> 498,21 -> 498,23 -> 500,23 -> 500,18 -> 500,23 -> 502,23 -> 502,15 -> 502,23 -> 504,23 -> 504,22 -> 504,23 -> 506,23 -> 506,18 -> 506,23 -> 508,23 -> 508,19 -> 508,23 +504,48 -> 508,48 +499,84 -> 499,80 -> 499,84 -> 501,84 -> 501,77 -> 501,84 -> 503,84 -> 503,75 -> 503,84 -> 505,84 -> 505,83 -> 505,84 +492,150 -> 496,150 +502,106 -> 507,106 +486,150 -> 490,150 +489,152 -> 493,152 +490,23 -> 490,13 -> 490,23 -> 492,23 -> 492,17 -> 492,23 -> 494,23 -> 494,18 -> 494,23 -> 496,23 -> 496,22 -> 496,23 -> 498,23 -> 498,21 -> 498,23 -> 500,23 -> 500,18 -> 500,23 -> 502,23 -> 502,15 -> 502,23 -> 504,23 -> 504,22 -> 504,23 -> 506,23 -> 506,18 -> 506,23 -> 508,23 -> 508,19 -> 508,23 +481,122 -> 481,125 -> 476,125 -> 476,129 -> 491,129 -> 491,125 -> 485,125 -> 485,122 +490,23 -> 490,13 -> 490,23 -> 492,23 -> 492,17 -> 492,23 -> 494,23 -> 494,18 -> 494,23 -> 496,23 -> 496,22 -> 496,23 -> 498,23 -> 498,21 -> 498,23 -> 500,23 -> 500,18 -> 500,23 -> 502,23 -> 502,15 -> 502,23 -> 504,23 -> 504,22 -> 504,23 -> 506,23 -> 506,18 -> 506,23 -> 508,23 -> 508,19 -> 508,23 +490,23 -> 490,13 -> 490,23 -> 492,23 -> 492,17 -> 492,23 -> 494,23 -> 494,18 -> 494,23 -> 496,23 -> 496,22 -> 496,23 -> 498,23 -> 498,21 -> 498,23 -> 500,23 -> 500,18 -> 500,23 -> 502,23 -> 502,15 -> 502,23 -> 504,23 -> 504,22 -> 504,23 -> 506,23 -> 506,18 -> 506,23 -> 508,23 -> 508,19 -> 508,23 +499,84 -> 499,80 -> 499,84 -> 501,84 -> 501,77 -> 501,84 -> 503,84 -> 503,75 -> 503,84 -> 505,84 -> 505,83 -> 505,84 +492,137 -> 497,137 +507,51 -> 511,51 +504,158 -> 504,162 -> 503,162 -> 503,170 -> 511,170 -> 511,162 -> 507,162 -> 507,158 +484,104 -> 489,104 +494,97 -> 494,92 -> 494,97 -> 496,97 -> 496,91 -> 496,97 -> 498,97 -> 498,88 -> 498,97 -> 500,97 -> 500,94 -> 500,97 +518,31 -> 518,35 -> 517,35 -> 517,38 -> 529,38 -> 529,35 -> 522,35 -> 522,31 +490,23 -> 490,13 -> 490,23 -> 492,23 -> 492,17 -> 492,23 -> 494,23 -> 494,18 -> 494,23 -> 496,23 -> 496,22 -> 496,23 -> 498,23 -> 498,21 -> 498,23 -> 500,23 -> 500,18 -> 500,23 -> 502,23 -> 502,15 -> 502,23 -> 504,23 -> 504,22 -> 504,23 -> 506,23 -> 506,18 -> 506,23 -> 508,23 -> 508,19 -> 508,23 +460,155 -> 474,155 -> 474,154 +487,102 -> 492,102 +491,104 -> 496,104 +481,122 -> 481,125 -> 476,125 -> 476,129 -> 491,129 -> 491,125 -> 485,125 -> 485,122 +510,41 -> 510,42 -> 521,42 -> 521,41 +475,119 -> 475,113 -> 475,119 -> 477,119 -> 477,113 -> 477,119 -> 479,119 -> 479,114 -> 479,119 -> 481,119 -> 481,115 -> 481,119 -> 483,119 -> 483,113 -> 483,119 +483,148 -> 487,148 +501,57 -> 505,57 +496,139 -> 501,139 +490,23 -> 490,13 -> 490,23 -> 492,23 -> 492,17 -> 492,23 -> 494,23 -> 494,18 -> 494,23 -> 496,23 -> 496,22 -> 496,23 -> 498,23 -> 498,21 -> 498,23 -> 500,23 -> 500,18 -> 500,23 -> 502,23 -> 502,15 -> 502,23 -> 504,23 -> 504,22 -> 504,23 -> 506,23 -> 506,18 -> 506,23 -> 508,23 -> 508,19 -> 508,23 +475,119 -> 475,113 -> 475,119 -> 477,119 -> 477,113 -> 477,119 -> 479,119 -> 479,114 -> 479,119 -> 481,119 -> 481,115 -> 481,119 -> 483,119 -> 483,113 -> 483,119 +475,119 -> 475,113 -> 475,119 -> 477,119 -> 477,113 -> 477,119 -> 479,119 -> 479,114 -> 479,119 -> 481,119 -> 481,115 -> 481,119 -> 483,119 -> 483,113 -> 483,119 +481,106 -> 486,106 +490,23 -> 490,13 -> 490,23 -> 492,23 -> 492,17 -> 492,23 -> 494,23 -> 494,18 -> 494,23 -> 496,23 -> 496,22 -> 496,23 -> 498,23 -> 498,21 -> 498,23 -> 500,23 -> 500,18 -> 500,23 -> 502,23 -> 502,15 -> 502,23 -> 504,23 -> 504,22 -> 504,23 -> 506,23 -> 506,18 -> 506,23 -> 508,23 -> 508,19 -> 508,23 +475,119 -> 475,113 -> 475,119 -> 477,119 -> 477,113 -> 477,119 -> 479,119 -> 479,114 -> 479,119 -> 481,119 -> 481,115 -> 481,119 -> 483,119 -> 483,113 -> 483,119 +475,119 -> 475,113 -> 475,119 -> 477,119 -> 477,113 -> 477,119 -> 479,119 -> 479,114 -> 479,119 -> 481,119 -> 481,115 -> 481,119 -> 483,119 -> 483,113 -> 483,119 +499,84 -> 499,80 -> 499,84 -> 501,84 -> 501,77 -> 501,84 -> 503,84 -> 503,75 -> 503,84 -> 505,84 -> 505,83 -> 505,84 +490,23 -> 490,13 -> 490,23 -> 492,23 -> 492,17 -> 492,23 -> 494,23 -> 494,18 -> 494,23 -> 496,23 -> 496,22 -> 496,23 -> 498,23 -> 498,21 -> 498,23 -> 500,23 -> 500,18 -> 500,23 -> 502,23 -> 502,15 -> 502,23 -> 504,23 -> 504,22 -> 504,23 -> 506,23 -> 506,18 -> 506,23 -> 508,23 -> 508,19 -> 508,23 +499,84 -> 499,80 -> 499,84 -> 501,84 -> 501,77 -> 501,84 -> 503,84 -> 503,75 -> 503,84 -> 505,84 -> 505,83 -> 505,84 +490,23 -> 490,13 -> 490,23 -> 492,23 -> 492,17 -> 492,23 -> 494,23 -> 494,18 -> 494,23 -> 496,23 -> 496,22 -> 496,23 -> 498,23 -> 498,21 -> 498,23 -> 500,23 -> 500,18 -> 500,23 -> 502,23 -> 502,15 -> 502,23 -> 504,23 -> 504,22 -> 504,23 -> 506,23 -> 506,18 -> 506,23 -> 508,23 -> 508,19 -> 508,23 +494,97 -> 494,92 -> 494,97 -> 496,97 -> 496,91 -> 496,97 -> 498,97 -> 498,88 -> 498,97 -> 500,97 -> 500,94 -> 500,97 +486,141 -> 491,141 +499,84 -> 499,80 -> 499,84 -> 501,84 -> 501,77 -> 501,84 -> 503,84 -> 503,75 -> 503,84 -> 505,84 -> 505,83 -> 505,84 +499,27 -> 499,28 -> 519,28 +499,84 -> 499,80 -> 499,84 -> 501,84 -> 501,77 -> 501,84 -> 503,84 -> 503,75 -> 503,84 -> 505,84 -> 505,83 -> 505,84 +513,57 -> 517,57 +483,144 -> 487,144 diff --git a/2022/Day15CSharp/Day15CSharp.csproj b/2022/Day15CSharp/Day15CSharp.csproj new file mode 100644 index 0000000..d439800 --- /dev/null +++ b/2022/Day15CSharp/Day15CSharp.csproj @@ -0,0 +1,10 @@ + + + + Exe + net7.0 + enable + enable + + + diff --git a/2022/Day15CSharp/Program.cs b/2022/Day15CSharp/Program.cs new file mode 100644 index 0000000..2c140cd --- /dev/null +++ b/2022/Day15CSharp/Program.cs @@ -0,0 +1,413 @@ +// See https://aka.ms/new-console-template for more information +using System.ComponentModel; +using System.Diagnostics; +using System.Drawing; +using System.Numerics; +using System.Runtime.InteropServices; +using System.Security; +using System.Security.Cryptography.X509Certificates; + +Console.WriteLine("!! === Part 01 === !!"); +Console.WriteLine("=== Example Data ==="); +var exampleData = new DataSet("example-input.txt"); +//exampleData.Print(); +Console.WriteLine("Coverage on row {0}: {1}", 10, exampleData.CalculateCoverage(10)); + +Console.WriteLine(); + +Console.WriteLine("=== Puzzle Data ==="); +var puzzleData = new DataSet("puzzle-input.txt"); +Console.WriteLine("Coverage on row {0}: {1}", 2000000, puzzleData.CalculateCoverage(2000000)); + +Console.WriteLine("!! === Part 02 === !!"); +Console.WriteLine("Example Tuning Frequency: " + exampleData.GetTuningFrequencyQuadSearch(20,1)); +Console.WriteLine("Example Tuning Frequency: " + exampleData.GetTuningFrequencyQuadSearch(20, 4)); + +Console.WriteLine(); + +Stopwatch sw = Stopwatch.StartNew(); +var result = puzzleData.GetTuningFrequencyQuadSearch(4000000, 10); +sw.Stop(); + +Console.Write("Puzzle Tuning Frequency: {0} in {1} milliseconds ", result, sw.ElapsedMilliseconds); + +class Beacon +{ + public Beacon(int x, int y) + { + Point = new Point(x, y); + } + + public Point Point { get; } +} + +class Sensor +{ + public Sensor(int x, int y, Beacon closestBeacon) + { + Point = new Point(x, y); + ClosestBeacon = closestBeacon; + MaxDistance = ManhattanDistance(ClosestBeacon.Point, this.Point); + } + + public Point Point { get; } + public Beacon ClosestBeacon { get; } + + public int MaxDistance { get; } + + public bool Covers(Rectangle r) + { + Point topLeft = new Point(r.X, r.Y); + Point topRight = new Point(r.Right, r.Y); + Point bottomLeft = new Point(r.X, r.Bottom); + Point bottomRight = new Point(r.Right, r.Bottom); + + return Covers(topLeft) && Covers(topRight) && Covers(bottomLeft) && Covers(bottomRight); + } + + public bool Covers(Point p) + { + return ManhattanDistance(p, this.Point) <= MaxDistance; + } + + private int ManhattanDistance(Point l, Point r) + { + return Math.Abs(l.X - r.X) + Math.Abs(l.Y - r.Y); + } +} + +class DataSet +{ + public Dictionary Sensors { get; set; } = new Dictionary(); + public Dictionary Beacons { get; set; } = new Dictionary(); + + public Rectangle Bounds { get; set; } + + private int ManhattanDistance(Point l, Point r) + { + return Math.Abs(l.X - r.X) + Math.Abs(l.Y - r.Y); + } + + public BigInteger GetTuningFrequencyFromX(int x, int y) + { + return ((BigInteger)x * (BigInteger)4000000) + y; + } + + public BigInteger GetTuningFrequencyQuadSearch(int maxValue, int minSearchSize) + { + BigInteger toRet = -1; + + Rectangle searchSpace = new Rectangle(0, 0, maxValue, maxValue); + + var result = GetMissingXQuadSearch(searchSpace, minSearchSize); + + if (result.X == -1) throw new InvalidDataException(); + + return GetTuningFrequencyFromX(result.X, result.Y); + } + + private Point GetMissingXQuadSearch(Rectangle searchSpace, int minSearchSize, bool printProgress = false) + { + if (printProgress) Console.WriteLine("Searching searchspace: " + searchSpace); + + bool covered = false; + foreach (var sensor in Sensors.Values) + { + if (sensor.Covers(searchSpace)) + { + covered = true; + break; + } + } + + if (covered) + { + if (printProgress) Console.WriteLine("Searchspace is covered: " + searchSpace); + + return new Point(-1,-1); + } + + if (searchSpace.Height > minSearchSize) + { + var result = new Point(-1,-1); + + // Split the rectangle into 4 and search that + + // topleft + Rectangle newSearchSpace = new Rectangle(searchSpace.X, searchSpace.Y, searchSpace.Width / 2, searchSpace.Height / 2); + result = GetMissingXQuadSearch(newSearchSpace, minSearchSize); + if (result.X != -1) return result; + + // shift right + newSearchSpace.Offset(searchSpace.Width / 2, 0); + result = GetMissingXQuadSearch(newSearchSpace, minSearchSize); + if (result.X != -1) return result; + + // shift down + newSearchSpace.Offset(0, searchSpace.Height / 2); + result = GetMissingXQuadSearch(newSearchSpace, minSearchSize); + if (result.X != -1) return result; + + // shift left + newSearchSpace.Offset(-1*(searchSpace.Width / 2), 0); + result = GetMissingXQuadSearch(newSearchSpace, minSearchSize); + if (result.X != -1) return result; + } + else + { + if (printProgress) Console.WriteLine("Brute searching space " + searchSpace); + for (int row = searchSpace.Top; row <= searchSpace.Bottom; row++) + { + int result = GetMissingBeaconX(row, searchSpace.Left, searchSpace.Right, false); + if (result != -1) return new Point(result, row); + } + } + + return new Point(-1, -1); + } + + public int GetMissingBeaconX(int row, int minX = int.MinValue, int maxX = int.MaxValue, bool useSegments = true) + { + const int numberOfSegments = 10; + List searchSegments = new List(numberOfSegments); + int segmentLength = maxX / numberOfSegments; + + if (useSegments) + { + for (int i = 0; i < numberOfSegments; i++) + { + searchSegments.Add(i * segmentLength); + } + + if (searchSegments[searchSegments.Count - 1] + segmentLength != maxX) throw new InvalidDataException(); + + // Cut down the search space first + foreach (var sensor in Sensors.Values) + { + int maxDistance = ManhattanDistance(sensor.ClosestBeacon.Point, sensor.Point); + + for (int i = 0; i < searchSegments.Count; i++) + { + Point left = new Point(searchSegments[i], row); + Point right = new Point(searchSegments[i] + segmentLength, row); + + if (ManhattanDistance(left, sensor.Point) <= maxDistance && ManhattanDistance(right, sensor.Point) <= maxDistance) + { + //Console.WriteLine("skipping {0} to {1}", left.X, right.X); + searchSegments.RemoveAt(i); + } + } + + if (searchSegments.Count == 0) + return -1; + } + } + else + { + searchSegments.Add(minX); + segmentLength = maxX - minX; + } + + foreach (var searchSegment in searchSegments) + { + Dictionary coverage = new Dictionary(); + + int leftX = searchSegment; + int rightX = searchSegment + segmentLength; + + + foreach (var sensor in Sensors.Values) + { + int startingX; + + if (sensor.Point.X <= rightX && sensor.Point.X >= leftX) + { + startingX = sensor.Point.X; + } + else if (sensor.Point.X >= rightX) + { + startingX = rightX; + } + else + { + startingX = leftX; + } + + Point startingPoint = new Point(startingX, row); + int maxDistance = ManhattanDistance(sensor.ClosestBeacon.Point, sensor.Point); + + // From start, go left + Point currentPoint = new Point(startingPoint.X, row); + while (currentPoint.X >= leftX && ManhattanDistance(currentPoint, sensor.Point) <= maxDistance) + { + coverage[currentPoint.X] = true; + currentPoint.X--; + + if (coverage.Count == (rightX - leftX) + 1) + { + break; + } + } + + // From start, go right + currentPoint = new Point(startingPoint.X, row); + while (currentPoint.X <= rightX && ManhattanDistance(currentPoint, sensor.Point) <= maxDistance) + { + coverage[currentPoint.X] = true; + currentPoint.X++; + + if (coverage.Count == (rightX - leftX) + 1) + { + break; + } + } + + if (coverage.Count == (rightX - leftX) + 1) + { + break; + } + } + + if (coverage.Count != (rightX - leftX) + 1) + { + for (int i = leftX; i <= rightX; i++) + { + if (!coverage.ContainsKey(i)) + return i; + } + + throw new InvalidDataException(); + } + } + + return -1; + } + + public int CalculateCoverage(int row, int minX = int.MinValue, int maxX = int.MaxValue) + { + Dictionary coverage = new Dictionary(); + + foreach (var sensor in Sensors.Values) + { + // Check straight down + Point startingPoint = new Point(sensor.Point.X, row); + int maxDistance = ManhattanDistance(sensor.ClosestBeacon.Point, sensor.Point); + + // From start, go left + Point currentPoint = new Point(startingPoint.X, startingPoint.Y); + while (currentPoint.X >= minX && ManhattanDistance(currentPoint, sensor.Point) <= maxDistance) + { + if (!Beacons.ContainsKey(currentPoint)) + { + coverage[currentPoint] = true; + } + currentPoint.X--; + } + + // From start, go right + currentPoint = new Point(startingPoint.X, startingPoint.Y); + while (currentPoint.X <= maxX && ManhattanDistance(currentPoint, sensor.Point) <= maxDistance) + { + if (!Beacons.ContainsKey(currentPoint)) + { + coverage[currentPoint] = true; + } + currentPoint.X++; + } + } + + return coverage.Count; + } + + public void Print() + { + int x_min = Bounds.Left, x_max = x_min + Bounds.Width, y_min = Bounds.Top, y_max = y_min + Bounds.Height; + + for (int y = y_min; y <= y_max; y++) + { + for (int x = x_min; x <= x_max; x++) + { + var point = new Point(x, y); + + if (Sensors.ContainsKey(point)) + { + Console.Write("S"); + } + else if (Beacons.ContainsKey(point)) + { + Console.Write("B"); + } + else + { + Console.Write('.'); + } + } + Console.WriteLine(); + } + } + + + private void FindBounds() + { + int x_min = int.MaxValue; + int x_max = int.MinValue; + int y_min = 0; // sand always starts at 0 + int y_max = int.MinValue; + + foreach (var item in Sensors) + { + x_min = Int32.Min(item.Key.X, x_min); + x_max = Int32.Max(item.Key.X, x_max); + y_min = Int32.Min(item.Key.Y, y_min); + y_max = Int32.Max(item.Key.Y, y_max); + } + foreach (var item in Beacons) + { + x_min = Int32.Min(item.Key.X, x_min); + x_max = Int32.Max(item.Key.X, x_max); + y_min = Int32.Min(item.Key.Y, y_min); + y_max = Int32.Max(item.Key.Y, y_max); + } + + Bounds = new Rectangle(x_min, y_min, x_max - x_min, y_max - y_min); + } + + public DataSet(string filename) + { + using (StreamReader reader = System.IO.File.OpenText(filename)) + { + while (!reader.EndOfStream) + { + string? line = reader.ReadLine(); + if (line == null) throw new InvalidDataException(); + + Beacon? beacon = null; + // Beacon + { + string right = line.Split(':')[1]; + string x_str = right.Split("x=")[1].Substring(0, right.Split("x=")[1].IndexOf(',')); + string y_str = right.Split("y=")[1]; + + beacon = new Beacon(Int32.Parse(x_str), Int32.Parse(y_str)); + } + + if (!Beacons.ContainsKey(beacon.Point)) + { + Beacons[beacon.Point] = beacon; + } + + // Sensor + { + string left = line.Split(':')[0]; + string x_str = left.Split("x=")[1].Substring(0, left.Split("x=")[1].IndexOf(',')); + string y_str = left.Split("y=")[1]; + + Sensor sensor = new Sensor(Int32.Parse(x_str), Int32.Parse(y_str), beacon); + Sensors[sensor.Point] = sensor; + } + } + } + + FindBounds(); + } +} \ No newline at end of file diff --git a/2022/Day15CSharp/Properties/launchSettings.json b/2022/Day15CSharp/Properties/launchSettings.json new file mode 100644 index 0000000..915a366 --- /dev/null +++ b/2022/Day15CSharp/Properties/launchSettings.json @@ -0,0 +1,8 @@ +{ + "profiles": { + "Day15CSharp": { + "commandName": "Project", + "workingDirectory": "C:\\dev\\DevSandbox\\AdventOfCode\\2022\\Day15CSharp" + } + } +} \ No newline at end of file diff --git a/2022/Day15CSharp/example-input.txt b/2022/Day15CSharp/example-input.txt new file mode 100644 index 0000000..91960de --- /dev/null +++ b/2022/Day15CSharp/example-input.txt @@ -0,0 +1,14 @@ +Sensor at x=2, y=18: closest beacon is at x=-2, y=15 +Sensor at x=9, y=16: closest beacon is at x=10, y=16 +Sensor at x=13, y=2: closest beacon is at x=15, y=3 +Sensor at x=12, y=14: closest beacon is at x=10, y=16 +Sensor at x=10, y=20: closest beacon is at x=10, y=16 +Sensor at x=14, y=17: closest beacon is at x=10, y=16 +Sensor at x=8, y=7: closest beacon is at x=2, y=10 +Sensor at x=2, y=0: closest beacon is at x=2, y=10 +Sensor at x=0, y=11: closest beacon is at x=2, y=10 +Sensor at x=20, y=14: closest beacon is at x=25, y=17 +Sensor at x=17, y=20: closest beacon is at x=21, y=22 +Sensor at x=16, y=7: closest beacon is at x=15, y=3 +Sensor at x=14, y=3: closest beacon is at x=15, y=3 +Sensor at x=20, y=1: closest beacon is at x=15, y=3 \ No newline at end of file diff --git a/2022/Day15CSharp/problem.txt b/2022/Day15CSharp/problem.txt new file mode 100644 index 0000000..5669e86 --- /dev/null +++ b/2022/Day15CSharp/problem.txt @@ -0,0 +1,113 @@ +--- Day 15: Beacon Exclusion Zone --- + +You feel the ground rumble again as the distress signal leads you to a large network of subterranean tunnels. You don't have time to search them all, but you don't need to: your pack contains a set of deployable sensors that you imagine were originally built to locate lost Elves. + +The sensors aren't very powerful, but that's okay; your handheld device indicates that you're close enough to the source of the distress signal to use them. You pull the emergency sensor system out of your pack, hit the big button on top, and the sensors zoom off down the tunnels. + +Once a sensor finds a spot it thinks will give it a good reading, it attaches itself to a hard surface and begins monitoring for the nearest signal source beacon. Sensors and beacons always exist at integer coordinates. Each sensor knows its own position and can determine the position of a beacon precisely; however, sensors can only lock on to the one beacon closest to the sensor as measured by the Manhattan distance. (There is never a tie where two beacons are the same distance to a sensor.) + +It doesn't take long for the sensors to report back their positions and closest beacons (your puzzle input). For example: + +Sensor at x=2, y=18: closest beacon is at x=-2, y=15 +Sensor at x=9, y=16: closest beacon is at x=10, y=16 +Sensor at x=13, y=2: closest beacon is at x=15, y=3 +Sensor at x=12, y=14: closest beacon is at x=10, y=16 +Sensor at x=10, y=20: closest beacon is at x=10, y=16 +Sensor at x=14, y=17: closest beacon is at x=10, y=16 +Sensor at x=8, y=7: closest beacon is at x=2, y=10 +Sensor at x=2, y=0: closest beacon is at x=2, y=10 +Sensor at x=0, y=11: closest beacon is at x=2, y=10 +Sensor at x=20, y=14: closest beacon is at x=25, y=17 +Sensor at x=17, y=20: closest beacon is at x=21, y=22 +Sensor at x=16, y=7: closest beacon is at x=15, y=3 +Sensor at x=14, y=3: closest beacon is at x=15, y=3 +Sensor at x=20, y=1: closest beacon is at x=15, y=3 + +So, consider the sensor at 2,18; the closest beacon to it is at -2,15. For the sensor at 9,16, the closest beacon to it is at 10,16. + +Drawing sensors as S and beacons as B, the above arrangement of sensors and beacons looks like this: + + 1 1 2 2 + 0 5 0 5 0 5 + 0 ....S....................... + 1 ......................S..... + 2 ...............S............ + 3 ................SB.......... + 4 ............................ + 5 ............................ + 6 ............................ + 7 ..........S.......S......... + 8 ............................ + 9 ............................ +10 ....B....................... +11 ..S......................... +12 ............................ +13 ............................ +14 ..............S.......S..... +15 B........................... +16 ...........SB............... +17 ................S..........B +18 ....S....................... +19 ............................ +20 ............S......S........ +21 ............................ +22 .......................B.... + +This isn't necessarily a comprehensive map of all beacons in the area, though. Because each sensor only identifies its closest beacon, if a sensor detects a beacon, you know there are no other beacons that close or closer to that sensor. There could still be beacons that just happen to not be the closest beacon to any sensor. Consider the sensor at 8,7: + + 1 1 2 2 + 0 5 0 5 0 5 +-2 ..........#................. +-1 .........###................ + 0 ....S...#####............... + 1 .......#######........S..... + 2 ......#########S............ + 3 .....###########SB.......... + 4 ....#############........... + 5 ...###############.......... + 6 ..#################......... + 7 .#########S#######S#........ + 8 ..#################......... + 9 ...###############.......... +10 ....B############........... +11 ..S..###########............ +12 ......#########............. +13 .......#######.............. +14 ........#####.S.......S..... +15 B........###................ +16 ..........#SB............... +17 ................S..........B +18 ....S....................... +19 ............................ +20 ............S......S........ +21 ............................ +22 .......................B.... + +This sensor's closest beacon is at 2,10, and so you know there are no beacons that close or closer (in any positions marked #). + +None of the detected beacons seem to be producing the distress signal, so you'll need to work out where the distress beacon is by working out where it isn't. For now, keep things simple by counting the positions where a beacon cannot possibly be along just a single row. + +So, suppose you have an arrangement of beacons and sensors like in the example above and, just in the row where y=10, you'd like to count the number of positions a beacon cannot possibly exist. The coverage from all sensors near that row looks like this: + + 1 1 2 2 + 0 5 0 5 0 5 + 9 ...#########################... +10 ..####B######################.. +11 .###S#############.###########. + +In this example, in the row where y=10, there are 26 positions where a beacon cannot be present. + +Consult the report from the sensors you just deployed. In the row where y=2000000, how many positions cannot contain a beacon? + +Your puzzle answer was 5511201. + +The first half of this puzzle is complete! It provides one gold star: * +--- Part Two --- + +Your handheld device indicates that the distress signal is coming from a beacon nearby. The distress beacon is not detected by any sensor, but the distress beacon must have x and y coordinates each no lower than 0 and no larger than 4000000. + +To isolate the distress beacon's signal, you need to determine its tuning frequency, which can be found by multiplying its x coordinate by 4000000 and then adding its y coordinate. + +In the example above, the search space is smaller: instead, the x and y coordinates can each be at most 20. With this reduced search area, there is only a single position that could have a beacon: x=14, y=11. The tuning frequency for this distress beacon is 56000011. + +Find the only possible position for the distress beacon. What is its tuning frequency? diff --git a/2022/Day15CSharp/puzzle-input.txt b/2022/Day15CSharp/puzzle-input.txt new file mode 100644 index 0000000..4276b1c --- /dev/null +++ b/2022/Day15CSharp/puzzle-input.txt @@ -0,0 +1,29 @@ +Sensor at x=3797530, y=3451192: closest beacon is at x=3316341, y=3328308 +Sensor at x=3779164, y=33938: closest beacon is at x=4608350, y=708806 +Sensor at x=1331810, y=3260896: closest beacon is at x=2075597, y=3280016 +Sensor at x=393374, y=696899: closest beacon is at x=2021690, y=453306 +Sensor at x=2928048, y=923094: closest beacon is at x=2021690, y=453306 +Sensor at x=2386726, y=3645023: closest beacon is at x=2075597, y=3280016 +Sensor at x=1900159, y=2381031: closest beacon is at x=1649961, y=2000000 +Sensor at x=2601378, y=2979844: closest beacon is at x=2218962, y=2701963 +Sensor at x=2254818, y=32199: closest beacon is at x=2021690, y=453306 +Sensor at x=2689643, y=375840: closest beacon is at x=2021690, y=453306 +Sensor at x=909141, y=2842547: closest beacon is at x=2218962, y=2701963 +Sensor at x=3915731, y=2454320: closest beacon is at x=4268501, y=1853073 +Sensor at x=1693574, y=1344104: closest beacon is at x=1649961, y=2000000 +Sensor at x=1760260, y=3297662: closest beacon is at x=2075597, y=3280016 +Sensor at x=1909567, y=3990737: closest beacon is at x=2075597, y=3280016 +Sensor at x=2097863, y=3179766: closest beacon is at x=2075597, y=3280016 +Sensor at x=3100489, y=3623847: closest beacon is at x=3104748, y=4102403 +Sensor at x=2746023, y=2432826: closest beacon is at x=2218962, y=2701963 +Sensor at x=3031245, y=3031354: closest beacon is at x=3316341, y=3328308 +Sensor at x=277094, y=1999350: closest beacon is at x=1649961, y=2000000 +Sensor at x=1763269, y=126349: closest beacon is at x=2021690, y=453306 +Sensor at x=3287624, y=2695420: closest beacon is at x=3316341, y=3328308 +Sensor at x=2371102, y=1745103: closest beacon is at x=1649961, y=2000000 +Sensor at x=3553438, y=1563379: closest beacon is at x=4268501, y=1853073 +Sensor at x=1529129, y=2735122: closest beacon is at x=2218962, y=2701963 +Sensor at x=2826220, y=3958350: closest beacon is at x=3104748, y=4102403 +Sensor at x=3999334, y=3912693: closest beacon is at x=3104748, y=4102403 +Sensor at x=240430, y=3829436: closest beacon is at x=-742036, y=3963149 +Sensor at x=3455748, y=3814861: closest beacon is at x=3316341, y=3328308 diff --git a/2022/Day16CSharp/Day16CSharp.csproj b/2022/Day16CSharp/Day16CSharp.csproj new file mode 100644 index 0000000..d439800 --- /dev/null +++ b/2022/Day16CSharp/Day16CSharp.csproj @@ -0,0 +1,10 @@ + + + + Exe + net7.0 + enable + enable + + + diff --git a/2022/Day16CSharp/Program.cs b/2022/Day16CSharp/Program.cs new file mode 100644 index 0000000..4889f28 --- /dev/null +++ b/2022/Day16CSharp/Program.cs @@ -0,0 +1,427 @@ +// See https://aka.ms/new-console-template for more information + +using System.Net.Http.Headers; +using System.Reflection; + +Part01(); + +void Part01() +{ + Console.WriteLine("!! === Part 01 === !!"); + + Console.WriteLine("=== Example ==="); + var exampleData = new VolcanoData("example-input.txt"); + Console.WriteLine("Most Pressure Released: {0}", exampleData.GetMostPossiblePressureReleased(31)); + + Console.WriteLine("=== Puzzle ==="); + var puzzleData = new VolcanoData("puzzle-input.txt"); + Console.WriteLine("Most Pressure Released: {0}", puzzleData.GetMostPossiblePressureReleased(31)); +} + +class StepList + : IComparable +{ + public struct Step + { + public enum StepType + { + First, + Move, + Open + } + + public StepType Type { get; set; } + public Tuple Value { get; set; } + + public Step() + { + Type = StepType.First; + Value = new Tuple("AA", "0"); + } + + public Step(string sourceValve, string targetValve) + { + Type = StepType.Move; + Value = new Tuple(sourceValve, targetValve); + } + + public Step(string valvename, int stepNumber) + { + Type = StepType.Open; + Value = new Tuple(valvename, stepNumber.ToString()); + } + } + + private List Steps { get; } + private Dictionary OpenedValves { get; } + + private IReadOnlyDictionary Valves { get; } + + public bool isValveOpen(string valveName) + { + return OpenedValves.ContainsKey(valveName); + } + + public StepList(IReadOnlyDictionary valves, int maxSteps = 31) + { + MaxSteps = maxSteps; + Valves = valves; + + OpenedValves = new Dictionary(); + Steps = new List(); + } + + public StepList(StepList other) + { + MaxSteps = other.MaxSteps; + Valves = other.Valves; + + OpenedValves = new Dictionary(); + Steps = new List(); + + foreach (var item in other.OpenedValves) + { + OpenedValves[item.Key] = item.Value; + } + + foreach (var item in other.Steps) + { + Steps.Add(item); + } + } + + public int MaxSteps { get; } + + public int StepCount + { + get + { + return Steps.Count; + } + } + + public bool CanContinue + { + get + { + return StepCount < MaxSteps; + } + } + + public Step Latest + { + get + { + if (Steps.Count == 0) return new Step(); + return Steps[Steps.Count - 1]; + } + } + + public bool AddStep(Step step) + { + if (StepCount < MaxSteps) + { + Steps.Add(step); + + if (step.Type == Step.StepType.Open) + { + if (OpenedValves.ContainsKey(step.Value.Item1)) throw new InvalidDataException(); + OpenedValves[step.Value.Item1] = true; + } + + return true; + } + + return false; + } + + public int GetPressureReleased() + { + int total = 0; + + for (int i =0; i< Steps.Count; i++) + { + var step = Steps[i]; + + if (step.Type == Step.StepType.Open) + { + int timeOpen = MaxSteps - (Int32.Parse(step.Value.Item2)+1); + + total += Valves[step.Value.Item1].FlowRate * timeOpen; + } + + } + + return total; + } + + public int CompareTo(object? obj) + { + var other = obj as StepList; + if (other == null) throw new ArgumentException(); + + return this.GetPressureReleased().CompareTo(other.GetPressureReleased()); + } + + public static StepList GenerateBestPath(StepList sl) + { + if (!sl.CanContinue) + return sl; + + var lastStep = sl.Latest; + + Valve valve = sl.Valves[lastStep.Value.Item1]; + + List paths = new List(); + paths.Add(sl); + + // Just did a move, see if we need to open this valve + if (lastStep.Type == StepList.Step.StepType.Move || lastStep.Type == Step.StepType.First) + { + // if it was a move, then our current valve is the target + if (lastStep.Type == StepList.Step.StepType.Move) + valve = sl.Valves[lastStep.Value.Item2]; + + // Valve isnt open and maybe should be + if (!sl.isValveOpen(valve.Name) && valve.FlowRate > 0) + { + // Open valve path + { + StepList copy = new StepList(sl); + + copy.AddStep(new Step(valve.Name, sl.StepCount)); + copy = GenerateBestPath(copy); + + paths.Add(copy); + } + + // leave it closed path + foreach (var tunnel in valve.AdjacentValves) + { + if (lastStep.Type == Step.StepType.Move && lastStep.Value.Item1 == tunnel.Name) + continue; // Dont bounce back and forth, can go back if it was an open tho + + StepList copy = new StepList(sl); + + copy.AddStep(new Step(valve.Name, tunnel.Name)); + copy = GenerateBestPath(copy); + + paths.Add(copy); + + StepList toRet = paths[0]; + foreach (var item in paths) + { + if (item.GetPressureReleased() > toRet.GetPressureReleased()) + { + toRet = item; + } + } + + return toRet; + } + } + } + + // Either the valve is already open or not worth opening + foreach (var tunnel in valve.AdjacentValves) + { + if (lastStep.Type == Step.StepType.Move && lastStep.Value.Item1 == tunnel.Name) + continue; // Dont bounce back and forth, can go back if it was an open tho + + StepList copy = new StepList(sl); + + copy.AddStep(new Step(valve.Name, tunnel.Name)); + copy = GenerateBestPath(copy); + + paths.Add(copy); + } + + { + StepList toRet = paths[0]; + foreach (var item in paths) + { + if (item.GetPressureReleased() > toRet.GetPressureReleased()) + { + toRet = item; + } + } + + return toRet; + } + } +} + +class CaveGraph +{ + public class CaveNode + { + public CaveNode(Valve v) + { + Valve = v; + } + + public List AdjacentNodes { get; set; } = new List(); + public List AdjacentPathWeights { get; set; } = new List(); + + public Valve Valve { get; } + + public string Name + { + get + { + return Valve.Name; + } + } + + public int FlowRate + { + get + { + return Valve.FlowRate; + } + } + } + + private void CompressNodes(CaveNode cn, List targets, int currentWeight) + { + foreach (var v in targets) + { + if (v.FlowRate > 0) + { + cn.AdjacentNodes.Add(CaveNodes[v.Name]); + } + } + } + + public Dictionary CaveNodes { get; } + + public CaveGraph(Dictionary valves) + { + CaveNodes = new Dictionary(); + + foreach (var item in valves) + { + var valve = item.Value; + // TODO + CaveNode cn = new CaveNode(valve); + //CaveNodes.Add(cn); + } + } +} + +class VolcanoData +{ + public VolcanoData(string filename) + { + Valves = new Dictionary(); + StartingValve = new Valve("AA", 0); + + using (StreamReader reader = System.IO.File.OpenText(filename)) + { + while (!reader.EndOfStream) + { + var line = reader.ReadLine(); + if (line == null) throw new InvalidDataException(); + + // Read in the valve name + string newValveName = line.Split(' ')[1]; + int flowRate = Int32.Parse(line.Split('=')[1].Substring(0, line.Split("=")[1].IndexOf(';'))); + + if (!Valves.ContainsKey(newValveName)) + { + Valves[newValveName] = new Valve(newValveName, flowRate); + } + else + { + Valves[newValveName].FlowRate = flowRate; + } + + // Read in adjacent valves + string[] valves; + + if (line.Contains("to valve ")) + { + valves = line.Split("to valve ")[1].Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries); + } + else if (line.Contains("to valves ")) + { + valves = line.Split("valves ")[1].Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries); + } + else + { + throw new InvalidDataException(); + } + + foreach (var adjacentValve in valves) + { + if (!Valves.ContainsKey(adjacentValve)) + { + Valves[adjacentValve] = new Valve(adjacentValve, -1); + } + + Valves[newValveName].AdjacentValves.Add(Valves[adjacentValve]); + } + } + } + + StartingValve = Valves["AA"]; + + CaveGraph cg = new CaveGraph(Valves); + } + + public void Print() + { + foreach (var item in Valves) + { + Console.Write("{0}; tunnels lead to ", item.Value); + + bool first = true; + foreach (var v in item.Value.AdjacentValves) + { + if (!first) Console.Write(", "); + Console.Write(v.Name); + first = false; + } + Console.WriteLine(); + } + } + + public Dictionary Valves { get; } + + public Valve StartingValve { get; } + + public int GetMostPossiblePressureReleased(int maxSteps) + { + StepList sl = new StepList(Valves, maxSteps); + + sl.AddStep(new StepList.Step()); + + sl = StepList.GenerateBestPath(sl); + + return sl.GetPressureReleased(); + } +} + +class Valve +{ + public Valve(string name, int flowRate) + { + Name = name; + FlowRate = flowRate; + AdjacentValves = new List(); + } + + public List AdjacentValves + { + get; + } + + public int FlowRate { get; set; } + public string Name { get; } + + public override string ToString() + { + return String.Format("Valve: ({0}) Flow ({1}): ", Name, FlowRate); + } +} + diff --git a/2022/Day16CSharp/Properties/launchSettings.json b/2022/Day16CSharp/Properties/launchSettings.json new file mode 100644 index 0000000..d9b8621 --- /dev/null +++ b/2022/Day16CSharp/Properties/launchSettings.json @@ -0,0 +1,8 @@ +{ + "profiles": { + "Day16CSharp": { + "commandName": "Project", + "workingDirectory": "C:\\dev\\DevSandbox\\AdventOfCode\\2022\\Day16CSharp" + } + } +} \ No newline at end of file diff --git a/2022/Day16CSharp/example-input.txt b/2022/Day16CSharp/example-input.txt new file mode 100644 index 0000000..dd7006b --- /dev/null +++ b/2022/Day16CSharp/example-input.txt @@ -0,0 +1,10 @@ +Valve AA has flow rate=0; tunnels lead to valves DD, II, BB +Valve BB has flow rate=13; tunnels lead to valves CC, AA +Valve CC has flow rate=2; tunnels lead to valves DD, BB +Valve DD has flow rate=20; tunnels lead to valves CC, AA, EE +Valve EE has flow rate=3; tunnels lead to valves FF, DD +Valve FF has flow rate=0; tunnels lead to valves EE, GG +Valve GG has flow rate=0; tunnels lead to valves FF, HH +Valve HH has flow rate=22; tunnel leads to valve GG +Valve II has flow rate=0; tunnels lead to valves AA, JJ +Valve JJ has flow rate=21; tunnel leads to valve II \ No newline at end of file diff --git a/2022/Day16CSharp/problem.txt b/2022/Day16CSharp/problem.txt new file mode 100644 index 0000000..d937625 --- /dev/null +++ b/2022/Day16CSharp/problem.txt @@ -0,0 +1,146 @@ +--- Day 16: Proboscidea Volcanium --- + +The sensors have led you to the origin of the distress signal: yet another handheld device, just like the one the Elves gave you. However, you don't see any Elves around; instead, the device is surrounded by elephants! They must have gotten lost in these tunnels, and one of the elephants apparently figured out how to turn on the distress signal. + +The ground rumbles again, much stronger this time. What kind of cave is this, exactly? You scan the cave with your handheld device; it reports mostly igneous rock, some ash, pockets of pressurized gas, magma... this isn't just a cave, it's a volcano! + +You need to get the elephants out of here, quickly. Your device estimates that you have 30 minutes before the volcano erupts, so you don't have time to go back out the way you came in. + +You scan the cave for other options and discover a network of pipes and pressure-release valves. You aren't sure how such a system got into a volcano, but you don't have time to complain; your device produces a report (your puzzle input) of each valve's flow rate if it were opened (in pressure per minute) and the tunnels you could use to move between the valves. + +There's even a valve in the room you and the elephants are currently standing in labeled AA. You estimate it will take you one minute to open a single valve and one minute to follow any tunnel from one valve to another. What is the most pressure you could release? + +For example, suppose you had the following scan output: + +Valve AA has flow rate=0; tunnels lead to valves DD, II, BB +Valve BB has flow rate=13; tunnels lead to valves CC, AA +Valve CC has flow rate=2; tunnels lead to valves DD, BB +Valve DD has flow rate=20; tunnels lead to valves CC, AA, EE +Valve EE has flow rate=3; tunnels lead to valves FF, DD +Valve FF has flow rate=0; tunnels lead to valves EE, GG +Valve GG has flow rate=0; tunnels lead to valves FF, HH +Valve HH has flow rate=22; tunnel leads to valve GG +Valve II has flow rate=0; tunnels lead to valves AA, JJ +Valve JJ has flow rate=21; tunnel leads to valve II + +All of the valves begin closed. You start at valve AA, but it must be damaged or jammed or something: its flow rate is 0, so there's no point in opening it. However, you could spend one minute moving to valve BB and another minute opening it; doing so would release pressure during the remaining 28 minutes at a flow rate of 13, a total eventual pressure release of 28 * 13 = 364. Then, you could spend your third minute moving to valve CC and your fourth minute opening it, providing an additional 26 minutes of eventual pressure release at a flow rate of 2, or 52 total pressure released by valve CC. + +Making your way through the tunnels like this, you could probably open many or all of the valves by the time 30 minutes have elapsed. However, you need to release as much pressure as possible, so you'll need to be methodical. Instead, consider this approach: + +== Minute 1 == +No valves are open. +You move to valve DD. + +== Minute 2 == +No valves are open. +You open valve DD. + +== Minute 3 == +Valve DD is open, releasing 20 pressure. +You move to valve CC. + +== Minute 4 == +Valve DD is open, releasing 20 pressure. +You move to valve BB. + +== Minute 5 == +Valve DD is open, releasing 20 pressure. +You open valve BB. + +== Minute 6 == +Valves BB and DD are open, releasing 33 pressure. +You move to valve AA. + +== Minute 7 == +Valves BB and DD are open, releasing 33 pressure. +You move to valve II. + +== Minute 8 == +Valves BB and DD are open, releasing 33 pressure. +You move to valve JJ. + +== Minute 9 == +Valves BB and DD are open, releasing 33 pressure. +You open valve JJ. + +== Minute 10 == +Valves BB, DD, and JJ are open, releasing 54 pressure. +You move to valve II. + +== Minute 11 == +Valves BB, DD, and JJ are open, releasing 54 pressure. +You move to valve AA. + +== Minute 12 == +Valves BB, DD, and JJ are open, releasing 54 pressure. +You move to valve DD. + +== Minute 13 == +Valves BB, DD, and JJ are open, releasing 54 pressure. +You move to valve EE. + +== Minute 14 == +Valves BB, DD, and JJ are open, releasing 54 pressure. +You move to valve FF. + +== Minute 15 == +Valves BB, DD, and JJ are open, releasing 54 pressure. +You move to valve GG. + +== Minute 16 == +Valves BB, DD, and JJ are open, releasing 54 pressure. +You move to valve HH. + +== Minute 17 == +Valves BB, DD, and JJ are open, releasing 54 pressure. +You open valve HH. + +== Minute 18 == +Valves BB, DD, HH, and JJ are open, releasing 76 pressure. +You move to valve GG. + +== Minute 19 == +Valves BB, DD, HH, and JJ are open, releasing 76 pressure. +You move to valve FF. + +== Minute 20 == +Valves BB, DD, HH, and JJ are open, releasing 76 pressure. +You move to valve EE. + +== Minute 21 == +Valves BB, DD, HH, and JJ are open, releasing 76 pressure. +You open valve EE. + +== Minute 22 == +Valves BB, DD, EE, HH, and JJ are open, releasing 79 pressure. +You move to valve DD. + +== Minute 23 == +Valves BB, DD, EE, HH, and JJ are open, releasing 79 pressure. +You move to valve CC. + +== Minute 24 == +Valves BB, DD, EE, HH, and JJ are open, releasing 79 pressure. +You open valve CC. + +== Minute 25 == +Valves BB, CC, DD, EE, HH, and JJ are open, releasing 81 pressure. + +== Minute 26 == +Valves BB, CC, DD, EE, HH, and JJ are open, releasing 81 pressure. + +== Minute 27 == +Valves BB, CC, DD, EE, HH, and JJ are open, releasing 81 pressure. + +== Minute 28 == +Valves BB, CC, DD, EE, HH, and JJ are open, releasing 81 pressure. + +== Minute 29 == +Valves BB, CC, DD, EE, HH, and JJ are open, releasing 81 pressure. + +== Minute 30 == +Valves BB, CC, DD, EE, HH, and JJ are open, releasing 81 pressure. + +This approach lets you release the most pressure possible in 30 minutes with this valve layout, 1651. + +Work out the steps to release the most pressure in 30 minutes. What is the most pressure you can release? diff --git a/2022/Day16CSharp/puzzle-input.txt b/2022/Day16CSharp/puzzle-input.txt new file mode 100644 index 0000000..a1caa58 --- /dev/null +++ b/2022/Day16CSharp/puzzle-input.txt @@ -0,0 +1,58 @@ +Valve OA has flow rate=0; tunnels lead to valves VP, VM +Valve GA has flow rate=13; tunnel leads to valve KV +Valve WD has flow rate=0; tunnels lead to valves SH, XQ +Valve TE has flow rate=0; tunnels lead to valves OY, DO +Valve JR has flow rate=0; tunnels lead to valves TR, LY +Valve JQ has flow rate=0; tunnels lead to valves TD, DZ +Valve VH has flow rate=6; tunnels lead to valves WY, YQ, NU +Valve NX has flow rate=0; tunnels lead to valves XQ, MN +Valve XL has flow rate=0; tunnels lead to valves AA, FA +Valve QY has flow rate=0; tunnels lead to valves NU, DO +Valve KV has flow rate=0; tunnels lead to valves GA, XQ +Valve NK has flow rate=0; tunnels lead to valves XW, XQ +Valve JU has flow rate=0; tunnels lead to valves QH, TB +Valve XZ has flow rate=0; tunnels lead to valves AA, SH +Valve XQ has flow rate=18; tunnels lead to valves GK, NX, WD, KV, NK +Valve VM has flow rate=19; tunnels lead to valves LY, OA, OY, AE +Valve LE has flow rate=0; tunnels lead to valves MN, NS +Valve HO has flow rate=0; tunnels lead to valves GO, QH +Valve PX has flow rate=0; tunnels lead to valves MN, VP +Valve MN has flow rate=4; tunnels lead to valves LE, UX, TB, NX, PX +Valve VB has flow rate=0; tunnels lead to valves XM, AA +Valve VP has flow rate=21; tunnels lead to valves XM, WT, BG, PX, OA +Valve KI has flow rate=15; tunnels lead to valves XU, MT +Valve NU has flow rate=0; tunnels lead to valves QY, VH +Valve WT has flow rate=0; tunnels lead to valves SH, VP +Valve OY has flow rate=0; tunnels lead to valves VM, TE +Valve VS has flow rate=0; tunnels lead to valves QH, SH +Valve XM has flow rate=0; tunnels lead to valves VB, VP +Valve HI has flow rate=17; tunnel leads to valve TD +Valve TB has flow rate=0; tunnels lead to valves JU, MN +Valve BG has flow rate=0; tunnels lead to valves VP, GK +Valve HN has flow rate=16; tunnel leads to valve BO +Valve MT has flow rate=0; tunnels lead to valves KI, BO +Valve OX has flow rate=0; tunnels lead to valves DZ, ZF +Valve QH has flow rate=5; tunnels lead to valves FA, DW, VS, JU, HO +Valve YQ has flow rate=0; tunnels lead to valves VH, AE +Valve DW has flow rate=0; tunnels lead to valves ML, QH +Valve WY has flow rate=0; tunnels lead to valves HS, VH +Valve GO has flow rate=0; tunnels lead to valves HO, DO +Valve UX has flow rate=0; tunnels lead to valves AA, MN +Valve AE has flow rate=0; tunnels lead to valves YQ, VM +Valve DZ has flow rate=9; tunnels lead to valves HS, OX, JQ +Valve NS has flow rate=0; tunnels lead to valves SH, LE +Valve LY has flow rate=0; tunnels lead to valves JR, VM +Valve BO has flow rate=0; tunnels lead to valves HN, MT +Valve HS has flow rate=0; tunnels lead to valves WY, DZ +Valve XW has flow rate=0; tunnels lead to valves NK, AA +Valve DO has flow rate=11; tunnels lead to valves TE, XU, ZF, QY, GO +Valve FA has flow rate=0; tunnels lead to valves XL, QH +Valve AA has flow rate=0; tunnels lead to valves VB, XL, XZ, XW, UX +Valve VW has flow rate=14; tunnel leads to valve ML +Valve SH has flow rate=8; tunnels lead to valves NS, WT, XZ, VS, WD +Valve XU has flow rate=0; tunnels lead to valves DO, KI +Valve ZF has flow rate=0; tunnels lead to valves OX, DO +Valve GK has flow rate=0; tunnels lead to valves XQ, BG +Valve ML has flow rate=0; tunnels lead to valves VW, DW +Valve TD has flow rate=0; tunnels lead to valves HI, JQ +Valve TR has flow rate=25; tunnel leads to valve JR diff --git a/2022/Day17CSharp/Day17CSharp.csproj b/2022/Day17CSharp/Day17CSharp.csproj new file mode 100644 index 0000000..d439800 --- /dev/null +++ b/2022/Day17CSharp/Day17CSharp.csproj @@ -0,0 +1,10 @@ + + + + Exe + net7.0 + enable + enable + + + diff --git a/2022/Day17CSharp/Program.cs b/2022/Day17CSharp/Program.cs new file mode 100644 index 0000000..2260634 --- /dev/null +++ b/2022/Day17CSharp/Program.cs @@ -0,0 +1,107 @@ +// See https://aka.ms/new-console-template for more information + +using System.Drawing; +using System.Net.Http.Headers; +using System.Runtime.CompilerServices; + +var exampleChamber = new Chamber(7, "example-input.txt"); + +var puzzleChamber = new Chamber(7, "puzzle-input.txt"); + +abstract class Shape +{ + +} + +// Chamber bottom right is 0,0. Y points up. 0,0 is a "block" +class Chamber +{ + public enum WindDirection + { + Left, + Right, + None + } + + public HashSet FilledSpaces { get; set; } + + public int ChamberWidth { get; private set; } + + public WindDirection[] WindDirections { get; private set; } + + public Chamber(int chamberWidth, string windfile) + { + FilledSpaces = new HashSet(); + ChamberWidth = chamberWidth; + + using (StreamReader reader = System.IO.File.OpenText(windfile)) + { + while (!reader.EndOfStream) + { + var line = reader.ReadLine(); + if (line == null) throw new InvalidDataException(); + + WindDirections = new WindDirection[line.Length]; + + for (int i = 0; i < WindDirections.Length; i++) + { + if (line[i] == '<') + WindDirections[i] = WindDirection.Left; + else if (line[i] == '>') + WindDirections[i] = WindDirection.Right; + else + throw new InvalidDataException(); + } + } + } + + if (WindDirections == null) throw new InvalidDataException(); + } + + public Rectangle Bounds + { + get + { + Point min = new Point(1,1), max = new Point(1,1); + + foreach (var item in FilledSpaces) + { + min.X = int.Min(min.X, item.X); + min.Y = int.Min(min.Y, item.Y); + max.X = int.Max(max.X, item.X); + max.Y = int.Max(max.Y, item.Y); + } + + return new Rectangle(0, 0, max.X - min.X, max.Y - min.Y); + } + } + + public void Draw() + { + var bounds = Bounds; + + int maxY = bounds.Height; + for (int j = maxY; j > 0; j--) + { + Console.Write("|"); + for (int i = 1; i <= ChamberWidth; i++) + { + if (FilledSpaces.Contains(new Point(i,j))) + { + Console.Write('#'); + } + else + { + Console.Write('.'); + } + } + Console.WriteLine("|"); + } + Console.Write("+"); + for (int i = 1; i <= ChamberWidth; i++) + { + Console.Write("-"); + } + Console.WriteLine("+"); + } +} \ No newline at end of file diff --git a/2022/Day17CSharp/Properties/launchSettings.json b/2022/Day17CSharp/Properties/launchSettings.json new file mode 100644 index 0000000..c374fe2 --- /dev/null +++ b/2022/Day17CSharp/Properties/launchSettings.json @@ -0,0 +1,8 @@ +{ + "profiles": { + "Day17CSharp": { + "commandName": "Project", + "workingDirectory": "C:\\dev\\DevSandbox\\AdventOfCode\\2022\\Day17CSharp" + } + } +} \ No newline at end of file diff --git a/2022/Day17CSharp/example-input.txt b/2022/Day17CSharp/example-input.txt new file mode 100644 index 0000000..fb5d89e --- /dev/null +++ b/2022/Day17CSharp/example-input.txt @@ -0,0 +1 @@ +>>><<><>><<<>><>>><<<>>><<<><<<>><>><<>> \ No newline at end of file diff --git a/2022/Day17CSharp/problem.txt b/2022/Day17CSharp/problem.txt new file mode 100644 index 0000000..17f9f53 --- /dev/null +++ b/2022/Day17CSharp/problem.txt @@ -0,0 +1,337 @@ +--- Day 17: Pyroclastic Flow --- + +Your handheld device has located an alternative exit from the cave for you and the elephants. The ground is rumbling almost continuously now, but the strange valves bought you some time. It's definitely getting warmer in here, though. + +The tunnels eventually open into a very tall, narrow chamber. Large, oddly-shaped rocks are falling into the chamber from above, presumably due to all the rumbling. If you can't work out where the rocks will fall next, you might be crushed! + +The five types of rocks have the following peculiar shapes, where # is rock and . is empty space: + +#### + +.#. +### +.#. + +..# +..# +### + +# +# +# +# + +## +## + +The rocks fall in the order shown above: first the - shape, then the + shape, and so on. Once the end of the list is reached, the same order repeats: the - shape falls first, sixth, 11th, 16th, etc. + +The rocks don't spin, but they do get pushed around by jets of hot gas coming out of the walls themselves. A quick scan reveals the effect the jets of hot gas will have on the rocks as they fall (your puzzle input). + +For example, suppose this was the jet pattern in your cave: + +>>><<><>><<<>><>>><<<>>><<<><<<>><>><<>> + +In jet patterns, < means a push to the left, while > means a push to the right. The pattern above means that the jets will push a falling rock right, then right, then right, then left, then left, then right, and so on. If the end of the list is reached, it repeats. + +The tall, vertical chamber is exactly seven units wide. Each rock appears so that its left edge is two units away from the left wall and its bottom edge is three units above the highest rock in the room (or the floor, if there isn't one). + +After a rock appears, it alternates between being pushed by a jet of hot gas one unit (in the direction indicated by the next symbol in the jet pattern) and then falling one unit down. If any movement would cause any part of the rock to move into the walls, floor, or a stopped rock, the movement instead does not occur. If a downward movement would have caused a falling rock to move into the floor or an already-fallen rock, the falling rock stops where it is (having landed on something) and a new rock immediately begins falling. + +Drawing falling rocks with @ and stopped rocks with #, the jet pattern in the example above manifests as follows: + +The first rock begins falling: +|..@@@@.| +|.......| +|.......| +|.......| ++-------+ + +Jet of gas pushes rock right: +|...@@@@| +|.......| +|.......| +|.......| ++-------+ + +Rock falls 1 unit: +|...@@@@| +|.......| +|.......| ++-------+ + +Jet of gas pushes rock right, but nothing happens: +|...@@@@| +|.......| +|.......| ++-------+ + +Rock falls 1 unit: +|...@@@@| +|.......| ++-------+ + +Jet of gas pushes rock right, but nothing happens: +|...@@@@| +|.......| ++-------+ + +Rock falls 1 unit: +|...@@@@| ++-------+ + +Jet of gas pushes rock left: +|..@@@@.| ++-------+ + +Rock falls 1 unit, causing it to come to rest: +|..####.| ++-------+ + +A new rock begins falling: +|...@...| +|..@@@..| +|...@...| +|.......| +|.......| +|.......| +|..####.| ++-------+ + +Jet of gas pushes rock left: +|..@....| +|.@@@...| +|..@....| +|.......| +|.......| +|.......| +|..####.| ++-------+ + +Rock falls 1 unit: +|..@....| +|.@@@...| +|..@....| +|.......| +|.......| +|..####.| ++-------+ + +Jet of gas pushes rock right: +|...@...| +|..@@@..| +|...@...| +|.......| +|.......| +|..####.| ++-------+ + +Rock falls 1 unit: +|...@...| +|..@@@..| +|...@...| +|.......| +|..####.| ++-------+ + +Jet of gas pushes rock left: +|..@....| +|.@@@...| +|..@....| +|.......| +|..####.| ++-------+ + +Rock falls 1 unit: +|..@....| +|.@@@...| +|..@....| +|..####.| ++-------+ + +Jet of gas pushes rock right: +|...@...| +|..@@@..| +|...@...| +|..####.| ++-------+ + +Rock falls 1 unit, causing it to come to rest: +|...#...| +|..###..| +|...#...| +|..####.| ++-------+ + +A new rock begins falling: +|....@..| +|....@..| +|..@@@..| +|.......| +|.......| +|.......| +|...#...| +|..###..| +|...#...| +|..####.| ++-------+ + +The moment each of the next few rocks begins falling, you would see this: + +|..@....| +|..@....| +|..@....| +|..@....| +|.......| +|.......| +|.......| +|..#....| +|..#....| +|####...| +|..###..| +|...#...| +|..####.| ++-------+ + +|..@@...| +|..@@...| +|.......| +|.......| +|.......| +|....#..| +|..#.#..| +|..#.#..| +|#####..| +|..###..| +|...#...| +|..####.| ++-------+ + +|..@@@@.| +|.......| +|.......| +|.......| +|....##.| +|....##.| +|....#..| +|..#.#..| +|..#.#..| +|#####..| +|..###..| +|...#...| +|..####.| ++-------+ + +|...@...| +|..@@@..| +|...@...| +|.......| +|.......| +|.......| +|.####..| +|....##.| +|....##.| +|....#..| +|..#.#..| +|..#.#..| +|#####..| +|..###..| +|...#...| +|..####.| ++-------+ + +|....@..| +|....@..| +|..@@@..| +|.......| +|.......| +|.......| +|..#....| +|.###...| +|..#....| +|.####..| +|....##.| +|....##.| +|....#..| +|..#.#..| +|..#.#..| +|#####..| +|..###..| +|...#...| +|..####.| ++-------+ + +|..@....| +|..@....| +|..@....| +|..@....| +|.......| +|.......| +|.......| +|.....#.| +|.....#.| +|..####.| +|.###...| +|..#....| +|.####..| +|....##.| +|....##.| +|....#..| +|..#.#..| +|..#.#..| +|#####..| +|..###..| +|...#...| +|..####.| ++-------+ + +|..@@...| +|..@@...| +|.......| +|.......| +|.......| +|....#..| +|....#..| +|....##.| +|....##.| +|..####.| +|.###...| +|..#....| +|.####..| +|....##.| +|....##.| +|....#..| +|..#.#..| +|..#.#..| +|#####..| +|..###..| +|...#...| +|..####.| ++-------+ + +|..@@@@.| +|.......| +|.......| +|.......| +|....#..| +|....#..| +|....##.| +|##..##.| +|######.| +|.###...| +|..#....| +|.####..| +|....##.| +|....##.| +|....#..| +|..#.#..| +|..#.#..| +|#####..| +|..###..| +|...#...| +|..####.| ++-------+ + +To prove to the elephants your simulation is accurate, they want to know how tall the tower will get after 2022 rocks have stopped (but before the 2023rd rock begins falling). In this example, the tower of rocks will be 3068 units tall. + +How many units tall will the tower of rocks be after 2022 rocks have stopped falling? diff --git a/2022/Day17CSharp/puzzle-input.txt b/2022/Day17CSharp/puzzle-input.txt new file mode 100644 index 0000000..0e52c0f --- /dev/null +++ b/2022/Day17CSharp/puzzle-input.txt @@ -0,0 +1 @@ +>>>><<<><<<>><<>>>><>>><<<>><<<>><<<<>>>><>>><<>><<<>>>><<<<>>><<><>>><<<<>>>><>><<><<<><<<><<>><><><<<<>>><<<<><<>>>><<>>>><>><<<<>><<<>><<<<>>><<<>>>><<>>><>><>>><>><<>>>><<><><<<>>><<><><<<<>><<<>>><<<<>>>><<><<>>><<<>>><<<><<<<>>>><<<>><><<<>>><<<>>><<<<><<<>>>><<>>><>>><<<<>>>><>><<<<>><<<>>>><<>><>>>><<<>>><<>><<<>>>><>>>><><<>>>><<<>><<>><<>>>><<<>>><<>>><<<<>>><<<<>>>><<<<>>>><>><<<>>><<>><>>><>>><<>>><>>><<<>>><<<<>><<><<<><>>>><<<><>>>><<<<>>><<<<>><><<<<>>><<><<<<>>><<<<>><>><>>><<<><<<<>>>><><><<<>><<<<>><<<>><<<><<<<>>>><<<<>>><<<>>><>><<<<><<<>><<<>><>><<<<><><>>><<>>>><>>><>>><<<<>><<>><<>><<<>><<><<<<>><><<<<>><<>>>><<>>>><>>><<<>><<<<>><<<>>>><<<<>><<<<>>><<>>>><>>><<<<>>><<<<><<><<<><<<<>><<<>><<<><<<>>><<<<>><<<>>><><<>>><>>>><<<<>>>><<<>>><<>><><>>><<<><<>><>><<>>>><<<<><<>><<<<><<>>><<<<>><<<>>><<<>>>><>><<><<<><>><<<>>>><<<<>>><><<<<><<><<<>><<<<>><<<>><>>><<><<><<>>>><<>>>><<>>>><><<>>>><<<<>>><<<>>><<<>>><<<<>>><<<>><<<<><><><<<>><<<<>>>><<<<>>>><<<>>><<>>>><>>>><<<<>><<<><<<>>>><><><<><<<>>><<>>>><>>><>>><<>><>>>><<<>><><<<><<<<>>><<<<><><><>>><>><>>>><>>>><<<<>><<<>>><<<>>>><<<>><<>>>><<<><<<<>><<><<<>>>><<<<>>><><>>><>>>><<<<>><<><<<>>><<>>><<>><<><<>><>>><<<>><<<<>><>>><<><<>><<<<>><<<>><>>>><<<>>><<>><<><>>><<<<>>>><<<<>><<<>>>><><<>><<>>><><<<<>>>><<<<>><>>>><<<>>><<<>>>><<<<>><<><<<<>><><<>>><<<<>>>><<<<>>><<><<<>>><<<<>>><<<<><<<<>>>><<>>>><<>>><<>><<<<><<<>><<<>>>><<<<>>><<<<><>>>><<<<>>>><<<><<<>>>><<>>><<<<>>><<<<><<<>><<<<><>>><>>><<<<>>><>><<>>>><<<>><<><<<>>>><<<>>>><<<>>><<<<>>>><<>>><<<><<<<>>><<<>><<<<><><>><<>>>><<>><<><<>>>><<<>>>><<<<><>><>>><<>>><><<<>>>><<>><<><<<<>>>><<<>>><<<<>>>><<<>><<<<><<<<>><<><>>><>><<>>>><<<<>>>><<<>>><><<><<><>>>><<>>>><<<><>>><<<>><<<<>>><><<<><<>>>><><<>>><<<<>><<>>><<>>>><<<<>>>><<>>><><>>>><<<<>>><<<<>>><<<<>>>><<<>><>>><<<<><<<>><<<<>>><>><<>><<<<><<<><<>>><>>><<<>><<<>>><<>><<><>><<<>>>><>>><<<<>><<>>>><<<>>><<><<<>>>><<<><<<>>>><<<<>>><>>><>><<<>>>><<<<>>><<<>>>><<>><<<<>>>><>><>>><<<>>>><>>>><<>><<<><><<>>><<<>>>><>>>><>>><<><<<<>>>><<<>>>><<<>>><<<<>>><>>>><<<>>>><<<><<<>><<<<><<<><<<<><<<>>>><>><>><<<>><<<><<<><><<<>>><<>>>><<<<>>>><<>>>><>><<<>>><<><<<<><<<<>>>><<>>><<<><>>><>>><<<>>><>><<<<><<<<>>>><<>>>><>><<<<><><><<><<>>>><<>><>><>>>><<>>>><<<<>>>><>><>>><<<>>><<>><<<>>><><<<><<<>><<><<>>>><>>>><<>>>><><<<>>>><<<>>>><<<>>><<>>>><<>>>><<<>>><<<<>>>><<<<>><>>>><<>>><<<>>><<>>>><<<<>><<<>><<><>>>><<<>>><<>>>><<<<>>>><<>><<<>>><>><>><>>><><<>><<<>><<><<>>><>>>><<><>>><<<<><<<<>><>><<<<>>><<<>>>><>><<<>>><<<<>>>><<<>>>><<>><<><<<>>><><>><>><>>>><><<<>>><<>>>><<<<>><><<>>>><<<>>><<>><<<>><<<><<>><<>>><<>>><>><<>>>><<><<<<><<<<>>><<<<>>>><<>>><<>><<<><<<><<<>>><<<<>><>>><<>>><<>>>><<>>>><<>>>><<<>><><<<<><>><<><<<>><<<<>>>><<<<>>>><<<><<<>><<<>>><>><>>>><<<<>>><<<>>><>>>><<<>>>><>><<<><<><<<>>>><<<>>><>>><<<>>><<<><<>>>><<<>><<><<>><<<><<<<>>><<<>><<>>><<<<>><>>>><<>>><<><<<<>><><<>>>><<<><<>><<>><<>>><<<<>>>><<<<>>><<<><<<<>>><<<>>><>>><<>><<<<><>>><<<<>><<<<>>><<><<<<>>><<<>>><<<<>><<<<>>>><><><<>>>><>><<<><><<<<>>><><<<<>>>><><><<<>>><>><<<<><>><<<<>>>><<>>>><<<>>><>>><>>><><>>>><<>><<<>>>><<<>>>><<<>>>><<<<>>>><<<><>><<<<>>>><<><<<<><<<>>>><<><>>>><<><<<>>>><><<<><<>><<<<>><<>><>><<<>><<<>>><>>>><>>>><<><<<>><<<>>>><<<<><<<>>><>><<>>><<>>><<<>>><<>>><>><<>>><<<<><<>><<<<>><<<>><>>>><>><><<<>><<<>><>>><<<<><<<>><<>><<<<>>>><<<<>>><>>><<<>>>><<<>>>><<<>><<<>>>><<<>><<<>><<<<>>><><<>><<<<>><>><<>><<<>><<<>>><<<<>>>><<<><<<<>>>><>>><<<<>>><<>>>><<<<>>><>>>><<<>><>>>><<><<>>><>>>><<>>>><<<>><<<><<<<>>><<<>>><<<>>>><<><>>>><<<>>>><<<<>>>><>>><<<><>><<>>>><<<<>>><>>><<<<>>><<<<>><<<<>><<<>><<>>><<<>>>><><<>>><>>>><<>>><<<<><<><<>>>><<<<>><<<<>>>><<<>><<><<>><<<<>>>><>><<<<>><<<>>><>>>><<<>>>><<><<<<><<<>><<<>>><<<<>>><<<>>><<<>>>><<<>>><><<<>>><>><<<>>><<>>><><<<>>>><<<<>>>><<<><<<<>>><<><<<>>><<<<>><<<>><>>>><<<>><<><<<<>>>><>><<<<>><<<>>><<>>><<<>>><<<>>><<<<>>><<<<><>>><>><><<<<>><<<>>><<<<><<<>>><<>><>><<>>>><<>>>><>>>><<><<>><>>>><<><<<<><<<<>>><>><<>>>><<<<>>><>>><<<<><<>><<><<<>>>><<>>>><<>>>><<<<><<>><>><><<<>><<<<>>><<<><<<>><>><<<>><><>>>><><<<>>><<<<><<<<>>><<<>>>><>>><<>>><<>>>><>>>><><<<<>>>><<<>>>><<<>><<>>><<><<<>>>><<<>>><<<><><>><<<>>><<<>>>><<>><<<<>><><<<<>><<<>><<<<><<>>>><<>>><<>><<>>>><<>>><<>>><<<<>>>><>>><<>>><<<>>><>>>><<<><<<<>><<><<<<>><<<>><<<>>><<<<>><>><<>><<<>>>><<>>><<<>><<>>>><<<<>><<>>>><<<>>><<<<><<<>>>><<<>>><<<>><<><>>>><<<<><<<<>>><<<<>>>><>>><><>>>><<<>>><<<<>>>><>>>><<<>>>><<><<<<>>><<>><<<<>><<<><<><<<>><<<>>><<<>>><<>>>><<<<>>><<>>><<>><><<<<>>><<<<>>>><><<><>><<<>>>><<<><<>>><<>>>><<<>>><>>>><>><>>><<<><>><<<<>>><>>><>><>><<<<>>><<>>><>>>><<<>><<>>><<<>><<<>><<<<><<>>>><>>><>><<<<>>>><><<<><<><<>>><<><<<>>>><<>><<>>><<<>>>><<>>>><<><<>>><>>>><<>><<<>><><>><<<>>>><<>><>><<>>>><<<<>>>><<<<>>>><<<><<>><<<<>>><<<<>>><<<<>>><<<<>><<<<>>><<<>><<>>><<<<>>><<>>>><<<>><>><>>><>>>><>><<<<><><<>>>><>>><<<>>>><<<>>>><<>>><<<<>><>>><<<<>>>><><<<<><<>><>>>><>>><<>>>><><<><<<<>><<<><><<<<>><<>>>><<<<>><>><<>><<>><<><<<>>><><>>><<<>>>><<<<><>>>><><>>>><<<<>>><<>><<>><<<<>>>><<>>>><<<<>>>><><<<><<>>><<<<>>>><<>>>><>>>><<<<>><<<>><<>>><<<<>>>><<<<>>>><<<<>><<<<><>>>><>>><<<<><<<<>>>><<<><<<<><<>>><>>>><<<>>><<<<>>><<>>>><<>>><<<<><<<<>>>><>>>><<<>><<<<>><>>>><>>><<<<>>>><>>>><<>>><<<>>>><>><<<<>>><<>>><<><<<><<<<>><<<<>><<><<<<><<<>>><<>>>><<<><<<<>>><<>><<<<>>>><>><<>>><<<<>>>><<<>>>><><>>><>>><<<<><>><<>>>><>>>><<>>>><<<<><>>>><<<>>>><<<<>>>><>><<<<><<<<>><<<>><<>>><<><<>>><<>><>>>><><<<>>>><<<<><<<>><<<<><<><>>><<>>>><<><<<<>><><<<>>><<<<>>><<<<><<<<>><>>>><<><<<>>><<>><<<<>>>><>>>><>>>><>><<<<><<<>>>><<<>><<<>>>><>>>><<<<>>>><<<>>>><<><<><<>><<><<<>>><<<<>><>>><<><<<<>><<<<>>>><<<<>>><<>>>><>><<<<>><><<<<>><<>><<<<>>>><<>>>><<<<>><>>><<<>><<><>>><<>><<<><<<<>>><>>>><<>><<>>><<>><<><<>>><<<<><<>>>><<>>>><<>><>>>><<>><>><>><<<<>>>><>>>><<<>>>><<<<>>>><<><<>>><><<>>><>>><><<<>><<<<>>><<<><<<<>>>><<<>>>><><>>><<<><<<>>><<<<><<<<>>><<>><<>><><<>>><<<><<<<>><>><<><<<>>><<>>><<>>>><>><>>><<<>><>>>><<<<><<<<>>>><><>>><>><><<<>>>><<<<>><<>><><>>><<<><<><<>>>><<<>>><>>>><<<<>>>><>><<<<><>>>><>>>><<<>>><<><<>>>><<>>><<<>>><<<>>><><<<>><<<<>>>><<>>>><<<<>>><<<>>><<<<><<>><>>>><>>>><<><<<<>><<<<>>><<<<>>><>>><><<>><<<><<<><<<>><<>>>><>><>>><><<<><<><>>>><<<<><<<>>>><><<><>>><<<<>>><<<>><<<<>>><<>>>><>>><>><<>><<<<>><<><<>><>>>><<>>><<<>><><<>>>><<>>><<>><<>><<<>>><<<>>>><<<<><<<<>>><<<>><>>><<<>><<<>>><<<>>>><<<<>><<<<>>><<><<<<>>><><<>>>><<<><<<<>>><<<<>>><<<>>>><<><<<<>>>><>>><<><<<<>>><>>>><<<<>>><><<<>>><>>><<>>>><<<>>><<<<>><<<<>><<>>><<<<>><>>>><<<<>>>><<<<>>><>><<>>>><<<<>>>><<<<>><<<>>><<<>>><>>><>>>><>><><>><<><<><><<>><>>><<<><<<>><<<>><<<>>><>><<>>>><<>><<<>>>><><<<><<>><<<<><<<><<>>>><>><<><<>><<>>><<<><>>><<<>>>><<<<>><<>>>><<<>>>><><>>><><<<<><<>>><>><<<><<<>>>><><>>>><>>>><<<<>>><><<<>><<<>>><<>>><<<><<<<>><<>>>><<<>>>><<>><<><<<>>>><<>>><<<>><><<><<<<>>><><>>>><<>><><<<<>>>><>>>><<<<><<>>>><<>>>><<<<><>><<<>>>><<<<><<<<>>><<<>><<<<><<<>>><>>>><<<<>>><<<>>><<>>><<>><<<><<<>>><<<>>>><<<><<<<>>><<<>><>>>><>><<<<>>>><><<<>><<>>>><<<<>>><><>><<>><>>><<<>>><>>>><<<<><><<<<>><<>>>><<<<>>><<><<<<>>><<<>>>><<<<><>>><>><><<>><<<><>>><<<><><<>><<<>><<<<><<<>>>><><><<<<><<<>>>><>>>><<>>><<>>><<<>><<>>><<<><<>>>><><<><><>>><<<>><<<<><<<><<>><<><<<>>>><<>>>><<><>>>><<>>><<<<><<<<><<<<>><<<<>>>><<><<<><>>><<<<>>><<<>><<<<>>>><<<>>>><<<>><<><><><><<><<<<><<<>><<<>><<<>><>><<<<>><<>>><<><<>>><<<><<<<>><<<>>>><<>>>><>>><<><>><<<<>>><>><<<>>><<<><<>>>><<<<>>><<<<>>><<<<>>><>>><>>><>><<>>>><<<><<<><<<>><<<>><<<>><<<>>><>>><<>>><<<<><>>><<<<><<<>>><<<>>>><<<<>>><<>><>>><>>><>><<<<>>><<<<><><<<><<>><<<>>>><<<>>><<><>>><<>><>>><<<>>>><<<>>>><<<><>>>><<><<><<<<>>><<<<><<><<>>>><<<>><<<<>>>><<<<>>>><><<<<>><<>>><<<<>>>><<>>><<<>>><>>><>>>><<<>><><<>>><<<>>><<><<<><<<<><<<<><>><<>>><<<<>>>><<<><<><<<<>>>><<<>><<<<><<>><<<><<<>><<<>>>><<<<>>><<<>><<<<><<<>>><<<<>><<>>>><<<>><<><<<<><<<>><>>><>>><<>>>><<<<><<<><<<<>><<<<>>>><><>>><<>>>><<>>><>><<>>><<<>>>><<<>><>>><<>><<><<<>>><<<><<<>>>><<>>>><<<<>>><<>>>><<<>>>><<><>>><<>>><<>>><<<>>><><<><<<<>><<>><><<<>>>><<<>>><<<><><<<<><<<<><<>>>><>>><>>><<<>>><<>>><<<<>>>><<<><<><<<<><<<><<<<>>><>>>><>>>><<<>>><<<<>>>><<<>><<>><<>>><<>><><<>>><<<>>><<>><<<<>><<<>>><<>><<<<>><>><><>>><><<<<>>>><<>>>><<<>><><<<<>><<<<><<<>><<<<>><><<<><<>><<<>>>><>><<<>>><><<<<>><<>><<>>>><<>><<<<>><<<<>><<>><<<<><<<<>>><<<><<<<>>>><<><>><<<<><>>><<<<><<><<<<>><>><<><<<>>>><<<<>>>><<<<><<>>>><<<<><<<><<>><>><<<>>>><>><<>>><<<<><<>>><<><<<<>><<><<<>><>><<<>>>><<<<><<<<>><>><<<>><<<>>><<>>><<<<>>><<>>><<<<><<<<>><<<<>>><<<>><><<<><>><<<<><<<<>><<<<><<<>>>><<><<><>>><<<<>><<<<>>>><>>><>><<>><<>><<<<>><>>>><<<<>>>><<<>>>><<>><><<<<>>><<<<>>>><<<>>><<><>>><<<<>>>><<<<>>>><<><>>>><<<<><<<><<<<>>><<<<><<<>>>><<<<>><<<>>><<<>>>><<><<><>>>><>>>><<<<>><>><<>>><<<><><<>>><<<>><<>>><<<><<<>>><<>>><<>>>><<<><>>>><><<<>>><>><<<>><<><<<>>><>>><<<<>>>><<<>>><>>><<>><<<>>><>><<>><>>>><<<<><<<>>>><><<<<><<<<><<<<><<>>>><<>>>><<>><<<<>><<<>>><<><<<>>>><<<<>>>><<<>>>><<<><<<>>>><<>>>><<<<>><>><<>>>><>>>><<<>><<<>><>>>><<<>>><>><>>>><>><<<<>><<>>><>><<>>><<<<>><><<<>><<<<>>><>>>><<<<>>><<<><<<>><<><<>>>><>>><<<><<>><<<><<>>>><><<<<>><<<>>><<>>><>>>><>>><>>>><<<><>><<<>>>><>>><<<>>><<><<>><<<<><<><>><<<>>><<<>>><<<>>>><<<><<<<>>><<<<><<<><<<>>>><<>>><>>>><<<>><<>>>><<><<<<><<<<>><<>>><<><<>><<><>>>><>><<<<>>><<<<>>>><<<><<<<>>>><>>>><<<><<>><<>>><<<<>><<>><<>>>><>>><>>><<>><>>><<>><<<<>>><><<>>><<<<>><<<>>><<<>><><<<<>><<<<>>><<<>><<<>>><>>>><<<>>>><<>>><>><>><<<<>>>><<<>>>><<>><<<<>>><<<<>>><><>><<><>>>><<<<>><<>>><>>>><<<><<<<>>>><>>><<<<>>>><<><<<<>>><<<<>>><<<<>>>><><<>><<>><<<>><<><<<>>>><<<>>>><<>><<<<>><>><<<>>>><<<<><<<>>>><<<>>><<<<>>>><<>>>><<<><<<<>>>><><>><<>>><<<<><><<>>>><<<>>>><<<><<<<>><<<<>>><<<><<<>><<><<<>>>><<>>><>><>><<>>>><><<><<<<>>><<>>>><<<<>>><<<<><><<<><<<>>><<><<>>>><<<>>><<<>><<>>>><<<<>>>><>><<>>><<>>>><<<><<>>>><<<>>>><<<<>>>><<<<><<<<><<<><<<<>>>><<>>><<>>><<>><<><<>>><<<>>>><>><<<><<>>>><<>><<><<<>>>><>><>>>><<>>>><><>><<<<><<<<>>><<<><<>><<>>><<<<>>>><>>>><<><<<>>><<<>>>><<>>><<>><<> diff --git a/2022/Day18CSharp/Day18CSharp.csproj b/2022/Day18CSharp/Day18CSharp.csproj new file mode 100644 index 0000000..d439800 --- /dev/null +++ b/2022/Day18CSharp/Day18CSharp.csproj @@ -0,0 +1,10 @@ + + + + Exe + net7.0 + enable + enable + + + diff --git a/2022/Day18CSharp/Program.cs b/2022/Day18CSharp/Program.cs new file mode 100644 index 0000000..010dded --- /dev/null +++ b/2022/Day18CSharp/Program.cs @@ -0,0 +1,344 @@ +// See https://aka.ms/new-console-template for more information +using System.ComponentModel.DataAnnotations; +using System.Diagnostics.CodeAnalysis; +using System.Drawing; +using System.Security.Cryptography.X509Certificates; + +Part01(); + +void Part01() +{ + Console.WriteLine("!! === Part 01 === !!"); + + Console.WriteLine(" === Example Simple ==="); + var exampleSimpleData = new ProblemData("example-input-simple.txt"); + exampleSimpleData.Print(); + + Console.WriteLine(" === Example ==="); + var exampleData = new ProblemData("example-input.txt"); + exampleData.Print(); + + Console.WriteLine(" === Puzzle ==="); + var puzzleData = new ProblemData("puzzle-input.txt"); + puzzleData.Print(); +} + +struct Vertex + : IComparable +{ + public int X; + public int Y; + public int Z; + + public Vertex() : this(int.MinValue, int.MinValue, int.MinValue) { } + + public Vertex(int x, int y, int z) + { + this.X = x; + this.Y = y; + this.Z = z; + } + + public int CompareTo(object? obj) + { + if (obj == null) throw new InvalidCastException(); + var other = (Vertex)obj; + + if (this.X != other.X) + { + return this.X.CompareTo(other.X); + } + else if (this.Y != other.Y) + { + return this.Y.CompareTo(other.Y); + } + else if (this.Z != other.Z) + { + return this.Z.CompareTo(other.Z); + } + + return 0; + } + + public override int GetHashCode() + { + return X.GetHashCode() ^ Y.GetHashCode() ^ Z.GetHashCode(); + } + + public override bool Equals([NotNullWhen(true)] object? obj) + { + if (obj == null) return false; + var other = (Vertex)obj; + return this.CompareTo(other) == 0; + } + +} + +class Cube +{ + public Cube(int x, int y, int z) + { + init(x, y, z); + } + + public Cube(string data) + { + var split = data.Split(','); + + init(int.Parse(split[0]), int.Parse(split[1]), int.Parse(split[2])); + } + + private void init(int x, int y, int z) + { + X = x; + Y = y; + Z = z; + + List vertices = new List(); + + // Create the verts (we'll store CCW) + for (int d = 0; d < 2; d++) + { + vertices.Add(new Vertex(x, y, z + d)); + vertices.Add(new Vertex(x+1, y, z + d)); + vertices.Add(new Vertex(x+1, y+1, z + d)); + vertices.Add(new Vertex(x, y+1, z + d)); + } + + Vertices = vertices.ToArray(); + } + + public Vertex[] Vertices { get; private set; } = new Vertex[0]; + + public int X { get; set; } + public int Y { get; set; } + public int Z { get; set; } + + public override string ToString() + { + return String.Format("Cube at {0},{1},{2}", X, Y, Z); + } + + public override bool Equals(object? obj) + { + if (obj == null) return false; + var other = (Cube)obj; + return X == other.X && Y == other.Y && Z == other.Z; + } + + public override int GetHashCode() + { + return X ^ Y ^ Z; + } + + public bool IsAdjacent(Cube c) + { + var faceAdjacents = new Cube[] + { + // Directly to the sides + new Cube(c.X+1, c.Y, c.Z), + new Cube(c.X, c.Y+1, c.Z), + new Cube(c.X, c.Y, c.Z+1), + new Cube(c.X-1, c.Y, c.Z), + new Cube(c.X, c.Y-1, c.Z), + new Cube(c.X, c.Y, c.Z-1), + }; + + foreach (var f in faceAdjacents) + { + if (f.Equals(this)) return true; + } + + return false; + } + + public Cube[] Adjacents + { + get + { + var faceAdjacents = new Cube[] + { + // Directly to the sides + new Cube(this.X+1, this.Y, this.Z), + new Cube(this.X, this.Y+1, this.Z), + new Cube(this.X, this.Y, this.Z+1), + new Cube(this.X-1, this.Y, this.Z), + new Cube(this.X, this.Y-1, this.Z), + new Cube(this.X, this.Y, this.Z-1), + }; + + return faceAdjacents; + } + } +} + +class ProblemData +{ + public HashSet Cubes { get; } + public HashSet AirCubes { get; private set; } = new HashSet(); + + public ProblemData(string filename) + { + Cubes = new HashSet(); + + using (StreamReader reader = System.IO.File.OpenText(filename)) + { + while (!reader.EndOfStream) + { + var line = reader.ReadLine(); + if (line == null) throw new InvalidDataException(); + + var newCube = new Cube(line); + if (Cubes.Contains(newCube)) throw new InvalidDataException(); + Cubes.Add(newCube); + } + } + } + + public static int GetExposedSides(Cube c, HashSet cubes) + { + int total = 0; + + var faceAdjacents = new Cube[] + { + // Directly to the sides + new Cube(c.X+1, c.Y, c.Z), + new Cube(c.X, c.Y+1, c.Z), + new Cube(c.X, c.Y, c.Z+1), + new Cube(c.X-1, c.Y, c.Z), + new Cube(c.X, c.Y-1, c.Z), + new Cube(c.X, c.Y, c.Z-1), + }; + + var angledAdjacents = new Cube[] + { + new Cube(c.X+1, c.Y, c.Z-1), // Right and closer to camera + new Cube(c.X-1, c.Y, c.Z-1), // Left and closer to camera + new Cube(c.X+1, c.Y, c.Z+1), // Right and farther from camera + new Cube(c.X-1, c.Y, c.Z+1), // Left and farther from camera + new Cube(c.X, c.Y+1, c.Z-1), // Up and closer to the camera + new Cube(c.X, c.Y+1, c.Z+1), // Up and farther from camera + new Cube(c.X, c.Y-1, c.Z-1), // Down and closer to camera + new Cube(c.X, c.Y-1, c.Z+1), // Down and farther from camera + }; + + foreach (var adjacent in faceAdjacents) + { + if (cubes.Contains(adjacent)) + { + continue; + } + else + { + total++; + } + } + + return total; + } + + public int SurfaceArea + { + get + { + return GetSurfaceArea(Cubes); + } + } + + private int GetSurfaceArea(HashSet cubes) + { + int area = 0; + foreach (var c in cubes) + { + area += GetExposedSides(c, cubes); + } + return area; + } + + public int ExteriorSurfaceArea + { + get + { + HashSet exterior = new HashSet(); + + FillExterior(new Cube(Bounds[0].X, Bounds[0].Y, Bounds[0].Z), Cubes, exterior); + + int area = 0; + foreach (var cube in Cubes) + { + foreach (var adjacent in cube.Adjacents) + { + if (exterior.Contains(adjacent)) area++; + } + } + + return area; + } + } + + public void FillExterior(Cube startingCube, HashSet dropletCubes, HashSet exterior) + { + List toTest = new List(); + + toTest.Add(startingCube); + + do + { + var c = toTest[0]; + toTest.RemoveAt(0); + + if (c.X >= Bounds[0].X - 1 && c.Y >= Bounds[0].Y - 1 && c.Z >= Bounds[0].Z - 1 + && c.X <= Bounds[1].X + 1 && c.Y <= Bounds[1].Y + 1 && c.Z <= Bounds[1].Z + 1 + && !dropletCubes.Contains(c) + && !exterior.Contains(c)) + { + exterior.Add(c); + foreach (var face in c.Adjacents) + { + // C# doesnt support tail recursion innately + //FillExterior(face, dropletCubes, exterior); + toTest.Add(face); + } + } + } while (toTest.Count > 0); + } + + private bool HasCubeBelow(Cube c) + { + return Cubes.Contains(new Cube(c.X, c.Y-1, c.Z)); + } + + public Vertex[] Bounds + { + get + { + if (mBounds.Length == 0) + { + Vertex bottomLeft = new Vertex(int.MaxValue, int.MaxValue, int.MaxValue); + Vertex topRight = new Vertex(int.MinValue,int.MinValue,int.MinValue); + + foreach (var c in Cubes) + { + bottomLeft.X = int.Min(c.X, bottomLeft.X); + bottomLeft.Y = int.Min(c.Y, bottomLeft.Y); + bottomLeft.Z = int.Min(c.Z, bottomLeft.Z); + + topRight.X = int.Max(c.X, topRight.X); + topRight.Y = int.Max(c.Y, topRight.Y); + topRight.Z = int.Max(c.Z, topRight.Z); + } + + mBounds = new Vertex[] { bottomLeft, topRight }; + } + + return mBounds; + } + } + + private Vertex[] mBounds = new Vertex[0]; + + public void Print() + { + Console.WriteLine("Cubes {0} with surface area {1} and {2} exterior area", Cubes.Count, SurfaceArea, ExteriorSurfaceArea); + } +} \ No newline at end of file diff --git a/2022/Day18CSharp/Properties/launchSettings.json b/2022/Day18CSharp/Properties/launchSettings.json new file mode 100644 index 0000000..2cf0d76 --- /dev/null +++ b/2022/Day18CSharp/Properties/launchSettings.json @@ -0,0 +1,8 @@ +{ + "profiles": { + "Day18CSharp": { + "commandName": "Project", + "workingDirectory": "C:\\dev\\DevSandbox\\AdventOfCode\\2022\\Day18CSharp" + } + } +} \ No newline at end of file diff --git a/2022/Day18CSharp/example-input-simple.txt b/2022/Day18CSharp/example-input-simple.txt new file mode 100644 index 0000000..83ee23a --- /dev/null +++ b/2022/Day18CSharp/example-input-simple.txt @@ -0,0 +1,2 @@ +1,1,1 +2,1,1 diff --git a/2022/Day18CSharp/example-input.txt b/2022/Day18CSharp/example-input.txt new file mode 100644 index 0000000..09d4a1a --- /dev/null +++ b/2022/Day18CSharp/example-input.txt @@ -0,0 +1,13 @@ +2,2,2 +1,2,2 +3,2,2 +2,1,2 +2,3,2 +2,2,1 +2,2,3 +2,2,4 +2,2,6 +1,2,5 +3,2,5 +2,1,5 +2,3,5 \ No newline at end of file diff --git a/2022/Day18CSharp/problem.txt b/2022/Day18CSharp/problem.txt new file mode 100644 index 0000000..bd8c76a --- /dev/null +++ b/2022/Day18CSharp/problem.txt @@ -0,0 +1,44 @@ +--- Day 18: Boiling Boulders --- + +You and the elephants finally reach fresh air. You've emerged near the base of a large volcano that seems to be actively erupting! Fortunately, the lava seems to be flowing away from you and toward the ocean. + +Bits of lava are still being ejected toward you, so you're sheltering in the cavern exit a little longer. Outside the cave, you can see the lava landing in a pond and hear it loudly hissing as it solidifies. + +Depending on the specific compounds in the lava and speed at which it cools, it might be forming obsidian! The cooling rate should be based on the surface area of the lava droplets, so you take a quick scan of a droplet as it flies past you (your puzzle input). + +Because of how quickly the lava is moving, the scan isn't very good; its resolution is quite low and, as a result, it approximates the shape of the lava droplet with 1x1x1 cubes on a 3D grid, each given as its x,y,z position. + +To approximate the surface area, count the number of sides of each cube that are not immediately connected to another cube. So, if your scan were only two adjacent cubes like 1,1,1 and 2,1,1, each cube would have a single side covered and five sides exposed, a total surface area of 10 sides. + +Here's a larger example: + +2,2,2 +1,2,2 +3,2,2 +2,1,2 +2,3,2 +2,2,1 +2,2,3 +2,2,4 +2,2,6 +1,2,5 +3,2,5 +2,1,5 +2,3,5 + +In the above example, after counting up all the sides that aren't connected to another cube, the total surface area is 64. + +What is the surface area of your scanned lava droplet? + +Your puzzle answer was 4332. + +The first half of this puzzle is complete! It provides one gold star: * +--- Part Two --- + +Something seems off about your calculation. The cooling rate depends on exterior surface area, but your calculation also included the surface area of air pockets trapped in the lava droplet. + +Instead, consider only cube sides that could be reached by the water and steam as the lava droplet tumbles into the pond. The steam will expand to reach as much as possible, completely displacing any air on the outside of the lava droplet but never expanding diagonally. + +In the larger example above, exactly one cube of air is trapped within the lava droplet (at 2,2,5), so the exterior surface area of the lava droplet is 58. + +What is the exterior surface area of your scanned lava droplet? diff --git a/2022/Day18CSharp/puzzle-input.txt b/2022/Day18CSharp/puzzle-input.txt new file mode 100644 index 0000000..ffca686 --- /dev/null +++ b/2022/Day18CSharp/puzzle-input.txt @@ -0,0 +1,2879 @@ +14,10,19 +17,18,13 +16,6,10 +10,13,19 +5,6,5 +14,14,17 +6,4,13 +13,14,17 +18,12,17 +6,18,7 +19,8,5 +2,10,14 +15,16,6 +14,18,11 +17,16,7 +17,4,12 +12,6,3 +12,1,11 +10,6,18 +13,17,6 +11,14,2 +9,9,18 +16,10,17 +13,4,7 +2,12,6 +15,16,10 +3,16,10 +6,15,16 +10,7,19 +7,4,4 +14,15,13 +15,7,16 +8,2,11 +9,10,2 +17,13,5 +6,13,3 +15,14,15 +11,19,6 +10,2,10 +12,19,9 +18,8,11 +5,13,15 +6,7,17 +15,3,11 +16,9,16 +12,3,11 +13,19,11 +10,10,1 +8,18,12 +17,16,11 +11,14,3 +2,12,12 +7,17,16 +17,9,16 +7,19,11 +16,9,3 +17,10,10 +19,8,12 +16,15,16 +17,9,8 +7,11,19 +14,15,16 +3,12,11 +15,8,15 +10,3,13 +14,11,2 +12,14,17 +11,15,18 +9,5,5 +7,15,5 +16,7,17 +17,12,14 +10,17,4 +17,6,12 +8,7,16 +7,8,4 +4,5,12 +8,17,7 +20,10,10 +18,8,14 +3,13,14 +17,13,15 +8,13,18 +11,21,9 +16,13,18 +4,5,14 +9,15,3 +12,20,11 +14,6,18 +18,10,16 +4,15,7 +14,5,7 +3,9,15 +11,3,5 +11,16,3 +3,10,15 +10,3,10 +11,19,13 +20,9,13 +3,9,12 +18,10,5 +4,13,5 +3,8,14 +2,9,12 +16,4,11 +9,19,11 +10,9,3 +13,16,16 +9,10,18 +10,5,15 +8,8,2 +14,14,16 +7,5,16 +4,4,7 +11,15,17 +14,5,16 +5,10,6 +12,8,18 +18,15,10 +12,5,16 +16,15,7 +4,4,9 +11,18,7 +19,12,9 +7,4,9 +4,8,6 +15,4,7 +3,12,12 +11,18,8 +19,10,11 +4,8,12 +15,17,12 +11,11,2 +9,11,20 +8,17,6 +13,1,9 +13,20,9 +7,3,15 +7,3,7 +14,7,4 +2,7,13 +12,18,12 +5,18,7 +3,9,14 +14,19,9 +9,5,16 +5,8,18 +8,7,18 +13,3,6 +6,8,17 +19,8,6 +7,10,2 +6,4,16 +9,13,19 +6,14,18 +12,2,15 +9,4,17 +4,16,8 +9,12,2 +16,5,7 +14,6,3 +13,7,18 +4,11,6 +15,7,4 +5,13,17 +4,7,13 +5,8,19 +12,19,12 +6,4,6 +7,10,4 +4,5,11 +6,10,17 +16,12,17 +3,7,6 +6,5,8 +9,17,5 +13,3,7 +16,17,10 +6,5,4 +8,17,13 +16,13,8 +13,3,15 +8,20,12 +4,7,7 +8,17,17 +4,11,18 +19,11,11 +5,4,9 +2,15,14 +12,14,16 +17,6,5 +7,18,13 +16,5,15 +11,4,3 +11,19,8 +7,17,7 +3,14,9 +12,7,17 +13,4,10 +16,11,17 +6,17,11 +5,15,5 +11,7,2 +17,10,14 +2,9,14 +16,16,10 +19,10,6 +13,16,5 +17,11,5 +15,10,3 +14,2,11 +18,14,12 +15,8,2 +14,7,3 +11,15,5 +18,7,9 +19,12,13 +14,18,12 +2,10,13 +19,8,11 +4,15,11 +5,9,3 +16,5,14 +5,7,17 +4,13,11 +10,19,8 +2,8,11 +14,3,10 +13,3,14 +7,12,18 +13,19,8 +12,7,2 +12,10,20 +10,18,14 +7,3,10 +12,14,4 +11,15,3 +3,11,5 +14,15,17 +1,11,12 +14,4,5 +3,14,13 +10,16,18 +6,3,14 +6,2,10 +7,19,12 +4,8,16 +5,14,5 +7,14,18 +13,2,12 +6,17,16 +20,9,9 +15,14,6 +6,18,13 +9,18,13 +8,16,16 +4,17,11 +11,3,15 +8,6,18 +11,18,11 +7,2,8 +16,5,8 +10,5,3 +17,12,15 +8,7,5 +7,13,3 +9,18,10 +9,5,13 +15,4,9 +17,13,7 +17,6,13 +13,16,3 +19,9,14 +17,9,6 +19,12,12 +20,10,12 +6,10,3 +3,6,14 +6,16,10 +20,9,12 +14,6,17 +14,17,9 +7,4,5 +9,16,6 +13,2,10 +15,13,18 +9,5,10 +10,9,2 +13,5,18 +1,12,9 +11,3,6 +15,10,18 +9,11,3 +7,2,13 +16,15,9 +13,19,9 +17,4,10 +13,17,16 +11,4,16 +18,11,16 +2,11,9 +19,12,10 +4,14,10 +5,17,6 +3,13,8 +1,10,12 +2,6,11 +8,14,18 +18,8,12 +5,8,17 +18,14,8 +11,8,19 +17,14,14 +13,8,17 +13,20,11 +12,4,19 +17,12,3 +17,7,10 +3,7,13 +4,9,17 +17,7,5 +13,9,2 +2,11,11 +16,13,16 +17,15,11 +10,18,11 +8,16,3 +8,16,18 +10,18,16 +18,16,7 +13,18,13 +6,15,9 +5,6,4 +12,17,16 +6,9,16 +10,13,3 +5,18,10 +9,3,11 +17,12,17 +17,8,6 +3,13,7 +17,15,7 +19,8,13 +8,16,4 +3,13,16 +10,3,15 +15,14,4 +3,13,15 +16,4,13 +9,16,5 +10,17,15 +3,7,9 +8,16,17 +15,16,7 +19,11,7 +16,8,16 +10,11,19 +14,12,3 +8,2,10 +11,19,9 +5,19,10 +5,9,6 +2,9,13 +7,17,5 +6,16,15 +16,12,14 +4,8,15 +18,9,9 +2,12,14 +12,3,16 +17,7,17 +7,5,8 +18,13,5 +6,12,16 +2,12,7 +7,19,9 +16,10,15 +6,19,11 +15,13,4 +12,13,3 +15,17,14 +19,10,10 +6,4,14 +17,5,7 +13,14,4 +10,17,6 +10,16,16 +16,6,7 +15,2,14 +16,10,16 +12,1,8 +12,3,7 +4,11,5 +18,16,12 +6,6,15 +4,15,13 +12,5,4 +18,13,8 +9,15,18 +16,6,12 +14,16,3 +17,5,11 +18,7,13 +8,2,13 +17,16,8 +13,10,18 +12,16,3 +2,12,9 +16,9,17 +17,3,11 +17,9,7 +18,5,10 +3,11,17 +15,5,11 +20,11,14 +7,15,4 +18,7,7 +5,15,12 +19,8,8 +8,19,8 +13,10,3 +13,16,14 +7,3,12 +2,8,9 +8,7,3 +19,8,10 +7,7,17 +11,16,6 +3,12,17 +10,5,5 +9,2,11 +7,16,4 +11,15,19 +8,3,10 +9,4,16 +8,3,12 +4,15,15 +9,8,5 +14,11,17 +10,2,12 +17,4,13 +13,14,18 +6,13,5 +9,8,3 +7,7,4 +12,11,3 +3,11,7 +18,14,7 +16,4,12 +10,10,4 +13,13,2 +7,16,13 +17,10,4 +15,19,10 +14,6,4 +8,5,15 +18,12,13 +18,16,11 +9,17,16 +7,6,4 +4,11,13 +8,16,5 +13,18,5 +16,16,6 +11,12,18 +18,15,9 +1,12,14 +14,3,14 +11,11,17 +19,12,7 +16,17,16 +6,12,5 +7,5,5 +18,16,9 +9,6,2 +6,17,14 +17,10,13 +8,13,3 +18,12,6 +10,19,15 +15,7,17 +13,5,13 +6,8,16 +11,17,15 +10,4,16 +6,2,11 +11,7,4 +16,14,15 +16,15,15 +9,6,19 +15,15,12 +10,16,5 +18,14,15 +14,13,2 +18,7,5 +5,5,14 +7,16,12 +10,18,13 +16,10,3 +3,11,11 +17,5,10 +7,16,18 +2,13,14 +4,16,11 +8,10,1 +5,14,8 +6,14,17 +18,11,13 +17,14,15 +16,8,17 +11,4,15 +16,11,18 +17,17,10 +5,4,11 +5,9,4 +17,16,9 +4,4,14 +11,17,5 +19,14,12 +9,12,20 +13,12,2 +5,16,14 +16,13,6 +12,18,8 +12,16,16 +11,9,2 +19,9,12 +6,17,5 +11,14,19 +3,5,15 +7,4,14 +15,3,13 +7,17,13 +11,19,12 +11,18,10 +16,9,14 +5,10,3 +13,5,17 +6,9,18 +16,17,9 +5,5,11 +13,10,19 +5,5,13 +4,17,13 +11,1,10 +15,5,13 +18,7,8 +14,17,5 +7,18,7 +5,17,12 +14,8,18 +17,7,13 +3,15,9 +18,14,11 +11,9,19 +12,17,12 +17,17,11 +2,8,16 +11,17,7 +12,14,19 +12,18,7 +5,14,4 +16,15,10 +10,8,3 +4,14,16 +15,16,5 +5,15,16 +4,13,13 +3,8,8 +16,18,9 +18,13,6 +14,4,11 +17,6,15 +3,8,10 +6,15,18 +10,12,19 +12,19,6 +12,3,12 +8,16,6 +17,6,7 +6,3,15 +8,15,4 +7,11,18 +15,4,6 +8,3,14 +9,19,10 +18,7,12 +11,11,19 +13,7,3 +10,12,0 +15,3,12 +3,14,10 +4,16,14 +16,4,10 +18,6,11 +8,18,11 +11,11,18 +16,6,6 +19,12,6 +17,15,15 +18,6,12 +3,13,11 +16,12,6 +4,14,12 +20,12,12 +8,9,2 +3,16,13 +5,4,8 +5,3,10 +9,18,8 +2,10,12 +6,8,18 +9,13,3 +16,13,13 +5,14,16 +9,5,17 +14,2,6 +11,2,6 +9,19,12 +14,11,18 +5,9,7 +15,6,17 +11,3,4 +10,17,5 +9,4,5 +9,3,15 +14,17,8 +6,7,4 +14,9,17 +19,12,8 +14,6,16 +14,13,3 +17,6,9 +4,11,10 +15,10,17 +5,17,14 +17,16,14 +5,9,17 +19,10,9 +2,14,10 +7,15,16 +13,17,8 +18,13,10 +13,4,18 +7,5,12 +17,18,9 +4,13,6 +19,13,13 +7,11,20 +18,11,11 +20,12,11 +18,15,11 +8,9,18 +20,12,10 +16,8,14 +14,16,6 +15,3,10 +16,15,17 +12,19,11 +16,17,8 +18,6,9 +2,14,12 +14,16,7 +7,16,16 +20,9,8 +4,14,5 +11,3,10 +4,9,5 +16,15,5 +12,2,13 +5,4,6 +5,8,16 +10,10,18 +15,4,15 +3,15,10 +18,9,13 +15,3,14 +17,15,13 +11,15,4 +12,11,20 +11,5,17 +10,18,6 +15,8,4 +6,4,9 +3,7,14 +9,9,2 +14,4,14 +19,7,10 +2,13,15 +15,17,10 +4,12,8 +6,4,5 +11,14,18 +19,11,15 +18,15,14 +16,9,7 +6,8,6 +18,7,6 +17,12,5 +8,8,16 +12,5,18 +7,3,13 +9,14,1 +10,2,13 +7,13,19 +16,14,16 +15,4,11 +17,9,15 +12,16,15 +12,4,5 +1,10,7 +18,14,5 +12,4,6 +3,18,9 +16,6,4 +3,7,10 +5,5,15 +10,6,17 +15,13,17 +5,13,5 +14,19,11 +3,14,8 +13,9,19 +20,8,11 +8,17,18 +4,11,16 +3,6,8 +4,6,13 +16,7,7 +14,18,7 +10,3,8 +14,6,5 +12,6,18 +20,10,11 +2,14,9 +11,20,11 +8,18,15 +19,7,9 +9,7,4 +7,18,9 +3,14,16 +15,4,12 +6,3,6 +17,7,9 +18,5,8 +3,15,8 +17,11,16 +8,3,16 +16,7,16 +12,13,18 +8,2,9 +13,6,18 +15,8,14 +7,4,6 +5,18,13 +14,14,14 +10,7,3 +8,10,19 +2,9,11 +6,17,15 +4,15,14 +17,6,6 +9,2,10 +2,11,8 +6,17,7 +10,14,18 +18,5,12 +8,14,3 +10,9,17 +11,19,14 +10,15,5 +13,15,15 +19,8,7 +15,2,9 +16,10,18 +18,11,10 +15,5,15 +2,8,14 +6,9,3 +13,13,5 +12,10,18 +11,12,21 +15,15,4 +6,11,2 +1,13,7 +16,5,11 +14,14,4 +3,14,14 +13,1,8 +16,7,15 +13,11,19 +16,12,8 +14,18,6 +17,11,15 +7,2,12 +6,12,2 +7,5,6 +10,2,9 +15,15,10 +12,12,19 +9,5,15 +15,16,14 +8,13,6 +3,12,15 +10,19,11 +9,19,7 +17,14,7 +3,6,15 +15,18,13 +6,11,3 +5,17,11 +9,18,5 +17,15,6 +18,10,7 +18,15,13 +4,12,5 +3,4,8 +7,14,17 +17,18,12 +6,7,3 +11,20,9 +18,6,8 +7,16,15 +4,16,7 +10,12,3 +7,11,3 +5,11,18 +14,1,10 +13,20,10 +7,20,8 +13,17,15 +12,4,17 +3,11,15 +4,15,6 +6,13,9 +13,18,14 +10,14,3 +4,16,13 +8,19,12 +1,8,10 +16,15,6 +13,12,16 +4,4,6 +6,5,16 +10,8,19 +17,14,11 +18,7,11 +11,6,5 +2,14,7 +9,11,1 +10,19,9 +14,17,17 +7,3,9 +6,9,19 +11,4,17 +18,12,14 +11,3,9 +16,4,14 +6,4,8 +11,1,9 +7,17,17 +17,8,16 +4,11,4 +10,16,14 +5,12,5 +7,5,2 +15,18,11 +19,14,14 +9,5,6 +10,20,7 +14,5,5 +16,17,14 +18,5,7 +6,5,5 +16,7,14 +10,12,2 +11,4,5 +18,9,14 +16,14,3 +8,12,17 +5,9,16 +16,7,13 +10,1,7 +12,3,15 +5,7,8 +6,5,13 +12,5,3 +13,10,20 +10,18,4 +14,17,15 +7,3,6 +15,14,17 +12,2,8 +9,13,2 +18,16,8 +3,13,9 +8,17,8 +15,12,5 +4,10,9 +3,16,9 +5,16,8 +3,8,12 +6,4,10 +8,6,16 +5,17,13 +2,13,8 +15,13,19 +11,10,2 +4,14,11 +4,7,16 +18,15,8 +8,15,16 +12,9,20 +18,10,15 +8,1,10 +16,8,4 +8,6,4 +12,4,16 +6,15,4 +4,14,14 +13,2,13 +16,18,11 +11,6,2 +11,3,16 +6,6,14 +12,12,3 +14,17,13 +9,18,14 +5,13,18 +8,11,18 +12,11,4 +18,11,6 +14,3,8 +16,16,11 +10,4,7 +10,14,17 +15,9,16 +13,18,8 +6,3,9 +7,7,18 +18,6,7 +16,7,4 +12,13,4 +5,4,10 +11,13,18 +19,14,8 +4,11,14 +16,11,15 +2,12,11 +8,17,15 +6,12,19 +10,5,17 +7,18,10 +6,16,12 +16,9,4 +3,10,6 +14,4,13 +6,11,17 +9,7,19 +10,14,19 +13,9,3 +6,5,14 +9,4,8 +13,18,10 +16,12,16 +16,5,6 +5,4,16 +17,6,8 +14,10,4 +6,18,8 +5,3,11 +4,12,6 +3,6,7 +13,2,7 +11,1,13 +8,4,6 +12,11,18 +13,18,6 +20,9,14 +3,15,11 +12,19,14 +13,11,3 +8,2,12 +8,11,19 +17,17,8 +4,13,17 +11,8,3 +14,5,17 +5,11,3 +11,3,14 +6,13,16 +10,4,5 +5,9,2 +11,9,3 +16,7,5 +16,3,9 +15,5,7 +1,12,8 +16,9,15 +12,5,7 +16,17,13 +13,3,10 +18,8,6 +3,12,8 +17,16,15 +16,17,11 +15,16,11 +2,7,10 +1,10,11 +9,11,4 +6,18,11 +12,16,9 +10,11,20 +7,17,9 +15,4,5 +4,15,5 +15,7,18 +12,16,5 +13,9,20 +7,3,5 +13,15,4 +5,18,11 +7,8,17 +19,11,8 +15,5,12 +14,15,15 +12,7,3 +6,3,11 +3,8,6 +19,15,8 +16,16,8 +11,3,8 +11,5,5 +10,15,3 +14,2,12 +6,17,8 +16,12,4 +4,8,3 +16,6,15 +18,11,17 +14,8,4 +8,3,8 +2,14,14 +10,3,4 +6,17,10 +19,12,11 +15,9,18 +10,19,12 +12,3,8 +14,16,5 +18,10,9 +3,7,12 +4,5,15 +15,14,5 +16,4,7 +16,12,19 +14,5,13 +13,15,18 +1,11,11 +10,3,5 +7,6,19 +12,16,4 +10,11,2 +6,6,4 +12,17,4 +14,10,17 +13,18,11 +11,18,15 +7,8,19 +9,9,3 +12,3,13 +8,18,10 +4,5,9 +7,12,1 +14,9,7 +4,4,12 +7,12,3 +16,17,12 +5,5,8 +9,4,14 +17,9,12 +13,15,19 +8,5,5 +14,2,7 +14,15,3 +17,11,10 +8,9,1 +4,6,15 +15,15,5 +11,17,4 +6,8,2 +3,9,17 +4,6,8 +13,3,16 +14,19,8 +2,13,9 +6,4,7 +2,7,7 +11,14,4 +16,4,15 +7,14,5 +8,13,4 +11,6,19 +11,4,4 +12,18,14 +11,10,18 +5,7,16 +7,4,15 +13,5,15 +17,5,6 +11,7,18 +17,9,13 +19,9,11 +17,12,9 +13,8,19 +5,6,11 +9,7,3 +6,16,7 +5,15,13 +10,6,16 +6,12,3 +10,20,11 +9,12,4 +16,5,10 +10,2,8 +16,5,9 +8,15,18 +14,18,13 +15,11,18 +6,9,2 +10,13,4 +18,10,11 +18,11,8 +6,16,13 +12,1,13 +2,11,10 +6,7,6 +18,10,10 +11,16,17 +3,9,7 +5,15,6 +4,12,15 +3,8,15 +11,3,12 +16,9,18 +1,12,12 +3,15,16 +16,8,6 +10,18,8 +11,15,2 +10,4,14 +10,7,20 +12,18,15 +2,10,11 +17,15,8 +6,12,4 +18,10,17 +5,3,9 +19,6,10 +5,6,7 +7,13,6 +15,3,6 +9,6,4 +6,4,4 +13,3,4 +9,1,13 +11,17,9 +5,16,12 +19,11,13 +13,6,4 +11,9,20 +6,15,7 +18,8,9 +12,3,14 +5,5,4 +13,9,18 +1,8,9 +10,17,16 +3,12,13 +8,12,3 +6,8,4 +5,4,15 +2,14,6 +9,2,12 +8,14,17 +16,13,5 +18,7,14 +14,12,18 +9,16,4 +5,5,16 +6,10,4 +12,18,9 +16,18,12 +10,10,21 +3,7,7 +18,9,8 +14,18,14 +14,13,18 +11,19,15 +12,17,5 +12,15,16 +7,9,4 +1,12,10 +15,15,16 +13,1,10 +9,8,2 +10,19,4 +15,5,5 +18,10,4 +11,17,6 +6,10,2 +10,5,14 +13,8,2 +12,20,8 +3,9,5 +12,4,15 +6,4,11 +12,16,7 +17,14,16 +3,15,12 +10,9,4 +16,18,13 +7,12,19 +10,19,10 +5,16,7 +9,19,6 +2,10,10 +9,2,8 +4,12,7 +13,15,2 +14,7,18 +5,11,7 +2,8,7 +14,16,16 +4,17,12 +4,12,17 +5,17,8 +16,14,5 +16,15,12 +3,7,8 +16,16,16 +3,5,11 +5,15,17 +14,19,14 +16,10,5 +4,8,7 +15,17,5 +9,10,3 +19,13,9 +5,4,13 +6,3,12 +18,9,10 +3,10,9 +9,18,6 +18,12,12 +19,10,13 +17,13,9 +12,18,6 +15,8,17 +2,6,12 +7,10,19 +7,9,19 +8,2,8 +14,10,3 +15,9,4 +3,7,11 +4,6,14 +10,16,4 +15,16,15 +5,17,17 +9,11,18 +6,3,13 +7,7,2 +15,17,6 +16,11,16 +12,8,20 +19,9,7 +4,13,8 +8,4,15 +8,5,16 +11,2,5 +10,19,14 +3,12,9 +18,9,12 +4,6,12 +6,7,18 +16,7,12 +9,14,5 +8,11,20 +18,8,13 +12,7,19 +5,16,6 +16,3,12 +12,18,16 +5,7,4 +12,11,2 +12,3,17 +13,8,18 +10,9,18 +14,16,8 +3,14,12 +8,18,6 +2,9,7 +2,8,8 +16,18,14 +6,6,17 +13,4,8 +16,18,10 +18,8,7 +17,6,14 +14,15,4 +7,6,8 +14,2,13 +4,10,16 +18,13,16 +17,10,16 +3,6,5 +14,18,8 +4,15,8 +10,19,13 +16,15,8 +12,5,17 +11,2,11 +11,6,3 +9,5,3 +8,18,8 +12,17,8 +16,14,4 +3,6,11 +19,12,15 +4,14,13 +16,16,15 +7,7,16 +8,4,14 +12,13,19 +18,6,6 +3,12,16 +18,9,15 +12,2,11 +12,15,18 +9,16,18 +20,8,10 +8,8,17 +5,11,4 +15,8,18 +13,3,9 +9,16,16 +7,17,14 +17,9,17 +8,11,3 +4,15,4 +12,17,15 +11,2,8 +5,7,5 +10,1,12 +17,12,13 +8,17,16 +10,9,19 +3,17,11 +11,6,17 +15,3,9 +18,11,7 +20,10,8 +8,15,3 +4,9,6 +18,13,15 +9,13,17 +2,10,8 +15,3,15 +11,10,19 +11,4,6 +10,7,18 +5,5,10 +7,16,6 +16,6,11 +11,5,18 +2,7,12 +4,6,10 +16,7,6 +6,19,12 +17,16,12 +9,3,9 +15,14,16 +16,4,9 +7,11,2 +10,11,1 +6,17,6 +4,6,5 +8,12,19 +5,13,14 +8,8,3 +13,4,11 +12,4,4 +12,18,5 +15,8,19 +15,3,7 +19,6,11 +4,15,12 +11,14,17 +4,7,15 +6,14,2 +9,16,17 +6,14,3 +12,6,2 +9,19,8 +15,4,14 +8,5,17 +3,6,12 +6,7,16 +5,17,10 +11,5,16 +2,8,10 +17,9,3 +8,5,6 +17,7,8 +11,19,11 +17,8,4 +17,14,12 +11,3,17 +17,15,14 +12,17,6 +14,4,16 +5,11,16 +11,20,12 +7,10,3 +2,7,8 +8,7,2 +13,19,12 +6,13,4 +5,7,7 +15,18,15 +13,17,5 +8,6,2 +15,13,5 +15,14,18 +8,4,8 +15,18,6 +12,11,17 +2,10,9 +8,7,19 +9,12,17 +11,2,10 +13,2,14 +10,5,18 +7,13,18 +11,13,19 +9,3,13 +6,19,10 +12,15,4 +4,11,7 +14,17,7 +8,16,14 +16,6,5 +6,13,17 +14,9,3 +18,10,8 +19,10,8 +18,12,4 +13,11,18 +9,11,2 +16,12,3 +9,5,18 +7,9,20 +3,10,5 +11,5,3 +12,8,3 +19,9,10 +4,10,17 +17,14,5 +17,5,12 +2,9,15 +7,15,17 +17,8,5 +10,12,1 +7,9,2 +16,16,4 +17,13,4 +5,12,18 +7,10,18 +13,7,4 +8,15,17 +2,9,16 +14,8,3 +6,16,4 +14,15,18 +2,13,13 +10,17,17 +8,19,9 +14,9,19 +13,17,12 +13,1,12 +13,12,18 +9,8,18 +18,10,14 +3,14,7 +3,11,8 +17,14,17 +2,14,8 +6,5,6 +3,9,4 +13,17,17 +3,9,9 +15,11,1 +13,5,4 +4,10,15 +5,12,17 +5,16,16 +6,5,9 +2,13,7 +2,5,10 +14,16,17 +14,3,11 +13,4,4 +15,7,19 +6,16,16 +4,5,8 +8,4,10 +7,16,5 +6,17,12 +13,8,4 +18,4,9 +9,18,12 +17,15,10 +20,12,9 +7,5,7 +17,11,3 +12,8,15 +11,2,12 +8,19,10 +7,9,3 +3,7,4 +7,14,3 +7,19,10 +12,17,17 +9,16,7 +3,8,11 +10,17,14 +12,14,18 +3,8,13 +1,14,9 +8,12,18 +18,10,12 +18,8,8 +11,16,5 +9,19,16 +12,10,4 +8,10,2 +13,5,5 +6,6,18 +19,9,9 +9,2,13 +8,8,19 +4,11,3 +14,19,12 +14,5,14 +17,5,8 +11,5,6 +2,15,10 +3,14,11 +4,6,6 +6,18,14 +3,4,13 +5,14,14 +9,15,19 +4,5,7 +16,3,13 +7,4,13 +13,9,17 +12,2,14 +14,6,8 +16,5,13 +17,7,11 +10,12,20 +11,2,9 +14,3,9 +17,11,4 +13,19,13 +5,13,3 +8,6,5 +12,16,17 +11,12,3 +5,16,15 +14,18,9 +11,6,18 +6,14,4 +2,12,13 +11,2,16 +7,2,10 +6,11,18 +18,9,6 +14,12,4 +15,5,6 +5,15,7 +16,18,8 +13,15,17 +7,16,14 +11,2,15 +16,10,4 +19,11,14 +17,13,16 +13,17,4 +5,3,13 +14,14,2 +3,13,10 +10,20,14 +12,2,6 +19,8,9 +4,8,4 +7,7,5 +2,8,12 +17,4,14 +10,20,12 +13,18,7 +15,18,12 +4,9,14 +12,9,19 +17,13,17 +17,5,14 +6,16,17 +6,18,9 +4,6,9 +7,8,16 +11,9,18 +2,11,12 +10,5,4 +8,5,4 +8,12,4 +2,12,16 +8,7,4 +13,2,11 +5,9,18 +4,8,13 +13,16,15 +5,5,12 +19,10,15 +14,4,7 +10,10,17 +15,12,3 +13,7,17 +18,5,13 +14,3,6 +18,6,10 +14,11,3 +15,11,3 +5,16,13 +4,10,5 +14,6,15 +18,14,13 +9,14,17 +18,14,17 +12,3,10 +9,6,3 +11,4,12 +7,16,9 +8,20,13 +4,7,9 +3,10,13 +9,5,19 +16,13,12 +12,8,19 +6,18,15 +11,18,16 +9,12,1 +9,4,4 +14,3,15 +9,15,2 +9,7,17 +16,13,19 +7,18,11 +3,8,7 +9,4,18 +16,5,5 +16,16,5 +10,19,6 +14,14,18 +17,8,12 +5,12,4 +3,5,10 +14,4,4 +13,13,19 +15,12,4 +1,9,10 +17,11,18 +5,14,6 +11,17,11 +8,9,3 +10,2,14 +16,8,3 +12,4,11 +6,10,8 +17,8,10 +15,8,16 +17,13,13 +18,9,17 +14,8,17 +2,16,12 +16,15,14 +12,10,19 +6,5,15 +3,12,7 +8,17,4 +9,17,15 +12,12,17 +4,18,9 +18,4,11 +5,3,14 +3,11,10 +7,2,11 +12,14,3 +12,15,2 +10,18,7 +9,14,18 +16,13,7 +8,15,19 +9,12,19 +7,6,18 +15,6,16 +18,10,13 +11,12,19 +17,9,10 +10,21,13 +4,17,14 +7,2,9 +10,5,16 +12,1,10 +3,11,14 +3,10,14 +6,18,10 +9,2,6 +7,17,4 +18,9,11 +8,13,19 +15,4,8 +6,19,9 +9,5,4 +9,18,7 +1,10,13 +16,11,3 +7,15,6 +12,2,10 +9,4,6 +13,2,9 +10,15,17 +9,21,11 +9,14,3 +14,4,9 +17,11,17 +15,4,10 +13,13,6 +10,8,18 +13,18,17 +10,16,15 +15,6,3 +14,10,18 +10,4,4 +2,6,9 +6,12,18 +11,8,2 +17,5,13 +9,16,15 +18,6,14 +12,2,5 +2,12,5 +13,9,4 +4,10,7 +15,15,11 +9,17,4 +8,14,2 +5,15,14 +18,5,11 +7,4,8 +2,10,15 +5,6,17 +18,4,12 +11,6,4 +7,6,3 +5,12,16 +16,8,5 +6,9,5 +7,6,7 +15,10,19 +19,7,11 +4,13,7 +13,6,3 +11,18,12 +3,13,13 +8,17,14 +19,10,12 +14,17,10 +12,4,13 +11,10,20 +4,14,7 +4,14,15 +18,7,15 +10,3,11 +9,3,16 +8,6,6 +10,17,7 +14,15,6 +19,13,8 +9,7,2 +13,16,17 +15,10,1 +10,2,4 +9,3,5 +7,18,15 +13,20,12 +5,15,15 +8,13,20 +6,15,12 +8,3,6 +7,9,15 +17,13,8 +19,11,9 +17,7,15 +19,16,9 +18,8,5 +7,15,7 +8,4,16 +3,14,6 +18,15,7 +16,18,7 +14,17,6 +17,15,12 +7,4,16 +8,10,3 +3,5,12 +14,6,6 +6,13,18 +18,8,15 +13,4,13 +19,15,9 +13,13,3 +15,14,14 +9,3,6 +9,6,16 +16,12,5 +12,19,13 +9,20,7 +6,16,6 +4,13,4 +2,11,13 +18,13,4 +15,13,16 +15,7,3 +18,5,14 +9,20,11 +7,14,2 +17,10,15 +5,17,9 +19,16,10 +3,6,10 +19,7,8 +12,6,4 +13,6,16 +16,15,11 +5,8,3 +13,4,5 +15,9,5 +5,5,9 +7,3,11 +15,16,16 +17,10,17 +8,6,17 +4,9,15 +4,13,9 +15,18,14 +18,11,14 +4,5,10 +13,19,14 +18,6,5 +12,12,2 +7,5,15 +11,12,20 +9,3,12 +14,17,12 +19,13,11 +16,7,9 +5,7,18 +5,11,5 +16,11,4 +5,7,15 +11,5,2 +9,3,7 +8,10,4 +20,11,11 +13,14,16 +2,8,5 +12,15,19 +9,13,18 +15,16,9 +5,10,4 +3,12,14 +7,4,7 +9,8,4 +4,7,10 +7,16,11 +8,18,13 +5,15,10 +9,20,13 +8,19,14 +18,13,9 +4,16,6 +2,11,6 +10,18,12 +13,5,3 +5,14,15 +11,4,18 +11,16,18 +4,10,11 +5,5,7 +5,5,6 +16,6,16 +11,7,19 +15,11,5 +8,3,11 +5,14,7 +12,9,17 +11,18,14 +10,1,10 +13,15,6 +4,10,4 +16,8,15 +9,19,15 +19,14,11 +5,11,15 +15,17,9 +4,10,13 +11,17,16 +4,8,5 +4,6,17 +6,3,10 +13,17,10 +5,6,13 +4,3,12 +19,15,11 +3,13,6 +13,9,1 +11,1,5 +13,17,14 +11,2,7 +11,2,14 +8,9,5 +12,8,5 +7,4,17 +17,12,16 +13,18,9 +20,11,15 +9,2,15 +8,18,16 +15,6,6 +20,7,13 +2,13,11 +17,4,11 +3,7,15 +8,18,7 +16,3,11 +19,7,13 +16,14,18 +14,15,8 +4,15,16 +17,5,15 +10,2,11 +14,2,9 +9,10,1 +13,14,3 +14,9,20 +17,17,7 +8,3,7 +3,15,6 +17,7,6 +11,7,17 +8,4,7 +13,18,12 +8,9,4 +5,7,14 +11,2,13 +3,10,10 +15,3,8 +6,15,6 +9,2,5 +1,10,10 +15,4,16 +15,19,12 +13,19,15 +14,3,7 +12,17,9 +10,3,16 +13,17,7 +17,14,6 +12,12,4 +17,12,7 +2,11,15 +16,8,12 +5,6,6 +8,11,2 +10,9,20 +19,9,8 +8,17,11 +11,3,13 +5,13,6 +11,15,1 +18,12,8 +15,10,4 +2,10,7 +9,18,17 +13,17,9 +20,11,13 +11,11,4 +20,9,7 +10,6,3 +11,16,4 +4,16,12 +9,12,3 +5,10,5 +17,11,11 +3,12,4 +13,4,14 +6,15,17 +6,16,8 +4,6,7 +17,11,14 +12,15,17 +8,1,11 +10,15,18 +4,5,6 +3,16,8 +15,12,2 +5,14,17 +9,3,4 +8,2,14 +6,16,14 +10,8,2 +10,2,15 +19,7,15 +12,7,16 +15,15,7 +5,15,11 +15,14,3 +12,14,2 +5,3,6 +3,3,11 +3,8,16 +19,12,14 +7,13,2 +9,1,12 +2,11,14 +17,7,16 +16,15,13 +5,15,4 +17,7,14 +9,18,16 +17,15,16 +11,17,10 +7,16,3 +7,7,3 +12,4,8 +8,9,19 +17,10,9 +3,13,12 +17,8,15 +5,11,17 +18,9,7 +16,10,13 +11,10,1 +5,9,5 +9,19,9 +12,19,10 +13,10,1 +6,15,15 +15,2,12 +18,16,6 +11,17,17 +19,10,14 +10,15,2 +8,2,6 +10,18,15 +6,4,15 +10,3,12 +3,16,11 +15,7,9 +16,13,2 +19,10,16 +14,9,4 +1,9,7 +5,7,12 +19,6,12 +13,11,20 +4,15,17 +2,12,10 +8,19,7 +10,3,14 +3,15,13 +10,18,9 +1,12,7 +17,6,10 +5,11,12 +7,5,17 +6,10,18 +6,11,16 +2,10,6 +8,10,17 +6,6,3 +14,2,8 +7,8,18 +16,3,8 +14,12,19 +18,11,5 +10,11,3 +13,10,17 +20,7,9 +14,7,17 +18,12,5 +20,13,12 +16,7,8 +12,9,3 +15,10,16 +12,18,4 +18,14,9 +16,17,15 +8,12,8 +19,11,12 +11,18,6 +6,6,5 +5,6,12 +1,10,8 +14,15,5 +6,15,5 +14,11,5 +13,7,2 +16,19,12 +7,9,18 +15,10,2 +12,6,19 +15,17,11 +4,17,8 +14,13,5 +10,6,19 +6,14,19 +14,3,13 +17,5,9 +6,7,5 +5,12,3 +6,2,9 +4,7,17 +11,14,7 +9,17,7 +18,12,15 +7,14,20 +17,11,6 +13,6,17 +5,16,9 +9,2,9 +12,15,3 +4,10,6 +13,5,16 +2,9,6 +9,17,17 +3,10,12 +18,17,9 +17,13,12 +12,5,6 +13,4,6 +4,9,7 +8,14,19 +17,12,4 +19,10,7 +8,6,19 +15,15,6 +8,12,2 +10,4,6 +13,3,17 +17,8,11 +15,5,8 +14,5,4 +1,9,9 +4,16,15 +1,11,10 +17,18,11 +15,12,19 +12,17,11 +3,10,7 +7,5,4 +5,3,8 +4,5,13 +10,3,6 +15,15,17 +11,1,12 +17,9,5 +12,1,9 +2,9,10 +10,1,14 +6,16,9 +12,6,6 +5,16,11 +10,10,19 +18,13,14 +17,10,7 +2,6,13 +10,10,16 +2,7,11 +16,11,14 +1,13,9 +9,10,20 +7,18,8 +16,14,14 +16,16,9 +9,19,14 +8,17,9 +16,13,3 +17,4,8 +12,11,19 +10,10,3 +8,3,13 +7,8,3 +4,7,14 +14,9,2 +14,2,10 +13,13,17 +4,4,10 +15,18,10 +6,5,10 +3,9,13 +11,18,13 +10,6,15 +3,8,9 +7,17,8 +6,15,8 +11,18,5 +6,7,15 +8,8,18 +8,2,7 +6,10,15 +9,20,10 +7,5,14 +7,9,5 +19,15,14 +4,9,16 +4,3,11 +18,5,9 +19,6,8 +7,13,15 +6,8,3 +7,18,12 +9,15,4 +11,11,0 +8,18,14 +10,7,2 +13,20,13 +12,10,17 +5,10,18 +7,17,15 +3,12,6 +15,16,12 +18,12,9 +10,18,5 +16,16,13 +19,13,12 +14,19,7 +8,8,5 +19,16,14 +13,3,13 +9,18,9 +17,5,5 +4,6,11 +7,14,4 +3,16,7 +14,14,5 +13,4,9 +4,4,8 +13,3,11 +14,8,19 +16,19,9 +6,9,17 +6,16,5 +14,10,2 +10,16,19 +6,5,11 +8,13,2 +15,7,5 +10,3,17 +10,14,2 +5,4,14 +9,3,14 +12,19,15 +14,12,16 +17,10,5 +17,8,7 +15,5,18 +13,15,20 +15,15,18 +3,8,5 +4,13,15 +16,4,6 +11,10,3 +11,4,7 +7,3,14 +7,12,2 +20,9,11 +5,7,6 +19,14,7 +17,6,11 +17,16,13 +7,3,8 +11,13,3 +16,13,4 +13,19,7 +11,7,3 +9,8,19 +14,17,4 +6,5,17 +5,10,17 +13,12,1 +13,15,9 +14,16,18 +5,14,10 +3,11,12 +13,18,15 +13,3,5 +5,2,12 +3,5,13 +14,11,19 +9,17,18 +19,5,10 +12,2,7 +4,16,10 +11,5,4 +8,4,18 +12,9,18 +18,11,12 +9,12,18 +12,4,18 +5,8,5 +5,8,9 +5,11,14 +5,9,15 +17,10,3 +13,15,16 +1,7,9 +8,16,12 +13,6,11 +16,2,8 +7,12,4 +5,8,13 +7,12,17 +6,8,5 +11,4,14 +3,10,16 +16,9,5 +9,9,20 +8,5,10 +15,6,5 +10,9,1 +18,9,16 +12,6,17 +14,8,16 +12,7,18 +11,11,3 +17,6,16 +12,4,9 +4,7,6 +9,20,9 +19,9,13 +2,8,6 +12,3,9 +1,12,11 +10,1,11 +5,2,11 +12,8,2 +9,6,18 +16,3,14 +17,18,10 +2,8,13 +14,16,4 +17,7,12 +2,6,10 +12,10,3 +12,3,6 +8,19,11 +13,12,17 +10,18,10 +4,12,3 +4,13,14 +8,6,7 +10,1,6 +7,10,17 +13,14,2 +6,3,8 +7,4,12 +18,15,5 +18,11,15 +16,16,14 +6,11,4 +3,17,8 +13,12,19 +15,10,5 +11,20,13 +8,20,8 +5,4,12 +3,9,10 +6,14,5 +5,7,3 +15,8,5 +12,7,4 +6,11,5 +17,10,8 +9,4,9 +7,6,5 +19,6,13 +12,18,10 +8,3,9 +4,7,5 +20,12,8 +2,7,15 +16,8,7 +13,1,13 +10,16,3 +13,15,5 +13,19,6 +10,16,2 +19,14,10 +7,19,14 +1,11,9 +19,9,15 +10,4,15 +8,18,5 +9,3,10 +15,17,15 +2,13,12 +14,13,19 +15,19,9 +3,16,15 +12,9,1 +18,13,7 +17,10,18 +18,8,10 +6,14,6 +14,3,12 +7,6,17 +5,6,14 +16,14,8 +13,16,18 +14,19,13 +16,15,4 +12,10,1 +10,15,4 +9,14,19 +3,15,7 +14,18,15 +7,14,16 +11,17,14 +7,16,7 +9,4,7 +10,8,16 +15,6,13 +15,17,8 +17,8,17 +15,2,13 +15,5,16 +17,17,9 +9,10,19 +15,4,13 +7,18,16 +14,16,12 +15,12,18 +5,8,4 +18,10,6 +6,17,9 +14,11,20 +19,13,16 +4,13,16 +7,17,11 +10,17,3 +18,13,13 +2,15,9 +15,2,10 +13,10,2 +12,5,19 +9,15,5 +19,15,10 +10,14,4 +17,8,18 +7,8,2 +6,10,6 +5,3,12 +15,5,4 +15,18,9 +10,7,4 +4,9,10 +6,9,4 +10,16,17 +8,17,10 +1,9,11 +7,10,16 +12,6,5 +7,15,19 +12,12,18 +8,4,5 +15,18,7 +11,18,4 +11,19,7 +10,2,7 +5,12,6 +11,14,1 +8,3,4 +12,7,1 +17,10,6 +3,6,13 +20,14,10 +13,6,5 +10,13,18 +10,2,6 +16,11,5 +8,8,20 +10,17,10 +17,3,13 +16,16,12 +12,9,2 +8,1,12 +12,4,12 +10,6,2 +9,2,14 +3,9,8 +12,10,2 +11,12,2 +14,10,15 +13,14,6 +11,20,7 +6,19,13 +5,7,13 +16,7,3 +19,13,10 +11,17,13 +14,5,11 +11,10,17 +3,10,17 +11,9,17 +19,11,10 +18,9,4 +17,8,14 +8,14,4 +4,7,4 +12,18,13 +12,17,14 +13,20,14 +16,14,17 +7,6,16 +14,5,6 +13,4,16 +14,13,16 +10,3,7 +4,11,12 +13,4,15 +13,14,19 +4,7,11 +17,3,8 +7,11,17 +15,9,3 +5,12,13 +8,20,9 +5,10,8 +11,12,17 +9,19,13 +12,13,2 +16,4,8 +9,18,15 +9,14,2 +3,10,11 +1,10,9 +2,15,13 +15,8,3 +15,5,17 +6,8,14 +17,13,11 +16,6,8 +15,6,18 +10,17,8 +15,17,16 +13,12,3 +10,11,18 +10,13,2 +11,3,3 +7,19,8 +9,15,17 +4,16,9 +8,19,15 +13,20,8 +15,1,11 +17,17,12 +2,9,9 +9,13,1 +16,19,10 +14,16,15 +12,16,18 +15,9,19 +10,17,13 +12,12,20 +13,16,7 +20,10,13 +17,9,11 +17,17,14 +5,4,7 +12,4,3 +7,19,6 +3,11,13 +12,1,12 +17,14,13 +18,7,10 +8,4,13 +19,7,12 +5,6,8 +3,12,5 +3,5,9 +12,2,12 +8,15,5 +7,16,17 +6,13,11 +7,9,17 +5,15,9 +6,17,13 +17,7,7 +6,10,19 +15,13,15 +14,8,2 +11,12,16 +7,4,10 +18,14,14 +15,19,11 +11,13,4 +14,20,11 +16,7,18 +16,13,17 +15,18,8 +8,13,17 +20,8,14 +15,11,16 +10,16,7 +4,15,9 +14,7,5 +8,1,13 +6,14,16 +6,2,12 +5,17,15 +12,2,9 +13,6,2 +14,5,8 +7,4,11 +6,7,13 +2,6,8 +13,5,6 +3,15,14 +15,15,13 +15,11,4 +10,12,4 +17,8,9 +4,8,9 +12,13,1 +10,4,13 +12,16,6 +10,8,17 +7,8,15 +12,7,20 +10,3,9 +17,4,7 +9,15,15 +19,9,16 +8,10,18 +6,7,12 +5,12,14 +18,16,10 +19,6,14 +7,15,15 +8,18,17 +6,5,7 +5,2,10 +10,7,5 +2,8,15 +10,11,17 +5,5,17 +3,6,9 +11,5,15 +2,11,16 +10,5,6 +8,7,17 +6,18,5 +17,6,4 +11,16,16 +20,9,10 +7,13,17 +17,13,6 +16,6,13 +17,7,4 +17,16,10 +16,18,15 +15,6,9 +18,6,13 +5,11,13 +14,7,16 +11,7,20 +20,10,14 +5,12,2 +8,8,4 +14,17,14 +4,14,6 +10,21,11 +13,6,19 +1,13,11 +3,4,12 +8,15,15 +16,8,8 +13,7,5 +10,1,13 +14,5,18 +12,14,20 +17,16,6 +9,17,13 +7,18,14 +14,4,8 +14,9,1 +9,20,12 +9,3,8 +4,12,10 +5,14,13 +4,16,5 +5,3,7 +3,9,6 +10,12,6 +5,17,7 +2,12,8 +14,4,12 +17,6,17 +4,13,10 +3,9,16 +15,11,2 +9,3,17 +1,15,11 +18,16,13 +21,9,12 +11,20,10 +1,9,8 +14,4,15 +7,17,6 +14,18,10 +18,14,10 +17,9,4 +2,12,15 +11,8,20 +15,4,17 +18,7,16 +15,15,3 +16,17,7 +7,12,16 +10,12,17 +16,5,12 +18,8,4 +15,18,5 +9,16,3 +1,9,14 +15,13,3 +6,18,12 +16,14,7 +5,14,18 +14,4,6 +12,13,17 +11,11,1 +7,19,7 +7,11,4 +7,8,6 +9,8,20 +13,17,18 +14,14,19 +2,14,11 +8,16,8 +2,10,16 +7,2,6 +12,20,12 +9,6,5 +10,1,9 +15,15,15 +2,13,4 +2,7,14 +9,9,19 +10,18,18 +4,12,16 +13,5,19 +11,20,8 +6,15,11 +13,8,3 +13,16,11 +4,4,11 +10,15,1 +9,11,19 +10,4,17 +8,9,20 +11,9,1 +9,2,7 +10,5,2 +8,12,1 +10,6,5 +12,3,4 +9,13,5 +13,3,8 +6,5,12 +11,17,18 +14,19,10 +4,6,4 +1,11,13 +4,10,8 +8,19,6 +15,5,9 +10,19,7 +8,4,4 +6,4,12 +19,16,12 +3,11,6 +10,0,10 +7,9,16 +9,17,6 +19,13,6 +4,18,11 +14,20,8 +16,14,6 +4,11,17 +20,12,14 +15,16,4 +7,2,7 +20,13,9 +18,15,15 +18,4,8 +11,18,9 +8,17,5 +16,17,6 +15,17,13 +17,10,11 +17,15,9 +15,7,15 +16,11,19 +4,12,14 +10,14,6 +8,12,16 +13,16,4 +19,15,7 +17,17,5 +6,6,16 +14,17,16 +15,6,14 +17,14,9 +12,17,13 +9,4,11 +7,13,16 +11,6,16 +4,11,15 +11,3,7 +5,18,12 +10,15,8 +13,7,19 +16,13,15 +13,5,7 +17,12,11 +14,15,7 +16,14,10 +6,12,17 +17,16,17 +20,12,13 +11,19,10 +20,11,10 +6,10,5 +4,7,8 +1,8,8 +12,3,5 +14,9,18 +17,18,14 +13,12,4 +2,15,12 +9,4,15 +5,14,9 +15,13,1 +17,12,18 +8,19,13 diff --git a/2022/Day19CSharp/Day19CSharp.csproj b/2022/Day19CSharp/Day19CSharp.csproj new file mode 100644 index 0000000..d439800 --- /dev/null +++ b/2022/Day19CSharp/Day19CSharp.csproj @@ -0,0 +1,10 @@ + + + + Exe + net7.0 + enable + enable + + + diff --git a/2022/Day19CSharp/Program.cs b/2022/Day19CSharp/Program.cs new file mode 100644 index 0000000..83fa4f4 --- /dev/null +++ b/2022/Day19CSharp/Program.cs @@ -0,0 +1,2 @@ +// See https://aka.ms/new-console-template for more information +Console.WriteLine("Hello, World!"); diff --git a/2022/Day19CSharp/Properties/launchSettings.json b/2022/Day19CSharp/Properties/launchSettings.json new file mode 100644 index 0000000..f024555 --- /dev/null +++ b/2022/Day19CSharp/Properties/launchSettings.json @@ -0,0 +1,8 @@ +{ + "profiles": { + "Day19CSharp": { + "commandName": "Project", + "workingDirectory": "C:\\dev\\DevSandbox\\AdventOfCode\\2022\\Day19CSharp" + } + } +} \ No newline at end of file diff --git a/2022/Day19CSharp/example-input.txt b/2022/Day19CSharp/example-input.txt new file mode 100644 index 0000000..3b5bf4a --- /dev/null +++ b/2022/Day19CSharp/example-input.txt @@ -0,0 +1,2 @@ +Blueprint 1: Each ore robot costs 4 ore. Each clay robot costs 2 ore. Each obsidian robot costs 3 ore and 14 clay. Each geode robot costs 2 ore and 7 obsidian. +Blueprint 2: Each ore robot costs 2 ore. Each clay robot costs 3 ore. Each obsidian robot costs 3 ore and 8 clay. Each geode robot costs 3 ore and 12 obsidian. \ No newline at end of file diff --git a/2022/Day19CSharp/problem.txt b/2022/Day19CSharp/problem.txt new file mode 100644 index 0000000..c1c4734 --- /dev/null +++ b/2022/Day19CSharp/problem.txt @@ -0,0 +1,169 @@ +--- Day 19: Not Enough Minerals --- + +Your scans show that the lava did indeed form obsidian! + +The wind has changed direction enough to stop sending lava droplets toward you, so you and the elephants exit the cave. As you do, you notice a collection of geodes around the pond. Perhaps you could use the obsidian to create some geode-cracking robots and break them open? + +To collect the obsidian from the bottom of the pond, you'll need waterproof obsidian-collecting robots. Fortunately, there is an abundant amount of clay nearby that you can use to make them waterproof. + +In order to harvest the clay, you'll need special-purpose clay-collecting robots. To make any type of robot, you'll need ore, which is also plentiful but in the opposite direction from the clay. + +Collecting ore requires ore-collecting robots with big drills. Fortunately, you have exactly one ore-collecting robot in your pack that you can use to kickstart the whole operation. + +Each robot can collect 1 of its resource type per minute. It also takes one minute for the robot factory (also conveniently from your pack) to construct any type of robot, although it consumes the necessary resources available when construction begins. + +The robot factory has many blueprints (your puzzle input) you can choose from, but once you've configured it with a blueprint, you can't change it. You'll need to work out which blueprint is best. + +For example: + +Blueprint 1: + Each ore robot costs 4 ore. + Each clay robot costs 2 ore. + Each obsidian robot costs 3 ore and 14 clay. + Each geode robot costs 2 ore and 7 obsidian. + +Blueprint 2: + Each ore robot costs 2 ore. + Each clay robot costs 3 ore. + Each obsidian robot costs 3 ore and 8 clay. + Each geode robot costs 3 ore and 12 obsidian. + +(Blueprints have been line-wrapped here for legibility. The robot factory's actual assortment of blueprints are provided one blueprint per line.) + +The elephants are starting to look hungry, so you shouldn't take too long; you need to figure out which blueprint would maximize the number of opened geodes after 24 minutes by figuring out which robots to build and when to build them. + +Using blueprint 1 in the example above, the largest number of geodes you could open in 24 minutes is 9. One way to achieve that is: + +== Minute 1 == +1 ore-collecting robot collects 1 ore; you now have 1 ore. + +== Minute 2 == +1 ore-collecting robot collects 1 ore; you now have 2 ore. + +== Minute 3 == +Spend 2 ore to start building a clay-collecting robot. +1 ore-collecting robot collects 1 ore; you now have 1 ore. +The new clay-collecting robot is ready; you now have 1 of them. + +== Minute 4 == +1 ore-collecting robot collects 1 ore; you now have 2 ore. +1 clay-collecting robot collects 1 clay; you now have 1 clay. + +== Minute 5 == +Spend 2 ore to start building a clay-collecting robot. +1 ore-collecting robot collects 1 ore; you now have 1 ore. +1 clay-collecting robot collects 1 clay; you now have 2 clay. +The new clay-collecting robot is ready; you now have 2 of them. + +== Minute 6 == +1 ore-collecting robot collects 1 ore; you now have 2 ore. +2 clay-collecting robots collect 2 clay; you now have 4 clay. + +== Minute 7 == +Spend 2 ore to start building a clay-collecting robot. +1 ore-collecting robot collects 1 ore; you now have 1 ore. +2 clay-collecting robots collect 2 clay; you now have 6 clay. +The new clay-collecting robot is ready; you now have 3 of them. + +== Minute 8 == +1 ore-collecting robot collects 1 ore; you now have 2 ore. +3 clay-collecting robots collect 3 clay; you now have 9 clay. + +== Minute 9 == +1 ore-collecting robot collects 1 ore; you now have 3 ore. +3 clay-collecting robots collect 3 clay; you now have 12 clay. + +== Minute 10 == +1 ore-collecting robot collects 1 ore; you now have 4 ore. +3 clay-collecting robots collect 3 clay; you now have 15 clay. + +== Minute 11 == +Spend 3 ore and 14 clay to start building an obsidian-collecting robot. +1 ore-collecting robot collects 1 ore; you now have 2 ore. +3 clay-collecting robots collect 3 clay; you now have 4 clay. +The new obsidian-collecting robot is ready; you now have 1 of them. + +== Minute 12 == +Spend 2 ore to start building a clay-collecting robot. +1 ore-collecting robot collects 1 ore; you now have 1 ore. +3 clay-collecting robots collect 3 clay; you now have 7 clay. +1 obsidian-collecting robot collects 1 obsidian; you now have 1 obsidian. +The new clay-collecting robot is ready; you now have 4 of them. + +== Minute 13 == +1 ore-collecting robot collects 1 ore; you now have 2 ore. +4 clay-collecting robots collect 4 clay; you now have 11 clay. +1 obsidian-collecting robot collects 1 obsidian; you now have 2 obsidian. + +== Minute 14 == +1 ore-collecting robot collects 1 ore; you now have 3 ore. +4 clay-collecting robots collect 4 clay; you now have 15 clay. +1 obsidian-collecting robot collects 1 obsidian; you now have 3 obsidian. + +== Minute 15 == +Spend 3 ore and 14 clay to start building an obsidian-collecting robot. +1 ore-collecting robot collects 1 ore; you now have 1 ore. +4 clay-collecting robots collect 4 clay; you now have 5 clay. +1 obsidian-collecting robot collects 1 obsidian; you now have 4 obsidian. +The new obsidian-collecting robot is ready; you now have 2 of them. + +== Minute 16 == +1 ore-collecting robot collects 1 ore; you now have 2 ore. +4 clay-collecting robots collect 4 clay; you now have 9 clay. +2 obsidian-collecting robots collect 2 obsidian; you now have 6 obsidian. + +== Minute 17 == +1 ore-collecting robot collects 1 ore; you now have 3 ore. +4 clay-collecting robots collect 4 clay; you now have 13 clay. +2 obsidian-collecting robots collect 2 obsidian; you now have 8 obsidian. + +== Minute 18 == +Spend 2 ore and 7 obsidian to start building a geode-cracking robot. +1 ore-collecting robot collects 1 ore; you now have 2 ore. +4 clay-collecting robots collect 4 clay; you now have 17 clay. +2 obsidian-collecting robots collect 2 obsidian; you now have 3 obsidian. +The new geode-cracking robot is ready; you now have 1 of them. + +== Minute 19 == +1 ore-collecting robot collects 1 ore; you now have 3 ore. +4 clay-collecting robots collect 4 clay; you now have 21 clay. +2 obsidian-collecting robots collect 2 obsidian; you now have 5 obsidian. +1 geode-cracking robot cracks 1 geode; you now have 1 open geode. + +== Minute 20 == +1 ore-collecting robot collects 1 ore; you now have 4 ore. +4 clay-collecting robots collect 4 clay; you now have 25 clay. +2 obsidian-collecting robots collect 2 obsidian; you now have 7 obsidian. +1 geode-cracking robot cracks 1 geode; you now have 2 open geodes. + +== Minute 21 == +Spend 2 ore and 7 obsidian to start building a geode-cracking robot. +1 ore-collecting robot collects 1 ore; you now have 3 ore. +4 clay-collecting robots collect 4 clay; you now have 29 clay. +2 obsidian-collecting robots collect 2 obsidian; you now have 2 obsidian. +1 geode-cracking robot cracks 1 geode; you now have 3 open geodes. +The new geode-cracking robot is ready; you now have 2 of them. + +== Minute 22 == +1 ore-collecting robot collects 1 ore; you now have 4 ore. +4 clay-collecting robots collect 4 clay; you now have 33 clay. +2 obsidian-collecting robots collect 2 obsidian; you now have 4 obsidian. +2 geode-cracking robots crack 2 geodes; you now have 5 open geodes. + +== Minute 23 == +1 ore-collecting robot collects 1 ore; you now have 5 ore. +4 clay-collecting robots collect 4 clay; you now have 37 clay. +2 obsidian-collecting robots collect 2 obsidian; you now have 6 obsidian. +2 geode-cracking robots crack 2 geodes; you now have 7 open geodes. + +== Minute 24 == +1 ore-collecting robot collects 1 ore; you now have 6 ore. +4 clay-collecting robots collect 4 clay; you now have 41 clay. +2 obsidian-collecting robots collect 2 obsidian; you now have 8 obsidian. +2 geode-cracking robots crack 2 geodes; you now have 9 open geodes. + +However, by using blueprint 2 in the example above, you could do even better: the largest number of geodes you could open in 24 minutes is 12. + +Determine the quality level of each blueprint by multiplying that blueprint's ID number with the largest number of geodes that can be opened in 24 minutes using that blueprint. In this example, the first blueprint has ID 1 and can open 9 geodes, so its quality level is 9. The second blueprint has ID 2 and can open 12 geodes, so its quality level is 24. Finally, if you add up the quality levels of all of the blueprints in the list, you get 33. + +Determine the quality level of each blueprint using the largest number of geodes it could produce in 24 minutes. What do you get if you add up the quality level of all of the blueprints in your list? diff --git a/2022/Day19CSharp/puzzle-input.txt b/2022/Day19CSharp/puzzle-input.txt new file mode 100644 index 0000000..8d20f21 --- /dev/null +++ b/2022/Day19CSharp/puzzle-input.txt @@ -0,0 +1,30 @@ +Blueprint 1: Each ore robot costs 4 ore. Each clay robot costs 3 ore. Each obsidian robot costs 2 ore and 14 clay. Each geode robot costs 4 ore and 11 obsidian. +Blueprint 2: Each ore robot costs 3 ore. Each clay robot costs 3 ore. Each obsidian robot costs 3 ore and 20 clay. Each geode robot costs 2 ore and 12 obsidian. +Blueprint 3: Each ore robot costs 4 ore. Each clay robot costs 4 ore. Each obsidian robot costs 3 ore and 20 clay. Each geode robot costs 2 ore and 10 obsidian. +Blueprint 4: Each ore robot costs 4 ore. Each clay robot costs 3 ore. Each obsidian robot costs 4 ore and 16 clay. Each geode robot costs 2 ore and 15 obsidian. +Blueprint 5: Each ore robot costs 4 ore. Each clay robot costs 4 ore. Each obsidian robot costs 3 ore and 7 clay. Each geode robot costs 4 ore and 20 obsidian. +Blueprint 6: Each ore robot costs 2 ore. Each clay robot costs 4 ore. Each obsidian robot costs 4 ore and 19 clay. Each geode robot costs 2 ore and 18 obsidian. +Blueprint 7: Each ore robot costs 2 ore. Each clay robot costs 3 ore. Each obsidian robot costs 2 ore and 14 clay. Each geode robot costs 3 ore and 20 obsidian. +Blueprint 8: Each ore robot costs 2 ore. Each clay robot costs 4 ore. Each obsidian robot costs 4 ore and 16 clay. Each geode robot costs 4 ore and 17 obsidian. +Blueprint 9: Each ore robot costs 4 ore. Each clay robot costs 3 ore. Each obsidian robot costs 3 ore and 11 clay. Each geode robot costs 4 ore and 7 obsidian. +Blueprint 10: Each ore robot costs 4 ore. Each clay robot costs 3 ore. Each obsidian robot costs 2 ore and 17 clay. Each geode robot costs 3 ore and 16 obsidian. +Blueprint 11: Each ore robot costs 2 ore. Each clay robot costs 4 ore. Each obsidian robot costs 3 ore and 19 clay. Each geode robot costs 4 ore and 12 obsidian. +Blueprint 12: Each ore robot costs 3 ore. Each clay robot costs 3 ore. Each obsidian robot costs 2 ore and 16 clay. Each geode robot costs 2 ore and 18 obsidian. +Blueprint 13: Each ore robot costs 2 ore. Each clay robot costs 3 ore. Each obsidian robot costs 3 ore and 13 clay. Each geode robot costs 2 ore and 20 obsidian. +Blueprint 14: Each ore robot costs 3 ore. Each clay robot costs 4 ore. Each obsidian robot costs 3 ore and 16 clay. Each geode robot costs 3 ore and 14 obsidian. +Blueprint 15: Each ore robot costs 4 ore. Each clay robot costs 4 ore. Each obsidian robot costs 4 ore and 17 clay. Each geode robot costs 4 ore and 16 obsidian. +Blueprint 16: Each ore robot costs 4 ore. Each clay robot costs 4 ore. Each obsidian robot costs 4 ore and 8 clay. Each geode robot costs 3 ore and 19 obsidian. +Blueprint 17: Each ore robot costs 3 ore. Each clay robot costs 3 ore. Each obsidian robot costs 3 ore and 19 clay. Each geode robot costs 3 ore and 19 obsidian. +Blueprint 18: Each ore robot costs 3 ore. Each clay robot costs 3 ore. Each obsidian robot costs 3 ore and 11 clay. Each geode robot costs 2 ore and 8 obsidian. +Blueprint 19: Each ore robot costs 4 ore. Each clay robot costs 4 ore. Each obsidian robot costs 2 ore and 7 clay. Each geode robot costs 3 ore and 10 obsidian. +Blueprint 20: Each ore robot costs 3 ore. Each clay robot costs 4 ore. Each obsidian robot costs 4 ore and 18 clay. Each geode robot costs 4 ore and 12 obsidian. +Blueprint 21: Each ore robot costs 3 ore. Each clay robot costs 3 ore. Each obsidian robot costs 3 ore and 19 clay. Each geode robot costs 3 ore and 17 obsidian. +Blueprint 22: Each ore robot costs 4 ore. Each clay robot costs 4 ore. Each obsidian robot costs 4 ore and 20 clay. Each geode robot costs 2 ore and 12 obsidian. +Blueprint 23: Each ore robot costs 4 ore. Each clay robot costs 3 ore. Each obsidian robot costs 3 ore and 7 clay. Each geode robot costs 3 ore and 9 obsidian. +Blueprint 24: Each ore robot costs 2 ore. Each clay robot costs 2 ore. Each obsidian robot costs 2 ore and 17 clay. Each geode robot costs 2 ore and 10 obsidian. +Blueprint 25: Each ore robot costs 4 ore. Each clay robot costs 3 ore. Each obsidian robot costs 2 ore and 15 clay. Each geode robot costs 2 ore and 8 obsidian. +Blueprint 26: Each ore robot costs 4 ore. Each clay robot costs 4 ore. Each obsidian robot costs 2 ore and 14 clay. Each geode robot costs 3 ore and 17 obsidian. +Blueprint 27: Each ore robot costs 3 ore. Each clay robot costs 4 ore. Each obsidian robot costs 3 ore and 19 clay. Each geode robot costs 3 ore and 8 obsidian. +Blueprint 28: Each ore robot costs 3 ore. Each clay robot costs 3 ore. Each obsidian robot costs 3 ore and 8 clay. Each geode robot costs 2 ore and 12 obsidian. +Blueprint 29: Each ore robot costs 4 ore. Each clay robot costs 3 ore. Each obsidian robot costs 2 ore and 19 clay. Each geode robot costs 3 ore and 13 obsidian. +Blueprint 30: Each ore robot costs 3 ore. Each clay robot costs 4 ore. Each obsidian robot costs 3 ore and 6 clay. Each geode robot costs 4 ore and 11 obsidian. diff --git a/2022/Day20CSharp/Advent2022_Day20.cs b/2022/Day20CSharp/Advent2022_Day20.cs new file mode 100644 index 0000000..5c29c17 --- /dev/null +++ b/2022/Day20CSharp/Advent2022_Day20.cs @@ -0,0 +1,176 @@ +// See https://aka.ms/new-console-template for more information + +using System.Numerics; + +var exampleData = new ProblemData("example-input.txt"); +Console.WriteLine("Grove Coordinates, Example: " + exampleData.GetGroveCoordinates(1,1)); + +var puzzleData = new ProblemData("puzzle-input.txt"); +Console.WriteLine("Grove Coordinates, Puzzle: " + puzzleData.GetGroveCoordinates(1,1)); + +Console.WriteLine("Grove Coordinates, Example Decrypted: " + exampleData.GetGroveCoordinates(811589153, 10)); +Console.WriteLine("Grove Coordinates, Puzzle Decrypted: " + puzzleData.GetGroveCoordinates(811589153, 10)); + + +class Item +{ + public Item(BigInteger value) + { + Value = value; + } + + public BigInteger Value { get; set; } + + public override string ToString() + { + return Value.ToString(); + } +} + +class CircularList +{ + public List Items; + + public CircularList() + { + Items = new List(); + } + + public void Add(Item item) + { + Items.Add(item); + } + + public void Move(int oldIndex, int newIndex) + { + if (oldIndex == newIndex) return; + + var temp = Items[oldIndex]; + + if (newIndex == 0) + { + Items.RemoveAt(oldIndex); + Items.Add(temp); + } + else if (newIndex == Items.Count - 1) + { + Items.RemoveAt(oldIndex); + Items.Insert(0, temp); + } + else + { + Items.RemoveAt(oldIndex); + Items.Insert(newIndex, temp); + } + } + + public static void PrintList(CircularList list) + { + for (int ci = 0; ci < list.Items.Count; ci++) + { + if (ci != 0) Console.Write(", "); + Console.Write(list.Items[ci]); + } + Console.WriteLine(); + } + + public static CircularList GetMixedList(CircularList source, BigInteger decryptionKey, int mixes) + { + var newList = new CircularList(); + + for (int i = 0; i < source.Items.Count; i++) + { + source.Items[i].Value *= decryptionKey; + + newList.Items.Add(source.Items[i]); + } + + for (int mixNum = 0; mixNum < mixes; mixNum++) + { + if (DebugPrint) Console.WriteLine("Starting mix {0} of {1}", mixNum + 1, mixes); + + for (int i = 0; i < source.Items.Count; i++) + { + if (DebugPrint) Console.WriteLine("|- Mixing item {0} of {1}", i + 1, source.Items.Count); + + var item = source.Items[i]; + + int currentIndex = newList.Items.IndexOf(item); + int direction = item.Value > 0 ? 1 : -1; + int newIndex = currentIndex; + + BigInteger max = BigInteger.Abs(item.Value) % (source.Items.Count-1); + + for (BigInteger j = 0; j < max; j++) + { + if (direction == 1 && newIndex == source.Items.Count - 1) newIndex = 1; + else if (direction == -1 && newIndex == 0) newIndex = source.Items.Count - 2; + else newIndex += direction; + } + + newList.Move(currentIndex, newIndex); + } + } + + return newList; + } + + public static bool DebugPrint { get; set; } = false; +} + +class ProblemData +{ + private CircularList Numbers { get; set; } + + public CircularList GetMixedList(BigInteger decryptionKey, int mixes) + { + + return CircularList.GetMixedList(Numbers, decryptionKey, mixes); + } + + public BigInteger GetGroveCoordinates(BigInteger decryptionKey, int mixes) + { + BigInteger sum = 0; + + var list = GetMixedList(decryptionKey, mixes); + + int index = list.Items.FindIndex(x => x.Value == 0); + + for (int i = 0; i <= 3000; i++) + { + if (i % 1000 == 0) + { + sum += list.Items[index].Value; + } + + if (index == list.Items.Count-1) + { + index = 0; + } + else + { + index++; + } + } + + return sum; + } + + public ProblemData(string filename) + { + Numbers = new CircularList(); + + using (StreamReader reader = System.IO.File.OpenText(filename)) + { + while (!reader.EndOfStream) + { + var line = reader.ReadLine(); + if (line == null) throw new InvalidDataException(); + + var value = Int32.Parse(line); + + Numbers.Add(new Item(value)); + } + } + } +} \ No newline at end of file diff --git a/2022/Day20CSharp/Day20CSharp.csproj b/2022/Day20CSharp/Day20CSharp.csproj new file mode 100644 index 0000000..d439800 --- /dev/null +++ b/2022/Day20CSharp/Day20CSharp.csproj @@ -0,0 +1,10 @@ + + + + Exe + net7.0 + enable + enable + + + diff --git a/2022/Day20CSharp/Properties/launchSettings.json b/2022/Day20CSharp/Properties/launchSettings.json new file mode 100644 index 0000000..849e536 --- /dev/null +++ b/2022/Day20CSharp/Properties/launchSettings.json @@ -0,0 +1,8 @@ +{ + "profiles": { + "Day20CSharp": { + "commandName": "Project", + "workingDirectory": "C:\\dev\\DevSandbox\\AdventOfCode\\2022\\Day20CSharp" + } + } +} \ No newline at end of file diff --git a/2022/Day20CSharp/example-input.txt b/2022/Day20CSharp/example-input.txt new file mode 100644 index 0000000..d206b01 --- /dev/null +++ b/2022/Day20CSharp/example-input.txt @@ -0,0 +1,7 @@ +1 +2 +-3 +3 +-2 +0 +4 \ No newline at end of file diff --git a/2022/Day20CSharp/problem.txt b/2022/Day20CSharp/problem.txt new file mode 100644 index 0000000..2e98419 --- /dev/null +++ b/2022/Day20CSharp/problem.txt @@ -0,0 +1,107 @@ +--- Day 20: Grove Positioning System --- + +It's finally time to meet back up with the Elves. When you try to contact them, however, you get no reply. Perhaps you're out of range? + +You know they're headed to the grove where the star fruit grows, so if you can figure out where that is, you should be able to meet back up with them. + +Fortunately, your handheld device has a file (your puzzle input) that contains the grove's coordinates! Unfortunately, the file is encrypted - just in case the device were to fall into the wrong hands. + +Maybe you can decrypt it? + +When you were still back at the camp, you overheard some Elves talking about coordinate file encryption. The main operation involved in decrypting the file is called mixing. + +The encrypted file is a list of numbers. To mix the file, move each number forward or backward in the file a number of positions equal to the value of the number being moved. The list is circular, so moving a number off one end of the list wraps back around to the other end as if the ends were connected. + +For example, to move the 1 in a sequence like 4, 5, 6, 1, 7, 8, 9, the 1 moves one position forward: 4, 5, 6, 7, 1, 8, 9. To move the -2 in a sequence like 4, -2, 5, 6, 7, 8, 9, the -2 moves two positions backward, wrapping around: 4, 5, 6, 7, 8, -2, 9. + +The numbers should be moved in the order they originally appear in the encrypted file. Numbers moving around during the mixing process do not change the order in which the numbers are moved. + +Consider this encrypted file: + +1 +2 +-3 +3 +-2 +0 +4 + +Mixing this file proceeds as follows: + +Initial arrangement: +1, 2, -3, 3, -2, 0, 4 + +1 moves between 2 and -3: +2, 1, -3, 3, -2, 0, 4 + +2 moves between -3 and 3: +1, -3, 2, 3, -2, 0, 4 + +-3 moves between -2 and 0: +1, 2, 3, -2, -3, 0, 4 + +3 moves between 0 and 4: +1, 2, -2, -3, 0, 3, 4 + +-2 moves between 4 and 1: +1, 2, -3, 0, 3, 4, -2 + +0 does not move: +1, 2, -3, 0, 3, 4, -2 + +4 moves between -3 and 0: +1, 2, -3, 4, 0, 3, -2 + +Then, the grove coordinates can be found by looking at the 1000th, 2000th, and 3000th numbers after the value 0, wrapping around the list as necessary. In the above example, the 1000th number after 0 is 4, the 2000th is -3, and the 3000th is 2; adding these together produces 3. + +Mix your encrypted file exactly once. What is the sum of the three numbers that form the grove coordinates? + +Your puzzle answer was 13289. + +The first half of this puzzle is complete! It provides one gold star: * +--- Part Two --- + +The grove coordinate values seem nonsensical. While you ponder the mysteries of Elf encryption, you suddenly remember the rest of the decryption routine you overheard back at camp. + +First, you need to apply the decryption key, 811589153. Multiply each number by the decryption key before you begin; this will produce the actual list of numbers to mix. + +Second, you need to mix the list of numbers ten times. The order in which the numbers are mixed does not change during mixing; the numbers are still moved in the order they appeared in the original, pre-mixed list. (So, if -3 appears fourth in the original list of numbers to mix, -3 will be the fourth number to move during each round of mixing.) + +Using the same example as above: + +Initial arrangement: +811589153, 1623178306, -2434767459, 2434767459, -1623178306, 0, 3246356612 + +After 1 round of mixing: +0, -2434767459, 3246356612, -1623178306, 2434767459, 1623178306, 811589153 + +After 2 rounds of mixing: +0, 2434767459, 1623178306, 3246356612, -2434767459, -1623178306, 811589153 + +After 3 rounds of mixing: +0, 811589153, 2434767459, 3246356612, 1623178306, -1623178306, -2434767459 + +After 4 rounds of mixing: +0, 1623178306, -2434767459, 811589153, 2434767459, 3246356612, -1623178306 + +After 5 rounds of mixing: +0, 811589153, -1623178306, 1623178306, -2434767459, 3246356612, 2434767459 + +After 6 rounds of mixing: +0, 811589153, -1623178306, 3246356612, -2434767459, 1623178306, 2434767459 + +After 7 rounds of mixing: +0, -2434767459, 2434767459, 1623178306, -1623178306, 811589153, 3246356612 + +After 8 rounds of mixing: +0, 1623178306, 3246356612, 811589153, -2434767459, 2434767459, -1623178306 + +After 9 rounds of mixing: +0, 811589153, 1623178306, -2434767459, 3246356612, 2434767459, -1623178306 + +After 10 rounds of mixing: +0, -2434767459, 1623178306, 3246356612, -1623178306, 2434767459, 811589153 + +The grove coordinates can still be found in the same way. Here, the 1000th number after 0 is 811589153, the 2000th is 2434767459, and the 3000th is -1623178306; adding these together produces 1623178306. + +Apply the decryption key and mix your encrypted file ten times. What is the sum of the three numbers that form the grove coordinates? diff --git a/2022/Day20CSharp/puzzle-input.txt b/2022/Day20CSharp/puzzle-input.txt new file mode 100644 index 0000000..565bef0 --- /dev/null +++ b/2022/Day20CSharp/puzzle-input.txt @@ -0,0 +1,5000 @@ +2142 +-9212 +-6282 +2720 +-370 +-4038 +-5780 +-1040 +-4553 +1148 +7374 +-6777 +7868 +1324 +935 +-6945 +-6605 +-5036 +-2684 +-2075 +-6520 +-1399 +5244 +-8095 +7467 +812 +1592 +-9760 +-2923 +4770 +1058 +4822 +1908 +9067 +4647 +6265 +8807 +5191 +-7777 +-1149 +-9019 +7072 +3415 +3744 +6116 +7842 +8261 +6159 +-6838 +-5350 +-1934 +-5418 +-5891 +6463 +-291 +6955 +2662 +-7593 +5776 +-8835 +-3927 +-8657 +-4881 +8250 +1100 +-7596 +9431 +4776 +2630 +-4746 +955 +936 +-3684 +-2629 +9450 +-2916 +-6582 +-237 +-5744 +7678 +-4977 +-375 +-8499 +7842 +6883 +6899 +7157 +-8525 +-8697 +8163 +-5728 +3867 +-8013 +-3582 +8146 +-278 +5820 +-3629 +6830 +-2231 +3225 +9581 +9269 +-7154 +-8694 +-5766 +3016 +128 +-8042 +3151 +4654 +8305 +6547 +-6062 +3222 +-2514 +-8386 +-77 +6139 +2667 +-3764 +6852 +785 +-108 +-1398 +-1518 +8370 +2098 +-6720 +-9030 +-238 +2220 +-1129 +2033 +-2579 +-833 +6615 +-3048 +6747 +8692 +-1500 +9142 +-7286 +-7270 +-6748 +5750 +6999 +7778 +-3844 +-743 +1954 +8587 +8126 +7269 +-2568 +3877 +2821 +6867 +2438 +4731 +-4349 +6057 +-4908 +1748 +1604 +4033 +-5222 +4661 +-5383 +8145 +8943 +6664 +2555 +-1112 +2309 +7610 +-3047 +-7435 +-672 +2481 +9344 +3584 +3381 +-8721 +6192 +-2171 +2360 +-9816 +4511 +-1342 +-3462 +-5358 +-3019 +5460 +1439 +7041 +-3010 +-667 +9435 +-3285 +2510 +-8205 +-6302 +3805 +1993 +3091 +-1966 +2545 +-5276 +-8458 +-9303 +-2886 +-7047 +985 +-9147 +-9453 +-3285 +8664 +-3878 +4433 +-1134 +5406 +-9102 +1041 +-6222 +1852 +2222 +2094 +8410 +4710 +-9978 +-3034 +9406 +4436 +1214 +9195 +-4823 +676 +1547 +-1354 +4510 +-2431 +3117 +3444 +1366 +-8733 +-4253 +7410 +-1527 +9578 +1177 +2846 +-8940 +9329 +9809 +1564 +8713 +6235 +-1380 +-8006 +2592 +8474 +651 +-6077 +6626 +-3951 +4711 +-8863 +3755 +6829 +-3097 +6821 +9051 +6348 +-3274 +-159 +4695 +3059 +-7035 +-6111 +-9112 +8032 +-1553 +273 +7794 +-2299 +1059 +-4652 +-1147 +5134 +4694 +-9555 +-7772 +2908 +-8682 +-8176 +-4685 +8628 +770 +7936 +2401 +8485 +760 +5447 +-4654 +3441 +-9749 +8609 +3852 +-7873 +7510 +-2323 +4980 +-3635 +-5157 +-6511 +-4796 +4226 +-2791 +6498 +-4760 +3529 +4821 +3696 +7510 +7911 +705 +-7811 +-3682 +3275 +5817 +2395 +-4045 +121 +-8507 +8102 +-5114 +-4569 +1392 +3670 +-1997 +9582 +-3494 +-730 +4204 +-825 +-2426 +-3773 +-3386 +567 +4901 +7048 +1670 +-5431 +-3801 +3933 +-9306 +-7288 +-3771 +20 +-2169 +-2742 +9199 +636 +8451 +7972 +-4033 +9184 +-7649 +6987 +-4315 +3210 +376 +9147 +-6732 +-8526 +8688 +-2283 +2352 +2178 +2698 +8667 +8688 +3030 +-389 +-5405 +-6111 +-7726 +-5147 +-1171 +-7977 +2331 +-8108 +-630 +-5114 +-4955 +-3420 +-9967 +2857 +-6572 +8334 +-7101 +-1047 +-4769 +-1122 +-1850 +2952 +8358 +-3093 +3225 +7383 +6102 +-5504 +9790 +8261 +1143 +-7365 +-7035 +-1538 +-3653 +-3805 +-9815 +-323 +8460 +-9205 +3709 +-829 +1807 +9740 +-4440 +3926 +-6210 +-3059 +-4346 +7297 +-2380 +-9653 +-4278 +861 +-6027 +-7110 +4109 +-435 +9948 +-720 +2948 +2732 +-7522 +-7785 +4927 +8644 +-1687 +-260 +-9244 +-340 +-8261 +2322 +-2330 +2404 +-3559 +1305 +-6230 +-6112 +-1410 +-2380 +9982 +8198 +2239 +-2341 +-7771 +5744 +7728 +7546 +651 +-4863 +-8853 +9535 +2232 +2484 +1499 +5582 +-62 +-8793 +-2851 +-9851 +9114 +-3960 +-1675 +6591 +9629 +5626 +-8653 +9307 +-822 +-7311 +7141 +3709 +1807 +4110 +2401 +5761 +-573 +-5874 +-6174 +7732 +-9183 +1478 +9943 +7151 +1437 +7007 +-6886 +-6953 +-1164 +6402 +-4487 +7821 +9160 +9852 +3484 +2781 +-7973 +6795 +4017 +2955 +-3007 +5887 +6899 +-1103 +2697 +-2405 +-9250 +4976 +4460 +-1839 +-1380 +-9608 +-3117 +-5088 +-1441 +-9496 +1558 +-3807 +-5201 +-2247 +2496 +9755 +-5390 +-177 +-1469 +-3034 +1177 +-6997 +-3399 +8753 +-8347 +8374 +8300 +-2700 +-9352 +-8220 +-807 +-892 +9439 +6770 +-5304 +8066 +994 +6273 +-4466 +8861 +4706 +3208 +228 +4836 +-4118 +-6521 +-491 +7486 +-9689 +9566 +2911 +-7364 +-9502 +-7869 +-2048 +-1952 +-7797 +7591 +5485 +-1317 +-5218 +-8949 +-9630 +-579 +7896 +9718 +-2495 +-6210 +4155 +-7820 +2199 +-6742 +-4707 +-8755 +-8798 +-3800 +-7947 +6865 +1918 +2477 +-4758 +4265 +-1135 +-2186 +5986 +-6402 +3794 +-7698 +-7255 +-2673 +6448 +5083 +-8507 +-2497 +5201 +-7721 +-9961 +3309 +3314 +6377 +-2725 +9875 +7161 +-3428 +7340 +-2518 +8567 +-16 +-8393 +-33 +-4440 +-5248 +-1873 +-3337 +-9767 +-1822 +898 +-3889 +482 +-7168 +171 +-8232 +1783 +-2354 +-7049 +5081 +5173 +-3473 +-6218 +-4817 +-3137 +-7180 +8689 +-5109 +-3609 +-6520 +-1047 +-8657 +-9933 +-3853 +-3907 +-8933 +2916 +-7190 +-1306 +-5253 +8340 +1654 +119 +-337 +5970 +-4095 +-3255 +7899 +-623 +1063 +1354 +-9498 +630 +2789 +2164 +985 +-882 +-5247 +3623 +-9253 +-2644 +-6464 +145 +-7665 +-4229 +3436 +-5752 +2911 +9744 +3069 +-5669 +-6373 +-9048 +-7861 +-7368 +410 +6127 +-5352 +-2400 +4068 +9809 +-4418 +4297 +7458 +5145 +968 +-4942 +1741 +-9494 +3729 +-1322 +4538 +936 +-4845 +8513 +4442 +7421 +-8040 +-3048 +-9019 +5083 +-2714 +927 +-8582 +-6433 +6918 +8518 +5063 +1389 +-654 +-3961 +-9300 +9581 +-4933 +-4347 +-4482 +-5657 +9601 +-8063 +-6551 +-5201 +6596 +-3533 +9041 +-6190 +4553 +-8644 +-1247 +-7843 +2236 +8667 +1324 +4836 +9477 +-1618 +-4338 +3143 +2276 +-9269 +5083 +-3031 +-6318 +-5989 +9202 +5319 +935 +5422 +8880 +-8339 +7014 +3422 +-1353 +4414 +-6755 +-6254 +-1346 +-1283 +3999 +8745 +-5816 +4280 +-769 +-8642 +8052 +-7536 +6734 +2807 +6622 +4947 +-8217 +-4556 +-1766 +3302 +-9548 +1090 +-7851 +9534 +1348 +5679 +1462 +8684 +1556 +8583 +2276 +3344 +7815 +-7198 +129 +8906 +-3851 +3797 +1969 +4713 +910 +-9969 +1689 +-6318 +-6025 +2818 +-1655 +567 +-2917 +-1521 +-2704 +2302 +-2714 +2987 +-7409 +-8912 +520 +8728 +-3418 +4756 +2057 +-9848 +163 +-8207 +-4727 +3214 +8575 +-2675 +-3736 +8116 +-7083 +-9630 +903 +8444 +1866 +9416 +-9249 +4614 +-3752 +-4486 +8871 +-8299 +2348 +-3174 +-5263 +-1556 +246 +-4195 +544 +81 +6411 +6036 +4327 +-878 +8593 +-1457 +-878 +2633 +9800 +-3162 +-3880 +-869 +8048 +8438 +-984 +-9964 +3378 +-6039 +1204 +1263 +785 +-1363 +-1283 +3619 +-7817 +-1108 +5848 +-5201 +1978 +-511 +5485 +1368 +4413 +2697 +-3949 +9789 +-1806 +5822 +-381 +4836 +-1766 +502 +6268 +-9779 +-3735 +4207 +-5467 +-2913 +-7141 +3381 +2116 +-2923 +513 +-1902 +4065 +4116 +124 +3151 +3410 +-8856 +-6389 +1421 +-4231 +-7467 +2003 +7664 +-7066 +6872 +6401 +-229 +1259 +-868 +7100 +-3535 +9025 +-8700 +-389 +-885 +2253 +-330 +4110 +4245 +7780 +-7376 +9985 +-3724 +-5904 +-3735 +-2560 +2178 +-5406 +985 +9053 +1571 +-572 +-6608 +7065 +802 +-4621 +-4229 +-4959 +2176 +-6928 +7985 +-632 +-9026 +7743 +-8714 +-9573 +-2784 +-365 +7141 +-8971 +-9259 +9279 +1386 +9703 +-7141 +3923 +-9172 +-448 +6160 +-2417 +-1001 +5561 +-2640 +-4273 +1947 +-6237 +8122 +7183 +4741 +-291 +-9214 +-557 +-3097 +-3050 +2322 +2955 +9335 +3052 +1421 +7445 +-3448 +-5608 +5631 +7186 +-2227 +-5169 +8006 +-9565 +-4114 +1612 +-1103 +-8416 +9625 +-2422 +-8536 +6336 +9079 +4941 +6158 +-9457 +2033 +-2532 +1156 +739 +-7246 +3522 +9390 +8842 +-9026 +-7729 +-7137 +-7357 +9028 +5921 +-7019 +-6995 +-5040 +-1364 +9800 +8483 +-1657 +4517 +3179 +-8682 +-3960 +2788 +603 +6648 +3428 +3687 +-4945 +2373 +2956 +5159 +-6484 +910 +9830 +-2038 +-2367 +-9329 +-9447 +-8959 +-9672 +-5343 +4297 +-660 +7042 +208 +5326 +7183 +6455 +7335 +4892 +-6557 +-8220 +-7596 +-4298 +9836 +-6496 +9639 +-2793 +-4952 +-1474 +-5543 +-6732 +-6564 +7520 +1485 +7537 +-7572 +4758 +8807 +662 +-8590 +-3048 +3574 +-2901 +9729 +5357 +-8519 +8871 +-3975 +2633 +-2550 +-4844 +2647 +-8051 +2448 +8321 +-8520 +5793 +9169 +-6631 +-7066 +1318 +-8458 +6 +5993 +-7061 +-1815 +6125 +-3679 +-3482 +-9905 +-8881 +-4793 +-8230 +4188 +-9503 +1819 +-3117 +117 +-1921 +3696 +7723 +-5176 +1921 +6255 +-9926 +-7369 +-8353 +1542 +-965 +5926 +2118 +9078 +1253 +-7432 +6297 +1724 +8208 +-5673 +-4847 +1994 +806 +7137 +6318 +-2620 +4327 +-7858 +9065 +8112 +-5622 +-2913 +-1100 +-5293 +1416 +1274 +7044 +974 +3989 +-7270 +-2190 +-3739 +2935 +-7250 +7108 +-6571 +6645 +890 +7334 +-5429 +9609 +-9550 +-3170 +-9295 +-6733 +6734 +7138 +7086 +-5293 +-2623 +-1309 +-481 +6516 +-5 +9938 +-1135 +8137 +6139 +-2918 +9489 +-6825 +1400 +-1554 +7467 +2465 +6934 +-9889 +5453 +5343 +-5522 +-4745 +6516 +-4398 +-2486 +4077 +-5210 +-7861 +1232 +1885 +9065 +7007 +-1098 +6177 +5544 +-8503 +5857 +-7584 +-5368 +2630 +-4328 +169 +-3363 +-6369 +-69 +6657 +-1921 +7253 +7401 +2570 +1870 +-4556 +1217 +-3591 +-3281 +2822 +3527 +-9048 +-266 +-7858 +-7024 +5712 +2857 +4629 +-3676 +4200 +9578 +-5065 +-8250 +-6267 +7818 +-1247 +493 +-2582 +-5735 +-2314 +8764 +-7822 +9523 +890 +-3800 +-2535 +-4669 +-567 +9943 +7267 +-5851 +-8910 +-8771 +-7089 +2395 +6374 +-8467 +-6385 +3581 +-1640 +8837 +-3471 +-4095 +-5919 +6159 +137 +-353 +-1040 +197 +-7421 +-4553 +-4845 +1903 +130 +1698 +7495 +8548 +-4367 +2699 +6588 +-6240 +6692 +-1118 +-7667 +9813 +-4325 +-329 +8228 +-3646 +9813 +5113 +-6756 +-7954 +4179 +-1594 +-8560 +-8665 +1116 +4188 +-7220 +7350 +-6621 +-9449 +6283 +-656 +3803 +4278 +-7250 +-2045 +-8846 +-3218 +5945 +5702 +-9978 +280 +-9599 +3531 +-6631 +-6170 +-7264 +8421 +-2545 +-2495 +-1889 +80 +7527 +137 +3846 +770 +8126 +6769 +493 +6777 +7901 +6162 +8431 +-9014 +-2132 +4814 +2750 +1043 +8558 +-3585 +-9269 +-3518 +474 +-3724 +-6917 +8946 +-9084 +-9752 +-7368 +-9420 +-906 +2687 +2661 +-4440 +2441 +1813 +2093 +-7208 +-6871 +-4701 +2974 +9153 +-5147 +895 +1940 +4324 +-5389 +-2415 +-4094 +514 +8586 +-744 +555 +-3155 +-3510 +-8394 +6061 +4862 +5449 +-8436 +-1715 +4038 +3244 +8796 +4103 +-7765 +-3827 +9849 +7492 +-2405 +7504 +4167 +-9464 +6374 +-7954 +-4328 +9155 +4116 +-6342 +1159 +-6847 +1592 +8808 +7072 +-6359 +-2089 +-2553 +785 +-2568 +-9604 +9426 +6963 +-2216 +8796 +-2370 +-9469 +-7917 +-2427 +-3420 +-4056 +7752 +-3170 +1478 +-730 +-6545 +4287 +-7941 +-6703 +-210 +-9606 +-9341 +4984 +-470 +520 +-2614 +7319 +3148 +2661 +-7748 +-3464 +1368 +3047 +8567 +-1259 +926 +6221 +-8190 +4584 +6172 +8485 +7697 +-9745 +935 +4520 +5551 +1816 +-9626 +-4418 +-208 +7421 +617 +-7444 +5947 +-8154 +-3837 +520 +-171 +-830 +3472 +4238 +-6915 +6825 +5918 +-356 +-4340 +294 +8321 +-6705 +739 +8396 +-3265 +-4936 +7354 +6846 +8333 +9403 +-5959 +9582 +3088 +-5739 +496 +-8572 +-653 +-1613 +4617 +567 +-3121 +5701 +-3598 +3719 +5094 +1748 +955 +-2009 +-8830 +-5271 +-6067 +-4829 +128 +-8798 +-1283 +9307 +1155 +6998 +2220 +5002 +2564 +-1017 +7748 +6051 +-9385 +-8422 +3316 +-3944 +-1312 +-4445 +979 +-2218 +4179 +7899 +-990 +8875 +-7405 +-5536 +3091 +7225 +-882 +-3078 +-4573 +5921 +-4672 +5255 +4950 +-9965 +-6998 +7415 +-2121 +-2679 +-5876 +9286 +-3323 +-5355 +-4497 +9121 +9899 +4080 +1807 +-7731 +-7183 +-9900 +7081 +-2655 +-5710 +-7748 +-6232 +9786 +-6331 +-8288 +167 +-9889 +-2718 +-9078 +-2988 +9041 +-4878 +2208 +3744 +-1624 +-3471 +3930 +5024 +-5932 +1375 +3077 +427 +4411 +-2883 +7519 +-6284 +-6080 +-5589 +-1071 +-9825 +-5938 +-555 +-5282 +-98 +-3243 +5963 +9518 +-5202 +-4942 +-7200 +-340 +-9117 +-6265 +5125 +-7069 +3152 +1137 +629 +-5746 +4856 +-5719 +-5418 +4206 +5771 +7306 +5147 +4489 +-4500 +2956 +1852 +-8012 +189 +5764 +4446 +-9026 +5381 +7830 +-7324 +-7525 +-2792 +4316 +-8492 +6314 +-6237 +-2247 +5326 +1104 +-3853 +-4652 +-4531 +2826 +-2582 +-9873 +-7614 +4607 +2484 +6285 +8261 +2083 +6795 +6703 +8001 +8502 +4218 +1263 +-265 +-1164 +9046 +-8813 +-8265 +5822 +-4562 +-3244 +8014 +-2047 +-7278 +-6808 +837 +2797 +5366 +-6709 +6168 +6918 +-508 +-9623 +-2577 +-9767 +3731 +-9768 +9153 +-2861 +6221 +9937 +-1637 +6311 +-8217 +536 +1612 +4160 +6102 +1328 +-9612 +-7128 +3508 +-4032 +-5721 +-3576 +2105 +-1512 +731 +-6254 +6154 +8025 +2737 +4489 +9542 +9279 +-7572 +8450 +5631 +-2014 +-9783 +-672 +-8289 +-1899 +-1773 +1867 +5568 +-1809 +-9550 +-3914 +7300 +8112 +-9339 +-4558 +-2367 +7301 +-9608 +3132 +-9532 +4297 +-7792 +3129 +4415 +-8165 +-6655 +4607 +-8593 +-8439 +3439 +4213 +5171 +9678 +-9840 +7863 +-3749 +-652 +-8934 +-7584 +2465 +-9412 +-7151 +4543 +7090 +-8870 +8596 +6496 +-3907 +-270 +8115 +-273 +3132 +-7600 +-7073 +3496 +8004 +-7586 +3760 +9227 +8938 +-6766 +166 +-2536 +-9572 +7273 +-3682 +-6232 +1751 +2774 +-3071 +1748 +2093 +8505 +-9889 +-1485 +-8619 +6428 +6769 +-8378 +-8713 +-8556 +9938 +6696 +9040 +-6425 +1415 +-4780 +6926 +2146 +-5403 +6934 +4307 +4038 +-7201 +929 +-4095 +-108 +-945 +8854 +9698 +4027 +2864 +4522 +-8870 +4135 +7526 +-2711 +-3274 +5923 +1895 +2595 +4293 +472 +5060 +-4083 +-6936 +8460 +6306 +890 +1644 +-4229 +-2649 +-4049 +-5711 +9249 +2703 +-9013 +2777 +1964 +-5355 +-7240 +-2027 +4934 +7617 +6382 +4668 +3555 +5195 +-2783 +-4937 +-4291 +428 +-2038 +1738 +-2215 +-3184 +1318 +1511 +164 +-9026 +6047 +-2816 +-2089 +-2593 +5004 +6735 +5576 +-9579 +4489 +8137 +4455 +4172 +-2289 +-3238 +-3801 +-1309 +-4340 +5176 +-9630 +-4646 +1548 +9002 +7229 +3757 +-9097 +1771 +-5169 +-1541 +1318 +-7083 +2697 +-7090 +-7078 +-5090 +1497 +2283 +3118 +-5443 +2555 +-3749 +-766 +8728 +901 +4708 +-2717 +-1512 +9429 +-3732 +-808 +-5690 +8180 +4901 +839 +-3126 +9049 +1011 +-7105 +8167 +-5361 +921 +4446 +9788 +-7286 +-5391 +-1612 +-8644 +-3706 +7060 +6638 +1263 +5398 +4735 +-2537 +8102 +4265 +-5036 +2630 +-4083 +-9400 +2660 +-3103 +7274 +-5327 +-8217 +-7643 +5194 +-3326 +-9633 +9695 +-8190 +6871 +-668 +-5959 +-7207 +9028 +-2380 +-4328 +9933 +-3926 +3169 +2916 +-2355 +-9537 +-3769 +802 +4616 +2744 +910 +-4796 +-5028 +4517 +55 +4245 +-1538 +4218 +-6332 +-4195 +2316 +2721 +6053 +5119 +-3339 +-1873 +5937 +-4258 +-8653 +26 +7717 +-8165 +-5109 +-4505 +896 +7519 +-4164 +2223 +5664 +7553 +7778 +1054 +2756 +-6787 +2109 +6567 +-2386 +-9014 +6326 +302 +-1133 +-7517 +-3302 +7834 +-8334 +3857 +4109 +-2014 +-7324 +-1803 +-800 +-4494 +-7196 +-5636 +6227 +6756 +-2453 +-413 +-8144 +-8353 +-4226 +2309 +3189 +6413 +-2489 +5649 +-376 +992 +6657 +-1748 +-2090 +-4161 +7626 +-192 +3867 +4922 +2828 +-6420 +-3291 +7484 +4143 +-5516 +5095 +9160 +-7716 +-4298 +-8345 +2235 +-8971 +-4192 +16 +4382 +4858 +-6520 +-5363 +-115 +-9604 +-3494 +-9618 +3312 +-8435 +-7581 +6944 +-7220 +-6438 +-8553 +-747 +-2414 +5701 +-8144 +6583 +2510 +-2298 +-7368 +968 +7278 +662 +-5043 +-6382 +-9113 +3712 +-6605 +-456 +7677 +3687 +-1423 +8116 +9117 +4130 +5164 +-5355 +9153 +3628 +-2411 +8332 +-6893 +2988 +1856 +-3629 +-5858 +-5340 +-9230 +-7654 +7300 +7524 +2925 +2821 +-4624 +9117 +78 +2840 +8410 +2402 +2048 +-1960 +-2972 +5822 +5800 +-6265 +7038 +-1674 +-4088 +-5370 +9474 +-8100 +-8981 +-652 +-9564 +1852 +-3014 +-7327 +-3567 +-2655 +-9639 +-1291 +9281 +-8234 +-2443 +-4038 +-7271 +5863 +-6156 +-6365 +7577 +-6388 +4613 +-4795 +4297 +8013 +-1986 +-371 +-209 +7481 +-9127 +2630 +-4016 +9768 +2441 +-4283 +3624 +9581 +5076 +5220 +7967 +4384 +-3983 +-9306 +-2741 +923 +7496 +-354 +-8745 +8031 +-4603 +3331 +8685 +2580 +9625 +-4032 +-1312 +2585 +724 +-4855 +9796 +9233 +9184 +-7810 +8190 +-7283 +8827 +-3078 +1514 +289 +-6771 +1771 +3298 +4029 +47 +8639 +4746 +-2041 +3690 +5267 +-6267 +-4608 +679 +-4867 +-1906 +-8916 +5763 +8562 +-9101 +-5723 +-6536 +4778 +-8195 +9534 +2822 +-3904 +-5204 +-2261 +159 +4670 +-8013 +-9673 +2790 +-7268 +3132 +6222 +-3310 +6318 +8764 +-6084 +-7276 +-1017 +828 +4182 +8932 +-6997 +7697 +301 +-3162 +3415 +-1640 +4399 +7007 +7337 +6867 +-4937 +4172 +8133 +8128 +9144 +-9297 +2913 +273 +-8642 +7512 +-798 +8807 +1784 +7755 +-1655 +-4927 +-3204 +9043 +-3301 +-8714 +3732 +9298 +-2412 +9294 +7100 +-9608 +-9565 +-5478 +2587 +3415 +-3487 +3056 +-1611 +219 +8202 +-6556 +-231 +4607 +6322 +-3356 +6154 +5826 +852 +9342 +-131 +-5125 +-3799 +-650 +-5604 +-7309 +-6523 +8768 +2756 +-9667 +6099 +3109 +245 +97 +-90 +-8856 +-7306 +-4032 +5287 +2847 +8946 +-8136 +9723 +-1468 +-6973 +9286 +-5391 +4561 +4571 +7508 +-2577 +2779 +-2083 +-3951 +-7421 +2655 +-6499 +5478 +-3799 +-3641 +3742 +8380 +7333 +-6550 +-3682 +-8492 +4481 +-3015 +-1889 +7821 +-3551 +-5809 +4110 +-5040 +-4092 +5445 +-5175 +-6280 +9532 +9147 +5048 +6657 +-4544 +8730 +-3225 +-5271 +-3167 +-7417 +-8826 +8890 +32 +-2989 +1565 +1200 +2800 +-100 +588 +723 +2934 +-8672 +7056 +1422 +9459 +2982 +8508 +-3356 +-1845 +299 +4418 +9949 +-7101 +-6748 +-4830 +5451 +7495 +-4229 +-3448 +-5256 +1072 +-6484 +6663 +-3006 +-21 +5850 +-4757 +-5292 +-4298 +9117 +-4440 +-2427 +7397 +-9078 +-7036 +-1817 +418 +-4746 +-3827 +-2818 +3041 +1585 +7874 +-8274 +-2124 +4222 +-4143 +-1358 +-4460 +1454 +9695 +-3652 +-9078 +7941 +-4267 +-1518 +6926 +15 +-9743 +-1309 +7569 +2934 +-4898 +464 +-435 +2041 +8937 +-5431 +8612 +9292 +917 +7809 +4476 +-7954 +-9212 +-4112 +7822 +-708 +6843 +5417 +-4643 +592 +2906 +9912 +1077 +3892 +1692 +-8636 +-9705 +-4085 +-7772 +3827 +9079 +3732 +-2380 +-8013 +5399 +3351 +4092 +-7737 +-2384 +-3333 +130 +364 +3208 +-1292 +1787 +-4966 +-436 +7147 +5179 +2214 +-3368 +6259 +741 +-6054 +-6388 +-4567 +1170 +-7869 +-9978 +-8013 +-6787 +-1593 +1646 +-2149 +-997 +-1948 +5921 +9586 +7007 +2675 +1399 +9002 +2990 +3271 +5340 +-2670 +1670 +-9309 +8031 +-6169 +-8528 +7893 +5877 +8553 +-435 +8301 +8048 +-6104 +3754 +-7151 +-5142 +5182 +280 +2230 +-666 +2229 +-2314 +9114 +-5483 +7453 +-2548 +453 +2234 +-299 +-7086 +6463 +5526 +6313 +8972 +-6279 +7892 +-4562 +5480 +6674 +-5981 +7075 +-2610 +-2832 +-1070 +1906 +450 +-1419 +-9880 +2752 +-9978 +1974 +2309 +2529 +-6175 +1271 +6626 +8606 +1409 +-3799 +3963 +8310 +4069 +-9459 +8714 +8684 +6455 +5264 +1758 +7365 +-90 +737 +828 +-4599 +-4340 +-1374 +3325 +5101 +4605 +3524 +8185 +-131 +-8642 +5911 +-9756 +-9170 +-9296 +1961 +-1717 +430 +6280 +-4674 +180 +-716 +-2135 +-8454 +6248 +2926 +-1784 +-4497 +-3800 +4297 +2231 +-4107 +1211 +-4291 +6731 +-5685 +3654 +-375 +9025 +-6260 +6759 +1204 +-4544 +5147 +-9862 +-9647 +1763 +-8642 +5067 +4860 +-5639 +-6705 +-6817 +-2811 +-9819 +-7053 +3202 +6518 +7056 +-2081 +0 +-9405 +2240 +-1817 +-3397 +-8206 +8880 +-8339 +-1781 +-2565 +-2768 +5038 +-9066 +-4521 +-4592 +5606 +-4415 +-90 +3640 +-4852 +9163 +-4340 +-8082 +-5689 +983 +6984 +-7886 +-4913 +-4376 +-5876 +-3756 +-3499 +-9234 +-4363 +8031 +5826 +-6806 +4011 +-9520 +8512 +427 +-2814 +-4107 +7543 +-718 +-4987 +3331 +2309 +3589 +-2791 +-1689 +-9603 +-1306 +6734 +-2969 +4204 +2647 +-1981 +-6698 +134 +-4603 +-3062 +-1414 +-6015 +-4092 +7867 +1816 +-803 +3452 +-3675 +4655 +-4319 +-834 +-9777 +206 +-1985 +-401 +-1118 +-6908 +-1367 +8527 +-923 +-8430 +538 +6907 +-2415 +-4401 +5173 +-7338 +-7961 +5903 +-2669 +1944 +8321 +9940 +-3132 +7732 +2048 +-6846 +-5133 +-9900 +-84 +5923 +5083 +9695 +2934 +-7522 +4765 +-7351 +-594 +2445 +2927 +6400 +-6503 +9869 +6439 +7893 +6735 +-6454 +-9570 +6558 +-4545 +951 +-5748 +8416 +8157 +7520 +4935 +4384 +6212 +6651 +5330 +180 +1816 +-8781 +40 +1855 +5429 +-5157 +9165 +-8971 +2362 +6730 +8927 +-375 +-8205 +3985 +4501 +8664 +7850 +-2504 +3255 +2955 +-5587 +-5982 +-100 +1944 +-3990 +7528 +-1346 +-2577 +6946 +-555 +-7321 +6703 +5493 +-8013 +-7754 +1401 +7941 +-3748 +-2927 +-5210 +-3429 +7944 +4110 +-375 +-8041 +-6946 +5086 +5631 +9778 +-4310 +121 +8685 +1011 +9907 +-7047 +8890 +-555 +-3285 +224 +5327 +290 +6844 +-5903 +8188 +-6689 +-5028 +6944 +-3554 +5419 +-1309 +-6388 +-175 +5455 +1496 +3605 +-893 +-4510 +-892 +4554 +4492 +5191 +3876 +-9508 +-5448 +-1683 +-863 +-5378 +1232 +4130 +-2042 +6384 +-5389 +8432 +5052 +-3470 +-4620 +2987 +-6631 +8460 +4149 +3742 +-1950 +9937 +9726 +-3448 +6591 +5181 +-1366 +1396 +-3629 +2728 +-3623 +4103 +-4817 +7893 +-8642 +1311 +-4851 +-4040 +-2387 +-4025 +-5217 +6071 +3755 +-1040 +-3623 +3047 +8189 +5980 +1084 +-8253 +-1385 +-4225 +-3975 +6054 +-4574 +-9868 +-6903 +-1950 +-3634 +8917 +5970 +4270 +5182 +3222 +2116 +4738 +-3694 +3143 +8023 +8286 +-4500 +5280 +-7160 +-9117 +-7356 +2944 +158 +8739 +-9057 +-2218 +-5217 +-8261 +-8943 +-3253 +-825 +-1808 +5388 +5504 +8842 +-1920 +-3769 +3985 +7337 +-7221 +-1773 +-2229 +-601 +1489 +-237 +6175 +-7446 +-4970 +-6093 +1797 +1682 +-9115 +-7933 +-7808 +8805 +-3446 +2239 +9066 +-5441 +-6396 +4325 +4702 +8048 +-2399 +1318 +-9813 +-366 +6818 +-9555 +8070 +6779 +6194 +4668 +-1879 +6403 +3945 +596 +6945 +-2761 +5549 +-8310 +-4450 +6105 +3757 +-4188 +1118 +-7954 +-515 +7119 +2777 +-3137 +-6350 +-6079 +-3218 +-3649 +-7498 +2472 +-5305 +-8651 +7981 +2653 +5480 +-1895 +-144 +5075 +-2927 +5125 +-920 +8764 +-5364 +6151 +259 +-8959 +992 +8943 +5512 +-16 +-9469 +5453 +-2840 +5559 +13 +3225 +-1164 +2797 +2665 +-3121 +7 +-1119 +-4694 +1600 +3655 +9789 +4895 +-3337 +3655 +-7812 +5926 +6518 +-7221 +2952 +-3337 +5638 +-8357 +1318 +1271 +9646 +-37 +6756 +-1270 +-728 +7935 +3025 +-1191 +-9542 +3891 +-4580 +270 +6439 +6493 +7436 +8226 +6235 +3073 +8026 +-6644 +-9174 +-7551 +6664 +8483 +-3027 +-7869 +8821 +-8852 +538 +-4032 +-1299 +3078 +-6363 +1231 +6722 +-6054 +-5540 +-4056 +-3975 +-5189 +7743 +-7558 +-3609 +-2475 +8401 +-7686 +1547 +-2238 +3331 +5622 +8228 +-3422 +-1630 +-7746 +2178 +-2627 +2222 +7328 +-6607 +8652 +1571 +-580 +-8326 +-33 +6865 +-3972 +-6387 +3405 +7301 +-1673 +-4546 +5559 +-2821 +3771 +-5175 +-3630 +-7586 +1333 +6326 +3930 +4922 +2991 +9865 +-4495 +-8171 +-4143 +-6291 +-8682 +9935 +1066 +6850 +-2411 +-5293 +-8347 +5657 +-7164 +9148 +-3822 +9996 +-1441 +9286 +-5789 +8025 +7273 +7151 +-8859 +2051 +6696 +-3008 +-5267 +-9128 +6591 +2806 +3645 +-7069 +-6789 +5850 +2649 +-4239 +-4096 +-5939 +-1976 +-2943 +2955 +-3643 +2702 +8210 +-8857 +2340 +2396 +1741 +-3026 +506 +-2515 +5729 +2674 +-5088 +9651 +8882 +7439 +2812 +-2954 +5863 +4384 +485 +607 +2570 +6571 +2674 +-4897 +3056 +7882 +-6945 +-6240 +-9208 +5086 +8686 +-2466 +-308 +5398 +-6230 +8526 +1040 +544 +-2999 +-5755 +-5809 +-8991 +-5905 +9623 +7520 +8032 +1189 +-9331 +-9442 +-7242 +-5705 +9080 +-7517 +9061 +6566 +-4128 +1645 +289 +-4279 +-7845 +9651 +-446 +-7345 +125 +-3686 +-3984 +9462 +-1354 +-4281 +3383 +-9483 +-4878 +-5134 +-1414 +6705 +-7441 +-1029 +2952 +-8009 +1556 +8736 +-7782 +8841 +-7649 +903 +-6742 +-4811 +4607 +8516 +-3330 +4194 +9067 +5864 +1138 +-6503 +-8877 +612 +-2042 +-2475 +-7163 +-4563 +721 +6273 +2952 +-7758 +9630 +4100 +3804 +4860 +-4633 +-8393 +9779 +-8963 +5233 +-6194 +1328 +4645 +8815 +-6061 +-8802 +2424 +-491 +-9625 +-760 +-8115 +-2346 +-1512 +-4642 +7503 +-3603 +9081 +5923 +280 +4038 +-3576 +743 +-9828 +3638 +1471 +-9175 +-596 +-4040 +-4710 +2208 +-6479 +-1471 +-5231 +2054 +-6372 +-8315 +-3731 +9201 +3727 +4299 +-5866 +4234 +-666 +-1687 +2947 +1865 +9396 +2277 +9410 +-8963 +5406 +6626 +2730 +-4442 +-4620 +631 +-9405 +-1447 +-5973 +1698 +7504 +274 +-455 +-1185 +-7954 +2641 +6386 +7337 +7388 +-2231 +-2643 +-1867 +-4195 +8471 +-7407 +-3078 +-6916 +6731 +-1420 +947 +1509 +-1118 +5109 +9167 +-5146 +2521 +-7454 +1786 +5686 +258 +-6363 +-4107 +-3165 +5310 +489 +-3739 +2253 +378 +-7216 +-6520 +848 +1950 +-5490 +-8461 +-8216 +6238 +-3471 +-8877 +-8731 +-69 +921 +-5504 +-2643 +-8022 +7852 +-7640 +5811 +-2614 +2179 +9185 +4416 +-636 +-8359 +6721 +-5334 +-4553 +-7808 +-4738 +839 +2222 +6699 +-3487 +-1752 +7290 +1748 +-1001 +-6756 +852 +5724 +6399 +-1670 +721 +-9612 +9947 +8692 +-7917 +2924 +-5819 +7269 +-3285 +26 +3932 +7516 +4447 +5471 +6471 +-7149 +-2052 +-4669 +-9399 +3726 +7364 +8688 +1021 +-1125 +-99 +5233 +4904 +-4161 +8529 +5809 +5822 +3670 +-8249 +8416 +-2123 +-3327 +1708 +-5109 +-2405 +3316 +894 +3047 +6317 +-6690 +-1374 +6287 +4962 +3030 +3383 +-1027 +-2365 +6558 +3886 +-4237 +2018 +7273 +-9733 +4713 +-9301 +-2791 +1248 +8173 +-5741 +-1726 +2496 +-6631 +-4553 +-8041 +-9938 +-2781 +-9603 +8854 +-7956 +-5945 +4190 +3445 +6579 +7436 +1941 +-8171 +-5367 +-4151 +-8162 +-4896 +1798 +9831 +6919 +-3429 +6463 +4289 +3688 +-3006 +-3205 +-5876 +4776 +-4119 +-10000 +5890 +-1760 +3128 +5548 +-4710 +7626 +-9779 +2280 +6103 +-5945 +-5701 +-7221 +3426 +-6000 +-4520 +-6402 +-1703 +-5202 +1164 +9192 +-895 +9001 +-6393 +6466 +5324 +8115 +-8846 +3338 +-8813 +47 +802 +5683 +-8353 +5923 +-5409 +-7843 +3848 +12 +9183 +2252 +9714 +-6001 +-4520 +1011 +273 +-8106 +-6277 +-5023 +7811 +-9513 +839 +-2340 +802 +-816 +-4287 +1816 +-333 +2475 +8849 +-5751 +-1 +-1011 +-8508 +-5689 +3805 +-9845 +-2169 +-3330 +-3603 +-1902 +3744 +-9873 +-9579 +-8507 +-3518 +-3087 +-436 +-7163 +2049 +8851 +-8183 +8749 +-4107 +-1649 +-6787 +955 +3688 +6977 +7249 +5326 +922 +8939 +-760 +-7638 +-409 +7527 +-3170 +1003 +-3165 +3160 +-1897 +-3921 +1964 +-8978 +-7164 +5368 +7355 +-735 +-3926 +-9 +714 +9333 +1656 +8752 +7777 +-7337 +2165 +7421 +829 +-6363 +1786 +-7207 +-4558 +5338 +10 +-9578 +6666 +-4621 +8644 +-9645 +-9539 +8881 +-7320 +6591 +9635 +3044 +7752 +1670 +-7675 +-4195 +9202 +-4225 +6221 +1740 +980 +1798 +-2160 +-255 +5827 +7451 +4904 +-2399 +8093 +8001 +-2304 +-1254 +506 +5626 +-9732 +8144 +4928 +178 +-8803 +9174 +4382 +-1586 +-4350 +5885 +-8718 +7610 +5313 +-8187 +-3520 +5613 +2958 +4609 +-3307 +-9102 +-4056 +-4246 +-5680 +5013 +2158 +-1952 +2001 +8667 +5526 +9544 +-5292 +-8487 +-3186 +5213 +4646 +2309 +7608 +-2971 +4950 +3063 +-231 +-4904 +-1299 +5417 +-8743 +111 +-1983 +3712 +1150 +-8518 +-5652 +8685 +-4298 +-6113 +8915 +2633 +-2314 +-1657 +8892 +-9889 +-5597 +7823 +-5163 +5485 +-7399 +9199 +7383 +-9420 +-8137 +4327 +3709 +8166 +2149 +8474 +-3682 +-4819 +-7772 +5047 +2310 +4032 +7447 +-9847 +-8055 +-2206 +1546 +6411 +-122 +3003 +-273 +2925 +6209 +-8642 +7058 +3044 +1729 +-4161 +248 +6518 +-5368 +5481 +-4363 +-6298 +1748 +-5285 +-6467 +5750 +-984 +-5288 +2435 +-2969 +3468 +5934 +9822 +-7421 +1465 +-4097 +-7204 +6073 +1964 +2465 +-7060 +6553 +9381 +8485 +3886 +5549 +1954 +6428 +1797 +4110 +1557 +3063 +-7121 +-2659 +-2405 +-9037 +-3646 +-6684 +9035 +9808 +-8165 +7917 +6368 +8612 +498 +6 +-1105 +6531 +4446 +4284 +-3800 +7002 +-8688 +-4766 +2876 +9641 +8137 +5761 +776 +-3274 +-7094 +89 +8370 +3316 +3527 +4190 +-489 +-224 +7957 +-7637 +-984 +-1840 +4414 +-1221 +-6377 +2068 +8470 +-3385 +-5273 +-9014 +-5947 +8935 +9253 +189 +-6520 +-9118 +62 +-327 +-1944 +907 +-8183 +159 +-9175 +-667 +7794 +4533 +-4554 +9256 +6622 +2389 +3507 +-4258 +9689 +-4814 +-2446 +-3126 +-5764 +-8721 +-6388 +-4069 +-8106 +-1803 +-8007 +7249 +2773 +5285 +592 +-4040 +-4936 +-7019 +-4940 +2175 +-9777 +27 +-6770 +4098 +2782 +2173 +739 +4002 +3734 +5080 +-8888 +6468 +-7198 +-3016 +-1518 +-5684 +5545 +5275 +-3132 +115 +1865 +9471 +7794 +3732 +1613 +3300 +7668 +1218 +-7062 +-8386 +1204 +-5375 +-6557 +-5302 +-3448 +-2171 +-3613 +7828 +8202 +-5389 +1645 +-4081 +-4040 +997 +8880 +-8149 +7163 +4382 +-2684 +-5713 +-8886 +1866 +4571 +-5028 +1054 +-5735 +2601 +-2454 +-5704 +2325 +-7502 +-1627 +-3635 +5702 +-2367 +3454 +-882 +-3285 +2401 +9552 +1585 +8480 +-6479 +-3197 +5 +1486 +3687 +-6828 +-5078 +-8245 +-7729 +-4365 +-5651 +-2617 +7797 +-2179 +-33 +-2229 +7388 +8349 +7382 +2703 +6105 +3388 +7797 +538 +8638 +-3130 +-6110 +7896 +-5073 +345 +9213 +124 +3540 +5809 +-2696 +-5475 +6730 +4979 +8048 +369 +-7772 +7546 +-8215 +-923 +9427 +727 +702 +9503 +2990 +-1503 +2173 +1026 +2180 +2925 +-2227 +-3951 +-5220 +-4462 +9542 +-5201 +-298 +8745 +5992 +6900 +2801 +-5851 +-2957 +6756 +-9263 +-9405 +2839 +-252 +-7064 +7100 +-9265 +6518 +8126 +-3351 +1556 +-2817 +8202 +-6946 +-5201 +7863 +6566 +5640 +8304 +-4677 +3151 +3609 +3268 +6525 +-8137 +-7542 +-8526 +166 +5478 +5186 +-7907 +-3482 +3126 +2033 +-3801 +8636 +-6563 +-5292 +-6255 +1048 +-6720 +-269 +-6238 +5178 +3709 +-6001 +-9140 +3292 +-6683 +2870 +5847 +7225 +5441 +-1678 +9764 +610 +1404 +-100 +579 +-2497 +4172 +-733 +8727 +-9360 +123 +-3594 +-1815 +5200 +997 +2773 +4673 +-7840 +-6742 +5451 +5915 +-4793 +9993 +-5741 +-7772 +6174 +-9150 +-6561 +7877 +-2988 +5638 +-229 +5882 +1585 +-4231 +3388 +-9884 +4571 +5287 +2864 +-3191 +-3987 +8976 +8332 +-8150 +7190 +5379 +4726 +-6332 +-4239 +4068 +5562 +4498 +-3505 +-224 +7057 +-1252 +-5390 +-4351 +-7695 +-4698 +-4554 +-6288 +7465 +4742 +-8665 +-9734 +-2365 +-5367 +2605 +6248 +-8538 +-3126 +-5292 +-1575 +-7956 +2247 +-576 +-2929 +-6819 +-366 +9815 +6558 +-4711 +7947 +1156 +-2603 +-3413 +6496 +-3598 +7758 +-7440 +8692 +-5673 +-6444 +-2945 +-9673 +-8906 +8719 +7147 +-1260 +2479 +8882 +-7363 +4571 +-7675 +-2515 +8137 +8850 +-8348 +7611 +-9400 +4708 +1248 +1457 +-5724 +-9926 +9789 +-1808 +-603 +-3921 +2744 +2365 +-4896 +4676 +555 +-6826 +3690 +2746 +3989 +-8013 +-7577 +7805 +6274 +-7711 +-1637 +-5904 +9581 +8526 +1158 +9695 +1724 +6941 +7579 +1655 +-6133 +-889 +4985 +-9579 +-7328 +9448 +-6110 +2801 +-305 +-7542 +3344 +5455 +-8560 +-2081 +-1680 +-6284 +7873 +-2314 +1054 +3128 +724 +1056 +9231 +-8868 +-8636 +-5689 +1234 +-3257 +-5782 +-9749 +1265 +8482 +1841 +5093 +5474 +-436 +-5874 +-6188 +1486 +1079 +-6487 +-8999 +-1921 +-6577 +9506 +3900 +3426 +-52 +8892 +1956 +-3351 +-7047 +-7124 +-8837 +4766 +-1636 +2173 +-1945 +7581 +-2624 +3091 +7397 +4935 +-5340 +-6398 +-5937 +-4479 +9413 +2063 +-2215 +-3274 +8361 +8492 +-4898 +2870 +2235 +-2916 +3630 +7811 +-6222 +-1668 +-4065 +4254 +-6335 +455 +4766 +-5403 +2744 +2178 +-3886 +4645 +-6340 +-1736 +2374 +-1118 +8927 +-3871 +-9813 +-2816 +7122 +3910 +5631 +6209 +2876 +2334 +-2414 +1386 +-6856 +-2369 +-8261 +-2339 +3259 +2348 +610 +-5192 +-2579 +9578 +5759 +5986 +5244 +9726 +-4711 +-455 +6438 +-9214 +-4668 +5650 +-3821 +-7334 +610 +-5423 +-8857 +4976 +-9130 +-6718 +-6999 +-283 +-2819 +-5349 +7565 +4594 +-3946 +-9013 +2674 +3234 +8807 +5993 +-5428 +-4231 +9142 +-9358 +3857 +-8585 +6 +-3139 +-4138 +-6257 +4612 +7641 +-3327 +-3391 +7284 +5871 +-8007 +-7066 +9233 +4069 +-8100 +8450 +-7531 +630 +-3679 +-8736 +-1878 +-6927 +6583 +4675 +5656 +8526 +5649 +2113 +-1895 +184 +3332 +-1173 +750 +8815 +-973 +-8108 +-1507 +8569 +-1867 +1242 +-7601 +3462 +-1438 +-582 +6 +-6428 +-6017 +-8608 +9294 +6942 +-1100 +2388 +-8753 +-8997 +6235 +-2784 +-8499 +-1267 +1609 +-6388 +-7585 +-1322 +636 +-3442 +-7127 +4554 +6998 +9707 +-4847 +4904 +-6864 +4681 +-6925 +-3251 +7778 +9768 +6591 +-1605 +-1558 +9169 +829 +-502 +2519 +-7189 +-4698 +7014 +6733 +-8849 +-7003 +-400 +-125 +-3634 +2158 +2445 +-8648 +3559 +-4440 +-1760 +-287 +6648 +8583 +5147 +2139 +1921 +-6840 +8370 +9427 +5463 +-1441 +-9760 +9481 +7312 +-1512 +8891 +1692 +4250 +-2739 +6102 +6471 +7812 +-5147 +312 +-2710 +-6893 +-1960 +-7288 +758 +-1522 +2780 +7354 +-1306 +-894 +-100 +9938 +5911 +-9009 +-9851 +-6783 +3468 +-5449 +6471 +-3842 +854 +-4629 +-299 +-9627 +4859 +-5444 +6317 +-4440 +5555 +4628 +-5794 +1100 +-1771 +-9689 +2928 +6867 +-5451 +-5899 +9184 +-5278 +-2309 +3805 +-4083 +4632 +4941 +3769 +3409 +7192 +-3871 +-9864 +-208 +-6080 +-8753 +2457 +3623 +8991 +-9604 +-1948 +9298 +-4975 +-5157 +4976 +3677 +2234 +-1649 +7582 +-580 +5631 +-6061 +-4774 +4901 +-6484 +-2644 +5650 +3744 +-9915 +5582 +9718 +4694 +-7028 +6004 +6019 +987 +-900 +-150 +8930 +2733 +-8994 +1547 +7631 +-224 +-3551 +-2311 +-990 +-9214 +3527 +-7522 +-2304 +5265 +-4340 +6503 +-722 +5326 +2861 +6828 +-3752 +-5631 +2527 +-426 +-3955 +-8448 +2315 +-7250 +-8206 +8543 +-573 +9286 +992 +-5937 +2119 +2649 +2794 +-5261 +-899 +-8022 +7253 +-3886 +-3787 +3932 +6471 +-2265 +-8454 +-4096 +-3839 +-5406 +1724 +-216 +506 +7050 +969 +2296 +-8519 +7462 +-6732 +-7807 +-9622 +1743 +6583 +-7047 +6210 +7743 +2911 +3547 +3852 +-8934 +-8909 +5338 +6472 +-5323 +-5441 +5943 +3796 +4355 +2943 +1898 +-424 +6894 +-3085 +5357 +3688 +-3789 +-3923 +-666 +1947 +8630 +6831 +-7318 +-6153 +-7078 +8166 +6483 +-2811 +-4504 +-8984 +9331 +-7058 +-5073 +-5643 +-6578 +-9078 +-933 +-5631 +7728 +-3233 +-3444 +-8253 +-1894 +-1400 +7065 +-8135 +7428 +-1016 +-7183 +-1557 +7893 +-1655 +1374 +-8920 +-9955 +3058 +-5651 +4840 +6086 +-5112 +-968 +-4307 +3953 +6733 +3456 +-1631 +-2706 +-992 +3533 +-3202 +-8012 +-7950 +-3839 +-9471 +6127 +5961 +7812 +-523 +-6582 +5920 +-1459 +8513 +6525 +-3629 +-7154 +6365 +-7321 +-2299 +-9223 +4235 +968 +6463 +3795 +5836 +-3513 +3377 +-2891 +3805 +-816 +9923 +-9472 +9793 +2527 +-7201 +-3123 +-735 +7812 +2744 +-8343 +-6642 +-9245 +8300 +4610 +-1242 +-8773 +2875 +-1073 +2597 +2846 +-6748 +9750 +4567 +5707 +3930 +-8642 +3593 +9517 +-8865 +-3428 +6491 +8943 +-9176 +7467 +9478 +6918 +7237 +-9113 +-3976 +-7443 +-1474 +2097 +3151 +7546 +-6408 +-1599 +-2908 +6858 +1324 +4576 +-3772 +3479 +-7493 +7481 +-4594 +-237 +1011 +-9955 +-4863 +-8492 +8842 +-2721 +-228 +-3132 +3910 +7906 +-7033 +-3137 +-3103 +1416 +-3814 +-7552 +4151 +7864 +-5599 +-8567 +-3137 +-2916 +-7376 +2788 +948 +4646 +5464 +-1850 +-2986 +-3103 +-2833 +3933 +2047 +5679 +-8176 +-1354 +8381 +1084 +-559 +8719 +4510 +5638 +9924 +-44 +5565 +-2614 +5932 +-1297 +6265 +9067 +-6089 +-5355 +-8814 +-2515 +2165 +2457 +8482 +-1363 +-4264 +-3205 +-6170 +8296 +4737 +-6476 +9665 +5389 +8188 +-1322 +-8724 +3909 +8807 +-2928 +-7858 +5271 +5550 +130 +-2837 +1011 +-8438 +-3006 +-5188 +-4872 +8730 +-727 +-5992 +7885 +8759 +3933 +9760 +-6318 +-5625 +-4651 +-1986 +-4287 +4791 +5324 +-3807 +8932 +8300 +2658 +-958 +4654 +1960 +-9007 diff --git a/2022/Day21CSharp/Advent2022_Day21.cs b/2022/Day21CSharp/Advent2022_Day21.cs new file mode 100644 index 0000000..6561f12 --- /dev/null +++ b/2022/Day21CSharp/Advent2022_Day21.cs @@ -0,0 +1,242 @@ +using System.Numerics; + +var exampleData = new ProblemData("example-input.txt"); +var puzzleData = new ProblemData("puzzle-input.txt"); + +Console.WriteLine("!! === Part01 === !!"); +Console.WriteLine("Example root yells: {0}", exampleData.GetMonkeyValuePart01("root")); +Console.WriteLine("Puzzle root yells: {0}", puzzleData.GetMonkeyValuePart01("root")); + +Console.WriteLine("!! === Part02 === !!"); +Console.WriteLine("Example human yells: {0}", exampleData.GetMonkeyValuePart02()); +Console.WriteLine("Puzzle human yells: {0}", puzzleData.GetMonkeyValuePart02()); + +abstract class MonkeyCommand +{ + public MonkeyCommand(string name) + { + Name = name; + } + + public abstract BigInteger GetValue(); + + public string Name { get; protected set; } + + public static bool DebugPrint { get; set; } = false; +} + +class MonkeyYellCommand + : MonkeyCommand +{ + public MonkeyYellCommand(string name, BigInteger val) + : base(name) + { + Value = val; + } + + public BigInteger Value { get; set; } + public override BigInteger GetValue() + { + return Value; + } +} + +class MonkeyMathCommand + : MonkeyCommand +{ + public MonkeyMathCommand(string name, Dictionary lookupTable, string left, string right, char op) + : base(name) + { + LookupTable = lookupTable; + Left = left; + Right = right; + if ((op != '-') && (op != '+') && (op != '*') && (op != '/') && (op != '=')) throw new InvalidDataException(); + Op = op; + } + + public string Left { get; set; } + public string Right { get; set; } + + public BigInteger RightValue + { + get + { + return LookupTable[Right].GetValue(); + } + } + + public BigInteger LeftValue + { + get + { + return LookupTable[Left].GetValue(); + } + } + + public char Op { get; set; } + + public char InverseOp + { + get + { + switch (Op) + { + case '+': return '-'; + case '-': return '+'; + case '*': return '/'; + case '/': return '*'; + default: throw new InvalidDataException(); + } + } + } + + public Dictionary LookupTable { get; set; } + + public override BigInteger GetValue() + { + BigInteger left = LeftValue; + BigInteger right = RightValue; + + switch (Op) + { + case '+': + return left + right; + case '-': + return left - right; + case '*': + return left * right; + case '/': + return left / right; + case '=': + if (MonkeyCommand.DebugPrint && LookupTable["humn"].GetValue()%10000 == 0) Console.WriteLine("Comparing {0} v {1} with humn {2}", left, right, LookupTable["humn"].GetValue()); + return left - right; + default: throw new InvalidDataException(); + + } + } +} + +class ProblemData +{ + private Dictionary CommandLookupPart01 { get; set; } + private Dictionary CommandLookupPart02 { get; set; } + + public ProblemData(string filename) + { + CommandLookupPart01 = new Dictionary(); + CommandLookupPart02 = new Dictionary(); + + using (StreamReader reader = System.IO.File.OpenText(filename)) + { + while (!reader.EndOfStream) + { + var line = reader.ReadLine(); + if (line == null) throw new InvalidDataException(); + + var split = line.Split(':', StringSplitOptions.TrimEntries); + var name = split[0]; + + MonkeyCommand monkey, monkey2; + + // First see if its a value being yelled by the goddamned monkeys + int val; + if (int.TryParse(split[1], out val)) + { + // It's a value monkey + monkey = new MonkeyYellCommand(name, val); + monkey2 = new MonkeyYellCommand(name, val); + } + else + { + // It's a math monkey + var mathline = split[1].Split(' ', StringSplitOptions.RemoveEmptyEntries); + monkey = new MonkeyMathCommand(name, CommandLookupPart01, mathline[0], mathline[2], mathline[1][0]); + + char op = mathline[1][0]; + if (name == "root") + op = '='; + monkey2 = new MonkeyMathCommand(name, CommandLookupPart02, mathline[0], mathline[2], op); + } + + CommandLookupPart01[name] = monkey; + CommandLookupPart02[name] = monkey2; + } + } + } + + public BigInteger GetMonkeyValuePart01(string name) + { + return CommandLookupPart01[name].GetValue(); + } + + public BigInteger GetMonkeyValuePart02() + { + MonkeyMathCommand rootCmd = (MonkeyMathCommand)CommandLookupPart02["root"]; + + // Find the side the human is on + bool isHumanOnLeft = IsHumanOnLeft(CommandLookupPart02, rootCmd); + BigInteger targetValue; + + if (isHumanOnLeft) + { + targetValue = rootCmd.RightValue; + } + else + { + targetValue = rootCmd.LeftValue; + } + + var humnCmd = (MonkeyYellCommand)CommandLookupPart02["humn"]; + BigInteger result = 0; + BigInteger high = long.MaxValue, low = long.MinValue; + BigInteger mid = low + (high - low) / 2; + + bool incrementUp = false; + humnCmd.Value = 1; + var first = isHumanOnLeft ? rootCmd.LeftValue : rootCmd.RightValue; + humnCmd.Value = 100; + var second = isHumanOnLeft ? rootCmd.LeftValue : rootCmd.RightValue; + + if (second > first) incrementUp = true; + + while ((isHumanOnLeft ? rootCmd.LeftValue : rootCmd.RightValue) != targetValue) + { + humnCmd.Value = mid; + + var newVal = isHumanOnLeft ? rootCmd.LeftValue : rootCmd.RightValue; + + if ((incrementUp && (newVal > targetValue)) || (!incrementUp && (newVal < targetValue))) + { + high = low + (high - low) / 2; + } + else + { + low = low + (high - low) / 2; + } + + mid = low + (high - low) / 2; + } + + return CommandLookupPart02["humn"].GetValue(); + } + + private static bool IsHumanOnLeft(Dictionary dict, MonkeyMathCommand command) + { + MonkeyYellCommand humnCmd = (MonkeyYellCommand)dict["humn"]; + + var ogRight = command.RightValue; + var ogLeft = command.LeftValue; + + humnCmd.Value += 10; + + var newRight = command.RightValue; + var newLeft = command.LeftValue; + + humnCmd.Value -= 10; + + if (ogLeft == newLeft) return false; + else if (ogRight == newRight) return true; + else throw new InvalidDataException(); + } + +} \ No newline at end of file diff --git a/2022/Day21CSharp/Day21CSharp.csproj b/2022/Day21CSharp/Day21CSharp.csproj new file mode 100644 index 0000000..d439800 --- /dev/null +++ b/2022/Day21CSharp/Day21CSharp.csproj @@ -0,0 +1,10 @@ + + + + Exe + net7.0 + enable + enable + + + diff --git a/2022/Day21CSharp/Properties/launchSettings.json b/2022/Day21CSharp/Properties/launchSettings.json new file mode 100644 index 0000000..38fe186 --- /dev/null +++ b/2022/Day21CSharp/Properties/launchSettings.json @@ -0,0 +1,8 @@ +{ + "profiles": { + "Day21CSharp": { + "commandName": "Project", + "workingDirectory": "C:\\dev\\DevSandbox\\AdventOfCode\\2022\\Day21CSharp" + } + } +} \ No newline at end of file diff --git a/2022/Day21CSharp/example-input.txt b/2022/Day21CSharp/example-input.txt new file mode 100644 index 0000000..6972c84 --- /dev/null +++ b/2022/Day21CSharp/example-input.txt @@ -0,0 +1,15 @@ +root: pppw + sjmn +dbpl: 5 +cczh: sllz + lgvd +zczc: 2 +ptdq: humn - dvpt +dvpt: 3 +lfqf: 4 +humn: 5 +ljgn: 2 +sjmn: drzm * dbpl +sllz: 4 +pppw: cczh / lfqf +lgvd: ljgn * ptdq +drzm: hmdt - zczc +hmdt: 32 \ No newline at end of file diff --git a/2022/Day21CSharp/problem.txt b/2022/Day21CSharp/problem.txt new file mode 100644 index 0000000..1b0c8fb --- /dev/null +++ b/2022/Day21CSharp/problem.txt @@ -0,0 +1,58 @@ +--- Day 21: Monkey Math --- + +The monkeys are back! You're worried they're going to try to steal your stuff again, but it seems like they're just holding their ground and making various monkey noises at you. + +Eventually, one of the elephants realizes you don't speak monkey and comes over to interpret. As it turns out, they overheard you talking about trying to find the grove; they can show you a shortcut if you answer their riddle. + +Each monkey is given a job: either to yell a specific number or to yell the result of a math operation. All of the number-yelling monkeys know their number from the start; however, the math operation monkeys need to wait for two other monkeys to yell a number, and those two other monkeys might also be waiting on other monkeys. + +Your job is to work out the number the monkey named root will yell before the monkeys figure it out themselves. + +For example: + +root: pppw + sjmn +dbpl: 5 +cczh: sllz + lgvd +zczc: 2 +ptdq: humn - dvpt +dvpt: 3 +lfqf: 4 +humn: 5 +ljgn: 2 +sjmn: drzm * dbpl +sllz: 4 +pppw: cczh / lfqf +lgvd: ljgn * ptdq +drzm: hmdt - zczc +hmdt: 32 + +Each line contains the name of a monkey, a colon, and then the job of that monkey: + + A lone number means the monkey's job is simply to yell that number. + A job like aaaa + bbbb means the monkey waits for monkeys aaaa and bbbb to yell each of their numbers; the monkey then yells the sum of those two numbers. + aaaa - bbbb means the monkey yells aaaa's number minus bbbb's number. + Job aaaa * bbbb will yell aaaa's number multiplied by bbbb's number. + Job aaaa / bbbb will yell aaaa's number divided by bbbb's number. + +So, in the above example, monkey drzm has to wait for monkeys hmdt and zczc to yell their numbers. Fortunately, both hmdt and zczc have jobs that involve simply yelling a single number, so they do this immediately: 32 and 2. Monkey drzm can then yell its number by finding 32 minus 2: 30. + +Then, monkey sjmn has one of its numbers (30, from monkey drzm), and already has its other number, 5, from dbpl. This allows it to yell its own number by finding 30 multiplied by 5: 150. + +This process continues until root yells a number: 152. + +However, your actual situation involves considerably more monkeys. What number will the monkey named root yell? + +Your puzzle answer was 223971851179174. + +The first half of this puzzle is complete! It provides one gold star: * +--- Part Two --- + +Due to some kind of monkey-elephant-human mistranslation, you seem to have misunderstood a few key details about the riddle. + +First, you got the wrong job for the monkey named root; specifically, you got the wrong math operation. The correct operation for monkey root should be =, which means that it still listens for two numbers (from the same two monkeys as before), but now checks that the two numbers match. + +Second, you got the wrong monkey for the job starting with humn:. It isn't a monkey - it's you. Actually, you got the job wrong, too: you need to figure out what number you need to yell so that root's equality check passes. (The number that appears after humn: in your input is now irrelevant.) + +In the above example, the number you need to yell to pass root's equality test is 301. (This causes root to get the same number, 150, from both of its monkeys.) + +What number do you yell to pass root's equality test? diff --git a/2022/Day21CSharp/puzzle-input.txt b/2022/Day21CSharp/puzzle-input.txt new file mode 100644 index 0000000..40b8083 --- /dev/null +++ b/2022/Day21CSharp/puzzle-input.txt @@ -0,0 +1,2597 @@ +ngwp: dbhf + lhwf +rcdg: npwg * pdqh +cqwl: bwgm + bplm +nprq: vwfn * gpss +mnqb: 5 +hnnt: cqwl * pbht +tdjm: 3 +bpvm: ljpj * shjf +bgdj: hrqc * tcnw +tvfq: vnts + qnzq +sffd: 2 +czmj: 8 +wggj: jnzd + gjcw +dzmw: tpbz / ddwg +blzh: rgnn + jpsn +czsz: fnhp / mvgg +hszf: lpsz + lrpl +bqgw: 11 +mfsv: dttp * tvmh +tshp: 7 +pbrm: 5 +dndl: 12 +lmhg: cvjd * qwfl +dgsm: 3 +hhds: rnqw + lszf +rbbj: 2 +ttvg: 5 +mprs: gvhg / nzlz +rqnt: 13 +dttp: vdlr + zspd +vhtm: 9 +qzsc: 2 +szhv: cmgs + ttnh +wmls: 9 +gfws: 9 +vtcj: 3 +rpwp: 3 +drfs: 3 +vhhr: mvjr * qzml +fdsq: 3 +nlnr: pfsf / wchj +zzmn: wgmf - spcp +rbbr: nzjt + ndzb +tgsj: hpvt + dqvq +qhqj: vlgr + rqnt +gmpt: hscb - lmjw +cshg: jgrj * tplj +qmwn: dgrs * mccm +tntn: 18 +zfhv: pfdf + gvtc +qbtz: 1 +rqqf: 2 +pvdd: 8 +jljb: dmjl * gdmq +hmdj: 2 +dgvm: rhfj * zlnt +jmtc: 5 +zlnf: hvgn + nvwg +rwtd: 5 +sjsc: vrlw - sngh +dqwn: 3 +scsc: 2 +rsbl: 5 +lhfc: 2 +cmct: flmq + fbpf +ndrd: 4 +nrjz: 3 +vtvq: rbbr + dgms +bthq: zpgv + nblh +pzln: 2 +zfff: whmz - frrm +wrmr: lfrq + ctsb +fsss: 2 +wbdm: bjhb * cjmv +zpdc: 5 +hrqc: 7 +jtss: 3 +nctt: gdqd + blrb +gzzt: 2 +pgzr: 1 +wdbr: 3 +gjtf: 7 +fzsj: jgjj + pqdh +wzjh: 8 +wpwz: 5 +rdpp: 5 +mrhg: 11 +jcnb: 20 +qlzb: rtrt * zbsg +wbrj: 2 +wpfs: 2 +hbqg: 3 +fnsr: tmsq / qrfg +jfcq: gpgw + sqrl +zbmq: 2 +cgtj: qnzw / qrlp +tnzf: 3 +bhbz: jwjf + bbcz +mntg: 7 +hzmf: pbrm * hwbl +cjmv: ztpv + mvbm +wctd: pvzz * wpjr +zhvn: lvpc - wblw +cwlp: 2 +cnpc: bjmt * fzbh +tpbz: vdmh / ftdt +cmps: 13 +prdj: 5 +pzmc: 3 +jgpl: nsqh + trhr +hrvj: vhhr / zjzt +qzhv: 1 +hfgl: 5 +svzt: 2 +lcnv: gnnb + sdbv +nbrl: zznq * pcnz +mqnc: 2 +glvf: 11 +vtsm: hrcn + rljv +ncdn: rbgc + bftf +znrs: 11 +zvdc: 2 +mbsr: 2 +jhhb: bngc + tqlt +dbvt: 2 +svmc: rntv + lwlr +hbtt: gddc * zngw +vcgg: 11 +pdqg: 2 +cmgs: 6 +bfsl: 2 +stgv: pbmf + wznm +rmfw: 7 +mphw: 2 +blrb: jtdz * djft +mphf: 1 +cqnp: grzz * mgft +flcm: thrp * fnhn +lwlr: 6 +mczd: smgm * tffn +pbll: 3 +msrj: 5 +fszt: 5 +vlnw: bscl + bfjw +wtvv: jfpt * jvzp +shjf: vnhq + lngs +jfnj: twpc / pzln +mmgq: 8 +pmsn: 3 +rctg: 3 +mrnq: qcfb + qngj +zlbw: 6 +zpsl: jnsh / rgbw +ttmw: rdms + jljb +plzs: 4 +dzss: 3 +ftdw: ctjd * fdsq +vjvl: 3 +jrrm: 4 +mhdr: 3 +clgf: jnwf + shzm +czzd: 2 +mnjc: zddt * mhdv +hhrg: qjsm * dznt +msvm: 2 +gnmd: 2 +wlql: 6 +zfcf: 2 +qnpr: zpdc * fzvp +trhr: brqf * vtwf +zhgs: 3 +dntj: pwwg * bvjj +bsbs: srnq / jfwh +bhzg: gntm + gczr +jwpf: 3 +vvfm: jvfm * vwqm +pgwr: mbgv * vhpn +nvjh: rqbz * lpcj +tftq: vsps + pghb +vhrt: jsjj / lzwl +sgnf: rctg * njsn +mrdg: 20 +crjw: vmhf + tpcm +wdtb: zdrn + jfhp +trtj: cscn - lpnp +ftmm: sgcs * qtmp +zcfd: 3 +jpjv: 2 +gnjw: vpdq / lpzw +fthz: 20 +wvhd: dcqf + wcrt +llfv: 2 +jpfd: 8 +tqlc: zgfq + stss +jsgm: qsmb + qdqj +sdph: rflc - bhzg +tpbv: 2 +zdmt: 2 +hmjc: mvzc + nhrw +cvpc: bnnt * bpzr +zhpp: dzbl * zngb +vpvh: 3 +sscd: mfdd + prnn +sbvb: mrrb + zmgd +twjg: 2 +drzl: 11 +cfvb: bltn + vtsm +gqss: qffm + wwhm +mgqq: dcbw + rlzq +sgnd: 2 +bqvv: 6 +rtqw: mpqd * spgg +jmcr: mrns * dhln +sqfc: mbjv * rjtp +rpgd: 2 +lttg: jhps * zjwz +zrqs: ndms + dslc +rzgm: 7 +gvrj: 15 +zldr: tjqd * wppp +dgms: 1 +rwws: zjhq * cbvf +mnld: frdh / pcrq +cgjw: tfpd * njwh +tbgc: wqhz * wbvr +mbln: 3 +pcbr: 2 +gmmw: mmql * wsql +fwcs: rwlt + fmcp +rfgp: 7 +svvz: 3 +hlhj: zvbs + jbqj +pmcg: pvms + gpzf +fpbb: nblt * rtrm +ljpj: 2 +gddt: 10 +gbrl: 2 +dllf: 4 +dzjs: 3 +mfdd: 6 +qvst: rgqg * ndpz +hbcd: 7 +msqs: 3 +rlbq: 1 +vbrz: jjqm + stgv +hnzb: zftn + jhzs +snhs: 6 +crsv: 16 +ctgb: 10 +srpm: dghd + rlhg +wblm: 20 +czjq: 5 +jlvb: tfjn + qtdm +nzfg: 2 +qvmv: 1 +ljmz: 2 +wswp: 2 +zgbc: hfdg + vmhs +mszm: 4 +rdph: 2 +vhqj: wcpv * ztfh +jhsf: 4 +vwtf: jlcn + pdgl +gbwj: 12 +fngn: whcp * lbvn +rtrt: 5 +sjhh: 2 +mrvp: wjdf + mhwj +rhtm: wgmq + spgf +vrqs: qtlz - gsrw +pvzz: 8 +pwgh: qdhb + vbrz +bmvv: 4 +gjbv: vtjc + wcsg +swwq: wjbj * hfgl +vrmn: pqvc + zmdn +jpgl: fvzt * mbvw +pwhs: bhbz * drwv +fzwq: ggqn + rlsf +fwzl: bdhr + trrb +fdnn: 3 +pqlj: vnpl * fpgs +jgbg: 3 +vmhf: 5 +stss: 9 +ntcm: fbqq * snhj +dssj: 6 +sclc: 2 +wppp: thhv * sdlc +sbzv: vtbm + pgss +lvmv: ccch + snjj +ddwc: scgw + mcwn +wqmm: 8 +wrqb: rscq * vfdv +rlfr: 5 +llhz: ssmv / nzbp +zfcl: clhs + mcgr +mjzr: tldr + qppc +fwhb: jstf * rlqj +sgzc: hvmn + qpsl +lgpf: zdjp * bcrh +scgw: 11 +vpzl: 3 +bcqm: 17 +cbqz: 6 +mlwr: mwwh * jvbp +sngh: hcbs * bvqd +dbhf: 2 +jdzb: 13 +rwjl: fjgt + pgzr +qqnc: 2 +ssqz: zmmg * zpbt +zbgr: hsnb - lpcp +vmzb: 5 +dnrs: swfn * fzrd +tvpj: 3 +qmjl: 11 +njzd: qmht * wsqt +mzsr: 4 +hfzj: 2 +rwgf: wbgb + fpbb +jplw: 2 +snlp: snhs * gmwp +vrzv: pvcz + zzql +vjst: pnmp + wrns +msbs: 1 +hpvg: vfqn + zlrl +ztfd: ffls * pqcs +bldp: 10 +vtrz: svvl * nmqc +fhpw: 5 +dffp: mnld * tfhf +gnnb: wdtb * ftzl +rlqr: qqcd - rvwn +mhrh: qzcj * wptm +tjnh: hrsv * hhqs +pmbh: vtgj * jltn +zgct: rbjt + vjdn +hsbt: 2 +mrfd: 5 +rglt: hrvj * mlzs +slmh: 4 +pwdd: bswg * jpjv +wlvv: rjln * mctl +ntzq: lmhg + qshb +jjqm: 4 +pfds: fhpw * fztw +nmnr: 3 +wsql: tfqj - qzhv +fbcg: qmjd + ngpw +tsrp: 1 +rhwd: 11 +mrjc: vdgm / nmhv +glmt: lcrt * cjpv +hbbw: cgjw + wsnz +cnhl: qfnr / lmrt +hpvt: 4 +dswf: 2 +lhwg: 1 +tpcv: 7 +bnrb: 2 +frlj: cfpd * gbrl +mjbs: zlcq * fjbs +tffn: 12 +dwmn: szjl + htgj +gjlq: 4 +cscn: hssb + vflp +vprz: dggh * gwmn +fzhh: rnwg * wmnt +fpmq: 2 +njwh: jvfz * rqmc +cwlv: ddtz + lffw +vdlr: btmf / wqmm +dwcs: 2 +tvms: 4 +rrtc: 3 +mmpg: 2 +fqgd: rbjh * jglv +jlpl: fmfs / zpdt +rqmm: brhj * vsqz +gnbz: 2 +mpqq: jrbd * ftmm +mgfn: pwdd * tntn +htmn: bjzj * vhtm +bltl: chdb - vsnh +qpgd: 3 +dbqv: 2 +mvzc: tvzt + fzdn +tthg: 5 +pcnz: 2 +dwjm: mjzr * bvjn +jfdp: 4 +qqwq: jqlb + whvm +bwvv: hhrg * zscg +pdmh: nnvv + ppms +bvcg: 11 +lhbv: 4 +lpft: 13 +qhqc: vnsf + zmzd +cjvd: 2 +fhtd: lrsm * lghr +mrrb: 19 +fqbs: 14 +lpgv: 10 +pgdm: nrnq - fgfv +vrqf: dwms / szzp +jvrr: mnqb * bwmb +fzcb: tsdl * lpfz +rgnn: 3 +zsdb: 5 +jthp: 3 +lcbg: lrwf + whch +frtz: 5 +fvbh: 3 +vlhn: gfvb + rnsc +cwcg: 5 +lpcp: 4 +dvjw: 3 +lgvv: fpnb + bffq +qwgr: 2 +dsfj: bjbj + rlbq +bwgq: 3 +wptm: 2 +rwcm: qhfh * jtgb +fhtv: zrsl + psgj +gvhd: tjwz + dsvv +gjjm: dgsm * lblg +mtvl: 3 +ztfv: ncpn * cgnr +wdvw: czcv * rmfw +cbcq: 5 +czts: vlms * gnhg +pdqh: btzd * htcn +gpml: ccwq + tdwc +gdzm: ghmp + tscj +fqff: 4 +tflv: 1 +trnr: 2 +gnmc: svmc * pftd +vlzz: hcvj + mngp +vhcd: vbln * tdfr +rhlv: gmpt * tbgc +mmmm: 3 +pssq: nzlb + wpts +nblh: 4 +gtlz: 12 +zgmz: 2 +dsql: 4 +smmh: mwmj / cchp +vjjj: 8 +qdqj: hbqg * zplf +bffq: fqpd + wfrm +cscc: 5 +tvpc: 9 +cchp: 4 +cnhc: bvnt * vtcj +vhlb: 7 +vnlv: mbln + gmdz +vshf: 6 +nvfs: pdhf * thsq +pghb: 2 +fbft: 2 +bhlz: 2 +vdtv: 3 +lndp: 13 +ctfm: jzpm * tcvs +nfgf: fwpb - mzsr +glcz: bmdr + vntl +ftbz: 13 +jnsh: vlnw + qqhr +sjfl: 2 +cftd: fqlj * fdqg +gtff: hqfj + mnmv +mnfn: gfjq * wbwh +fflh: zdmt * dwtr +sjpp: 1 +pwbs: tcmz + gctb +pmpb: jfcq + hzrr +zjwz: 3 +lwdq: 3 +nzbp: 2 +btzd: sqmn + wdrq +fhhg: scsc * rnqc +nwvj: frth * zrdd +snbl: 4 +drjz: 1 +nvqn: vccc + hgvz +pdbb: qhhm * qmhc +jqzz: 2 +qfcb: 2 +mcnq: pbbd + dgvm +cczs: bsbt + dfcv +tldr: mchw * ncch +zcbt: 1 +wbwr: ghlg * vmgm +vwbh: llhc + sndl +hbtl: 8 +smcc: ltsj / jzsf +qcqh: nvmj * jnlb +qddw: 2 +wshd: 7 +gdzt: bwhd + hnzz +rbcm: wbcp + wzjh +dcqf: ncvr * fclv +fdpb: drzl + gnzj +sccd: glvv + zdlb +lsph: 13 +ggtj: vftj * wlst +wdlq: flhq + ccfn +czbt: 2 +mwwh: bbwd + zsdb +rwpb: 2 +tjsv: pdfn + shlz +gsjf: 8 +vthn: dqbc * vldv +gqqj: rttb + czts +jwzf: 3 +mpcq: 11 +ljwv: gvhd - cdpv +srgh: stds * zbgr +bltn: rnnm + vrnt +trrb: 5 +jpwq: 5 +tttd: bmnh + mcnq +swrj: 7 +frrm: 14 +qsdf: 2 +jgsd: 9 +gsnn: 4 +zgrf: dhns + wbdm +rbjh: tvjg + qpjg +zdwh: rzgm + ndrd +bpcz: 4 +llwb: dvjz * gtss +hhqs: 2 +jlvd: pmtv + qqsh +rjtr: 5 +qcrj: 20 +bbbr: jzsb - cnpc +hsnb: btqc + jgsd +fjnp: tpfl * mbds +zmmg: 4 +shzm: 2 +pdhz: 2 +bcdz: vzhn * dzmw +jtth: 4 +nrnq: mjgq * fvtd +jqwn: fmvm * cfwf +bzhl: hvfn + tsjl +bwhd: tlvq * fjlj +dspc: 3 +hvzv: 2 +mcdq: tzsq * fczq +qfnr: gvmw - vthn +zznq: 9 +crvp: pgpp + jwhz +lnqc: mmrq * fsgb +snjj: 1 +grws: dtjl * tfbw +dzwp: 2 +fvjg: hwfw * jwtf +lccn: 2 +sftl: stgd + lnwd +mvbm: gpsl * bpms +jjsd: 9 +gdgp: 3 +bnqg: rcdg - tmqm +mhfc: qtfm * zntj +qbrw: srdz * fdpb +bmsj: fcpw + jhhb +gqjt: nghw * shrv +bvbp: 10 +gwmn: vfhc - msbs +hpnh: qnsd + bdzz +sljs: hfjh + vbsr +rhjl: 8 +vszw: dwcc + jtnp +lfrq: qszg + dzqz +sfjc: 3 +pdbd: dlrq + rrft +dmlq: dslb * msvm +sdmq: cpsb + nszq +vrpt: zqns + wrnn +mlrt: qvst - pssq +hmtj: qljm / jnmh +fhqn: 1 +gmdz: 19 +pbht: jrnp + scsp +gcqm: 10 +tcmn: wfwb * whlg +bvqd: 5 +nbmq: gfrp + zgnh +cfwq: gwcl + mqhb +jmfg: 5 +jhps: 17 +jqlb: mqzz * qnzd +grjb: 2 +ptht: tfvj * qhdp +zlrl: 3 +lqzb: 6 +ndzb: 5 +snpj: fdlt * fqsj +pbmz: qfsm / zjvf +lnzb: 3 +vtpt: qjdp / mqbr +wsdb: gstr * nvbj +ssrb: 2 +gvht: fcgl * dqvh +cbvf: 3 +mlbw: frlj + rtwl +hcjh: 18 +rwqr: mcwz / mntg +bjzj: 3 +fqpd: gdzr * hfrh +jnwf: rrsr * pdrl +mvnl: 3 +qppc: nttz * vnhp +swfn: 2 +vlth: 4 +bcwq: bblj * cwff +qtlz: jzzs * mzfj +mbpn: 6 +lvwn: rlbm * fbft +ghlb: 4 +ppms: 2 +tjgg: 3 +plbl: 5 +lpzh: 3 +wscv: trtj + dvlf +frbf: 4 +vwfn: 3 +vssp: gfwf + fhqn +zqnf: 12 +lddr: pmbh / thfr +lnrv: 2 +llgp: 5 +mjgp: fgrw + hwfs +rwgw: 3 +npvt: pdtc + gqqj +fzvp: 5 +wdgr: 8 +gfjq: 4 +hscb: dwdz + pncq +sfzr: lcqq * mnmr +zlwh: 5 +sdbp: mgqq + lcvr +wjjn: mrdg + spbp +sjdv: gssz + hpml +dnvb: hszf + nwvj +dffz: 1 +rnjn: hngs + gdzm +gfsn: 4 +bclj: 3 +jfsl: 1 +mphc: dtfm + qtnh +jrcm: 5 +gfht: 6 +jbqj: bwcj * qbfz +btmn: 8 +vppv: 3 +zvlv: qhpn * bzpv +drwv: 15 +dplg: jjbj + qqmb +cfsz: cgtj * fzqs +pbpn: 13 +ncvr: 3 +svtg: lhrw - fbzw +qrgf: 2 +jzzs: hgqg + jmdw +jrnp: qzrn * lfzc +htwq: rswn * gqss +zllz: 14 +zszs: 11 +qlfw: 13 +tptw: frms + cphl +rtrm: 13 +vdqq: 5 +gzmz: 2 +qlhm: 3 +bwmb: sgnf + bwgh +rcqw: 2 +hlzf: 3 +dtjl: ctdv + pdsz +mlbn: 3 +rhjv: wbzh + vjst +mfcr: 7 +msdc: tqsj * ftvr +bngr: fmsf + hzlf +mjnm: 2 +ffzt: 2 +rnnc: tjgg * rqht +hmpr: qgjn + cnhl +qffw: 9 +tfjn: dmfd * nhdf +lhtw: qffw + pbzz +vlms: 5 +qqhr: swfm - tzhz +ljbn: 7 +lvwb: vlzz * zwcf +lrfp: 3 +bjfv: 3 +msbw: dtcz + dqrf +djzb: rzdl / drvd +lghr: psbr / vshf +crjg: lpbw + ggtj +pzls: jfsl + qjmt +zlcq: 2 +lrbs: nmnr * zfhv +gsdv: 1 +fjrb: 4 +wjsv: 2 +bdbl: dslt + hchb +prgn: 2 +bjhb: lgpm + cqqr +lzhh: 2 +sjvn: 2 +fcgl: 2 +cpsb: 5 +fjwp: 3 +stwl: 14 +dzqs: pqlj * ztfv +sncr: pdhz * gsmz +lpcj: 5 +rbjt: 8 +fmvm: 3 +qwrb: fjmv / mrvp +zscg: 2 +cdjp: jsvs * srcm +dwtr: wthv * bgvh +scsp: dnvb - ncdr +phwh: hgmr + hgvb +rtwl: 1 +pgpp: pwhs + chrd +fsjh: 16 +gnfc: jhgz * dzjs +srcj: qhqc + mhqf +spgg: rcnl * lzhg +ljjm: 5 +fvtb: mjnm * sfzr +rqmd: 2 +jmqw: 4 +hvmn: mcdq - qmlb +pqcs: 2 +pgbt: wlvv + vptz +cjdg: 2 +jmmj: lhfq * zhrq +mbgv: 3 +zsvd: qqzp - zlbw +bwcj: 3 +fzqs: 19 +ssmv: 20 +lcvr: jnzs * stjp +prnn: 2 +ftcc: hhgq + ntvw +zpbt: wrsc - cvbb +wsnz: rvzd * rqqv +gddc: mprs + sljs +zvlp: gvrj * cdrs +drgt: 5 +gssz: gstb * dzdz +grwz: 4 +cwff: swjq * llnm +tlfp: zzzq * hgsq +wvgg: zflq * nbgq +jgwl: 4 +grzz: 2 +fqlj: hpnh * vdqq +ztsz: 13 +ztfh: 2 +jvfm: 3 +lbvf: mrhg * hvwz +dtfm: 5 +vhmc: 16 +brwz: ftgn + qjrv +gdqd: 16 +nqhb: zdtw * lmss +pbfn: lplq + bcqm +rntv: qtmg * lpft +glbg: qqqc * gcdw +ghnz: jsfw + ssdl +nftf: gqbg * mfcr +gfjb: 10 +fmhf: 2 +lfrj: wfdf * jmnq +cqfp: 3 +btmf: lzcr * rrfg +fgzv: 19 +wpcp: qgwj + mnfn +rfqr: fnzf + zrqs +mhwj: 3 +qjcv: gpml * gqdq +vtwf: htgt * sjhh +njjh: msmm + rjvd +pzsw: hqvl + mmdv +wrbt: 1 +bcdf: 7 +pwdp: 3 +gpmb: 4 +cbjm: 3 +wgmf: frrt * fsmq +tqcw: 17 +mbvw: 6 +srjf: prqr * fmdv +pggh: 15 +qdwp: 8 +cppb: 3 +zjct: wptr * whqn +tlvq: jsml + hhfh +fmsf: bhpt * zgrf +wfhj: bhwd * smcf +hgbc: rdzq + hgbm +zdrn: 3 +wmsr: ldgg * tvfq +rjvd: vdbm * thjq +fdlt: 4 +npnc: 2 +czsj: 3 +zlth: znrs * mbsr +phfj: sppg + rgjr +qnsd: pqml * fvrf +jglv: 5 +fzjr: crvp + vqpg +njfr: 2 +ndvz: srgh - lpgv +qgzh: 2 +qffm: bcdz / ntvp +jnmh: 7 +jzjm: cmtj * nzwf +psvq: 3 +szlm: wcth * mwhr +mbvc: 2 +spcp: gqjt - cppb +nsrb: mnvt * rrnj +prsz: 4 +rlsf: nrnc * fvfv +pqml: 5 +tqzb: 2 +pmgb: 3 +sjsf: 5 +wvvd: 3 +srpc: 2 +djft: 3 +vstv: qvrn * rrbs +njsn: 3 +wblw: fgld * jnhf +vjdn: 15 +srcb: srpm + ntmq +sqrl: 2 +fdbj: 5 +ffls: 17 +zmwd: 5 +hfpm: tcgz * ljhp +vwqm: tccw + cjdw +gfrp: 1 +rtdb: dbbn + fnmj +fsrv: 2 +vnsf: frgj + tdjh +zwzz: 3 +rtcr: twhl + nhhp +ssfw: 2 +lqtf: 2 +cvnz: 2 +zngb: 2 +pclv: 2 +svdj: 5 +rnsc: jjrp + mvzv +zrsl: bbdp * jdnl +ghsv: 5 +thss: cbjm * zwdd +tpfl: 2 +swft: hvwn * dspb +qfsm: mmpg * pmcg +lllp: 3 +ssdl: tsjh + htwv +zgfq: gffm * pvlf +hdjm: mnhw + snbl +lnrr: qdwz * vmlt +vvfh: nwsv + zglp +psmz: 5 +hgzd: 7 +bqbl: 11 +wfgq: llgp * tfrz +jlwv: drgt + tqwj +ljhp: 2 +mdtr: 3 +dbdf: pnft + swtz +gfvb: bmsj + tvpc +jsvs: tftq + mzdw +qnzq: zlwh + smmh +bfcs: 3 +rrfg: wvgg + sbrh +fdqg: 14 +sgrr: mrzl * rtvw +gvbp: pfds + lqzb +llwp: cbcp + mssw +ngnd: cnpz * ftfr +mwhr: jtqc * fgvl +tvmh: 2 +qvdw: thss + crsv +wjsw: 14 +jtnp: wgtg * lztw +cjpv: 2 +zqfz: qsmr * qhsr +qcfb: nljz * jhsf +thbr: ppfb * lgpf +ncdr: wrpd * tqzb +jjrp: 10 +hgmf: 2 +fqgp: fzjr + vfgn +flhq: mlmw / bjpf +tdlf: tfcv + fvtb +sfwc: pzps * gpvg +htlz: 5 +flmq: 2 +pftd: 2 +hntg: 3 +fbhc: 5 +rfmq: 5 +wznm: 4 +qzfc: 6 +gscs: 4 +cmdh: qvnm * swhv +dtnn: 3 +shnl: rnmz - vjvl +mmdv: nrbl * njmt +zngw: 3 +mrgq: 10 +fwtv: 4 +tpjb: jnnh + lvwb +hjvl: nmcz * wjzt +qnzw: cgcr * lhvn +scbr: fmml + rrhd +gwhg: jgpl / vppv +zlvb: 2 +lmll: rhjl + zgmz +mwrq: 14 +cztz: gzsb + gchb +rrsr: 5 +gpsl: grws + pjnj +rlqj: 3 +phmc: qrzs - hgbc +vntl: dzmt + zwdt +bqjd: 4 +bdhr: 2 +ppjv: bdlb * bzzp +gmfl: dsfj * zfdg +pldw: tvpj * nrfq +fpgs: 3 +cnpz: 3 +fblp: smwp * zfdm +nscr: 3 +jbgz: svmf * cztz +lzqg: srwt * lwjr +qwcf: 2 +jtfr: sfwc + gctg +pbbd: wvnm * gdgp +rnqc: tqlv * dbvt +mplm: zvdb + lzqg +bvwz: 3 +lfct: 2 +zcbr: 2 +vmvd: rfmq * tvnc +psdt: ptmq + jzzt +jnzs: 5 +lwcv: 3 +rlrj: 3 +mgtb: 3 +vhsv: wtwh + gvbp +mlzs: 3 +bjbj: 6 +hplw: cbzs + hhrm +vlqw: flcm - swft +mvgg: 2 +zfwb: 14 +qbwz: vjvp + cjqf +dhqh: pclv * ptlc +bjzg: 9 +hfbj: msdc * lrhg +nttz: 3 +wfdf: 6 +lnvl: 3 +crcm: 10 +tnqs: 2 +wjpw: twvr / rqqf +bppv: 7 +swjq: 3 +pdgl: 4 +mwsq: drjs / bfsl +hqfj: 1 +smvb: 4 +hfqm: npvt / tgsj +szjl: 4 +nhqw: dqrc * bddl +hvng: 5 +zdgg: 10 +llhc: 4 +tcqz: 3 +tccw: 7 +fbqb: cpbh / jjpz +fztw: 3 +rrsp: 4 +wqpn: 5 +fmcp: 4 +gqdq: 2 +zvhz: 1 +zghm: qtrf + nhqw +gsrw: 10 +tvzz: vgtv * ccrg +dwms: qnnj * qrdp +wlms: lqtf * lhtw +fnhp: cwml + pnwq +lcsg: mcmt * rpgd +chnc: 3 +fvtd: 5 +vjvm: 4 +fgld: 3 +hgvz: sncs * fttn +rrlf: 3 +gznp: 3 +mjbv: gcnn * pfzr +dtzp: vlqw / vnjt +vzrw: jfpc + zldr +wrns: 2 +ntnd: dmwc * lwdq +jwzp: zvql + vrpt +cnlq: 3 +nnpf: vmvd + vsbc +lzlb: 19 +btqv: 4 +smwp: lnvl * gbdb +zsdr: ttsz * mhdr +blqg: vwvw * sgdz +zwms: tcmn + dbvf +znhd: 3 +slqh: pzrv - qrjj +cqqr: bmrv - vdsp +mpmb: tbzf * dthz +cncf: 10 +bhzh: 5 +hqth: tlfp - ghsl +vnhq: 7 +tjhj: jplw * dfwl +pfsf: vrmn - cnhc +lpzw: 2 +nscj: 2 +ptmq: hbtt * hmjc +nrts: cwmh * hvcm +mnmn: 2 +vmgm: 7 +spbp: tnlt * dwzf +lcrt: czzm + dbdf +hhfh: 4 +stds: 3 +hgvb: 17 +wztp: fbqb - czsz +jnlb: bcvw + jlpl +wltf: pdjq * cgfp +qljm: sbcq + swrn +rqtc: 4 +psmg: tzbj - rshs +sbcq: sjzp - fzhh +vtdz: 3 +rnqw: vdgc - bfzf +lgpm: wnzb * mjbr +jvct: jwbq * mvgf +nnvv: 4 +wptb: 3 +qmlr: 8 +bfzf: mpqv + blzh +mnmr: 2 +znhn: 4 +bdlj: 3 +bmdr: 1 +bmhv: rvfq * rlqr +zqms: 3 +pslz: vndc + qgjt +gqhp: gjjm * fbcg +stjp: 6 +tfgv: mhrh + cwlp +tfqj: bfzr * rcgg +vgzv: lddr - rwwp +mcmt: 3 +rqbt: jzdw * wpfs +twpc: stfl * mdjv +vnpl: msnr * rmfl +vjgm: hccc * ccbw +nzss: 2 +pdfn: whpl * mphw +hzrr: 6 +slch: 2 +lpbw: nsmc * hlzf +vgwt: vjjm + nfgf +vnml: sddl * grdd +vsnh: 2 +vqgh: 1 +lvmh: lcbg + qbrw +mdjv: nvpt * cdtw +gvmw: hhpv * qzsc +gdvr: vwtf * vrfr +rhnn: vhlb * rhqq +bmcl: 3 +zbsg: nnpf - nqbm +ttsz: 5 +fgrw: dhhr * srnd +tdjf: twdw / psvq +gbnz: brwz * rqtc +bblj: 2 +pllt: 5 +nhrw: 3 +tcnw: 3 +dphn: 8 +pnbt: lndp * jfnj +prwp: 5 +sthl: fhrw * lbzw +tsjh: zwpw + hrqf +dqvq: 3 +wzmw: vgbg / hgmf +ttsg: 2 +cmtw: 3 +zwpw: 18 +gdmq: gcqm * jqwf +nvmj: 3 +jzvj: 2 +wstn: glbg + dplg +jltn: 5 +rjtp: 5 +dspb: fqph / lddz +rvfq: mqcv + mgvw +gcfh: lhcc + lhlt +jhrr: 2 +rcjj: bbbr / lftw +vcdc: fvbh * pdbd +nwsv: 16 +jhfb: 2 +wdjp: 4 +jgjj: phrb * vfwv +rcdp: 6 +qgrq: tjsv + stwl +lbzn: 2 +rgqw: smbv * vdjf +dslb: fvss + fzqd +mpzz: ctwr + gnrm +jvqh: 18 +cjdw: 16 +qlrc: 1 +hcvj: zmrp * sgzc +qbwm: gsfw * lfct +zntj: fpdb + fngn +mjgq: 18 +hrsv: zrwj * vmzb +vnmj: wptb * qddw +mftf: 3 +crnq: 8 +wpjr: 4 +mrsr: zlth + rppw +qjsm: 5 +mqcv: jchf * mpmb +svvl: 5 +hnhv: 19 +jpgf: 4 +nnnd: gssl + cprg +mvzv: ddpg / wshd +lvpc: jmmj / djgl +nvbj: 13 +zrwj: 5 +gljm: 11 +crcs: zwch + jwpq +bgsq: wrts + sgrr +wjvr: 5 +snhj: 19 +pffp: ldrc * mnmn +qsmr: 4 +hngs: 4 +lqrd: 11 +npwg: 2 +hvfn: lvng * csms +frdh: fwtv * hczv +bmrv: hczq * tdgw +zgbp: 4 +pdwf: lgvv + crcs +fdhf: 5 +mlmw: vzrw - ndmt +gssl: prdj * czzd +pfzr: lmpr + mwrq +wrvb: clgf * ttsg +glmz: mgfn + wlql +wsbf: jvsf * fwzl +wqmw: 4 +llfn: 3 +fzdn: 9 +jmvf: 2 +hdhq: 5 +dgrp: zgts * tcgc +smmg: sclc * zwms +zgts: hqcw - pzsw +cwbp: rqmm + gwnp +wlst: 7 +qtwp: 3 +cbcp: gjlq * crzd +cdpv: dnsc + tptw +mbjv: 5 +cdpw: mtvl * llfv +jqwp: 15 +djgl: 3 +qshb: thqn * cptw +zftn: vrzv * drcm +dwsf: 2 +cmrf: 3 +tdwc: fzjs + zdgg +gfds: lwbg * nvfs +thsq: 2 +lpsz: 14 +zhtg: 4 +hpml: bgps * vqpd +zzws: 3 +gnrm: 3 +tfcv: wpwz + wqmw +pgss: 2 +drbw: pggh * wqpn +wvbq: 7 +nqft: 2 +vnhg: 2 +tbpp: 10 +tzhz: mphf + lbfr +cfpd: 5 +czzm: 5 +jzsb: wztp * bqtv +vlfs: 2 +gjfb: 4 +pmms: 3 +jqbd: hnzb / scmf +sbft: 11 +pbpm: 2 +szzp: 2 +zpgv: rtdb + mncr +lbfr: drfl * dvgl +rvwn: 1 +nmtj: cghq + brtm +mppd: vhmc - znhd +smcf: 20 +tvjg: 4 +nzlb: fdzj + vhsv +vnqf: bwfb / vwcg +tzsm: 10 +fjbs: 7 +qbrd: 2 +mchw: bpvm * twjg +rbgc: 1 +wzsm: 20 +dmjb: qrgf * lnzb +mcgr: rcln * fvsr +gccl: gvph * lpzh +njnh: 3 +tvcv: fcfh + tdjm +bqjr: 5 +nvrc: znhn * cblf +djwz: sdvq / fmhf +nldh: 2 +tpcm: 1 +nqjt: 2 +stph: 13 +fzjs: 1 +zpdt: 2 +bgps: 2 +qgqc: hctf * gmfl +phrb: scvs - sdqt +bwgh: zbfn * gvht +qfpc: dbjp + wtqv +sdqt: 16 +lddz: 2 +mwmj: ssbz * jwzp +gcnn: 8 +sqsh: vvmw + pwdp +dgrs: 11 +lvng: hplg + scbr +fbzw: vlqc / gzzt +vfgn: cwqd * nvjh +qjrv: cfmq + mwsq +pvtr: 3 +szrj: 4 +qqdg: cddb * ppjv +bbdp: 3 +shlz: 13 +fcvj: rwqr + fvcs +fsgb: 3 +stgd: vfjf + pfsj +mqzz: 11 +vfqn: glsj * mrfb +cjtd: 3 +bmrn: tpjb * jpgj +hpqm: grqr + bfhd +npdp: 7 +wbvr: thbz + pzbs +cfwf: vjvm + qsdf +fmml: ntlc * prbd +ngrc: 2 +qfsh: fcmb / vssp +hczv: bjjn + gbnz +gpss: 6 +dqrc: 5 +mgnh: 2 +ftqq: 4 +cpvd: nrjz * pmgb +lcqq: 5 +ljvp: 14 +csrw: gmmv * hplw +bdcr: wzmw + nhgs +vwqj: bmhv + prlb +bhgs: 7 +rtpj: 1 +humn: 3951 +nhgs: fzsj + glfc +cghq: jpgl + pjmm +whmz: qhhl * sflv +dwdz: qcqh * rcqw +hgvp: 7 +hvgn: ftcc / jdvt +lgcs: 6 +pfrc: tflv + cczs +fmdv: rqmd + sgzm +smbv: 2 +nghw: qjcv + rwgf +dcbw: 11 +bnnt: lmqh * pzls +qtdm: 1 +ftvr: 2 +wsqt: 2 +qvtc: 2 +root: lntp + bjft +rswn: pbpn - wswp +bzhf: zqhq - hpqm +qhdp: lntt - cbjl +gtpz: 6 +pzvs: wsbf / nldh +qqsh: gjtf * lwvr +mvdl: zfcl * sjfl +twrj: 5 +clhs: dztm * htcp +fjmv: vlhn + srjh +gdjw: wrzn * wbrj +dzbl: qcrj + tmwh +wjwv: 3 +tflg: hmpr / vnhg +wrfr: wsnt * rwgw +lzrf: gdzt + pvqg +dbjp: 1 +gntm: wqsf * gdjz +glvv: 2 +mqbr: 5 +tvzt: 1 +wbgb: nqzc / hfrg +ntvw: mrsr + vnlv +pvqg: vstv + fhtd +fccw: 10 +sscw: 2 +jvbp: zpps + cmwv +spgf: 8 +pqvc: jwzf * jlvd +nlvd: 6 +qhbw: fbrs + fzfl +gsmz: lvwn + cmps +jgqb: 5 +phhh: 5 +pcth: szdt * ffzw +ftfr: hzmf + fhgn +rjln: 5 +vfdv: 4 +qtmp: 7 +wrrg: 5 +bprt: 14 +svsb: cqsm * zqgm +pmrt: 4 +jfvl: sddq / gtpz +wptr: 2 +nqbm: dlhh * qqnc +ddtz: 13 +qtnh: qcqd * rvgs +hhgq: gffp * tmcn +lnsc: 10 +hczq: qfsh + vcdc +lclz: 16 +fmhb: 2 +bdps: zjqs * fwhb +vngd: 6 +jzsf: 4 +fnmj: 18 +cdtw: rdph + bhmq +grhj: dqwn * zpmb +dzhv: 2 +pggv: 4 +vmjp: 5 +mmvc: grdz * rcdp +glwr: jpwq * zrbt +vlqj: 3 +msdt: 2 +vhpn: rlrj * qpgd +rtth: sqmd * dzhv +trfm: 2 +brqf: 2 +brpp: wpfl * btqv +bmnh: hjcz + jgtr +swrn: pldc * wpjq +rlcj: jjsd * ndjh +prbd: rgfr + zppc +ctsb: lncj * pptp +fbqq: 5 +jtqc: 3 +tnvv: tvms * jpfd +nrnc: pbpm * pbll +jdvt: 2 +cprg: gsdv + gjbv +hwfv: 3 +pzbs: czsj * tdfs +bwgm: cgqp + dtnh +chrd: rtth + fwhn +rdzq: ntnd + twvm +brtm: bmcl * njjh +htgj: 3 +jchf: 2 +hdqf: 3 +whcp: dfsj + pldw +mgcj: 5 +nbhf: 3 +bwjj: 3 +qmgl: 8 +wmzc: 2 +lhrw: rhlv * dcgw +tltr: 2 +zwch: mrjc * pbnl +bttd: 6 +gchb: 13 +bpms: wfhj + zhvn +hjch: gfds - rhnn +qqcd: 8 +dznt: ssqz - mlpt +rtct: 3 +cgfp: 4 +pbtm: mfjj * pptm +zddt: 4 +vflp: 4 +gdlr: tjvw + vsch +jzgc: 4 +pbnl: 5 +jsvl: grwz * llfn +vsqz: 2 +mfjj: 3 +hvcm: 3 +dhhz: grcg - ctfm +cddb: 2 +qzrn: 4 +lmfp: 14 +tltv: wltf * wzsm +rgfr: hfzj * sgcj +zqhq: mqqv * vpzl +tzsq: 3 +bfwv: wcph + crcm +jmdw: 1 +qgpm: lltd * vlqj +zrff: sdbp + wrmr +htzl: 2 +tscj: 11 +bwfb: ldfr * vvfm +gffp: vnmj + vcbq +rnnm: 17 +jzbc: sbql * glvf +whvm: mlrt * fscv +wcqv: 5 +qpjg: pnhs + bbfv +zhhh: zhgs * mpvl +twvr: nbrl + lmfp +qvnm: 4 +rqqv: 10 +wvnm: msbw + btmn +qjmt: 18 +ggzf: 2 +nsmc: 3 +ggsw: 2 +ccwq: nmlg * vrzn +bvjn: 8 +nvpt: 3 +mcwz: tvzz * sbzv +bhtb: 5 +pnhs: bclj + srjd +bhsp: 7 +hrcn: tvcv * jzvj +mlwq: 5 +rcgg: 7 +drfl: 12 +vzzc: 2 +shqb: 3 +bswg: 3 +gfzv: sjsv + npsg +szrq: sbft + nqhb +vtbv: djpp * rhtm +czph: lzlb * tcqz +nszq: wzvf * jtss +vdgm: gnjw / lvcp +tjhg: 2 +tqlv: 7 +hfdg: 4 +mssw: hwfv * nbht +prlb: mmqt + wpcp +hbwt: 5 +fhwj: shpf * bjfv +srnq: qvhb * rtcr +lrzt: 3 +tvnc: 5 +wcrt: 2 +zjzt: 3 +grcg: rwcm * qwrb +frth: 13 +bhgp: tjhg * crpg +gdzr: bhgp * prcd +bgvh: 2 +rzgj: pzbj + lrbs +vrzn: flpq - qfcb +nqzb: wvhd * cscc +nzjt: 12 +bcvw: glmz / vzzc +zcgm: ttmw / wdgr +svjl: nscj * bfcs +pzps: mczd - lcnv +lscv: 4 +mqhb: 19 +dwlp: 2 +zzbc: 3 +czcv: 3 +rhbg: dmjb + jvcw +tmfm: wscv + mfsv +tvvw: 3 +rmfl: 5 +hmpc: 2 +tjqd: njfr * cpss +sqmn: mpmp + dffz +wbwh: pgdm - crjw +hrqv: jvrr + hqth +nvwg: 19 +lmss: 4 +jsml: frtl * sjsf +zpps: 2 +gzws: 5 +wrpd: dwsf + lqrd +tqlt: 1 +lwsl: ffvr + jwvb +qzcj: rwws + tbzz +ldrc: ppdl - qmwn +wrts: 1 +dvjz: 13 +frdw: 11 +wnzb: wjsw * prwp +rrbs: qtwp * gznp +bhpt: gjpj + tpcv +vdmh: rjmj + zrff +jcwg: 2 +gpcz: 11 +rvmp: qgzh * dbrp +vpdq: rrzv * sdvd +cpds: gdlr * zgnd +zqgm: mdlt * qght +rphl: rwjl * cffn +zwrp: pwgh - pfmr +wpjq: fllv - pdbb +dcps: 2 +shrv: 2 +rthh: 4 +vzlj: 3 +bfjw: zhhh * rjtr +tcmz: 6 +jhzs: gzmz * jtfr +qnzd: hcjh + jmzp +lhvn: nctt + svhp +qjdp: qgpm - bbzg +ntqz: hmdj * zqms +cfmq: 14 +dtcz: rhbg + jcwg +glfc: lrzt * bgsq +rlhg: 19 +jzdw: fbnh + gtlz +gqbc: 5 +sdbv: 8 +tfrz: 2 +bcrh: 2 +lhwf: 5 +dmwc: 12 +tpch: 2 +rqmc: 2 +vvmw: hvhf + bdps +czlv: frbf * wrfr +lwpl: 12 +bjpf: 2 +zfrc: 1 +qhhl: cbcq * fjgb +ndpz: pgjn + ffzt +bfzr: 2 +tbzf: 2 +wppw: 18 +rgjr: jmtc * hhds +dgng: pndq + cpds +hwbl: 5 +wbzh: cjnf / jzpn +nbsw: 18 +snpr: 3 +dwzf: 4 +cfjs: 3 +dmbb: 2 +vsbc: rrsp * pbfn +fpnb: pfps + dzqs +vfjf: qlfw * sfjc +zbfn: 4 +llnq: 11 +tmfg: jgqb * bhlz +jfhm: plzs + bjzg +bpzj: 7 +lrsm: 5 +cqsm: lwsn + cfqb +tdgw: 2 +zgnh: gpgv / pqsm +gbzb: 2 +sddl: mjgp + mgtb +dztm: 5 +mmtv: pqss * slqh +ftth: 4 +whqn: szrq + glcz +rrnj: jlvb * pfrc +vpdz: 3 +lhlt: 9 +dvgl: 6 +pptm: 3 +hfjh: 1 +qngj: vhrt * djqs +tsjl: dhhz * mmtv +bbzg: ljvp * jlqf +chfb: hvng + smcz +jtdz: 2 +szdt: rgqw * gnbz +stfl: 4 +rsrp: czph - tbpp +pdsz: 3 +spgn: 3 +cpbh: humn + vccs +lszf: vpmj * gfht +msnr: 3 +ccbw: 5 +jjpz: 2 +qrjj: zpmt + lccn +sqnv: jwmn * czhf +fbpf: 5 +rwwp: tttp + sqbv +ldfr: 2 +lzwl: 8 +nzlz: 2 +gvhg: nbsw * prsz +jpnz: 2 +zwdd: 14 +wdrq: 12 +djjw: 1 +ccfn: ghsv * wvvd +vzhn: 2 +ndhs: jsvl * lnrv +tqzz: bpcz * vdtv +svqq: qfpc * zvdc +rjmj: dvhs * phtq +bhmq: 5 +dfcv: 1 +cvbb: 4 +jsfw: zdwh + dnrs +ghlg: 3 +gfwf: 7 +zshv: 20 +fgbj: 3 +ndmt: zlvb * bldp +jtgb: 5 +vphg: 1 +vjvq: jqwn + djjw +rgqg: mmvc + vtpt +qnnj: 3 +csms: 3 +lmjw: tdjf * wccw +tdfs: dvvg * vnjm +jbmw: rlfr * ljmz +njmp: dzss * rrlf +lhcc: czbt + psmg +tcgz: czlv + lhwg +pwjw: 7 +jvcw: 11 +jzvb: 7 +qzml: 13 +dqrf: 4 +jvzj: qhbw - vprz +nsqh: dgrp + mlwr +sbql: zgwp + pjng +ppdl: cfvb * rnjn +hqcw: sjdv / cqfp +qcwg: 18 +dslc: 1 +svmf: 2 +pfsj: qmjl + fjzg +rcln: 2 +dmjl: lnnn * wjvr +dbbn: 6 +lwsn: 17 +gpgv: 12 +qtdj: nlnr * mpln +hjbn: 2 +cmtj: qtpd + mrnq +tcvs: 2 +jswr: 4 +qrdp: 16 +gsgq: 12 +ngpw: phmc + wblm +frtl: 5 +qdwz: 2 +lnwd: hfpm + tjnh +msmm: jbmw * fflh +rrzv: nmtj * szrj +gstb: dllf * jhfb +zlnt: 7 +vdbm: zcfd * pbtd +fnhf: tthg + tpch +qcbw: 2 +hqvl: bwvv / wspb +mncr: ljjm * ztsz +gfjg: lbhs * bvwz +rzdl: zfcf * ppnj +zltc: cmtg * rbcm +gtvr: qcbw * wfgq +bscl: hbbw - lgcs +hgqg: bttd * trnr +gjpj: 4 +mhdv: mszm + gmmw +ctwr: 4 +dtnh: dzwp * ftbz +pdhf: crtg * lbzn +zjth: rrnb - hpcs +nbht: 9 +wcth: 4 +nrhf: fqff + qtdj +jvfz: 3 +qhsr: 6 +zmdn: fccw + wjpw +jjsb: mcwg + zzmn +ppvh: zprm * nnll +nljz: 4 +whch: 2 +sbrh: 10 +gqbg: 3 +lztw: 2 +qgjn: djzb + jzjm +mmmv: jwbt * stps +vwvw: 2 +wpts: hpvg + cbmt +tjvw: dlrd * zwrp +fjgt: nlgj * lwpl +nlgj: 3 +wqnz: fsjh + swtj +mpmp: zhtg * lnsc +dqvh: msjr + bgdj +svhp: jbtg + gdjw +whpl: 13 +qpsl: 3 +gvtc: 2 +tsmw: srcb * gnmd +fcfh: sdsh * lwlw +lfzc: 17 +jpsn: jdzb * pcbr +vcbq: 1 +qgff: qmgl + zzbc +lmpr: 3 +hplg: vbqc + nsrb +ltsj: zltc * rfss +dmfd: 2 +jfwh: 2 +qsqj: 2 +sddq: bfwv * tqlc +dslt: grhj + nnnd +lcvv: zsvd - sjpp +pfps: tlsn * jzhc +rfss: 2 +ntvp: 2 +zfdg: twrj * rwtd +bqtv: pmpb * rpwp +vccc: pgbt * vrqs +hwfs: hpcj + pqzg +hfhh: 4 +cpss: 3 +zpmb: 2 +mgft: 9 +flpq: bpzj * dtnn +hvsl: nsld - hrcm +fvrf: jpnz * slmh +jhnn: 5 +sqbv: pngs + dndl +vndc: pggv * rvmp +vsps: 5 +dlpz: 10 +bzsj: 12 +scvs: jmcr * rtct +frgj: 4 +dljs: 3 +hvhf: bthq - csrw +jwmn: 2 +nsdj: 4 +mrhm: 2 +vrfr: 2 +wtqv: 6 +sgcj: pcth + nqzb +bsbt: 5 +ddpg: bltl * nnbw +cmqj: 13 +cfdc: zpsl + lzjb +mmrq: 3 +mzzm: lhfc * crjg +cdrs: drfs * zbmq +fzrd: pvtr * twqf +qwfl: lhbv * bmvv +vjcp: 2 +bjbq: 14 +jwvb: 7 +hhpv: gqhp + nrhf +bvfh: shqb * tpbv +smcz: 2 +fgvl: 3 +mqnr: zmwd * snnj +tbjd: 4 +sjpv: mzbt * llwp +nljm: vgzv + tmqf +srbq: 3 +bjft: dgng * bqbd +btqc: 8 +ccrg: lvvq + cmct +gmwp: dgzb / jlwv +mrns: 7 +rhqt: 14 +bpzr: 2 +fvzt: zcbt + tjhj +wndp: 3 +hnzz: 2 +jngd: bvdp + wppw +jdnj: 7 +hvqw: fmhp * jmqw +qght: 2 +sdlc: 2 +nczg: fnsr - lzrf +znqt: cvnz * jfhm +dlrd: nvqn * dvjw +vpfm: qmlr * tbjd +mwnz: gjfb + cslz +mpqd: zzsp + bmjr +ndjh: 3 +znqr: rqbt + sjpv +shpf: 12 +pnlt: nscr * vnbh +vldv: 2 +dhln: 3 +tlsn: ggvq * tdlf +mhww: 2 +cwqd: pdqg * qbwz +gsfw: mpqq + hnnt +fmfs: rtqw + lpdr +pnmp: lnrr - ljbn +lntp: svtg * nnvm +qqmb: jzvb * ltqm +hzlf: qgqc * mtwd +tvqz: vjgm + phwh +cjnf: 18 +vgtv: 2 +lhfq: lttg + jbgz +pzbj: hpwh * gvqg +wwhm: 10 +mnhw: vvpv + mftf +pdrl: 3 +dgmt: 2 +fzqd: qlhm * nbmq +vdsp: vnml / blqb +mpqv: cmdh + lscv +jrbd: 2 +chsf: 2 +thrp: tflg - pnbt +djqs: 3 +jjbj: wcqv + glwr +mqqv: ddwc + zfff +mslt: dswf * jjch +lngc: bzdv * bmrn +swtz: czlg * lwcv +sdvd: tnmt + phhh +nlqz: 2 +gstr: 3 +qgjt: vbcn + cwlv +qtrf: pwjw * cvpc +lqwj: stlg * gnhf +pgjn: 5 +vsch: svqq * smmg +qgwj: shnl * htmn +wspb: 2 +fhlm: fzwq + mrrw +gfwp: ftdw + gnmc +dlrq: 6 +dzqz: 4 +zmgd: mmmv - gbzb +bfbj: glmp * bzhl +jfrl: 1 +vmzt: sscw + fqgd +dzmt: hqnn * zdzc +pdtc: 17 +vnts: gpmb + bhsp +lftw: 4 +zdjp: stvh + fjwp +mpjc: vlsv / rqvr +qqpg: sqjn * fgbj +zvbs: dhqh + svsb +gqth: gmsl * vlth +pzrv: wqts + zshv +vjmb: qwrl * mnjc +pncq: vwqj + thbr +tmqf: zszs * cbqz +trmn: 19 +vptz: 19 +zjhq: 7 +ffvr: 6 +tvqf: 3 +ttnh: 1 +msjr: 2 +vvwv: wcrw - tfzv +fwhn: vzlj * wqnz +twdm: 13 +hcbs: mgcj * ltrz +cpqm: dwjm / dphn +wthv: 4 +lghz: ggzf * rsbl +gnzj: 6 +ftzl: 3 +vnbh: 2 +ldgg: 2 +dvhs: wdvw + wgnp +zgnd: fqgp * cfsz +vsbj: 2 +swgf: zfrc + ndhs +ssbz: zwzz * svvz +zplf: bvfh + jtth +gctg: smvb * qvdw +mdlt: 3 +cslz: 2 +vnjm: 11 +nrmf: 5 +pvlf: 3 +jmjw: 5 +hlvn: 17 +mgrj: sqfc - wssw +rqht: llsm * lwsl +qbfz: qhqj + gsnn +lffw: 3 +twdw: ttcw + fblp +gpzf: trmn + jzgc +mgvw: tnvv + hfqm +htwv: 2 +fcmb: jfdp * fwzv +njld: 2 +jhbp: 5 +lstd: jfvl + pzmm +zvdb: 20 +zvql: 1 +jwjf: bzsj + jfrl +fwzv: mphc * wmzc +zrbt: 5 +chvn: 12 +wzvf: 8 +gvqg: 2 +wwbs: 5 +fqwv: cfdc * vmbf +rhqq: 5 +lfsw: wlcf * gqth +prcd: 2 +wcsg: 5 +jlcn: 7 +ncpn: vtdz * jgbg +pjmm: mpjc * tmfg +gwbc: 8 +qhpn: 3 +blpc: 2 +thpr: 13 +qqqc: 4 +ddwg: 2 +vdgc: rfqr * lvfl +rrft: zqfz + fhhg +pjng: zcgm + zhpp +fvcs: 13 +cgcr: 7 +bhzd: msdt + ldnm +wccw: gzws * ppvh +fvss: 20 +nmqc: sgtg * qsqj +mmql: 3 +cphl: 4 +ggqn: 1 +lvvq: mqnc * lcsg +mvgf: btcg * cmrf +zggn: 2 +lmqh: 2 +crpg: qcmn + fhlm +vrlw: thfg + pffp +wggs: fwcs * cmtw +pjnj: ftjr * hzfg +cgnr: 2 +brcn: 2 +crtg: 19 +lrpl: mvnl * vnqf +bfvv: dmlq / vlfs +zgwp: cbsq * jgwl +lwlw: 2 +tcgc: 5 +jsjj: tnqs * vszw +lpwh: 2 +vrnt: pzvs * dwlp +zspd: 7 +tfhf: rzfv + pslz +wrzn: pvdd + bqjr +ptnr: llhz * spgn +fgsg: jrrm * svdj +fvsr: jdnj * nbhf +vmhs: 13 +thzg: msjw * gtvr +wfwb: vvqb * vgwt +phvh: bqjd + dssj +dhfw: 4 +qvhb: 16 +wgmq: 3 +fdzj: llbh * llnq +tzbj: 12 +fjgb: 5 +wptl: 5 +sqjn: 5 +jwtf: 3 +fwtt: cshg - dpfp +zzql: 3 +lwvr: 10 +ghrb: 4 +zgvs: qgff + tfgv +bhwd: 4 +fbnh: 17 +ttcw: 3 +dtwn: 5 +zhrq: 3 +lncj: 2 +vfch: 3 +jmrg: 2 +vsmc: mfnp + zllz +tjwz: jhnn * rhjv +gnhf: 8 +pbzz: 1 +vqpg: snlp + ljwv +jgtr: fcvj * fwjz +gwcl: ssrb * rlcj +jzmd: fdbj * prgn +sjsv: bqbl * mlbw +chdb: dljs * wjwv +cjqf: lbvf - mbvc +tmcn: 5 +qmjd: nczg / srbq +wjdf: 4 +fbrs: llwb * smcc +qvfd: 3 +pnwq: vsmc * cqnp +qjhc: 11 +wjfv: ngrc * ftqq +ptlc: 16 +jvzp: hsbt * psqs +jdnl: wwvz - jvct +thfg: nljm * njzd +swtj: 15 +rmqh: 3 +djwm: wtqq * rmqh +stvh: 20 +lrwf: gcfh - jrcm +rrnb: wjjn + nftf +llsm: 13 +twqf: jswr + jwpf +zpmt: 4 +nnbw: pgwr + ftth +wlcf: 10 +cmjq: hjbn * gccl +jwbt: snpj + zvhz +mctl: 2 +lpfz: 5 +bngc: 8 +pvms: 18 +rljt: 4 +hpcj: 19 +qszg: rwth * cjtd +nqzc: gfjb * crnq +bddl: wgvg + hjvl +hssb: 3 +qwrl: 2 +htcp: 5 +jnnh: thzg + ptht +pqzg: 4 +wcph: 1 +vbln: 3 +glln: tqcw - rljt +mfnp: fpmq * ffpf +ddqh: svzt * szhv +fdrl: cpvd * gsjf +pjnz: hvsl - hbcd +wjvv: 15 +tfvj: mgrj + vphg +tbzz: 2 +zqns: 3 +stps: 2 +tqwj: 2 +qmlb: 1 +npsg: rhqt * stph +ggrg: 1 +fgfv: 11 +fzfl: lqwj + mpzz +srwt: pjnz + jcnb +crps: 9 +bvpn: fbjg + qgrq +lplq: lzhh * cmqj +ctdv: jpgf * hvzv +cmwv: 5 +lbhs: 7 +dfwl: hbwt + szlm +fjzg: vhqj - svjl +hfrh: 7 +jnzd: 18 +lpdr: npnc * rrvr +wpfl: gwhg - lfsw +ztwf: 2 +rvgs: 8 +fqph: fvjg * fsss +qhhm: nprq + vblt +jqwf: 2 +gvph: 7 +dthz: 13 +pgsb: 5 +dwcc: qbrd + fthz +cfqb: jthp * qwcf +fnhn: swrj + vmjp +bbcz: 9 +hghr: jvth * mlwq +ztvv: 2 +lvcp: 2 +rttb: ndvz * hfhh +nnvm: 7 +zflq: 7 +gpgw: gtff + wrbt +wjzt: 5 +pngs: 10 +mjbr: 11 +zgnn: 3 +fqsj: 3 +tdfr: 19 +mpfp: pzmc * hlhj +vtgj: snpr * mjcz +jmnq: qbtz + psmz +wcjm: 9 +cbjl: ttqs * brcn +ffpf: rldg + lmll +jvsf: 2 +thjq: nlqz + gqbc +nzwf: 3 +gczr: dgcq + lvmv +wgvg: vwbh * djwz +jlqf: 8 +zjqs: 19 +gmmv: 4 +vpmj: bhgs * zggn +pfdf: 5 +qrzs: hvlr + bvpn +hrcm: 2 +mrrw: 2 +sgcs: vtrz + cpqm +srdz: 2 +trbc: qvtc * znqr +jzhc: lnqc * wmls +tmqm: npdp * wrrg +qbts: 5 +jstf: 2 +hvwn: wdbr * zgbc +mlpt: jhbp + dwcs +tnlt: vjjj - dmbb +ftdt: 2 +msjw: 8 +vmlt: bqgw + hbtl +wwvz: ptrm / wvbq +ndms: 5 +fttn: wggs + mvdl +pnft: 5 +lpnp: 1 +wsnt: 3 +dqbc: nzss * bzhf +wbcp: 3 +zppc: wstn * njmp +rgbw: 4 +dvlf: qzgr / czmj +jbbv: fdrl / vsbj +sflv: 2 +frrt: jfcn * fwtt +gzsb: 18 +tdmc: 2 +mzbt: jmvf + mrfd +thqn: pbmz * sjvn +hqnn: vpvh * tshp +jfhp: cnlq + lgnr +nrbl: 2 +lbvn: 2 +vwcg: blpc + dsql +qmhc: 17 +mccm: zvlp - frdw +sndl: 3 +vjjm: cmjq / htzl +qmht: gfws - mgnh +ftgq: pmsn * fszt +lbzw: 3 +lwjr: grjb * tvqf +lblg: 2 +vlgr: 12 +lvfl: 6 +stlg: 8 +bvdp: drbw + ztfd +nbrg: 2 +rtvw: 17 +cbsq: 15 +pfmr: 2 +mcwg: njpj * bcwq +hwfw: 2 +wqsf: 2 +zdtw: 3 +dnmm: qbvs * qmws +tttp: lmvc - wjvv +vvpv: rbbj * mslt +bvnt: vngd + hlvn +bvjj: 2 +ddzl: zlnf / dbqv +pntf: dvzm + jzbc +sppg: 9 +qcqd: 4 +whlg: 13 +cpjm: 18 +jfcn: 3 +dnsc: 3 +lngs: 6 +srnd: hghr - sthl +hlbl: tmfm * mwnz +thhh: 7 +mjcz: sdmq + jsgm +sgzm: bprt - wndp +sppt: twqt + msjl +ccch: qvfd + ztsf +tbrz: 2 +bbwd: wdlq + wrvb +bjjn: phfj + fzcb +brhj: mjbv / lpwh +zwdt: 5 +mcwn: fsrv + vvfh +sncs: qjmb + qzfc +fllv: hrqv / lllp +qjmb: ghrb * mwlm +sgdz: 5 +mvjr: 3 +rscq: 13 +zmzd: sgfw * dsrc +fsmq: 2 +ncch: 2 +rqbz: cdpw + drjz +dgzb: tpbb * sdph +fscv: 2 +pmtv: vqgh + mmgq +vqrf: wggj * wrqb +hzfg: 3 +qtmg: ldzg / rrtc +drjs: wbwr + swgf +jzpn: 3 +zzcr: 6 +dghd: rtpj + pnlt +sdvq: rfgp * ggsw +prqr: znqt / srpc +vbcn: 3 +flnv: jmrg * blqg +jpgj: 3 +dlhh: pmms + chsg +rrvr: wjsv * hjch +cwmh: 13 +tmsq: fhtv + cwbp +rcnl: 4 +wchj: 2 +lzjz: 11 +cpwh: 3 +tqsj: 4 +ppfb: cpjm + ghnz +lntt: crps * ftgq +gtss: 4 +rljv: hnhv * slch +qcmn: nqft * vmzt +rzfm: rsrp - wdjp +gwnp: sftl + gfwp +thhv: 4 +hpcs: wcjm * mhww +ldnm: 5 +psgj: ncdn * jzmd +zprm: 3 +ntmq: dtwn * bhzd +bfhd: 8 +nmhv: 4 +bftf: vrqf * ghlb +rlll: 1 +tmwh: ddzl + qdwp +hgmr: zqnf * jvqh +pqss: trfm + vcgg +cvjd: sccd * vngz +mwlm: 2 +dsvv: 4 +lgnr: 5 +bzpv: qlrc + bvbp +nrfq: mlbn * fdnn +ltrz: mdql / tbrz +mbds: crdp * bngr +vmbf: 5 +llfl: qwgr * gljm +wrsc: 13 +glsj: 4 +jzpm: lstd * lrfp +zzsp: cdjp + vtvq +lzjb: vfch * gfzv +scmf: 2 +vdjf: mqnr / bhtb +grqr: 14 +fczq: 5 +qhfh: 16 +dqvg: pmrt * sffd +rvzd: zsdr + cgzh +fbjg: bjbq * phvh +qvrn: wctd + lghz +zjgv: sqsh + wtvv +dcgw: bfbj / cjvd +cmtg: 2 +twvm: lsph * ztvv +msjl: 19 +zfdm: 2 +psbr: dspc * lclz +gbdb: 9 +fmhp: fgsg + pptj +ntlc: zjct / njld +tnmt: 3 +qfcd: pntf - zghm +ldzg: vpdz * pwbs +mrfb: sgnd * whlc +rwlt: tvqz / tltr +lmvc: wmsr - dntj +rldg: 1 +wgtg: 3 +rshs: 1 +cgzh: 4 +sdsh: 14 +bbfv: 2 +fwjz: 2 +lzcr: 10 +rqvr: 2 +ppnj: qcwg + flnv +btcg: 7 +ghsl: ngwp * lvmh +gjcw: 5 +bjmt: 5 +czlg: 3 +ptrm: qqdg + qqwq +dfsj: cwcg * hdhq +whlc: 13 +hjcz: ddqh * gfjg +wmnt: 4 +pzmm: chvn * jqwp +mrzl: 2 +hmpw: 13 +bzzp: 4 +dbrp: 3 +wcpv: 16 +qbvs: 2 +rlzq: 2 +njpj: 14 +gffm: pbtm + hmpc +jbtg: fnhf * bppv +fhrw: 2 +tsdl: zzws * zjth +hgbm: 5 +dggh: 5 +jfpt: 3 +fclv: 3 +mngp: sscd + vqrf +cbzs: mrhm * mmmm +srjh: tsmw * tnzf +qsmb: wtzd * tvvw +dsrc: 5 +wfrm: qfcd + cftd +tpbb: ctgb - njnh +jmzp: qjhc * qbts +jnhf: bnrb * ttvg +tplj: 2 +vftj: 2 +wgnp: pllt * ssfw +bqbd: 7 +frms: pdmh * rthh +hhrm: 1 +dngs: zgnn * jjsb +cwml: sbvb * gnfc +blqb: 2 +lzhg: 4 +fqtj: 5 +cptw: 2 +gdjz: chsf + plbl +sldt: ntcm * bwgq +glmp: 2 +njmt: lfrj + frtz +mzfj: 3 +rppw: qvmv + fqbs +tdjh: 2 +vfhc: wlms + fjrb +fpnh: 7 +zrdd: 2 +vccs: qnpr * pgsb +zwcf: 2 +bdlb: rglt + dqvg +zglp: 2 +vlsv: qqpg + rhwd +llbh: nlvd + hgvp +bplm: srcj * nbrg +twhl: 1 +ttqs: 19 +rrhd: rnnc * bnqg +mnvt: mpfp + psdt +jgrj: rdpp * sppt +fvfv: mdtr * msqs +wrnn: 4 +hpwh: 5 +pqdh: hmpw * bqvv +tpwz: 2 +ftgn: 4 +pptp: 3 +qmws: wptl + mjbs +twqt: hvqw / mbpn +dhhr: 3 +mmqt: rzfm * zzcr +fjlj: sncr / nqjt +pqwg: zvlv * tqzz +lmrt: 10 +snnj: gpcz + wjfv +wcrw: mrgq + ggrg +hfrg: 2 +htgt: fqtj * jhrr +vtjc: hdqf + gfsn +tfzv: 2 +qqzp: zfwb + djwm +rdms: dlpz + llfl +cgqp: ptnr + lzjz +thbz: 2 +ltqm: 13 +dgcq: 5 +lwbg: 4 +qzgr: zprj + srjf +ghmp: 20 +qdhb: 2 +vngz: 3 +qtpd: 10 +rnmz: 20 +wssw: 3 +wtzd: 4 +sqmd: 17 +jzzt: nvrc + mhfc +rflc: hlbl / tdmc +nhhp: 12 +wqts: 3 +hvlr: 13 +htcn: 3 +hccc: zttv * bvcg +fwpb: htlz * lcvv +dzdz: mpcq * cpwh +zmrp: rphl + pbrc +rwth: 3 +pcrq: 4 +qrfg: 3 +gnhg: fmhb * dwmn +dvvg: 5 +nhdf: 3 +sjzp: bfvv * wwbs +crzd: 4 +pldc: 2 +cffn: 2 +vnjt: 6 +vbsr: 10 +tfpd: nzfg * fgzv +dhns: qbwm * sjsc +zprj: bwjj * czjq +vtbm: 5 +jwpq: jbbv * jqbd +rzfv: 3 +rhfj: 10 +ztsf: 12 +fhgn: chfb * fpnh +rnwg: 4 +nmlg: 2 +fzbh: jngd + mzzm +srcm: 3 +mdql: zcbr * cfwq +qrlp: 7 +vgbg: hmtj - htwq +jhgz: 2 +grdd: 2 +pvcz: cjdg + bhzh +bmjr: wsdb * dhfw +mpvl: fdhf * jmfg +swfm: bdcr * fbhc +ftjr: swwq + gbwj +mhqf: dgmt * glmt +hvwz: 2 +pdjq: 2 +lrbz: bdbl + fhwj +mnmv: cncf + cfjs +phtq: 2 +ctjd: 13 +ztpv: hdjm * dngs +dpfp: vpfm + vhcd +hctf: qlzb + mplm +tfbw: rlll + hfbj +vblt: msrj * jmjw +zjvf: 2 +pptj: 7 +drcm: nsdj * ntqz +vnhp: 3 +zttv: 3 +psqs: bdlj * vvwv +pndq: sqnv * fjnp +pbmf: 3 +srjd: 4 +nsld: nrts - mppd +dvzm: gsgq * rzgj +grdz: tzsm + tsrp +czhf: gdvr / crtp +hchb: thhh * gnjd +qtfm: 3 +wjbj: bcdf + vtbv +zdzc: 2 +jfpc: gscs * vjvq +sgfw: 5 +drvd: 2 +rlbm: 3 +lrhg: 6 +fpdb: pqwg + sldt +wtwh: 8 +swhv: 2 +hgsq: brpp + trbc +crtp: 2 +nblt: 7 +mzdw: 2 +lnnn: 2 +vbqc: lngc + dffp +cbmt: ngnd / dcps +gctb: 1 +thfr: 5 +fnzf: 17 +gcdw: chnc * hntg +crdp: 2 +chsg: twdm * vjcp +gmsl: 2 +nnll: 7 +mtwd: pdwf * rwpb +gnjd: 2 +llnm: 3 +jwbq: tpwz * zgct +zdlb: 5 +nbgq: 2 +bdzz: 1 +vfwv: 2 +vqpd: ntzq + dtzp +mpln: 7 +fcpw: 2 +smgm: hgzd * ztwf +bzdv: 10 +pbtd: thpr + gddt +jvth: 5 +ggvq: 5 +pqsm: 2 +jwhz: dnmm * nrmf +dbvf: tltv + tttd +pwwg: 11 +cblf: vjmb / zgbp +gpvg: 3 +zzzq: 2 +vlqc: fqwv + jvzj +wtqq: 2 +hrqf: zgvs - gwbc +jjch: 4 +pbrc: bsbs + lrbz +vjvp: 5 +lltd: zjgv + rcjj +nmcz: 2 +djpp: 2 +wqhz: 2 +ffzw: 4 +vvqb: 2 +sgtg: glln * jqzz diff --git a/2023/AdventCommon/AdventCommon.csproj b/2023/AdventCommon/AdventCommon.csproj new file mode 100644 index 0000000..4658cbf --- /dev/null +++ b/2023/AdventCommon/AdventCommon.csproj @@ -0,0 +1,9 @@ + + + + net7.0 + enable + enable + + + diff --git a/2023/AdventCommon/PuzzleInput.cs b/2023/AdventCommon/PuzzleInput.cs new file mode 100644 index 0000000..ada80f4 --- /dev/null +++ b/2023/AdventCommon/PuzzleInput.cs @@ -0,0 +1,35 @@ +namespace AdventCommon +{ + public class PuzzleInput + { + public PuzzleInput(string fileName, bool ignoreEmptyLines = true) + { + using (StreamReader reader = System.IO.File.OpenText(fileName)) + { + while (!reader.EndOfStream) + { + string? line = reader.ReadLine(); + + if (line == null) { throw new InvalidDataException(); } + if (ignoreEmptyLines && String.IsNullOrWhiteSpace(line)) continue; + + Lines.Add(line); + } + } + } + + public List Lines { get; private set; } = new List(); + + public void Print() + { + for (int j = 0; j < Lines.Count; j++) + { + for (int i = 0; i < Lines[j].Length; i++) + { + Console.Write(Lines[j][i]); + } + Console.WriteLine(); + } + } + } +} \ No newline at end of file diff --git a/2023/AdventOfCode.sln b/2023/AdventOfCode.sln new file mode 100644 index 0000000..7422276 --- /dev/null +++ b/2023/AdventOfCode.sln @@ -0,0 +1,55 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.6.33829.357 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Day01CSharp", "Day01CSharp\Day01CSharp.csproj", "{40E10A11-46AE-459F-8D01-BD2AE2261B4A}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AdventCommon", "AdventCommon\AdventCommon.csproj", "{15399021-F5A7-4A4E-81EB-0DFB8A328D83}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Day02CSharp", "Day02CSharp\Day02CSharp.csproj", "{8226DC9A-0D25-4A8D-82F6-B6F7768E9488}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Day03CSharp", "Day03CSharp\Day03CSharp.csproj", "{ACB7DB81-82F3-4884-9C01-F14BF6A001C5}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Day04CSharp", "Day04CSharp\Day04CSharp.csproj", "{046F51E9-3275-4857-8589-9D692BACEEBA}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Day05CSharp", "Day05CSharp\Day05CSharp.csproj", "{A1500F47-F5FE-46B7-985C-FBE0D1950D9D}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {40E10A11-46AE-459F-8D01-BD2AE2261B4A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {40E10A11-46AE-459F-8D01-BD2AE2261B4A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {40E10A11-46AE-459F-8D01-BD2AE2261B4A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {40E10A11-46AE-459F-8D01-BD2AE2261B4A}.Release|Any CPU.Build.0 = Release|Any CPU + {15399021-F5A7-4A4E-81EB-0DFB8A328D83}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {15399021-F5A7-4A4E-81EB-0DFB8A328D83}.Debug|Any CPU.Build.0 = Debug|Any CPU + {15399021-F5A7-4A4E-81EB-0DFB8A328D83}.Release|Any CPU.ActiveCfg = Release|Any CPU + {15399021-F5A7-4A4E-81EB-0DFB8A328D83}.Release|Any CPU.Build.0 = Release|Any CPU + {8226DC9A-0D25-4A8D-82F6-B6F7768E9488}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8226DC9A-0D25-4A8D-82F6-B6F7768E9488}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8226DC9A-0D25-4A8D-82F6-B6F7768E9488}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8226DC9A-0D25-4A8D-82F6-B6F7768E9488}.Release|Any CPU.Build.0 = Release|Any CPU + {ACB7DB81-82F3-4884-9C01-F14BF6A001C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {ACB7DB81-82F3-4884-9C01-F14BF6A001C5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {ACB7DB81-82F3-4884-9C01-F14BF6A001C5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {ACB7DB81-82F3-4884-9C01-F14BF6A001C5}.Release|Any CPU.Build.0 = Release|Any CPU + {046F51E9-3275-4857-8589-9D692BACEEBA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {046F51E9-3275-4857-8589-9D692BACEEBA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {046F51E9-3275-4857-8589-9D692BACEEBA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {046F51E9-3275-4857-8589-9D692BACEEBA}.Release|Any CPU.Build.0 = Release|Any CPU + {A1500F47-F5FE-46B7-985C-FBE0D1950D9D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A1500F47-F5FE-46B7-985C-FBE0D1950D9D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A1500F47-F5FE-46B7-985C-FBE0D1950D9D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A1500F47-F5FE-46B7-985C-FBE0D1950D9D}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {BABBCA3F-69A8-428C-BBD9-2621712E38E4} + EndGlobalSection +EndGlobal diff --git a/2023/Day01CSharp/Day01CSharp.csproj b/2023/Day01CSharp/Day01CSharp.csproj new file mode 100644 index 0000000..8ae44db --- /dev/null +++ b/2023/Day01CSharp/Day01CSharp.csproj @@ -0,0 +1,14 @@ + + + + Exe + net7.0 + enable + enable + + + + + + + diff --git a/2023/Day01CSharp/Program.cs b/2023/Day01CSharp/Program.cs new file mode 100644 index 0000000..51f1a78 --- /dev/null +++ b/2023/Day01CSharp/Program.cs @@ -0,0 +1,129 @@ +// See https://aka.ms/new-console-template for more information +using AdventCommon; + +/** P1 **/ +var p1exampleSln = Part01(new AdventCommon.PuzzleInput("example-input.txt")); +var p1puzzleSln = Part01(new AdventCommon.PuzzleInput("puzzle-input.txt")); + +Console.WriteLine("Part01 Example Sum: " + p1exampleSln); +Console.WriteLine("Part01 Puzzle Sum: " + p1puzzleSln); + +/** P2 **/ +var p2exampleSln = Part02(new AdventCommon.PuzzleInput("example-input-2.txt")); +var p2puzzleSln = Part02(new AdventCommon.PuzzleInput("puzzle-input.txt")); + +Console.WriteLine("Part02 Example Sum: " + p2exampleSln); +Console.WriteLine("Part02 Puzzle Sum: " + p2puzzleSln); + +int Part01(PuzzleInput input) +{ + int sum = 0; + + foreach (var line in input.Lines) + { + int num = 0; + + // Left digit + for (int i = 0; i < line.Length; i++) + { + if (Char.IsDigit(line[i])) + { + num += 10 * (line[i] - '0'); + break; + } + } + + // Right digit + for (int i = line.Length-1; i >= 0; i--) + { + if (Char.IsDigit(line[i])) + { + num += line[i] - '0'; + break; + } + } + + sum += num; + } + + return sum; +} + +int Part02(PuzzleInput input) +{ + int sum = 0; + + foreach (var line in input.Lines) + { + int num = 0; + + // Left digit + for (int i = 0; i < line.Length; i++) + { + var val = ReadInteger(line, i); + + if (val != -1) + { + num += 10 * val; + break; + } + } + + // Right digit + for (int i = line.Length - 1; i >= 0; i--) + { + var val = ReadInteger(line, i); + + if (val != -1) + { + num += val; + break; + } + } + + sum += num; + } + + return sum; +} + +int ReadInteger(string line, int index) +{ + // If its a digit, we done + if (Char.IsDigit(line[index])) + { + return line[index] - '0'; + } + else + { + // Ok read string + int number_index = 1; + var number = new string[] { "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" }; + + foreach (var num in number) + { + if (index + num.Length <= line.Length) + { + bool found = true; + + for (int i = 0; i < num.Length && (index + i) < line.Length; i++) + { + if (num[i] != line[index + i]) + { + found = false; + break; + } + } + + if (found) + { + return number_index; + } + } + + number_index++; + } + } + + return -1; +} \ No newline at end of file diff --git a/2023/Day01CSharp/Properties/launchSettings.json b/2023/Day01CSharp/Properties/launchSettings.json new file mode 100644 index 0000000..fb6e0f6 --- /dev/null +++ b/2023/Day01CSharp/Properties/launchSettings.json @@ -0,0 +1,8 @@ +{ + "profiles": { + "Day01CSharp": { + "commandName": "Project", + "workingDirectory": "C:\\dev\\DevSandbox\\AdventOfCode\\2023\\Day01CSharp" + } + } +} \ No newline at end of file diff --git a/2023/Day01CSharp/example-input-2.txt b/2023/Day01CSharp/example-input-2.txt new file mode 100644 index 0000000..04791cb --- /dev/null +++ b/2023/Day01CSharp/example-input-2.txt @@ -0,0 +1,7 @@ +two1nine +eightwothree +abcone2threexyz +xtwone3four +4nineeightseven2 +zoneight234 +7pqrstsixteen \ No newline at end of file diff --git a/2023/Day01CSharp/example-input.txt b/2023/Day01CSharp/example-input.txt new file mode 100644 index 0000000..1bd782e --- /dev/null +++ b/2023/Day01CSharp/example-input.txt @@ -0,0 +1,4 @@ +1abc2 +pqr3stu8vwx +a1b2c3d4e5f +treb7uchet \ No newline at end of file diff --git a/2023/Day01CSharp/puzzle-input.txt b/2023/Day01CSharp/puzzle-input.txt new file mode 100644 index 0000000..f7acecc --- /dev/null +++ b/2023/Day01CSharp/puzzle-input.txt @@ -0,0 +1,1000 @@ +threerznlrhtkjp23mtflmbrzq395three +9sevenvlttm +3twochzbv +mdxdlh5six5nqfld9bqzxdqxfour +422268 +vdctljvnj2jpgdfnbpfjv1 +tshl7foureightvzvzdcgt +1fourrj +6mfbqtzbprqfive +4sevens34 +fourfourpsckl47xdbncvndrthree +7ltsp1seventhreesix +8sixnmm85 +11three +fourvninelccgtkjzhhdqjmnxjbbkdsnine6two +three8seven +oneonefour7193eight +8jmqfhmzf7 +5nine8 +eight1qlfzvdtseven1threefour +5slbnsevenmz +8sixnzfctpblt +xthzlbsjvz4dlg9fiveseven7seven +fzqeightwothree1qhjtmfdsmsf +74ninesixfivermkvh +five7xshrvvxbjtwo +22threepdtqbceightninesevenvrsct +4ttbxqm76fiveqcpdptn2 +five3nrftzlzrqpkrxgtwoqplpgf +threethreeptz4 +755hhmsrseven +sevenone1 +two7bsnxknseven +threezdbbhkrnrq4seven +eighttwosix71xb +fourtwo86one4 +nxsvfqlpbtmjnjn9zkvhdn2zpn +37five4mrkcjgtpldsixtwo +cjbhbxx7v +911lvreightfour +6qptwo36onefour +fscrbckvp8threemrjmgvcfknfourseven8 +four48718hfour +kbzfourdfxdjmmn9onefourhcxbgnlthree +ktvnxthree6pltdv8hqhkcmcnfj +9qgnmdf +ninefive2 +twobrcdbnninefour85 +4qsst9pnvtxfcrpbgt4 +65cdxrjxqhbr86fourvvjvsdgl3 +mpfsmd7five +2krzxbvdgmfourthreeseven6onesevensix +eightone16 +zcslhb6hfsixnine +four44mrtqqsixtwo +two9gqfsk2six1 +1zrkpqvtfhm3five4 +375threethree +dmnjsjbqcvvqqseven3twoonesixcrdjglhdl +kpkhplpf8seven +zhk9ninesixbsfrg +34four +sevenseven8 +tlppzmxvgjnine9sixtxkpdone +drrzvjcgdxqmtmxffrftkthhfbqrpxmfiveseven32 +eight4mscvrpr7 +sixqmndjctlnxs9q1three +41mfqk81eight55 +jhmhqzcsxfsdxkx5oneseventhree2z1 +6three6k +6nine887 +hdrtcqn7zrsnrsbpxgbbsjzd +hxdvfnxd1sevensixthree1eight8six +eightn2 +sevenqlcf2fiveseven6266 +ttwone4vgtsrcds +four36 +52zlhmm22seven +lpblvxfivethreebfslbtfour6eightone4 +4cbr15two3 +4bvxjzhbdvmjgxlqhk5cxklkx5 +d392qsfpkbvhlz1jkcfkcjnsdvdknqbd +zffmdgmqzzsmzdqbhgjt8hhxzqvgflff22cfrnnq +555onebpttwothreessdtlhkzfk +7jsvkktn +pxslsbnlhj6fivesqdf3nhkmzzgdkckfsbxvgh +snjqcmpqf1threevxj +5jkcvtsgtwo49 +blbsmtgjhthree9glgchhmrlnrvcvf +jpdvqhxrrdonebmgdbpkcj8sixfourrkrllrcv +6five3smn3nine +kptrrdzxcninesevenfiveeight458 +fourfour171twobfqcvdpx6one +pqrzsmqls294 +bx7 +8eightthree71fourtksmgxcz2 +eighttwosix8mtpv +8ninedrjxsbvhrsqvdpbrl97tdkxdjmq9six +59twonine7ninenineninehsbqqzlr +five11 +6cmxnnmzmsk4lqclspone +grzqrbgtb2hztgffpzqflsqhzzdlzmktqbnjone +mrmvfive37two +three5ccvghbkp3mjrsfkbpn +three94oneonethree +mhoneightfivemdggmcjqgv7tlqkmhhxrjh +twodfbnnsfgnjc7fivetwo +sevensix8vfvkrxninedlxdjjmlvp +258 +phl9nine2fivefivenzzdckxdgpzrzqbkx +sfmfive46one +fourtwo6zjtjmtdkfzmltxdhltdzrtqp +429 +one3bzzthqjgl1skhmqvrtffpzqch +one7118 +fourninefivexzsgonefrmxpjx9svccseven +vqs3fourninenine +scchxmzbhqptt5 +seven3threetwo3 +gqdbqxbctkdbxf9zonevk6 +one5dxhfrsrsz7fivesevenseven +51m +twoninedfdshzcqrgvrkdrjmlqvqjhsmxlmfrhcdtbc713 +twofivethree9bccssbgqnthreethree +three76hpkzttdhgj +7dsseven1six9lggkdzrmjtwo +dpxg7threexfvxjsqzx +9191eightninekfcspxskthreethree +seven5five9hrvznqxn9qtqxghtgp9 +gm8threefiverpbqkf5 +8three3eightdgn +27nineeightninej +43fiveprxftkhpszrgsevenninebncn +threeone7drmqtjnine2ninerjbrhtbzfkone +zcplmpnbm3 +gllplmbp57one8fxpqbhgbln +xlxfkgjvnnpbvcclcf18oneseight6 +51pvmcdzbnxtsevenqrvmmfhchthree +nine6fdzrjone +77sixbvlsfninegjq +7hstqmscrqseven95ninerqjb +fourthree8jfnqbbztqsevennbllxgflc5 +four2threedrdqcqsbrnsix +one5onedplktrfb3mphprnfbcnineeighttlb +8five1mscqbplsltllmqjkkcfzkh9 +73nine +one98hmlkqlnbrnbzxjd +three8onesixmckhzrlbssxhoneonexftkn +6pthmtsixeightnine8one +h516nine16 +six83zsqd4lxqzqgcpd7twonehlj +threeseven4five35eightwont +sevenfour3 +275779 +pftjgl25 +eight5oneights +oneeighteight8nsnzphnmspkjxzdxhvhkgrl +9ninekzhkh2lfdseventwo +6two81fivethree +sixblhfvjfnm1mfmnpvqqnqshthreepjlzvfour9 +45spmbfdgdhljpdoneqclcqzccjndhqkthree6 +34jhrxkrtxf +83mgdntfnhdj +sixdtzllvpkppvlxhpkfive8sevenmdzpbnlcnfpcltg3 +8krd +threeqxcx8 +mtrssgmf85onesevenbtpmvptmjk5 +cgjlmfljxm98three4 +threehggmbtmzjceight11 +mxhhvvptm95two +8oneqcht3 +zjbfive6vvrr +1mbxsvmlveight7six645crtjb +6vptgkghfgzfourrsleightfive2five +onejcqbtfivesixeighttwo8 +2eight2kqmmbsbjvxtvjhponesixtwonesn +8pqeight +38mfhtq95ntvbmpthreexxg +six2zhzb4dhf7threeseven +jskqfbsct51seven8fourn +jmlgbbsqtwosklzkz6five +spngmplhchpqtfcksix1 +fiveqvsjlmlqmjzzhktkstwoeight3five +threenbf6zhtwo95nine +9ltqfqqxdlv +two6threeseven +xbgzgqfvgone4fs +fourfivedljcgdjrjzqmjbqqrctdvdnbjszszgpfour1 +82foureighteightqfmxfkvvmr +991pfoursjb +deightwo7sixbtxpv5qjfhkh3 +482nineznmhcqhmrmbxztgkdfour9five +four9threefiveeight2eightgcm +738 +6tfive9sixtwofour +two9fourone8 +5gfnine996zgsnvjn +8hpgkrndtfourtwofive +sbvxxctttjmkchhlbnine8seven +l9 +hm6xdmone5jzhppnlcs +five664 +gxthreemvrm5nine +tjknbthreegjs8ckrrqmffhfour7 +two5bbcszdzvtpprsgkmteightfive +plbtlpktcslgggpznine8sevenonejmsvg1 +87two85seven +5fxdb5sevenseven9 +zgpbndt6one +7239pztpqfkf +768threetwocfzcvc4sx +pbvc34sevenone47 +68nine +kqfxgjpnttwo84one +eighttxk2psqlfzf +sevenshrqgptpfj88fhxgmkkz +7three17one2 +pfmxggfx8lgvvln +39tsix7bkbfzqqx +gtmvx3485mjtrdmsfxl9 +7twosevenfour9seveneight65 +ninehscl531 +82rseventkhksixj +vzjtwo6ztbtjpllptmznhxcnljf +xrjnql792 +53twofourtnbfdhhr2xbsh +twogrhgmvhkgcsj2two +bxlgbpnvpkrphcp54pqjhndjfmf7 +hszmjxgjfcnine7 +sixsix2 +688qmpnj1vsfiveeightmfrd +one2sixmhmlmbghfeight3 +5two4six1twosix +58459nine3fourseven +72nineonedtz88eight +4lgjq +lvstjk3twoninefh +eight161652xczvqcjhtvxgc +1seven5zrkchldlfxvzrqjgzg8bl +ngfkczcrbrfvnsevenf4 +six9fiveseven21fourfour +onecsix1 +8fiverpnktj +5eightfourmjkhskllbrb83eightkrtn +hqrkbrcccd5 +sixjlcncnfivexqhqdbkqfour8 +72two +one8sevenfivefour +drgznqtjdfive3 +2vgpfdhseveneight43thtnthree +2kfgbh17seven5 +bclqfgsdvfour9five +seven48oneeightwon +sixthhzzffourfivervssxzncxcthree9 +ninefive8 +49sixnine73cvzgvnvvjqzmht +sttbtlxgxfd69threeoneqbsmdsbpbfzpfpmf8 +zmxffive57 +dncfqshnpgmfmnpqfiveone4br2threeeight +8fivetworps +two2twoeightnine6 +kttfsevenfrspkpsn8cscqgvthreetwo +sphvhseven1mcone8 +qmtlxml2onetxsjdnprxlcd7jfncngfsv +onetxjrzhnb1fxnlncstxthreelsixjlqhrnjhgt +tdftgntv83433 +sfq4dvgbmrseven6nsmxfgzfh +fourmvsgfvnrpp7one36hkfcmd +528dfbr4six9 +threesevenfiveddpmf9five1four +76ninehfivejseventhree +7ninelkkdgqzgksixlhdsmvvhvseven5 +hrjgpzlggnine4two7 +2sixsixjnsfztffone7tb1 +6pjxcpkpdh +84jsnmmllbzsseven +2three572ninekn1rjqg +sseightwofivenineonesixsix3gqxcnztsveight +nm18sxsrgmkqsfrrcqs +xsvgrddftfmt1nnmzndpc +lx5jlnbzmfeighteight +fdfjhnrhdbpskcpgqjhbfjxsx7 +twokxnskxseventwo2xlmrtphhkvhznp +two3mbfczdreightmxfr85 +rqtmx2qrhhqfmvonefour +59fourjsblcnbrzmbcgdzpnrqcptn +4ninexpjzqsjsznqtbclcplftnfour13six +onekmj58kzvs8v +five2nineseven +1two6jhdzt +2n +tlsbhsr1lhnjhbthz3hkgrlglzsix8l +sevensevenngkc7 +4rxnlbqs +jlsg8ftfpmmlthk3fourzqmrcrx +twosixtwo94 +825tpltn1ssszdsdklbrjn9qtz +seven96seventllvlfxddqjvtft58six +seven9ndsdnone +rrdmxl1 +fjhlhhmmsklmfhrrjhvgblgqqhtvhfpzlgshcgvh445 +6threetrsp75twoddj5 +gslbmxjn9twofivefourkbvdcpxrz4fivejbzhxjk +hp6vplls1pvhscqflc +one91oneeight9ninesixtwo +vxntwofour1 +fivexbslqmnsixq8 +8eight8two2 +524 +8five8rlkbjdsixfbqznnfive +threeseven2fourkkmhgmt +sbsr2nine52seven6 +hxqqhcxzfour2tpbkkzpndpkthreefourfour +eightnbtthbztdtdv87oneonetwo +eightninesevennqdx5 +ptmpmmh6 +5svmgf1 +2mhlmtbfive +sixfour883 +x4eight239fivesl +kqjzgkfs4txmfmn +twonine6hjfzkdk +cntncrvfour4mnd +fourhnnsksgkskq11two4 +eightdhnine25 +two7lhbqh +jbjgqt5threefour44threegcn +37eightpkhjshdg +1seven9pqmnsix +361rqvcqhv5zqzshvrffjqp4 +lbptzzf2ninezninesix7 +xvqgxhhn4694vjfdmnnine +rhqjjxbn68 +zdoneightone3tldkfzzpbqblm12three +sixnine7vss8fflxfxvvj +kmpsffxpsxjbdkphpfour8cseven +5hhdbthreefivepfmonesix +7six13gmqvfcxrbsix +twoxtqbsbsxtdjcdzqfourrrtgs86 +52zdbph3kdtmpl +959threethree +bckxnxxvmhbz923fourthree +seven2lsjr +xvspjhcvpnine8sevenqjvzmjbzseven1zone +twogxgz2onefive +9qmstrkqpgqzkxbbprbsixjk3sixsevenone +4vzrjdvbkmlhtwo6mdkhsixfour +oneone2eight9zszpvnfgn3one +httbg6nztnlpgdgf +qlxrnfclphthree5zbzsrszbc6 +ctcvnkckxtgsg1ninefivecrpnqmngqvnhmqcvn +9sevenfivefour +6pkvvone3 +6nine2sixeightthree4 +9qfivedrpfmxfbskhfstwofivergqcg +955mztjrdmlstwo5onedcrzz +sevenrxbnlfpm6twozg7 +four1oneseven34three3 +ninerhc5qninefivebndtqdjrd25 +lsbx5bhlrjfdrmblnkl41576 +dvzbqqbd4615fourbjsmpvhllhjpzc +657 +4ldkzjvdjfone +nine49seven +4kx2rnmpjnheighthjkxpdstb557 +threeeight34three59 +twofourrv48fivetwosevenddcdm +gkpzqjk89 +341 +two5pnbbmp +nine3btkkdn6 +339 +5gxcktphmzxjdtsb8 +8dhfzjf832 +bqlv7klbrbsfcbdhpcb1eightone +fourcpl5mnbtzmrgdjhfl +22hfmg1 +fiveqxtkfivethreesix5mzhj +qfmfvbks1three3foureight1 +twoseven8ntkbkjmtxrb33 +5ninensvcbfb +nine2839kffmnbgvpzflmbvfpg +34six2fivebdvzlbdqkl +7three8five +ndfrcqjrn3foureightfour +one8pfpnpqxt49fourcspbbhlpszkxd +qrmxsvjsnv2szlxhfour +mpjninesixsixmngjcrphthreeseven6two +vmponeightfour5 +776 +22twov7354one +ninexffxsqrfourcsvhgj8eightthree +nghjjvxldbznlqdeight96vhhgslrddvfmc6 +3sixbjfvtgqp4 +rrqlrfksk9zpvmfqqsgdonesixseven +six1fourqhvggsfdzfckntmfbrhthree +one47onesmdhrtjhjk +seventwoptwo7gtfzvgknbone8 +foureighttwo2nnnxljzt2seven +nine66threemshnrl +9tbtkz98lhlprtwonevn +two6two9867 +8foureightvflcsxxblgzcjmdkllblvt1 +fourzlcneight5 +tltmpnhmrbhnntmjpfkfourtnxtmtqnhrsone9 +838lqcmbqqrdgsix +sixthreeeight9grr5nine8 +oneeight4six68 +rppnht6gdrztq14five +4xvgv72threev +fournine2onenine2two +9dhksjxmct23ninempcqhroneeight3 +eightvhgtlfft4threethreecgnpzjf +sfslpsixthreeeightcqnlpsplvtseven7nine2 +drr2 +twossevenhtffztninehkgzvnmgrn7one +three4fourthree6eightthree +eightpkgknqhfour6 +28onethree25 +1sevennine6vkrqnxct +786ptjbkbf1 +ninetjvnxqkphrltpeightthree514four +376mgfkztqseven +3threeqqvqxtvsnjvdkvpnvhk +8rqxcrxmkxczzfkqkffvzcstwosrtmfnzmbf5eighttwo +two93 +854 +29fourhnmjvlseightnvkfbn61 +6zslckzztm3eight +sixfive1 +xzmlzvhcfk6seven8fiveeightpxbgkcl +seven33bdrzdtwotvseven +seven7oneeightthree +j6sevenzjbf5eighttwo +onegjeighteightttmknmgrmx1oneqxxfgone +fljrjlk4sixone7five +sevenbvqxrx27five9eight +bhdfblngngtkq4 +3sevenfivekpgnine9 +nineonelqppbgtgsnine6five +fdmqs1two3twothree7qdhbmkqxf +176pfmhfrgvsseveneight +one974fourdhvbbvfive8 +crlfbone3sevencjcsix +rdgone8lrkhggmkttlmhvvxhvxpgkkjfllq1 +7xtlstglgnqoneeightfive +onerjcplltnd1seven +gsqtjxhd8nndrkjxgmhzdmflslthreetwotwo +jrspjndsvk1seven4hx +5lks +one935onecmfrqxjxqq +9npxbtsfives2 +9one7bghdxtv1 +1khgbtlhxnsevensznknbbdrvgfgpfour +2sixrzlcqcrmgsxsxv +sixthreezqbrlnngnpbbzp6 +eighteightrkjphnngh4lhrrdfhbx +cqbsglsixfiveonetwonvzclvsdgnmmkmchrml9 +7gsqfourpht3two +sixsevenfoursixnine2ninemrgnlmqd9 +9eight2eightsixfkzlmrzqgt +onethreeseven4 +6seveneight +7rq +jmlbxtsxj265qssfhtlgx9 +three22fiveeightfdpfthree +fiveninerflxggpvflnine5dvgcl +2q2twolxksmntbxrbt6 +c6mvlmhgbztpjhlsm2bhgnxtb65 +4six3six4twoonecchglvpf +1eightvvhtdtwofltvfx +bfnfhrlznxzszzdfoursljone922five +g9 +hczxfzlhjntwo7ninesix35 +8ddh3 +3pjxlfour3 +84tcc2oneightdz +two96 +8mrxsdltwo41onesix6 +four1cjqeightvpghbd9qtdkjfzmmjcslv +oneeight3svkfzqh38threetqsxqz +four1dfhhhnhjcsdzhqdrthreethreeqxmjsdnv +99eightsixone3three +995432 +onez6five +6sixtwo +xhsmjfkgpninesevenfive2onepnfivefive +3xvfdxnfzkvmnfvvrqjqzkkq6vrxdeight +fourfiveseven386 +272pcvttjzdzzonegtsxqntflkppfive +tone4mlskzchk9xgcht +xqrkhzhghptwo18 +two25 +seveneight9 +86three6bfmdkslfmxnbqrzjltwo7 +6vclgmphzt7twovmvvshtslgkng6 +twofourfive2nine34rmljd +two2cjjhrtxtvxntdzxstmcsixrfnzfsdmsninejkl +5ninenine9two6 +threegsmgz4three86seven +five8tkdqvkmjqhdrnv9 +gsjhgthfqpcglnbpgfk83three2vnnhlr +1three8lxqzdcjsix46oneightjhb +rhlbq9txlkxvninesl +six4zldvvgjhzhszrqcdhrm9 +hlsqmddjmeightlfcrqkkbnssnxthree6four5 +gps5eighttwo93 +6four3eighthvhlknbxdpseven4 +threespxdrjqsevenseven75pxxmphbqfhvvdtp +four8nhlsqdlgnone2seven +vjcxsixthree2hspmmpqnhrddseven +1tmrz8xfgtvtqmcrninedbpt739 +knjtcfive1eightknnbxgmsix +qbj9 +fivefsrtdfcddfourtwojxdlmxczkljltbrct8 +jnggmc4fourbtblkhzfnnplggfive +96seven641 +pvvqsmtqf3fourdgqrxrtxlslsone59five +five567 +two6nmhbffour38 +rhppzxndqrhmrxlvhn58fnseven +ctgjbnine9ninebkbone4nine +threeone2sixpldcvhfpfourz3 +jxxgfvzglzrzpfk7stplphbdone8eight1 +3zvpstzgnz4gnfzdhnvvl +eightthree88sixtwosixbrr +seveneightqjncs4vdqllkvmfr +1five653sixonethree +ninehkdxcqrhszdxbgvjjkcvfmzzbq5seventhree +bttqsrsz6four5tdjkmrkcqb +23one35three +nine4five +8jhvnq1foureightsixctfxnine +mscdbpkzfptqvpxd7 +7bmfvmtmjm +five66btxzbjmxhqljqclkponeqxcq +5jpsnjbz +sptwone4ffcqgfvzmsevensix +27sevenqxccm +bpttwonine1vrkhxkxlvd +six6rpqxbhdlgm4 +3threeppmfsix1one +dnhbjkmhbcbzkcncmjcrmkrhmhtwo2qxblfsgtwo +mpztn5 +8hkdnzqqs52 +szfsgbgxmlthreefourtwo43six1 +two5lb +mv1three3d +gfqn45 +87brnjzx +zzfszvk6five +3shknsmbksrxtkqdls6fivegfive +5xtgdxhflbnrq +onelbrxfour6 +one3six +95vqkfive +lnsl6sevengxlbqqrlpdxmhjbnc +vkglhnqxbffll6pseveneightninelgkqv +sevendsix3ghjrlkhlkqztkksvvsrqvhfthree +ssfive8vmfdbfivend1xjpnjfbxxtwo +8eighttwodxpjeightvzqzpltldclmbkj +817rmdzceight3seven +49ftonethree9 +eighttwo5 +9pdzqxgpone11ggnksvvcgg9seven +jjljrfmdxg1fivetwo2kglgxjbjvznrb7rklzlhnpbn +srkrbfseighttwo8 +dsjxggrzsnnine1one1 +798xgsix9two +956six +5pnprseventhree +46cpjgjxs +7kpxxmmbrvm8ptwoneqht +3lfghbcksg +72cdcznmtsg2fiveone +sevendvkzjsmsb8vmcdrxgvjv8fivenineeight +3xvdjgnz17 +zkss7nztwo97oneightnj +ctgseven5nineccmbmdkgxmeight6four +five3mfkrhbzvf +5one55vjsgpszbz +zjbzghrbjh8fourrlpcfrxc +sevengndftmqsxfjdzkjzvtwohzx83 +7xpqmfninesevenfdeight6fivexqfj +hfpbkh325xg +ninefivekcsxrvjvvc7twogqxhddnine +ssvfgvmmv8seven799bnmn +fournhvbhhx9 +sixfour8hbzdbkmzqj6three1 +fivemxhmgvxfpsxm4 +sevenseven1srh7 +eight4pnsnh +4gbskpjhlptkflkjgzxlxrfskxxlrxvf +xmj7cngxjrnzcstrbrjsixfmqxnqnljqthreexsnfptpvd +qceightcplznbthree6 +ninebmqthreesixxfl3one4 +fivelb8four2one +9one5jpfourfour37 +sevenfourtwo6zknqzv +twovbcltvfcv1ninechcjrc +seventwo1five8mdxhv3three +rqtgxztqntznineghqqkhfzvhmf1 +rloneightseven88 +7five81one7 +ninepgnzpfktsslpmbonej6d +ktwoseven78jhsdkkbptptwop +six7nineoneninenine +jtcqdt1 +8fivetcqdglbnbxone +92sdvljhqdt6zgmgsznfchjnpn1 +threefour73threefive1 +jbhqh8phjqmm +4jlpncphmjjtthreethreesixpmpttpd +tzxpfds4two4one7sevenjbblnlsl +fxthhmseven4eighttwo +2csbxskpqzqkktsv2 +xjfjmvtkjfoursevenone9xbrl7 +3ninekgg +8fkmzjqdntzone43fivethree2 +4nine2blkhpjgpnone +3six66foursix +9one1 +4mz +2fourfourone +33six2fourfoursix +8j +59trgvlblqbk35gjeightnine +fdtvfddzfourfivepnrvpr2two3 +ctninetdv26seven +crjtlxgcbgfr8sevensix +fourfourhckrdsqkq8eight +two24kdqkzgffpxkjngj8657 +foursdss33seven9zcl +bhl2clcfsqnhpsixjxonefour5 +545vksixeight +three35five7two +sevenmkddhdvqmsthree2five +7zmxsix2ckskqcglhtgthree59 +xvsthree9 +22q +ninetwo3threenineeight8dzfrf4 +cqnbzgtjthreed2 +76jkpnonepbvhcdpfd8 +sevensevenmjrzvbkkknkfbq2seven5vms5 +threedeight8znlvhlzpbzvhvxxmgdt +cndxthxtvztwonlcqcshvnclzvxmsdrtn1 +hcz8vnkrrkmgpbxk2nine +5h5oneeight3 +5m1five99six62 +l1eighttwofour +2ccxhrlhjbr +tfpzvqj4gs9 +6twosixfivenine1 +8zjsixqnrzlfxdhm8fvpfnnjxhhpggjtjnsix +jzmgdcptone3hqbhthree +jvqmsixone2hlqseven7 +f9eightqkdpqlctcmmzx +98fivethreexgl9 +4bvztrtwo +fivetnrqt8twokfxrsftsnfour +onetwo33threenvng +sixvznvnt3scseveneight81qjdbj +threenine1 +47rjklmqqpnthreeninehcslqslrbjtwoeight +8one1twotlsgf +qpzvxrb242sevenrlssthreethreem +eightthreethreeeightxxrz3gjmccv +862seventhree5one +hjjx3threegsmggrfb +twonc4eightfour43r +7cblplgthnineone1 +fxzjsnfn2xrzfhrsq +one4xbvtvtxvqqmgnm9jdjxbmdjlldrqtzhrsxqseven +lmgtwogqghh9five3seventwott +oneeight2b +4five2525fivembnftdmkxzmq +3m4ninefoureight6ttxrcdgnine +threeeighthcnxpqfgsvv12rkd +gntcxfth588 +sclktwofivesnxkfq7twoxdvlxgvtzjtlgfspzk +rg7 +3vbrgrsevenzgncpj55nine6 +seventhreefiveshlrnfnqjvd21tldlrkjmtwo +8scjnkfpklljchzszvvfourjpvmvmgr6 +8fivepdlqzrsllkqkqnine9four1lqgjz +qmtwone7six2one5 +xrvhsvkvjb2nineleightwob +ninefourhkdzxrgxxhfmsninedlddz5nine +1sevenhslkkjfxz +seven5six94ninemjvv +nine4three +onesktp3szmp +cqconetwoninek4sevensix +nine892fouronegxhscsn +4mvzntcldzjxbmrrtzsheighteightbhtknp9 +4nineoneightfl +17kdhhcnvnnq +ckmqgt16gs +threefivefour9 +3twofoursbzpbdqlj5 +qdxzfxdfnsgj3twofour8fivefour +4xninesixzxkbqsgvpf +fourqthree1nine +one6fivenine2txbfgfkxzfmshmzhv4eight +9lhdxrmvfive +xktdxtwo71 +225two +two3csjhrszsfdkqmxcc3ctlhlbk4nine +bfspnrjxsgoneftk1665 +4fivefivecsbqnljgrk +8xmkhgonefivethreethreenine4zbh +nineone3twofour +pflpcxx7two1jkzqmthreefive +ksnjdtfhrnvcp2six +sixrfsrqfbdvn1c +sixlfmqfsnnnzhmqbngct2 +x9x7sevenqjn +eightninethreeqttkfm1seven +59zx923six +5rnrdbmpddjldqjnrxsdsrgpfive8 +one38432spgsfkjzeightxxk +95csptxbnmdfourmzqccclqjzntftgmskvf9 +tlbbjckfnine6mssscphp4rzndb5three +4sixnineeightztjdssbflnine +dzdftgcnvvrx669 +6six7threeh +eight7onelsrkgtkgdkgsntwosixonedn +4fourfourninenine1 +rtwonegfzmbhjbmbsvf3seven1 +3czkzzzvqbt5rmdskr +9bmponetwo +ltvcjgvkqqmfivethreeeight1jls8 +14oneeight3qtkgbpsnseveneight2 +dmrgm4 +twodlxpltlcxxks5 +tdxfeight3pqdsz35 +6hvfbrqccktfqhnnineone7btwovmgssfts +66threedrsbtwo +prbsfivetwo21ccqb5qhxz +nineninebkzq829fzkd5 +pddtlrsj7twonine5two61seven +threeeightctnkhjnqm5sevenvdjqsjpknmmslmdb +76nqxdvzrninefszr31 +3gvgclgxbvs5eight68sixnmppfhcqhbmzq +1eightrkninefive9four +3hfour375three +eightthree54sixninenggbmckqk +zbtqlmfqmbdxllqpffeight9 +1threehxmlj1czzlphp +4four7stfrr7 +four6htkfsfx3qlk41seven +qsixndconehconenine12 +sqvvptnzbqdmgjlmctqzhlldmzthreefour8 +f6ssgkone +twofive8kqs +foursevenxj6two +rqlqljzzdrzq4 +one3ninefiveonesixpgjsnrvnine +jktfqdxpfive3bhhczvnfive +fivedtcgstrzg7five7seveneight48 +7sevendnqnine54fivecvhzf1 +9fivebseven +nine9mjbjmmfkpxdjhch87hpzx +fivejdqrrx71sixbone6v +2qkkng5 +fiveksvzs3threenine +prtllbkjhxjhg4 +fctmfcrmqgq78rckrfq99d +9seventnsrsbxftwothreefgpzznbjcxh +three34two +ggvr32sbmseven4gjfhqstzq +threefour4three +two6sevenpzdvjdlninesevenfour +pgneight692vqlnhmndjvlj +six8sixqclbkscndtsfczqxhzt9bsf +fivefourdlrjnbvbnine3six72five +4fivefiveglchzczdstone +six4two +7threefoureighteight +ngjpztzcshbksbzlbdnqnine4gbdsbthreetwo2 +39sevenseven +sxcxnqrskgzkzmrkkdbxjthone3 +1lf9onebg +9lgfxnfffh9qbdxdl65fqlsjgdljrcn +37three1twofourfive +92onegdcczrfrkztxttftv +fxzkfnrmh7fiveggfour +14fivetwoflrr59 +7sixtzfpxrfrtnqxvkcgtc +drmjeight1sixthreeeightrxqjknmql6vzz +bsmbtp2 +ninetworfour7vgtvfvbv +ninethreesccxmtmbnnine2eight1five +47twothreethreeonethree7 +ftqjtwo7dbcnfdprnn335 +d5three5b +5eightfivevnf4one +1dgtwojfxnqpc +sixsixone7cpxpnzgeightbvx +33 +7sixtwo4zjb +pzfxv57one9fourfour +9two8 +5nineone1 +one6five9twotwo2vtnqjtpxxr +6threehhrmtfsgld +lbdjsslmqpspxrxqtp186rzjfour +six4qd32dczd3 +six5sevensix6dhlgzlfvgkthree4 +rmgdbsvqqnt7five +8slpfjnhtggzpqr7q8three3 +fivecmsjjhxhh6rmvsnlfive +2onejrnnkpkf7sixsixthreetqkfbk +ltwonejvqkzsltnine5fivemftvx +fourtwolkxrtzdsninenine5pznzrqbcmnph +3rzkfvqfnine +6xbninefourszjltwo6 +59qkf96twofour +fivecp37 +bcpmljn5 +7stthfdseven2threefourcrbxjjfnzbfqsfmqjlts1 +cpvsczrlrgnfpqbfbgh415five +seventhree6 +tworqbfj7114clslxks9 +six5eightjtnq +7six9llnsseventfmflxsjkdgq +six8tznfvz3 +fourpnmbqdbj23 +2ninexltrcbkjlb +665fourptmcdj +seven4mkvn1tkthree8s +eight84one +rhskrpddrmbgg7eight +qgbtqls7fd63xngfvcgdp8kkffgxdcs +9seventhree +lslprchqthree13fourkdfsrtfrthree2 +246eight +5ldnrqhhqmvtwojhtjhflzczsb9kklbkldvc +36fivebgn3vzgvjffckfour +vbxqnvhvmsix9lthree6zvmr8 +eighttwo23 +flqbvc23 +loneightsix9two +xkzvpttgfourfive6rnngs +threeseven6one5 +sixthree5rgklgfxllqzk4onetwo +one15dhhtcsx +zdmhgtnsjs22fjfourqzdsvcbgq +4four5 +hfjrsqjvtjkseven4kqcqbmbseven +241lgrtbsh +fiveptwo9sevenfpxpbfdoneightzj +9eight923xnxgndjfg +two8fivenine9cqcqqssbfc +fivetwosevenlgrvqvtsv5tcmsvbmggvfqqg7 +5mgkmn6ninetwo +mzsncqkbtq45r +fivefivegxzjvnxcbq8ptrzpjm5three +8ngzppeight646seven3oneightf +sevenvcsix8 +vxkmqgpsixgs2 +9jv9 +17jzmvgzc +6dz9 +sevenzzvone86twothreeonesktlhbks +three57vmlrfhcqkvlttzhcbtgqxgtbxb +fiveeighteighttwotwotdtfncfjn8pkxdvkfgr +8k5dsrxlvtmvdsixtwo +nine2fivernnckm +fpngdckp48onepbslnjdm2zbthxqp +nhrl8two +eightczdrdrxninesdqlqhhvq7twoz +sevenssmdflds6 +8sglqfive7p6threeqrdkmg +4brkbn +t4onepvf9three +mdfnjqjdl2lsb2btsj +tthreeljckhjqxbcjvmvx27jrffive +fiveqldglnp2six9vqvdcqxbdznghqcrnbxm99 +9pmkfmr6sevenlfjbvxqdbstwonine +threeninezmhc8three +one4nine4vc +8nqtgvnvcttpsrpsfive +pjjkmpfjpjzsbhzrgrkk96snqbtkkkd +6four58fourtworg +4fivekrjgx4 +mqrzmhhvlvknzdknine9 +one8seven2qd5 +pjhkthxm4 +sixjmbljdchjsrs3bvvnzqcqmjcm3eightwoc +8ninekrb5vxhbhdtdfd7 +7eightvlrsklsbpc3 +2onethree1 +4nine6qvfive2dlhvfour1 +threedkvnvvsmlthree149 +szseight88fourlfcvbzmone1dnzbnkq +onekxnsfour7 +onefivefivefive6rmpjhdvk2 +two75 +xrxzfmnqrvrtflqscnhlbh14vf +hsplmrdxtknine7tqtlk +sncgfpvz43lvjmvrpv +rdhoneightdxrvxhnthsevenfour72dxcdbmpbfd +six2oneonethree1xdszcmstmq +seven1one +12fourbtnxmsrvbnn6 +qfive7twomcmcsgsseven9 +five1nine7 +qcntzlp8one +qgpeightwosix8lbclbpknfive4ksqvptntmonevlrtrcs +nxmff91hzscmcthreesh +6three16 +hrlgqhzhqone14fivenine +fournrvxrxsmvsskdnbzs5zgmfh1m +four67one8drnprkbgt +81brchsdqdlk5fourseven2three +ninefoureightfjtmvsnine9onefive +two7rnl6three9 +eightseven2threethreenineqtwonezkq +eightcfkglfmzqjgrns99seven +dbzvbkslvthreefiveeight141gcklzxrzms9 +4frfvf6fourgnsm +7hcgjbbpbl9qbzzhfq +mnfllkcqgkninefive9 +4qdld5hqgrthreeeight2 +xlnnine6lksthree +lkvcnntznk33three4nine +8five2twonem +695mzfnhtlbhpvn1dfour4 +47seven811tzhqrrshdm +vgoneightnsr3fivethreetwornvbz +gc2 +3sevenxvmzbpknnqninetwofourtwosbpmqk +4seven8 +2fivegk47gsqtvdms +1jqgxbmgs4zxkrtvvtsjf1nfsdgtqrmthreeeight +vbvjdlnfiveninefive162nine +jqqsfqbfq2clfmfxz +2hmn1v2twofour16 +phchfbxz3one +zdcqgg34vqkhlbkc96six7 +5eightbghcktjjninermkpmbpk +4zctvpqqfxqdpf +six5onebljkhvlzfour3vf7 +three7sevenspczxeight3 +eightsjxdbgcjllvpxn5ninehrhlp +r4 +vtkqxmmdfkmbxbvgr633 +nrtfbqdthb1974jsdfive7jc +twothreenineeight3 +seven9c9 +l4rmngrjjl8phsftfrtwoninethree +8hptpqbfltv6twovcz5twothreethree +hncsxnxrbx174dbsddg9n +7fpvztb +eightnineq5kkd1seven +gbj8rvvqjkbp +sevenninecjrxhfsevenfivembxm1nkjrdtrllqrglrrxxj +21eightfive84mkdnzone +3rqjlbfzjninesncjnxxqnine9 +cvtwone2k1zmp65 +1v +one7eighteightsixqkfsm +44jkrsmcthreekktxlnnzjdslhfsmzl +dmhxlbsixh35 +four8ninetwofour864 +5threezmcq +6ninefive7 +4nine9twooneeightwoz +5klvpcfxpkhdhx717 +6stgznine4vhnsnhts9 +9threeone98seven1vnnvgxslf +sixeighteightztpdhvt2zqjstmzmtzgsfthreezzhhdr +twodtbkqsjgtwohfnsqcrmpjfourhkpnsfdkfive6four +ggrxkrdzmthree3 +sixlflcmmjrs5fivenine488 +four94hmhvlczssonedvgchseven6 +ssoneightfbfctjqv43psixsevenslqsfpkb1 +bdpnkb9eightnvtwojxbztssqfmninethree +cpcnkvdbrqrxtfnmzbqgffivesix91fivehgrv +five5495eight2 +7foursix93seventwonbhtmfrbqgq +tpqhxqqxpcnmlhqhkz123ninefive +knqxmrrmninegr4 +14qhlbkthreellvnqpfpbb +7eightcrlb6eightthree7 +twom3 +gtzdljfdzpdg4zbnzbnxmpcpfsevennine3 +svfjvnninefourpqsdmjcfhvccnjkpf8 +dzmoneighttwovk5tvpnmxfive +88msthvt4vbmnbrzjone +nbgcs8nine +4three53pczsx1sevenmzmtrzz +four24qphdrxfsf +gdgj3f +hthphptmmtwo7sixsevenoneightls +qxbhjmmqsixfkfn36three6 +eightmkmdtvkctkvptsbckzpnkhpskdmp3 +six2twobgzsfsptlqnine42xtmdprjqc +pxreightwo7 diff --git a/2023/Day02CSharp/Day02CSharp.csproj b/2023/Day02CSharp/Day02CSharp.csproj new file mode 100644 index 0000000..8ae44db --- /dev/null +++ b/2023/Day02CSharp/Day02CSharp.csproj @@ -0,0 +1,14 @@ + + + + Exe + net7.0 + enable + enable + + + + + + + diff --git a/2023/Day02CSharp/Program.cs b/2023/Day02CSharp/Program.cs new file mode 100644 index 0000000..72d5605 --- /dev/null +++ b/2023/Day02CSharp/Program.cs @@ -0,0 +1,147 @@ +// See https://aka.ms/new-console-template for more information +using AdventCommon; + +var p1exampleSln = Part01("example-input.txt"); +var p1puzzleSln = Part01("puzzle-input.txt"); + +Console.WriteLine("Part01 Example Sum: " + p1exampleSln); +Console.WriteLine("Part01 Puzzle Sum: " + p1puzzleSln); + +var p2exampleSln = Part02("example-input.txt"); +var p2puzzleSln = Part02("puzzle-input.txt"); + +Console.WriteLine("Part02 Example Sum: " + p2exampleSln); +Console.WriteLine("Part02 Puzzle Sum: " + p2puzzleSln); + +int Part01(string fileName) +{ + var input = new PuzzleInput(fileName); + + var trueBag = new Dictionary() { { "red", 12 }, + { "green", 13 }, + { "blue", 14 } + }; + var bag = new BagOfCubes(trueBag); + + int sum = 0; + + for (int i = 0; i < input.Lines.Count; i++) + { + var game = BagOfCubes.ParseLine(input.Lines[i]); + + bool possible = true; + + foreach (var item in game) + { + if (bag.IsPossible(item.Key, item.Value)) + { + continue; + } + + possible = false; + break; + } + + if (possible) + { + sum += i + 1; + } + } + + return sum; +} + +int Part02(string fileName) +{ + int sum = 0; + var input = new PuzzleInput(fileName); + + foreach (var item in input.Lines) + { + var result = BagOfCubes.ParseLine(item); + + int power = 1; + foreach (var item2 in result) + { + power *= item2.Value; + } + + sum += power; + } + + return sum; +} + +class BagOfCubes +{ + public BagOfCubes(PuzzleInput input) + { + foreach (var line in input.Lines) + { + var result = ParseLine(line); + + foreach (var item in result) + { + if (!Cubes.ContainsKey(item.Key)) + { + Cubes.Add(item.Key, item.Value); + } + else + { + Cubes[item.Key] = Math.Max(item.Value, Cubes[item.Key]); + } + } + } + } + + public BagOfCubes(Dictionary cubes) + { + Cubes = cubes; + } + + public static Dictionary ParseLine(string line) + { + Dictionary toRet = new Dictionary(); + + var plays = line.Split(':')[1].Split(';', StringSplitOptions.TrimEntries); + + foreach (var play in plays) + { + var p = play.Split(',', StringSplitOptions.TrimEntries); + + foreach (var split in p) + { + var cubeCount = Int32.Parse(split.Split(' ')[0]); + var cubeColor = split.Split(' ', StringSplitOptions.TrimEntries)[1]; + + if (!toRet.ContainsKey(cubeColor)) + { + toRet.Add(cubeColor, cubeCount); + } + else + { + toRet[cubeColor] = Math.Max(cubeCount, toRet[cubeColor]); + } + } + } + + return toRet; + } + + public int GetCubeCount(string color) + { + if (Cubes.ContainsKey(color)) + { + return Cubes[color]; + } + + return -1; + } + + public bool IsPossible(string color, int count) + { + return GetCubeCount(color) >= count; + } + + public Dictionary Cubes { get; private set; } = new Dictionary(); +} \ No newline at end of file diff --git a/2023/Day02CSharp/Properties/launchSettings.json b/2023/Day02CSharp/Properties/launchSettings.json new file mode 100644 index 0000000..c8ce407 --- /dev/null +++ b/2023/Day02CSharp/Properties/launchSettings.json @@ -0,0 +1,8 @@ +{ + "profiles": { + "Day02CSharp": { + "commandName": "Project", + "workingDirectory": "C:\\dev\\DevSandbox\\AdventOfCode\\2023\\Day02CSharp" + } + } +} \ No newline at end of file diff --git a/2023/Day02CSharp/example-input.txt b/2023/Day02CSharp/example-input.txt new file mode 100644 index 0000000..c85b98d --- /dev/null +++ b/2023/Day02CSharp/example-input.txt @@ -0,0 +1,5 @@ +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 \ No newline at end of file diff --git a/2023/Day02CSharp/puzzle-input.txt b/2023/Day02CSharp/puzzle-input.txt new file mode 100644 index 0000000..1dd27f6 --- /dev/null +++ b/2023/Day02CSharp/puzzle-input.txt @@ -0,0 +1,100 @@ +Game 1: 1 red, 5 blue, 1 green; 16 blue, 3 red; 6 blue, 5 red; 4 red, 7 blue, 1 green +Game 2: 4 blue; 4 red, 3 blue, 1 green; 4 red, 9 blue, 2 green; 5 blue, 7 green, 4 red +Game 3: 10 blue; 7 blue, 1 green; 19 blue, 1 green, 9 red +Game 4: 2 green; 14 blue, 14 red, 4 green; 12 red, 11 green, 13 blue; 5 green, 9 red, 4 blue; 9 red, 7 green, 12 blue; 2 green, 3 blue, 8 red +Game 5: 3 blue, 4 red; 12 red, 2 green, 15 blue; 1 red, 10 blue, 1 green +Game 6: 1 blue, 7 red; 3 green, 5 red, 1 blue; 1 green, 7 red; 6 red, 1 blue, 4 green; 1 green, 8 red, 1 blue; 2 green, 4 red, 1 blue +Game 7: 11 green, 10 blue, 2 red; 1 green, 12 blue, 2 red; 9 green, 14 blue; 1 red, 19 blue, 15 green +Game 8: 4 green, 2 red, 14 blue; 9 green, 1 red, 15 blue; 2 green, 9 red, 8 blue; 11 green, 7 red, 8 blue; 9 red, 7 green, 6 blue +Game 9: 4 blue, 1 green, 2 red; 1 blue, 3 red; 1 red, 3 blue, 3 green +Game 10: 4 red, 3 green, 6 blue; 2 green, 15 blue, 6 red; 3 green, 2 blue; 2 red, 1 green; 11 blue, 7 red, 4 green; 2 blue, 2 red, 4 green +Game 11: 10 red, 1 green, 7 blue; 5 red, 2 green, 7 blue; 2 green, 4 blue; 1 green, 10 red, 10 blue; 8 blue, 4 red +Game 12: 6 green, 2 blue, 7 red; 3 green, 2 blue, 3 red; 6 red, 1 blue, 9 green; 9 green, 13 red, 5 blue; 6 green, 4 blue, 8 red +Game 13: 10 green, 4 red, 6 blue; 19 red, 6 green, 7 blue; 6 blue, 5 red, 8 green +Game 14: 4 blue, 2 green; 19 blue; 6 red, 17 blue; 10 blue, 7 red; 1 green, 2 blue, 7 red +Game 15: 4 green, 12 blue, 15 red; 10 blue, 18 green, 13 red; 20 blue, 6 green, 10 red; 20 red, 12 blue, 13 green; 12 blue, 17 green, 10 red; 1 red, 3 blue, 7 green +Game 16: 1 blue, 6 red, 5 green; 3 red, 3 green; 5 green, 1 red; 2 red, 1 blue, 6 green; 1 blue, 1 red, 6 green; 1 blue, 6 green +Game 17: 4 red, 3 blue, 3 green; 8 blue, 8 green; 5 red, 3 green, 9 blue; 9 green, 12 blue, 13 red; 1 green, 1 blue, 5 red; 7 green, 6 red +Game 18: 2 green, 11 blue, 6 red; 2 green, 11 red, 2 blue; 7 red, 4 blue, 9 green; 18 blue, 6 red, 1 green +Game 19: 4 red, 7 green, 17 blue; 5 green, 6 red, 4 blue; 4 blue, 4 red, 1 green +Game 20: 2 blue, 5 green, 9 red; 4 green, 8 red, 10 blue; 7 blue, 9 red, 1 green; 1 green, 10 blue, 9 red; 1 green, 8 red; 8 blue, 8 red, 1 green +Game 21: 1 blue, 14 red; 1 green, 2 red; 9 red, 1 blue, 1 green +Game 22: 7 green, 9 red, 4 blue; 9 red, 7 green, 9 blue; 8 green, 14 red; 5 blue; 10 red, 1 blue, 1 green; 8 green +Game 23: 2 red, 12 green, 5 blue; 3 red, 5 blue, 3 green; 1 red, 9 green, 1 blue; 8 green, 6 blue; 13 green +Game 24: 8 red, 7 green, 1 blue; 1 red, 6 green, 7 blue; 1 green, 3 red +Game 25: 4 green, 2 red; 1 red, 2 green, 8 blue; 1 green; 8 blue +Game 26: 1 green, 4 blue, 17 red; 15 red, 3 green, 3 blue; 2 blue, 2 red; 18 red, 2 green, 11 blue; 6 red, 7 blue; 10 blue, 1 green, 4 red +Game 27: 2 red, 5 blue, 1 green; 14 green, 2 red, 6 blue; 1 red, 4 blue, 14 green +Game 28: 3 red, 5 green, 2 blue; 2 red, 3 green, 4 blue; 1 red, 9 green, 3 blue; 13 green, 4 red, 4 blue +Game 29: 18 red, 11 green; 4 blue, 18 red, 9 green; 16 red, 2 green, 4 blue; 2 red, 3 blue, 12 green; 1 green, 18 red; 2 blue, 15 green, 1 red +Game 30: 10 red, 3 blue, 1 green; 6 red, 1 blue, 3 green; 2 green, 2 blue, 10 red; 6 green; 3 blue, 15 red +Game 31: 1 blue, 7 green, 2 red; 12 red, 8 green, 4 blue; 2 green, 2 blue, 5 red; 2 blue, 3 green, 12 red; 7 red, 5 green, 4 blue; 7 red, 1 blue +Game 32: 4 blue, 5 red, 11 green; 20 red, 8 green, 1 blue; 10 red, 7 green, 1 blue; 1 blue, 7 red, 2 green; 1 red, 19 green, 3 blue +Game 33: 9 red; 9 red, 6 green, 7 blue; 5 red, 7 blue, 2 green +Game 34: 5 green, 5 red, 3 blue; 8 green, 6 blue, 16 red; 12 blue, 8 red, 8 green; 1 blue, 10 red, 3 green; 1 green, 13 blue, 18 red; 4 blue, 5 green, 8 red +Game 35: 15 green, 4 red, 8 blue; 7 red, 1 green, 14 blue; 12 green, 16 blue, 2 red +Game 36: 3 blue, 3 green, 2 red; 7 red, 8 blue; 11 blue, 9 red; 4 red, 13 blue, 1 green +Game 37: 4 red, 11 blue, 8 green; 6 green, 4 blue, 14 red; 5 blue, 7 green, 13 red; 6 red, 2 green, 5 blue; 4 red, 3 blue, 1 green; 6 red, 4 green, 6 blue +Game 38: 10 green, 5 blue, 1 red; 3 red, 6 blue, 3 green; 9 green, 9 blue, 3 red; 9 blue, 1 red, 6 green +Game 39: 3 blue, 16 red; 10 red, 4 green, 2 blue; 2 blue, 13 red, 1 green; 2 blue, 11 red, 2 green; 3 green, 13 red +Game 40: 2 blue, 3 red, 2 green; 2 green, 2 blue, 6 red; 1 green, 9 red +Game 41: 1 blue, 12 red; 8 blue, 1 red, 5 green; 1 green, 7 blue, 13 red; 8 red, 7 blue, 7 green; 4 green, 17 red, 9 blue; 2 green, 8 blue +Game 42: 2 green, 6 red, 1 blue; 3 red, 2 green; 9 red, 1 green; 2 red, 2 green +Game 43: 10 blue, 9 red; 14 blue, 4 green; 5 red, 3 green, 9 blue; 5 blue, 8 green, 1 red +Game 44: 3 blue, 10 green, 1 red; 1 blue, 13 red, 3 green; 1 blue, 5 green, 16 red +Game 45: 1 red, 1 green, 3 blue; 2 green, 1 red, 5 blue; 1 red, 2 blue, 1 green; 1 blue; 1 green, 5 blue; 1 blue +Game 46: 8 green, 8 blue, 4 red; 10 green, 4 red, 7 blue; 2 red, 3 green, 14 blue +Game 47: 3 green, 3 red; 5 green, 2 blue, 6 red; 3 blue, 5 red, 15 green; 2 green, 2 blue, 2 red +Game 48: 11 blue, 12 green, 3 red; 8 blue, 3 red, 3 green; 1 green, 6 blue, 2 red +Game 49: 3 blue, 17 green, 1 red; 4 red, 16 blue, 17 green; 1 green, 3 red, 5 blue; 14 blue, 1 red, 12 green +Game 50: 2 blue, 5 red, 6 green; 8 blue, 11 green, 5 red; 2 green, 2 red, 6 blue +Game 51: 1 green, 2 red; 4 green; 1 blue, 10 green +Game 52: 8 blue, 9 red, 4 green; 2 green, 8 blue, 2 red; 1 red, 2 green, 1 blue; 2 blue, 8 green, 8 red; 4 red, 1 green, 9 blue; 11 blue, 4 green, 8 red +Game 53: 1 green, 2 red; 3 blue, 1 green, 9 red; 5 blue, 11 red; 4 blue, 6 red, 1 green; 5 blue, 10 red; 5 blue, 5 red, 1 green +Game 54: 1 blue, 8 green; 9 green, 1 red, 11 blue; 16 green, 8 blue; 5 green +Game 55: 7 blue, 2 red, 1 green; 16 green, 19 blue, 5 red; 9 green, 3 blue, 7 red; 8 blue, 2 green, 4 red; 8 green, 15 blue, 5 red +Game 56: 9 blue, 1 red, 4 green; 12 green, 12 blue; 1 green, 1 red, 5 blue +Game 57: 1 green, 10 blue; 1 red, 9 blue; 10 blue, 1 red, 3 green +Game 58: 6 red, 15 blue, 3 green; 13 blue, 5 red; 10 blue, 2 red; 5 red, 1 green, 14 blue +Game 59: 7 red, 1 blue, 9 green; 4 green, 12 red, 2 blue; 6 green, 20 red, 1 blue; 4 blue, 9 red, 2 green; 8 red, 4 blue, 2 green +Game 60: 11 red, 8 blue, 1 green; 18 green, 11 blue; 16 red, 10 blue, 7 green; 6 blue, 8 red; 7 red, 15 green, 4 blue +Game 61: 1 blue, 1 green, 8 red; 3 red, 7 blue; 4 blue, 10 red; 1 green, 5 red, 8 blue; 10 red, 7 blue +Game 62: 12 blue, 1 red, 1 green; 2 green, 1 red, 7 blue; 3 green, 18 blue; 11 blue, 4 green +Game 63: 4 green, 4 red, 8 blue; 7 red, 5 blue, 5 green; 2 green, 20 blue, 4 red; 1 green, 4 blue, 3 red +Game 64: 2 green, 2 red; 3 green, 2 blue; 12 green, 2 red, 4 blue; 5 red, 9 green, 8 blue; 7 blue, 6 green; 3 green, 5 red +Game 65: 8 red, 2 green, 13 blue; 11 blue; 7 blue, 2 green; 12 blue, 1 green, 9 red +Game 66: 1 blue, 3 red, 19 green; 3 red, 17 blue, 15 green; 9 green, 9 blue +Game 67: 2 green, 7 blue, 1 red; 3 green, 1 red, 7 blue; 1 red, 6 green; 7 blue, 2 red, 10 green; 2 red, 5 green, 4 blue +Game 68: 14 red, 10 green, 8 blue; 11 red, 1 blue, 6 green; 7 red, 7 green; 12 blue, 10 green, 3 red; 6 red, 12 blue, 10 green; 8 green, 14 red, 3 blue +Game 69: 4 green, 8 red; 2 red, 15 green; 5 red, 1 blue, 12 green; 13 red, 6 green; 10 green, 13 red, 1 blue +Game 70: 3 red, 10 blue, 3 green; 8 red, 11 blue, 11 green; 5 red, 13 green +Game 71: 18 green, 3 red, 1 blue; 3 blue, 14 green, 2 red; 6 blue, 20 green, 4 red +Game 72: 2 blue, 1 red; 2 blue, 3 green, 1 red; 4 blue, 2 red, 4 green +Game 73: 11 red, 11 green; 5 green, 1 blue; 8 red, 7 green, 4 blue; 5 blue, 7 red, 12 green +Game 74: 12 red, 12 green, 5 blue; 10 red, 7 blue, 15 green; 6 green, 19 red, 19 blue; 3 red, 7 blue, 16 green; 11 red, 14 green, 16 blue +Game 75: 5 red, 17 green, 8 blue; 10 red, 8 blue, 19 green; 9 blue, 6 red, 18 green; 3 blue, 13 red, 12 green +Game 76: 5 green, 2 red, 8 blue; 3 blue, 14 red, 2 green; 14 red, 1 blue; 3 green, 8 blue, 15 red; 11 red, 1 green; 11 red, 9 blue, 3 green +Game 77: 3 blue, 2 red; 1 blue, 8 green, 11 red; 14 green, 14 red; 3 red, 5 green, 5 blue; 2 green, 16 blue, 3 red; 13 red, 7 green, 5 blue +Game 78: 3 blue, 1 green, 1 red; 5 blue, 1 green, 1 red; 9 blue, 7 red, 1 green; 5 blue, 1 green, 5 red; 10 blue, 3 green, 7 red +Game 79: 19 green, 17 blue, 4 red; 7 green, 7 red, 16 blue; 4 red, 10 green; 13 blue, 17 green, 2 red +Game 80: 9 blue, 3 green; 15 blue, 1 red; 3 blue, 12 green, 2 red; 1 red, 14 green, 13 blue; 1 red, 10 blue, 16 green; 8 blue, 6 green, 2 red +Game 81: 1 green, 3 red, 19 blue; 2 red, 1 green, 9 blue; 1 green, 2 red, 8 blue; 1 red, 1 green, 11 blue; 1 green, 3 red, 11 blue +Game 82: 8 red, 1 blue, 4 green; 9 green, 3 blue, 4 red; 3 green, 3 blue, 18 red +Game 83: 3 red, 13 blue, 16 green; 16 green, 2 blue; 14 green, 12 blue; 8 green, 14 blue, 4 red; 12 green, 4 blue; 20 green, 1 red +Game 84: 4 green, 4 blue, 5 red; 6 red, 6 blue, 8 green; 5 blue, 12 green, 3 red; 5 red, 13 green; 6 blue, 1 green, 5 red +Game 85: 10 green; 7 green, 1 blue; 5 red, 5 blue, 1 green; 2 green, 2 red, 3 blue; 3 red, 10 green, 3 blue; 1 blue, 1 red +Game 86: 3 green, 1 red, 3 blue; 2 red, 2 green; 9 green, 2 blue, 3 red; 3 red, 3 blue, 4 green +Game 87: 6 red, 4 green; 1 red, 3 green, 5 blue; 1 green, 7 blue, 4 red +Game 88: 2 green, 4 red, 3 blue; 5 green, 1 blue; 3 red, 5 green, 2 blue; 1 green, 6 red, 1 blue; 7 red, 2 blue; 17 red, 13 green +Game 89: 4 green, 2 blue, 6 red; 15 red, 7 green, 10 blue; 7 red, 9 blue, 4 green +Game 90: 9 red, 17 blue; 1 green, 9 blue; 5 red, 8 blue; 3 blue, 9 red, 1 green; 17 blue, 1 red +Game 91: 7 green, 3 red, 5 blue; 4 blue, 3 red, 9 green; 9 red, 7 blue, 7 green; 5 red, 6 blue, 3 green; 10 red, 2 green, 6 blue +Game 92: 13 blue, 8 red; 7 green, 1 red, 8 blue; 5 blue, 4 red, 2 green; 9 red, 10 blue +Game 93: 6 green; 1 blue, 16 green, 6 red; 5 green, 1 blue, 5 red; 5 red, 6 green; 16 green, 2 red, 1 blue; 11 green, 2 red +Game 94: 9 blue, 4 green; 12 green, 17 blue; 4 green, 5 blue, 6 red; 2 red, 2 blue, 12 green +Game 95: 5 red, 4 blue, 5 green; 2 blue, 4 green, 4 red; 4 blue, 2 red, 7 green; 1 green, 7 blue, 8 red +Game 96: 7 blue, 6 green, 2 red; 3 green, 1 blue; 7 blue, 3 red, 5 green; 1 green, 5 blue; 6 blue, 2 red; 2 green, 1 red +Game 97: 10 red, 1 green, 1 blue; 4 green, 11 red, 2 blue; 4 red, 1 blue, 4 green +Game 98: 3 green, 4 blue, 7 red; 7 red, 8 green; 7 green, 16 red, 1 blue; 8 green, 2 blue, 4 red; 5 green, 3 blue, 18 red +Game 99: 6 green, 12 red, 1 blue; 5 blue, 1 red, 7 green; 5 green, 7 red, 10 blue; 8 blue, 1 red, 7 green; 17 red, 4 blue, 9 green +Game 100: 6 blue, 10 green; 3 green, 4 blue, 1 red; 7 blue, 1 red, 12 green diff --git a/2023/Day03CSharp/Day03CSharp.csproj b/2023/Day03CSharp/Day03CSharp.csproj new file mode 100644 index 0000000..8ae44db --- /dev/null +++ b/2023/Day03CSharp/Day03CSharp.csproj @@ -0,0 +1,14 @@ + + + + Exe + net7.0 + enable + enable + + + + + + + diff --git a/2023/Day03CSharp/Program.cs b/2023/Day03CSharp/Program.cs new file mode 100644 index 0000000..f2028b5 --- /dev/null +++ b/2023/Day03CSharp/Program.cs @@ -0,0 +1,156 @@ +using AdventCommon; +using System.ComponentModel.DataAnnotations; +using System.Numerics; + +var p1exampleSln = Part01("example-input.txt"); +var p1puzzleSln = Part01("puzzle-input.txt"); + +Console.WriteLine("Part01 Example Sum: " + p1exampleSln); +Console.WriteLine("Part01 Puzzle Sum: " + p1puzzleSln); + +var p2exampleSln = Part02("example-input.txt"); +var p2puzzleSln = Part02("puzzle-input.txt"); + +Console.WriteLine("Part02 Example Sum: " + p2exampleSln); +Console.WriteLine("Part02 Puzzle Sum: " + p2puzzleSln); + +int Part01(string fileName) +{ + var input = new Day03Input(fileName); + + int sum = 0; + foreach (var num in input.Numbers) + { + bool foundAdjacent = false; + + foreach (var s in input.Symbols) + { + if (Day03Input.Part.IsAdjacent(num, s)) + { + foundAdjacent = true; + break; + } + } + + if (foundAdjacent) + { + sum += num.Value; + } + } + + return sum; +} + +int Part02(string fileName) +{ + var input = new Day03Input(fileName); + + int sum = 0; + + foreach (var symbol in input.Symbols.Where(x => x.S == '*')) + { + List adjacentNums = new List(); + + foreach (var num in input.Numbers) + { + if (Day03Input.Part.IsAdjacent(num, symbol)) + { + adjacentNums.Add(num); + } + } + + if (adjacentNums.Count == 2) + { + sum += adjacentNums[0].Value * adjacentNums[1].Value; + } + } + + return sum; +} + +class Day03Input : PuzzleInput +{ + public abstract class Part + { + public Part(int x, int y, int length) + { + Coords = new Vector2(x, y); + Length = length; + } + + public Vector2 Coords { get; set; } + public float X { get { return Coords.X; } } + public float Y { get { return Coords.Y; } } + public int Length { get; private set; } + + public static bool IsAdjacent(Part left, Part right) + { + for (int i = 0; i < left.Length; i++) + { + for (int j = 0; j < right.Length; j++) + { + var l = new Vector2(left.X + i, left.Y); + var r = new Vector2(right.X + j, right.Y); + + if (Vector2.Subtract(l, r).Length() < 2) + return true; + } + } + + return false; + } + } + + public class Number : Part + { + public Number(int x, int y, int value, int length) : base(x,y,length) + { + Value = value; + } + + public int Value { get; private set; } + } + + public class Symbol : Part + { + public Symbol(int x, int y, char s) : base(x,y,1) + { + S = s; + } + + public char S { get; private set; } + } + + public Day03Input(string fileName) : base(fileName) + { + for (int j = 0; j < Lines.Count; j++) + { + for (int i = 0; i < Lines[j].Length; i++) + { + if (Char.IsDigit(Lines[j][i])) + { + string num = ""; + for (int sub = i; sub < Lines[j].Length && Char.IsDigit(Lines[j][sub]); sub++) + { + num += Lines[j][sub]; + } + int val = Int32.Parse(num); + + var n = new Number(i, j, val, num.Length); + Numbers.Add(n); + + // Skip remaining characters in the number + for (int upper = i + n.Length - 1; i < upper; i++) ; + } + else if (!Char.IsLetterOrDigit(Lines[j][i]) && Lines[j][i] != '.') + { + var v = new Symbol(i, j, Lines[j][i]); + Symbols.Add(v); + } + } + } + } + + public List Numbers { get; set; } = new List(); + public List Symbols { get; set; } = new List(); +} diff --git a/2023/Day03CSharp/Properties/launchSettings.json b/2023/Day03CSharp/Properties/launchSettings.json new file mode 100644 index 0000000..0cc27de --- /dev/null +++ b/2023/Day03CSharp/Properties/launchSettings.json @@ -0,0 +1,8 @@ +{ + "profiles": { + "Day03CSharp": { + "commandName": "Project", + "workingDirectory": "C:\\dev\\DevSandbox\\AdventOfCode\\2023\\Day03CSharp" + } + } +} \ No newline at end of file diff --git a/2023/Day03CSharp/example-input.txt b/2023/Day03CSharp/example-input.txt new file mode 100644 index 0000000..98280e3 --- /dev/null +++ b/2023/Day03CSharp/example-input.txt @@ -0,0 +1,10 @@ +467..114.. +...*...... +..35..633. +......#... +617*...... +.....+.58. +..592..... +......755. +...$.*.... +.664.598.. \ No newline at end of file diff --git a/2023/Day03CSharp/puzzle-input.txt b/2023/Day03CSharp/puzzle-input.txt new file mode 100644 index 0000000..8240b0c --- /dev/null +++ b/2023/Day03CSharp/puzzle-input.txt @@ -0,0 +1,140 @@ +....411...............838......721.....44..............................................607.................................................. +...&......519..................*..........#.97.........994..............404..............*...&43........440...882.......673.505............. +.....*......*...892.........971...%....131....*..........*.......515...$.......157.....412.............-.....*.............*............594. +..856.495....13...-...............602..........36...$.985....341*.........88.....*.921....................122..................806..508..... +......................667.325*734.................718...............284..*....288..*....620.......854.............643....817....*........... +....*480..825..........*....................784.......&.............*...859........856.*..........*...........................137........... +............*..903*986.681....403.....451...*.....424..24.855....844....................826.......202....-.........542%..564......@.212*.... +......735...70.............=.....*895.......575.....*......*.............490.........+.......114.......890....519...........*857.88.....761. +.......%..........#.#.....896.....................600.821@..565.............*390..664........@...292@..................%.................... +....$...........256..340.........851..............................476..................................210..............102................. +....758..........................*......=.............@................................273......911...#....@666...+193...................... +.............604....483..&144.859......807...-.........995..-218.770............37.512.*.........*.........................215...........117 +......354..........*...............$........849.*.................................*.....242....469.&764.........................959*128.$... +.........&........575..521#..30..812..89.........836....../..........116............385....................942$..739....*46................. +..912*.......*845..........................................338..165.#....995.160......*....882.......421..........-..697.......619.......... +......154..........................700...........................*....$.........*710..923....=.........*.................................... +...................616..328........*......184..........227..401.635...264.=16....................-.....659....................613.....526... +.............33.......+.-........63..........#..........*..*.....................@............647..................352/.........*......*.... +...107.......+............=318.................&862..210....588...703.........754.......151...................747.......260.....201..458.... +...*..................................&671.........................................473......812..391.........&......249..................... +....13...................709.21..876....................-..52.........965.527*814...................*...*63...........*...75.400.....*619... +.............713.-...319*......$......................215.*.............*................@........407.67..............802.+.....*.466....... +.............*...230.............997......................80.526..3.811.541..753.........642......................212........119........+738 +....197.....6......................=..618.....39.364.........+....*./........*................217*......443*703......*...................... +......*.................240...........#......*....*............378............156.................763.............444....94...86......../273 +.....866..&.........273*..................970.....673.....&........*359.............*565..147.............238...........+....&.............. +.........690.761...........*985.......%...................691...587........../...663..................%....$......34................336..... +.......#...../....951+...75........708.......411..939..85.............189...143....................301..-......=..@......-......596......... +......406.....................+............+.........*...*..55.974%.......................203..179.......917..399.........451............... +....................177......220...........500......111.46.........................413....*.....*................................/.......... +500............+....../.167-....................959.............231..................=..192...........334.....781.....&..........122..151... +...*............969..........+878..136.../........*.#.............*.&...........226......................*...*......855..296..........%..... +....421...611............448.........*....490..631...16........200..328........*..................51..272.....525..........*................ +............@........@......=.....719.....................................57..46.............................................*844.....305... +.....868..............887.....@...........-..........@........964.........*..........-859.................#...............189..........@.... +.....*.......804...............132..688....420.740.868.609......*....849...70..972.........991.....799.....43......574@..................... +935...99.530....*......................@.........................243..*............675.345*..........#.............................@........ +...........*.724...........645....114$....364......154.....989/......440.............=..........................275.......594......788...... +........756................................*.....................+........................187...504............./...../......*832........... +374................*.......586.......656..239....................40.........................*....*.......334*.........580................... +...*..............780..715......680...*..............490*...+715......648..........875.....735....359....................................... +563........662...................*..260.....896.357....................#.......407*....................................520.382.59.491....... +......204.*....................947.........../..*..............%.........................506.../..#..269#..*...........*.........*.......... +.......*..150............355...................371...430.....155.107...............322....+..137.303......424..772......33.................. +778...871.......*769.290*..........&..............................*................./.........................*...................743.153... +.............140............938..763..........3...............443..510....868...579.....577/....264............572.........#........*...$... +........*238...................#......417....=.......&....337..&.........#...........*.......................$.............125......153..... +.970$...........695..57..540........%..*..........930........*.............754%......156...560*305..567..78..149.974........................ +..........@...........+...*........891.531....848......105....911....................................*...*........*.....825................. +..........573..525..&....958.777...............*..........*...........883....=....%.........158.....530..839....803............254*688...... +..................*..560.............&......592.........159......743.......209.....735......*.......................237..................... +................15..................54.665........858..............*....93...................438.239*825.......284.....*.....565*684........ +......732..............574.690..........@.....471....*....@.......157....*............692.....................*........495.................. +...$.*.....320..9..........@......*576..........*........196..........738.................47......%955...80...983..505...............249.... +.468.541.........%.............134...............974..............=................424........533..........*..........*...727............... +..........$.................51...............193.....824....#....170...667*107.200..*...380...+........=.302.440#....791...-.........394@... +....*....331.+662....540*............445......*..........27..742................*..972....*..........255......................762........... +...770...........................301*....947.673.....164............../353...228.......237...................&246....431%.942*........21.... +........................................................*809..79..................#178.......409...@.....263......................285....... +114.................233.894......998....663.....65.830..........*...457............................598......*............554.....-.......... +.......740......204....*.........*.....=..........*....655...803.......................................&....957...........*.........514..... +...151*...........................438.......*208..........@................644.....294..531........58...241.....&949....612...511..%........ +..................534@........=.......*..494........569.......#........245.....980..*......*.......*.........................-.............. +....$267.972............@......308...366...........*...../.....883....*.....-.../..784.....954.232.224.........121..................293..... +..........@..........409...........................487....540......699.....756.................*.........437-.=.......@.......#......@...... +....957.........471.........795.#514.268.....443........................................=532..217....................171.144...246.......... +....*....59.642...@...........=......*...694...................*..........594..308..................933.........39........=...........*..... +.....393..*....%.........479.......305..*...................593.789.........*.....*.......78.@211.....&.....................866......116.... +.531..................%.../....911.....763..453..291.................+684..917..93....365..*.......48.........*834...545...#................ +....*280....-919...365.............115.........*....=.......................................213...../......120..........*............+...... +803.......................788........&.........764.....................*895.315........402......................824.....949....679..243..... +..........176.............*...............908$..................882.859...................*....586.......#404.-...=............-............ +..366.......*..37*840.....66.........189............*....368*.....-.....391......803.....512.......478........294.....................978... +...........977.............................388....932........759........*...........*........619...*......845.....78.247........441......... +.........%.......................613....................355...........632.........................270.....*.......*.....*691.....%......$327 +.......797..........................*.........473..451.....*..846.@................474*.......@.......-....561..493......................... +235.....................................880#...-...%....951.....*.490.507..............430....435.....370.............540..17.984..107...... +.....280..986...589.367......595.............................110........$.....325...................................+../..*...%......#...... +..........*...../......*........*949.......469.....#590.@......................*................912.......-.......269....818................ +..697.................106..315........./.................366..................795....614*800......%./666...396.........................798.. +....*.122.645....50.......*..........67..186.397.591.-.........353....201....................944............................&798......=..... +..193.+....#.....*.......918...............*....*.....930.......*......*....41..388.....387...+......&.......869.505........................ +.........$....595............709........763.......365............649..705..........=....*......./.....32.....*.....*............609.404*.... +.......540...........189.......*..442.........623*......$...............................295..524............64.....436......426*........15.. +...........129...466.*.......513...*..................175.........824...820..........................460.......154..................962..... +.................*......306=......307......=...-...........*........*......%....$............./344./.....811....$........817..........*..... +.........$..923.118...........343........811.787.........329.......650.179....180..................648...%................=......157..656... +........186.$.........995......#.........................................*...............-.....524.......................................... +..................682...%.........-...+...............411................20...659.........635.....$....*768..#.......986..269............... +........=.....143.#...........@.118.769..134...........#..=....332#...........................107...140.......569............*.930&......... +........92...$..............471...........*........485.....961..............15.............46*.............................820......838.649. +...................353..............865....991.629....*................841...*........@....................../129........#.............*.... +......163.716.......*....123.892....*..............#.727..611.........*......236.498.36..434..762.........................438...5........... +...............903.688..*....../..378............662.....#.....934....1..........-.........+.*....110.88........124.....................513. +....550...299...........430.............*638.684...............*..........157................220.....*................751......336..647*.... +....*...../..........................946...........873*203.337.4.............*......553..........921....553.....743...............*......... +....975.....*76................867............103............%.....603.....588.672*...#......728..*.....%......$......877...332*...903.+850. +.........542....592....992.......*.............+.....801..........................................215.................%..................... +.491...........*........*.................545.........*.....@..............33...233...782.....417..........%415.............%.........*119.. +.................../929..123........275.........409..494.251...............*.......*.....*830...*....709.........368......932......626...... +..47.837....926........................@.=864.....*.................482............972.........545..%....424......./..........990........... +......*.......*.../354..........$................107.......377+.......-....................................*.................*....50*....... +....351....177.........801....789...871......190..................&.........-408.292.....243..884........419.@936.795.......258......227.... +...............323+.....*.............-..508*.........@......$396..817............*..431....*.......*678.................................288 +...........*........+15...../..................=....144................*510.....177.....*....403.524.....&58.735....#........519..615%...... +........574.328..@........362..201*109..........816.................379...............84.........................312...........*.......212.. +................411....................550.................875.#.........172.....&...................133.799..................849..274*..... +.....................890*942..........*................264.....361.444........189....817..812....333...*.*.................................. +...+430...............................................*............*......490.............*..........37...160..166.............%......*..... +........532..............743&...595...217.............260...........740......*..4..453..89..%..304.............*...+........769........793.. +.........+..560..702=..............*..*......270..........-.527.717........675..=..........954...=......=398..9..916..............323....... +....835.......*..........%...144..959........@.........419.........*251...............................*..................360..586*.....273.. +...............766.....113....*..................................#............68...............%...944.....390%...418.......%...........*... +...................467.......548.....922.......125...792......44..65.....263*.....26....369...688.......................757...216*637..292.. +.....*309..347....*...................*...........*.....*.......-..................%...*.............815.571.............*.................. +..786.............473...807=..164......781......959......27..........28*.........................687*.....*.............259..............939 +....../........................&...333........................876.....................132..............=..396.....742+.............281...... +...210.....@............899........*......%.....873..24*167..*.....664.................%..465.........633................492.........*...... +...........639.........*........464......738......*..........766...&......396.775..151.......*375........./177..........*.....245.752....... +.501.................@..43.527.................415...782...................*..*....*................*537........=331..37.................... +.......93.........723........*....882...............@.....186&......642..150.593...414.......117.718........851............................. +...#.....*..................275.....#.503...23=.................145..*........................*.......645*.....+................33.310+..603 +537.........$..........#164...........&...........887.......562*......497....742............97...602......290...........................@... +....../375...845....................................*.............510.............315*720......................./.......69*114.....968...... +...................153.662........276...795........356...............&...365..................................333....................*...... +.995.980..............*...........*....*................375.............$.......500............148...................*915........$.......... +...*.-........32............243...258.674...........+..#........................*...531....590*...........837.408.100..........609..296..... +.532............*.690..734.....*...................828..........#............502...*.........................*..........&..........*........ +.............215.....*...*.....800...@.......690..........79....403..785..........363...................159..........383..322*99...561...867 +...384.613...............565..........106.....&.............%..........*..215.........-.....55*758.516.....#............................#... +...../..*...986..539.425.........................682@.........719...880..*......135...119............................686.........988........ +.......373.......*.....*...508..862.................../862...*..........647......*..............638..............204...*..............808... +................284...968....@....*..........382.438$.......561................709.59..............#...509.......*......234.......235*...... +........432.....................348...................714..........................%.....990.............*.....581..543......844............ +..580/.....*...............41...........384....243...*....................=...389*..........*140..-......683..........*..................... +...................73.*242..+.............*........323..78........700..978........761.....%.......626...............93................@..... +.567........945....*............199..........601*.........*........*...................800..365.............982.897..................962.... +.....1......*...$..468............*..............154.......626....662........606............*........337..@......*....121...707..945........ +..........568..818.............813..424@.............*642.............2......*...589.....678....963....*.342......162...=..=........#....... +......114...............81........................767......................720......................260..................................... diff --git a/2023/Day04CSharp/Day04CSharp.csproj b/2023/Day04CSharp/Day04CSharp.csproj new file mode 100644 index 0000000..8ae44db --- /dev/null +++ b/2023/Day04CSharp/Day04CSharp.csproj @@ -0,0 +1,14 @@ + + + + Exe + net7.0 + enable + enable + + + + + + + diff --git a/2023/Day04CSharp/Program.cs b/2023/Day04CSharp/Program.cs new file mode 100644 index 0000000..e48b349 --- /dev/null +++ b/2023/Day04CSharp/Program.cs @@ -0,0 +1,151 @@ +// See https://aka.ms/new-console-template for more information +using AdventCommon; + +int p1exampleSln = Part01("example-input.txt"); +int p1puzzleSln = Part01("puzzle-input.txt"); + +Console.WriteLine("Part01 Example Points: " + p1exampleSln); +Console.WriteLine("Part01 Puzzle Points: " + p1puzzleSln); + +int p2exampleSln = Part02("example-input.txt"); +int p2puzzleSln = Part02("puzzle-input.txt"); + +Console.WriteLine("Part02 Example Points: " + p2exampleSln); +Console.WriteLine("Part02 Puzzle Points: " + p2puzzleSln); + +int Part01(string fileName) +{ + var input = new Day04Input(fileName); + + int sum = 0; + foreach (var c in input.Cards) + { + sum += c.Points; + } + + return sum; +} + +int Part02(string fileName) +{ + var input = new Day04Input(fileName); + + Dictionary CardCopies = new Dictionary(); + + // Initial state -- 1 of each + for (int i = 0; i < input.Cards.Count; i++) + { + CardCopies.Add(i + 1, 1); + } + + // Start with card 1 and work to the end + for (int i = 0; i < input.Cards.Count; i++) + { + Day04Input.Card card = input.GetCardNumber(i + 1); + int numberOfCards = CardCopies[i + 1]; + var matches = card.MatchingNumbers; + + for (int cardNum = 0; cardNum < numberOfCards; cardNum++) + { + for (int j = 0; j < matches.Count; j++) + { + CardCopies[i + 2 + j]++; + } + } + } + + int sum = 0; + foreach (var c in CardCopies) + { + sum += c.Value; + } + + return sum; +} + +class Day04Input : PuzzleInput +{ + public class Card + { + public List WinningNumbers { get; private set; } = new List(); + public List ScratchedNumbers { get; private set; } = new List (); + public int CardNumber { get; private set; } + + public Card(string line) + { + // Extract card number + CardNumber = Int32.Parse(line.Split(':', StringSplitOptions.RemoveEmptyEntries)[0].Split(' ', StringSplitOptions.RemoveEmptyEntries)[1]); + + // extract numbers + string winningNumbers = line.Split(":")[1].Split('|', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries)[0]; + string scratchedNumbers = line.Split(":")[1].Split('|', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries)[1]; + + // parse the winning numbers + foreach (var winningNumber in winningNumbers.Split(' ', StringSplitOptions.RemoveEmptyEntries)) + { + WinningNumbers.Add(Int32.Parse(winningNumber)); + } + + // parse the scratchers + foreach (var scratchedNumber in scratchedNumbers.Split(' ', StringSplitOptions.RemoveEmptyEntries)) + { + ScratchedNumbers.Add(Int32.Parse(scratchedNumber)); + } + } + + public int Points + { + get + { + int points = 0; + + foreach (var scratched in ScratchedNumbers) + { + if (WinningNumbers.Contains(scratched)) + { + if (points == 0) points = 1; + else points *= 2; + } + } + + return points; + } + } + + public List MatchingNumbers + { + get + { + List matches = new List(); + + foreach (var scratched in ScratchedNumbers) + { + if (WinningNumbers.Contains(scratched)) + { + matches.Add(scratched); + } + } + + return matches; + } + } + } + + public List Cards { get; private set; } = new List(); + + public Card GetCardNumber(int num) + { + if (Cards[num - 1].CardNumber != num) throw new InvalidDataException(); + + return Cards[num - 1]; + } + + public Day04Input(string fileName) + : base(fileName) + { + foreach (var line in Lines) + { + Cards.Add(new Card(line)); + } + } +} \ No newline at end of file diff --git a/2023/Day04CSharp/Properties/launchSettings.json b/2023/Day04CSharp/Properties/launchSettings.json new file mode 100644 index 0000000..fe79cf7 --- /dev/null +++ b/2023/Day04CSharp/Properties/launchSettings.json @@ -0,0 +1,8 @@ +{ + "profiles": { + "Day04CSharp": { + "commandName": "Project", + "workingDirectory": "C:\\dev\\DevSandbox\\AdventOfCode\\2023\\Day04CSharp" + } + } +} \ No newline at end of file diff --git a/2023/Day04CSharp/example-input.txt b/2023/Day04CSharp/example-input.txt new file mode 100644 index 0000000..f0d2a90 --- /dev/null +++ b/2023/Day04CSharp/example-input.txt @@ -0,0 +1,6 @@ +Card 1: 41 48 83 86 17 | 83 86 6 31 17 9 48 53 +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 \ No newline at end of file diff --git a/2023/Day04CSharp/puzzle-input.txt b/2023/Day04CSharp/puzzle-input.txt new file mode 100644 index 0000000..bb309c4 --- /dev/null +++ b/2023/Day04CSharp/puzzle-input.txt @@ -0,0 +1,201 @@ +Card 1: 58 96 35 20 93 34 10 27 37 30 | 99 70 93 11 63 41 37 29 7 28 34 10 40 96 38 35 27 30 20 21 4 51 58 39 56 +Card 2: 64 84 57 46 53 86 90 99 59 70 | 99 59 30 83 84 70 31 57 6 29 18 82 15 88 86 53 51 64 32 47 44 46 80 39 90 +Card 3: 55 87 51 18 86 5 66 83 92 95 | 73 68 49 57 29 14 41 42 65 10 84 34 67 44 6 48 61 13 28 38 52 19 78 64 11 +Card 4: 52 21 59 78 18 42 46 91 31 10 | 48 83 13 68 42 72 4 10 6 36 63 81 21 94 8 3 78 53 2 47 62 77 56 97 7 +Card 5: 8 79 31 1 26 57 90 62 93 10 | 26 70 73 6 16 15 93 57 34 56 87 31 10 45 1 22 79 77 90 47 42 58 41 62 8 +Card 6: 90 75 24 69 81 93 39 38 96 33 | 2 78 68 31 99 35 49 66 36 84 54 27 43 80 50 3 22 74 60 98 57 83 13 82 91 +Card 7: 74 86 51 70 28 54 6 34 48 53 | 51 82 34 74 40 24 42 66 20 61 84 15 89 62 69 48 95 31 93 52 76 12 90 75 99 +Card 8: 54 44 69 6 51 24 84 39 20 99 | 89 93 96 85 18 94 15 87 72 67 5 52 45 43 55 65 14 47 30 61 82 41 76 29 38 +Card 9: 26 44 60 20 11 15 16 95 18 47 | 71 56 10 57 65 90 32 30 13 42 19 55 29 12 89 91 2 67 79 58 99 4 81 41 69 +Card 10: 68 65 79 3 44 55 12 71 47 84 | 47 65 93 4 71 23 17 30 59 85 3 28 95 36 88 12 7 97 68 62 84 21 79 61 44 +Card 11: 96 57 36 49 80 73 3 60 11 53 | 83 78 6 39 42 4 96 84 3 80 95 60 97 57 49 66 27 93 31 45 86 90 50 9 73 +Card 12: 85 69 14 3 54 56 61 43 77 80 | 84 8 53 72 9 24 52 88 40 2 95 31 34 90 61 70 89 97 58 56 14 65 98 38 3 +Card 13: 69 29 79 83 89 94 44 68 15 35 | 37 39 29 55 2 82 96 42 73 32 31 79 8 53 88 40 44 49 69 94 87 62 41 81 89 +Card 14: 27 40 19 34 91 84 98 49 21 68 | 58 94 2 1 55 53 52 44 98 8 75 46 50 79 9 56 43 67 10 3 11 19 69 95 17 +Card 15: 3 47 44 77 95 25 60 65 93 53 | 15 40 3 93 33 44 60 19 62 90 35 50 30 65 10 94 38 47 1 29 56 46 99 91 42 +Card 16: 96 27 10 19 93 22 87 53 97 1 | 52 36 77 72 13 61 48 22 94 5 76 51 62 4 41 81 11 17 79 64 40 24 54 23 33 +Card 17: 58 74 26 97 13 61 88 82 89 22 | 9 90 82 88 61 80 3 95 94 81 75 34 71 98 89 74 97 14 47 22 64 52 73 45 35 +Card 18: 29 90 8 16 69 48 40 21 18 9 | 79 26 84 12 40 36 85 19 69 25 21 9 13 16 83 4 22 90 54 97 17 2 89 73 50 +Card 19: 10 66 52 31 72 16 62 1 58 5 | 59 36 75 11 73 92 91 12 37 9 40 52 85 53 24 69 57 82 99 35 27 34 3 2 77 +Card 20: 96 5 9 50 28 34 80 2 36 43 | 90 77 12 17 75 24 32 67 28 22 73 23 68 84 6 25 96 95 85 9 11 36 49 39 98 +Card 21: 84 16 48 91 50 1 94 45 8 88 | 45 96 15 85 62 81 77 61 92 22 76 52 59 36 73 80 64 72 89 79 93 82 83 60 67 +Card 22: 21 46 26 27 28 3 8 44 32 24 | 76 6 90 80 26 11 83 2 18 81 93 95 53 85 31 78 66 35 5 1 56 65 89 14 94 +Card 23: 58 52 2 38 5 63 8 20 99 73 | 23 29 97 91 43 1 37 95 89 80 94 41 22 72 77 62 85 4 24 16 10 39 88 56 19 +Card 24: 36 94 57 12 16 64 4 62 39 41 | 19 6 72 9 17 46 68 34 28 80 59 74 18 13 76 77 43 82 48 58 5 52 30 25 23 +Card 25: 19 14 23 16 7 35 57 40 83 80 | 80 85 7 68 91 22 40 49 35 87 83 93 19 57 23 84 14 16 18 51 77 69 28 54 56 +Card 26: 25 58 34 14 13 30 56 22 97 6 | 38 13 97 24 94 88 30 77 14 34 73 6 44 17 26 57 47 22 31 85 58 56 25 96 10 +Card 27: 41 64 75 24 62 67 45 99 73 27 | 33 9 14 5 32 50 54 20 46 4 45 71 26 59 58 22 7 30 96 34 48 37 23 15 85 +Card 28: 89 90 33 58 59 69 49 72 2 32 | 79 43 28 97 72 92 58 59 31 33 44 89 71 90 11 80 51 2 30 32 69 82 77 49 95 +Card 29: 15 6 27 80 12 2 36 34 64 58 | 15 38 53 34 32 47 64 16 60 2 3 14 62 80 79 27 12 36 6 85 58 33 69 24 57 +Card 30: 54 63 65 76 87 6 47 89 10 79 | 87 73 12 10 92 86 39 76 79 6 97 67 84 47 65 54 22 51 19 31 9 37 89 82 63 +Card 31: 23 96 48 30 75 9 72 11 78 62 | 75 24 23 1 14 72 54 2 47 95 48 18 50 12 94 78 9 96 34 30 11 98 46 62 66 +Card 32: 41 27 4 60 29 24 82 31 17 26 | 4 40 59 27 70 37 60 77 31 46 99 43 61 67 45 5 73 35 30 33 41 17 24 29 76 +Card 33: 90 49 23 13 57 1 72 5 20 81 | 61 20 51 83 54 85 8 23 17 7 1 49 39 11 92 27 90 76 10 25 57 93 13 81 66 +Card 34: 12 16 36 14 17 73 97 74 83 11 | 76 91 97 26 36 12 10 73 85 7 17 14 25 29 80 16 74 32 60 94 83 11 67 37 35 +Card 35: 92 80 27 26 61 91 28 66 15 76 | 19 64 36 42 70 77 27 91 29 66 61 18 58 15 32 8 68 67 92 80 93 76 28 26 48 +Card 36: 70 49 5 86 84 71 72 40 22 47 | 98 68 10 75 88 16 61 17 21 91 14 48 44 73 81 2 82 83 80 93 87 59 92 41 34 +Card 37: 18 9 71 88 72 74 33 50 4 40 | 96 72 41 21 40 33 18 73 91 53 71 74 46 61 80 12 88 36 70 26 66 69 39 38 9 +Card 38: 52 91 3 1 58 80 78 15 99 25 | 70 55 27 59 62 56 78 97 91 52 18 2 23 80 9 8 89 51 19 46 10 71 25 49 99 +Card 39: 85 9 86 88 36 60 90 56 77 16 | 34 26 85 46 86 2 28 31 16 22 36 83 60 37 74 81 19 27 7 17 91 49 56 3 47 +Card 40: 38 12 23 15 31 48 24 76 82 54 | 44 30 45 97 3 20 38 52 43 53 47 8 71 92 12 41 79 42 28 25 65 59 83 89 24 +Card 41: 78 11 68 8 89 13 26 93 65 54 | 84 22 71 3 53 4 15 9 81 96 26 6 40 56 95 75 30 62 65 13 33 78 41 66 44 +Card 42: 41 90 34 15 47 56 39 59 21 53 | 11 87 9 37 47 78 5 61 93 89 58 81 46 48 4 42 40 33 67 27 97 43 55 22 26 +Card 43: 42 99 37 62 40 79 15 55 76 82 | 91 21 53 1 54 63 4 51 28 59 71 61 18 66 23 10 25 38 6 20 30 87 44 11 14 +Card 44: 59 19 4 75 62 55 38 82 60 22 | 25 89 80 19 87 97 40 53 98 10 73 77 81 76 48 83 44 69 34 36 24 42 27 78 88 +Card 45: 19 76 23 87 25 13 67 52 3 60 | 92 1 96 22 26 42 54 24 57 41 49 33 72 17 77 14 78 62 11 74 73 4 47 99 59 +Card 46: 80 48 27 98 36 29 28 83 82 39 | 2 74 47 43 27 48 82 91 28 99 9 29 36 80 66 4 46 25 83 20 37 72 49 39 98 +Card 47: 39 12 2 66 78 8 58 98 95 15 | 63 78 90 49 83 72 66 56 82 92 20 21 11 89 17 51 5 55 39 48 97 19 33 22 12 +Card 48: 91 29 16 88 11 46 75 55 3 51 | 99 71 4 26 16 2 98 44 32 1 46 28 36 67 14 49 93 72 83 35 65 8 27 96 74 +Card 49: 71 93 41 5 84 26 1 33 2 94 | 2 41 54 74 33 5 13 91 1 19 65 14 34 58 84 94 23 61 85 26 20 11 71 93 22 +Card 50: 9 69 66 54 4 18 56 15 80 63 | 35 59 38 62 54 16 8 69 89 74 71 93 64 15 80 39 13 84 9 28 79 27 18 45 75 +Card 51: 83 65 33 4 48 7 68 77 42 81 | 84 4 65 48 15 77 79 92 42 7 68 96 33 85 17 87 81 58 54 83 36 75 18 94 97 +Card 52: 86 34 54 12 13 67 61 57 41 4 | 91 35 27 3 68 39 12 30 65 9 50 46 66 80 20 77 29 45 72 98 19 10 55 47 73 +Card 53: 54 98 74 15 77 79 13 41 56 33 | 18 87 53 94 98 54 92 17 72 32 10 46 47 69 6 35 63 61 89 52 55 77 49 14 60 +Card 54: 55 76 46 69 22 60 13 90 86 48 | 90 57 63 23 39 47 34 65 97 6 93 95 13 48 60 22 86 96 33 92 94 29 56 72 18 +Card 55: 90 10 36 50 2 87 48 25 56 3 | 36 16 40 26 74 57 56 6 67 3 10 2 87 25 48 69 49 61 65 68 42 91 90 50 72 +Card 56: 79 48 63 72 24 98 64 80 42 87 | 98 63 15 40 28 39 85 81 60 48 64 92 80 82 74 91 72 41 23 99 17 93 42 59 87 +Card 57: 17 95 91 39 51 56 16 14 54 33 | 20 65 34 80 27 13 1 43 59 26 76 54 41 85 14 83 17 39 23 16 12 37 49 44 24 +Card 58: 50 9 39 92 89 62 74 56 73 61 | 78 92 68 31 13 28 83 61 8 14 56 62 6 16 50 39 24 9 58 1 17 89 48 15 12 +Card 59: 6 92 15 50 99 29 3 72 12 95 | 73 72 80 92 88 19 55 12 53 93 91 45 26 15 99 43 84 62 59 49 6 64 77 3 16 +Card 60: 14 93 76 15 7 90 39 30 83 32 | 83 35 69 40 60 77 73 75 36 27 94 80 90 1 56 99 93 13 37 45 22 26 31 20 70 +Card 61: 50 64 24 26 72 8 33 13 22 27 | 45 60 37 19 55 95 76 52 4 9 75 44 78 20 53 41 69 11 47 36 2 48 74 94 21 +Card 62: 55 87 6 12 83 97 11 94 56 19 | 4 71 56 25 88 50 55 42 10 28 81 60 59 22 44 49 86 66 94 31 62 84 57 90 51 +Card 63: 89 13 38 94 61 8 79 1 11 80 | 5 55 56 13 84 39 54 32 79 74 58 96 82 53 21 91 64 42 41 94 44 97 95 28 14 +Card 64: 39 73 72 12 74 58 57 50 25 24 | 1 49 3 46 89 26 78 24 28 21 54 64 86 88 30 91 43 15 98 23 99 12 22 79 33 +Card 65: 58 65 74 21 7 3 95 71 50 41 | 3 53 28 78 18 65 52 89 33 30 87 13 62 72 88 37 71 26 27 19 46 98 84 76 4 +Card 66: 27 73 68 71 55 33 88 30 56 87 | 50 74 97 18 34 5 65 66 93 31 57 32 69 38 28 60 81 43 87 98 53 86 59 49 14 +Card 67: 9 50 66 57 33 76 65 84 44 88 | 34 85 27 32 12 77 63 3 95 93 4 10 70 38 49 19 41 83 14 72 16 5 40 57 24 +Card 68: 71 27 65 58 38 62 73 23 77 57 | 51 56 61 78 41 68 22 2 20 64 6 24 45 5 72 79 13 67 85 7 50 48 93 80 26 +Card 69: 36 60 4 27 41 67 61 88 50 83 | 67 45 29 66 36 59 95 60 41 28 43 37 61 4 84 88 23 49 92 65 89 27 50 83 58 +Card 70: 34 37 95 65 11 29 98 15 55 68 | 13 58 34 52 29 46 72 25 68 5 7 87 42 51 61 98 75 15 65 33 95 11 83 55 60 +Card 71: 13 67 2 41 43 52 47 6 54 51 | 2 81 22 30 13 52 5 10 67 50 86 54 3 51 92 15 37 79 43 11 41 6 69 47 25 +Card 72: 51 72 65 50 55 80 48 87 13 10 | 28 5 41 51 42 45 87 98 35 64 93 72 65 55 50 88 13 74 48 63 80 10 34 86 40 +Card 73: 98 36 68 48 17 75 64 11 70 61 | 17 50 8 89 93 3 65 14 85 33 23 55 42 40 63 84 1 62 20 86 36 51 80 16 77 +Card 74: 75 10 74 42 71 63 14 2 12 96 | 33 7 65 96 38 6 17 34 18 40 71 61 95 14 27 46 2 91 66 58 8 19 31 16 25 +Card 75: 88 90 82 53 34 4 28 57 2 51 | 2 16 46 87 34 51 88 90 3 79 28 57 20 80 44 22 42 12 82 1 53 4 56 83 99 +Card 76: 75 48 5 98 51 7 34 67 66 32 | 93 92 75 43 1 98 71 19 13 40 29 85 67 66 12 25 83 39 48 8 7 5 31 65 33 +Card 77: 87 73 2 20 57 7 99 23 4 81 | 3 10 65 56 26 84 34 78 17 66 44 72 69 76 30 95 5 38 28 8 70 22 99 82 54 +Card 78: 2 48 95 8 80 41 26 96 47 50 | 1 5 21 24 91 29 22 47 98 57 82 42 72 94 62 90 2 95 49 36 6 71 27 70 33 +Card 79: 32 35 6 27 72 8 81 44 28 43 | 59 79 54 18 51 82 25 61 83 37 12 94 41 74 69 16 73 65 1 26 9 33 29 34 66 +Card 80: 46 43 77 74 73 26 84 50 86 24 | 6 29 89 70 16 3 98 92 17 27 79 86 31 93 85 41 96 91 77 48 14 66 18 54 99 +Card 81: 69 60 90 30 65 28 96 97 41 38 | 40 3 44 62 94 97 57 60 9 85 17 88 28 96 22 77 72 36 30 52 83 95 73 48 80 +Card 82: 27 47 86 26 46 44 59 63 31 58 | 51 13 11 50 35 89 8 78 54 82 67 64 15 83 73 74 57 4 76 29 43 90 91 37 22 +Card 83: 84 6 1 64 33 37 68 83 72 90 | 41 69 59 91 46 40 22 5 51 27 76 45 32 43 37 3 10 85 26 81 87 56 25 67 55 +Card 84: 61 83 50 49 91 12 98 38 6 78 | 93 73 96 62 70 39 59 5 48 18 40 63 90 22 61 46 50 66 91 95 88 71 76 87 29 +Card 85: 3 60 82 33 22 43 9 98 50 89 | 48 56 15 77 25 92 6 41 84 2 49 29 61 57 51 64 96 36 7 22 31 32 28 30 59 +Card 86: 48 22 41 64 65 16 25 36 29 76 | 86 5 19 89 36 60 27 1 11 67 98 73 35 75 61 21 92 91 93 66 47 39 87 68 52 +Card 87: 68 42 18 51 79 37 9 34 8 85 | 12 7 19 30 91 84 29 53 73 65 48 94 17 22 4 32 33 15 93 75 38 31 41 86 67 +Card 88: 50 35 98 64 91 37 80 75 39 8 | 37 13 35 24 64 91 75 4 63 45 98 56 85 8 1 29 43 97 65 50 80 74 25 32 39 +Card 89: 55 87 4 74 33 2 61 37 94 57 | 37 25 55 48 2 40 5 38 94 85 87 4 7 51 57 75 43 61 34 67 17 74 24 10 33 +Card 90: 76 98 38 16 60 19 93 26 48 43 | 72 8 26 45 98 61 67 16 42 43 29 76 93 50 79 38 27 15 19 54 99 60 3 88 48 +Card 91: 64 67 7 18 71 96 45 89 39 2 | 71 21 98 87 39 19 57 45 86 7 49 2 67 20 96 74 90 64 18 17 89 99 23 59 16 +Card 92: 68 66 33 78 22 62 39 31 37 5 | 95 40 33 37 5 22 66 78 10 68 63 43 90 31 46 8 62 32 98 73 39 21 45 13 20 +Card 93: 21 25 2 91 58 37 51 60 12 74 | 47 40 51 66 77 63 84 68 2 4 60 75 91 21 22 35 32 80 74 37 58 20 12 14 27 +Card 94: 81 48 43 59 86 85 2 92 27 35 | 34 84 11 6 25 1 96 24 30 8 21 33 74 57 70 91 66 20 7 75 36 73 53 87 62 +Card 95: 15 2 41 54 12 45 3 56 77 9 | 12 60 7 97 49 96 99 32 24 63 16 62 68 88 26 43 54 20 27 33 47 19 58 15 75 +Card 96: 90 47 53 86 39 54 7 82 65 22 | 84 62 70 82 78 65 53 86 30 73 57 47 72 54 39 11 35 83 22 40 28 7 21 90 63 +Card 97: 17 25 87 43 20 84 75 78 6 53 | 75 6 64 90 87 61 11 31 36 60 38 78 46 27 82 72 16 95 57 17 30 53 94 77 3 +Card 98: 45 18 60 22 16 91 39 27 38 88 | 18 88 92 49 79 10 38 98 35 99 89 91 23 32 9 39 1 64 48 11 22 15 66 82 21 +Card 99: 6 42 69 91 94 38 87 11 97 26 | 6 71 11 69 16 97 49 73 45 48 38 87 42 2 67 26 89 95 81 30 1 91 20 10 66 +Card 100: 57 7 39 52 99 68 48 24 2 16 | 1 43 77 38 25 18 41 73 26 12 90 3 95 54 22 72 65 83 11 32 37 85 14 71 29 +Card 101: 48 71 81 27 52 26 75 95 19 54 | 19 59 90 24 17 56 34 39 49 88 80 75 10 58 86 55 26 67 89 85 65 40 30 81 6 +Card 102: 35 62 57 40 79 63 37 33 60 17 | 37 35 33 97 79 75 7 19 59 67 23 63 41 17 85 58 42 38 53 36 83 60 62 76 95 +Card 103: 91 18 51 5 41 61 26 94 47 85 | 26 58 65 41 96 83 30 63 78 87 90 4 53 95 6 8 98 36 82 76 92 34 28 94 56 +Card 104: 45 38 79 42 74 18 16 61 65 89 | 58 5 84 72 51 22 52 56 64 11 23 38 16 93 24 25 29 66 41 35 77 20 95 17 1 +Card 105: 9 97 56 51 55 62 19 75 83 47 | 58 15 96 43 24 9 47 80 95 71 62 29 72 39 40 19 61 52 8 32 88 69 27 70 86 +Card 106: 82 26 96 33 35 50 19 78 64 91 | 9 17 70 96 89 91 4 52 75 56 64 14 63 32 50 73 7 81 46 10 53 42 99 95 26 +Card 107: 66 58 63 7 95 46 42 97 67 59 | 96 23 86 7 58 61 14 17 93 45 39 60 28 32 15 46 55 35 2 44 22 27 78 94 68 +Card 108: 48 3 54 58 30 47 71 74 28 37 | 44 62 60 16 97 71 23 35 49 24 93 7 65 87 19 99 89 28 34 45 90 70 64 20 66 +Card 109: 3 90 39 83 16 47 44 1 28 65 | 38 48 24 37 96 81 60 54 6 58 68 23 21 35 26 45 98 85 40 63 64 80 29 97 34 +Card 110: 3 12 59 28 93 26 92 52 38 64 | 65 36 5 49 72 86 6 33 84 73 98 89 47 61 57 14 32 44 10 97 69 40 99 7 51 +Card 111: 3 2 30 72 16 80 46 52 51 64 | 76 86 57 44 89 26 96 10 1 23 59 32 60 41 77 73 68 29 78 75 62 28 6 99 71 +Card 112: 84 34 17 40 47 44 33 99 65 79 | 65 74 97 55 33 13 52 34 47 40 17 56 6 96 76 8 59 51 99 84 18 48 79 44 24 +Card 113: 13 92 5 86 85 36 74 28 82 18 | 48 36 5 37 46 95 90 82 19 68 10 8 11 18 80 69 63 86 85 28 92 64 71 32 94 +Card 114: 96 50 90 97 11 42 79 78 56 26 | 78 50 27 47 96 97 62 42 26 86 84 72 79 20 11 43 8 64 87 95 56 68 90 67 52 +Card 115: 29 36 84 82 38 61 86 73 25 45 | 37 58 28 45 6 36 29 43 95 92 56 73 44 83 25 97 61 82 84 71 69 38 77 86 42 +Card 116: 97 19 96 10 44 26 81 79 7 89 | 39 55 63 4 94 24 29 12 65 84 68 31 75 23 15 71 54 82 56 42 5 53 96 40 51 +Card 117: 74 94 58 42 30 40 97 33 73 93 | 62 59 9 41 71 98 97 19 32 24 40 1 56 14 74 87 52 92 61 90 37 45 20 80 31 +Card 118: 96 45 27 88 2 82 87 99 39 17 | 53 36 44 55 21 88 33 74 26 22 61 46 18 43 20 68 54 49 87 67 35 73 3 63 1 +Card 119: 80 19 2 6 68 32 23 22 99 28 | 20 40 66 38 87 59 41 55 54 57 21 12 11 45 65 16 24 3 63 68 73 98 99 14 17 +Card 120: 84 92 65 58 80 55 2 72 78 75 | 66 64 44 88 1 41 59 13 29 52 30 71 90 21 76 87 73 70 25 61 26 69 32 81 95 +Card 121: 52 32 92 91 42 8 15 19 1 30 | 89 92 96 46 25 24 48 90 59 83 15 75 28 57 61 39 43 42 84 95 45 73 41 98 67 +Card 122: 70 89 60 43 1 58 49 46 28 45 | 74 62 66 13 67 95 55 10 9 70 54 84 29 31 8 96 59 81 27 3 63 12 1 82 87 +Card 123: 41 51 96 76 48 54 4 71 45 84 | 68 66 2 4 78 15 1 62 75 94 59 7 12 28 60 39 16 42 61 8 84 89 46 95 35 +Card 124: 48 61 35 81 94 73 98 46 53 85 | 55 2 40 3 84 4 11 88 77 62 79 39 85 27 36 82 33 93 29 47 67 50 12 91 19 +Card 125: 63 44 28 58 5 26 85 93 50 76 | 39 10 25 30 2 3 42 60 94 83 57 9 75 13 67 90 36 81 18 72 23 37 48 19 69 +Card 126: 41 28 15 87 88 50 57 27 78 30 | 3 24 89 91 47 40 11 83 76 33 53 74 9 42 43 66 70 17 99 29 75 19 98 90 64 +Card 127: 77 24 27 2 59 54 6 61 65 12 | 34 42 68 15 70 75 2 27 61 40 6 13 24 54 12 59 44 65 22 88 86 77 3 79 64 +Card 128: 3 15 55 7 80 69 64 13 77 33 | 34 50 3 17 88 66 79 59 38 1 41 11 55 8 7 80 68 25 16 46 61 19 13 74 33 +Card 129: 26 19 39 29 4 6 55 49 67 12 | 72 53 12 63 64 49 19 98 3 45 4 35 28 43 51 26 38 23 96 44 22 7 79 80 67 +Card 130: 80 61 1 62 46 5 84 17 14 49 | 75 84 61 85 29 62 46 1 17 63 3 31 57 79 19 58 96 14 76 42 32 49 5 80 56 +Card 131: 63 30 2 29 71 37 12 36 16 47 | 14 82 99 98 52 39 19 60 4 90 74 33 65 27 62 7 32 64 10 37 35 15 11 69 59 +Card 132: 68 81 89 42 36 34 18 53 74 41 | 24 37 14 73 97 54 59 90 9 29 49 10 47 32 85 87 99 98 78 39 27 22 57 81 33 +Card 133: 89 9 10 61 30 81 36 84 70 12 | 69 10 4 90 65 50 93 34 54 13 80 16 98 49 42 35 77 61 85 55 86 6 11 23 39 +Card 134: 27 19 90 30 85 41 58 79 53 11 | 15 58 36 52 11 93 54 24 26 39 51 79 56 35 30 85 53 6 17 32 5 16 87 27 33 +Card 135: 26 44 30 42 99 89 76 27 64 48 | 38 70 95 25 60 2 49 35 71 5 17 63 62 88 20 41 79 19 67 72 40 46 81 10 74 +Card 136: 70 64 49 85 48 16 41 52 91 24 | 48 2 62 28 54 78 50 52 83 7 43 90 96 60 10 26 12 6 95 51 91 25 47 67 87 +Card 137: 10 6 53 80 8 93 62 98 60 82 | 28 19 36 1 14 73 85 16 8 32 21 13 97 90 2 29 34 69 55 80 6 27 62 37 10 +Card 138: 28 25 60 17 99 39 35 48 34 26 | 46 32 33 43 98 10 62 70 41 17 40 27 34 67 4 26 85 63 58 60 16 97 14 57 20 +Card 139: 42 49 16 73 10 23 35 41 93 8 | 76 28 17 32 91 96 92 19 61 97 88 27 83 80 72 57 87 33 14 67 42 10 64 94 65 +Card 140: 81 17 80 94 54 21 57 12 60 48 | 88 27 7 11 6 28 98 33 94 77 14 53 1 92 50 22 93 49 18 86 84 63 42 64 90 +Card 141: 98 31 93 30 72 39 33 35 57 54 | 45 95 69 89 51 55 21 67 50 68 46 5 86 65 17 82 29 48 8 91 71 63 25 52 1 +Card 142: 81 61 78 99 24 42 13 10 3 9 | 8 41 38 63 5 82 54 46 67 83 45 20 44 19 91 92 1 4 77 32 17 59 21 50 94 +Card 143: 78 65 47 51 54 16 23 59 39 34 | 34 53 78 4 29 59 3 87 23 73 16 65 24 38 58 21 89 92 54 39 47 30 66 37 88 +Card 144: 61 73 60 75 2 23 24 44 1 40 | 45 72 5 22 77 88 78 21 76 16 39 85 46 51 97 80 4 27 41 37 9 71 38 28 65 +Card 145: 28 24 22 79 56 23 51 50 54 63 | 22 25 11 44 59 28 50 2 29 85 79 24 54 8 6 23 92 20 71 56 81 95 51 26 63 +Card 146: 28 74 36 10 32 15 72 30 83 73 | 76 7 10 49 11 74 20 62 24 26 21 40 79 41 34 55 98 95 82 43 89 37 9 45 52 +Card 147: 80 20 78 59 53 42 31 95 63 11 | 80 59 61 57 86 42 78 53 21 95 92 75 15 31 97 72 5 11 41 90 63 56 44 25 20 +Card 148: 58 73 92 17 9 24 30 49 5 20 | 95 77 78 72 20 24 1 27 82 92 58 49 74 59 5 65 73 9 84 4 14 76 43 17 30 +Card 149: 87 18 12 98 41 27 13 48 82 37 | 87 78 2 88 61 36 95 25 81 18 41 33 1 69 34 57 27 73 55 12 82 31 59 48 6 +Card 150: 35 47 42 66 43 72 76 68 21 20 | 83 85 8 71 21 6 60 74 96 55 2 19 9 11 98 62 20 39 41 10 30 81 33 51 31 +Card 151: 83 24 73 61 49 67 89 95 60 43 | 59 84 28 21 26 72 37 43 38 3 13 6 9 27 7 42 77 19 65 16 71 52 29 80 33 +Card 152: 99 54 98 50 69 82 51 95 73 62 | 86 38 88 79 9 63 45 34 23 80 47 30 83 14 93 4 96 49 15 52 16 20 33 76 75 +Card 153: 76 36 9 23 70 53 41 74 27 64 | 40 71 39 29 88 19 76 97 46 23 4 68 67 33 52 95 62 91 60 11 75 13 81 99 37 +Card 154: 27 71 72 6 69 76 59 44 51 80 | 5 2 17 82 58 83 7 9 61 70 43 96 87 78 69 42 88 74 85 31 99 13 16 81 15 +Card 155: 82 71 39 56 8 42 1 63 92 11 | 16 52 94 85 67 11 98 65 50 71 2 78 43 1 41 66 86 72 77 36 30 6 46 70 38 +Card 156: 90 44 46 70 71 60 5 68 57 77 | 1 28 62 56 87 32 23 37 40 68 18 94 20 97 72 21 4 33 50 73 16 80 22 14 45 +Card 157: 60 51 2 24 69 85 55 47 62 48 | 6 86 49 55 78 42 61 98 30 77 65 4 21 20 38 93 54 18 72 44 32 8 14 58 37 +Card 158: 50 45 37 6 18 12 2 69 23 76 | 10 70 54 79 95 4 36 87 73 22 94 42 26 21 57 15 7 14 74 90 67 3 33 49 63 +Card 159: 26 12 57 16 96 61 42 99 71 25 | 25 51 26 9 47 57 4 53 61 12 97 36 76 39 99 65 92 16 78 41 71 62 48 96 42 +Card 160: 48 43 26 9 31 62 10 60 38 59 | 59 26 38 4 10 85 55 6 62 18 35 33 29 95 9 60 79 11 24 34 43 22 88 16 12 +Card 161: 15 82 90 63 18 26 57 9 47 35 | 63 23 43 56 82 92 9 42 94 4 90 89 10 26 62 32 20 30 52 85 18 19 47 66 57 +Card 162: 4 37 67 35 71 22 17 14 49 16 | 10 82 7 16 87 99 84 45 20 21 97 79 43 29 86 54 19 9 81 85 62 78 1 61 24 +Card 163: 41 6 57 96 5 21 9 89 65 27 | 26 12 23 9 17 89 33 2 28 65 92 10 97 27 96 56 80 64 90 50 52 46 42 6 5 +Card 164: 53 51 16 32 60 84 55 14 18 25 | 18 52 56 28 6 89 80 19 23 29 57 34 8 70 79 41 91 90 96 88 66 35 97 44 82 +Card 165: 17 66 59 23 35 45 32 49 56 26 | 2 74 97 9 80 76 12 50 31 15 53 41 56 33 30 98 20 44 25 81 91 45 55 99 24 +Card 166: 92 25 70 80 85 88 62 81 61 43 | 40 62 21 83 44 18 87 5 81 43 13 10 85 30 1 53 99 79 68 16 49 20 56 7 15 +Card 167: 36 63 98 92 11 59 6 47 2 83 | 41 90 83 68 54 64 25 80 56 7 99 16 5 30 27 88 63 11 22 67 81 17 9 39 95 +Card 168: 64 20 56 74 5 21 70 52 33 58 | 4 64 28 7 44 80 12 38 8 89 83 57 37 54 87 69 48 63 2 72 78 85 62 60 15 +Card 169: 13 92 14 8 98 84 54 85 97 38 | 51 90 69 98 38 13 4 8 67 5 91 14 54 68 10 18 83 56 41 25 81 73 58 17 62 +Card 170: 54 39 20 12 50 6 83 85 33 45 | 3 97 19 5 61 66 81 46 24 56 29 92 52 85 73 43 71 13 60 12 36 62 64 35 32 +Card 171: 33 36 27 29 93 73 83 62 60 82 | 4 71 14 72 45 58 10 38 12 69 27 3 95 31 84 34 66 83 21 87 22 5 75 53 35 +Card 172: 92 9 73 82 15 6 44 28 88 34 | 99 78 11 46 9 36 89 65 17 8 16 94 68 63 12 54 25 33 69 47 13 38 93 50 59 +Card 173: 41 10 43 83 81 39 66 17 28 63 | 48 79 29 20 64 59 55 46 47 45 70 62 37 16 84 68 82 88 67 2 65 97 18 56 14 +Card 174: 53 73 55 83 9 57 87 35 1 42 | 66 52 56 76 19 92 78 91 82 87 20 39 31 72 43 71 11 33 15 18 75 84 46 47 22 +Card 175: 93 51 74 60 92 84 87 58 81 34 | 67 7 99 68 30 66 27 43 65 71 28 50 2 13 32 26 72 76 17 31 49 3 54 95 82 +Card 176: 3 92 48 97 73 37 84 44 53 91 | 21 35 42 99 87 36 31 43 79 52 89 6 59 14 57 26 76 33 38 19 82 63 74 25 39 +Card 177: 46 93 6 62 56 3 76 64 59 7 | 88 46 7 98 93 76 60 59 6 3 72 64 21 40 77 78 62 47 61 42 45 99 56 28 41 +Card 178: 43 69 96 12 88 93 97 33 80 20 | 58 94 56 93 12 2 20 24 14 40 27 73 97 80 99 43 74 16 91 88 33 96 71 25 69 +Card 179: 59 1 88 53 87 90 39 32 97 89 | 70 57 90 20 73 35 32 88 58 71 36 59 33 1 55 97 87 98 45 39 9 96 53 60 89 +Card 180: 33 19 87 82 90 1 14 78 84 35 | 89 19 20 3 66 23 87 54 78 39 65 84 35 83 33 69 14 90 44 49 72 38 75 82 1 +Card 181: 60 32 78 83 82 29 90 14 46 87 | 63 72 92 39 75 10 43 40 7 89 11 32 86 54 4 90 68 45 95 91 13 1 56 6 29 +Card 182: 11 18 63 73 64 39 9 92 82 62 | 8 27 69 64 3 53 73 11 21 39 10 18 35 44 56 62 75 72 4 51 6 42 82 37 76 +Card 183: 88 56 32 39 23 49 92 50 59 28 | 92 2 48 32 63 49 59 83 56 1 91 41 50 88 28 17 39 57 20 36 34 6 60 23 42 +Card 184: 34 97 99 76 32 75 69 83 60 79 | 44 86 52 99 85 32 34 4 28 79 76 46 22 83 54 56 60 31 75 51 80 89 45 69 97 +Card 185: 74 35 67 1 55 18 60 37 17 50 | 85 50 44 20 87 14 22 32 55 18 17 59 28 93 1 96 68 37 74 60 98 97 67 35 4 +Card 186: 44 36 3 80 6 24 90 81 34 61 | 76 69 14 77 53 21 4 16 18 46 9 59 34 38 98 13 30 11 7 17 88 41 42 99 23 +Card 187: 54 53 39 24 80 78 13 46 17 67 | 62 91 86 52 80 59 26 78 73 46 16 77 18 37 9 55 13 17 72 69 32 68 67 34 81 +Card 188: 50 19 11 73 61 75 67 54 12 84 | 73 84 97 56 74 59 35 75 61 14 15 19 24 12 51 6 58 11 89 67 53 25 21 54 50 +Card 189: 76 48 38 17 97 67 42 23 82 6 | 73 10 17 70 85 95 54 43 93 91 3 82 26 16 23 76 33 38 67 48 5 53 97 6 42 +Card 190: 61 19 93 50 11 56 32 5 84 37 | 32 62 82 84 50 61 91 15 69 19 68 20 74 92 10 55 11 93 39 37 18 5 47 22 46 +Card 191: 2 58 93 26 23 31 60 74 35 47 | 74 64 26 68 8 60 11 73 93 42 87 2 31 97 61 47 65 24 58 66 53 38 94 46 88 +Card 192: 64 37 49 88 95 79 29 59 2 99 | 39 63 31 68 36 24 60 9 94 89 93 13 45 77 38 55 14 23 92 83 29 33 44 34 71 +Card 193: 19 23 99 89 26 80 63 60 59 66 | 78 80 99 60 66 47 84 59 24 61 5 63 67 26 87 42 96 10 54 98 19 81 4 43 8 +Card 194: 6 36 31 40 89 19 63 16 60 68 | 75 84 91 77 40 5 81 10 52 86 19 96 16 58 30 6 78 61 82 74 97 89 90 62 37 +Card 195: 45 54 92 67 47 65 91 98 87 29 | 5 72 15 25 88 36 73 20 91 90 83 46 87 47 10 22 69 2 62 57 28 93 3 59 1 +Card 196: 88 34 96 16 54 9 17 89 20 52 | 20 54 47 61 12 57 38 11 8 85 74 52 90 77 41 46 4 89 19 39 34 83 55 7 97 +Card 197: 38 3 57 72 97 45 66 73 56 8 | 83 68 28 64 58 66 85 15 53 65 23 3 37 87 20 17 47 63 55 69 88 70 62 92 76 +Card 198: 98 66 29 17 83 9 6 84 36 70 | 21 10 31 84 93 14 67 29 24 91 12 41 99 19 5 56 83 74 2 8 79 95 64 49 53 +Card 199: 41 93 33 26 45 65 97 39 20 95 | 82 8 30 6 34 58 49 16 29 91 64 80 50 9 74 59 19 60 69 53 61 3 83 67 35 +Card 200: 86 85 91 2 27 65 45 73 60 69 | 66 26 28 7 98 80 14 52 6 35 57 46 39 4 30 55 94 75 82 83 96 13 74 9 58 +Card 201: 30 53 41 42 10 51 37 63 46 67 | 84 74 33 5 86 32 45 83 52 1 13 43 65 49 98 91 9 11 96 66 15 62 27 44 24 diff --git a/2023/Day05CSharp/Day05CSharp.csproj b/2023/Day05CSharp/Day05CSharp.csproj new file mode 100644 index 0000000..8ae44db --- /dev/null +++ b/2023/Day05CSharp/Day05CSharp.csproj @@ -0,0 +1,14 @@ + + + + Exe + net7.0 + enable + enable + + + + + + + diff --git a/2023/Day05CSharp/Program.cs b/2023/Day05CSharp/Program.cs new file mode 100644 index 0000000..91001d9 --- /dev/null +++ b/2023/Day05CSharp/Program.cs @@ -0,0 +1,173 @@ +// See https://aka.ms/new-console-template for more information +using AdventCommon; +using System.Collections; +using System.Net.Sockets; + +var p1exampleSln = Part01("example-input.txt"); +var p1puzzleSln = Part01("puzzle-input.txt"); + +Console.WriteLine("Part01 Example: " + p1exampleSln); +Console.WriteLine("Part01 Puzzle: " + p1puzzleSln); + +long Part01(string fileName) +{ + Day05Input d = new Day05Input(fileName); + + List locations = new List(); + long min = long.MaxValue; + foreach (var seed in d.Seeds) + { + long loc = Day05Input.MapEntry.GetConversion(seed.Number, d.Maps); + locations.Add(loc); + min = long.Min(loc, min); + } + + return min; +} + +class Day05Input : PuzzleInput +{ + public class MapEntry + { + public MapEntry(string line) + { + var split = line.Split(' ', StringSplitOptions.RemoveEmptyEntries); + + long dest = Int64.Parse(split[0]); + long source = Int64.Parse(split[1]); + long range = Int64.Parse(split[2]); + + SourceRangeStart = source; + DestinationRangeStart = dest; + Range = range; + } + + public MapEntry(long sourceStart, long destStart, long length) + { + SourceRangeStart = sourceStart; + DestinationRangeStart = destStart; + Range = length; + } + + public long SourceRangeStart { get; private set; } + public long Range { get; private set; } + public long DestinationRangeStart { get; private set; } + + public bool Contains(long val) + { + return (SourceRangeStart <= val && val < SourceRangeStart + Range); + } + + public long GetDestinationCategory(long srcVal) + { + return DestinationRangeStart + (srcVal - SourceRangeStart); + } + + public static long GetConversion(long val, List entryMap) + { + foreach (var entry in entryMap) + { + if (entry.Contains(val)) + { + return (val - entry.SourceRangeStart) + entry.DestinationRangeStart; + } + } + + return val; + } + + public static long GetConversion(long val, List> Maps) + { + long currentVal = val; + + foreach (var entry in Maps) + { + currentVal = GetConversion(currentVal, entry); + } + + return currentVal; + } + } + + public class Seed + { + public Seed(long number) + { + Number = number; + } + + public long Number { get; private set; } + } + + public List Seeds { get; private set; } = new List(); + + public List SeedToSoil { get; private set; } = new List(); + public List SoilToFertilizer { get; private set; } = new List(); + public List FertilizerToWater { get; private set; } = new List(); + public List WaterToLight { get; private set; } = new List(); + public List LightToTemperature { get; private set; } = new List(); + public List TemperatureToHumidity { get; private set; } = new List(); + public List HumidityToLocation { get; private set; } = new List(); + + public List> Maps { get; private set; } = new List>(); + + public Day05Input(string fileName, bool isPart02 = false) : base(fileName, false) + { + Maps.Add(SeedToSoil); + Maps.Add(SoilToFertilizer); + Maps.Add(FertilizerToWater); + Maps.Add(WaterToLight); + Maps.Add(LightToTemperature); + Maps.Add(TemperatureToHumidity); + Maps.Add(HumidityToLocation); + + int currentMap = -1; + + foreach (var line in Lines) + { + // Read the seeds line + if (Seeds.Count == 0) + { + // First line is seeds + if (!line.Split(':')[0].Equals("seeds")) + { + throw new InvalidDataException("Expected seeds"); + } + + if (!isPart02) + { + var seeds = line.Split(':')[1].Split(' ', StringSplitOptions.RemoveEmptyEntries); + foreach (var seed in seeds) + { + Seeds.Add(new Seed(Int64.Parse(seed))); + } + } + else + { + var seeds = line.Split(':')[1].Split(' ', StringSplitOptions.RemoveEmptyEntries); + + if (!(seeds.Length % 2 == 0)) throw new InvalidDataException("Uneven seed count"); + + for (int i = 0; i < seeds.Length; i+=2) + { + + } + } + + continue; + } + + if (String.IsNullOrWhiteSpace(line)) continue; + + if (line.Contains("map:")) + { + // Move to the next map + currentMap++; + } + else + { + Maps[currentMap].Add(new MapEntry(line)); + } + } + } +} \ No newline at end of file diff --git a/2023/Day05CSharp/Properties/launchSettings.json b/2023/Day05CSharp/Properties/launchSettings.json new file mode 100644 index 0000000..5b67133 --- /dev/null +++ b/2023/Day05CSharp/Properties/launchSettings.json @@ -0,0 +1,8 @@ +{ + "profiles": { + "Day05CSharp": { + "commandName": "Project", + "workingDirectory": "C:\\dev\\DevSandbox\\AdventOfCode\\2023\\Day05CSharp" + } + } +} \ No newline at end of file diff --git a/2023/Day05CSharp/example-input.txt b/2023/Day05CSharp/example-input.txt new file mode 100644 index 0000000..1344eba --- /dev/null +++ b/2023/Day05CSharp/example-input.txt @@ -0,0 +1,33 @@ +seeds: 79 14 55 13 + +seed-to-soil map: +50 98 2 +52 50 48 + +soil-to-fertilizer map: +0 15 37 +37 52 2 +39 0 15 + +fertilizer-to-water map: +49 53 8 +0 11 42 +42 0 7 +57 7 4 + +water-to-light map: +88 18 7 +18 25 70 + +light-to-temperature map: +45 77 23 +81 45 19 +68 64 13 + +temperature-to-humidity map: +0 69 1 +1 0 69 + +humidity-to-location map: +60 56 37 +56 93 4 \ No newline at end of file diff --git a/2023/Day05CSharp/puzzle-input.txt b/2023/Day05CSharp/puzzle-input.txt new file mode 100644 index 0000000..2482873 --- /dev/null +++ b/2023/Day05CSharp/puzzle-input.txt @@ -0,0 +1,258 @@ +seeds: 1347397244 12212989 2916488878 1034516675 2821376423 8776260 2240804122 368941186 824872000 124877531 1597965637 36057332 4091290431 159289722 1875817275 106230212 998513229 159131132 2671581775 4213184 + +seed-to-soil map: +2988689842 4194451945 100515351 +2936009234 3353543976 52680608 +588295233 2638661119 66434163 +3932833115 2936009234 88315480 +3525561241 3331695912 21848064 +1622262003 1969921080 210668061 +2160566101 909457337 162053391 +1832930064 1887384181 82536899 +3625461917 3024324714 307371198 +3547409305 3680043285 78052612 +1915466963 588295233 240773057 +3089205193 3758095897 436356048 +4021148595 3406224584 273818701 +2156240020 2705095282 4326081 +1164190025 2180589141 458071978 +2477360206 829068290 80389047 +2322619492 2709421363 154740714 +654729396 1377923552 509460629 +2557749253 1211672006 166251546 +2724000799 1071510728 140161278 + +soil-to-fertilizer map: +3961802244 3774724750 90737174 +3164426550 3931513861 70563571 +147221566 1279409424 704464 +1394834067 2074132435 40845148 +3795834030 2142537807 47621185 +4083197470 4095560143 199407153 +2722903919 2876212954 93296050 +3467494732 2775293966 100918988 +1809650294 1815421878 66426374 +505665614 275280169 12031240 +2142537807 4002077432 60985377 +1577608496 331482268 177958690 +2590855103 2196397738 132048816 +1942888942 1978207624 24340152 +756722275 120895382 4815243 +3435289775 3899308904 32204957 +1967229094 715059087 147748489 +3955563498 2190158992 6238746 +356096070 125710625 149569544 +2520387506 2704826369 70467597 +517696854 2041922514 32209921 +1755567186 0 54083108 +348569226 1280113888 7526844 +761537518 1597328127 34415327 +1114796271 1631743454 128592301 +0 1494456232 102871895 +1070625412 287311409 44170859 +549906775 1287640732 206815500 +102871895 710084154 4974933 +1298474695 1881848252 96359372 +3843455215 2549697361 112108283 +3761987050 3865461924 33846980 +4052539418 2674168317 30658052 +1435679215 862807576 141929281 +795952845 1004736857 274672567 +3729489716 4063062809 32497334 +2203523184 3085216895 316864322 +2931907860 3402081217 11267883 +107846828 2002547776 39374738 +2816199969 2969509004 115707891 +3568413720 3413349100 161075996 +2943175743 2328446554 221250807 +3234990121 3574425096 200299654 +4282604623 2661805644 12362673 +147926030 509440958 200643196 +1876076668 54083108 66812274 +1243388572 1760335755 55086123 + +fertilizer-to-water map: +2460553918 850437816 63304366 +1259757436 1986466040 193004355 +2879827793 2638634287 61837387 +39629536 0 3143529 +2160922553 2535779758 68016930 +2523858284 922523353 36811379 +52449107 1199799263 207670511 +2692884203 2603796688 34837599 +3755186617 147251641 492169035 +3266515480 3620937477 292130997 +1596851845 4077877285 217090011 +2727721802 913742182 8781171 +3055087322 3913068474 164808811 +2228939483 2179470395 229525704 +3668162112 1052896909 87024505 +3219896133 1539684314 30399976 +1510550909 1679599925 86300936 +0 3143529 39629536 +2560669663 1407469774 132214540 +1452761791 1142010145 57789118 +260119618 2700471674 920465803 +3250296109 1036677538 16219371 +1813941856 1026924408 9753130 +4247355652 2488168114 47611644 +1823694986 959334732 67589676 +2831305507 639420676 48522286 +2736502973 52449107 94802534 +1180585421 2408996099 79172015 +2941665180 1765900861 113422142 +2458465187 1139921414 2088731 +3558646477 1570084290 109515635 +1891284662 687942962 162494854 +2053779516 1879323003 107143037 + +water-to-light map: +2196302869 3170532562 121192468 +3065704582 2916528129 254004433 +2858667310 1154274853 9085577 +3789349818 1163360430 70779786 +2064226029 1434838179 90165206 +1448515654 725716988 103420445 +2690533041 2124509945 168134269 +347894075 3345882022 38285799 +3966625235 2618593488 35838159 +4186823059 4134088017 89981817 +1701108140 1088713231 65561622 +2589948930 2518009377 100584111 +4283393470 4230658428 11573826 +0 3384167821 347894075 +1638541363 2061943168 62566777 +1296314418 573515752 152201236 +1065865126 194284013 230449292 +1766669762 1991838394 70104774 +830054797 2292644214 110248534 +3595088014 3291725030 12245358 +1978385607 1905997972 85840422 +3607333372 424733305 148782447 +3511869770 2833309885 83218244 +4134088017 4242232254 52735042 +2154391235 3303970388 41911634 +494720868 3732061896 335333929 +1836774536 1234140216 141611071 +2317495337 1633544379 272453593 +4002463394 2402892748 64932431 +940303331 829137433 125561795 +1551936099 954699228 27518372 +4276804876 4224069834 6588594 +3756115819 2467825179 33233999 +2867752887 0 19073457 +386179874 1525003385 108540994 +1579454471 1375751287 59086892 +3319709015 2501059178 16950199 +3336659214 19073457 175210556 +3860129604 982217600 106495631 +2886826344 2654431647 178878238 + +light-to-temperature map: +977891457 1797846421 453265654 +3607226990 3913974738 161345346 +2303244644 3266224873 12707372 +1537599301 3278932245 264559714 +354466514 3168465761 62294113 +747844586 3543491959 55668994 +2982698313 3599160953 269886589 +2067998119 2251112075 27763866 +59336731 230685734 266868096 +3768572336 1500157846 31849471 +3856743875 939537646 438223421 +2095761985 59336731 146190926 +326204827 4075320084 28261687 +1502134302 3230759874 35464999 +1431157111 868560455 70977191 +2315952016 2579115195 227102616 +1802159015 1532007317 265839104 +2241952911 807268722 61291733 +3297512098 497553830 309714892 +852851251 4103581771 2643427 +3252584902 3869047542 44927196 +855494678 1377761067 122396779 +2543054632 4106225198 139404427 +2682459059 2278875941 300239254 +803513580 4245629625 49337671 +416760627 205527657 25158077 +3800421807 2806217811 56322068 +441918704 2862539879 305925882 + +temperature-to-humidity map: +3507573 490548898 11693081 +545755853 699222305 569882925 +3794976513 167435410 77260251 +0 1526297837 3507573 +1335234764 1766508370 36536350 +2131780538 502241979 64264976 +3707588652 1679120509 87387861 +96082543 2288930706 220305732 +1371771114 1529805410 106547120 +481810045 3044354609 63945808 +15200654 1426594789 7560739 +3206337878 109359655 58075755 +2445677382 2019348918 269581788 +1909096745 3571407035 4209780 +3138678479 4049712539 66833109 +3400069156 3490205314 81201721 +4084645800 3846924477 65868498 +2353535073 1434155528 92142309 +1716598669 3935506457 114206082 +3264413633 4116545648 30901597 +1913306525 3628450464 218474013 +3205511588 3461720938 826290 +2748703371 2770603565 195642711 +2715259170 244990096 33149766 +1478318234 3108300417 88629505 +22761393 0 73321150 +3295315230 3575616815 45887125 +3872236764 278139862 212409036 +2196045514 1269105230 157489559 +2972004168 2509236438 123906332 +316388275 3296299168 165421770 +1685215763 3025113077 18894296 +2748408936 244695661 294435 +3704521599 4147447245 3067053 +1215008024 566506955 120226740 +1830804751 3912792975 22713482 +1704110059 686733695 12488610 +3488217401 1803044720 216304198 +1872711004 3044007373 347236 +1566947739 2652335541 118268024 +3481270877 3621503940 6946524 +2944346082 3462547228 27658086 +3095910500 1636352530 42767979 +1115638778 3196929922 99369246 +3341202355 2966246276 58866801 +1853518233 2633142770 19192771 +1873058240 73321150 36038505 + +humidity-to-location map: +336906655 0 11018487 +4177510177 2085057023 105144397 +1299579245 2985741466 175347598 +643133711 2270603056 161424888 +2404489601 1000033728 105953201 +4282654574 2864154964 12312722 +3409171342 3327025690 30826088 +2119751049 2190201420 80401636 +3393269098 3357851778 15902244 +82121354 319849190 39107402 +1953814423 3161089064 165936626 +64524116 385149760 17597238 +3439997430 2057119912 27937111 +0 358956592 26193168 +347925142 11018487 93152804 +1484466972 2432027944 360604841 +2510442802 643133711 347359888 +26193168 402746998 38330948 +1190305465 2946259551 39481915 +2200152685 1105986929 204336916 +3467934541 2792632785 71522179 +804558599 3373754022 385746866 +3539456720 1310323845 638053457 +2857802690 3759500888 535466408 +121228756 104171291 215677899 +1229787380 2876467686 69791865 +1474926843 990493599 9540129 +1845071813 1948377302 108742610 diff --git a/2024/AdventCommon/AdventCommon.csproj b/2024/AdventCommon/AdventCommon.csproj new file mode 100644 index 0000000..86ab0bb --- /dev/null +++ b/2024/AdventCommon/AdventCommon.csproj @@ -0,0 +1,9 @@ + + + + net9.0 + enable + enable + + + diff --git a/2024/AdventCommon/ParsedInput.cs b/2024/AdventCommon/ParsedInput.cs new file mode 100644 index 0000000..32d1b01 --- /dev/null +++ b/2024/AdventCommon/ParsedInput.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AdventCommon +{ + public abstract class ParsedInput + { + public virtual object? GetContext() { return null; } + + public abstract bool ParseLine(string line, object? context = null); + + public virtual long GetPart01() { return 0; } + public virtual long GetPart02() { return 0; } + + public ParsedInput(string fileName) + { + var input = new AdventCommon.PuzzleInput(fileName); + + foreach (var line in input.Lines) + { + if (!ParseLine(line, GetContext())) + { + throw new Exception("Line not formatted as expected"); + } + } + } + } +} diff --git a/2024/AdventCommon/PuzzleInput.cs b/2024/AdventCommon/PuzzleInput.cs new file mode 100644 index 0000000..ada80f4 --- /dev/null +++ b/2024/AdventCommon/PuzzleInput.cs @@ -0,0 +1,35 @@ +namespace AdventCommon +{ + public class PuzzleInput + { + public PuzzleInput(string fileName, bool ignoreEmptyLines = true) + { + using (StreamReader reader = System.IO.File.OpenText(fileName)) + { + while (!reader.EndOfStream) + { + string? line = reader.ReadLine(); + + if (line == null) { throw new InvalidDataException(); } + if (ignoreEmptyLines && String.IsNullOrWhiteSpace(line)) continue; + + Lines.Add(line); + } + } + } + + public List Lines { get; private set; } = new List(); + + public void Print() + { + for (int j = 0; j < Lines.Count; j++) + { + for (int i = 0; i < Lines[j].Length; i++) + { + Console.Write(Lines[j][i]); + } + Console.WriteLine(); + } + } + } +} \ No newline at end of file diff --git a/2024/AdventOfCode.sln b/2024/AdventOfCode.sln new file mode 100644 index 0000000..ff1ef53 --- /dev/null +++ b/2024/AdventOfCode.sln @@ -0,0 +1,67 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.6.33829.357 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Day01CSharp", "Day01CSharp\Day01CSharp.csproj", "{40E10A11-46AE-459F-8D01-BD2AE2261B4A}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AdventCommon", "AdventCommon\AdventCommon.csproj", "{15399021-F5A7-4A4E-81EB-0DFB8A328D83}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Day02CSharp", "Day02CSharp\Day02CSharp.csproj", "{FD978B93-02A8-492C-BB9F-91D96FD98A9E}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Day03CSharp", "Day03CSharp\Day03CSharp.csproj", "{94C0C575-4BA0-44C3-813E-FFB63D2A5A63}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Day04CSharp", "Day04CSharp\Day04CSharp.csproj", "{0949A58E-755F-4594-ACCA-9632BFE7A0A8}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Day05CSharp", "Day05CSharp\Day05CSharp.csproj", "{C3681618-04D2-460C-A529-D6544A67F079}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Day06CSharp", "Day06CSharp\Day06CSharp.csproj", "{5660DEAA-1FCF-4B00-A4BD-0B257F25E377}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Day07CSharp", "Day07CSharp\Day07CSharp.csproj", "{BB246D3B-246D-4CFF-9E31-1CABF3C342F4}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {40E10A11-46AE-459F-8D01-BD2AE2261B4A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {40E10A11-46AE-459F-8D01-BD2AE2261B4A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {40E10A11-46AE-459F-8D01-BD2AE2261B4A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {40E10A11-46AE-459F-8D01-BD2AE2261B4A}.Release|Any CPU.Build.0 = Release|Any CPU + {15399021-F5A7-4A4E-81EB-0DFB8A328D83}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {15399021-F5A7-4A4E-81EB-0DFB8A328D83}.Debug|Any CPU.Build.0 = Debug|Any CPU + {15399021-F5A7-4A4E-81EB-0DFB8A328D83}.Release|Any CPU.ActiveCfg = Release|Any CPU + {15399021-F5A7-4A4E-81EB-0DFB8A328D83}.Release|Any CPU.Build.0 = Release|Any CPU + {FD978B93-02A8-492C-BB9F-91D96FD98A9E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FD978B93-02A8-492C-BB9F-91D96FD98A9E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FD978B93-02A8-492C-BB9F-91D96FD98A9E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FD978B93-02A8-492C-BB9F-91D96FD98A9E}.Release|Any CPU.Build.0 = Release|Any CPU + {94C0C575-4BA0-44C3-813E-FFB63D2A5A63}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {94C0C575-4BA0-44C3-813E-FFB63D2A5A63}.Debug|Any CPU.Build.0 = Debug|Any CPU + {94C0C575-4BA0-44C3-813E-FFB63D2A5A63}.Release|Any CPU.ActiveCfg = Release|Any CPU + {94C0C575-4BA0-44C3-813E-FFB63D2A5A63}.Release|Any CPU.Build.0 = Release|Any CPU + {0949A58E-755F-4594-ACCA-9632BFE7A0A8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0949A58E-755F-4594-ACCA-9632BFE7A0A8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0949A58E-755F-4594-ACCA-9632BFE7A0A8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0949A58E-755F-4594-ACCA-9632BFE7A0A8}.Release|Any CPU.Build.0 = Release|Any CPU + {C3681618-04D2-460C-A529-D6544A67F079}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C3681618-04D2-460C-A529-D6544A67F079}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C3681618-04D2-460C-A529-D6544A67F079}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C3681618-04D2-460C-A529-D6544A67F079}.Release|Any CPU.Build.0 = Release|Any CPU + {5660DEAA-1FCF-4B00-A4BD-0B257F25E377}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5660DEAA-1FCF-4B00-A4BD-0B257F25E377}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5660DEAA-1FCF-4B00-A4BD-0B257F25E377}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5660DEAA-1FCF-4B00-A4BD-0B257F25E377}.Release|Any CPU.Build.0 = Release|Any CPU + {BB246D3B-246D-4CFF-9E31-1CABF3C342F4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BB246D3B-246D-4CFF-9E31-1CABF3C342F4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BB246D3B-246D-4CFF-9E31-1CABF3C342F4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BB246D3B-246D-4CFF-9E31-1CABF3C342F4}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {BABBCA3F-69A8-428C-BBD9-2621712E38E4} + EndGlobalSection +EndGlobal diff --git a/2024/Day01CSharp/Day01CSharp.csproj b/2024/Day01CSharp/Day01CSharp.csproj new file mode 100644 index 0000000..f2afcca --- /dev/null +++ b/2024/Day01CSharp/Day01CSharp.csproj @@ -0,0 +1,14 @@ + + + + Exe + net9.0 + enable + enable + + + + + + + diff --git a/2024/Day01CSharp/Program.cs b/2024/Day01CSharp/Program.cs new file mode 100644 index 0000000..97e6d61 --- /dev/null +++ b/2024/Day01CSharp/Program.cs @@ -0,0 +1,97 @@ +// See https://aka.ms/new-console-template for more information +using AdventCommon; +using System.Security.AccessControl; +using System.Security.Cryptography.X509Certificates; + +/** P1 **/ +var p1exampleSln = Part01(new Day01Parsed("example-input.txt")); +var p1puzzleSln = Part01(new Day01Parsed("puzzle-input.txt")); + +Console.WriteLine("Part01 Total Distance: " + p1exampleSln); +Console.WriteLine("Part01 Total Distance: " + p1puzzleSln); + +/** P2 **/ +var p2exampleSln = Part02(new Day01Parsed("example-input.txt")); +var p2puzzleSln = Part02(new Day01Parsed("puzzle-input.txt")); + +Console.WriteLine("Part02 Example Sum: " + p2exampleSln); +Console.WriteLine("Part02 Puzzle Sum: " + p2puzzleSln); + +int GetDistance(int l, int r) +{ + return Math.Abs(l - r); +} + +int Part01(Day01Parsed input) +{ + int distance = 0; + input.left.Sort(); + input.right.Sort(); + + for (int i = 0; i < input.left.Count; i++) + { + distance += GetDistance(input.left[i], input.right[i]); + } + + return distance; +} + +int Part02(Day01Parsed input) +{ + int total = 0; + + for (int i = 0; i < input.left.Count; i++) + { + var l = input.left[i]; + total += l * input.GetSimilarity(l); + } + + return total; +} + +class Day01Parsed : AdventCommon.ParsedInput +{ + public List left = new List(); + public List right = new List(); + + public int GetSimilarity(int value) + { + int instances = 0; + + foreach (var item in right) + { + if (item == value) + { + instances++; + } + } + + return instances; + } + + public Day01Parsed(string fileName) : base(fileName) + { + if (left.Count != right.Count) + { + throw new Exception("Improperly formatted input file"); + } + } + + public override bool ParseLine(string line, object? context = null) + { + var split = line.Split(' ', StringSplitOptions.RemoveEmptyEntries); + + if (split.Length != 2) + { + return false; + } + + var l = Int32.Parse(split[0]); + var r = Int32.Parse(split[1]); + + left.Add(l); + right.Add(r); + + return true; + } +} \ No newline at end of file diff --git a/2024/Day01CSharp/Properties/launchSettings.json b/2024/Day01CSharp/Properties/launchSettings.json new file mode 100644 index 0000000..9e54f12 --- /dev/null +++ b/2024/Day01CSharp/Properties/launchSettings.json @@ -0,0 +1,8 @@ +{ + "profiles": { + "Day01CSharp": { + "commandName": "Project", + "workingDirectory": "C:\\dev\\dev-drive\\DevSandbox\\AdventOfCode\\2024\\Day01CSharp" + } + } +} \ No newline at end of file diff --git a/2024/Day01CSharp/example-input.txt b/2024/Day01CSharp/example-input.txt new file mode 100644 index 0000000..ee911d1 --- /dev/null +++ b/2024/Day01CSharp/example-input.txt @@ -0,0 +1,6 @@ +3 4 +4 3 +2 5 +1 3 +3 9 +3 3 \ No newline at end of file diff --git a/2024/Day01CSharp/puzzle-input.txt b/2024/Day01CSharp/puzzle-input.txt new file mode 100644 index 0000000..3c9277a --- /dev/null +++ b/2024/Day01CSharp/puzzle-input.txt @@ -0,0 +1,1000 @@ +27636 67663 +92436 51410 +68957 77912 +36747 51149 +30882 77912 +46213 99914 +86101 84506 +33651 96019 +21290 82431 +63075 53396 +71804 79079 +59491 99914 +38723 14006 +33281 26247 +83935 50770 +86374 85083 +25576 54727 +73648 86649 +22409 70249 +29227 64316 +35430 67143 +56749 86649 +54666 96019 +34014 95399 +79952 39373 +11527 93723 +62980 57578 +30486 71734 +32658 65436 +93735 27438 +61456 18953 +25491 56656 +76585 62810 +25849 18414 +31715 71902 +70587 95582 +80976 14987 +38641 41417 +67621 73094 +85775 53902 +17220 40408 +88727 97556 +22359 67543 +91113 12527 +62161 31532 +11773 15282 +89645 63687 +25738 16174 +90797 16652 +57466 93723 +51356 19628 +25218 41212 +23778 85100 +69307 79895 +13469 20787 +88354 57627 +21993 13027 +55533 37964 +69092 70902 +48561 79752 +65224 87109 +87087 63928 +51086 13027 +29509 99914 +70303 58298 +70347 61384 +26945 76706 +70853 57779 +73422 69817 +44312 25891 +59429 14006 +37343 70249 +19979 70249 +69957 39312 +18726 53276 +83466 77883 +61518 13900 +42155 89500 +63098 60521 +14449 98681 +82637 43106 +22191 50560 +73961 11938 +45981 65414 +52835 21932 +64522 66095 +72719 18593 +95067 14254 +67827 67002 +91626 16259 +46648 97579 +64260 16945 +51036 96019 +11763 16672 +22050 54727 +81115 40408 +24109 99038 +61490 16520 +12415 86649 +70936 46470 +67369 17839 +66661 65147 +46002 97383 +92236 32003 +76595 80883 +99797 80845 +47203 21390 +12531 13900 +14567 85100 +97701 14006 +36042 77912 +68698 58773 +83171 93348 +46016 85412 +74415 15656 +54278 51529 +97371 98662 +71146 19396 +34619 49766 +27335 55419 +14750 15656 +20499 47003 +65181 18169 +25908 34850 +48966 46960 +56623 67545 +84778 14006 +23425 55003 +57291 77912 +34146 20637 +30067 85100 +43424 35599 +73421 14006 +91453 13935 +78330 51410 +76088 28885 +18833 13272 +20958 75765 +96718 30755 +56023 67143 +43806 52016 +14604 59721 +44139 12527 +65784 77912 +29570 76135 +47348 70249 +43549 86649 +76570 70249 +88162 71939 +34486 60331 +26741 92387 +41198 13377 +53021 50770 +98314 23805 +52060 12527 +86515 86649 +98183 99252 +79091 41638 +56721 32794 +69895 88727 +30104 55899 +48178 11818 +99914 18935 +18953 99914 +59782 97763 +69560 77912 +84587 39848 +16112 36887 +97943 88572 +48829 84079 +61496 50770 +16975 65569 +20602 88536 +28286 55419 +46401 96019 +33053 57040 +20081 70249 +20222 50466 +87107 65780 +70108 20762 +60443 18222 +86645 18222 +86432 61462 +10447 40408 +26601 30399 +20669 51410 +64973 54727 +26844 67876 +66711 15656 +50935 70954 +64188 27385 +72301 76224 +68529 19569 +60079 90182 +31692 56893 +32049 55692 +99568 24749 +68169 51227 +90063 70816 +70353 76443 +45207 83046 +10840 44770 +29710 88168 +84751 77912 +22547 39355 +32776 54727 +10792 96019 +86847 34709 +90912 94687 +61472 33330 +17627 82577 +59955 82580 +84314 67146 +17585 12527 +85936 90872 +19621 24662 +91812 81993 +32625 19895 +15656 32549 +99742 94319 +66920 85100 +24557 21855 +64760 54727 +83318 85721 +41316 96019 +70737 80023 +77115 60150 +48008 50770 +65812 50858 +49725 63057 +59430 29710 +56813 71902 +18412 69153 +74854 88293 +53478 61306 +46955 13896 +58632 18937 +19960 45246 +50522 14006 +13027 14006 +50345 25891 +32301 73422 +56811 74923 +33257 26767 +85044 57082 +44874 23425 +90402 83509 +35786 99914 +27689 73422 +12527 48603 +56563 40588 +49173 58298 +25094 21932 +52615 28332 +87738 47861 +15259 86649 +56450 12469 +99476 13027 +31357 20788 +29302 88536 +69527 99914 +79016 86091 +86187 75381 +37040 13900 +40789 17863 +52819 88536 +99512 67289 +43526 49745 +93256 92442 +86400 71902 +13900 32003 +86362 46470 +84806 89066 +13325 73969 +38597 82656 +26209 71126 +67143 49421 +12555 73422 +49109 47621 +12757 93723 +60966 54727 +91829 82268 +16715 15691 +68953 93723 +29390 76089 +17838 65569 +51410 31825 +87719 13027 +20487 39355 +56471 24545 +21675 43800 +13445 54727 +20493 65829 +12310 73945 +29366 93723 +55574 74438 +20558 40408 +60707 60326 +67675 28319 +68219 99051 +55901 12056 +36090 67102 +21645 93723 +91741 70249 +86631 68917 +16190 73338 +69156 78863 +25891 12529 +60505 76667 +91367 54996 +35197 12527 +96289 65569 +99720 13027 +60152 67328 +47373 40408 +46470 29710 +92309 49534 +96399 17417 +19136 80925 +75645 55419 +60134 51410 +44963 25891 +57213 36908 +32935 13027 +13760 16748 +10501 48177 +24699 88567 +87817 63343 +98506 96019 +13109 51410 +98827 88536 +81592 29559 +32418 96845 +23249 35212 +33739 18823 +91660 94468 +41270 14006 +61624 45215 +94473 82748 +81411 22202 +62042 79434 +87156 78604 +96708 39355 +21576 94644 +58090 88727 +75796 88727 +36732 65569 +98878 93723 +77836 40408 +12739 71850 +14393 65616 +54759 54727 +91950 67999 +32038 71414 +88128 88727 +18687 51410 +86649 10180 +54652 14006 +51200 94013 +25759 73695 +78325 88536 +85100 15068 +77314 70249 +29771 25891 +48512 39931 +32758 23781 +65569 81723 +76547 81341 +97796 93723 +23560 86649 +85749 75599 +90577 14006 +89148 88727 +87413 25602 +80005 86649 +18222 50953 +84166 12223 +21431 55419 +51539 88536 +39002 77912 +40699 93886 +78076 33894 +50213 58400 +20711 12527 +66242 50770 +58894 95457 +20142 13027 +75889 82440 +42984 27810 +26613 18222 +17725 46470 +78045 58527 +70755 96361 +34750 71902 +23788 36870 +71435 15656 +69573 76045 +97075 41621 +68889 74341 +43705 71777 +51174 15068 +25175 77912 +46042 18071 +43652 91644 +17776 13027 +21586 32003 +55557 44791 +15068 26861 +31285 37296 +41268 12527 +12274 70661 +64942 83051 +40158 27491 +97113 12527 +64437 50770 +29587 52457 +93723 18953 +26593 61122 +77159 36445 +70733 11733 +58626 69962 +88075 10820 +27706 71880 +62175 19584 +29037 77912 +39846 88536 +52710 17260 +37988 12527 +98941 40408 +55492 27433 +49614 49375 +73031 53756 +69107 93963 +13487 13027 +88557 52956 +19978 54109 +70308 61626 +97197 75015 +29461 13027 +49851 33862 +61641 43710 +97372 21774 +24845 11676 +23306 33519 +79069 85100 +90401 66032 +70009 38628 +74208 90870 +66927 34883 +83113 78562 +67665 13027 +50134 79665 +39442 94713 +34392 81306 +74601 88727 +15396 42882 +75388 94071 +60137 52050 +11501 44410 +70249 86649 +34514 95654 +58802 59932 +60092 82834 +59700 84142 +73594 84251 +41063 23656 +24258 85833 +77170 71729 +57174 93723 +52939 49958 +17073 40408 +91476 19173 +67849 46955 +42366 85100 +31967 18222 +51791 29710 +80503 21818 +21171 29593 +35814 88536 +50383 18222 +68500 73422 +60941 38247 +80579 25728 +56150 40408 +91392 58387 +97794 36481 +24938 16433 +20897 29710 +69005 86270 +23332 82430 +96092 40408 +55606 47408 +69393 25538 +88805 93865 +25377 70249 +74563 88727 +89699 53054 +45796 55419 +56407 67840 +72925 97565 +88536 75060 +33881 70279 +19496 13027 +26289 44211 +51334 88536 +12579 46470 +69622 39657 +17900 77122 +67747 89325 +79881 21053 +61202 42967 +70883 87544 +16535 93383 +26503 45342 +28297 61791 +50933 96173 +32002 32699 +34690 57980 +28399 29710 +13660 21932 +98065 27996 +50853 35963 +88438 86562 +36165 73677 +79940 40408 +40541 67170 +20091 91424 +39355 99566 +13081 14006 +58083 81235 +54830 49834 +32825 96019 +83692 43716 +95628 73356 +74443 89957 +35677 36499 +75279 88536 +71821 80590 +84260 98484 +59645 59826 +35932 50116 +75575 22994 +73616 84555 +51144 93243 +60005 14006 +12864 10684 +77834 48318 +69011 41387 +97024 46470 +98000 64609 +26029 33500 +33877 94750 +55830 93723 +15334 85100 +89061 23221 +11922 77337 +47976 22799 +11635 91933 +75213 24886 +90993 41805 +90684 25891 +72604 76753 +42647 85843 +40408 68133 +75946 51218 +70196 25891 +30412 57914 +97066 18953 +38230 13899 +29377 11580 +75574 72968 +29393 72845 +77297 89211 +16269 94844 +82893 88061 +37116 76838 +80997 20602 +97618 91685 +33698 51410 +61935 12527 +44252 79583 +46297 65424 +21075 15121 +61997 65569 +82784 24455 +32616 50770 +65600 52179 +70762 93723 +33830 14006 +59127 76111 +79111 42235 +14634 65569 +61114 98404 +34701 57155 +66321 32003 +71411 77114 +36070 54003 +44096 31057 +17790 54727 +94384 50770 +55954 71902 +48200 87183 +77912 12527 +68228 18280 +98972 44903 +36198 50770 +38106 65335 +25785 12527 +76187 77603 +23889 85100 +68678 41314 +22106 18953 +24718 77912 +23942 40408 +78992 55995 +69199 55700 +53735 79770 +44697 51111 +32874 28161 +65350 46470 +31226 70249 +25736 68636 +35753 99319 +84252 54258 +28351 73446 +36754 11085 +81734 37763 +20447 86649 +93586 53062 +68321 90392 +60154 94363 +94162 12527 +49437 88536 +36753 77770 +52652 51410 +44124 77727 +41114 39334 +16864 77072 +83149 65132 +59730 54727 +84057 23618 +30656 12284 +92801 37685 +49414 78016 +21932 88727 +83899 99914 +50417 73542 +42247 36961 +11620 12527 +89175 55534 +29239 54727 +52046 39122 +10565 13027 +94606 34488 +80368 51410 +19058 70249 +52560 88727 +94907 94594 +22583 59070 +87045 57573 +81908 66470 +52664 14006 +85444 50714 +79620 41857 +64520 28656 +77565 40408 +54891 79480 +60407 67143 +94156 85508 +78606 12527 +49973 99914 +18848 12527 +16148 13383 +39583 88536 +71135 76625 +15135 88536 +81304 13900 +78906 24249 +70225 84691 +82947 40735 +56886 59761 +87699 68570 +48939 46470 +72665 99460 +29077 13027 +37693 86226 +49023 23978 +14671 63325 +95319 61292 +40288 73784 +40842 70647 +52129 68530 +59166 91619 +21052 11307 +98213 99699 +61504 13900 +27254 99914 +30050 25730 +75338 80979 +91814 16267 +84916 50770 +51427 88782 +51277 82884 +50738 85720 +71902 32003 +61287 54727 +48427 93265 +34807 51980 +56975 96019 +58937 51410 +64930 22005 +72532 55499 +40608 56661 +53656 88727 +62477 96019 +48812 88536 +37482 25188 +32909 71902 +60132 12743 +36648 92407 +26489 46955 +25601 23377 +17624 71902 +69982 63535 +23798 12527 +14088 46470 +79596 12527 +47284 18073 +66594 82908 +47309 21386 +41035 86649 +95662 18222 +19255 70249 +59514 22092 +83736 32111 +19643 64859 +30590 26610 +16132 94311 +61696 45689 +67551 96019 +12741 12527 +78583 25891 +26961 17506 +78162 56028 +80916 83853 +98196 76265 +58308 16344 +40122 58950 +53743 21620 +24428 86026 +78836 73860 +10212 38302 +19115 36550 +15104 93723 +16369 51410 +68786 14006 +43892 40408 +23295 29751 +91988 79020 +20067 54727 +43312 77912 +68147 71902 +13779 32131 +94847 40408 +91423 73498 +69229 13900 +25697 72238 +99306 63294 +66446 48149 +69853 29710 +92750 51625 +81823 55419 +36427 15068 +86459 66813 +48199 81641 +20218 56086 +83018 39032 +72219 50770 +94256 93723 +32003 39207 +47335 14006 +42785 62691 +74560 63579 +27781 86649 +15494 13647 +92404 45629 +84689 85500 +17033 21765 +10332 13027 +35398 79463 +92891 79965 +33833 48986 +55107 99914 +57461 88727 +60916 87668 +79014 20602 +17965 13027 +10123 29710 +36522 46583 +83178 51594 +92593 37792 +38714 21861 +40023 13395 +72206 73081 +36381 75286 +90435 26071 +97471 69336 +97952 40145 +56034 20097 +13292 81538 +20477 50770 +11873 77989 +60247 50523 +67149 48592 +49108 68874 +68890 87402 +40881 94963 +35432 13027 +39476 47915 +90012 54566 +92534 48674 +92032 50770 +27585 79761 +37875 37853 +89774 13027 +61075 15674 +60756 87360 +47898 92766 +96598 68826 +50236 47764 +55057 70249 +54727 17366 +13681 54727 +17072 77525 +42614 90096 +98669 82051 +57089 13900 +18696 54195 +94345 35225 +44841 88536 +38879 23114 +83766 94182 +58826 99914 +41811 85416 +72019 50770 +38976 86649 +42451 59949 +14546 55721 +99835 97560 +49639 30033 +73524 60863 +65556 87850 +96707 58953 +27288 74220 +46483 15656 +72352 96712 +32100 70249 +63167 14314 +16622 95903 +19000 15656 +42483 78654 +54025 76612 +70377 60749 +39261 36106 +21224 96019 +50908 82897 +33035 16572 +96495 31039 +58082 88727 +81593 19590 +35755 54727 +67526 44620 +72752 89000 +83650 17979 +70801 85100 +25664 39700 +44529 12527 +59027 70249 +16374 51410 +80656 73108 +66428 70249 +13405 29710 +24375 51410 +68087 40408 +76117 48681 +94015 65689 +76691 16635 +99054 13378 +30917 90481 +96893 25891 +62567 21627 +94245 10321 +14080 40408 +49942 29710 +27954 25201 +75660 93412 +78795 88727 +77270 88727 +85985 42151 +30119 46470 +24570 15656 +38301 25919 +60012 82323 +17386 61141 +41982 15656 +52502 14428 +40518 16829 +67678 88727 +98468 67870 +58153 18953 +99115 15112 +46175 92280 +76963 70249 +47731 85214 +23760 73422 +67026 30272 +60174 27340 +53612 13317 +54298 88727 +96019 77912 +38623 64924 +64015 99483 +78520 32003 +55419 65046 +16763 77012 +79038 70196 +10821 93823 +21975 92009 +59774 70249 +49520 59948 +23429 74262 +74297 84035 +60268 86649 +97106 70249 +67040 13027 +64952 32110 +28218 14006 +40852 83878 +14006 78414 +71194 95950 +49032 88536 +93565 76366 +87180 54727 +44863 27608 +45305 75367 +92628 30076 +53704 25974 +98469 33452 +59903 54979 +10499 20819 +83104 67143 +96322 65569 +32582 14006 +56098 93723 +94744 60959 +87479 15950 +89231 11601 +50869 70404 +38814 73422 +32132 73422 +74145 35520 +90512 88727 +70617 38209 +58298 48954 +56952 29710 +68984 70249 +72264 56329 +58999 54727 +48633 42365 +56154 57575 +24276 54727 +24166 14006 +43755 59506 +14184 65569 +89299 31443 +44142 46882 +91129 86649 +85560 86681 +64723 14006 +15506 10738 +48493 71902 +66107 48245 +91213 16367 +52172 54762 +57989 56463 +12155 82395 +77388 25091 +43192 47163 +72417 30734 +49430 71902 +70268 85100 +44133 81902 +19946 82107 +39220 51410 +28498 29710 +50770 27829 +95962 15656 +61245 14960 +74434 46710 +21991 30826 diff --git a/2024/Day02CSharp/Day02CSharp.csproj b/2024/Day02CSharp/Day02CSharp.csproj new file mode 100644 index 0000000..c9cae6e --- /dev/null +++ b/2024/Day02CSharp/Day02CSharp.csproj @@ -0,0 +1,14 @@ + + + + Exe + net9.0 + enable + enable + + + + + + + diff --git a/2024/Day02CSharp/Program.cs b/2024/Day02CSharp/Program.cs new file mode 100644 index 0000000..b1031a7 --- /dev/null +++ b/2024/Day02CSharp/Program.cs @@ -0,0 +1,141 @@ +Day02Parsed exParsed = new Day02Parsed("example-input.txt"); + +Console.WriteLine("Example Part01: {0}", exParsed.GetSafeReportCount01()); +Console.WriteLine("Example Part02: {0}", exParsed.GetSafeReportCount02()); + +Day02Parsed pzParsed = new Day02Parsed("puzzle-input.txt"); + +Console.WriteLine("Puzzle Part01: {0}", pzParsed.GetSafeReportCount01()); +Console.WriteLine("Puzzle Part02: {0}", pzParsed.GetSafeReportCount02()); + +class Day02Parsed : AdventCommon.ParsedInput +{ + List> Reports = new List>(); + + public Day02Parsed(string fileName) : base(fileName) + { + + } + + public int GetSafeReportCount01() + { + int count = 0; + + for (int i = 0; i < Reports.Count; i++) + { + if (IsSafe(Reports[i])) + { + count++; + } + } + + return count; + } + + public int GetSafeReportCount02() + { + int count = 0; + + for (int i = 0; i < Reports.Count; i++) + { + // First see if its safe outright + if (IsSafe(Reports[i])) + { + count++; + } + else + { + // Remove one start to end and check again + for (int j = 0; j < Reports[i].Count; j++) + { + List newReport = new List(Reports[i]); + newReport.RemoveAt(j); + if (IsSafe(newReport)) + { + count++; + break; + } + } + } + } + + return count; + } + + public bool IsSafe(List report) + { + bool isAscending = false; + + if ( report[0] < report[1] ) + { + isAscending = true; + } + + { + int rightDiff = report[1] - report[0]; + + if (Math.Abs(rightDiff) < 1 || Math.Abs(rightDiff) > 3) + { + return false; + } + } + + for (int i = 1; i < report.Count - 1; i++) + { + int leftDiff = report[i] - report[i - 1]; + int rightDiff = report[i + 1] - report[i]; + + // if ascending and either difference is negative, not safe + if (isAscending && (leftDiff < 0 || rightDiff < 0)) + { + return false; + } + // if descending and either difference is positive, not safe + else if (!isAscending && (rightDiff > 0 || leftDiff > 0)) + { + return false; + } + + if (Math.Abs(leftDiff) < 1 || Math.Abs(leftDiff) > 3) + { + return false; + } + + if (Math.Abs(rightDiff) < 1 || Math.Abs(rightDiff) > 3) + { + return false; + } + } + + { + int leftDiff = report[report.Count - 1] - report[report.Count - 2]; + if (isAscending && leftDiff < 0) + { + return false; + } + + if (Math.Abs(leftDiff) < 1 || Math.Abs(leftDiff) > 3) + { + return false; + } + } + + return true; + } + + + public override bool ParseLine(string line, object? context = null) + { + List levels = new List(); + var split = line.Split(' ', StringSplitOptions.RemoveEmptyEntries); + + foreach (var level in split) + { + levels.Add(Int32.Parse(level)); + } + + Reports.Add(levels); + + return true; + } +} \ No newline at end of file diff --git a/2024/Day02CSharp/Properties/launchSettings.json b/2024/Day02CSharp/Properties/launchSettings.json new file mode 100644 index 0000000..24140e2 --- /dev/null +++ b/2024/Day02CSharp/Properties/launchSettings.json @@ -0,0 +1,8 @@ +{ + "profiles": { + "Day02CSharp": { + "commandName": "Project", + "workingDirectory": "C:\\dev\\dev-drive\\DevSandbox\\AdventOfCode\\2024\\Day02CSharp" + } + } +} \ No newline at end of file diff --git a/2024/Day02CSharp/example-input.txt b/2024/Day02CSharp/example-input.txt new file mode 100644 index 0000000..2d6faf5 --- /dev/null +++ b/2024/Day02CSharp/example-input.txt @@ -0,0 +1,6 @@ +7 6 4 2 1 +1 2 7 8 9 +9 7 6 2 1 +1 3 2 4 5 +8 6 4 4 1 +1 3 6 7 9 \ No newline at end of file diff --git a/2024/Day02CSharp/puzzle-input.txt b/2024/Day02CSharp/puzzle-input.txt new file mode 100644 index 0000000..7dc04c9 --- /dev/null +++ b/2024/Day02CSharp/puzzle-input.txt @@ -0,0 +1,1000 @@ +62 65 67 70 73 76 75 +68 71 73 76 78 78 +77 80 81 82 86 +44 47 48 51 53 58 +51 53 56 57 59 56 57 60 +68 70 71 69 72 74 71 +59 61 63 66 64 66 66 +55 56 55 58 61 63 64 68 +3 4 5 8 11 9 10 17 +16 18 18 21 22 +70 71 73 73 74 76 78 75 +16 17 20 20 23 23 +10 12 12 15 16 17 21 +50 53 56 56 63 +25 26 29 33 36 +52 54 56 57 60 64 66 63 +59 60 63 66 70 73 73 +42 43 45 47 51 54 58 +69 71 72 73 75 79 86 +13 16 17 24 25 28 31 33 +9 10 17 19 16 +6 7 8 15 18 18 +17 18 24 27 31 +20 21 23 30 36 +27 24 25 26 28 31 34 +29 26 28 30 31 34 33 +86 83 84 86 87 89 91 91 +81 79 80 83 85 89 +56 55 57 59 66 +49 48 46 47 49 +77 76 77 76 74 +42 41 44 43 46 46 +86 85 86 85 88 92 +16 13 14 11 16 +34 32 32 35 36 39 41 +36 34 35 36 36 38 35 +8 6 8 8 10 13 13 +17 15 15 18 21 25 +18 17 17 18 25 +85 84 86 88 89 93 96 +37 36 40 41 38 +25 22 24 28 29 29 +70 68 71 74 78 82 +16 13 14 15 17 21 27 +58 57 62 63 65 66 68 +84 81 84 85 90 88 +67 66 68 74 75 78 78 +68 66 73 76 80 +38 35 41 43 45 46 52 +63 63 64 67 69 70 71 74 +28 28 31 33 31 +43 43 44 47 48 49 52 52 +68 68 69 72 74 75 79 +60 60 62 65 67 70 76 +38 38 37 38 40 +18 18 21 22 25 23 22 +19 19 16 17 19 20 20 +24 24 22 25 29 +38 38 35 38 43 +14 14 14 16 18 20 +55 55 55 56 53 +32 32 35 35 38 41 41 +14 14 15 15 16 20 +18 18 18 19 20 27 +42 42 45 49 52 54 56 +19 19 23 26 27 24 +71 71 73 76 80 83 85 85 +35 35 38 42 46 +25 25 29 32 37 +28 28 30 35 37 38 40 41 +33 33 38 39 38 +69 69 72 79 79 +8 8 13 14 15 18 22 +40 40 42 47 53 +83 87 89 90 91 +18 22 25 27 28 30 32 31 +47 51 54 57 60 60 +66 70 72 74 78 +24 28 31 33 40 +30 34 33 34 36 +65 69 67 70 72 74 73 +72 76 77 80 83 80 80 +54 58 61 58 62 +59 63 65 66 65 66 72 +28 32 32 34 35 38 41 +16 20 21 23 23 22 +48 52 52 55 58 58 +17 21 21 24 25 29 +19 23 24 25 25 28 33 +39 43 44 47 51 53 54 +4 8 10 14 16 17 18 17 +7 11 12 15 19 22 22 +70 74 77 78 80 84 88 +60 64 67 70 74 76 81 +47 51 58 59 60 62 64 +9 13 14 16 22 19 +21 25 32 33 35 35 +78 82 89 91 95 +15 19 26 29 36 +53 58 59 61 64 66 +52 59 60 62 63 64 66 65 +60 67 70 71 71 +67 72 75 76 79 81 85 +19 25 26 28 30 37 +13 19 21 18 20 +10 16 19 22 24 26 23 21 +37 42 41 44 46 46 +53 60 63 64 62 64 68 +48 54 55 53 59 +49 54 57 57 60 63 65 +27 34 35 35 38 41 38 +37 42 45 48 49 51 51 51 +68 75 78 78 80 84 +36 41 43 43 49 +36 42 45 46 50 52 +24 31 35 36 35 +3 10 13 14 18 21 21 +25 32 34 37 41 45 +51 57 58 60 64 71 +10 17 19 21 23 25 32 34 +41 46 48 51 54 60 58 +7 12 15 17 23 25 27 27 +11 18 19 25 29 +56 63 64 67 70 75 80 +22 21 18 17 16 14 15 +86 83 81 78 77 76 73 73 +90 88 85 82 81 78 75 71 +88 86 85 82 79 76 70 +90 88 87 88 86 +35 34 33 32 29 26 27 30 +95 94 93 90 92 91 91 +32 29 28 25 28 26 23 19 +62 61 59 58 61 59 56 51 +32 29 29 28 26 +47 46 45 44 44 46 +84 82 79 77 74 74 74 +16 14 13 11 10 10 9 5 +73 71 68 68 62 +42 39 35 32 29 26 24 +98 95 94 92 91 87 86 89 +83 82 78 77 76 74 74 +83 80 76 73 69 +25 23 19 18 15 12 6 +69 68 66 60 58 +15 14 8 5 2 4 +55 52 50 48 46 39 37 37 +42 41 40 39 37 31 27 +90 88 86 84 78 72 +37 39 36 33 31 29 +65 67 64 62 64 +57 59 56 54 51 51 +49 52 51 49 46 45 43 39 +47 49 46 45 42 36 +55 58 56 54 55 53 52 51 +29 32 29 30 29 31 +95 98 97 96 97 97 +36 39 36 39 37 33 +79 81 79 77 80 73 +55 57 56 56 54 52 51 +27 30 28 25 25 22 19 21 +61 64 62 62 61 61 +51 53 50 48 46 46 45 41 +28 31 30 30 27 25 20 +27 29 25 22 19 +52 54 53 49 51 +31 33 31 29 28 24 21 21 +29 30 26 23 21 20 16 +59 61 59 55 53 48 +17 18 17 14 12 9 4 3 +67 70 68 63 65 +42 45 43 42 36 36 +34 36 35 29 27 25 21 +62 64 63 62 56 53 51 46 +62 62 59 56 55 +93 93 90 87 86 85 83 85 +74 74 71 68 67 66 66 +31 31 28 25 22 18 +40 40 39 36 34 32 25 +16 16 14 17 16 15 13 11 +18 18 15 12 13 12 14 +77 77 75 77 76 76 +53 53 54 51 48 44 +81 81 84 82 79 76 74 67 +74 74 71 71 68 66 65 64 +4 4 4 1 2 +24 24 21 21 20 20 +69 69 66 64 64 63 62 58 +64 64 61 61 59 57 52 +28 28 25 23 19 16 13 10 +22 22 20 16 14 13 15 +68 68 64 63 62 62 +64 64 62 58 55 52 49 45 +42 42 38 37 36 31 +51 51 50 49 46 40 38 +77 77 71 69 68 67 65 68 +25 25 24 19 17 16 15 15 +99 99 98 93 90 86 +82 82 76 74 72 65 +91 87 86 83 81 80 79 78 +55 51 50 47 44 42 40 42 +56 52 51 48 46 43 41 41 +72 68 66 63 62 59 55 +56 52 51 50 48 47 44 37 +27 23 21 23 22 +10 6 4 6 7 +66 62 65 62 59 57 57 +76 72 69 71 69 65 +45 41 42 41 39 32 +28 24 24 21 20 18 +27 23 22 21 21 20 17 18 +41 37 35 32 32 31 31 +89 85 82 79 79 76 75 71 +19 15 12 9 7 7 2 +54 50 47 43 42 41 +32 28 24 22 23 +51 47 43 42 41 40 37 37 +41 37 36 32 31 27 +97 93 89 87 85 82 81 76 +66 62 59 58 52 49 +65 61 60 57 51 53 +99 95 88 87 87 +88 84 82 81 75 74 71 67 +76 72 66 63 62 60 55 +46 41 38 36 33 31 28 +82 75 72 69 71 +58 53 52 49 49 +53 46 45 42 38 +68 62 61 58 57 55 50 +66 60 58 56 57 56 54 +57 51 48 46 43 46 45 46 +65 60 58 56 57 55 55 +73 68 69 67 63 +29 24 23 24 18 +34 28 26 24 21 19 19 17 +51 46 45 45 46 +15 8 5 3 2 2 2 +56 51 50 48 48 47 43 +57 51 49 48 48 42 +81 76 73 69 68 +92 86 83 82 78 81 +56 51 49 45 42 40 40 +91 84 80 77 76 72 +44 39 37 33 30 25 +64 57 55 54 51 44 41 38 +32 27 24 18 17 16 14 17 +64 58 51 49 48 45 45 +72 66 64 59 57 53 +83 78 72 70 68 67 60 +47 48 50 52 55 52 +64 67 70 71 72 72 +76 77 80 83 84 87 90 94 +77 79 82 85 86 87 88 93 +44 47 46 47 49 +15 17 20 18 20 18 +22 24 27 28 30 29 29 +20 22 24 21 25 +84 85 88 87 90 96 +18 19 20 22 24 24 27 29 +23 24 24 26 27 29 28 +24 25 25 28 28 +50 53 53 55 56 60 +27 28 29 30 30 32 39 +48 49 52 53 54 58 60 63 +16 17 20 24 27 24 +5 7 8 10 12 16 16 +80 81 84 85 86 87 91 95 +10 11 14 18 24 +48 51 53 58 59 62 64 66 +23 24 25 28 33 30 +30 33 34 35 41 42 43 43 +8 10 11 13 14 20 24 +28 30 31 36 39 42 48 +61 59 61 62 65 67 69 +73 70 72 73 71 +90 88 89 91 93 93 +15 14 17 19 20 22 24 28 +46 45 47 50 52 53 58 +70 67 69 66 69 +66 65 67 65 68 69 70 68 +8 7 5 6 9 11 11 +5 3 1 2 4 8 +93 92 90 92 93 99 +14 12 12 14 16 +16 13 13 14 16 15 +23 22 22 24 27 28 29 29 +34 33 33 34 37 41 +11 9 11 11 12 13 15 20 +28 25 27 31 32 34 +63 62 66 68 70 67 +35 34 37 38 42 42 +10 8 12 13 16 19 23 +42 39 43 44 46 52 +84 81 83 90 93 +56 55 61 64 61 +63 60 62 63 68 70 71 71 +83 80 82 83 88 92 +71 69 75 77 84 +69 69 70 72 73 76 +38 38 39 40 41 43 40 +6 6 8 10 11 13 13 +46 46 49 52 55 56 60 +24 24 25 27 29 31 32 37 +23 23 24 27 28 29 26 27 +82 82 83 86 83 84 82 +48 48 51 54 55 52 52 +88 88 90 89 91 94 98 +11 11 14 17 15 16 23 +38 38 40 40 43 +35 35 38 40 40 38 +26 26 27 27 27 +1 1 1 3 7 +1 1 4 4 7 10 11 18 +83 83 87 89 91 93 +37 37 40 41 42 46 49 46 +9 9 10 14 15 18 18 +67 67 69 71 74 77 81 85 +62 62 66 67 69 75 +20 20 21 23 29 32 33 36 +4 4 10 13 15 16 15 +44 44 45 52 53 53 +80 80 87 88 89 93 +13 13 14 16 22 29 +25 29 31 32 34 35 +86 90 92 94 95 92 +28 32 35 37 39 42 44 44 +26 30 31 32 35 39 +54 58 61 62 63 65 72 +72 76 79 81 82 79 81 83 +49 53 56 58 60 63 60 57 +66 70 72 69 69 +84 88 85 86 90 +85 89 91 94 95 92 98 +8 12 13 13 14 16 19 +85 89 92 92 91 +74 78 79 81 82 84 84 84 +57 61 61 64 66 70 +36 40 40 42 44 51 +2 6 8 9 12 16 17 18 +26 30 31 35 36 35 +50 54 58 61 64 64 +47 51 52 54 58 59 63 +67 71 73 77 83 +7 11 18 20 21 23 +66 70 73 80 77 +50 54 59 61 64 67 67 +76 80 81 82 83 88 90 94 +68 72 73 80 82 84 91 +18 23 26 27 29 30 +67 74 77 78 75 +18 24 25 27 27 +57 64 67 68 69 73 +8 13 15 16 18 19 21 27 +68 74 72 73 76 78 79 80 +17 22 19 22 19 +72 79 78 80 80 +42 47 44 45 48 52 +20 27 28 27 32 +44 51 54 54 56 57 60 +43 49 52 55 55 56 58 55 +63 70 71 71 74 75 77 77 +17 22 25 27 30 30 34 +18 24 27 27 29 30 32 39 +56 61 64 68 71 74 +48 55 59 60 61 58 +13 19 22 25 29 31 31 +35 40 41 42 45 49 53 +24 31 34 35 37 41 46 +62 69 70 73 78 81 83 +47 52 54 59 62 65 68 67 +16 23 24 27 29 36 38 38 +57 62 63 65 72 73 75 79 +68 73 74 79 82 87 +23 21 18 15 12 11 12 +86 85 82 79 77 77 +24 23 20 19 17 13 +89 87 86 84 81 78 72 +10 9 7 4 2 5 4 3 +74 73 71 72 75 +92 90 88 86 83 86 83 83 +83 81 80 82 78 +33 32 31 33 32 27 +21 20 18 15 15 12 10 7 +21 20 17 15 14 12 12 14 +51 48 46 43 43 40 39 39 +46 43 43 41 40 36 +71 68 67 64 63 63 56 +37 35 32 28 27 26 23 +42 41 37 36 34 33 30 32 +44 41 40 38 34 34 +25 24 22 18 17 14 10 +81 79 77 76 72 69 68 62 +36 34 29 28 27 24 21 +21 20 18 16 9 12 +74 72 65 64 62 62 +70 67 64 62 56 54 50 +89 88 82 80 77 74 73 66 +79 81 78 77 75 +20 23 20 19 17 19 +78 79 78 75 74 72 72 +86 88 87 84 83 80 79 75 +98 99 98 97 95 93 86 +16 18 17 18 16 +21 23 21 24 25 +28 29 26 25 24 26 26 +46 48 45 48 44 +27 29 26 23 25 23 17 +17 18 17 17 16 15 +85 86 83 82 82 79 82 +88 91 91 88 88 +90 91 91 88 86 84 81 77 +43 45 43 43 40 34 +18 20 17 15 14 11 7 6 +18 19 18 15 13 9 8 10 +95 97 93 90 90 +89 92 91 90 86 84 83 79 +95 96 92 89 87 85 80 +29 32 29 23 21 +21 22 19 17 11 9 12 +87 88 85 83 81 76 76 +57 60 54 51 49 45 +85 87 81 80 77 76 73 67 +30 30 29 26 24 21 20 +65 65 64 63 60 59 60 +49 49 48 47 46 45 45 +56 56 53 52 51 47 +82 82 80 77 75 68 +47 47 48 45 44 +81 81 82 79 82 +36 36 39 37 37 +49 49 47 45 43 42 45 41 +88 88 87 90 85 +54 54 52 52 51 +89 89 89 87 84 83 86 +33 33 31 31 28 25 25 +58 58 57 54 54 52 51 47 +89 89 86 86 85 78 +19 19 17 14 11 7 4 1 +68 68 67 63 64 +78 78 74 71 70 69 69 +56 56 54 50 46 +23 23 20 18 14 12 5 +50 50 49 48 47 46 40 37 +40 40 37 34 28 31 +88 88 87 82 80 77 75 75 +59 59 56 55 48 44 +46 46 43 38 31 +83 79 76 75 72 70 +67 63 62 59 56 53 52 55 +94 90 89 87 87 +46 42 41 38 36 33 29 +48 44 42 41 39 37 35 29 +68 64 65 64 61 59 +59 55 53 56 58 +66 62 59 61 59 59 +35 31 32 31 29 25 +90 86 87 85 82 80 77 72 +68 64 62 60 60 58 57 55 +26 22 21 18 18 17 18 +44 40 39 39 39 +53 49 46 44 44 40 +63 59 58 56 56 54 48 +93 89 85 84 81 +96 92 89 88 86 82 79 81 +22 18 17 13 13 +77 73 69 67 63 +91 87 84 83 79 76 75 70 +98 94 91 85 84 81 +14 10 9 3 5 +90 86 81 78 75 73 73 +31 27 24 22 19 18 13 9 +83 79 72 70 64 +83 76 75 72 69 66 64 61 +48 41 39 38 35 34 37 +73 68 66 65 62 60 58 58 +94 89 88 86 82 +65 58 55 52 50 47 42 +43 36 35 34 32 30 33 32 +59 54 55 53 50 52 +30 23 21 19 22 22 +10 5 4 3 6 2 +60 53 51 48 46 49 42 +14 9 9 7 5 +27 21 18 17 16 16 19 +94 89 86 83 83 80 80 +37 31 31 28 24 +52 47 45 42 40 40 35 +36 31 30 28 24 22 +35 30 28 25 22 20 16 18 +84 78 75 71 71 +77 71 68 64 60 +24 17 16 15 13 9 7 1 +31 25 18 15 12 +47 42 35 32 31 30 32 +38 31 28 26 20 20 +96 90 89 86 80 79 78 74 +30 24 23 21 16 9 +77 77 82 84 87 89 91 89 +13 13 12 14 16 20 +69 64 63 59 57 54 51 51 +82 87 88 90 93 95 95 +85 79 76 75 76 74 77 +60 64 67 73 79 +86 86 85 79 75 +74 68 67 61 59 +61 57 54 53 53 52 51 44 +79 84 81 83 85 90 +80 80 76 74 73 70 70 +30 31 31 29 26 23 26 +35 36 39 42 40 +38 38 41 41 44 41 +88 91 90 89 87 85 82 78 +32 30 28 27 21 21 +89 89 86 84 81 84 83 78 +40 44 48 49 50 52 55 56 +92 89 91 91 88 +80 86 89 95 94 +49 50 50 47 42 +23 28 31 34 40 +39 37 35 37 31 +25 28 26 23 21 22 19 17 +44 38 37 39 37 33 +88 90 86 83 78 +77 79 83 85 88 95 +60 63 61 64 60 +70 64 67 64 61 60 +38 45 48 51 54 57 59 57 +58 56 53 56 52 +23 21 23 25 26 27 27 +66 60 59 57 56 56 54 57 +49 49 49 46 44 39 +40 35 33 31 26 +65 63 70 73 73 +38 31 26 25 20 +43 39 36 32 29 23 +56 54 52 50 50 47 45 39 +58 55 58 59 61 58 59 64 +47 45 43 45 45 +81 81 78 77 75 71 64 +48 42 41 38 39 36 33 33 +78 77 83 85 89 +14 17 15 14 11 9 +62 58 57 51 50 47 43 +95 92 95 96 95 +62 65 66 70 73 75 75 +32 33 33 31 30 +94 93 92 87 83 +16 16 19 24 27 28 30 32 +60 62 60 57 55 56 51 +70 73 71 74 73 72 72 +9 8 11 18 20 23 22 +74 69 67 65 63 57 54 54 +14 15 13 11 12 13 +26 30 32 30 28 +32 32 34 33 33 +4 8 10 13 11 14 18 +25 25 18 16 14 13 12 12 +63 59 58 54 53 +40 43 40 39 38 32 26 +49 49 51 55 59 +23 23 16 14 13 10 7 2 +84 80 76 74 71 70 69 65 +76 73 71 68 66 65 59 +75 70 68 65 61 +15 9 6 5 7 1 +45 41 38 36 33 28 27 +49 55 57 57 63 +29 33 36 38 39 45 +49 48 49 52 56 63 +40 43 46 52 55 56 +18 14 11 8 8 6 +42 48 49 51 50 52 49 +39 45 44 46 48 48 +69 73 73 74 74 +95 98 95 94 93 89 88 88 +13 10 13 17 18 20 21 21 +52 49 46 43 37 36 29 +5 6 9 11 12 15 19 +31 32 35 37 43 46 48 48 +47 47 50 52 53 54 55 +38 38 39 45 50 +47 45 40 39 36 +82 85 88 90 88 92 +36 36 38 35 32 +67 61 61 59 56 53 53 +79 84 88 90 92 94 95 93 +74 78 79 82 84 88 90 94 +14 18 21 19 22 25 26 31 +87 83 80 79 78 76 78 73 +90 84 81 79 76 74 74 72 +56 60 64 66 69 74 +3 7 9 12 15 17 20 19 +29 32 29 28 26 24 18 16 +66 62 60 60 58 56 52 +62 66 69 71 74 74 +53 53 52 49 48 45 44 47 +33 37 38 41 44 45 50 53 +40 44 49 52 54 57 57 +8 6 13 16 18 20 25 +7 3 1 1 4 +23 24 21 20 19 22 +77 80 78 73 72 74 +10 10 7 8 11 13 15 +49 49 56 58 61 61 +51 47 45 48 47 43 +67 67 66 65 66 64 63 64 +97 90 89 86 84 84 +16 20 23 26 31 35 +64 66 65 64 62 60 59 54 +17 24 30 32 35 +99 93 90 88 84 80 +33 37 38 37 38 41 +7 12 13 17 20 22 23 23 +88 84 81 76 74 69 +6 10 13 17 19 18 +30 34 36 38 42 +77 77 74 72 71 69 66 61 +88 88 84 81 78 +47 44 42 39 37 +13 10 9 6 4 1 +37 38 41 44 45 46 +66 64 61 59 57 56 +38 35 32 29 28 25 24 21 +31 32 35 38 41 42 43 +50 49 46 44 41 39 +37 39 40 41 43 44 47 48 +58 55 53 52 49 46 43 +70 73 76 79 80 81 +43 41 38 36 33 32 29 +40 37 35 34 33 +22 21 18 15 14 13 12 9 +26 25 22 21 18 +23 21 20 19 16 15 12 +98 96 95 94 91 +67 70 72 75 77 79 80 82 +92 90 87 84 81 +73 70 69 67 65 63 60 59 +24 27 28 30 33 36 39 42 +18 15 13 11 10 8 7 +82 79 77 76 73 71 69 66 +2 4 6 8 10 +44 42 39 36 33 30 +16 13 11 9 7 4 +45 46 47 48 50 53 +20 19 18 17 16 15 12 +34 32 29 28 25 +74 76 78 81 82 83 86 +17 19 22 24 26 29 31 33 +80 83 84 86 88 90 92 94 +60 63 65 67 69 70 73 74 +55 56 58 59 61 +34 35 36 38 39 40 42 45 +74 77 80 81 82 +40 37 35 32 31 29 27 25 +16 15 14 11 10 +29 27 24 21 19 +48 51 54 56 59 62 +42 44 46 49 51 52 +95 94 93 91 88 +52 54 57 60 63 +54 57 60 63 64 66 69 +39 42 45 46 49 52 +73 72 70 68 66 65 62 59 +47 49 52 54 57 58 59 +7 9 12 15 16 19 20 21 +14 15 18 19 22 24 +46 49 51 54 57 +50 47 46 44 41 38 35 +70 67 66 64 62 59 57 +34 33 31 30 28 27 26 23 +76 79 82 83 86 89 92 +53 51 49 47 46 45 +17 19 21 24 25 +65 62 59 57 55 52 51 48 +88 87 86 83 81 80 79 77 +61 59 58 56 53 51 +42 45 48 49 51 54 56 +58 60 61 62 64 +74 71 69 68 65 62 60 +21 20 17 14 13 11 8 +43 45 46 47 50 53 54 +13 16 18 19 22 23 25 +19 18 17 15 14 11 9 +47 49 51 52 53 54 55 56 +93 92 90 89 88 86 83 80 +88 89 90 91 93 94 95 98 +16 13 11 8 5 +41 39 36 34 33 32 29 27 +59 58 57 55 52 49 +73 76 77 78 81 84 85 87 +68 69 71 72 75 77 79 +14 12 10 7 6 +57 56 55 53 51 50 47 +98 96 93 92 89 87 +49 48 46 44 42 40 +41 43 46 48 50 +64 61 58 57 56 53 52 +12 10 9 8 6 4 +46 48 49 52 55 +59 62 65 66 67 70 73 +26 29 30 31 33 36 +50 47 46 43 41 40 39 38 +15 16 19 22 23 26 28 +12 13 14 17 20 22 23 26 +66 65 63 60 57 54 +44 46 48 51 52 +7 8 11 12 15 18 20 21 +26 28 29 31 32 33 +91 90 89 86 84 83 80 78 +93 92 91 90 89 87 +33 32 31 30 28 27 26 +68 69 70 73 76 +24 21 18 16 14 11 9 7 +5 8 9 11 12 +66 65 62 61 60 57 55 53 +68 65 63 60 59 58 55 +81 79 77 75 74 72 +43 42 40 39 37 36 +84 82 80 78 77 +88 85 83 82 81 79 78 76 +21 24 26 28 30 32 33 35 +15 16 18 19 21 23 26 +18 17 14 11 8 7 +52 53 56 59 60 63 65 67 +33 34 35 38 39 40 +61 62 63 65 66 +23 21 19 16 13 +3 6 8 10 12 +80 77 76 74 72 70 69 66 +29 26 23 20 18 +59 58 55 54 52 50 +51 54 57 59 60 62 63 +33 35 36 39 40 43 44 +34 32 31 29 27 26 +65 64 61 60 57 +31 30 27 24 21 19 18 16 +18 19 20 21 24 +3 6 8 10 13 14 +56 55 53 52 50 49 +90 88 87 84 82 +15 18 19 22 25 +96 95 94 91 90 88 +14 11 9 7 5 4 1 +26 28 31 33 36 37 39 +51 49 47 46 44 41 +85 83 82 81 78 77 76 +43 40 38 36 33 +71 70 69 67 65 63 61 +40 41 43 45 48 51 +55 52 50 49 47 45 42 40 +79 78 76 75 73 71 +39 38 37 35 32 +83 86 88 90 91 +70 68 67 64 63 61 58 55 +98 95 92 90 89 88 87 85 +59 60 62 64 67 70 71 74 +99 98 97 95 92 89 87 +70 72 75 76 78 79 80 +85 88 89 91 93 95 +62 60 58 55 53 51 49 47 +34 33 32 31 28 25 24 23 +87 84 83 82 79 +35 34 33 30 29 26 +54 57 58 61 64 65 +49 50 51 53 55 56 +82 80 79 76 74 +66 68 70 71 73 76 77 78 +44 47 49 50 52 53 55 58 +34 35 36 38 40 42 +73 76 77 78 80 81 +98 95 94 91 90 +45 46 48 51 52 +21 20 18 16 15 12 10 +25 22 19 18 17 14 12 10 +56 57 59 60 61 64 66 +34 35 38 40 42 44 47 +98 97 96 94 93 92 90 +44 47 50 52 53 55 57 +91 90 89 87 86 83 +33 30 27 24 23 21 19 +36 38 39 40 43 +89 88 85 83 81 80 +61 64 67 68 70 71 73 +2 4 5 6 8 10 +48 50 52 55 57 58 +19 17 15 12 9 6 4 +55 58 61 63 66 67 69 72 +47 50 51 53 56 59 +66 64 61 58 57 54 51 50 +72 73 75 77 78 81 82 +7 9 12 14 15 16 17 +30 31 32 35 37 40 42 44 +13 14 15 17 19 22 +83 84 86 87 89 92 93 +19 16 13 10 7 5 3 2 +27 29 30 32 34 +27 30 33 34 35 38 40 +44 46 47 48 50 +73 71 70 69 68 66 64 63 +52 49 48 47 44 +33 32 30 27 24 22 19 17 +95 94 91 89 88 87 +34 35 37 39 41 43 45 +20 19 17 16 13 +30 28 27 25 24 21 19 +11 14 15 17 20 23 +58 56 54 52 50 +30 33 34 35 38 +32 30 27 25 22 20 18 15 +37 40 42 45 46 +38 35 32 29 26 25 +19 17 15 12 10 8 6 +7 8 9 11 13 +92 90 89 88 86 +28 26 25 22 21 19 18 +84 82 79 77 74 72 70 +86 83 81 79 77 74 +86 87 89 90 91 94 97 +31 28 25 22 21 +32 29 26 23 22 19 17 +89 90 92 93 95 +57 60 62 63 64 +76 73 72 69 66 +97 95 93 90 87 84 +1 2 5 6 8 +19 17 14 13 11 +39 38 35 33 30 +83 81 79 78 77 +43 42 41 38 36 35 33 30 +82 80 77 76 73 71 68 +90 88 86 85 84 83 +21 24 27 29 31 33 35 36 +50 53 54 56 58 60 63 +58 55 53 50 48 46 45 +72 75 76 79 80 83 85 +78 77 76 74 73 70 67 +83 80 79 78 75 72 +59 57 56 54 52 49 47 +73 71 69 68 66 65 62 +72 69 66 64 62 +54 55 56 58 60 +88 87 84 83 81 79 76 +46 45 44 43 40 38 +42 39 38 37 34 33 +13 16 18 19 22 25 28 29 +43 44 47 49 51 +6 8 9 12 14 15 17 +67 70 72 74 75 76 79 80 +76 75 73 72 71 70 +44 46 48 50 53 56 +29 31 32 33 36 39 42 43 +15 18 19 20 22 23 26 28 +95 94 91 89 87 85 82 +49 47 45 43 40 +51 54 56 57 60 63 +68 71 74 75 76 +26 28 31 32 35 37 38 39 +33 35 36 37 39 41 44 +96 95 94 93 92 +54 57 58 60 62 65 68 69 +10 13 15 18 20 22 +57 60 63 64 67 69 71 74 +36 37 39 40 43 45 +79 81 84 87 90 92 +89 88 87 85 82 79 76 +64 62 60 59 56 +20 17 16 14 13 12 +39 40 42 44 46 49 52 +97 96 94 91 90 87 84 +19 18 15 14 11 10 +76 78 80 81 82 +41 43 46 49 52 55 57 +24 22 19 18 15 14 11 +52 51 50 47 44 41 40 +20 23 26 27 28 31 33 +84 81 78 77 74 +47 50 53 55 57 60 +51 54 55 58 61 64 65 66 +37 40 41 44 46 49 51 52 +23 24 25 27 28 +79 78 75 74 72 +49 50 53 54 57 58 60 +49 52 55 58 60 61 63 +33 31 30 29 26 25 22 21 +17 14 11 9 7 4 +79 81 84 87 89 91 94 +89 86 83 81 80 +90 88 87 85 82 80 77 +58 59 60 62 65 66 67 +57 56 53 52 49 48 46 +12 15 17 20 22 25 26 29 +34 37 39 42 45 48 51 +14 15 18 21 24 +64 63 61 58 56 55 52 +78 75 73 72 70 69 68 +77 78 81 84 87 +26 24 21 20 19 17 +37 40 43 44 46 +56 59 60 62 64 65 +75 78 80 81 83 85 87 +82 79 77 76 73 71 70 +37 40 43 46 48 +65 64 62 59 56 +81 80 79 77 76 75 73 +68 71 72 73 75 76 79 80 +28 25 22 19 17 +27 24 21 19 17 16 +52 49 47 46 44 +57 54 53 50 49 +72 71 70 68 67 64 +25 26 29 32 34 36 39 +85 88 89 90 91 93 95 +21 24 25 28 31 34 +35 33 30 28 27 26 24 +11 9 7 5 2 +10 11 14 15 16 17 18 +76 79 81 84 85 +43 46 47 48 49 +26 27 30 31 32 33 +13 15 16 19 21 23 24 +45 48 50 53 54 +94 92 90 87 86 85 84 +59 56 53 50 49 +28 26 25 22 20 17 16 15 +50 49 48 47 44 +58 57 56 54 53 51 49 +44 46 48 50 53 54 56 +63 64 66 68 70 71 72 74 +92 91 90 87 86 83 +18 16 14 13 12 11 +60 63 64 67 68 +30 27 26 24 21 18 +77 80 82 85 87 88 91 +78 75 74 73 70 67 65 +10 13 14 16 17 20 21 23 +46 44 41 40 39 36 +88 87 85 82 81 79 76 73 +42 44 46 49 50 53 54 57 +55 52 49 46 45 42 41 40 +87 84 82 81 78 76 73 71 +62 65 67 69 71 74 +35 36 39 42 43 45 46 +59 58 55 53 51 50 +22 19 18 17 15 +76 77 80 81 84 +48 47 45 44 41 39 +69 67 64 63 61 59 57 55 +91 90 87 85 84 81 +39 36 33 31 30 27 24 21 +79 82 83 84 85 86 +96 93 92 89 88 86 +15 14 12 9 8 6 4 +76 74 73 70 69 67 +34 32 30 27 25 24 +62 65 68 70 72 +26 28 29 30 33 36 37 40 +61 64 65 66 67 68 +19 20 22 24 26 29 30 31 +80 83 84 87 89 +96 95 92 89 87 86 83 80 +96 95 93 90 89 87 85 84 +48 50 53 56 57 58 61 62 +27 29 32 33 36 38 41 42 +78 80 82 83 85 87 90 93 +67 64 62 59 58 57 56 55 +69 71 73 76 78 +57 55 53 51 48 45 42 41 +18 19 21 22 25 28 30 31 +86 83 81 79 77 76 +32 29 28 25 23 22 20 19 +58 60 61 62 63 +66 65 63 62 60 57 56 +48 49 50 53 54 55 58 60 +74 71 70 67 64 62 61 +65 62 59 56 53 51 +66 68 69 71 74 77 +67 69 71 73 75 76 77 80 +13 15 18 20 21 +40 43 44 45 46 47 +42 41 39 37 34 32 +13 11 10 9 6 4 +48 51 54 57 59 62 65 +64 62 60 59 58 55 +47 44 43 42 41 +82 84 86 89 90 92 +83 85 86 88 91 93 +53 55 57 60 62 64 +19 17 16 15 12 9 6 +79 77 75 73 71 69 67 65 +74 77 78 81 84 86 +54 53 50 47 46 43 +98 95 94 93 91 88 +94 91 89 86 85 83 +98 97 96 94 93 91 90 88 +85 82 80 79 76 +81 83 86 87 90 93 96 +74 77 78 80 82 +29 27 26 24 22 19 +24 26 27 30 33 34 37 39 +17 19 20 23 25 28 +76 74 71 69 67 diff --git a/2024/Day03CSharp/Day03CSharp.csproj b/2024/Day03CSharp/Day03CSharp.csproj new file mode 100644 index 0000000..c9cae6e --- /dev/null +++ b/2024/Day03CSharp/Day03CSharp.csproj @@ -0,0 +1,14 @@ + + + + Exe + net9.0 + enable + enable + + + + + + + diff --git a/2024/Day03CSharp/Program.cs b/2024/Day03CSharp/Program.cs new file mode 100644 index 0000000..292c8a7 --- /dev/null +++ b/2024/Day03CSharp/Program.cs @@ -0,0 +1,171 @@ +using System.Numerics; +using System.Text.RegularExpressions; + +var exParsed = new Day03Parsed("example-input.txt"); +var ex2Parsed = new Day03Parsed("example-input2.txt"); + +Console.WriteLine("Example Part01: {0}", exParsed.GetPart01()); +Console.WriteLine("Example Part02: {0}", ex2Parsed.GetPart02()); + +var pzParsed = new Day03Parsed("puzzle-input.txt"); + +Console.WriteLine("Puzzle Part01: {0}", pzParsed.GetPart01()); +Console.WriteLine("Puzzle Part02: {0}", pzParsed.GetPart02()); + + +public class Mul +{ + private static readonly int INVALID_VALUE = 9999; + + private int leftOperand = INVALID_VALUE; + private int rightOperand = INVALID_VALUE; + + public int LeftOperand { get { return leftOperand; } } + public int RightOperand { get { return rightOperand; } } + + public Mul(string line) + { + try + { + var split = line.Split(','); + + // left side + var leftOperand = split[0].Substring("mul(".Length); + System.Diagnostics.Debug.Assert(leftOperand.Length <= 3); + + this.leftOperand = Int32.Parse(leftOperand); + + // right side + var rightOperand = split[1].Split(')')[0]; + System.Diagnostics.Debug.Assert(rightOperand.Length <= 3); + + this.rightOperand = Int32.Parse(rightOperand); + } + catch (Exception) + { + + } + } + + public bool IsValid() + { + return leftOperand != INVALID_VALUE && rightOperand != INVALID_VALUE; + } + + public int GetResult() + { + if (!IsValid()) throw new Exception("OBJECT INVALID YO"); + + return leftOperand * rightOperand; + } +} + +class Day03Parsed : AdventCommon.ParsedInput +{ + public Day03Parsed(string fileName) : base(fileName) + { + + } + + private int part01 = 0; + private int part02 = 0; + + private void UpdatePart01(string line) + { + string pattern = @"mul\([0-9]{1,3},[0-9]{1,3}\)"; + + var m = Regex.Match(line, pattern); + + while (m.Success) + { + var mul = new Mul(m.Value); + part01 += mul.GetResult(); + + //Console.WriteLine("'{0}' found at position {1}", m.Value, m.Index); + m = m.NextMatch(); + } + } + + private bool UpdatePart02(string line, bool lastMul) + { + bool mulEnabled = lastMul; + + SortedDictionary ops = new SortedDictionary(); + + string[] patterns = [ + @"mul\([0-9]{1,3},[0-9]{1,3}\)", + @"do\(\)", + @"don't\(\)" + ]; + + foreach (var pattern in patterns) + { + for (var r = Regex.Match(line, pattern); r.Success; r = r.NextMatch()) + { + ops.Add(r.Index, r.Value); + } + } + + foreach (var op in ops) + { + //Console.WriteLine("{ " + op.Value + " }"); + + string canary = "mul(549,60)"; + if (op.Value.Contains(canary)) + { + //Console.WriteLine("poop"); + } + + if (mulEnabled) + { + var m = new Mul(op.Value); + + if (m.IsValid()) + { + part02 += m.GetResult(); + + // Console.WriteLine("Added: {0}", m.GetResult()); + //Console.WriteLine("New: {0}", part02); + } + + // m not valid, is it a don't? + if (op.Value.Contains("don't")) + { + //Console.WriteLine("Setting do() to false"); + mulEnabled = false; + } + } + else + { + if (op.Value.Contains("do()")) + { + //Console.WriteLine("Setting do() to true"); + mulEnabled = true; + } + } + } + + return mulEnabled; + } + + private bool lastMulEnabled = true; + + public override bool ParseLine(string line, object? context = null) + { + UpdatePart01(line); + + lastMulEnabled = UpdatePart02(line, lastMulEnabled); + + return true; + } + + public override int GetPart01() + { + return part01; + } + + public override int GetPart02() + { + return part02; + } +} \ No newline at end of file diff --git a/2024/Day03CSharp/Properties/launchSettings.json b/2024/Day03CSharp/Properties/launchSettings.json new file mode 100644 index 0000000..d087bcb --- /dev/null +++ b/2024/Day03CSharp/Properties/launchSettings.json @@ -0,0 +1,8 @@ +{ + "profiles": { + "Day03CSharp": { + "commandName": "Project", + "workingDirectory": "C:\\dev\\dev-drive\\DevSandbox\\AdventOfCode\\2024\\Day03CSharp" + } + } +} \ No newline at end of file diff --git a/2024/Day03CSharp/example-input.txt b/2024/Day03CSharp/example-input.txt new file mode 100644 index 0000000..2e1a90a --- /dev/null +++ b/2024/Day03CSharp/example-input.txt @@ -0,0 +1 @@ +xmul(2,4)%&mul[3,7]!@^do_not_mul(5,5)+mul(32,64]then(mul(11,8)mul(8,5)) \ No newline at end of file diff --git a/2024/Day03CSharp/example-input2.txt b/2024/Day03CSharp/example-input2.txt new file mode 100644 index 0000000..b774ec9 --- /dev/null +++ b/2024/Day03CSharp/example-input2.txt @@ -0,0 +1 @@ +xmul(2,4)&mul[3,7]!^don't()_mul(5,5)+mul(32,64](mul(11,8)undo()?mul(8,5)) \ No newline at end of file diff --git a/2024/Day03CSharp/puzzle-input.txt b/2024/Day03CSharp/puzzle-input.txt new file mode 100644 index 0000000..db4e691 --- /dev/null +++ b/2024/Day03CSharp/puzzle-input.txt @@ -0,0 +1,6 @@ +<,:[*where()%mul(53,612)!^}&mul(3,518)??$~select()>??]mul(245,515),why()who()*@from()(where(242,190)mul(817,764)^select(),+who(851,301)where())from(){;mul(431,780)mul(110,982)what()what()]mul(441,829)??where()mul(269,112)>when()?who()$**#!@mul(343,569),;what()from(){(;}mul(486,404)why()]#~when()%@do()+:'why(256,886)why()who(868,710)mul(103,406)?>mul(563,652)from()$-@when())!@:from()mul(744,992)[<^~}mul(822,789)],+select(45,52)!,why()*mul(433,911) }why()<&&how()who()?]mul(877,899);':what())#{]@mul(401,705)@&mul(627,54)? )~+mul(668,930)%)}do()what()#from()$/when()[:when() mul(545,444)how()]mul(409,150)>?%?@mul(295,205))'mul(321,875)mul(915,728){?when()what(644,532)*?;<):(:mul(566,595)%'mul(499,468)/'where()}mul(721,340)]when()mul(162,291)mul(73,373)<]where()mul(100,385)][what()]mul(832,226)mul(675,546)who()how()#<^+how()'mul(119,723)what(){+,-mul(959,612)select()mul(758,905)!mul(247,521)&}$?don't()!'$ what()where(353,94)select(){mul(997,311)@from()/mul(987,583)&select(207,730)mul(299,379)select()do()what()select()when()select()]*?(?mul(841,179)!when()what()where()@:why()'>]mul(265,944)mul(968,747)what()}),(mul(541,36)~how()~select()where()when()-+when()mul(448,567)select()where()why(342,599) -when()<}mul(566,357)/$*>> mul(414,962)mul(904,116)what():/'@--}where()mul(390,663)who()~~],when()&where()[%mul(304,146))'who()>+when(){mul(526,627)!;(]@}where()where()mul(253,767)-^+]how()>,,!do():~[^when()]mul(263,450)mul(757,944)><' (],mul(934,282)@{who()+%when()mul(136,652)mul(366,573)!$//where()mul(501,845)}+~select()+]mul(532,462),~},from()mul(322,350)@~mul(64,374)&what()>[){mul(962,241),?/}-'+mul(39,522)%!$do()^}mul(447,40)mul(971,488)()mul(983,842)where()/mul(956,799);*+)^mul(233,820)mul(957,287)&>[when()why()where(855,333)<@)mul(304,558){~from(),how(){mul(555,718)]]-where() mul(881,781);^&);mul(231,766)$)mul(7,979)^why()'/,mul(352,951)mul(575,449)'mul(803/#(<^when()>mul(500,697)]~^<>[select();^when()mul(822,422)@[where()what() how()&;[(mul(756,744)how() @mul(741,854)what()(do()&how()){what()'^}-mul(664,580)<+ &+mul(788,961) -&}#!,how()who()mul(378,886)[!{,mul(53,236)what())select():~>why()~@who()mul(275,625)*from():what(80,711)why()@don't()mul(426,724)?&from()-)/^-mul(47,60)&+select()?%why()&where()mul(706,388)from()/how()mul(2,761)mul(377,995),from()*?{how()mul(198,840)why()&';[/+^~mul(72,849)mul(720,901 <(mul(998,859)mul(409,24)>?#-)why()mul(208,800)~how()+^?why()^mul(765,394) )mul(269,340)>mul:$~&select();mul(466,453)why()mul(59what()-?'where()?;who()mul(474,555)<[]]when()%-how(225,412)mul(626,574)/,{{what(832,679)where()how()mul(250,300)<#$;+mul(840,193)who(562,102),mul(390,251)(mul(6,397%~what();%who()from()#![mul(95,829)where(811,818)@mul(847,742)'~+&~@/mul(329,961)>~mul(625,917)#+what()%?>mul(314{mul(392,487)mul(770,684)]'mul(607,73)]where()/#what(378,688) :}'why(778,249)mul(732,423)from()$;@why()>mul(255,618),#+from(849,914);>mul(99,409):]mul(948,905)select()<@mul(342,35)$!@how()/)where():mul(49,617)mul(396,154)>mul(671,367)mul(68,795)~select()<:select()~/mul(900,855){ why(622,665)#when()-<@mul(629~{;~+how(){'mul(907,182)}<;+{' mul(223,519)}+>mul(776,473):where()what()^when()don't()/^ -/(/mul(894,814)mul(698,226)}~/mul(570,960),?@?what()select()}/mul(918,543)'[from()&why()where())~from()[mul(321,507)mul(616,831)why()when()/]{mul#>[!!; mul(480,401)'%%~](from()mul(643,85)who()where()mul(982,510)when():,(mul(799,43[from())$what()%where()@;)mul(420,538)how()mul(358,891)who()what()what()select()(?how()*)mul(612,717)<+(where();who()from(170,645)how()why()where(310,422)mul(789,673)mul(779,49)what()who()[from()$*'&mul(211,472)why()< mul(77,895)?&:*-;^mul(861,148)/what()[+#}when(360,356)mul(905,744):~<-how()][-where()^mul(272,757select()'mul(994,335) what(362,794)$;$mul(242,327)who()when()who();don't()$mul(808,996);don't()/}from()(what()who()mul(398,570)from()~select()[mul(420,441)+mul(452,212)who();~what()#how()what()mul(557when(699,863)mul(184,806)&')from(),:'';don't()[select()mul(139,882~^(how()&mul(931,970)>]] &do()&*)(,:;,mul(924,272)who()$$%select()?/[mul(712,215)~,mul(114,862) :select()#who()$&how():mul(617,150)]why()~(&@?mul(28,990)-)mul(221,546from()^:<&/[select()mul(5,78)mul(476,316)(<'%[mul(227,163)from()where()who()why()[ mul(229,680)>/+?how();select()&$[mul(110,33)~{)#who()]^+/mul(479%%#{#from()select()when()what()what();)//mul(229,348)how()*/mul(643,351)mul(615,362(/->(how()-when()mul(499,697)*don't()mul(992,821){from(413,389));when()who()#mul(921,742)mul(253,580)]how()how(102,372) mul-from()where()mul(104,127)what(),{what() what()[*mul(657,659)'-select()mul(612,851)how()<~-when()$select(718,662)from()(!mulselect()-/^,<&^~mul(497,827)who()-how()-$select()+*mul(943,533)@;mul(403,629)why(826,610)} +:>mul(943,942)why():-)>^why()what()how()mul(302,757'mul(22,286):/-{mul(391,954)mul(528,734)select()-where()why() mul(909,426)!/($+mul(106#&-from()^mul(592,459)'(select()]!when()@{}*mul/&'>mul(894,472)who(),-#mul(924,264)%where()-{from()!mul(956,587)-$do()&why(173,205))$&~where()#&}mul(615,17)how(){>%from()from()@where()mul(683,358),how()when()-}](;/mul(688,622)/select()}(what()mul(872,568)/why(){mul(600,562) #mul(733,946)( ?]/when()$(mul(606,986)@!when()mul(597,648)what()-who()from()?,>]!'mul)>-&@~who()/%!mul(486,264)from())mul(556,968)(who()[:$:,*mul(564,519)# %)&/from(390,158)mul(583,746)how()why()('#/mul(519,835)&(/?^#,mul(447,762){?,]]]/@mul(257,451)&<$why()(mul(670,126){#:mul(555,660)}+%$:(select()mul(723,37)why()who()}where()}how()%)>don't()#where()how()]%what() select()mul(726,542)how()mul:how()/~}) mul(753,350)mul(905,645)+ how():(when(879,434)mul(632*?'$/,<*what()mul(442,98)$&(&;mul(424,515)!mul(443,813)**),^%how()what(),mul(252,469)select()[)mul(370,416)%&::&+%mul(885,78)how()^mul(885> {&,why()$mul(52,196)+,{%select(),!##;mul(714,770)mul(607,394)when()how() -@]mul+^@mul(90,350)~@+where()mul(934,150)when(788,941)^mul(557,327)mul(86,867) :~$-how()select()who()mul(166,855) what() %]mul(928,22)%when()-how()$!what():mul(628,252)~{>,who()~where(967,401)#mul(943,366)'[*>@mul(781,986)>:when()?&don't()~ :where()who()select():what()mul(839,261) *&*where())/]when()mul(24,536)how()how()'who()why())<,~mul(254,257)^@:where()mul(945,657)!&]select()from()}'[#)mul(148,151)-#!/usr/bin/perlwhere()>%why()}!/]{;mul(549,60) +how(477,669) mul(853,888)<[/who()>}+mul(361,751)mul(837,651)-mul(8,515)(}>!!# do()&@!:^][@mul(143,286)&?^&*how()&!'mul(88,781):}who(){!*!&mul(348,435)mulfrom()?>]-}+ }@mul(33,697)do()what()why()}(#]:mul(3,176):$mul(613,679),'how(882,581)who()*mul(519,798)from()mul(865,503),+~mul(767,837)/)?^why()/mul(520,288)where(){)who()what(); )mul(274,562)$:<^*what(423,612) from()>)mul(375,282)#select()from(646,967)?(*!'$mul(991,635)mul(598,876)%^?+mul(716,646)!)&mul(699,500){^^who()when()from()what()mul(314,198)%@;mul(419,800from()]$mul(844,419)$&]mul(317,754))<;^@(mul(222,12)##:what(751,642)$[from()%;mul(205,32)when()&{>+'>why()+mul(864,418)*@select()mul(911,629)*why();)^who()mul(248,4)}mul(132,503)/when()why()%mul(441,482)-mul(818,349)(#(where();(who(22,952)mul(534,621)$'~]where()why()-mul(199,973)mul(746,506)@'select()%{mul(866,951)from()mul(381,827)[select()*}(what()mul(744,979)mul(907,379)how(347,456)who()@what()##>;@mul(114,609),}what()'mul(406,863)][who()/when()mul(900,454)<'-)->[select()!select()mul(499,399)who()mul(349,409)',-~)select()mul(234,866)'why()mul(225,989)-(-mul(626,378);,$who()mul(597,85)mul(977,267)select(){mul(111,206):(&mul(989,396)#[:)<~{who()select()mul(689,817)mul(240,827)#how(){-+-@mul(663,156)'^$from())mul(416,908)*%why(714,896)#^+mul(993,707)'when()#;who()>where()select()?mul(978,206)@how(315,762)*/>why()({mul(998,362)who()$<(mul(488,946)},when()):}?where()where()}do()[!;?~{select()mul(673,574)%[::@;why()#]+mul(455,366)$~:mul(351,347)%,~-?what(595,890)]*select()mul(186,325)where()/:why(744,171)mul(513,868)/+why(118,201)mul(691,608) %mul(469,265)why()do()[mul(80,813)*<:mul(925,31):((mul(640,344)when(758,885)where()mul(474,482)?[>{where()]!mul(66,500)why()![# -mul(549,187,how()'where()*don't()#-<>%select()?who()]mul(581,943)?]what()}?) mul(54,791)]do()+$-)mul(255,793)who()]mul(338[)how()!@mul(253,351)++who()$mul(696,214)select()&mul(899%what()~}/what()-mul(302,687)when()#&mul(842,464)}?^$when()([()mul(579,190)@mulwho()where()~mul(238,298)from()<^(+,mul(766,436)how()^)%':{mul(427,646) ?%}(?mul(995,814)#~where()'}mul(267,274)']mul(174,583[,((!what()+when()*)mul(146,807)!:where()+!mul(856,39)?;@!mul(653,577)%}^do()^mul(961,701)::mul(23,391)what()^*~-do()how()how(832,138);!}($#+mul(841,486)how()+# mul(255,21))-$who()when() -)> mul(427,236);&who(),where()+{mul(97,633) +::where(946,25)!where()do()?where()-why()mul(129,728)>^&mul(557,253)mul(535,49)who()~$>mul(342,811)([*don't(),+how(398,338)}why()<:mul(556,398)[@??:^(),how()mul(708,821):;-?where()/when()select()%?how(955,77)why()mul(428,310)how()where()'mul(759,360)(#>;where()when()mul(396,975)}{mul(131,376)(!@what()%] @mul(100,818)mul(478,394)<%$<:%($&/mul(337,545)mul(227,220)who()-'+why()select()select()don't()why():';!mul(49,915)+))[do()?[when()mul(886,984)'^ who()>when()~mul(468,20)from()(<>why(){mul(791,347)? &} +mul(389,748)/[<;when()select()*mul(370,770)::[select();what()mul(63,701)why()^mul(361,364)when(592,110)select()+: ]mul(988,308)$mul(693{from()!(how()~/mul(782,22)why()mul(355,443)}<)%how()how(){[mul(47,507,^}>)&#don't()why()mul(459,418)?who()/(how()select()when(456,391)?select()mul(451(mul(473,946))who()how()*mul(733,242)mul(575,863)why()*>&,}%!]^mul(613,249){#from()mul&]who()where()}+}}$+mul(94,794)mul(813,82)#mul(294,897)mul(995,245)!%#!^why()mul(411,763)/}what(),)mul(952,776)mul(868,728) ':~$}mul(869,784#who()don't()%@-} (mul(766,260)']who()@^&select()mul(723,930)what()what()from()-#~!mul(873,766)%:,?mul(520,521)& mul(407,520)select()$mul(547,416)~?}%^mul(677,996)mul(661,622)[~!mul(310,928)^;>-mul(740,171) /$#$*don't()select()>: &mul(306,628)*{select()$mul(705,686$/mul(803,660)mul(485,760)[select()'select(){@mul(917,878)#mul(188,324)(>}<:select()'mul(281,982)(select()},what()mul(730,931)}-#mulwhat(469,510)select()'from()where()#from()#do()/mul(869,458) +when()from()mul(912+{@mul(635,991)>}mul(158,871){[*{>'$*/ mul(686,481)mul(339,86)$>how()[when()mul(78,204)+&'mul(58,734)<{who()where()]';~mul(964,213)&select()where()@where(513,771)mul(471,186)'%$)@~({# mul(517,787){+%from()>]{,mul(762,604),~from()~+do()select()mul(827,656)$^>['-what()mul(318,236)select()'+>who(530,155)*mul(394,518)&#)select()from()!)select();:mul(805,79)why()}how()/&?mul(924,569)who()$%where()]~*&[why(621,535)mul(152,407)[why()]#mul(478,24)mul(107,697)select()'>~mul(481,432) mul(248,61)^:+don't()mul(400,374)^]{who(){mul(959,329)from(){))]mul(566,182)}what()(where()>from()&don't()select()who():+?!]]/mul(766,741)why()@ !how()who()?select();mul(470,17)/mul(374,487)%@@mul(685,185)} {<#(mul(845,259)'why(230,429)[??^select()^>/mul(791,324)$how()/?mul(478,641)+/ <{(when()mul(794,547)why()[select()!*-mul(474,709)#select()# select()}select()mul(896,775)select()-where():!mul(817,123)mul(333,359)mul(433,461)mul(722,474)@'!@$mul(49,892) #(+,mul(726,435)what()>,;mul(957,798)) #%)$ mul(541,867)-?*# do() -]who(265,168){'*>{mul(770,902)+,-who()*what()mul(21,402)mul(843,622)~#mul(604,248)how()%(why()where()[;where()+mul(342,802))from()*when())#,<#,mul(439,954)}@-&)>+what()mul(593,520)>?,what();+,select()~mul(202,526)where()+#-]? mul(654,204)>why(),(]+mul(95,133)mul(626,152)@,[+mul(811,855)when()$when(387,144)when()who()mul(781,279))+&@&mul(77,160),why()%from()do())#mul(982,99):mul(722,476)mul(757,193)from()when()select()who(){mul(569,549)]*$mul(943,277)why()@who()}{from()!when()]mul(714,885),;*do()@where()^how()mul(941,709)~@{when(215,138)how()mul(772,310)~,what()>who()!?++]mul(858,573)-what()<(from()from()mul(254,457)mul(890,367)from()why()[mul(590,183)/@who()*#-^?~mul(446,447)how()$select()mul(734,361)]~where();}when()mul(50,364):(where()-<^why()!&mul(692,682)from())&mul(949,43)mul(923,776)^/mul(987,377)!who()mul(286,329)#what()~from()^who()#/mul(13,658)why()>@(>]mul(592,423)mul(148,486)*mul(878,721)$%#how()what()mul(710,18):[#%do()where()@!(~mul(357,115)where()select()how()don't()mul(356,206)@,? how()^^what(295,729)[mul(759,861)from()*/select(334,18)&*how()@>what()mul(580,828)+;where()^;*select();what()mul(542,530)~where()[mul(549,51)'!mul(12,992)#why()don't()!;how()-(+{(mul(543,363)[what()from():mul(135,364)/select()mul(312,500)@where()[when()&$)]when(610,72)mul(215,533)~;who()}how()from()*)>~mul(522,58)@mul(402,510)!!;who()mul(867,26)-mul(25,987)?select()mul(973,76)why()&#{(/mul(148,345))^'%@when()-how()mul(233,85) diff --git a/2024/Day04CSharp/Day04CSharp.csproj b/2024/Day04CSharp/Day04CSharp.csproj new file mode 100644 index 0000000..c9cae6e --- /dev/null +++ b/2024/Day04CSharp/Day04CSharp.csproj @@ -0,0 +1,14 @@ + + + + Exe + net9.0 + enable + enable + + + + + + + diff --git a/2024/Day04CSharp/Program.cs b/2024/Day04CSharp/Program.cs new file mode 100644 index 0000000..577add9 --- /dev/null +++ b/2024/Day04CSharp/Program.cs @@ -0,0 +1,197 @@ +var exParsed = new Day04Parsed("example-input.txt"); + +Console.WriteLine("Example Part01: {0}", exParsed.GetPart01()); +Console.WriteLine("Example Part02: {0}", exParsed.GetPart02()); + +var pzParsed = new Day04Parsed("puzzle-input.txt"); + +Console.WriteLine("Puzzle Part01: {0}", pzParsed.GetPart01()); +Console.WriteLine("Puzzle Part02: {0}", pzParsed.GetPart02()); + +class Day04Parsed : AdventCommon.ParsedInput +{ + static readonly string WORD_TO_SEARCH = "XMAS"; + + List letterGrid = new List(); + + public Day04Parsed(string fileName) : base(fileName) + { + } + + public override int GetPart01() + { + int count = 0; + + for (int i = 0; i < letterGrid.Count; i++) + { + var row = GetRow(i); + + for (int j = 0; j < row.Length; j++) + { + var words = GetWords(i, j); + count += CountWords(words, WORD_TO_SEARCH); + } + } + + return count; + } + + public override int GetPart02() + { + int count = 0; + + for (int i = 0; i < letterGrid.Count; i++) + { + var row = GetRow(i); + for (int j = 0; j < row.Length; j++) + { + if (IsMASX(i, j)) { count++; } + } + } + + return count; + } + + public bool IsMASX(int i, int j) + { + try + { + string wordToSearch = "MAS"; + string rwordToSearch = new string(wordToSearch.Reverse().ToArray()); + + if (GetEntry(i,j) != 'A') { return false; } + + string backwardSlash = String.Format("{0}{1}{2}", GetEntry(i-1,j-1), GetEntry(i,j), GetEntry(i+1,j+1)); + string forwardSlash = String.Format("{0}{1}{2}", GetEntry(i-1,j+1), GetEntry(i,j), GetEntry(i+1,j-1)); + + if ( (String.Compare(backwardSlash, wordToSearch) == 0 || String.Compare(backwardSlash, rwordToSearch) == 0) + && (String.Compare(forwardSlash, wordToSearch) == 0 || String.Compare(forwardSlash, rwordToSearch) == 0)) + { + return true; + } + } + catch (Exception) { } + + return false; + } + + string GetRow(int i) => letterGrid[i]; + string GetColumn(int i) { + string toRet = ""; + foreach (var line in letterGrid) + { + toRet += line[i]; + } + return toRet; + } + + char GetEntry(int i, int j) => letterGrid[i][j]; + + static int CountWords(List words, string wordToSearch) + { + int count = 0; + + string rwordToSearch = new string(wordToSearch.Reverse().ToArray()); + + foreach (var word in words) + { + if (String.Compare(word, wordToSearch) == 0 || String.Compare(word, rwordToSearch) == 0) + { + count++; + } + } + + return count; + } + + List GetWords(int i, int j) + { + List words = new List(); + + // Scan only with X + if (GetEntry(i, j) != 'X') + { + return words; + } + + var row = GetRow(i); + var col = GetColumn(j); + + // Get horizontal + try + { + words.Add(row.Substring(j, WORD_TO_SEARCH.Length)); + } catch (Exception) { } + + // Get backwards + try + { + words.Add(row.Substring(j-(WORD_TO_SEARCH.Length-1), WORD_TO_SEARCH.Length)); + } catch (Exception) { } + + // Get vertical down + try + { + words.Add(col.Substring(i, WORD_TO_SEARCH.Length)); + } catch (Exception) { } + + // Get vertical "up" + try + { + words.Add(col.Substring(i-(WORD_TO_SEARCH.Length-1), WORD_TO_SEARCH.Length)); + } catch (Exception) { } + + // Top Right Diag + try + { + string diag = ""; + for (int x = i, y = j; y < j+WORD_TO_SEARCH.Length; x--, y++) + { + diag += GetEntry(x, y); + } + words.Add(diag); + } catch (Exception) { } + + // Down right Diag + try + { + string diag = ""; + for (int x = i, y = j; y < j + WORD_TO_SEARCH.Length; x++, y++) + { + diag += GetEntry(x, y); + } + words.Add(diag); + } catch (Exception) { } + + // Down left Diag + try + { + string diag = ""; + for (int x = i, y = j; y > j - WORD_TO_SEARCH.Length; x++, y--) + { + diag += GetEntry(x, y); + } + words.Add(diag); + } catch (Exception) { } + + // Up right Diag + try + { + string diag = ""; + for (int x = i, y = j; y > j - WORD_TO_SEARCH.Length; x--, y--) + { + diag += GetEntry(x, y); + } + words.Add(diag); + } + catch (Exception) { } + + return words; + } + + public override bool ParseLine(string line, object? context = null) + { + letterGrid.Add(line); + return true; + } +} diff --git a/2024/Day04CSharp/Properties/launchSettings.json b/2024/Day04CSharp/Properties/launchSettings.json new file mode 100644 index 0000000..30e032f --- /dev/null +++ b/2024/Day04CSharp/Properties/launchSettings.json @@ -0,0 +1,8 @@ +{ + "profiles": { + "Day04CSharp": { + "commandName": "Project", + "workingDirectory": "C:\\dev\\dev-drive\\DevSandbox\\AdventOfCode\\2024\\Day04CSharp" + } + } +} \ No newline at end of file diff --git a/2024/Day04CSharp/example-input.txt b/2024/Day04CSharp/example-input.txt new file mode 100644 index 0000000..ff4241e --- /dev/null +++ b/2024/Day04CSharp/example-input.txt @@ -0,0 +1,10 @@ +MMMSXXMASM +MSAMXMSMSA +AMXSXMAAMM +MSAMASMSMX +XMASAMXAMM +XXAMMXXAMA +SMSMSASXSS +SAXAMASAAA +MAMMMXMMMM +MXMXAXMASX \ No newline at end of file diff --git a/2024/Day04CSharp/puzzle-input.txt b/2024/Day04CSharp/puzzle-input.txt new file mode 100644 index 0000000..14b87a0 --- /dev/null +++ b/2024/Day04CSharp/puzzle-input.txt @@ -0,0 +1,140 @@ +MXXMASAMXSAMXSXMAMXXAMXASAXASMSMXAAMAMXXMMXAMXSXMAMSAMSAMMXASXXXXMXSXMSMSXSMSMMSSMMXSAMXSSSSXXXMMSSSMMXMAMXAXAMXMSMSSSMMSASMXSXAAXMSSMXXXSXS +SASAMXSAMAMXAAAMSMSSMSAMXMAMAAAMSSMMSMXXMAXSAMXMMAAAAASASMXSXAMSMSAAXXMASASAMXXAAAXAXXMAXMAMAMSAMXAAMMSXXASMSMAMXAASXXAXSAXAASXSXMXAAAMMMMAA +MASXSXAMMSXMSMMMMAMAASASMAAAMXMMXAMAAAASMAXMAMAMSASMMMMAAAMMMXMAAMMXMSMAMAMAMMMSSMMAMMMSSMAMAMSAMMXMAAAASXSXAMAMMMSMASMMMMMMMSAMXAMSSMXAAMXM +MXMAMMMMAXAMMAAAMAMMMMAMASMXMXXXSAMSSMMMMMMMAMMMAAMXSSMSMAMXAMSMSMSAAAMAXXAMXXAMAMXMXAAMAXXSAMXAMXAXMMXXSASAMSXSASAMMMMAAAXMAMAMAXMAMASXXSAS +SXMXMAXMASAMSSMMSAMMAMAMXXMASAMXMXMXAAXAAMMSAMXMXSMSMSAAXAXMXMASAAMMSMSAMXXAXMMSAMSMSAMSAMXXMSSSMSMSASXMMXMAMAXMMXASMAASXSMXAMAMMXMASAMMXMMM +MMMAXMXMAMAMXMAXSXMXAXXXSMSAMAAMSAMXSASMMSASXSASXMXXAMXMMMSMSSXSMMMXMXMASMSMSAMSXMAAXAXMAXSSMAXAAAASAMMAMAMMMSSSSSXMMSXMMMASMSMSAASAMAXXAMAS +XASMSMSMSSMMAXSXMMMSSMSAXAMMSMMXSASAMMXMAMMSAMASAXMMXMXSAAAAXMASAMSASAMSMAAXAXXXMSMSMSMSXMMAMSSMMMXMAMSASXSXAXXAAMXMMMASMMMMXAAMMMMAXSMMASAS +MMAMAMSAXXXSXSMMSMMAAAMAMSAXAAXASMMMMAAMAMXMAMSMMMASMMASMSMSMMMMAMSASMSAMMMMMMSMAXAXAMXMMXSAMAAMXMASAMXAMXAMXSMMMMSMXSAMMAAAMSMSXSSSMXASXMAS +XMAMMSMMMMMMMSMAAAMMSMMXMXASXSMAXXAAMSMSASAMMMMASXMXXXAXAAAXXSAMXMMAMXSAXXASXAAMSMMMXSAMAASAMMSSSSMSSXMAMMSMSXMASXAAAMAXSSMMAAXMAAAAXXXASMAM +ASXMSAXAAAMAAMMSXSMAMMMAXMASAMMSMMMSMXAMASXSMASAMMSMSMASMMXSAMXXAXMAMAXAMXMSMSXMMAXMASASXXMAMXXXMAMXASMMMAMMXAXXSSMMSSSMMXSASMSMMMSMMSSMAMAS +MAMXSASXXSSSXXAMXXMASASMSMXXAMXAAAAXAMAMAMAXMAMAMMAAXMAXAAXMAMSSMMSASXSSXSAXAXMXXSMMMSXMASMAMXMMSMMMMAXAMXMSSMMMXMXMAAAAXAMXMSMXSAMXXAMXMSAS +AXSAMXMXSMMASMAMXXMASXMXXXMSSMSSSMSMASMMMSMSMASAMSMSMSMSMMMMSMAAAXAMXAXAAMMMMSMSXMASXSXMAMMAXASAAXASXMSXSMMAAAXMASAMMSMMMMSAMASXMXXXMMSSXMAS +MXSAMXMXAAMAMMAMMMMMSXSXMAMAMAMAXAXXAMXXAMXMXASXXAMAXAAAXAXMXMMXMSXSMMMMMMMASAAXAXXMXMXMAXAXSASXMXAXAXMMSAMSSMASMSASMAAXMASXSASMMSMXMXAMXMAM +XAMAMAAXMSMSSSSMSAASMAMXMAMASXMSMMMMMSSSXSASMXXXXSSSSMSMSMMSAMXSAMXXAAAXAASMSMSMSMMSAMMSXSMMAXMAASXSMMSASAMAMMXXXSXMXSSMXMSAMXSAAXMAXMMMSMAM +MMSAXMSMXMAXMXMASXSMMSMMMAXAMAAXMAAAXXAAASASXMMSXMAMXAMMXAAMAMAAAXSXXAXXMXMXMXAAXAASASAMMMXAAAMXMMAAMAMXSSMXSSSMMMMSAMXMAAMMMMSMMSSXSXSASASX +XMAMAAAXAMMMMAMMMMXASAMAXSSSSMMMSSSSSMMMMMMMXMAXAMXMMMMMXMSSSMSSXSMMSSSMSASASXMSMMMMXMAXMMAXSMSAXMSMMXSAMXXXSAMXAAAMASASMSMXMASAMXXXAXMASAXA +MMAMMXMXMSSMSMSMAMXXMAMSMMAAMMMAXAAXMXXAXAXASMMSSMAXASAMMXAAAAXXMSAAAXAASXSASMMMAMXXSSSMAMSMXXSXSMMXXMMMXMSMMXMXSSMMAMXMXAMXAMXAMAMMMMMAMMMM +AMSMSASMAAXXAAAMAMMAMXMAAMMMMSMMSSSMMSMMSMSAXSAAMSSSMSAMASMMMMMMMSAMSMMMMMMMMMMSSMMXMAMMAMMAMMMXMAMAAMASAMXXMASXAAXMSSMSSXXMSMSAMASAMMMAAMAS +SMXASASMMMSSSSMSMSAXAAMMSAMXXMAMAAXAXAAXAMMAMMMMMAMXASXMXXAXSXMAMMXMAAXAMXAAASMAAAMXMAMSSMMAMASMMSMAMSASMSXMSASMSMXXAAAAMXSMMAAXXXMASXSMXSAS +MXMMMAMMMMAAXXAXAXMMMSSMAXMAMXAMMMMSMXMMASXMMMSMMMSMXSXMXASXMASMSSMMXSXSMSMSSSMSSXMAMMXAMXSASMSAAXXSMSASXMMAMXSAMSMMSMMMMXSAMMMMMASAMAMSAMXX +SMSMMMMMAAMXMSXMAAMAXXAXMSXMSSSXSAAXMMSSMMMXSAMMAAAAMMAMSAXAMASAXXAMSAMXMAAMXXXAXXMSSSMASXSASASMMMMAAXASAMXSMMMMMAXAAMAXMAMXMSAXSAMXSAMMMMSX +SAMXAASXSSXMAMAAXXSASXMMXMASMAAASMSMSAAAAAAXMAMSMSSSMSAMXASXMASMSMSMSAASMXMMMSSMMSAMXASAMAMAMMXXMAMMMMSMMMAMAAAASMMSSXSAMXXAXMXMAASAMXSXXAAX +MMMXMSAAAXXAXSMMMXAXSAXMXSSMMMMMMAAAMMSMMMSXMAMXXAAAAXXXMMMMMXSXXAAASMMMXSAAXMAAAAAASMASMMAASXSMSASAXMXAAMAXMMSXSAAAXXXAAAMSXMXMAXMASXSMMMSX +MSSSMXMMMMMSXMAAMMSASMMMAMAAXXXSMSMSMAXXXSAMSASMMSSMSMSXAAAXSXMMMSMXXAXAAXXMSSMMMSMMMXMXSXSASASXSMSAMXMSMSSSMAXASMMSSMSAMSXMASMMMXSXMXMASAAM +XAAAAXXMMXAAMMSMSAMMXAAMASMMXAMXAMXXMASMMSAMSAMMAXAAXAMXSSSSMAXSAXSSSSMMMXAXMASXMAMXXSXMMMMMMMMAMMMMXMMMXAAAAXMAMAAXAAXXMXASXMAAXAMAMMSAMMMA +MMSMMMSMAMSMSAXAMXSSSSMSMSAMSSMMAMXSMXSAAMAMMSMMXSMMMSAXXXMAMAMMMSXMAMXAAXSMMASMSSSMXMAMMXAAXAMXMAAXAMASMMSXMAMSAXXMAMMASMMMSSSMMXXAMAMMSXXS +AAAAMAAMSXMAMAMXAMAMAXAAASAMAXAMASAXAASMMSSMXMXXMXXMSXXXMMSSMXSAMXMMAMMXSMMAMASAAXXMASAMAMMXXXSASMSSXSASAAXAXMMAMSAAAMSMMAAAXMAMSMXMSXSMMAMX +SSSSMXXMMAMSMXMASXMMAMSMXSXMASXMAMXXXMXAAAASAMAAAMMMMXMAAAAAXMSASXAMASMAXASXMASMXSMSMSASXSSSMASASAMMAMXSMMSMMMXAMXXMXXXASXMXSXMMAAAXMASXMASM +AXAXASXXMXMAMAMAXAXMMMXMASXMAMXMASMSMSASMXSMMSMSXXAAXMSASMSSMMSSMMMSAAMASAMMSXXMAMASASAMAAAAMAMMMMMMAMXMAMMMASMSSXMMMASXMASXSXSSMSMSAXMASASA +XMAXSAMXMASMSAMXSSMMXMAMAMXMASASMMAAAXAMMXMXMAAMAMSMSAMAXMAXAXMASAXMMMMAMAMAAAMMSXSMMMAMMMMMMXXAMXAMAMAXAMASMSAAXAXMAXMASXMAMAAXXAXAAMSXMAMX +SXAXMMXMXASXSXXMMMMSASXMASMSASMSXSMMSMMSXAXASMSMMMAASMXAMMSSSMASMSMXAXXMMSMMSXSAMMXXXMAMXSSMXXMAMXSSSSXSASXMMMMMXMMMSMXMMXMAMXMASMSMXAXMMSMM +SAMXSMMSXASAMXMAAAASMSXSXMAMASXMAMXAXAASMASXMMXMXSMMMMMMXXXAXXXMMXXMASMSAMAMAMMASASMSMMXAAASAMSSMAXAMXAMXSAMSAMMASAMASMASXSASXXAMAAAXSXSAMAS +MAMAXAAXMMMXMAAXMMMSXXAMAMSMMMAMAMMMXMMSSMXMAXAXMXMMAXXAMSMMMXSASXMASMAMXSSMAAMXMASAAXSMMSXMXXAXMXMAMMSMAMAMXAMSASASASMXMAMASMMMMMMMMMAMASAM +SAMXSMXXAXAASASAMXXMMMAMAMAASXMSXSASASMMXXMASMSSMMASMMMMSMAAAXSAMSASAMSMXMXSMSXSMMMMMSMAAMAMMMMSMMSAMAAMASAMXXMMXSAMASASMSMXMAXAASMMSMAMMMMM +XXMMMASXSMSMSAXMMXSXAMSXMXSSMAXAXMASAMAMXMSMXAXSAAAXXAMXAMSMSMMAMASAXSXSXSASMMAAASAMMXXMMSASAAXAAASAMSMSASMXAMXSAMXMSMXMAMXAXASXMSAAXXSMXMAS +SXSASAMXAAMAMXMXXAXMSSMAXAMAMSMMSMMMXSXMAXMAMSMSSMSSSMSXMMXXMASXSXAMXSAMXMASAMSMMMAMSAMXASAMMSSSSMSSMAXMASASMMMXAXMMMMMMAMMSMASMASMMXAMXMSMA +AASMMASXMXMAMMMMMSSMMAMMMXSAMXXXAAAAXMASAXMAMAMXXXAAAAMMSXMASXMASAMXMMAMAMAMAXAXAXXMMMSMMSMMXXXAXASMMSSMXMAMAAXXXMMMSAAMASAXMAMMAMAAXSMSAAXM +MXMXSAMMXMSAMMAXMASASAMMAMMXMXMSSSMMXXAMXASASMSASXMSMMMAXASAMAMXMXXMXSAMXMXSMXSXMXXSAXMXAXXXXXMMMMMMAMMMMMAMSMMASAMASXSXXMAXMAXMXMAMXMAMSAMX +MXMASAXXMAXAMXMMSASMMASMAAASMMAAAXASMMAMMXXASXMASAAMAMMMSMMMSMSMMXXXAMASMMMXMAMASAMSMSMMMXXXMXMXAAAMASAAAMXXAASMSAMXSAMXSXMXSSSSSMMMAMXMASAX +XXMASXMMXSSSMXMMMAXAMAXXXMXMASMMMSAAMXMASMSMMASAMMMMAXAMXMMAAAAASASMSSSMAMAXMASAMAMMAAXAXMSMSASXSXSXMSMSXSMSSMMXSXMMMXMAMSXXXAAAXMASAMXAAMSS +MXMAMAMXAAAMAASMMSMAMMSAMXMSMMAXXMMXAAMXAAAMXXMASXSSSSMXAMXXMSMSMASAAMASMMSXSAMXMXMXXSXMSXAASASAMXMMMMAXAAMAMAXAXAAMAAMAMMXMMMMMSSMSSMSMMSAX +MXMSSSSMMSSMSMSAAASAMMAMXAAAXMMMXXSXMXSSMSMMMXMAMAAAAXMMSMMAMMMAMXMMMSAMXAAAMMXMXSMSAMAAAMMMMMMAMMMAMMAMXMMSSMMSSSMMXSSMSMAAMXMAXMAXAXSAMMMS +AMXMAAXAAAAXXAXMSMSXXXSXSMSMSASMSMMAXSAXXAAASMSSMMMMMMSAMAXXMAXXMAXAXMAXMXMMMSSSXAASASXMXMMMSAMAMASMSMXMXXAXXXAXAMAXSAXMAMSXSAMMSMMMMMSAMAAX +AAMMMMMMMSSMMAMXAAMMMMMASXMASAMXAAMMMSAMXMMMSAMXXAMSMAMASXMASAMMSMSMSMMMSMXSAAAXSMAMAMMSAXSASXSASXSXSXAXMMXMMMXSXSAMMMXSXXXASXXMAAAAXASXMMSS +MSAXXMXAAAMXMAXMMMMAMAMAMMMMMAMSSSMAAMXMMMSXMXMMMSMMMAXMMAAMMASXAAXXAAAAAAXAMMXMXMAMAMASAXMAXMAMXAMAMMXAXSASAAASMMXSMXXMMMMMMAMSSSMSMXMASXAX +SAMAAMSSMSSMMSSMSASASAMASAXAMXMXXAAMASMSXAAXMMMSAMASXMASAMSXSAMMMMMXSSMSSSMMXAXSXMASAXXMSMMAMMXMMMMSMAMMASASASXSAMASAMXAAMAMMSMAAAAXMASAMMSM +XAMMXMAAMXAXAXAASMXMSASAMASXXMSXSXMXXXAXMMMSXAAMMSAMAXXAAXXXMAMMSASAXMAMAMAXMMSAAMAXXMAAAXMMSAAXAXMAMXMMAMXMAMMSAMASASMSXXAMMMMMXMMMSXMASXMA +MMMXXMSSMSAMMSMXMASAMAMAMMMXAASAMXMXMMXSASMMXMSSXMASMMSMMSSMSSXASASMMMAMAXAMAXSMSMSMSAMXMXAXMMSXMMXMXASMSMSXAMXSXMMSAMAAASXMSAAMMSAMXSMMMAMS +XASAMMMXMMAMMXXSXMASXXMMMMASMMMMMAAAXAASXMAAMSMMXXMAAXSAMMAMAMMMMMMXASXSMSMXMXMAXAXASAXMMXMXSAXAXSSXMMSAMASMSMXMAMMMAMMMMMAASXXSMMASASXAMAMA +MMMMMAXAMXXMXSXSAXAMMXMSMMAMAMAMSMSAMMMSXSMMMAAMMSSSXMSAMSAMASAXSSSSMMXSAAAASAMXMASMSAMXMASMMASMMMAAAMMAMAMAAMMSAMAXAMAASMMMMASAXMXMASMXSSSS +XAAAXMSMSAMAXMASMMSMSAMAAMAMASAMAAMXMMXMAMMXSMSAAAMAMXSXMSMXMSMSXAAMMMAMXMMMSASXSAMXSAMXSAMAMAMMXSAMSSMSMAMXMXASMMMSSSXXXAXMASAASXMMXMAXXMAM +MSXSXXAXMAMMMMAMAAAAMASMMMMSASMSMSMASXMXAMMMMXXMMXMAXAMXXMSAMXMXMMMMAMXSXSXASAMXMASAMAMAMMXSAMXSAXASXAAASXSMSMMSAXMAMMMSSMMMSMMMMAASXMSMSMSM +MMAXXSASMSMSAMXSMMXMMAMAMAMMAMASAAMMSAMXMSXAMAMXXMSMSMSXMASXSAXMAAXXASAMAXMMMAMXSAMXMSMSMSAMAMAMXXMMMMSMSMSAXMMMXXMASAAXASXSXXMXSXMMAMAXSAMX +AMXMAXASAAXXXXXSASAMSASAMSMMXMAMXMMMSMMASAMMSSXMXMAAAMAAMAMXSAMSSMSSXSAMXMXSASMXMASXMXAAAMXSAMSMSASASXMASAXMASAMMMMXSMMXAMXAMSMXAMAMAMAXMAMX +MMMSSMMMXMMSSXMSAMAMSAMMMMAMXMXSMMAAXAXXMASXAXAMASMSMSXXMASXMXMAAAXXMXAMAMASAMAXSAMXAMSMSMAMASAAXAMMXAMAMXSXASXSAASMMMXMXMMSMAMXMASMMSSMMAMX +XXAAAAXXXMAAXMAMAMMMSXMXAMXMMMAMASMSSMMSMMMMMSSSXSXMXMXMMMSAMXMSMSMASXSMXSAMAMSXMASMXMAAAMASXMMSMMMSMSMAMMSMMMAMXXXAAASXSMXXSMSXXAMAAAMASASX +SMMSSMMXXMMXSAXSAMXAXASXSSMMAMAXMMAMAXAMASXAXAAMMXAMMSASAAXXMAXMAMMAMXMAXMXSXMXASAMXXAMMMMXSAMXAAAAXAXSASXXAASAMXSSMMMSAAMAMAXAXMMSMMMSAASAX +AAMAMASXMMSASMMSXXMXMSMAXMAXMMXSMSSMAMMSAMMMMMSMAXAMXSXSMXSASMSMAMMXXAMXMAAXMASAMASAMXMASMMMMMSXSMSMMMXXMASXMSASAASXAXMXMMASAMSSMAMAMXMASMSS +SXMAMAMAMAMMSAMSXMASXAXXMSSMXSXAAAXMXSXMASAAXXMMXSAMXMAMAXSXMAAMSMAMXMSMSMSSMAMASXMXMASASAAXSAXXXXXAMSAMXAXMASAMAAMSMMMASXXMAMAAMAMSAMXMMMAM +XXMSMMXSMXMAMAMXAMAMSMMXAAAAAXSMMMSAMMXXAXXXMMXAAMAMAMXMSMSAMSMXAMXSAAAASAAXMXSAMXAMXXMASMMSMASAMASMXMAMMMSMXMXMMMAXMASMSMMSMMSSMAMMAMMSAMAM +SAAAASXXMMMSXMMSXMAMAXXXSSMMMMAMXSXAAAAMSSSSSXMMMMAXASXMAASAMMSXXSAMMSMSMMMMXMAXMXSXSXAXMXMAMXMMMXMAXSAMASAMXAAXXXXXMMSAMXMAAXMAXMSMAMASMSAS +SMMSXMAXAAAMASMMSSMSSSMMMAXXMASMXASXMSXMAAAAMSMAASXSMSASMXMAXAAMSMMXMMXMMAAXSSMSSMMAMXMSMASASAMXXSXMASASMSMSMXASXSXXMSMXMASXSMSAMXAMAMXSASAX +XAAAAXASMMMSAMAAXXAAAAAASMMSAAAMAMXXMAMMMMMMMASMMMAAASXMXMSMMMXMAAMXSAMXSMMXMAAMMAMXMAMAMMSXSASXMSAAXSMMMMMAAAMXMXMASXAXSASAMXMXXSMSXSAMMMSM +SMMMMMXSXAAMMXMMMMMMSMXMMAXXMMSAMXMXSAMMAMMXSMSXSMSMMMMMMXAAAAMSMSMAMAMASAMXSMMMMXMMXMSMSXSMSMSAASAMXXMASASXSXXAMXAMAMXMMMMXXMSMMXAXMMASAAMX +MXSAAMASMMMSSXXMASAAAMMSMMSXSAXMXAAAMAMSAXMAMXMASAXASAAAMSSSMSAAAAMASAMXSAMXXASASMMSAAAAAAXAXAXMMMMXMASMSASAAAMSMAMAXXAMASXMMXAASMMMMSAMMSSM +XAMMSMASASXAXMAXASMSXMAAAXAAMASXXMMMSAMXMSMMXXXXMXMAXMMSXMAXAMMMXXMAMAXASAMMSMMXXAASMSMSMMMMMMMXSASAMMMMMMMMMMMXASXMMSXSASAAXSMSXAXAMASMMAXA +MXXSAMXMXMMSSMSMAXMXAMSXSMMXMSMMXSMXSASXAMMAMSMSMSMSMSXXASMSSXSXMSXSSSMAMAMASXMXSMMMXAMXAAAXAXSXSASXSAXXXSSXSMXMAXXAASAMASMSMMXAXSMXSAXXMAMM +MAXSASMSMXAXAAAMSMSMMXMAAXXXMXAMASAXMAXMSMMAAAAAAAAAAAASAMXAAXXAXAAMAMXXMAMMMASAMXAXXXXSMSSSSSMAMXMAMMMMAMMAMMSMSMSXSMAMAMMAAXSSSMAXMASXMXSX +ASXSXMXAMXSXMMMSMAMASAMMMMXMAAMMASMSMSMAAXSMXMSMMMSMSMXMMMMMSMSXMMXMAMAMMSMSSXMXMMMSMSMAAAMXMAMXMMMMXSAAASMAMXSAMXXMXMSMXSSSSMAXAASXMXMMMMAM +MXAMXSSMSMXMXAXAMAMMMAXSAMMAMMSMXSXAAXMSMXXAAXMXMMMXMMXMSAMSAAXMXSASAMASXXAXXMSASXMAMAAMMMXXXXMASXMXAMXXAXMASXMMMXXASAMXXMAXAMMSMMMMMMSXSASX +XMAMAMAXXXAXMASMSMSXSAMMAMSASASXSMXMSMMAMSMSMSAASAMAXMAMMAXSMMMMAAXMXSASAMSMSASASMSMSMXXMMMSMMSAMAXMMMSMASMXSAMSMMASAMSMSMAMXAXSAMXAAAXMAMXM +MSAMXSMMSSMSMXMAAMMXMAMSAMXAMAXSXMAMXASMSSXAXMMMXAXAMSASXSMXASMMSSMMXSAMXMMAAAMAMAAAAMSXSAAAAAMASXMMSAXAAXMASXMAAXSMMXAAAXSSSXXMMMMMSSMXSAMX +MSMSAMXAAAXAMAMSMSSMSAMMASMAMMMSXSMSXMMXAXMXXSASXSMSXSAXAAXMXMAAAMXXAMMMMMMSMXMAMSMSXSAASMSSMMSXMASAAAXMXSMMMMSMSMXAXSMSMMMAMSSMSSMMXAMAMMMM +ASMMXXMMMSMXMMMXAAXASAMSAMXAXAMXAXAAMMSMSSSMASXSAMAMMMXMSMMMXSMMMSXMAMSAXMAMMMSAMXAMXMMMMMMAXAXXMAMXSSSMMAMMAMAAXMXSMMAXXMSAMXSAAAASXXMASAMA +XSMSMASMMXMSAMAMMMSXSAMMMSMSXSMSSMMMSAAXAAAMXMAMAMXMXXSAXASAMAXSXXXAMXMMSMASXAXXXMAMAXXSMSSSMMSMSMSAMAAXXMASASMMMSAXAMAMXXMAMXMMMSMMAXSASASX +MXASXMSASMASAMASAXMXMMMAAAAMAMAXMAXAMXSMMSMMAMXMMMXSAXMASAMSAMSAAMSSXXAAMMMMMSSSSMSSXMAAXAAAMXAAAAXAMSMMXSASASAMAMASMMMSSMSMMASAMAMMSMMASAMM +AMMMAXSAMMAMAXASMMXAMXXMSMMMAMAMXXMXXAMXMAAMASXSAAXMAXMAMAMXSXAMXMAMMSMSSMMMXMAMXAAMAMXMAMSMMMMSMSMMXMXMAMMSXSAMMXAXXAXMAAAMXASAXXMAXAMAMAMA +SAASMMMAMMSSSMMSASMMMAXXMXAMAMAAAXSSSMSXSSSMMSAAMAMMAMMASMMXXSMXAMSXMAAXXAASMMAMMMMSXMASMXAMAXMAAXMSASAMAMAMXMMSSMMSSSMXMMMSMAMAMSMXSAMSSMMS +MSMAAXSMSAAAXXMMMMAAAXMXASXXAXMMSXAAXAXXMMXAXMMAMXAXASXAMAMXXXXSAMXASMSMSSMMASXMXMXMASXSMXMSMSMMSMAMASASASMSASMAAAAAMASXAAAAMSMSMMAAMAMMAMAX +XAMSMMMASMMSMMMASMSMSSMMXMASXSXAXMMMMMMXSAMMXMMXMAMXAMMMSAMXAXMAMXSAMAAXMASXXMXMASASAMXMXMXAAXXSMMXMAMAXAAMSAMMMSMMMMAASXMMXXXAMAMMMMSMSAMXS +AXAAMAMAMSAMXASXSAAAAAASAMXMMAMXSAASMMAAMASXMMAASXSSMMSAMASAXSSMSXMAMSMMMXMXAAAMXSXSAMXMAAXMMMXMAMSMAMXMASMMXMAMMAXXMSASXSXSAMAXXMAAAXASXSXS +MMSMSAMXSMMMSXSMMMMMXSMMAXMAMMSMSXMAAMMSSMMMAMSMSAMAAAMMSMMMMAAAAXSAMMXXSASMMSXSXMASASASXSXSAAAMAMXSASXAAXXAASASXMMXMXAMAMMMXSMMSSMSSMAMXMAS +XAAXXMSXMASAMXMAXMXSAMASAMXAMXMAMAMXMMXAMAAAMAMAMAMMMMSXAAAAMSMMMXMXSMAMSASXMXMAMXAXASASAMASMSSSXSAMXMMMMXMXMSASAAXSAMMMAMXXMAMAAAXMXMXMXMSM +MSSMSASXSAMXSASMMXAMAXAMXMSASMSSSXMAXSMSMSASMSSMXAXXAAXXSSSMXMAMXSXAAMAXMMMAXMXAXMXMAMAMAMAMXAAAAMASXMSMSASMXMASMMAAASASASXSMSMMSSMMAMAMXMAM +AXAAMSMMMXSSMAAMMMMSSMMSXXAASAAXMASXMAAMAXAXXAAXMMXSMXSAXAAXASXMAMMSMSMXAAMXMSMSXSAAAXXXAMXSMMSMMSAMXAAASAMXAMXMMMMXXXAXXAAAAAAXXMAMAMAMMXMS +SMMMMXMASAMXMAMAAAMAXAXMMMMXMMMMSAMSAMXMMMSMMSMMXSAXMAXXMXMSMMXMAMAAXAMSMMMSXSAAASXMXSMSXSAXMXXMASASXSMMMAMSMSMMXAMSSMSMSMMMXMSAXMSMSSMXSAXA +MMSXXXSXSMSMSASMMSMMSMMXASAXMAMMMAXXSXXXXSAMAAXMAMMSMMXSASXMXXXMXSXXSXMAAAXMAMXMMMMSMAAAXMASXMAMMSXMAXXXXXASAMXMMXMXAAXAMXAXSAMMSXXAMAAAMAMM +AAAXMASASAAAAAMAMMXAAXXMMMMXMASXSSMAXXSMMSXXSASMXSASAAAAXMAASMXSASXASMSMMMAMXMMXXAAASMMMSMMSMSMMAMAMAMAMSAAMMMAXMMMSXMMAMSXXAAAAXMXMSMMMXSAX +MMSMSAMAMMMSMSSMMMMSMSMAAAXMAXSXAAMMMASAAMMXXAMXAAXXMMSSMSMMAAAXAXMXMASASMSAMXMMSMSXSXAMAAAXMAXMASAMXSAAAMAMXSMMMAXAAXXXXMXXSSMXMMAMAXAAAASX +XMAMXSMAMSMXXAAASMMAAAASXSSXSASMSMMMSASMMXAXMSSMMSSXSMMAAXAXMMMMMMMMMXMMMAAMASXAAXXXMXSSSMMSSMXSAMASXMXSXXXMAMXAXXSMSMXSAMMMMAMSMSASXSXMASXM +MSMMMMSXMAAXMMMMMASMSMXMXAXAXMSAAAAAMASXMASXMASAMXAXSASMMMSXXAXAAAAMMMSAMXMXSAMSMSXMSAMXMMAMXAAMASMMXXXMASMMSSSMSAMAXAMMAXAAMAMAAMAXXMMXMAXA +XAAAAMAMSMMMSMASXMMAXMXSXMMSMASMSSMSMAMXMAXAMMSXMMXASAMAAMMSSMSSSSXSAAMASMXXXMAXAMAMMXSAMXAXMMMMAMAAAXMXMMMAMAMAAXMAMAMSMMSMSMSXMSXSASMMMASX +SSSMSSXMASAAXXAMAAMAMXAAAXAMMMMAXXXXMXXXMXSAMXSMMASASMMXMMMXMXAMAAXSMSSMMMMMMXAMAMXMAAXASMSMSMAMASMMMMMAAAMXMAMXMXMMMAMAAMAASASMAAASXMASAMAA +XAAAXAAMAMMMMMSMSMMSSMMSSMSXMXMMMSSXAASMMASXMAMAXXAAMXXXSASASMMSAMXMXAAASXAAXMASXMMMMMXAMAXAMXAXAMXMXAXSSMSXSXMMXMMMXXXMMMMMMAMXMMMMASAMAMMX +MSMMMSMMSSSMSXMAAXAAXAMAMAAAMMMSAAMMMMXAAASAMXMMMMMMMXMMSASASAXAAXAMSSSMMSSSSSXAAXXSASMSMAMAMSMSMASAMXMXAMXAXAXSASXMASMSXXAAMAMAXXXXXMASXMXS +AXASAAAXAAAAXAMSMMMSSMMASMSMMAAMMXMAMSSSMMSXMASASAXAMMMAMXMASXMMXMXXAAAMXAMMMMMSMMMSASMAMXSAMAMAMMSMMXSMSMSXSMMSASXMASAAMSSMSXSMSMMSSSXMXSAM +MSAMSSMMMSMMMXMAXASAMMSXMXAASMMXSASMSMAAMAXAMAXMXXMSXMMSSSMXMASASMSMMSMMMXSXXXAMASXMMMMSSMSXSXSASXMASAXXAAAMAAAMXMXSAMMMMAAMMAXAAAXAAXXSXMAS +AAXAXXAAXMAAAXSXSXSASMMAMMMMXAAAMXMMAMXMMSSSMSSSSMXMAMAXAXMASXMAAAAMXMAXMMMAXSMMAMXAAAXMAMXXMXMMMAMAMXSMMSMAXMASXSAMMSAAMXSAMMMMMMMMSMMMXSAM +AMMSAMSSMSSMSXMASMSAMXXMMSXASMMMSAMSSMMSMMAXAAAAAXAXAMMMAMSXSXMXMSMSASMSSMMAMMAMSMSSMSSSMMSASAMSSMMMSMAXXAXXXXASAMXSASMSAXMAAXMASAMXMMAAASAS +XXAXAMXAMXXAMXMASASAMXXSAMMMSMAXSAMAAAAAXMAMMMXMMSMSSMXMAMSSSXXXMAMSASAAAXSMSMAMXAMXMMXAXAMAMXSAAAMSAXAAMSSSSMAMAMAMASAXMSMXMASASASASMXXASAM +XMAXMMMMXMMXMAMXSXMMMAAMAMAXMMSXMAMSMMMSAMXMAXMXXXAAXMAMAXXASAXSSMMMMMMMMMXAAXAMMXMSXMAMXAMAMMMMSMMAAMXSAXAXXAXSXMASXMMMXAAASXMASMMASASXAMMM +XSSMSAAXSASASASAMMSMMXSSSSXSAAMASAMASMXMASASXSASASMMMSSSSSMMMSMAASMAMAXXSMMSMSMSSMAXMAXSAXSAXMXAXAMMMMXAMMAMMSAMXSMMMAXMSMMMMAMAMAMMMAMMSMAM +AAAASXMSAAMASAMXMSASAMXAAXXAMASMMSMAXXAXXSAXAXXMAAXXXAAAMXASAXMSMMSASMXMAMXAAAMAAMMMMMAAMMSMSSMMSSMSSXMMXSAMAAAXMXAMSSMXMASMSMMXSMSXMSMAAMAS +SMMMMMXMMMMXMAMAXSASMSMMMMAXMASXMAMMSXSMMMMMSMXMMMMMSMMMSSMMMSMAAMMMSXASXMSMXMMSXMMAMXMMXAXAAMAAAAAAMMAXAMAMXSXMSMMMAAMXAAAXAAXAAXMAMMMSMSAS +XASXXXAMMSMXXAMXAMXMASXAMXAXSXMASMXMAMXAMAAAMASXSXAMAXXAMMAAAAXMSMAXXMXMAMMSMXAMAMSMSAXXSMMMMSSMSMMMSSSMMSXMXXAAXASMSSMSXSMSXSMAMMSXMAAXXMAS +SXMAXSAXAAAMASXMMMXMAMSMSAMXAXMXMSXMAXSAMXMMSMXAXSMSMSMMSMXMSSSXMMMMMMXSMMAAMMASMMAASXSASAAXMXMAXMMAMXMXMAMXASXMXSMAAXAMAMXMMXMAXXAAMMXSAMXM +MMMXMMAMXSAMAAASXSAMXXMMAMMMMSXSASMXXXMMMAMXMAMSMXXAXXAMAMAAXAXAMMSMXAAMXMSSXSAMXSMMMASASAMXSMMSMXMSMSXMASXMASAMSMMMMMAMMSAMAMXAMASAMAASXMAS +SASASXXMMAAMMSXMASXXSASXMSAAXMAMAMMMSSMSMMXAMSMMAXSMMSSMAXMSMMMMMAAAAMXMAMMAXMASASXAXXMAMMXAXAXXXXSAAASMMMASASXMAAAAXMAXXSAMSMMXSAMSSMMSASAS +XMSAMMMSXSXMAMAMXMAXSAMXAXMMAMAMAMMAMAAAASXMMMAMSMAAAAMMMSMMAXAASXMXXXMXXSMSMSAMMXMMASMXMMMXXXXMAXXMSMXSASXMASXMSSMSSSXSAMXMAAXAMAMXMMXSXMMS +XMMXMAXXAXXMXSAMXMXMMSMMSMMSMSAMXMMAMMMMXMAMASXMXSMMMMSAASASXMMXXAAXSMSMMMMMMMXXMAMXMAAAAXASXMSXSASXMMASXSMMAMAXAAXAAXMMAMXSXSMMSSMAMSAMSSMX +XMASXSMMMMMMMSAMXMXSAMXAAAAAMAMMSMSMXMAXASAMASAMAMXSAMMMXSAMMAMSSSMMSAAAAAAAXSSSSMMAXSAMXMXSAAAAMSAAXMAMXXXMASXMASMMSMXSAMAMMMAXAAMAMMASAMXA +XMXMAMXXAAAAASAMSAXMASMSXXMXMAMXAAAAASMSMSAMXSAMXSASASXSXMASXSMMAMXAXSMSSSMMSAAMASXXXAXSXMASMMMXSMMMMMSSMMASMMXSXMASAAASMSMSASXMSSMAMSXMMMMX +SSSMSMAMXSSMMSMMSAMSMMMMASMSSSSSMSMSMAAAAMMMASXMXMXSAMXAMXSAAAXMAMMMXAMXAAASAMXMAMXXSSMSAXAMAMMXMAASAXXAXXAMAAAXAAXSMSMMAAXMASAAAXXAXMAMASMM +MXASAMXSAMAXMXXAXAMXSAMXAAAAAAAAAMAXASXSXSAMXSASMSAMXMSXASXMMXMXAMXXSSMSSMXMAMXMAMXMAXASXMASAMMASMMSMSSSMMMSMMSAMXMMMMXMMMXSAMMMMXMXXSMMASAA +AMXMMXAMASAMXAMXSAMXSMSMSMMMSMSMMMASAMAXASMSASMSAMXMAAXAMAXXSSMSASMXSAMAXXAXXMAMASAMXMXMMMXMMXSASAMXAMMMAAAAXSAMSMMAASASASAMXSXMXSSSMAXMXSMM +MAAMXMXMAMXMMSSMAXXMMXXAXXXXMAXAXXMMAMXMMMAMXXXMXMASXSSSSSSMAAAASAMXXAMXSSMMSXMSAAAMSMSAMXASXMMASXMMMMASXMMMSAAXMASMMMASAMXXMXMMXXAAAMSXMMXS +MSSSMMSMMSXSAAAAMMMMMAMXMASXSAMMMXXSXMXMSMMSMSMMMSXMMXMAAAMMMMMMMMXSSXMMMMMXMAMMMXMMSAXASMMSAAMAMMMSMSMSSSXXMMMMSAMXSMXMXMXSAAMSMMSMMXSASMAA +MAMAMAMAMAASMMMSAAMASAXASXMMXAMXAXMASMXAAAXAAASXMMMSMSMMMMMASAMXXXMMAMXXAAMMMMMAMXSAMAMXXAXSXMMMAAXAAAAMAMMMXAAXMASAMXMASMMSSMSAAMAXAXSAMMSS +MASMMMSAMXMMAXAMMMMAMMMMSAXAMSMMMSAAASMSMSSMXMMXAAAASAAXMMSASASMMMXMAXSXMMSAAASXMAMASAMXSAMXAXAXSXSMSMMMAMAAXMSMMAXASAMAXXAMAMXMSMXSMMMAMAMM +XMMXAASAMXMSXMXMASMSXSAMXAMSSMAAXMMMMXMAXAXXSXMSSMSSSSSMSAMASXMASASMSMSASASMSMSAMXMAXMAMXSAMMXXXAAMAMAASMSMXSAAMMSXMXAMXMAMSAMSXXAAAAASAMASX +SXAMMMXAMAXMASXMMXAAAXAXMAMXAXMMMMSMSAAMXMAXSAMAAAXAMAXAMMSAMAXSAMXAAASXMAMXXXSASAMSSMSXAMMXXMMAMXMAMSMXAAAXMXMSAAASMSMSMAMMAMAMMMXSMMSXXXSA +AMAMXSSMSXXMAMXXXMMMSSMMMXXSAMXAAXAASASXAXMASAMSMMMSMMMSMMMMSXMXAMASMMMMMSMAMAMXMAXMAAMMMMASXSMAMSMXXXAMSMMMXAXMMMMMAMAAMSXSAMMAAAAXAMXXSASM +MMXMAMAAAASXMXXMXAXAXAXAXAXMAASXSXMXMAMXXSMMSXMAAXAMASXAXMAASASXAMXMMXAAAAMAMAMXXSMSMMMXMAMSAASXMAAXMMSMMAASMMSMSMXMAMSMSAASMMMMSMMSSMAAMMMX +XAAMSSMMMAMAMASXMMMXSMMMMMSSSMSAXAMAMAMXXMAAMASMSMASXMSMMMMMXMASXXXSXSMMMSXXMAXXAXAMXAAXXMSMMMMXSMSSXAAASMMSXAAAAXXSAXMXSMMMMAMXXAAAAMXMXXAX +XSXXMAMXXMSXMASXAXMMMXASAXAXMAMAMXSASXMMXSMMSAMAMXMMAXXXASMMSAMAMXAXXMMSXMASXMSMAMAMMXAXMMAAMMMXSXAMMSSMMMAMMMMSMSAMXXAAXAMXSAMMSMMSSMAMAMAM +MAMXXXMAXMXMAMMMSMMASXXSASMXMSMSMXMAMXMAXSMMMAMAMASXMMMXMAAAAXXAXMAXSXAMAMAMAAXXAXSMMMMAASMMMAMMMMMSAAXAMMSMAMAMXSXMXMMMSSMAMXXXAAAAAMAXASAS +XSXSMSMSMASXSMSMMMMASMAMAXMAMAAASXMAMXMSXMAXSMMMSAMXXMAMMSMMSMSXXASMSMXSMMSSMMMXXXXAXAMXXMAXSAXAAAXMMMXXMAMMAMXSMMAMXAAAXAMXSAMSAMMSSSXMAMAS +AMASXAAAAXXAMAAAMSMMXMAMXMSSSMMMMMSSMSAMASXMAASAMASXSMXSXAAMMAMMMXMAXAMAAAAAAXXASASMMXSXASXMSASXSSSSSSSXMASMMMXSASAMMSMMSMMAMAXSMMXXMAMMSMAM +AMAMSMSMSMMMMSSSMAMAMMSXMXAMXAAAXMAAMMAMAMAASXMAMAMAAAMSMSSMSSSMSMMSMSASMMSSSMSXMASASAMMAMAAMAMMAMXAAAAMMAMAASXSASXSAASAAXMXSSMMAXXAMAMAXAMX +SMAMXXAXAAAAXMAXMMMASXMASMMSXSSMMAXMASXMXSMMXMSSMXXSMMMMAMXAAAXAAXXAAMMXAMAAAAAXSXMAMASXMAMXMMMASMMMMMMMMSMSMMAMAMAXMAMXSMSXMAMXAMSXMXMXSSXX +ASXSXSMSMSMSSMAMXXMAXXMXMAMAAMAXAMMXMSXMAMXAMMAXXAMXMAMMXMMMMMMXMSMMSMASXMMSMMMAMAMXMXMXXAMMSSMAMMAAXAAXMXMXAMXMSMMMSMSAXASXMAMMSMMAXSXAXAMM +AAMMASAAXAAXMMSMSMSMSASXXXMXMMAMMXMAMXXMASAMAMASXXAAXSXMAXAXXXSAASMSMMXMAMXAXXMAXXMASMMMMXSAAAMSSSSSSMXSAAXXAXMAXAMXAAAAMMMAMXSXMASMMMMMSMAA +XXAMAMMSSMSMXAMSMAAAXAXAASMSAMSMXXXMSMMSASASMSASMSSMSMAMMMMSMAXMXMMAAAXSAMMSMXSSMMMXXAAAAAMMSMMAAMAAXMASMMMSSMSMSXMMMSMSMXSAMXMAMXMAMAAAAXXS +MSSMMSXMMMMXMASAMMMSMMMMMAAXMAMMXSXXAAXMXSMMXMAXAMXMAMAMXXAAMXMSASMSXMMXASAAXXXXAXSSSSMSMMXMMAMMXMMMMMMXAXXAMAAXMMSMMAXMAAMMSSMAMSSSMSMSSSMX +XAXAASAMXASAMXSXSAXAASAASMMMMAXSAMXXMSMSXSASAMXMSMSSMSMSAMSXMMAMASAMSXMMXMMSSMMMSMAAXAXAMMAXSXMAMXXMAAMXMSXMMSMSMAMASMSMMMSMAMXASAAAXMAMAAMX +SSSMMSSMMMSMSMMASXSMMMXXXAMXSMMMMSSMAMAMASXMXXXAXAMXXAXMAXMASXSMAMAMAXMASAMXAAAAMMMMMXSXSXMXXAMMSMASXMSAAAMXXAAXMASXMAMAXMAMAMXMMMSMMMSMSMMS +XXAMXMXSXAXXAXMMSASXSSMMSSMMMXAAAAAMXMAMAMAXMMSAMXMMMMXMMMSAMAXMMMMMMXAASAMSSMMXSAXXAMMASAMXXMMAAMXMAASMSMSXSMMMSASXMASAMSASXSXMAMAMXAAXXAXA +MSMSAMXAMASASXMXMAMAAAAMAMAAAMSSMSSMASXMSSMMAASAMASXMSAAAXMAMXMASASAXXMASAMXMSMAXMAMSAMASMMSMAMSXMAMMMMAMASAMMSMMASXMXMMXSASAAMXSSMSMMSSSSMM +ASASXSAMXAMAMASAMAMMMSMMASMMSMXAXMAMASAAAAASMXSAMAXAAASXMXSAMSAMSASASXMASAMXAAMMSXAXMSMXMXAASAMAASXSAAMXMAMAMAAAMAMXMAMSAMSMMAMAMAMXAAAMAAAX +SMAMMMMXAMMAMXSXSSXMAXXSMMXAMXSMMSAMXSXMSSMMMXSAMXSMMMXXSASXSXSAMXMMXMMXSXMMSMSXSMXSXXMASMSXSSSXMASMXXSAMXSMMSSSMXSXSXSMMSXMASMXSAMSMMSMSMMM diff --git a/2024/Day05CSharp/Day05CSharp.csproj b/2024/Day05CSharp/Day05CSharp.csproj new file mode 100644 index 0000000..c9cae6e --- /dev/null +++ b/2024/Day05CSharp/Day05CSharp.csproj @@ -0,0 +1,14 @@ + + + + Exe + net9.0 + enable + enable + + + + + + + diff --git a/2024/Day05CSharp/Program.cs b/2024/Day05CSharp/Program.cs new file mode 100644 index 0000000..44ef225 --- /dev/null +++ b/2024/Day05CSharp/Program.cs @@ -0,0 +1,196 @@ +using System.Runtime.InteropServices; + +var exParsed = new Day05Parsed("example-input.txt"); + +Console.WriteLine("Example Part01: {0}", exParsed.GetPart01()); +Console.WriteLine("Example Part02: {0}", exParsed.GetPart02()); + +var pzParsed = new Day05Parsed("puzzle-input.txt"); + +Console.WriteLine("Puzzle Part01: {0}", pzParsed.GetPart01()); +Console.WriteLine("Puzzle Part02: {0}", pzParsed.GetPart02()); + +class Day05Parsed : AdventCommon.ParsedInput +{ + public class Page : IComparable + { + public static Dictionary> RulesByPage = new Dictionary>(); + + public Page(int value) => Value = value; + + public int Value { get; set; } + + public int CompareTo(Page? other) + { + if (other == null) throw new Exception("Other is null"); + + if (this.Value == other.Value) return 0; + + if (!RulesByPage.ContainsKey(this.Value)) + { + // If there's no key, then this MUST be at the end so its the "biggest" + return 1; + } + + if (RulesByPage[this.Value].Contains(other.Value)) + { + return -1; + } + else if (RulesByPage[other.Value].Contains(this.Value)) + { + return 1; + } + + throw new Exception("Unable to compare!"); + } + } + public class OrderingRule + { + public OrderingRule(string line) + { + LeftPage = Int32.Parse(line.Split('|')[0]); + RightPage = Int32.Parse(line.Split('|')[1]); + } + + public int LeftPage { get; set; } + public int RightPage { get; set; } + } + + public class Update + { + public Update(string[] pages) + { + foreach (var page in pages) + { + Pages.Add(Int32.Parse(page)); + } + } + + public List Pages { get; set; } = new List(); + } + + public Dictionary> RulesByPage { get; set; } = new Dictionary>(); + + public List Rules { get; set; } = new List(); + public List Updates { get; set; } = new List(); + + public Day05Parsed(string fileName) : base(fileName) + { + foreach (var rule in Rules) + { + if (RulesByPage.ContainsKey(rule.LeftPage)) + { + RulesByPage[rule.LeftPage].Add(rule.RightPage); + } + else + { + RulesByPage.Add(rule.LeftPage, new HashSet() { rule.RightPage }); + } + } + + Page.RulesByPage = RulesByPage; + } + + public override int GetPart01() + { + List validUpdates = new List(); + + Updates.ForEach(update => { + if (IsUpdateValid(update)) validUpdates.Add(update); + }); + + // We have all the valid updates, now get the "middle" item + int middlePageNumberSum = 0; + + foreach (var update in validUpdates) + { + middlePageNumberSum += update.Pages[update.Pages.Count / 2]; + } + + return middlePageNumberSum; + } + + public override int GetPart02() + { + List invalidUpdates = new List(); + + Updates.ForEach(update => { + if (!IsUpdateValid(update)) invalidUpdates.Add(update); + }); + + + int middleSum = 0; + + foreach (var update in invalidUpdates) + { + List pages = new List(); + + foreach (var page in update.Pages) + { + pages.Add(new Page(page)); + } + + pages.Sort(); + + middleSum += pages[pages.Count / 2].Value; + } + + return middleSum; + } + + + private bool IsUpdateValid(Update update) + { + bool isUpdateValid = true; + + for (int pageIndex = 0; pageIndex < update.Pages.Count; pageIndex++) + { + if (!RulesByPage.ContainsKey(update.Pages[pageIndex])) + { + continue; + } + + var rules = RulesByPage[update.Pages[pageIndex]]; + + // Make sure current page has rules that say its before all the subsequent pages + for (int subIndex = pageIndex + 1; subIndex < update.Pages.Count; subIndex++) + { + if (!rules.Contains(update.Pages[subIndex])) + { + isUpdateValid = false; + break; + } + } + + // Go backwards and make sure none of the previous pages have an existing rule + for (int i = 0; i < pageIndex; i++) + { + if (rules.Contains(update.Pages[i])) + { + isUpdateValid = false; + break; + } + } + } + + return isUpdateValid; + } + + public override bool ParseLine(string line, object? context = null) + { + if (line.Contains('|')) + { + // It's a rule + Rules.Add(new OrderingRule(line)); + } + else if (!String.IsNullOrWhiteSpace(line)) + { + // Must be an update + string[] pages = line.Split(','); + + Updates.Add(new Update(pages)); + } + + return true; + } +} diff --git a/2024/Day05CSharp/Properties/launchSettings.json b/2024/Day05CSharp/Properties/launchSettings.json new file mode 100644 index 0000000..5a47dee --- /dev/null +++ b/2024/Day05CSharp/Properties/launchSettings.json @@ -0,0 +1,8 @@ +{ + "profiles": { + "Day05CSharp": { + "commandName": "Project", + "workingDirectory": "C:\\dev\\dev-drive\\DevSandbox\\AdventOfCode\\2024\\Day05CSharp" + } + } +} \ No newline at end of file diff --git a/2024/Day05CSharp/example-input.txt b/2024/Day05CSharp/example-input.txt new file mode 100644 index 0000000..2508bd7 --- /dev/null +++ b/2024/Day05CSharp/example-input.txt @@ -0,0 +1,28 @@ +47|53 +97|13 +97|61 +97|47 +75|29 +61|13 +75|53 +29|13 +97|29 +53|29 +61|53 +97|53 +61|29 +47|13 +75|47 +97|75 +47|61 +75|61 +47|29 +75|13 +53|13 + +75,47,61,53,29 +97,61,53,29,13 +75,29,13 +75,97,47,61,53 +61,13,29 +97,13,75,29,47 \ No newline at end of file diff --git a/2024/Day05CSharp/puzzle-input.txt b/2024/Day05CSharp/puzzle-input.txt new file mode 100644 index 0000000..0112828 --- /dev/null +++ b/2024/Day05CSharp/puzzle-input.txt @@ -0,0 +1,1380 @@ +76|18 +58|19 +58|49 +44|59 +44|16 +44|25 +59|33 +59|35 +59|51 +59|71 +79|28 +79|76 +79|18 +79|63 +79|44 +99|85 +99|79 +99|55 +99|36 +99|33 +99|63 +86|73 +86|63 +86|18 +86|48 +86|35 +86|11 +86|57 +98|82 +98|76 +98|35 +98|99 +98|32 +98|79 +98|95 +98|29 +46|48 +46|57 +46|75 +46|49 +46|13 +46|98 +46|93 +46|45 +46|44 +56|17 +56|32 +56|86 +56|53 +56|37 +56|36 +56|55 +56|24 +56|11 +56|85 +85|39 +85|92 +85|84 +85|25 +85|45 +85|54 +85|51 +85|61 +85|78 +85|59 +85|21 +93|99 +93|61 +93|82 +93|21 +93|54 +93|56 +93|92 +93|79 +93|58 +93|33 +93|95 +93|24 +32|57 +32|37 +32|19 +32|44 +32|85 +32|13 +32|28 +32|17 +32|55 +32|48 +32|53 +32|78 +32|11 +35|32 +35|92 +35|33 +35|28 +35|79 +35|56 +35|36 +35|54 +35|61 +35|19 +35|71 +35|13 +35|24 +35|16 +45|76 +45|32 +45|71 +45|79 +45|58 +45|24 +45|99 +45|42 +45|51 +45|54 +45|82 +45|29 +45|25 +45|33 +45|84 +37|59 +37|75 +37|86 +37|39 +37|63 +37|57 +37|93 +37|44 +37|11 +37|42 +37|85 +37|18 +37|16 +37|53 +37|36 +37|48 +18|61 +18|21 +18|51 +18|84 +18|73 +18|17 +18|45 +18|39 +18|35 +18|59 +18|48 +18|31 +18|53 +18|54 +18|75 +18|71 +18|25 +13|75 +13|78 +13|86 +13|45 +13|85 +13|59 +13|21 +13|82 +13|39 +13|63 +13|18 +13|17 +13|11 +13|93 +13|44 +13|98 +13|42 +13|31 +53|54 +53|42 +53|75 +53|35 +53|21 +53|31 +53|71 +53|79 +53|99 +53|92 +53|58 +53|98 +53|51 +53|25 +53|45 +53|84 +53|93 +53|61 +53|82 +63|31 +63|59 +63|61 +63|75 +63|25 +63|82 +63|51 +63|35 +63|93 +63|17 +63|84 +63|54 +63|98 +63|42 +63|45 +63|11 +63|48 +63|73 +63|21 +63|39 +42|35 +42|95 +42|54 +42|56 +42|19 +42|33 +42|92 +42|71 +42|24 +42|32 +42|76 +42|51 +42|21 +42|49 +42|55 +42|79 +42|29 +42|58 +42|61 +42|28 +42|25 +29|63 +29|32 +29|76 +29|85 +29|44 +29|19 +29|86 +29|16 +29|49 +29|95 +29|18 +29|37 +29|57 +29|28 +29|55 +29|79 +29|36 +29|11 +29|13 +29|46 +29|24 +29|48 +19|49 +19|31 +19|18 +19|75 +19|73 +19|13 +19|16 +19|44 +19|53 +19|86 +19|36 +19|48 +19|63 +19|39 +19|98 +19|78 +19|46 +19|85 +19|57 +19|37 +19|11 +19|17 +19|59 +51|36 +51|79 +51|92 +51|24 +51|71 +51|54 +51|19 +51|33 +51|61 +51|37 +51|29 +51|44 +51|28 +51|32 +51|76 +51|99 +51|95 +51|35 +51|46 +51|56 +51|55 +51|13 +51|58 +51|49 +75|71 +75|51 +75|35 +75|42 +75|33 +75|25 +75|82 +75|56 +75|29 +75|99 +75|73 +75|61 +75|79 +75|93 +75|58 +75|59 +75|84 +75|39 +75|31 +75|98 +75|21 +75|45 +75|92 +75|54 +54|32 +54|99 +54|76 +54|55 +54|61 +54|49 +54|29 +54|28 +54|24 +54|33 +54|13 +54|46 +54|79 +54|95 +54|86 +54|37 +54|36 +54|19 +54|56 +54|71 +54|92 +54|58 +54|44 +54|16 +78|99 +78|92 +78|75 +78|71 +78|29 +78|59 +78|93 +78|25 +78|33 +78|45 +78|51 +78|21 +78|61 +78|39 +78|42 +78|58 +78|82 +78|54 +78|73 +78|98 +78|31 +78|53 +78|84 +78|35 +84|56 +84|79 +84|95 +84|32 +84|29 +84|71 +84|36 +84|19 +84|33 +84|24 +84|92 +84|99 +84|54 +84|51 +84|55 +84|37 +84|28 +84|58 +84|13 +84|61 +84|46 +84|35 +84|76 +84|49 +71|76 +71|33 +71|57 +71|36 +71|16 +71|13 +71|99 +71|85 +71|86 +71|19 +71|29 +71|95 +71|58 +71|24 +71|37 +71|32 +71|63 +71|46 +71|28 +71|79 +71|49 +71|44 +71|56 +71|55 +95|63 +95|78 +95|85 +95|57 +95|19 +95|46 +95|44 +95|55 +95|17 +95|48 +95|39 +95|18 +95|11 +95|75 +95|76 +95|86 +95|37 +95|36 +95|53 +95|49 +95|73 +95|28 +95|13 +95|16 +28|48 +28|13 +28|17 +28|36 +28|86 +28|11 +28|55 +28|63 +28|49 +28|37 +28|31 +28|16 +28|44 +28|85 +28|76 +28|53 +28|39 +28|57 +28|19 +28|78 +28|46 +28|73 +28|75 +28|18 +92|56 +92|76 +92|95 +92|33 +92|24 +92|36 +92|63 +92|79 +92|71 +92|32 +92|16 +92|57 +92|37 +92|99 +92|29 +92|46 +92|19 +92|44 +92|58 +92|86 +92|49 +92|55 +92|28 +92|13 +11|84 +11|25 +11|18 +11|73 +11|92 +11|98 +11|61 +11|82 +11|59 +11|35 +11|93 +11|54 +11|45 +11|39 +11|48 +11|75 +11|71 +11|31 +11|17 +11|51 +11|21 +11|78 +11|42 +11|53 +55|49 +55|11 +55|16 +55|76 +55|46 +55|85 +55|37 +55|44 +55|73 +55|36 +55|75 +55|57 +55|63 +55|31 +55|17 +55|86 +55|48 +55|18 +55|39 +55|13 +55|53 +55|78 +55|19 +55|59 +31|51 +31|59 +31|82 +31|95 +31|42 +31|71 +31|25 +31|58 +31|24 +31|45 +31|21 +31|61 +31|84 +31|99 +31|92 +31|56 +31|33 +31|54 +31|79 +31|35 +31|29 +31|93 +31|98 +31|32 +73|54 +73|42 +73|71 +73|84 +73|33 +73|93 +73|24 +73|92 +73|79 +73|99 +73|25 +73|31 +73|82 +73|29 +73|59 +73|21 +73|35 +73|32 +73|56 +73|58 +73|98 +73|45 +73|51 +73|61 +48|53 +48|75 +48|58 +48|78 +48|25 +48|98 +48|45 +48|31 +48|73 +48|59 +48|51 +48|93 +48|17 +48|92 +48|84 +48|54 +48|99 +48|21 +48|61 +48|42 +48|71 +48|39 +48|82 +48|35 +24|85 +24|18 +24|28 +24|13 +24|19 +24|76 +24|36 +24|86 +24|55 +24|46 +24|63 +24|39 +24|95 +24|48 +24|57 +24|53 +24|49 +24|78 +24|37 +24|75 +24|17 +24|11 +24|16 +24|44 +25|76 +25|71 +25|21 +25|92 +25|37 +25|99 +25|33 +25|32 +25|35 +25|49 +25|84 +25|61 +25|54 +25|51 +25|29 +25|79 +25|46 +25|95 +25|24 +25|55 +25|58 +25|19 +25|28 +25|56 +21|37 +21|51 +21|92 +21|33 +21|28 +21|36 +21|95 +21|76 +21|35 +21|58 +21|84 +21|46 +21|61 +21|24 +21|71 +21|49 +21|32 +21|55 +21|79 +21|19 +21|29 +21|54 +21|56 +21|99 +16|84 +16|11 +16|57 +16|42 +16|48 +16|86 +16|53 +16|78 +16|98 +16|39 +16|85 +16|59 +16|82 +16|73 +16|63 +16|75 +16|93 +16|25 +16|18 +16|21 +16|17 +16|45 +16|31 +16|51 +39|61 +39|32 +39|25 +39|98 +39|56 +39|45 +39|92 +39|82 +39|93 +39|99 +39|59 +39|79 +39|51 +39|35 +39|42 +39|29 +39|71 +39|73 +39|33 +39|58 +39|21 +39|54 +39|31 +39|84 +33|79 +33|19 +33|11 +33|56 +33|46 +33|49 +33|28 +33|18 +33|85 +33|55 +33|63 +33|13 +33|44 +33|36 +33|86 +33|48 +33|24 +33|16 +33|57 +33|29 +33|76 +33|95 +33|37 +33|32 +17|84 +17|75 +17|42 +17|99 +17|71 +17|53 +17|33 +17|78 +17|98 +17|31 +17|73 +17|25 +17|39 +17|59 +17|93 +17|82 +17|61 +17|21 +17|35 +17|54 +17|92 +17|51 +17|45 +17|58 +57|53 +57|54 +57|18 +57|42 +57|25 +57|73 +57|59 +57|98 +57|51 +57|48 +57|85 +57|21 +57|39 +57|31 +57|17 +57|45 +57|82 +57|63 +57|84 +57|35 +57|78 +57|11 +57|93 +57|75 +82|56 +82|35 +82|24 +82|76 +82|46 +82|19 +82|79 +82|25 +82|99 +82|84 +82|51 +82|32 +82|28 +82|95 +82|71 +82|21 +82|92 +82|58 +82|61 +82|33 +82|54 +82|42 +82|29 +82|55 +61|79 +61|28 +61|13 +61|19 +61|92 +61|24 +61|36 +61|58 +61|71 +61|29 +61|99 +61|55 +61|33 +61|86 +61|46 +61|49 +61|56 +61|32 +61|57 +61|44 +61|16 +61|37 +61|95 +61|76 +49|53 +49|16 +49|17 +49|98 +49|36 +49|86 +49|44 +49|31 +49|13 +49|73 +49|93 +49|63 +49|85 +49|11 +49|18 +49|48 +49|82 +49|57 +49|37 +49|39 +49|78 +49|75 +49|59 +49|45 +36|98 +36|31 +36|53 +36|63 +36|45 +36|75 +36|59 +36|44 +36|85 +36|11 +36|13 +36|39 +36|42 +36|86 +36|93 +36|73 +36|18 +36|78 +36|57 +36|48 +36|82 +36|17 +36|25 +36|16 +76|93 +76|39 +76|75 +76|73 +76|44 +76|16 +76|63 +76|86 +76|59 +76|46 +76|57 +76|37 +76|31 +76|11 +76|36 +76|48 +76|85 +76|17 +76|78 +76|49 +76|13 +76|53 +76|19 +58|99 +58|29 +58|76 +58|36 +58|56 +58|33 +58|79 +58|32 +58|63 +58|37 +58|86 +58|28 +58|11 +58|13 +58|24 +58|44 +58|57 +58|95 +58|46 +58|85 +58|55 +58|16 +44|18 +44|31 +44|21 +44|73 +44|42 +44|98 +44|53 +44|48 +44|57 +44|86 +44|11 +44|45 +44|93 +44|17 +44|82 +44|78 +44|63 +44|75 +44|84 +44|39 +44|85 +59|24 +59|82 +59|95 +59|45 +59|56 +59|61 +59|32 +59|29 +59|42 +59|98 +59|79 +59|21 +59|99 +59|93 +59|84 +59|58 +59|92 +59|28 +59|25 +59|54 +79|57 +79|46 +79|24 +79|86 +79|13 +79|11 +79|37 +79|56 +79|36 +79|17 +79|78 +79|48 +79|55 +79|16 +79|49 +79|19 +79|95 +79|32 +79|85 +99|76 +99|57 +99|46 +99|16 +99|29 +99|13 +99|95 +99|28 +99|32 +99|56 +99|86 +99|19 +99|11 +99|49 +99|18 +99|24 +99|37 +99|44 +86|59 +86|39 +86|17 +86|75 +86|98 +86|85 +86|93 +86|51 +86|21 +86|25 +86|53 +86|78 +86|84 +86|45 +86|82 +86|31 +86|42 +98|28 +98|25 +98|84 +98|51 +98|42 +98|71 +98|61 +98|21 +98|55 +98|45 +98|24 +98|92 +98|54 +98|33 +98|58 +98|56 +46|16 +46|37 +46|53 +46|59 +46|39 +46|36 +46|63 +46|78 +46|31 +46|86 +46|18 +46|11 +46|85 +46|73 +46|17 +56|48 +56|78 +56|13 +56|44 +56|49 +56|57 +56|18 +56|46 +56|19 +56|63 +56|76 +56|28 +56|16 +56|95 +85|73 +85|98 +85|17 +85|53 +85|31 +85|75 +85|93 +85|18 +85|48 +85|11 +85|42 +85|82 +85|35 +93|51 +93|35 +93|28 +93|29 +93|42 +93|45 +93|55 +93|71 +93|32 +93|98 +93|84 +93|25 +32|18 +32|36 +32|46 +32|16 +32|95 +32|75 +32|76 +32|49 +32|63 +32|86 +32|24 +35|46 +35|37 +35|29 +35|49 +35|58 +35|55 +35|99 +35|76 +35|95 +35|44 +45|19 +45|95 +45|61 +45|56 +45|28 +45|21 +45|35 +45|92 +45|55 +37|31 +37|17 +37|73 +37|98 +37|45 +37|13 +37|82 +37|78 +18|78 +18|98 +18|42 +18|82 +18|93 +18|92 +18|58 +13|25 +13|16 +13|57 +13|48 +13|73 +13|53 +53|59 +53|73 +53|29 +53|39 +53|33 +63|85 +63|53 +63|18 +63|78 +42|84 +42|99 +42|46 +29|56 +29|17 +19|93 + +21,84,35,92,58,33,29,79,56,24,95,28,19,46,37 +46,17,63,48,59,76,75,78,16,73,49,53,57,18,36 +56,55,76,19,37,36,16,86,57,85,18,48,78 +25,73,98,54,21,59,39,45,75,71,99,92,82,31,35,33,42,51,61,29,53,58,93 +82,53,42,58,59,33,39,21,25,51,71,78,45 +73,31,98,78,84,75,53,17,93,21,39,92,48,82,58 +71,16,46,32,54,29,44 +44,63,17,31,82,86,93,39,37 +25,28,21,54,92,99,24,46,71,42,56,32,84,51,55 +49,37,36,13,44,16,86,57,63,85,11,18,48,17,78,53,75,39,31,59,93,98,45 +11,18,48,17,78,53,75,39,73,31,59,93,45,82,42,25,21,84,51,35,54,61,92 +17,39,85,75,16,86,48,59,98,49,53,13,57,11,45,63,37 +36,49,16,73,78,76,57,75,55,44,19 +39,73,31,59,98,45,82,42,21,84,51,35,61,71,33,29,79 +18,93,39,54,45,31,17,92,51,82,11 +11,29,55,57,76,48,18 +84,42,61,98,28,82,71,35,21,32,79,93,56,54,99,92,25,24,58,29,51 +98,82,61,31,53,73,92,21,33,93,58,99,25,54,75,29,71,35,59,42,84 +54,61,71,58,33,29,32,24,55 +75,82,84,71,33 +37,95,36,28,24,11,18,85,57,19,13,63,76,86,16,46,75 +32,56,61,31,51,59,82,33,79,58,21,29,71,54,45,98,93,84,92,35,24 +42,21,84,58,99,29,79,32,24,76,46 +45,75,31,85,18,11,98,25,59,93,82,13,73,63,57,16,39 +37,55,78,13,76,86,46,85,11,24,63,19,36,44,75,16,53 +61,86,29,16,24 +17,39,73,31,59,45,82,42,54,92,99 +17,78,53,75,73,31,59,93,98,45,82,42,25,84,51,35,54,61,92,71,99 +37,18,95,44,57 +63,18,31,59,39,25,11,48,57,44,53,98,42 +84,35,21,54,71,42,61,78,48,82,98,93,31,58,51 +76,78,13,37,32,85,16,24,49,28,11,57,46,63,95,19,18,44,17 +32,24,95,55,76,19,46,49,37,36,13,44,16,86,57,63,85,11,18,48,17,78,53 +13,85,19,17,36,16,63,39,78,86,57,48,37,18,75,46,95 +24,32,25,46,61,49,99,84,56,54,19,28,55 +57,63,85,11,18,48,17,78,53,39,73,31,59,93,98,45,82,42,25,21,84,51,35 +63,37,28,57,46,86,13,55,29,71,56,33,44,95,32,16,99,19,36 +92,61,79,25,99,33,24,28,21,82,76,35,19,71,42 +95,56,25,71,21,51,99,92,29,35,98,58,24,55,61 +98,53,46,13,63,11,37,93,18 +53,57,76,78,18,39,37,19,55,13,17,86,95 +39,73,31,59,45,82,42,21,51,54,61,92,99,29,56 +48,75,39,73,59,93,25,51,54,61,58 +51,53,21,39,84,57,31,35,25,59,93,85,78 +56,76,55,54,28,49,36,37,71,24,99,32,33,95,58,46,13,35,44 +95,28,55,76,46,49,13,16,57,63,85,11,18,48,17,78,53,75,39 +16,56,63,36,49,11,37,86,57,19,28,95,55,18,48 +73,31,59,93,98,45,25,21,84,35,54,61,92,71,58,99,33,29,79,56,32 +44,73,18,55,63,16,48,49,36,78,76,31,13 +75,73,31,59,93,45,82,42,25,21,84,51,35,54,92,71,58,99,33,29,79 +33,29,35,32,99,56,49,84,36,46,51,95,58,76,19,54,71,61,55 +11,31,85,78,73,59,42,84,35,53,21 +78,76,86,57,95,85,55,63,24,46,53,19,44,17,37,49,28,36,16,13,11 +29,33,45,76,61,82,24 +25,18,86,21,82,75,31,98,44,63,73,85,39,17,78,53,59,42,93,11,45,48,16 +79,75,59,21,71,93,29,33,82,54,92,35,99,51,31,73,98,39,45,25,42,84,58 +63,99,85,44,36,95,58,49,57 +99,29,79,56,32,24,28,55,76,46,49,37,36,44,86,57,63,85,11 +13,44,16,86,57,63,85,11,18,48,17,78,53,75,39,73,31,59,93,98,45,82,42 +32,95,58,33,79,21,35,93,42,71,28,61,84,29,24,25,98,99,56,54,92 +44,57,98,75,18,17,31,16,93,13,73,63,37,49,46 +85,17,78,53,75,73,59,93,98,45,82,25,21,35,54 +92,71,51,56,84,42,79,46,55,19,21 +54,29,36,61,56,79,33,44,71 +86,11,48,17,53,75,31,93,25,21,84 +95,28,76,49,44,86,57,85,18 +11,18,48,17,78,53,75,39,73,59,93,98,45,82,42,25,21,84,51,35,54,61,92 +19,29,55,28,58,33,44,37,79,16,95,49,85,13,36 +76,19,49,37,36,57,85,11,18,17,78,53,75,39,73 +76,37,57,85,17,39,59 +76,19,36,13,16,86,57,63,85,11,18,48,17,73,59 +16,86,57,63,85,11,48,17,78,53,39,73,59,98,45,82,42,21,84 +75,73,98,82,42,21,51,35,61,71,99,29,79 +85,86,13,11,44,28,99,49,57,56,76,37,55,95,63 +61,84,21,29,33,39,92,71,51,73,98,31,35,54,99,25,58,59,42,75,93,82,53 +19,46,49,37,36,13,16,86,57,63,85,11,78,53,75,39,73,31,59 +82,25,21,84,51,35,61,92,71,99,29,32,24,95,19 +61,92,71,58,99,33,29,79,56,32,24,95,28,55,19,46,49,13,44,16,86 +49,79,76,36,33,32,13,57,55,46,44,85,29,28,86,24,16 +98,45,82,42,21,84,51,35,54,61,92,71,58,99,33,29,32,24,95,28,55 +24,95,28,55,76,46,49,36,13,44,16,63,18,48,17,78,75 +79,24,76,19,37,36,57,48,17 +11,18,48,17,78,53,75,39,73,31,59,93,98,45,82,42,21,84,51,35,54,61,92 +36,13,44,16,86,57,63,85,11,48,17,78,53,75,39,73,31,59,93,98,45,82,42 +48,25,78,98,86 +85,18,53,73,31,82,84 +42,82,18,73,93,45,36 +37,36,13,44,16,86,57,63,85,18,17,78,53,75,39,73,31,59,93,98,82 +78,53,39,59,82,42,25,21,84,51,61,92,71,58,99 +45,82,42,25,21,84,51,35,54,92,71,58,99,33,29,79,56,32,24,95,28,55,76 +73,21,17,45,42,93,44,39,98,82,48,11,75,85,16,63,18,57,78,53,25 +84,92,71,99,32 +59,98,45,82,25,21,84,35,54,92,71,58,99,33,79,56,32,24,95 +32,19,54,44,36,95,28,99,61,16,46,37,49,79,71 +55,71,57,92,33,95,79 +61,42,85,25,39,53,73 +57,33,16,24,11,29,56,63,32,95,46,37,44,99,49 +84,51,92,55,32,82,25,28,21,24,54,33,29,56,95,58,42,35,79,19,71 +53,16,75,63,37,18,17,13,31,57,49 +85,36,17,49,37,28,73,39,11,78,18,75,19,55,48,63,76 +53,86,63,55,37,28,18,76,13,78,46,95,44,32,85 +57,63,18,48,17,75,39,73,31,59,98,45,82,42,25,21,84,51,35 +33,21,29,73,92,99,51,75,54,53,39 +63,48,78,98,86,73,31,57,11,82,42,21,53,84,93,85,16 +63,11,18,48,17,78,53,75,39,31,93,98,45,82,25,84,51,35,54 +61,71,99,33,29,95,86 +31,82,35,56,24,21,71,54,29 +31,98,21,84,92,29,32 +46,49,37,13,44,16,86,57,85,11,48,17,78,53,31,93,98 +45,82,84,55,33,42,35,29,95,51,56,28,76,79,54,21,32 +99,33,29,79,32,95,76,19,46,37,13,86,63,85,11 +21,79,46,35,71,58,55,42,32,33,92,29,24,61,54,84,95,19,56 +46,49,37,36,13,44,16,86,57,63,85,11,18,48,78,39,73,31,59,93,98 +35,54,61,92,71,58,99,33,29,79,56,32,24,95,28,76,19,46,49,37,36,13,44 +32,24,95,55,19,49,37,13,44,16,86,57,63,18,48 +36,39,86,17,57,73,18,85,75,46,49,11,31,59,98,78,48 +13,63,11,18,78,53,39,73,93,98,45,82,25 +71,56,95,13,61,24,46,35,58,44,19,29,76 +56,32,24,95,28,55,76,19,46,49,37,36,13,44,16,57,63,85,11,18,48,17,78 +32,19,18,17,86,46,79,37,28 +71,58,99,33,29,95,28,55,46,36,13,16,63 +29,95,76,32,25,21,71 +24,79,71,46,84,55,95,28,99 +46,37,36,86,44,29,33,79,28,32,18,85,49,55,57 +21,84,51,35,54,61,92,33,29,79,32,24,95,76,19,46,37 +16,61,19,56,33,54,92 +29,33,21,54,42,76,71,79,45,32,28,51,55,92,84 +33,37,28,29,46,63,13,49,86,79,56,24,55,44,18,57,32,16,76,85,19,95,36 +35,71,32,61,99,29,58 +28,49,92,13,95,61,51,46,19,36,33,32,58,76,55,24,35,56,79 +82,93,86,44,75,39,17,73,53,21,78,25,48 +93,61,79,21,84,71,56,25,35,42,54,92,29,45,95,33,24,59,32,51,58 +45,86,75,25,93,44,98,63,31,85,82 +51,35,54,71,99,33,95,28,76,19,49 +24,86,16,19,85,11,95,46,49,79,18,36,37,17,56,63,13,76,28,55,44 +49,37,86,76,33,95,79,44,13,99,46,28,85,58,16,32,24 +37,13,16,17,86,63,46,18,79,56,32 +36,99,19,44,76,29,24,57,92,58,55,46,86 +76,49,37,13,44,16,86,57,63,85,11,18,48,17,78,75,73,31,59 +53,75,39,31,93,51,35,61,71,58,99,33,29 +56,24,19,37,86,57,63,11,18 +17,44,86,55,36 +58,99,33,29,79,56,32,24,95,28,55,76,19,46,37,36,57,63,85 +53,11,95,17,28,32,85,36,37,18,24,13,19,57,49,63,46,78,86,55,76 +28,76,19,46,37,36,13,44,16,86,63,85,11,18,48,78,53,39,73 +95,19,32,79,99,35,71,61,49,29,37,58,36,28,56,24,55,51,54 +33,82,61,29,56,42,54,84,79,35,58 +28,13,55,24,57,63,44,29,48 +28,55,76,19,46,49,37,36,44,86,57,63,85,11,48,17,78,53,73 +46,49,37,36,13,16,57,63,85,11,18,48,78,53,73,31,59,93,98 +31,16,18,55,85,37,46,73,63 +45,84,16,57,78,11,48,73,98,63,17,93,85 +56,32,95,19,49,37,13,86,57,63,11,48,78 +59,93,98,45,82,42,25,84,61,92,99,29,95 +49,18,33,57,13,46,16,85,55,11,36,76,28,24,95,29,44,32,86 +18,48,17,53,39,73,31,98,45,82,25,51,71 +28,55,76,19,46,37,36,44,16,57,63,85,11,18,48,17,75,39,73 +31,82,42,25,21,84,54,99,33,56,24 +36,13,63,85,18,39,31,82,42 +95,49,85,19,46,55,57,36,18,79,17,56,44,86,32 +98,28,32,99,71,79,24,35,61,95,55,21,84 +75,92,98,17,51,59,45,21,93,54,78,18,31,71,53,25,39,42,35,61,82,73,84 +44,17,46,85,63,39,53,37,18,78,95,48,75,76,55,16,49 +24,19,49,36,44,16,86,57,11,48,78,53,75 +95,71,19,84,99,46,29,21,54,37,79,76,61,35,51 +36,11,78,48,73,53,93,59,17,75,16,49,63,19,37,57,39 +18,25,11,42,31,57,98,21,82,63,35,53,85,39,93,48,51,45,84,73,17,78,75 +45,21,35,98,99,95,58,92,42,61,56,71,24,82,59,93,32 +39,73,93,45,82,42,25,84,51,35,61,79,56 +85,86,19,36,55,78,39,53,31,46,18 +28,54,61,58,16,37,13,44,29,49,46 +11,18,17,78,39,73,31,59,98,45,25,84,35,54,92 +93,98,45,21,54,61,92,71,58,99,32,24,95 +98,21,55,82,29,56,42,33,51,84,32,54,61,79,28,24,95,58,35,25,71,45,92 +36,13,57,63,85,11,18,48,17,78,53,75,39,73,31,59,93,98,45,82,42 +54,28,21,24,42,19,82,25,33,32,95,71,35 +55,32,58,49,51,29,56,54,76,21,33,19,35,99,28,95,46 +51,35,54,61,92,71,58,99,33,79,56,24,95,28,55,19,46,49,37,36,13 +39,85,73,45,51,21,86 +61,79,92,54,76,36,46,44,49,13,99,95,58,71,55,29,32 +45,82,42,61,32,95,76 +48,53,75,39,31,93,45,42,25,21,84,51,54,61,58 +78,31,25,21,84,92,33 +61,56,98,33,29,59,32,54,93,51,35,25,73,79,99 +63,19,86,46,33,18,11 +58,42,56,84,61,46,35 +49,95,76,37,78,46,86,85,19,48,56,57,11,36,32 +24,21,51,29,45,79,71,28,32,56,35,95,98,33,42,84,58 +16,86,57,63,11,18,48,78,39,59,98,82,42,21,84 +35,54,61,71,33,29,32,24,28,19,46,49,37,36,13 +85,11,18,75,39,59,42,84,51,35,61 +78,33,98,75,42,21,58,45,73,93,92,31,35,99,61 +39,78,98,42,35,63,93,84,17 +71,76,92,55,79,84,24,51,58,49,35,99,36,28,37 +19,46,37,36,13,44,16,86,57,63,85,18,48,17,53,75,39,31,93 +28,54,21,35,25,76,55,95,49,79,92,32,33,99,71,29,51 +99,33,56,32,95,28,55,19,37,85,11 +95,46,16,85,37,28,11,13,32,63,24,17,36,19,78,56,86,44,18 +85,18,48,78,75,73,59,98,82,42,25,21,84,35,61 +29,79,56,32,24,95,28,55,76,19,49,37,36,13,16,86,57,63,85,18,48 +36,49,16,99,54,95,32 +93,58,51,56,31,92,35,61,25,82,42,45,32 +37,16,86,85,11,78,53,39,73,31,59,98,82 diff --git a/2024/Day06CSharp/Day06CSharp.csproj b/2024/Day06CSharp/Day06CSharp.csproj new file mode 100644 index 0000000..c9cae6e --- /dev/null +++ b/2024/Day06CSharp/Day06CSharp.csproj @@ -0,0 +1,14 @@ + + + + Exe + net9.0 + enable + enable + + + + + + + diff --git a/2024/Day06CSharp/Program.cs b/2024/Day06CSharp/Program.cs new file mode 100644 index 0000000..81bfa16 --- /dev/null +++ b/2024/Day06CSharp/Program.cs @@ -0,0 +1,334 @@ +using System.Runtime.InteropServices; +using System.Text.Json; +using System.Text.Json.Serialization; + +var exParsed = new Day06Parsed("example-input.txt"); + +Console.WriteLine("Example Part01: {0}", exParsed.GetPart01()); +Console.WriteLine("Example Part02: {0}", exParsed.GetPart02()); + +var pzParsed = new Day06Parsed("puzzle-input.txt"); + +Console.WriteLine("Puzzle Part01: {0}", pzParsed.GetPart01()); +Console.WriteLine("Puzzle Part02: {0}", pzParsed.GetPart02()); + +class Day06Parsed : AdventCommon.ParsedInput +{ + public enum Direction + { + UP, + DOWN, + LEFT, + RIGHT + } + + public enum BLOCK_STATE + { + UNTOUCHED, + OBSTACLE, + VISITED + } + + public class GridSquare + { + public GridSquare(BLOCK_STATE state) + { + State = state; + } + + public BLOCK_STATE State { get; set; } = BLOCK_STATE.UNTOUCHED; + + public bool hasVisited() { return State == BLOCK_STATE.VISITED; } + + public bool VisitedFacingUp { get; set; } = false; + public bool VisitedFacingDown { get; set; } = false; + public bool VisitedFacingLeft { get; set; } = false; + public bool VisitedFacingRight { get; set; } = false; + + public GridSquare Clone() + { + return (GridSquare)MemberwiseClone(); + } + } + + public class Guard + { + public Guard() { } + public Guard(Guard other) + { + CurrentDirection = other.CurrentDirection; + X = other.X; + Y = other.Y; + IsGone = other.IsGone; + } + + public Direction CurrentDirection { get; set; } + public int X { get; set; } + public int Y { get; set; } + public bool IsGone { get; set; } = false; + + public Guard Clone() + { + return (Guard)MemberwiseClone(); + } + } + + public class Level + { + public List> Grid { get; set; } = new List>(); + public Guard SecurityGuard { get; set; } = new Guard(); + + public int CountVisited() => Grid.SelectMany(x => x).Count(x => x.State == BLOCK_STATE.VISITED); + + public bool GuardIsAround() + { + return SecurityGuard.X >= 0 && SecurityGuard.Y >= 0; + } + + public enum SIMULATION_RESULT + { + CONTINUE, + DONE, + LOOP + } + + public SIMULATION_RESULT SimStep() + { + if (SecurityGuard.IsGone) return SIMULATION_RESULT.DONE; + + try + { + int newY = SecurityGuard.Y, newX = SecurityGuard.X; + + switch (SecurityGuard.CurrentDirection) + { + case Direction.UP: + newY = SecurityGuard.Y-1; + break; + case Direction.DOWN: + newY = SecurityGuard.Y+1; + break; + case Direction.LEFT: + newX = SecurityGuard.X-1; + break; + case Direction.RIGHT: + newX = SecurityGuard.X+1; + break; + } + + if (Grid[newY][newX].State == BLOCK_STATE.OBSTACLE) + { + switch (SecurityGuard.CurrentDirection) + { + case Direction.UP: + SecurityGuard.CurrentDirection = Direction.RIGHT; + break; + case Direction.DOWN: + SecurityGuard.CurrentDirection = Direction.LEFT; + break; + case Direction.LEFT: + SecurityGuard.CurrentDirection = Direction.UP; + break; + case Direction.RIGHT: + SecurityGuard.CurrentDirection = Direction.DOWN; + break; + } + } + else + { + if (Grid[newY][newX].State == BLOCK_STATE.VISITED) + { + // We've already visited this block, check if we're looping + bool hasLooped = false; + + switch (SecurityGuard.CurrentDirection) + { + case Direction.UP: + if (Grid[newY][newX].VisitedFacingUp) hasLooped = true; + break; + case Direction.DOWN: + if (Grid[newY][newX].VisitedFacingDown) hasLooped = true; + break; + case Direction.LEFT: + if (Grid[newY][newX].VisitedFacingLeft) hasLooped = true; + break; + case Direction.RIGHT: + if (Grid[newY][newX].VisitedFacingRight) hasLooped = true; + break; + default: + throw new Exception("Unknown direction"); + } + + if (hasLooped) return SIMULATION_RESULT.LOOP; + } + + SecurityGuard.X = newX; + SecurityGuard.Y = newY; + + Grid[newY][newX].State = BLOCK_STATE.VISITED; + switch (SecurityGuard.CurrentDirection) + { + case Direction.UP: + Grid[newY][newX].VisitedFacingUp = true; + break; + case Direction.DOWN: + Grid[newY][newX].VisitedFacingDown = true; + break; + case Direction.LEFT: + Grid[newY][newX].VisitedFacingLeft = true; + break; + case Direction.RIGHT: + Grid[newY][newX].VisitedFacingRight = true; + break; + } + } + } + catch (Exception) + { + // Guard left the area + SecurityGuard.IsGone = true; + return SIMULATION_RESULT.DONE; + } + + return SIMULATION_RESULT.CONTINUE; + } + + public SIMULATION_RESULT SimulateAll() + { + SIMULATION_RESULT result; + + for (result = SIMULATION_RESULT.CONTINUE; result == SIMULATION_RESULT.CONTINUE; result = SimStep()); + + return result; + } + + public Level Clone() + { + bool useJson = false; + + if (!useJson) + { + Level other = new Level(); + + // Copy the grid + foreach (var row in this.Grid) + { + List newRow = new List(); + foreach (var s in row) + { + newRow.Add(s.Clone()); + } + other.Grid.Add(newRow); + } + + // Copy the guard + other.SecurityGuard = SecurityGuard.Clone(); + + return other; + } + else + { + var jsonString = JsonSerializer.Serialize(this); + var copy = JsonSerializer.Deserialize(jsonString); + if (copy == null) throw new Exception("Failed to clone"); + return copy; + } + } + + public GridSquare GetGridSquare(int x, int y) => Grid[y][x]; + } + + Level CurrentLevel { get; set; } = new Level(); + + public Day06Parsed(string fileName) : base(fileName) + { + } + + public override int GetPart01() + { + var level = CurrentLevel.Clone(); + level.SimulateAll(); + return level.CountVisited(); + } + + public override int GetPart02() + { + // First simulate everything as a base + var simulatedOriginalLevel = CurrentLevel.Clone(); + simulatedOriginalLevel.SimulateAll(); + + int loops = 0; + + // Iterate across the level and find loops + List<(int,int)> visited = new List<(int,int)>(); + + for (int y = 0; y < simulatedOriginalLevel.Grid.Count; y++) + { + for (int x = 0; x < simulatedOriginalLevel.Grid[y].Count; x++) + { + if (simulatedOriginalLevel.Grid[y][x].State == BLOCK_STATE.VISITED) + { + visited.Add((x, y)); + } + } + } + + // Run simulations in parallel because we can + Parallel.ForEach(visited, coords => + { + int x = coords.Item1; + int y = coords.Item2; + //var loopTest = coords.Item3; + + var loopTest = CurrentLevel.Clone(); + loopTest.GetGridSquare(x, y).State = BLOCK_STATE.OBSTACLE; + var result = loopTest.SimulateAll(); + if (result == Level.SIMULATION_RESULT.LOOP) loops++; + }); + + return loops; + } + + public override bool ParseLine(string line, object? context = null) + { + List list = new List(); + + int index = 0; + foreach (char c in line) + { + switch (c) + { + case '.': + list.Add(new GridSquare(BLOCK_STATE.UNTOUCHED)); + break; + case '#': + list.Add(new GridSquare(BLOCK_STATE.OBSTACLE)); + break; + case '^': + var gridSquare = new GridSquare(BLOCK_STATE.VISITED); + + int guardY = CurrentLevel.Grid.Count; + int guardX = index; + + CurrentLevel.SecurityGuard.CurrentDirection = Direction.UP; + CurrentLevel.SecurityGuard.X = guardX; + CurrentLevel.SecurityGuard.Y = guardY; + + gridSquare.VisitedFacingUp = true; + + list.Add(gridSquare); + + break; + + default: + throw new Exception("Unknown character"); + } + + index++; + } + + CurrentLevel.Grid.Add(list); + + return true; + } +} diff --git a/2024/Day06CSharp/Properties/launchSettings.json b/2024/Day06CSharp/Properties/launchSettings.json new file mode 100644 index 0000000..2f56d40 --- /dev/null +++ b/2024/Day06CSharp/Properties/launchSettings.json @@ -0,0 +1,8 @@ +{ + "profiles": { + "Day06CSharp": { + "commandName": "Project", + "workingDirectory": "C:\\dev\\dev-drive\\DevSandbox\\AdventOfCode\\2024\\Day06CSharp" + } + } +} \ No newline at end of file diff --git a/2024/Day06CSharp/example-input.txt b/2024/Day06CSharp/example-input.txt new file mode 100644 index 0000000..f76349a --- /dev/null +++ b/2024/Day06CSharp/example-input.txt @@ -0,0 +1,10 @@ +....#..... +.........# +.......... +..#....... +.......#.. +.......... +.#..^..... +........#. +#......... +......#... \ No newline at end of file diff --git a/2024/Day06CSharp/puzzle-input.txt b/2024/Day06CSharp/puzzle-input.txt new file mode 100644 index 0000000..4cafbbb --- /dev/null +++ b/2024/Day06CSharp/puzzle-input.txt @@ -0,0 +1,130 @@ +........................#........#................#.............#..#....#.#.#.........#........##..................#..#........... +.#........#......##........#.................................................#.#.........#......#................................. +...........#.#.##.#.........#.#..#............#.....................................................#.............#............... +..........#...............#......#...............#.#..............................#..........#........#..#...##.........#..#...... +..........................................................#...........................................#........................... +................#.....#.............#...........................................................#.....#..........#...#...##....... +.....................#......#....................#..................#.....................#................................#...... +......#........#.........#.....................................#......................#...........#................#.......#...... +.........#.......#...#..................##.#...#...........#.......#............#...#....#...........#................#........... +..........................................#..........................#........#.....##............#.........................#..... +..........#...................##.......#.............#....##..............#.........#..............#........#..........#....#..... +.#....##........#.....................................#...#.............................#..............#.....#.................... +....#..#................................................#.......#..........#.....#.....#.......................................... +.............##...............#..........#...............................................#............#..............#..##....#... +......#...............#...............#.........................................................................#.#..............# +......#........................................................................................#.......#.....#................#... +.......#..#...#.............................#......#.....#........................................#.........................#..##. +.................................#..................#.......#......#...................#...................#.......#............#. +......#....................#.........................#........................................................#...#.......#..#..#. +..##....#...............................#.................#....#........#......#..........#....#........#..................#...... +..................#..........#................................#.........#...........#..#......#.....................#............. +##.................................................#..............#....#...............#.......................................... +....#..............#.............#..........................................................................#................#.... +..................................................#...#..#.......#................................................#...........#... +.....#.......#...............................................................#......#.....#......................................# +....#....................##....................#............#................................#..#....#....#..........#............ +.#.........................#.....................#..........................##............................................#....... +.......................#.........................................#................................................................ +...............#........................................................................#..........#.............................# +.#..............................#..#....................#........................#......#.#......#.......#....................#..# +..........................#........#.........#.........#...#..#................#........#.........................#............... +..#.................................#.........#......................#............................................................ +...........................#..............................................#.................#...............#..................... +..........#..................#.............................................#.......................#.............................. +....................#............##..........................#...............#..........#.......................................#. +....................#....#.....................................................................#.................................# +....#.......#...................#....#.#....#..................................#.#....#..#.............................#.....##... +.............#.#...................................................................#........#..............................#...... +.......................#.....................#.......#.........................................#..........#....................... +...............#..............#..................................#.............#.................................................. +......................................................................................#........#......................#.....#..... +.........#.....................................................#................#..........................#........###........... +...................#..##...............#......................#................................................................... +.............#........................................#..................................#.#.#.................................... +......#............#.........................#..........#..#.................................................................##... +............#...............#..................................#...........#...............................#...........#.......... +................#.......#.......................#................#.............#................................#................. +.........................#.#.........#..#.....#.....................................#................................#............ +..#...............#..#..........................#.#.....#....................#.................................................... +................................................................................#..........#..............#....................... +............#.#......#......#........#..................#...#..................................................................... +....#......................#........................#..................#......#.....#............................................. +.#..................#...........................#..........#..........................................#....#...................... +...............#......................#.......#.....#...#.................#...............................................#....... +#...#.......#..............................................................................................#...........#......#... +........................#......................#..........#...............................##......#...........................#... +....................#....#..............#.....#.....#................#............................................................ +................#........................................................................................#........................ +...##................#.............#.............................................................................................. +.#....#........................................................................................................................##. +..#...................................#......#.#......#...................#........#.............................#....##.......... +.......................................................#..#....#..#.................................................#............. +............#..................#......#.....#...........................................................#..#........#............# +..#................................#....................................................................#.............#......#.... +..#..........#........#..............................................................................................#............ +.....#.....................#..............#.................................#................................#...#................ +........................#........#..................................................................................#............. +...#...........#.............................................#....................#....#..........#............................... +...................#...........#...................................................................#...........#.................. +...........#............................#......................................................................................##. +#..............#.#.......................................#.......................#.....#...........#.......#...........#.##....... +..............................................................##.........................................#.............#.........# +...........................#.#..................................................#..................#..#........................... +.....................................#...............#.....#...................................#.................................. +..#...................#.#....#...#......................................................#.#..................................#.... +..........................................#......................................................................#................ +.............#...................................................................#...#....#........#...................#.......... +.......................#.......................................##...........#......#......#..............................#........ +.......#..............#..............#..............................................................#............................# +...........................................#...#.......#......#...............................#.........#......................... +.......#...................................................#........................^..#.......................................... +.#..........................................................................................#.......#.#..#........................ +............................##........................................................................#..#........................ +..........#.#..#....#.##........................#................................................................................. +......#.#...................................#...#...................#.............#.....#......................................... +.................#........................................................................................#..#.#.................. +#....................#.......................................#..#..#.....#..............#......................................#.. +..............#.#............................................................#.....#......................................#......# +....................#.......#.............................#..............#.........................................##............. +.....#................................#.#...........#...........#.......................................#...#....#................ +...............#...#......................#............................#..................................#....................... +....#........##...............................................................#......#...#.........#.....#..................#..... +...............................#......................................................................#........................... +............................#.............................#........##...............#................#....#...#..............#.... +.......................#................#.......#........................................................................#........ +..................................................................................#......................#.......#.#.............. +........#.........................#........#.........................#.......................#......................#......#...... +.........................#..#...........#..#.......................#.#.................#.......................................... +......#.................#......................................................................#........................#......... +......................................##..........#...........................#........#...........#.............................. +.......................................#...........................#.........#....#................#...............#.............. +...........#...........#.........................#.......#.................#....#.#...........#..................#.##...........#. +...#..................#..#...............#..#...................................#.......#................#...................#.... +...............#............#.......#.............#............#......###.............#.............................#..........#.. +.......................................#...........................................#........#...........#......................... +................#...........#.....#..#...........##..................##..........#....#.....#...#........#........................ +...............................##.............................................................#..........#...#....#............... +............#.................#...##.........#.......................................................................#............ +...........#.#............................#...............##...........................................#............#....#........ +...............................................#...........................................#..........#......................#.... +......................................#........................................#.....................##...........#.....#..#.#.... +..............................#.......#...#.#...............................................................................##.... +................##......#..#.......#...........#............#.#......#..#................#..#.....#..................##........... +#.....#...........................#....................#.........................................................................# +............#.............#........#........#.#...............#...........................#.........#.............#......#........ +#...#.........#.....#...................................................#......................................................... +.....................#...........#....................#.....#............##..........#....#..........#......#..........#.......... +...................................#.........#.....#.................................#..........................................#. +......................................................#.........#................................................................. +...............#..............#........................................................................##.......#.............##.. +...............#.......#.........#.........................#.......................##............................................. +..................#....................................#......................................................##...#....#.......#. +..#........#.....#...............#...............................#.........................#.#........#....#...................... +..#.............#.......##...#......#....................................................................................#........ +............................#.......#...........#.............#.............#..........................#.......................... +.............#........................#........................................................#.........#........................ +.#............#.....#...........................................#..#............................#..............#..........#....... +................#.....................................#..............................#............................................ +..................#........................................#.#.................................................................#.. +.#............#.......#..................................#....#.................................................#..............#.# diff --git a/2024/Day07CSharp/Day07CSharp.csproj b/2024/Day07CSharp/Day07CSharp.csproj new file mode 100644 index 0000000..c9cae6e --- /dev/null +++ b/2024/Day07CSharp/Day07CSharp.csproj @@ -0,0 +1,14 @@ + + + + Exe + net9.0 + enable + enable + + + + + + + diff --git a/2024/Day07CSharp/Program.cs b/2024/Day07CSharp/Program.cs new file mode 100644 index 0000000..ea77eca --- /dev/null +++ b/2024/Day07CSharp/Program.cs @@ -0,0 +1,98 @@ +// See https://aka.ms/new-console-template for more information +using System.Collections.Generic; +using System.Runtime.CompilerServices; + +var exParsed = new Day07Parsed("example-input.txt"); + +Console.WriteLine("Example Part01: {0}", exParsed.GetPart01()); +Console.WriteLine("Example Part02: {0}", exParsed.GetPart02()); + +var pzParsed = new Day07Parsed("puzzle-input.txt"); + +Console.WriteLine("Puzzle Part01: {0}", pzParsed.GetPart01()); +Console.WriteLine("Puzzle Part02: {0}", pzParsed.GetPart02()); + +class Day07Parsed : AdventCommon.ParsedInput +{ + class Equation + { + public long LeftHandSide { get; set; } + public List RightHandSide { get; set; } = new List(); + + public int MaxOpCount + { + get + { + return RightHandSide.Count - 1; + } + } + + List ValidOps { get; set; } = new List(); + + public bool IsValid() + { + for (int i = 0; i < (int)Math.Pow(2,MaxOpCount); i++) + { + long eqTotal = RightHandSide[0]; + + // a value of 0 for a given bit is +, 1 is * + for (int opIndex = 0; opIndex < MaxOpCount; opIndex++) + { + if ((i & (1 << opIndex)) == 0) + { + eqTotal += RightHandSide[opIndex + 1]; + } else + { + eqTotal *= RightHandSide[opIndex + 1]; + } + + if (eqTotal > LeftHandSide) + { + break; + } + } + + if (eqTotal == LeftHandSide) + { + ValidOps.Add(i); + return true; + } + } + return false; + } + + } + + public override int GetPart01() + { + int sum = 0; + foreach (var equation in Equations) + { + if (equation.IsValid()) + { + sum += equation.LeftHandSide; + } + } + return 0; + } + + List Equations { get; set; } = new List(); + + public Day07Parsed(string fileName) : base(fileName) { } + + public override bool ParseLine(string line, object? context = null) + { + Equation equation = new Equation(); + + equation.LeftHandSide = Int32.Parse(line.Split(':')[0].Trim()); + + foreach (var v in line.Split(':')[1].Split(' ', StringSplitOptions.RemoveEmptyEntries)) + { + equation.RightHandSide.Add(Int32.Parse(v)); + } + + Equations.Add(equation); + + return true; + } +} \ No newline at end of file diff --git a/2024/Day07CSharp/Properties/launchSettings.json b/2024/Day07CSharp/Properties/launchSettings.json new file mode 100644 index 0000000..90007fd --- /dev/null +++ b/2024/Day07CSharp/Properties/launchSettings.json @@ -0,0 +1,8 @@ +{ + "profiles": { + "Day07CSharp": { + "commandName": "Project", + "workingDirectory": "C:\\dev\\dev-drive\\DevSandbox\\AdventOfCode\\2024\\Day07CSharp" + } + } +} \ No newline at end of file diff --git a/2024/Day07CSharp/example-input.txt b/2024/Day07CSharp/example-input.txt new file mode 100644 index 0000000..7ece8aa --- /dev/null +++ b/2024/Day07CSharp/example-input.txt @@ -0,0 +1,9 @@ +190: 10 19 +3267: 81 40 27 +83: 17 5 +156: 15 6 +7290: 6 8 6 15 +161011: 16 10 13 +192: 17 8 14 +21037: 9 7 18 13 +292: 11 6 16 20 \ No newline at end of file diff --git a/2024/Day07CSharp/puzzle-input.txt b/2024/Day07CSharp/puzzle-input.txt new file mode 100644 index 0000000..14df039 --- /dev/null +++ b/2024/Day07CSharp/puzzle-input.txt @@ -0,0 +1,850 @@ +80453: 65 232 17 4 253 1 1 +11072880: 9 5 91 338 8 +251359026: 801 36 2 1 4 7 9 34 3 3 +5146105932: 3 4 73 2 105 4 1 8 6 4 8 +3217192: 32 99 49 156 33 +1240885: 980 2 568 2 2 4 85 +761411281: 8 13 16 4 1 79 76 3 6 5 8 +1773078: 300 75 788 6 78 +363734176: 5 10 32 928 2 7 177 1 1 +44388674: 64 8 9 82 4 49 75 +2405604276: 3 9 9 4 85 9 433 3 991 7 +693989: 693 333 1 30 628 +13925303275: 7 909 38 6 4 186 327 5 +63263200: 63 7 79 16 715 +8544146: 58 33 5 89 147 +869069580: 564 99 233 31 16 5 +14736199074: 5 997 63 9 3 819 4 46 +61182660: 3 3 2 95 77 697 +8680: 4 84 376 7 8 +1796382720: 934 9 62 9 6 6 64 5 1 2 8 +1158: 100 968 8 74 6 +309536: 4 64 569 4 2 +98070674452: 7 815 1 191 6 30 3 3 2 2 +765702: 6 3 85 70 3 +486500: 44 2 37 556 7 +857641310086: 653 1 1 4 9 41 8 7 5 4 8 8 +12655: 970 2 81 63 6 151 +11037: 5 8 5 49 9 657 1 1 567 +15426904: 6 9 156 2 7 5 74 14 86 3 +255584836: 82 317 56 3 2 5 5 981 1 +2795079846: 9 31 693 260 23 3 +59474651: 9 2 33 1 472 1 42 123 4 +31392: 5 3 8 7 4 22 7 326 709 8 +202335: 3 1 195 2 615 719 +10072161288612: 329 76 973 414 6 12 +304800: 62 8 12 8 75 1 +410694814: 7 74 2 9 9 7 8 4 602 6 22 +37200044757: 590 3 9 5 27 3 7 21 57 +1879341: 238 388 44 6 3 3 +1199889306: 52 8 4 1 9 8 11 8 316 18 +531918519: 9 4 48 1 504 1 8 7 189 8 +13077712: 653 88 52 2 6 +2861487998: 74 58 10 921 379 97 +7476829: 51 274 535 645 94 +162477: 2 799 4 64 9 97 +166412: 7 78 8 9 975 1 3 +451743: 3 4 624 7 6 9 578 7 1 1 2 +92311037059: 9 4 4 9 7 1 9 61 9 91 51 7 +67295279430: 2 82 3 1 4 67 7 99 6 2 9 +8793: 822 1 4 1 10 476 1 39 8 +3794488742: 949 7 425 5 84 8 211 2 +1579094: 2 97 2 5 72 54 2 563 3 +25871540: 4 14 7 871 539 +805: 3 777 23 4 +592118916732: 30 783 6 71 7 24 7 7 9 4 +995405888: 625 5 158 546 9 416 +6335512: 633 509 2 39 9 +24861: 322 77 65 +70077355183: 2 6 685 3 773 551 74 7 +7674310: 64 2 98 595 1 +53167296001: 50 4 50 60 510 10 52 8 +9921503: 21 79 9 91 2 4 3 3 2 9 8 5 +26477554: 7 214 1 9 557 943 2 +4451398: 8 5 2 9 355 9 179 3 6 4 2 +18133152: 3 185 8 87 96 +4075412211: 815 5 3 1 247 875 13 +149028: 749 27 32 6 6 +3932866: 9 25 971 5 9 3 6 6 8 8 12 +2115650020: 77 223 86 61 4 205 +31439100: 9 64 8 19 72 87 7 7 4 75 +16388: 3 27 8 74 87 +1418098: 1 4 47 5 7 7 6 5 6 85 +178644: 9 7 1 864 2 +350280828: 4 15 7 3 713 315 825 +307320304: 4 985 78 30 4 +2362320: 7 5 158 85 144 +142823: 307 9 134 32 1 44 +2721809: 30 907 6 48 8 69 84 +3950727505: 2 20 5 3 13 7 9 5 43 7 5 2 +131968643: 2 9 2 1 4 1 1 903 730 8 2 +2757417345: 851 193 93 4 64 71 1 +572376238: 7 647 87 814 74 +11313873117: 3 36 68 3 7 6 5 786 478 +445454: 25 3 2 88 11 8 50 7 +241: 17 1 8 3 3 7 +265704964: 7 54 2 5 7 1 8 29 2 6 1 4 +25524498: 8 573 348 8 2 14 764 8 +41898086205: 20 94 1 872 31 824 +30006791: 28 6 4 4 5 3 6 8 864 7 2 1 +161840: 44 4 48 8 7 3 +529760419: 9 3 6 8 85 8 1 22 1 208 2 +10827556512: 500 581 1 4 3 5 5 6 515 +278813227280163: 9 968 913 352 50 5 4 8 +107410: 1 4 5 74 11 +111966: 6 703 59 85 391 9 7 +1820799016210: 1 43 9 58 9 9 5 1 1 62 10 +34086: 51 2 6 1 46 2 90 9 409 +658814461: 4 82 68 6 76 8 5 2 784 +6248684908090: 762 965 19 3 7 49 2 39 +49325079: 39 87 367 227 23 73 9 +128180486: 419 8 956 4 6 +12146408: 482 70 3 6 4 2 +46151352: 4 7 1 6 5 5 17 8 8 5 5 950 +268237: 6 51 4 78 37 +75087: 7 149 7 1 213 7 71 469 +2030410: 57 9 10 7 4 554 +8190500163: 21 7 12 9 946 538 7 +4627959995970: 66 7 1 7 959 995 9 73 +472457: 471 180 941 304 33 +2843491: 9 2 1 5 2 59 990 71 9 +1662060690: 281 528 94 83 2 59 8 3 +71528448486: 4 51 6 758 44 2 8 73 5 +159099841: 7 231 81 1 22 +12663773526: 4 2 2 11 6 3 6 47 5 22 2 +927300212: 9 4 4 90 781 2 2 85 388 +6782849: 4 6 5 3 68 8 8 598 1 8 8 +299601: 287 1 83 2 62 355 5 4 2 +51682789: 4 9 44 68 9 9 6 579 5 86 +153393346: 22 66 7 45 9 427 +102623: 89 3 8 48 7 82 6 +27139448: 79 6 3 8 1 681 7 9 8 2 9 +44209555513: 44 209 55 49 6 13 +19102: 9 970 1 1 19 6 96 9 390 +90534: 8 5 830 104 54 +25134318083801: 364 9 984 869 7 803 +84393891730: 7 85 7 405 403 91 3 55 +790: 1 19 5 63 5 +12009921: 3 50 8 9 921 +9781206: 4 473 8 858 6 3 +5218166016: 5 51 5 4 558 2 7 8 6 7 7 +14119: 3 2 435 32 7 +219619443: 586 9 359 114 38 4 9 3 +494506865160: 8 3 4 12 84 7 2 7 8 603 5 +25643796039: 18 694 3 4 5 5 5 2 67 9 7 +6715112: 9 2 8 201 29 1 4 2 4 1 99 +4608: 4 433 1 2 1 1 2 40 5 18 +991684: 5 3 9 77 27 +369627102: 461 342 691 88 8 +12453: 67 2 1 45 9 1 51 +41985868: 4 457 208 9 867 +230112045: 2 14 340 940 5 9 37 8 +1558443235357: 25 4 5 740 3 2 3 9 22 6 6 +7658313312: 2 463 1 31 4 557 897 4 +21551778: 536 7 441 7 9 1 41 +350465040: 2 1 740 2 800 6 4 4 37 4 +99964808: 9 4 534 52 10 +5550930: 52 7 37 238 1 405 +22715297428: 8 739 7 14 782 8 217 +384007419: 320 120 7 41 8 +25916002: 16 42 9 80 550 +80805925: 5 676 2 6 733 4 4 6 +136800: 227 1 5 15 8 +2656155: 9 6 74 53 8 82 9 +16286: 1 7 7 676 61 +1139100: 92 2 146 83 7 +623772543: 529 89 6 51 725 40 +1142: 14 42 23 42 405 84 +50415: 50 841 7 14 30 4 7 +301413: 42 9 6 99 900 92 849 +848103923: 6 14 810 392 4 +53940: 51 54 741 24 62 +144491721762: 1 2 994 46 8 6 3 33 19 7 +45386287: 784 29 437 39 931 37 +10108943: 130 877 3 894 4 +21658: 9 1 5 7 55 47 4 4 82 4 1 2 +759325513853792: 83 95 963 138 5 37 93 +722643: 289 8 4 24 92 153 +399639247996: 3 370 109 36 79 95 +3051058: 40 2 280 11 38 +1202: 4 962 233 1 2 +4727573267: 6 69 9 367 57 1 1 4 70 1 +52677907: 49 461 313 10 33 7 +10050892265: 5 86 35 915 8 922 66 +2987: 34 79 78 217 6 +583746: 583 7 46 +9646: 36 7 38 1 69 +2807723736: 46 137 41 495 9 9 +18826860280: 8 8 547 76 3 1 8 8 1 44 8 +971981682: 97 1 9 453 363 82 +5977403: 8 51 1 77 393 7 +14303180: 528 901 4 9 178 +36134415: 6 4 20 7 7 2 931 463 9 +35109: 38 634 30 50 9 +12606003: 4 4 5 75 764 +17683203483: 5 3 6 73 323 95 4 1 255 +355577: 901 7 795 9 5 8 16 +654126: 7 7 1 6 89 5 8 5 1 5 6 96 +762858: 7 636 3 754 9 152 1 6 +4466521: 67 7 4 6 77 4 57 1 +40257693486: 349 1 2 9 10 8 71 37 4 9 +26709004: 3 4 151 981 84 98 2 +32746679: 71 79 6 648 9 +39625: 1 4 748 52 469 +9709: 97 248 9 617 1 +144459502: 1 164 42 4 23 651 2 +235672: 360 61 128 82 31 4 89 +514215: 8 61 110 30 41 5 4 25 3 +626870234975: 9 3 5 6 25 2 67 14 497 4 +343752250: 902 74 103 1 50 +867: 2 8 2 41 2 45 +229252821: 9 6 339 6 49 919 +335358: 353 95 8 +1260845177: 3 93 45 1 533 515 2 2 5 +35513409: 5 8 74 558 2 31 367 +4811913: 473 7 6 2 2 5 3 45 38 73 +1593555586: 9 122 2 54 2 7 1 1 5 5 8 8 +386835: 187 5 4 6 8 934 205 +6294685256: 9 62 4 113 9 6 7 4 662 +2094621: 9 9 5 826 127 8 6 7 1 6 +223546540: 3 7 5 3 87 6 5 571 28 8 5 +3562: 306 1 501 +3251820: 6 34 5 3 639 6 6 102 9 4 +47425: 4 3 8 80 5 7 8 5 8 1 58 6 +17359545: 577 1 15 3 21 131 1 2 3 +44797453: 57 44 8 44 5 1 4 51 +1167206: 35 6 5 116 427 779 +44153: 6 8 19 659 +661320: 5 5 6 6 5 402 7 6 3 167 +459856: 535 24 1 8 82 +1093763483: 4 2 64 11 7 6 7 685 9 8 +587890: 58 1 1 6 46 1 9 1 79 5 3 +3152812902: 38 9 1 72 4 6 8 4 3 5 70 +991368: 991 3 5 8 7 +26501810: 1 24 356 287 9 27 230 +831526448802: 203 30 72 409 800 +107361118: 3 7 18 93 9 9 509 802 +903435238: 991 2 214 6 355 +2494172365978: 5 42 4 958 42 8 7 29 6 4 +66960781: 9 63 930 7 80 +2954430774: 29 9 62 85 9 723 50 2 +1843044: 1 5 3 959 4 8 17 7 5 7 7 6 +1515944541939: 639 77 237 861 13 6 +15580038: 2 7 69 16 6 24 7 390 +557225206481: 85 72 69 65 27 8 6 478 +663960349137: 4 36 37 6 404 767 111 +446472: 9 9 8 689 1 +55448739: 553 7 7 840 34 1 10 +139151273: 8 6 1 608 2 2 3 8 1 1 27 2 +8745053673: 5 10 83 9 29 6 634 9 3 6 +567594: 4 8 2 3 472 5 7 52 94 4 2 +1563994: 6 4 5 401 78 89 5 +113165: 537 7 6 2 2 1 546 5 +3191: 237 1 745 1 78 +2692218: 10 964 691 4 9 73 +1339821860: 670 33 619 9 9 40 589 +496620: 5 4 2 2 154 587 888 36 +1414877058462: 360 9 3 8 4 1 98 459 2 +1491097042: 1 710 21 1 8 6 945 99 +445501530: 4 45 5 90 142 8 5 25 +647931: 17 90 7 113 7 42 1 +1215: 4 7 1 93 3 +31518901471558: 8 41 851 9 52 3 944 1 8 +1797: 1 5 9 69 8 9 991 8 650 8 +9543: 89 41 43 9 547 +132436687408: 55 3 5 4 583 2 925 8 8 3 +13224041600: 1 4 748 902 784 5 1 1 +33761367370: 722 868 481 2 8 56 6 4 +427416: 46 23 172 36 63 105 +32747264: 13 4 7 1 2 8 4 6 4 8 8 29 +2839: 458 6 7 3 81 +3430168: 921 4 3 66 7 9 4 9 7 6 2 4 +346202395: 341 5 125 77 396 +16819164083: 552 549 555 7 3 7 +41630: 15 793 8 89 46 +48577788812329: 771 9 68 4 7 81 2 3 28 +13311605: 18 739 5 81 376 3 8 +704954971: 747 5 248 540 7 91 +29030550: 7 1 20 3 8 4 4 1 105 39 6 +66521838: 4 371 5 8 310 9 3 8 5 5 +380988: 5 3 39 7 96 3 4 7 +123491364: 17 46 842 84 274 +2025360000: 79 1 1 580 10 45 97 +55161058858: 9 913 636 222 354 5 8 +2507866928: 70 4 457 356 6 +4912132550: 97 1 2 3 5 1 1 4 3 254 9 1 +56991: 32 4 74 2 6 43 6 1 98 +661189130: 7 4 6 2 4 39 9 5 917 5 7 1 +13350852: 6 59 1 5 2 320 839 1 6 9 +6790: 9 1 15 1 8 84 4 62 5 +22855536: 3 3 4 396 614 +199118969: 7 1 5 9 42 554 9 4 7 8 7 +402931407: 36 8 8 5 4 4 1 743 873 +5695722994: 982 58 757 472 94 +54060007: 7 60 15 7 858 +3759488: 4 9 41 87 1 802 9 4 2 8 4 +1719433: 1 625 8 936 31 +3701529415: 790 32 562 45 4 12 +268276291: 46 6 8 5 9 9 762 92 +1129772527: 26 899 7 3 7 2 1 530 +64155: 6 761 7 1 2 2 4 194 20 9 +53740: 9 5 2 3 6 115 9 7 1 704 2 +5177612188: 4 88 457 36 4 70 13 2 +51687: 4 1 8 6 62 4 1 9 908 686 +171158415: 759 41 55 39 18 +160706087: 5 356 86 3 5 9 6 3 +375053: 1 9 164 4 1 57 507 569 +227289829: 2 9 184 5 6 6 10 7 2 98 +371838930252: 37 18 389 2 56 46 51 +363488: 864 7 42 315 1 +1779996: 329 3 90 74 57 +4874444999: 5 193 82 1 5 7 176 7 5 6 +5253: 3 49 5 1 3 +815: 5 3 65 8 5 +38820: 865 44 11 5 744 +3980: 9 8 2 3 6 1 76 5 3 2 8 4 +2057374: 33 7 565 11 34 +126929: 6 3 9 7 927 +121779: 555 53 3 6 87 34 165 9 +41269: 157 5 52 448 3 +1095433: 316 1 33 493 32 +759: 2 1 9 69 +9590393: 304 15 6 798 3 +8186291236: 818 62 91 238 1 +156397000: 6 9 6 4 6 2 1 783 88 250 +140024803776: 2 488 505 54 807 4 88 +253929288: 552 46 9 28 9 +53475506: 562 58 32 95 6 +316964278497: 566 56 427 8 48 1 4 +1987: 9 3 73 8 8 +18061344: 6 330 1 96 87 9 6 7 6 35 +1093604: 6 269 913 7 92 +52749645553: 1 975 6 4 2 8 7 172 7 9 7 +55123: 5 689 2 8 3 +1018: 9 43 66 7 +45663: 34 4 12 35 28 +221867989: 913 27 1 99 3 797 9 +17413621878: 290 227 6 13 5 78 +39627552: 81 91 896 169 6 33 7 2 +623627490: 3 7 260 3 1 27 3 6 470 +210555237: 1 1 6 319 2 2 2 3 6 23 5 +111797277: 5 837 4 4 1 981 8 5 9 8 6 +4489668616: 3 663 30 9 4 6 22 57 7 +70992: 61 648 9 4 +10136086086: 8 515 36 246 7 5 411 +125553456: 415 19 84 9 4 +432099851242: 3 9 8 9 5 998 5 1 17 7 2 1 +1197740: 57 15 53 14 +9841: 3 51 2 6 2 24 52 6 104 7 +1095765: 251 9 1 2 7 32 4 5 6 1 4 5 +1418604: 153 843 4 1 487 954 6 +395781: 40 38 98 4 54 +19638635: 2 2 4 71 49 722 9 226 +4122: 1 2 963 4 225 +259532427: 59 7 1 434 426 +9280106: 256 725 3 5 86 5 +36067626950: 89 15 83 8 27 953 +1320: 9 59 553 146 93 +144106119080: 98 94 971 6 15 77 +14557125649733: 8 1 8 554 811 986 8 7 5 +1677997: 1 26 63 1 385 4 9 94 +336386821: 10 5 32 550 73 187 7 +59025094863: 4 4 36 287 39 6 779 3 +96589446: 7 91 675 9 818 5 3 2 +7317283837: 4 60 18 67 114 34 3 +90806: 7 2 7 7 92 +96480541939: 459 431 15 21 21 +873: 33 1 4 23 +1695206159: 221 851 285 2 4 90 +6130571: 2 61 61 5 68 +39372208: 1 8 8 7 99 20 35 4 7 8 +18612096: 4 112 16 94 5 5 60 96 +6853511: 85 51 587 75 1 9 +266310616: 40 1 8 9 8 66 6 1 6 +9981672331684: 53 4 4 68 76 4 981 7 4 +44867478: 4 4 8 649 9 8 4 92 7 379 +76841: 18 4 754 93 23 +43763: 429 83 24 45 653 58 +362472323020: 891 1 3 53 17 9 460 4 5 +46448727: 7 1 5 3 9 6 81 8 6 6 67 6 +2461730: 82 3 17 32 +5284: 63 20 5 60 6 +116: 55 54 7 +939960134464: 71 752 681 95 7 1 131 +953880648: 2 362 8 67 83 503 +2976255212785: 87 4 3 30 95 7 3 2 786 +62433231224: 52 43 2 292 2 5 698 1 +2687832: 68 77 97 252 2 +9445356541: 5 8 37 30 5 5 163 41 9 1 +340425769: 12 73 89 45 772 +1097: 4 8 54 459 1 2 46 +5042559329287: 9 7 2 2 5 5 796 8 8 81 2 7 +10847196: 69 6 4 3 898 4 2 4 9 9 30 +18516887: 661 2 91 28 740 +391114505: 7 3 19 3 5 2 5 386 7 15 5 +28751890: 7 5 4 53 62 11 85 88 7 3 +3775884100: 65 101 4 50 58 +4291172291: 395 831 5 246 7 91 +4553304576: 93 765 376 8 64 +262: 4 56 66 88 48 +5949008: 586 8 80 320 691 +21516: 94 1 54 2 498 2 +499402575: 975 156 6 616 6 3 545 +15886516: 6 23 8 45 914 314 +566023992: 3 45 3 6 119 14 35 +1788409: 57 663 31 854 2 +761967136: 17 46 60 884 904 +1348913535713: 47 287 13 535 714 +1793: 4 424 1 2 86 8 +1541149: 570 52 7 35 7 5 1 89 7 +879: 26 357 496 +19725338: 52 7 995 48 7 458 +1407751082089: 9 5 7 7 91 9 138 7 5 49 8 +119: 2 3 2 53 6 +967365: 967 3 66 +75140232: 75 139 743 457 29 +2095326: 54 715 57 6 3 1 806 3 9 +8469341066: 4 3 66 4 8 8 66 2 8 907 9 +4527087: 2 20 17 93 9 30 86 +14688: 27 1 9 5 5 3 4 6 9 5 94 14 +764545: 2 8 1 4 37 66 594 9 67 +10374592350: 110 351 17 94 349 +93138130236: 7 225 5 2 8 5 4 1 29 591 +6309501: 381 92 5 2 4 2 6 9 1 6 1 8 +144372247: 67 59 267 8 7 +32204: 8 333 63 78 7 8 592 85 +12794630625: 395 789 6 88 48 5 5 45 +147538: 92 47 8 535 4 +341844: 506 7 7 1 6 2 8 8 1 976 3 +113702: 9 76 166 149 8 +1523526690: 3 91 5 41 6 140 93 6 90 +4914429: 44 5 6 51 4 438 69 +20976: 36 8 64 1 40 3 9 46 +645125222: 5 15 7 8 20 7 4 4 8 58 9 2 +18774236: 474 50 35 7 358 +65485435: 8 5 7 6 8 7 5 517 4 69 9 3 +43201942787: 54 686 79 278 7 +2213: 579 651 2 418 2 8 553 +1925205028706: 7 3 7 3 4 4 3 887 8 654 6 +2196748: 5 5 122 311 8 2 6 487 4 +7402752: 9 33 72 8 3 102 +135500: 767 969 1 78 14 +8821063171: 94 209 449 9 173 +16207705800: 7 2 130 22 834 755 +67661: 3 18 641 14 60 +2704169: 3 1 1 51 3 1 2 72 6 9 283 +4658180909: 36 5 4 6 566 5 81 8 8 80 +7562497803: 75 549 75 977 2 3 78 +108818150: 141 45 49 1 4 2 25 7 +55201563135: 51 4 194 7 563 138 +17: 9 4 4 +280065690098: 64 1 9 7 41 9 49 84 775 +250635474: 7 574 770 7 393 5 9 1 9 +22949642: 75 995 383 5 7 8 2 +3338140: 7 3 26 963 1 2 9 4 1 370 +8629264656: 63 89 45 2 68 342 +17658484538: 966 914 1 227 20 +990156: 2 987 973 178 4 +5098320: 49 6 67 4 6 5 9 776 5 9 +83260: 802 8 84 11 92 +91848: 288 47 9 267 1 +113480: 67 9 34 3 480 +187926960: 5 82 8 310 871 +928486: 871 2 95 35 2 61 871 +38547: 494 78 1 8 6 +350258: 8 4 99 5 8 4 9 6 6 78 8 2 +32403520: 9 8 4 16 111 1 8 3 5 40 8 +64168545: 2 14 13 1 4 1 228 +4901: 5 1 96 5 +32185440: 61 3 744 31 40 4 7 +1791603: 179 91 867 1 95 +312242: 77 3 7 6 8 5 3 +1968834563: 948 59 1 5 65 88 4 +96959: 358 27 22 7 9 +10843626757: 299 57 87 532 633 +188756400: 1 3 586 31 49 805 +9878383: 15 462 879 5 253 +223460: 7 446 4 300 295 145 +6522815: 24 4 3 1 5 1 6 349 5 +319259894: 57 56 595 3 97 +16356414611: 4 9 625 5 345 5 3 3 1 2 2 +10925466561: 79 52 834 66 561 +210847: 2 5 2 154 83 8 63 7 91 +9771484818: 2 64 371 9 44 21 5 4 +1517: 7 1 9 701 797 +366017164: 14 22 60 17 161 +705406145: 2 278 3 57 11 9 7 3 7 39 +4320: 8 54 2 +1136938409: 1 6 411 4 794 7 619 71 +26151: 4 5 645 714 4 75 +12141509451: 64 3 1 7 22 3 7 9 1 4 6 7 +6643619611: 277 72 54 4 443 +37988330: 51 8 67 310 31 +344528998: 353 976 989 5 5 +86260: 4 3 85 7 705 25 3 2 61 6 +207821952: 9 3 442 933 7 52 9 32 +68857957: 1 377 50 85 666 44 5 +22549414: 3 5 7 517 6 7 9 10 403 8 +91219296896: 4 91 1 362 784 883 +13340717: 7 9 74 601 5 8 54 3 6 4 7 +13277825: 236 6 7 98 7 4 53 25 +34904568801: 3 5 4 7 720 8 2 327 3 66 +365440507746: 35 75 291 232 91 6 +1217646: 87 7 310 1 883 3 +4542786: 4 5 114 3 78 13 2 3 74 +2487245: 76 58 2 94 6 5 +71519: 3 7 5 337 71 4 2 3 62 3 7 +367213749: 1 5 918 171 9 2 4 +394549089609: 4 5 1 977 3 727 240 4 9 +117940712: 4 897 69 46 349 +147064770258: 41 3 69 8 81 918 8 483 +10138575600: 6 50 6 474 51 233 1 +11877: 6 5 319 9 4 +10018771: 9 8 89 5 7 4 2 5 15 9 421 +4919: 328 1 817 85 4 +1399115897647: 4 62 6 7 7 42 8 60 54 9 +702776: 8 7 483 97 8 +63862: 3 71 863 +12256176: 8 5 3 8 6 834 126 3 4 6 8 +33442856: 899 186 25 7 8 +3609624055: 7 7 8 9 9 5 2 9 704 701 3 +1730553335: 24 2 9 505 67 66 333 4 +223848: 5 471 5 6 588 3 1 1 29 8 +410887: 6 36 6 369 61 55 +71437850: 34 7 7 9 1 74 8 9 1 2 8 2 +22671: 27 793 1 336 924 +189519651: 920 89 21 5 98 +35790480396: 2 4 5 6 9 7 810 1 8 1 395 +1938893491925: 8 9 153 4 4 2 10 59 88 3 +15984845871: 465 289 53 11 4 6 4 3 1 +4178671207: 7 9 1 8 73 26 2 86 5 8 5 7 +583945973953: 8 8 8 923 71 2 5 44 33 +4632752: 734 7 5 621 9 4 +26197367269: 1 2 803 328 98 7 26 4 3 +538104: 267 2 20 94 4 1 7 +619952448: 65 9 4 6 83 4 76 10 7 10 +517041: 752 8 85 22 8 8 +97747: 3 47 630 13 34 +6739294: 91 23 88 309 5 +1637457526: 33 660 5 5 11 27 3 53 +7369541154800: 602 9 2 535 979 649 4 +3452722: 60 9 7 56 31 23 +106641041: 1 32 7 2 9 3 3 6 204 7 5 9 +12139856: 8 6 42 74 279 4 1 +8144806: 8 9 9 4 8 8 18 8 9 2 80 6 +20728968: 285 7 3 8 6 3 9 6 85 1 4 6 +824529024: 759 4 6 328 138 +24066223: 9 14 191 22 10 +15546301: 8 18 18 190 881 +2250828: 7 4 958 62 2 8 2 44 2 3 +75450608: 24 2 969 8 1 150 501 8 +879206487920: 794 3 391 805 944 +54038971: 540 38 75 21 9 2 +171363: 1 91 58 3 85 8 +885: 5 1 29 32 5 +139205608: 582 436 823 774 2 83 +39041232: 4 9 4 4 94 8 5 1 610 5 1 2 +828: 263 1 3 24 12 +3639213: 255 2 4 4 5 178 +962: 3 1 8 938 12 +925: 21 4 1 8 6 68 +5612850981: 8 8 1 76 1 9 63 88 87 45 +402040748: 5 874 92 672 76 +6343584591: 90 7 2 1 8 388 9 845 8 9 +36893: 2 91 6 733 246 3 8 5 +239916393: 7 1 765 424 2 449 731 +6784649: 643 9 5 259 647 +1834: 83 826 7 1 2 +19808: 95 2 5 116 1 5 5 2 5 4 4 2 +199130: 497 9 2 390 981 24 1 4 +218513331718: 25 571 6 91 9 6 39 5 17 +10024: 939 9 7 40 6 66 +12273646: 1 414 6 2 8 2 3 1 6 9 7 22 +13043384735: 3 2 570 56 9 4 5 5 3 644 +5929930318: 474 255 2 39 28 8 3 26 +3105664675: 8 1 701 4 2 4 2 4 674 +33549: 799 867 4 5 40 1 5 +19491: 13 2 46 3 5 3 970 6 7 6 +7281282: 49 23 8 1 2 83 +2941225352: 6 88 2 985 1 8 648 1 6 2 +743842143: 3 46 5 2 9 1 9 592 1 6 50 +3770861494685: 3 9 639 5 18 7 755 6 6 5 +230900220: 49 645 6 401 9 93 135 +139021: 27 5 3 91 8 9 96 +2339418: 687 798 5 35 9 545 +17623875: 6 3 160 2 3 45 4 4 252 3 +7093008549: 1 737 8 4 4 9 9 6 4 5 49 3 +2161990244728: 2 2 56 1 9 803 9 473 30 +4233496995055: 1 9 79 569 70 850 6 9 +49611735: 3 8 398 8 9 5 68 4 11 2 2 +314315: 4 479 11 2 7 +15718188186: 260 6 9 2 818 8 1 81 2 +241: 24 1 1 +3010: 6 48 5 4 78 +1135: 1 4 281 2 9 +81773: 40 5 43 18 +30460941: 78 7 6 9 2 815 8 3 6 1 2 2 +35705061092: 6 9 39 8 2 816 6 7 5 6 9 3 +25386661278: 4 6 5 7 82 11 64 1 2 7 5 +1759980508: 33 68 323 9 386 5 +9285284808: 519 9 943 31 963 68 +825411626: 85 6 98 359 902 9 46 +181828: 27 55 66 +3339156: 31 1 6 78 145 158 +1828013722: 5 3 2 4 9 4 42 2 1 3 9 260 +14583391061: 46 2 40 35 35 83 5 61 +11615: 1 5 54 196 50 +125065785: 9 770 2 1 52 2 8 7 4 4 7 6 +3838169: 8 1 70 7 47 922 2 8 42 +757453: 23 392 84 104 5 +25565938: 4 2 9 536 563 1 464 +31650181: 380 2 8 52 8 69 5 206 +1550195111: 7 14 2 210 5 13 6 510 9 +2288: 4 6 8 848 79 996 +10906: 2 2 4 3 574 +1857247825: 1 5 1 3 3 3 4 7 993 6 34 +519606584: 591 91 478 3 7 456 8 7 +2387585200: 909 1 445 44 134 +240706: 5 48 706 +69652758240: 4 4 95 74 9 3 2 3 5 9 4 8 +1708581168: 515 1 15 667 783 28 +3529: 6 47 8 294 1 9 951 5 8 6 +2325425: 579 6 8 95 487 +9741670662: 1 4 7 3 42 2 9 9 2 4 773 5 +38772: 75 62 188 8 68 +6401764: 2 4 367 34 7 66 +155361598651: 3 9 65 8 5 8 142 6 7 8 9 1 +77114165613: 114 1 84 821 7 2 7 1 9 2 +129739783188: 21 4 5 7 96 1 8 1 2 2 317 +5352096010: 985 566 96 1 2 +83015410: 3 734 29 65 5 2 +13959262: 93 86 951 82 484 +131105147: 69 190 49 18 232 +80465240: 2 7 48 277 19 2 34 7 +4187717: 760 9 8 544 6 1 +66632: 8 2 9 4 4 4 5 764 5 1 40 8 +16701: 12 9 3 56 2 50 +476608899: 2 7 36 3 57 6 509 125 4 +65111177648: 9 41 1 1 3 7 3 6 2 4 7 48 +3764967: 6 105 26 44 8 8 75 76 +249938: 4 2 5 6 6 8 5 4 58 8 9 984 +12144922: 487 1 41 23 913 9 +55495023: 8 867 87 8 8 +2533544483: 8 6 4 776 6 8 9 5 3 2 84 +49882405: 3 9 20 7 5 8 4 7 120 2 8 +531821285: 9 413 6 356 59 8 +982: 5 1 3 423 550 +2035142: 437 388 2 71 7 6 2 +251946: 9 3 5 8 185 5 708 +2889: 32 1 9 +38035751: 425 6 25 5 706 +1706128499: 47 363 284 97 1 +15084993: 21 5 71 2 106 21 77 +115693001: 2 5 2 151 25 6 5 192 2 7 +4116653112: 5 48 887 75 6 15 +972753516650: 979 92 1 77 3 4 9 59 6 1 +3036153: 416 4 99 650 9 +1451700796: 211 688 47 160 99 +541867381: 451 556 12 70 108 +10564977526: 6 7 1 1 3 2 29 31 4 505 5 +196219884: 96 1 66 203 86 +283035968424: 6 83 97 1 99 982 4 53 8 +326432: 3 522 19 5 5 2 6 1 6 2 8 2 +2612707589: 5 9 8 1 9 7 86 1 3 94 7 7 +43451622: 567 26 650 3 941 6 +5630: 58 503 1 2 8 +4309231498: 85 178 7 190 375 84 +111142473: 623 9 479 42 3 7 6 7 35 +7433090320: 387 14 24 29 80 3 +6215287915: 9 417 102 9 66 +135649560682: 90 4 33 15 55 5 679 +50611810415: 2 2 2 178 87 985 8 79 +4899685: 78 86 44 97 7 18 +35154763576: 2 39 84 637 7 7 1 5 74 +365264770: 913 4 64 186 584 +8019: 84 798 5 4 9 +2508: 1 24 83 389 60 2 65 1 +5458136777: 53 6 9 81 3 6 2 5 5 522 +2757995051: 29 951 948 31 222 +764140: 7 6 413 7 +3995924243581: 648 689 560 325 11 6 +154058630934: 303 504 846 1 28 61 6 +1427638: 8 13 21 593 632 5 +21098550233: 4 1 1 69 824 65 45 98 6 +178: 50 46 82 +119341: 45 57 78 15 +1001625: 6 6 2 821 2 +107025: 78 28 9 64 61 +6827328: 346 3 7 4 930 21 45 3 +747730884: 29 96 954 65 4 2 8 2 +243569365: 3 9 1 6 4 3 8 443 43 76 6 +1359330: 7 97 298 2 735 +39346886641: 2 88 8 41 3 55 1 6 659 1 +455625: 90 7 5 78 234 861 9 +601917984: 5 55 1 8 3 8 6 1 973 3 3 5 +71009287: 2 4 8 628 684 4 4 9 4 +214: 2 6 2 7 4 +2342725: 6 12 89 14 43 +25959024: 4 7 187 1 308 7 9 4 1 7 8 +972061: 4 8 70 80 84 9 383 4 +2178012557: 9 3 234 18 12 5 39 6 12 +3915: 7 35 9 6 45 46 7 20 570 +26750623: 2 67 1 50 626 +1121087: 266 1 753 17 11 +3795624: 570 6 156 516 42 +967753: 5 35 395 1 14 +31443545952: 4 18 871 987 508 +9191024368: 7 54 3 96 43 5 2 3 47 +18400: 34 5 488 263 1 6 3 23 1 +509203: 1 1 61 7 1 9 118 3 3 5 3 +174801132: 30 1 1 6 732 80 65 8 99 +211965600: 2 5 814 7 62 60 +3173091525: 998 2 8 613 7 41 9 1 1 9 +169407529: 46 7 906 7 252 2 22 4 +5331: 4 4 9 37 1 +21980222: 3 133 6 988 2 41 7 1 7 +449553702: 405 111 282 88 2 +2942: 5 15 8 1 18 62 +2320553257: 91 51 5 53 156 9 91 +9146342: 197 8 1 4 92 441 5 +966594375: 9 840 5 5 6 4 1 5 757 5 3 +4780203738: 6 7 3 17 372 1 9 7 3 857 +277037610569: 3 6 8 19 4 4 6 8 9 710 67 +9836: 7 1 41 2 16 1 652 +200552837873474: 236 780 21 847 3 47 4 +1225: 3 2 7 7 901 3 9 26 35 6 +138: 5 6 108 +48726878940: 5 4 140 9 4 3 8 9 8 3 6 40 +1072958: 27 1 9 11 158 379 9 +14700: 18 3 7 525 +27192423: 74 9 9 6 3 7 6 3 18 2 36 3 +973: 8 5 1 7 1 61 +4767602: 970 6 4 305 106 7 35 6 +5699955: 8 14 47 70 41 956 +4799016: 6 9 5 7 2 8 5 2 59 514 8 9 +1104789: 211 843 50 74 2 47 +3465098: 3 4 487 1 2 385 1 5 9 44 +1092564: 455 2 1 8 20 3 +4046781265: 418 4 5 92 1 1 263 +9213: 85 98 3 871 9 +19183: 4 6 1 4 3 1 19 133 6 4 1 6 +3057: 913 3 317 1 +308423: 64 61 79 1 7 +4532250239: 4 12 8 25 421 6 56 72 +259228473176: 8 49 77 22 91 3 1 7 9 +53531868: 910 4 15 49 36 6 8 9 +3170: 633 5 5 +7000826121: 9 5 6 3 69 84 96 233 9 +26296280: 377 12 69 87 8 704 +944: 37 8 39 1 859 +416601374947: 4 67 9 7 472 493 2 3 3 6 +87295346: 2 8 9 68 2 75 9 9 4 9 3 9 +88964084: 282 9 598 640 83 +26775736: 6 6 93 934 4 +30545: 973 5 1 2 46 2 343 9 3 5 +96136910: 93 1 2 8 8 97 1 1 9 1 890 +37564937: 375 64 861 1 77 +3400: 7 17 362 84 480 184 3 +6800: 9 9 4 20 4 +351249746890: 48 38 15 11 862 66 +7882: 1 16 26 731 6 1 3 2 8 40 +17835253284: 243 651 732 8 3 +2210544040: 730 1 3 5 4 6 28 12 5 8 5 +122544: 6 851 8 3 +897030320: 6 4 7 2 98 4 867 165 3 1 +12088: 69 387 92 22 32 1 +278: 94 8 94 2 4 76 +1349040: 84 78 9 2 3 4 1 77 1 +1909: 702 784 6 412 5 +510079: 7 9 4 28 72 77 2 27 +434835: 7 62 1 4 69 3 +30991593633: 85 6 302 13 67 77 39 +3289538589: 77 712 6 9 85 88 +6121549: 50 9 5 795 385 15 3 5 +4979436: 13 5 4 7 3 13 6 2 8 8 3 68 +129724777: 3 12 1 7 2 87 47 59 5 4 +68892363: 6 897 5 74 3 1 7 5 6 2 3 3 +4255924039: 1 72 6 94 978 41 586 3 +70979251824: 63 3 50 8 1 152 779 78 +1308486: 997 7 783 939 4 2 1 1 6 +2493632464308: 457 659 3 41 1 4 207 +348724: 34 8 722 1 +99166237: 984 7 64 2 238 +285197: 165 3 781 700 91 +9295: 53 3 57 43 7 +572564: 51 4 2 2 564 +325498150: 171 19 5 981 47 +46795: 43 1 1 2 793 +46340060: 4 5 1 3 332 4 2 8 618 1 +147087: 59 4 876 8 6 1 +4611297686: 3 34 91 2 6 69 6 85 +3862158312: 79 8 9 97 4 4 4 1 8 44 7 +789742859: 2 572 8 6 4 15 862 25 9 +579661523530: 2 5 41 29 132 211 91 +574: 9 4 6 4 7 +70184473660: 3 68 8 643 58 807 11 4 +70743726: 8 22 9 193 382 +2837431380: 2 89 49 63 3 3 4 707 1 +4458906: 44 582 4 9 656 +171138967: 1 171 13 1 7 960 7 +38732: 3 8 7 3 5 +931380691: 80 59 67 806 92 +3906490490: 2 42 1 6 21 1 96 778 2 +12218522: 2 6 21 5 4 31 2 1 +101954797: 472 6 9 692 4 4 6 1 6 14 +305743: 70 49 5 89 28 +1327567128: 1 15 189 7 1 43 82 +13548879: 6 9 8 413 47 2 +1815476055012: 9 5 637 8 681 3 7 3 3 1 2 +7297: 65 82 748 688 531 +35204: 9 10 64 6 644 +716101542: 928 505 28 9 70 9 778 +43859: 146 55 741 5 2 +597783034238: 9 2 68 866 49 190 8 +63576: 5 7 92 54 12 +508211: 2 30 60 3 88 444 887 +809: 9 501 2 7 290 +54153: 5 32 332 981 34 18 +947723581: 43 29 76 3 581 +118147: 12 7 97 7 5 1 7 911 479 +40606820: 96 6 4 7 4 2 68 6 6 74 +29223272479321: 8 654 7 923 8 40 603 +276032: 16 7 30 4 34 +78046230: 47 3 75 56 22 +553350: 6 15 80 178 75 +3735: 5 64 7 7 535 3 1 3 525 +2771237635: 8 880 2 17 39 2 4 53 6 6 +1677983: 899 9 7 8 33 +1575693: 19 4 2 962 8 +171136: 5 267 2 4 2 32 +1255703222: 22 63 97 3 13 934 +455805632: 6 7 203 8 2 9 6 5 65 5 6 5 +109920: 35 3 209 5 195 +906417640: 58 1 5 23 2 307 1 40 +25890834326636: 1 7 2 896 109 7 6 6 5 9 4 +403244184917: 2 576 5 6 1 312 13 7 2 5 +3564175: 48 74 8 2 7 6 90 6 3 815 +1558050560: 3 2 1 2 231 8 5 4 926 44 +89400308: 5 1 401 8 421 354 217 +12147: 8 5 9 84 8 37 7 618 14 +6656: 2 51 5 81 776 +191770117: 6 627 1 8 1 91 5 8 5 70 7 +36606668968: 22 282 52 59 965 +44391606965: 98 1 59 760 6 887 81 +22680: 5 52 18 6 30 +9882851925: 987 3 5 93 51 75 17 3 +83482: 345 6 2 774 7 8 62 7 +1514: 4 35 3 7 199 +63054605: 13 5 819 958 +62283458186154: 77 1 837 643 801 954 +63516: 31 42 55 6 1 67 316 +33244662713: 71 7 6 786 79 85 +126031: 3 6 7 4 59 6 5 6 4 4 147 1 +15370: 71 82 2 5 44 +214042233972: 73 9 4 2 9 1 9 2 6 8 93 4 +100495410: 5 578 3 5 4 6 41 882 6 5 +989: 8 92 95 +177497320: 9 4 4 9 8 109 1 2 7 2 605 +38159834: 1 7 17 10 3 5 9 932 3 6 8 +3692749373496: 761 8 82 30 7 8 19 8 57 +54685213: 42 4 235 1 2 45 48 55 9 diff --git a/2025/.gitignore b/2025/.gitignore new file mode 100644 index 0000000..7b6d9fe --- /dev/null +++ b/2025/.gitignore @@ -0,0 +1,3 @@ +.vs +x64 +*.vcxproj.user \ No newline at end of file diff --git a/2025/AdventHelpers/AdventHelpers.vcxproj b/2025/AdventHelpers/AdventHelpers.vcxproj new file mode 100644 index 0000000..a56cc5a --- /dev/null +++ b/2025/AdventHelpers/AdventHelpers.vcxproj @@ -0,0 +1,167 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 18.0 + Win32Proj + {df572ffd-18c6-4b8d-8d35-4855f9a05376} + AdventHelpers + 10.0 + + + + StaticLibrary + true + v145 + Unicode + + + StaticLibrary + false + v145 + true + Unicode + + + StaticLibrary + true + v145 + Unicode + + + StaticLibrary + false + v145 + true + Unicode + + + + + + + + + + + + + + + + + + + + + $(ProjectDir)include;$(PublicIncludeDirectories) + + + $(ProjectDir)include;$(PublicIncludeDirectories) + + + $(ProjectDir)include;$(PublicIncludeDirectories) + + + $(ProjectDir)include;$(PublicIncludeDirectories) + + + + Level3 + true + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + true + stdcpplatest + NotUsing + pch.h + $(ProjectDir)include;%(AdditionalIncludeDirectories) + + + + + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + true + stdcpplatest + NotUsing + pch.h + $(ProjectDir)include;%(AdditionalIncludeDirectories) + + + + + true + + + + + Level3 + true + _DEBUG;_LIB;%(PreprocessorDefinitions) + true + stdcpplatest + NotUsing + pch.h + $(ProjectDir)include;%(AdditionalIncludeDirectories) + + + + + true + + + + + Level3 + true + true + true + NDEBUG;_LIB;%(PreprocessorDefinitions) + true + stdcpplatest + NotUsing + pch.h + $(ProjectDir)include;%(AdditionalIncludeDirectories) + + + + + true + + + + + + + + + + + + + \ No newline at end of file diff --git a/2025/AdventHelpers/AdventHelpers.vcxproj.filters b/2025/AdventHelpers/AdventHelpers.vcxproj.filters new file mode 100644 index 0000000..f66964e --- /dev/null +++ b/2025/AdventHelpers/AdventHelpers.vcxproj.filters @@ -0,0 +1,33 @@ + + + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {2a803cbd-00cf-4f43-9bed-5bc9ef841e3f} + + + + + source + + + + + include\AdventHelpers + + + include\AdventHelpers + + + \ No newline at end of file diff --git a/2025/AdventHelpers/include/AdventHelpers/AdventOfCodeSolution.h b/2025/AdventHelpers/include/AdventHelpers/AdventOfCodeSolution.h new file mode 100644 index 0000000..12787b1 --- /dev/null +++ b/2025/AdventHelpers/include/AdventHelpers/AdventOfCodeSolution.h @@ -0,0 +1,13 @@ +#pragma once + +#include "AdventHelpers/InputFileHelper.h" + +namespace AdventHelpers +{ + class IAdventOfCodeSolution { + public: + virtual void SolveExample(AdventHelper::InputFileHelper& inputFile) = 0; + virtual void SolveProblem01(AdventHelper::InputFileHelper& inputFile) = 0; + virtual void SolveProblem02(AdventHelper::InputFileHelper& inputFile) = 0; + }; +} diff --git a/2025/AdventHelpers/include/AdventHelpers/InputFileHelper.h b/2025/AdventHelpers/include/AdventHelpers/InputFileHelper.h new file mode 100644 index 0000000..5028cca --- /dev/null +++ b/2025/AdventHelpers/include/AdventHelpers/InputFileHelper.h @@ -0,0 +1,35 @@ +#pragma once + +#include +#include + +namespace AdventHelper { + // Interface + class InputFileHelper { + public: + using LinesType = std::vector; + + static InputFileHelper* create(const char* filename); + static void destroy(InputFileHelper* inputFileHelper); + + inline LinesType::const_iterator begin() const; + inline LinesType::const_iterator end() const; + private: + InputFileHelper() = default; + ~InputFileHelper() = default; + + const char* getLine(); + + LinesType mLines; + }; + + // Implementation + InputFileHelper::LinesType::const_iterator InputFileHelper::begin() const { + return mLines.cbegin(); + } + + InputFileHelper::LinesType::const_iterator InputFileHelper::end() const { + return mLines.cend(); + } +} + diff --git a/2025/AdventHelpers/source/InputFileHelper.cpp b/2025/AdventHelpers/source/InputFileHelper.cpp new file mode 100644 index 0000000..744e0b1 --- /dev/null +++ b/2025/AdventHelpers/source/InputFileHelper.cpp @@ -0,0 +1,42 @@ +#include "AdventHelpers/InputFileHelper.h" + +#include +#include +#include + +namespace AdventHelper { + // Opens file, reads each line into mLines vector. Returns null on error. + InputFileHelper* InputFileHelper::create(const char* filename) { + InputFileHelper* inputFileHelper = nullptr; + std::ifstream file(filename); + + if (file.is_open()) { + inputFileHelper = new InputFileHelper(); + + std::string line; + while (std::getline(file, line)) { + inputFileHelper->mLines.push_back(line); + } + + // Clean up + file.close(); + } + else { + std::cerr << "Error: Could not open file " << filename << std::endl; + } + + return inputFileHelper; + } + + const char* InputFileHelper::getLine() { + return nullptr; + } + + void InputFileHelper::destroy(InputFileHelper* inputFileHelper) { + if (inputFileHelper) { + delete inputFileHelper; + } else { + std::cerr << "Warning: Attempted to destroy a null InputFileHelper pointer." << std::endl; + } + } +} // namespace AdventHelper diff --git a/2025/AdventHelpersTester/AdventHelpersTester.cpp b/2025/AdventHelpersTester/AdventHelpersTester.cpp new file mode 100644 index 0000000..e583699 --- /dev/null +++ b/2025/AdventHelpersTester/AdventHelpersTester.cpp @@ -0,0 +1,36 @@ +#include "AdventHelpers/InputFileHelper.h" +#include "AdventHelpers/AdventOfCodeSolution.h" + +#include + +// Interface + +class ExampleSolution : public AdventHelpers::IAdventOfCodeSolution +{ +public: + virtual void SolveExample(AdventHelper::InputFileHelper& inputFile) override; + virtual void SolveProblem01(AdventHelper::InputFileHelper& inputFile) override; + virtual void SolveProblem02(AdventHelper::InputFileHelper& inputFile) override; +}; + +int main() +{ + auto* inputHelper = AdventHelper::InputFileHelper::create("input.txt"); + + std::cout << "Hello World!\n"; + + AdventHelper::InputFileHelper::destroy(inputHelper); +} + +// Implementation + +void ExampleSolution::SolveExample(AdventHelper::InputFileHelper& inputFile) { + +} + +void ExampleSolution::SolveProblem01(AdventHelper::InputFileHelper& inputFile) { + +} + +void ExampleSolution::SolveProblem02(AdventHelper::InputFileHelper& inputFile) { +} \ No newline at end of file diff --git a/2025/AdventHelpersTester/AdventHelpersTester.vcxproj b/2025/AdventHelpersTester/AdventHelpersTester.vcxproj new file mode 100644 index 0000000..4563198 --- /dev/null +++ b/2025/AdventHelpersTester/AdventHelpersTester.vcxproj @@ -0,0 +1,140 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 18.0 + Win32Proj + {8771a5e2-83fe-497e-8598-18dbf552d6b3} + AdventHelpersTester + 10.0 + + + + Application + true + v145 + Unicode + + + Application + false + v145 + true + Unicode + + + Application + true + v145 + Unicode + + + Application + false + v145 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + stdcpplatest + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + stdcpplatest + + + Console + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + stdcpplatest + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + stdcpplatest + + + Console + true + + + + + + + + {df572ffd-18c6-4b8d-8d35-4855f9a05376} + + + + + + \ No newline at end of file diff --git a/2025/AdventHelpersTester/AdventHelpersTester.vcxproj.filters b/2025/AdventHelpersTester/AdventHelpersTester.vcxproj.filters new file mode 100644 index 0000000..61fafaa --- /dev/null +++ b/2025/AdventHelpersTester/AdventHelpersTester.vcxproj.filters @@ -0,0 +1,22 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + \ No newline at end of file diff --git a/2025/AdventOfCode.slnx b/2025/AdventOfCode.slnx new file mode 100644 index 0000000..f458e09 --- /dev/null +++ b/2025/AdventOfCode.slnx @@ -0,0 +1,8 @@ + + + + + + + +