Initial Commit
This commit is contained in:
317
2022/AdventOfCode.sln
Normal file
317
2022/AdventOfCode.sln
Normal file
@@ -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
|
||||||
8
2022/Day01CSharp/Day01CSharp.csproj
Normal file
8
2022/Day01CSharp/Day01CSharp.csproj
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
45
2022/Day01CSharp/Program.cs
Normal file
45
2022/Day01CSharp/Program.cs
Normal file
@@ -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<int> elves = new List<int>();
|
||||||
|
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]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
8
2022/Day01CSharp/Properties/launchSettings.json
Normal file
8
2022/Day01CSharp/Properties/launchSettings.json
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"profiles": {
|
||||||
|
"Day01CSharp": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"workingDirectory": "C:\\dev\\DevSandbox\\AdventOfCode\\2022\\Day01CSharp"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
14
2022/Day01CSharp/data/example.txt
Normal file
14
2022/Day01CSharp/data/example.txt
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
1000
|
||||||
|
2000
|
||||||
|
3000
|
||||||
|
|
||||||
|
4000
|
||||||
|
|
||||||
|
5000
|
||||||
|
6000
|
||||||
|
|
||||||
|
7000
|
||||||
|
8000
|
||||||
|
9000
|
||||||
|
|
||||||
|
10000
|
||||||
2247
2022/Day01CSharp/data/input.txt
Normal file
2247
2022/Day01CSharp/data/input.txt
Normal file
File diff suppressed because it is too large
Load Diff
55
2022/Day01CSharp/problem.txt
Normal file
55
2022/Day01CSharp/problem.txt
Normal file
@@ -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: **
|
||||||
8
2022/Day02CSharp/Day02CSharp.csproj
Normal file
8
2022/Day02CSharp/Day02CSharp.csproj
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
133
2022/Day02CSharp/Program.cs
Normal file
133
2022/Day02CSharp/Program.cs
Normal file
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
8
2022/Day02CSharp/Properties/launchSettings.json
Normal file
8
2022/Day02CSharp/Properties/launchSettings.json
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"profiles": {
|
||||||
|
"Day02CSharp": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"workingDirectory": "C:\\dev\\DevSandbox\\AdventOfCode\\2022\\Day02CSharp"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
3
2022/Day02CSharp/data/example.txt
Normal file
3
2022/Day02CSharp/data/example.txt
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
A Y
|
||||||
|
B X
|
||||||
|
C Z
|
||||||
2500
2022/Day02CSharp/data/input.txt
Normal file
2500
2022/Day02CSharp/data/input.txt
Normal file
File diff suppressed because it is too large
Load Diff
48
2022/Day02CSharp/problem.txt
Normal file
48
2022/Day02CSharp/problem.txt
Normal file
@@ -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: **
|
||||||
8
2022/Day03CSharp/Day03CSharp.csproj
Normal file
8
2022/Day03CSharp/Day03CSharp.csproj
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
243
2022/Day03CSharp/Program.cs
Normal file
243
2022/Day03CSharp/Program.cs
Normal file
@@ -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<char, int> left = new Dictionary<char, int>();
|
||||||
|
public Dictionary<char, int> right = new Dictionary<char, int>();
|
||||||
|
|
||||||
|
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<char, int> 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<char> Keys
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
var list = new List<char>();
|
||||||
|
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<Rucksack> GetRucksacks(string fileName)
|
||||||
|
{
|
||||||
|
List<Rucksack> list = new List<Rucksack>();
|
||||||
|
|
||||||
|
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<Group> 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<Group> groups = new List<Group>();
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
8
2022/Day03CSharp/Properties/launchSettings.json
Normal file
8
2022/Day03CSharp/Properties/launchSettings.json
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"profiles": {
|
||||||
|
"Day03CSharp": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"workingDirectory": "C:\\dev\\DevSandbox\\AdventOfCode\\2022\\Day03CSharp"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
6
2022/Day03CSharp/example-input01.txt
Normal file
6
2022/Day03CSharp/example-input01.txt
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
vJrwpWtwJgWrhcsFMMfFFhFp
|
||||||
|
jqHRNqRjqzjGDLGLrsFMfFZSrLrFZsSL
|
||||||
|
PmmdzqPrVvPwwTWBwg
|
||||||
|
wMqvLMZHhHMvwLHjbvcjnnSBnvTQFn
|
||||||
|
ttgJtRGJQctTZtZT
|
||||||
|
CrZsJsPPZsGzwwsLwLmpwMDw
|
||||||
62
2022/Day03CSharp/problem.txt
Normal file
62
2022/Day03CSharp/problem.txt
Normal file
@@ -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?
|
||||||
300
2022/Day03CSharp/puzzle-input01.txt
Normal file
300
2022/Day03CSharp/puzzle-input01.txt
Normal file
@@ -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
|
||||||
10
2022/Day04CSharp/Day04CSharp.csproj
Normal file
10
2022/Day04CSharp/Day04CSharp.csproj
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
121
2022/Day04CSharp/Program.cs
Normal file
121
2022/Day04CSharp/Program.cs
Normal file
@@ -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<Assignment> Assignments = new List<Assignment>();
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
8
2022/Day04CSharp/Properties/launchSettings.json
Normal file
8
2022/Day04CSharp/Properties/launchSettings.json
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"profiles": {
|
||||||
|
"Day04CSharp": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"workingDirectory": "C:\\dev\\DevSandbox\\AdventOfCode\\2022\\Day04CSharp"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
6
2022/Day04CSharp/example-input.txt
Normal file
6
2022/Day04CSharp/example-input.txt
Normal file
@@ -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
|
||||||
59
2022/Day04CSharp/problem.txt
Normal file
59
2022/Day04CSharp/problem.txt
Normal file
@@ -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?
|
||||||
1000
2022/Day04CSharp/puzzle-input.txt
Normal file
1000
2022/Day04CSharp/puzzle-input.txt
Normal file
File diff suppressed because it is too large
Load Diff
10
2022/Day05CSharp/Day05CSharp.csproj
Normal file
10
2022/Day05CSharp/Day05CSharp.csproj
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
233
2022/Day05CSharp/Program.cs
Normal file
233
2022/Day05CSharp/Program.cs
Normal file
@@ -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<Crate>[] 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<Operation> Operations { get; set; } = new List<Operation>();
|
||||||
|
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<Crate>[length];
|
||||||
|
for (int i = 0; i < Crates.Length; i++)
|
||||||
|
{
|
||||||
|
Crates[i] = new List<Crate>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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])));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
8
2022/Day05CSharp/Properties/launchSettings.json
Normal file
8
2022/Day05CSharp/Properties/launchSettings.json
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"profiles": {
|
||||||
|
"Day05CSharp": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"workingDirectory": "C:\\dev\\DevSandbox\\AdventOfCode\\2022\\Day05CSharp"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
9
2022/Day05CSharp/example-input.txt
Normal file
9
2022/Day05CSharp/example-input.txt
Normal file
@@ -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
|
||||||
106
2022/Day05CSharp/problem.txt
Normal file
106
2022/Day05CSharp/problem.txt
Normal file
@@ -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?
|
||||||
513
2022/Day05CSharp/puzzle-input.txt
Normal file
513
2022/Day05CSharp/puzzle-input.txt
Normal file
@@ -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
|
||||||
10
2022/Day06CSharp/Day06CSharp.csproj
Normal file
10
2022/Day06CSharp/Day06CSharp.csproj
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
53
2022/Day06CSharp/Program.cs
Normal file
53
2022/Day06CSharp/Program.cs
Normal file
@@ -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();
|
||||||
|
}
|
||||||
8
2022/Day06CSharp/Properties/launchSettings.json
Normal file
8
2022/Day06CSharp/Properties/launchSettings.json
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"profiles": {
|
||||||
|
"Day06CSharp": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"workingDirectory": "C:\\dev\\DevSandbox\\AdventOfCode\\2022\\Day06CSharp"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
48
2022/Day06CSharp/problem.txt
Normal file
48
2022/Day06CSharp/problem.txt
Normal file
@@ -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?
|
||||||
1
2022/Day06CSharp/puzzle-input.txt
Normal file
1
2022/Day06CSharp/puzzle-input.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
bvsvcsssfwwdttzpzqqnjjmbbmpbmpmffnttjllzbblvlvqllcwwqpwwhcclqqhmhbhlbbmtmdmgmpggcmcnmcmfcfddvmmcncrcncbbtssdnnhmmfmfrmrbbzllgtllfnnwhwtwzwjjrsrgsrsbbnjjbhjbbjpplslrssdwswrrcsszpplpfplflnnvdvmvjmmgpghphlhphnhffgqgfgzgddstdsdjjgqglqggtgvgrrgtrtllrvrmmnggftgtdtrttgqttcrcqqjqcqwccdzdldrdbbbmrbbnmmwrmmbcchnhmhchddhpphdhzhbbnvbbtctwcwbcwcfclcwwzvwvddbsdsfftgtqggjllwjwppmvvswsjwsscdcrrbggqzqqbhhjwhjwjtjvttpnpdplljplpqpzqzrqrmqmvvsvrvppfgfzfqffvsfvfcvcddjcddzssgfgtffhtfhthntnvvzhzwhzhbbnvvbtbqtqcqnqwnnvpvwwcqcgqqwrwlwbwrbbjcbbqqpddtbddcldccddjssvnvlnnmggmbbchcdcqqdsdqsdqdvdpvvvbzvbvrrjdrjrbjbrbttqzttmffwcfcnnbjnbbjmmgtmgmgdgdpgdglgzzvnzzztjjwbwvvhbhwbbnbhbddwcwvcvjcvjjnnjqjqjzqjjbgbmbjjnqnqddgfgwfgwfftntvnvtvhvlvslsffhvvwnnhshchmmlwmmwvvnhnggzllphllbqqtgqqffhwwnwzztnzttftptnppdpjdjwdwhdddgqglqldqdzzslsggstsrrcsrcclqqrsqrqjqhhjwjggrjgjnjtjwtwjtjrrvnnbddzqzzfnnbvvmfvmvwvggmsgsrggcjjtftpfflzfzccdgcgzcgzcggrbgbngnpnfngfnfqqfzfbfsbfsslqsstvvfmvfvrrvdrddrlrjlrrngrrgfgvgdggnttqqjbjwbwwchhddpmmcvcppjttbzbrzrdzztgtrrchhhbnnqfnfjnnpncnbnvnfnwwsllvrvddhwdwndnjdjbjttmggfvggjhghrhggczgzttbnttjmmdhdrrnnmppwtwdtdbtdbdffpqplqqfbffjssllmwmnmffcnczzrnznzmmwcmwwpbpcbbfdfrrznnzwnnmjnngmngmgpgrppnhnjhhjnhjhfhbffcfhccvzccnrrsggtjtdtjjqqdmqqcggmzzrhzrrbnnlqqtlqtqhhcffrpffgcfgcgncgnggjgzgvzvtztctmtgmmfwwttrntrtqtptzpzjpjqjffpvffvdfvvjhhggfhfrhrwhhwshsnhshbbjzbjzzlvlfvffmrfffngfgpglgjjsbbvzzjsjvsslgsgsfggwjgjlgjgsjgsstvstvstsffdqdpqddrsrmmjbbqbffzbzjjvzvrvcvhhsjsrrmccgqqjnnplnnrprhppslsqszzpvzvggsqscqqbwqqccsdsswqswwqcqzqddbhhmggswggzllccwvwjjpqqrpplrprgrllfwfmwmhhcmmnppfffvtffndnsdnsnbsnsgnsncnzzwrrqrwwzhzbzbnbqbjjrhhjjjbcjjffmwffjnfjfbbjtbbjhjvhvshvhwvwhvwvwfwwwfvvlddqnnlttqssnpsprpwwttlwtwrwfflggvjggwswgwgtgccdjdtdldrdcdsspjpvjpvvfttjrjdrrjppddbdvdjdwdvdssrhsszsjzzfccmwcwzzlnljlppjdjsdjdhdttrdtdtvddslsmmjnmmhzmhhmwmvmcvclvlnndtdrrfdrfrvfvsfvsszfsfdsfdsfsnsdsnsbsddsdwwzbbfqqhrhmrmzmhzhbbpptptffvtvhhwqqtgtdthhrqrrvttprtprrbcblsmbwqqpffmwnqmrdwvjszzhhhffpqsphcgqhlmsgnmmjsdhbfjscztgfvhnlbcmccrfcbnrwcpvgzztvpjdplmncrbvpzwtdnpfwcpvcbzvbtpqmgztsblnchzlphtzgfqcwnrbpcdhbcgzsbgdmbhhrsjqcngfddwvwvldbftgccbjzrrqjcnhbdfgmpdhdgfqzmnpmjgtgwvqlbwgjzjppgmcjzrfzgnbjjbvmshllzjppscwjzjqnbvrppzlshfvtvnpwljrghhwdhfgtcrstnqtqdzfhvgbrrzfdwgtjpjccwrphsdrsjlrlbnrtdbnhpdtshmqlpjqjdlwvrrflwqhcmnsrmcdnfcnwwqmdjlqmqvpgggrjrvfwtwnmhrgzztvmnqczvgmvpcldgfwmtmnsvdshrjmtsgfstjllmqqmpttfhjnsjflcmnpqtqnvtpbgjjhlwqzmrgrbvcsjvprbtqdrnvrgfjdrlhdjsvhhzvllzgfbdwbtqbqzpllpcmcdrfmrsfnwvvmhcqjblnczltcmmmbqwpztqmdpprwphfwgwnsvnzsldnvbsbcdprnztpbmlfzcwpdvcwbsdflrcvsqlswctvlpvshqpwvtcjbtfnmgwtgsvtqhqdzzfhwznggpsmsmzlzrzqcdbqcnhpwhjbhvnqrcwnvpspwqmsqhdbchgrfcmznchwvftgvbldnvtpgmthbmpvccqwbjnjpzhrstscncsrdzsptzvlzjwnpzshmzbhrhgmnwmjmzvvvbgdjshgnqcmdmjrnhqzwtzpjvdczqzccvpvpqnftvpcwgzrzmmnhjnphfntbgjnscwqjcgfcrhjdsjbqfgzhsftghwwwvjwmhfhbwrwmnfrhcggcrjtjsqndrgsbvddqtwhctltzswmtsgwjgsbvvsvzfhbptjqbvbblzhcmnpcjpgzfhstsnlfvmqbdjhszhwhbqztvfdhnbnmppwvzjpnrhtbgthrdprjpqwpthqwzdnhpngflcmhnrmsbdlfwhjbfgrhfzspmfvvtqrwldzvblbtlwqfgfflvmvthbvdzzbtmmpzchgmldmgnhrfhhjwstbqqrzhmqsbqhjzdmjmllmjgqhhjghgsvrbmrbfjdzghmwpszfmslfwcjrftbqjgbbzddtvjmsgwmhhdzwtwvrgqctvwbwjqvssdvfprjsdgsgwbfmzwzmbnlzbfdqvwbrzpgvngqhfqzfqqsvmtgvsqwrplhfnsqhtvtbbqmpbjlcsfjgngwrztlrjbmcjddjsnbgcpnhdtngzhzvhzpjfcblhglhzfsjdgjdqvvppfrdftfbfldwqjznvrdqdnfscgvhztjwlqgqbjmlsbcrldjhnrsfgthlhplvwgmdnplrtpdvrqbpvnbpzfzwlvrrscvmgzhlcdwglwwrgzqsjqsqfblqljltbvvjwbpmfqjvldspgsbjrdbbwzjntlpqgvdjfvsjznczsppzwfvblffqqhwmhzdzztbvbsjhvjtjrptrdvrbbpnpncltqnhdvwjgzcmdtnbnhlmptjsqlzlpztnrtclgsmgvrvggtzfhpwgjgwtrnshmcpvhprpnrvgprspmwhchlhhsvwpvjdmjrlnjdchngrdgpwzsgqsjnqnqwsctzvsmqgvrpffffcfshbhmqbffwvcjqscrwhbfflwslspwjgdbvcgbtwldzffrdhrlbssjbcsjgbhprgspnjdbmnshzqwdvtnzsrfwbqfrgnlmpvqrrmmmcshzltqbwffprbwqbfthtvszqzcbbljtfjqmwpqssjtdpqlrfmpchrqmdpbsdjcdmglnlgnwvhclqfmbwhtljmscnzzqtwtjqsqrmmnssmqhqjvdlpmstmpwmrcfjbjrchrgvqqzbvtzpcbdvchvghnflllqddlttjwtnfhgqjjgtgsnhpvnwhcbljstshmhpwbqthvngqzrmqpmwqnvrfblpjlqgczfmtwvmlbzslqwdzhfccmrvjwfnwzgpbvgdgttdgtjdlvrmpbdhwjsvvsjqpclrnbtzphvmpfqhhqdmbmqzwphnzzfqjsqvdvbvnpmtnzpdsfzmbttssnssrtpmpvgrrzvcljtqtrqnfmmtsnvtrsjgcmqnttcmp
|
||||||
10
2022/Day07CSharp/Day07CSharp.csproj
Normal file
10
2022/Day07CSharp/Day07CSharp.csproj
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
205
2022/Day07CSharp/Program.cs
Normal file
205
2022/Day07CSharp/Program.cs
Normal file
@@ -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<Directory> SubDirectories { get; set; } = new List<Directory>();
|
||||||
|
public List<File> Files { get; set; } = new List<File>();
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
8
2022/Day07CSharp/Properties/launchSettings.json
Normal file
8
2022/Day07CSharp/Properties/launchSettings.json
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"profiles": {
|
||||||
|
"Day07CSharp": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"workingDirectory": "C:\\dev\\DevSandbox\\AdventOfCode\\2022\\Day07CSharp"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
23
2022/Day07CSharp/example-input.txt
Normal file
23
2022/Day07CSharp/example-input.txt
Normal file
@@ -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
|
||||||
99
2022/Day07CSharp/problem.txt
Normal file
99
2022/Day07CSharp/problem.txt
Normal file
@@ -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?
|
||||||
986
2022/Day07CSharp/puzzle-input.txt
Normal file
986
2022/Day07CSharp/puzzle-input.txt
Normal file
@@ -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
|
||||||
10
2022/Day08CSharp/Day08CSharp.csproj
Normal file
10
2022/Day08CSharp/Day08CSharp.csproj
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
203
2022/Day08CSharp/Program.cs
Normal file
203
2022/Day08CSharp/Program.cs
Normal file
@@ -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<List<int>> TreeData { get; } = new List<List<int>>();
|
||||||
|
|
||||||
|
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<List<int>>();
|
||||||
|
|
||||||
|
using (StreamReader reader = System.IO.File.OpenText(fileName))
|
||||||
|
{
|
||||||
|
while (!reader.EndOfStream)
|
||||||
|
{
|
||||||
|
string? line = reader.ReadLine();
|
||||||
|
if (line == null)
|
||||||
|
{
|
||||||
|
throw new InvalidDataException();
|
||||||
|
}
|
||||||
|
|
||||||
|
List<int> list = new List<int>();
|
||||||
|
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;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
8
2022/Day08CSharp/Properties/launchSettings.json
Normal file
8
2022/Day08CSharp/Properties/launchSettings.json
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"profiles": {
|
||||||
|
"Day08CSharp": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"workingDirectory": "C:\\dev\\DevSandbox\\AdventOfCode\\2022\\Day08CSharp"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
5
2022/Day08CSharp/example-input.txt
Normal file
5
2022/Day08CSharp/example-input.txt
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
30373
|
||||||
|
25512
|
||||||
|
65332
|
||||||
|
33549
|
||||||
|
35390
|
||||||
72
2022/Day08CSharp/problem.txt
Normal file
72
2022/Day08CSharp/problem.txt
Normal file
@@ -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?
|
||||||
|
|
||||||
99
2022/Day08CSharp/puzzle-input.txt
Normal file
99
2022/Day08CSharp/puzzle-input.txt
Normal file
@@ -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
|
||||||
10
2022/Day09CSharp/Day09CSharp.csproj
Normal file
10
2022/Day09CSharp/Day09CSharp.csproj
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
264
2022/Day09CSharp/Program.cs
Normal file
264
2022/Day09CSharp/Program.cs
Normal file
@@ -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<Position> rope = new List<Position>();
|
||||||
|
|
||||||
|
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<Position, bool> visited = new Dictionary<Position, bool>();
|
||||||
|
List<Tuple<char, int>> simulationSteps = new List<Tuple<char, int>>();
|
||||||
|
|
||||||
|
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<char, int>(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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
8
2022/Day09CSharp/Properties/launchSettings.json
Normal file
8
2022/Day09CSharp/Properties/launchSettings.json
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"profiles": {
|
||||||
|
"Day09CSharp": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"workingDirectory": "C:\\dev\\DevSandbox\\AdventOfCode\\2022\\Day09CSharp"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
8
2022/Day09CSharp/example-input.txt
Normal file
8
2022/Day09CSharp/example-input.txt
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
R 4
|
||||||
|
U 4
|
||||||
|
L 3
|
||||||
|
D 1
|
||||||
|
R 4
|
||||||
|
D 1
|
||||||
|
L 5
|
||||||
|
R 2
|
||||||
8
2022/Day09CSharp/example-input2.txt
Normal file
8
2022/Day09CSharp/example-input2.txt
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
R 5
|
||||||
|
U 8
|
||||||
|
L 8
|
||||||
|
D 3
|
||||||
|
R 17
|
||||||
|
D 10
|
||||||
|
L 25
|
||||||
|
U 20
|
||||||
685
2022/Day09CSharp/problem.txt
Normal file
685
2022/Day09CSharp/problem.txt
Normal file
@@ -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?
|
||||||
2000
2022/Day09CSharp/puzzle-input.txt
Normal file
2000
2022/Day09CSharp/puzzle-input.txt
Normal file
File diff suppressed because it is too large
Load Diff
10
2022/Day10CSharp/Day10CSharp.csproj
Normal file
10
2022/Day10CSharp/Day10CSharp.csproj
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
231
2022/Day10CSharp/Program.cs
Normal file
231
2022/Day10CSharp/Program.cs
Normal file
@@ -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<Instruction> 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<Instruction> list, int init, int step)
|
||||||
|
{
|
||||||
|
CPU cpu = new CPU();
|
||||||
|
int nextSignal = init;
|
||||||
|
List<int> strengthList = new List<int>();
|
||||||
|
|
||||||
|
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<Instruction> LoadInstructions(string filename)
|
||||||
|
{
|
||||||
|
List<Instruction> list = new List<Instruction>();
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
8
2022/Day10CSharp/Properties/launchSettings.json
Normal file
8
2022/Day10CSharp/Properties/launchSettings.json
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"profiles": {
|
||||||
|
"Day10CSharp": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"workingDirectory": "C:\\dev\\DevSandbox\\AdventOfCode\\2022\\Day10CSharp"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
3
2022/Day10CSharp/example-input1.txt
Normal file
3
2022/Day10CSharp/example-input1.txt
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
noop
|
||||||
|
addx 3
|
||||||
|
addx -5
|
||||||
146
2022/Day10CSharp/example-input2.txt
Normal file
146
2022/Day10CSharp/example-input2.txt
Normal file
@@ -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
|
||||||
321
2022/Day10CSharp/problem.txt
Normal file
321
2022/Day10CSharp/problem.txt
Normal file
@@ -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?
|
||||||
137
2022/Day10CSharp/puzzle-input.txt
Normal file
137
2022/Day10CSharp/puzzle-input.txt
Normal file
@@ -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
|
||||||
10
2022/Day11CSharp/Day11CSharp.csproj
Normal file
10
2022/Day11CSharp/Day11CSharp.csproj
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
319
2022/Day11CSharp/Program.cs
Normal file
319
2022/Day11CSharp/Program.cs
Normal file
@@ -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<Monkey> Monkeys { get; set; }
|
||||||
|
private bool AutoDropWorry { get; set; }
|
||||||
|
public Simulation(List<Monkey> monkeys)
|
||||||
|
{
|
||||||
|
Monkeys = monkeys;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigInteger MonkeyBusiness
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
var list = new List<Monkey>(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<BigInteger>();
|
||||||
|
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<BigInteger> Items { get; set; } = new List<BigInteger>();
|
||||||
|
|
||||||
|
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<Monkey> LoadMonkeys(string filename)
|
||||||
|
{
|
||||||
|
List<Monkey> monkeys = new List<Monkey>();
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
8
2022/Day11CSharp/Properties/launchSettings.json
Normal file
8
2022/Day11CSharp/Properties/launchSettings.json
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"profiles": {
|
||||||
|
"Day11CSharp": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"workingDirectory": "C:\\dev\\DevSandbox\\AdventOfCode\\2022\\Day11CSharp"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
27
2022/Day11CSharp/example-input.txt
Normal file
27
2022/Day11CSharp/example-input.txt
Normal file
@@ -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
|
||||||
307
2022/Day11CSharp/problem.txt
Normal file
307
2022/Day11CSharp/problem.txt
Normal file
@@ -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?
|
||||||
55
2022/Day11CSharp/puzzle-input.txt
Normal file
55
2022/Day11CSharp/puzzle-input.txt
Normal file
@@ -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
|
||||||
10
2022/Day12CSharp/Day12CSharp.csproj
Normal file
10
2022/Day12CSharp/Day12CSharp.csproj
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
279
2022/Day12CSharp/Program.cs
Normal file
279
2022/Day12CSharp/Program.cs
Normal file
@@ -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<int, int> 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<int, int> 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<int, int> 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<int, int> 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<int, int> Coordinates { get; set; }
|
||||||
|
|
||||||
|
public List<GraphNode> AdjacentNodes { get; set; } = new List<GraphNode>();
|
||||||
|
|
||||||
|
public bool Explored { get; set; }
|
||||||
|
|
||||||
|
public GraphNode(int height, Tuple<int, int> coordinates)
|
||||||
|
{
|
||||||
|
Height = height;
|
||||||
|
Coordinates = coordinates;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Reset()
|
||||||
|
{
|
||||||
|
Explored = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Graph
|
||||||
|
{
|
||||||
|
public Dictionary<Tuple<int, int>, GraphNode> Vertices { get; set; } = new Dictionary<Tuple<int, int>, GraphNode>();
|
||||||
|
|
||||||
|
public GraphNode GetAt(Tuple<int, int> index)
|
||||||
|
{
|
||||||
|
return Vertices[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
public int GetShortestNumberOfStepsAnywhere(int startingHeight, Tuple<int, int> 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<int, int>(x, y));
|
||||||
|
}
|
||||||
|
|
||||||
|
public int GetShortestNumberOfSteps(Tuple<int, int> start, Tuple<int, int> end)
|
||||||
|
{
|
||||||
|
Dictionary<Tuple<int, int>, Tuple<GraphNode?, int>> path = new Dictionary<Tuple<int, int>, Tuple<GraphNode?, int>>();
|
||||||
|
|
||||||
|
BFS(start, end, path);
|
||||||
|
|
||||||
|
return path[end].Item2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void PrintShortestPath(Tuple<int, int> start, Tuple<int, int> 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<int,int> start, Tuple<int,int> end, Dictionary<Tuple<int, int>, Tuple<GraphNode?, int>> path)
|
||||||
|
{
|
||||||
|
Queue<GraphNode> queue = new Queue<GraphNode>();
|
||||||
|
int visited = 0;
|
||||||
|
|
||||||
|
// label all verts as unexplored
|
||||||
|
foreach (var g in Vertices)
|
||||||
|
{
|
||||||
|
g.Value.Reset();
|
||||||
|
path.Add(g.Value.Coordinates, new Tuple<GraphNode?, int>(null, int.MaxValue));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the root
|
||||||
|
GraphNode root = GetAt(start);
|
||||||
|
|
||||||
|
Vertices[root.Coordinates].Explored = true;
|
||||||
|
path[root.Coordinates] = new Tuple<GraphNode?,int>(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<GraphNode?, int>(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<int, int>(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<int, int> current = new Tuple<int,int>(i, j);
|
||||||
|
Tuple<int, int> result = new Tuple<int, int>(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<int,int> newSpot)
|
||||||
|
{
|
||||||
|
int currentHeight = GetHeight(x, y);
|
||||||
|
|
||||||
|
switch (direction)
|
||||||
|
{
|
||||||
|
case 'u':
|
||||||
|
newSpot = new Tuple<int, int>(x, y - 1);
|
||||||
|
return (y > 0 && currentHeight >= GetHeight(x, y - 1) - 1);
|
||||||
|
|
||||||
|
case 'd':
|
||||||
|
newSpot = new Tuple<int, int>(x, y + 1);
|
||||||
|
return (y < heightmap.Count - 1 && currentHeight >= GetHeight(x, y + 1) - 1);
|
||||||
|
|
||||||
|
case 'l':
|
||||||
|
newSpot = new Tuple<int, int>(x - 1, y);
|
||||||
|
return (x > 0 && currentHeight >= GetHeight(x - 1, y) - 1);
|
||||||
|
|
||||||
|
case 'r':
|
||||||
|
newSpot = new Tuple<int, int>(x + 1, y);
|
||||||
|
return (x < heightmap[0].Count - 1 && currentHeight >= GetHeight(x + 1, y) - 1);
|
||||||
|
default:
|
||||||
|
throw new ArgumentException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<List<int>> heightmap = new List<List<int>>();
|
||||||
|
|
||||||
|
public static HeightMap LoadHeightMap(string filename, out Tuple<int, int> outStartPoint, out Tuple<int, int> outEndPoint)
|
||||||
|
{
|
||||||
|
HeightMap hm = new HeightMap();
|
||||||
|
Tuple<int, int>? startPoint = null;
|
||||||
|
Tuple<int, int>? endPoint = null;
|
||||||
|
|
||||||
|
using (StreamReader reader = System.IO.File.OpenText(filename))
|
||||||
|
{
|
||||||
|
while (!reader.EndOfStream)
|
||||||
|
{
|
||||||
|
string? line = reader.ReadLine();
|
||||||
|
if (line == null) throw new InvalidDataException();
|
||||||
|
|
||||||
|
List<int> row = new List<int>();
|
||||||
|
|
||||||
|
foreach (char c in line)
|
||||||
|
{
|
||||||
|
if (!char.IsLetter(c)) throw new InvalidDataException();
|
||||||
|
|
||||||
|
if (c == 'S')
|
||||||
|
{
|
||||||
|
row.Add('a' - 'a');
|
||||||
|
startPoint = new Tuple<int, int>(row.Count - 1, hm.heightmap.Count);
|
||||||
|
}
|
||||||
|
else if (c == 'E')
|
||||||
|
{
|
||||||
|
row.Add('z' - 'a');
|
||||||
|
endPoint = new Tuple<int, int>(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;
|
||||||
|
}
|
||||||
|
}
|
||||||
8
2022/Day12CSharp/Properties/launchSettings.json
Normal file
8
2022/Day12CSharp/Properties/launchSettings.json
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"profiles": {
|
||||||
|
"Day12CSharp": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"workingDirectory": "C:\\dev\\DevSandbox\\AdventOfCode\\2022\\Day12CSharp"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
5
2022/Day12CSharp/example-input.txt
Normal file
5
2022/Day12CSharp/example-input.txt
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
Sabqponm
|
||||||
|
abcryxxl
|
||||||
|
accszExk
|
||||||
|
acctuvwj
|
||||||
|
abdefghi
|
||||||
57
2022/Day12CSharp/problem.txt
Normal file
57
2022/Day12CSharp/problem.txt
Normal file
@@ -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?
|
||||||
41
2022/Day12CSharp/puzzle-input.txt
Normal file
41
2022/Day12CSharp/puzzle-input.txt
Normal file
@@ -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
|
||||||
10
2022/Day13CSharp/Day13CSharp.csproj
Normal file
10
2022/Day13CSharp/Day13CSharp.csproj
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
334
2022/Day13CSharp/Program.cs
Normal file
334
2022/Day13CSharp/Program.cs
Normal file
@@ -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<IComparable> 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<PacketPair> packetPairs)
|
||||||
|
{
|
||||||
|
int sum = 0, index = 1;
|
||||||
|
foreach (var packet in packetPairs)
|
||||||
|
{
|
||||||
|
if (packet.IsCorrectlyOrdered()) sum += index;
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return sum;
|
||||||
|
}
|
||||||
|
|
||||||
|
void InsertDividers(List<IComparable> packets)
|
||||||
|
{
|
||||||
|
PacketPair pair = GetDividers();
|
||||||
|
packets.Add(pair.Data.Item1);
|
||||||
|
packets.Add(pair.Data.Item2);
|
||||||
|
}
|
||||||
|
|
||||||
|
PacketPair GetDividers()
|
||||||
|
{
|
||||||
|
return new PacketPair("[[2]]", "[[6]]");
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrintPacketPairs(List<PacketPair> 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<IComparable> ReadPackets(string filename)
|
||||||
|
{
|
||||||
|
List<IComparable> packets = new List<IComparable>();
|
||||||
|
|
||||||
|
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<PacketPair> ReadPacketPairs(string filename)
|
||||||
|
{
|
||||||
|
List<PacketPair> packets = new List<PacketPair>();
|
||||||
|
|
||||||
|
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<IComparable, IComparable>(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<IComparable, IComparable> 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<IComparable> Values { get; set;} = new List<IComparable>();
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
8
2022/Day13CSharp/Properties/launchSettings.json
Normal file
8
2022/Day13CSharp/Properties/launchSettings.json
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"profiles": {
|
||||||
|
"Day13CSharp": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"workingDirectory": "C:\\dev\\DevSandbox\\AdventOfCode\\2022\\Day13CSharp"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
23
2022/Day13CSharp/example-input.txt
Normal file
23
2022/Day13CSharp/example-input.txt
Normal file
@@ -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]
|
||||||
449
2022/Day13CSharp/gen-input.txt
Normal file
449
2022/Day13CSharp/gen-input.txt
Normal file
@@ -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]]]
|
||||||
148
2022/Day13CSharp/problem.txt
Normal file
148
2022/Day13CSharp/problem.txt
Normal file
@@ -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?
|
||||||
449
2022/Day13CSharp/puzzle-input.txt
Normal file
449
2022/Day13CSharp/puzzle-input.txt
Normal file
@@ -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]]]
|
||||||
10
2022/Day14CSharp/Day14CSharp.csproj
Normal file
10
2022/Day14CSharp/Day14CSharp.csproj
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
264
2022/Day14CSharp/Program.cs
Normal file
264
2022/Day14CSharp/Program.cs
Normal file
@@ -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<Point, BlockType> CaveData = new Dictionary<Point, BlockType>();
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
8
2022/Day14CSharp/Properties/launchSettings.json
Normal file
8
2022/Day14CSharp/Properties/launchSettings.json
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"profiles": {
|
||||||
|
"Day14CSharp": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"workingDirectory": "C:\\dev\\DevSandbox\\AdventOfCode\\2022\\Day14CSharp"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
2
2022/Day14CSharp/example-input.txt
Normal file
2
2022/Day14CSharp/example-input.txt
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
498,4 -> 498,6 -> 496,6
|
||||||
|
503,4 -> 502,4 -> 502,9 -> 494,9
|
||||||
163
2022/Day14CSharp/problem.txt
Normal file
163
2022/Day14CSharp/problem.txt
Normal file
@@ -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?
|
||||||
148
2022/Day14CSharp/puzzle-input.txt
Normal file
148
2022/Day14CSharp/puzzle-input.txt
Normal file
@@ -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
|
||||||
10
2022/Day15CSharp/Day15CSharp.csproj
Normal file
10
2022/Day15CSharp/Day15CSharp.csproj
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
413
2022/Day15CSharp/Program.cs
Normal file
413
2022/Day15CSharp/Program.cs
Normal file
@@ -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<Point, Sensor> Sensors { get; set; } = new Dictionary<Point, Sensor>();
|
||||||
|
public Dictionary<Point, Beacon> Beacons { get; set; } = new Dictionary<Point, Beacon>();
|
||||||
|
|
||||||
|
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<int> searchSegments = new List<int>(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<int, bool> coverage = new Dictionary<int, bool>();
|
||||||
|
|
||||||
|
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<Point, bool> coverage = new Dictionary<Point, bool>();
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
8
2022/Day15CSharp/Properties/launchSettings.json
Normal file
8
2022/Day15CSharp/Properties/launchSettings.json
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"profiles": {
|
||||||
|
"Day15CSharp": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"workingDirectory": "C:\\dev\\DevSandbox\\AdventOfCode\\2022\\Day15CSharp"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
14
2022/Day15CSharp/example-input.txt
Normal file
14
2022/Day15CSharp/example-input.txt
Normal file
@@ -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
|
||||||
113
2022/Day15CSharp/problem.txt
Normal file
113
2022/Day15CSharp/problem.txt
Normal file
@@ -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?
|
||||||
29
2022/Day15CSharp/puzzle-input.txt
Normal file
29
2022/Day15CSharp/puzzle-input.txt
Normal file
@@ -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
|
||||||
10
2022/Day16CSharp/Day16CSharp.csproj
Normal file
10
2022/Day16CSharp/Day16CSharp.csproj
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
427
2022/Day16CSharp/Program.cs
Normal file
427
2022/Day16CSharp/Program.cs
Normal file
@@ -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<string,string> Value { get; set; }
|
||||||
|
|
||||||
|
public Step()
|
||||||
|
{
|
||||||
|
Type = StepType.First;
|
||||||
|
Value = new Tuple<string, string>("AA", "0");
|
||||||
|
}
|
||||||
|
|
||||||
|
public Step(string sourceValve, string targetValve)
|
||||||
|
{
|
||||||
|
Type = StepType.Move;
|
||||||
|
Value = new Tuple<string, string>(sourceValve, targetValve);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Step(string valvename, int stepNumber)
|
||||||
|
{
|
||||||
|
Type = StepType.Open;
|
||||||
|
Value = new Tuple<string, string>(valvename, stepNumber.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<Step> Steps { get; }
|
||||||
|
private Dictionary<string, bool> OpenedValves { get; }
|
||||||
|
|
||||||
|
private IReadOnlyDictionary<string, Valve> Valves { get; }
|
||||||
|
|
||||||
|
public bool isValveOpen(string valveName)
|
||||||
|
{
|
||||||
|
return OpenedValves.ContainsKey(valveName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public StepList(IReadOnlyDictionary<string, Valve> valves, int maxSteps = 31)
|
||||||
|
{
|
||||||
|
MaxSteps = maxSteps;
|
||||||
|
Valves = valves;
|
||||||
|
|
||||||
|
OpenedValves = new Dictionary<string, bool>();
|
||||||
|
Steps = new List<Step>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public StepList(StepList other)
|
||||||
|
{
|
||||||
|
MaxSteps = other.MaxSteps;
|
||||||
|
Valves = other.Valves;
|
||||||
|
|
||||||
|
OpenedValves = new Dictionary<string, bool>();
|
||||||
|
Steps = new List<Step>();
|
||||||
|
|
||||||
|
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<StepList> paths = new List<StepList>();
|
||||||
|
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<CaveNode> AdjacentNodes { get; set; } = new List<CaveNode>();
|
||||||
|
public List<int> AdjacentPathWeights { get; set; } = new List<int>();
|
||||||
|
|
||||||
|
public Valve Valve { get; }
|
||||||
|
|
||||||
|
public string Name
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return Valve.Name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int FlowRate
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return Valve.FlowRate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CompressNodes(CaveNode cn, List<Valve> targets, int currentWeight)
|
||||||
|
{
|
||||||
|
foreach (var v in targets)
|
||||||
|
{
|
||||||
|
if (v.FlowRate > 0)
|
||||||
|
{
|
||||||
|
cn.AdjacentNodes.Add(CaveNodes[v.Name]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Dictionary<string, CaveNode> CaveNodes { get; }
|
||||||
|
|
||||||
|
public CaveGraph(Dictionary<string, Valve> valves)
|
||||||
|
{
|
||||||
|
CaveNodes = new Dictionary<string, CaveNode>();
|
||||||
|
|
||||||
|
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<string, Valve>();
|
||||||
|
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<string, Valve> 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<Valve>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Valve> AdjacentValves
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int FlowRate { get; set; }
|
||||||
|
public string Name { get; }
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return String.Format("Valve: ({0}) Flow ({1}): ", Name, FlowRate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
8
2022/Day16CSharp/Properties/launchSettings.json
Normal file
8
2022/Day16CSharp/Properties/launchSettings.json
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"profiles": {
|
||||||
|
"Day16CSharp": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"workingDirectory": "C:\\dev\\DevSandbox\\AdventOfCode\\2022\\Day16CSharp"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
10
2022/Day16CSharp/example-input.txt
Normal file
10
2022/Day16CSharp/example-input.txt
Normal file
@@ -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
|
||||||
146
2022/Day16CSharp/problem.txt
Normal file
146
2022/Day16CSharp/problem.txt
Normal file
@@ -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?
|
||||||
58
2022/Day16CSharp/puzzle-input.txt
Normal file
58
2022/Day16CSharp/puzzle-input.txt
Normal file
@@ -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
|
||||||
10
2022/Day17CSharp/Day17CSharp.csproj
Normal file
10
2022/Day17CSharp/Day17CSharp.csproj
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user