Completed Day5 - Horrible parsing function but still works :)
This commit is contained in:
parent
7d0be1fec7
commit
fb41918b20
@ -132,26 +132,6 @@
|
||||
<ClCompile Include="src\days\day03.cpp" />
|
||||
<ClCompile Include="src\days\day04.cpp" />
|
||||
<ClCompile Include="src\days\day05.cpp" />
|
||||
<ClCompile Include="src\days\day06.cpp" />
|
||||
<ClCompile Include="src\days\day07.cpp" />
|
||||
<ClCompile Include="src\days\day08.cpp" />
|
||||
<ClCompile Include="src\days\day09.cpp" />
|
||||
<ClCompile Include="src\days\day10.cpp" />
|
||||
<ClCompile Include="src\days\day11.cpp" />
|
||||
<ClCompile Include="src\days\day12.cpp" />
|
||||
<ClCompile Include="src\days\day13.cpp" />
|
||||
<ClCompile Include="src\days\day14.cpp" />
|
||||
<ClCompile Include="src\days\day15.cpp" />
|
||||
<ClCompile Include="src\days\day16.cpp" />
|
||||
<ClCompile Include="src\days\day17.cpp" />
|
||||
<ClCompile Include="src\days\day18.cpp" />
|
||||
<ClCompile Include="src\days\day19.cpp" />
|
||||
<ClCompile Include="src\days\day20.cpp" />
|
||||
<ClCompile Include="src\days\day21.cpp" />
|
||||
<ClCompile Include="src\days\day22.cpp" />
|
||||
<ClCompile Include="src\days\day23.cpp" />
|
||||
<ClCompile Include="src\days\day24.cpp" />
|
||||
<ClCompile Include="src\days\day25.cpp" />
|
||||
<ClCompile Include="src\main.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
@ -33,66 +33,6 @@
|
||||
<ClCompile Include="src\days\day05.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\days\day07.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\days\day06.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\days\day08.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\days\day09.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\days\day10.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\days\day11.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\days\day12.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\days\day13.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\days\day14.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\days\day16.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\days\day15.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\days\day17.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\days\day18.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\days\day19.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\days\day20.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\days\day21.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\days\day22.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\days\day23.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\days\day24.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\days\day25.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="src\aoc2022.h">
|
||||
|
512
input/day05
512
input/day05
@ -0,0 +1,512 @@
|
||||
[Z] [W] [Z]
|
||||
[D] [M] [L] [P] [G]
|
||||
[S] [N] [R] [S] [F] [N]
|
||||
[N] [J] [W] [J] [F] [D] [F]
|
||||
[N] [H] [G] [J] [H] [Q] [H] [P]
|
||||
[V] [J] [T] [F] [H] [Z] [R] [L] [M]
|
||||
[C] [M] [C] [D] [F] [T] [P] [S] [S]
|
||||
[S] [Z] [M] [T] [P] [C] [D] [C] [D]
|
||||
1 2 3 4 5 6 7 8 9
|
||||
|
||||
move 3 from 9 to 6
|
||||
move 7 from 6 to 2
|
||||
move 1 from 1 to 5
|
||||
move 7 from 7 to 1
|
||||
move 3 from 9 to 7
|
||||
move 1 from 9 to 1
|
||||
move 1 from 7 to 2
|
||||
move 11 from 1 to 8
|
||||
move 9 from 8 to 2
|
||||
move 1 from 6 to 7
|
||||
move 3 from 7 to 3
|
||||
move 7 from 3 to 4
|
||||
move 9 from 8 to 7
|
||||
move 3 from 3 to 1
|
||||
move 2 from 5 to 2
|
||||
move 6 from 7 to 3
|
||||
move 1 from 1 to 7
|
||||
move 1 from 9 to 2
|
||||
move 1 from 5 to 3
|
||||
move 1 from 8 to 2
|
||||
move 2 from 7 to 5
|
||||
move 1 from 1 to 4
|
||||
move 3 from 5 to 8
|
||||
move 2 from 8 to 7
|
||||
move 1 from 8 to 9
|
||||
move 7 from 3 to 1
|
||||
move 8 from 2 to 5
|
||||
move 3 from 7 to 3
|
||||
move 1 from 5 to 1
|
||||
move 1 from 9 to 6
|
||||
move 1 from 7 to 4
|
||||
move 1 from 6 to 3
|
||||
move 1 from 7 to 1
|
||||
move 9 from 4 to 5
|
||||
move 8 from 1 to 2
|
||||
move 3 from 3 to 2
|
||||
move 1 from 1 to 6
|
||||
move 7 from 5 to 6
|
||||
move 1 from 1 to 5
|
||||
move 1 from 3 to 5
|
||||
move 21 from 2 to 3
|
||||
move 8 from 6 to 3
|
||||
move 5 from 4 to 9
|
||||
move 9 from 3 to 8
|
||||
move 17 from 3 to 5
|
||||
move 6 from 2 to 1
|
||||
move 2 from 9 to 1
|
||||
move 3 from 3 to 6
|
||||
move 3 from 2 to 5
|
||||
move 7 from 8 to 2
|
||||
move 3 from 6 to 9
|
||||
move 2 from 2 to 4
|
||||
move 1 from 2 to 6
|
||||
move 2 from 2 to 6
|
||||
move 2 from 6 to 5
|
||||
move 1 from 6 to 1
|
||||
move 2 from 2 to 7
|
||||
move 1 from 8 to 2
|
||||
move 4 from 9 to 1
|
||||
move 4 from 1 to 6
|
||||
move 1 from 8 to 5
|
||||
move 3 from 6 to 9
|
||||
move 1 from 9 to 1
|
||||
move 2 from 9 to 2
|
||||
move 4 from 4 to 5
|
||||
move 1 from 7 to 8
|
||||
move 1 from 7 to 5
|
||||
move 8 from 1 to 8
|
||||
move 1 from 1 to 9
|
||||
move 1 from 6 to 8
|
||||
move 2 from 2 to 6
|
||||
move 1 from 1 to 3
|
||||
move 1 from 2 to 5
|
||||
move 1 from 3 to 4
|
||||
move 3 from 9 to 4
|
||||
move 4 from 4 to 1
|
||||
move 29 from 5 to 1
|
||||
move 2 from 6 to 3
|
||||
move 2 from 3 to 5
|
||||
move 2 from 5 to 9
|
||||
move 7 from 8 to 1
|
||||
move 3 from 8 to 6
|
||||
move 6 from 1 to 6
|
||||
move 2 from 9 to 8
|
||||
move 2 from 5 to 3
|
||||
move 3 from 5 to 6
|
||||
move 2 from 5 to 6
|
||||
move 1 from 5 to 1
|
||||
move 2 from 3 to 9
|
||||
move 1 from 8 to 6
|
||||
move 1 from 8 to 3
|
||||
move 1 from 3 to 5
|
||||
move 5 from 1 to 5
|
||||
move 5 from 6 to 2
|
||||
move 25 from 1 to 9
|
||||
move 9 from 9 to 3
|
||||
move 7 from 6 to 8
|
||||
move 9 from 5 to 9
|
||||
move 2 from 6 to 5
|
||||
move 6 from 9 to 7
|
||||
move 1 from 6 to 8
|
||||
move 3 from 2 to 1
|
||||
move 3 from 8 to 1
|
||||
move 5 from 9 to 6
|
||||
move 3 from 9 to 1
|
||||
move 4 from 6 to 9
|
||||
move 2 from 7 to 4
|
||||
move 1 from 4 to 1
|
||||
move 1 from 6 to 2
|
||||
move 7 from 1 to 6
|
||||
move 1 from 9 to 8
|
||||
move 9 from 3 to 9
|
||||
move 5 from 1 to 7
|
||||
move 1 from 5 to 7
|
||||
move 3 from 1 to 7
|
||||
move 3 from 6 to 7
|
||||
move 8 from 9 to 1
|
||||
move 3 from 7 to 3
|
||||
move 1 from 5 to 6
|
||||
move 3 from 1 to 7
|
||||
move 4 from 1 to 4
|
||||
move 2 from 8 to 5
|
||||
move 1 from 4 to 2
|
||||
move 3 from 2 to 7
|
||||
move 2 from 6 to 4
|
||||
move 1 from 1 to 2
|
||||
move 18 from 7 to 5
|
||||
move 1 from 7 to 5
|
||||
move 1 from 2 to 3
|
||||
move 4 from 5 to 9
|
||||
move 1 from 2 to 1
|
||||
move 2 from 3 to 9
|
||||
move 2 from 3 to 4
|
||||
move 2 from 6 to 5
|
||||
move 1 from 8 to 3
|
||||
move 4 from 9 to 7
|
||||
move 1 from 1 to 9
|
||||
move 3 from 5 to 2
|
||||
move 2 from 8 to 6
|
||||
move 2 from 6 to 1
|
||||
move 5 from 5 to 7
|
||||
move 7 from 9 to 7
|
||||
move 11 from 5 to 9
|
||||
move 3 from 7 to 6
|
||||
move 6 from 4 to 9
|
||||
move 5 from 7 to 3
|
||||
move 6 from 3 to 6
|
||||
move 2 from 1 to 2
|
||||
move 2 from 4 to 9
|
||||
move 6 from 9 to 2
|
||||
move 1 from 7 to 5
|
||||
move 10 from 2 to 9
|
||||
move 4 from 9 to 4
|
||||
move 1 from 4 to 3
|
||||
move 31 from 9 to 3
|
||||
move 1 from 9 to 4
|
||||
move 6 from 3 to 8
|
||||
move 1 from 5 to 8
|
||||
move 5 from 6 to 4
|
||||
move 4 from 3 to 2
|
||||
move 1 from 4 to 6
|
||||
move 22 from 3 to 7
|
||||
move 6 from 4 to 7
|
||||
move 4 from 6 to 2
|
||||
move 8 from 8 to 1
|
||||
move 3 from 2 to 8
|
||||
move 2 from 1 to 9
|
||||
move 1 from 2 to 6
|
||||
move 3 from 2 to 5
|
||||
move 2 from 5 to 4
|
||||
move 2 from 6 to 4
|
||||
move 24 from 7 to 4
|
||||
move 1 from 7 to 4
|
||||
move 2 from 1 to 5
|
||||
move 2 from 9 to 6
|
||||
move 10 from 4 to 6
|
||||
move 3 from 1 to 6
|
||||
move 6 from 7 to 1
|
||||
move 2 from 2 to 3
|
||||
move 1 from 7 to 4
|
||||
move 2 from 8 to 4
|
||||
move 1 from 8 to 5
|
||||
move 4 from 5 to 2
|
||||
move 5 from 4 to 1
|
||||
move 2 from 7 to 8
|
||||
move 2 from 8 to 4
|
||||
move 5 from 6 to 3
|
||||
move 2 from 4 to 3
|
||||
move 1 from 7 to 5
|
||||
move 2 from 3 to 6
|
||||
move 1 from 5 to 1
|
||||
move 3 from 6 to 8
|
||||
move 11 from 4 to 3
|
||||
move 7 from 6 to 1
|
||||
move 3 from 8 to 1
|
||||
move 1 from 2 to 3
|
||||
move 2 from 6 to 9
|
||||
move 2 from 2 to 3
|
||||
move 3 from 4 to 3
|
||||
move 2 from 9 to 4
|
||||
move 1 from 6 to 3
|
||||
move 5 from 1 to 2
|
||||
move 2 from 4 to 3
|
||||
move 24 from 3 to 7
|
||||
move 3 from 3 to 9
|
||||
move 1 from 2 to 6
|
||||
move 1 from 2 to 5
|
||||
move 1 from 6 to 1
|
||||
move 4 from 2 to 1
|
||||
move 2 from 9 to 2
|
||||
move 1 from 2 to 4
|
||||
move 18 from 7 to 5
|
||||
move 1 from 2 to 1
|
||||
move 1 from 9 to 1
|
||||
move 2 from 5 to 7
|
||||
move 13 from 1 to 8
|
||||
move 3 from 4 to 9
|
||||
move 7 from 1 to 7
|
||||
move 13 from 7 to 6
|
||||
move 1 from 9 to 5
|
||||
move 3 from 4 to 3
|
||||
move 1 from 9 to 8
|
||||
move 3 from 1 to 3
|
||||
move 1 from 9 to 5
|
||||
move 2 from 1 to 4
|
||||
move 2 from 7 to 3
|
||||
move 4 from 3 to 1
|
||||
move 1 from 1 to 5
|
||||
move 9 from 6 to 7
|
||||
move 5 from 7 to 1
|
||||
move 2 from 4 to 1
|
||||
move 4 from 6 to 1
|
||||
move 3 from 5 to 3
|
||||
move 3 from 3 to 5
|
||||
move 7 from 1 to 6
|
||||
move 6 from 6 to 1
|
||||
move 1 from 6 to 8
|
||||
move 2 from 7 to 9
|
||||
move 2 from 1 to 5
|
||||
move 1 from 3 to 7
|
||||
move 7 from 5 to 9
|
||||
move 10 from 1 to 5
|
||||
move 8 from 8 to 4
|
||||
move 6 from 4 to 8
|
||||
move 1 from 4 to 1
|
||||
move 2 from 9 to 8
|
||||
move 2 from 1 to 3
|
||||
move 2 from 7 to 3
|
||||
move 1 from 7 to 8
|
||||
move 4 from 3 to 8
|
||||
move 1 from 3 to 2
|
||||
move 20 from 5 to 8
|
||||
move 1 from 2 to 4
|
||||
move 4 from 9 to 4
|
||||
move 4 from 4 to 5
|
||||
move 18 from 8 to 6
|
||||
move 3 from 9 to 6
|
||||
move 1 from 3 to 9
|
||||
move 10 from 8 to 7
|
||||
move 7 from 7 to 9
|
||||
move 7 from 8 to 5
|
||||
move 3 from 7 to 8
|
||||
move 6 from 5 to 1
|
||||
move 6 from 9 to 4
|
||||
move 1 from 9 to 6
|
||||
move 1 from 3 to 6
|
||||
move 1 from 8 to 5
|
||||
move 1 from 9 to 4
|
||||
move 12 from 6 to 7
|
||||
move 5 from 7 to 1
|
||||
move 6 from 8 to 5
|
||||
move 1 from 5 to 1
|
||||
move 3 from 5 to 3
|
||||
move 8 from 4 to 9
|
||||
move 2 from 3 to 7
|
||||
move 4 from 7 to 2
|
||||
move 10 from 5 to 6
|
||||
move 11 from 1 to 6
|
||||
move 4 from 2 to 5
|
||||
move 1 from 3 to 8
|
||||
move 1 from 8 to 9
|
||||
move 1 from 4 to 7
|
||||
move 3 from 7 to 4
|
||||
move 1 from 1 to 6
|
||||
move 1 from 4 to 7
|
||||
move 1 from 7 to 1
|
||||
move 4 from 5 to 2
|
||||
move 3 from 7 to 1
|
||||
move 2 from 4 to 8
|
||||
move 20 from 6 to 8
|
||||
move 4 from 1 to 5
|
||||
move 2 from 5 to 2
|
||||
move 6 from 6 to 1
|
||||
move 5 from 1 to 8
|
||||
move 7 from 6 to 2
|
||||
move 6 from 9 to 7
|
||||
move 2 from 9 to 8
|
||||
move 2 from 7 to 4
|
||||
move 4 from 2 to 6
|
||||
move 3 from 5 to 8
|
||||
move 12 from 8 to 7
|
||||
move 1 from 4 to 3
|
||||
move 1 from 2 to 9
|
||||
move 1 from 9 to 2
|
||||
move 1 from 6 to 8
|
||||
move 1 from 3 to 1
|
||||
move 2 from 1 to 6
|
||||
move 1 from 4 to 2
|
||||
move 3 from 6 to 2
|
||||
move 2 from 5 to 7
|
||||
move 1 from 9 to 8
|
||||
move 6 from 2 to 4
|
||||
move 17 from 7 to 1
|
||||
move 10 from 1 to 7
|
||||
move 4 from 2 to 6
|
||||
move 10 from 7 to 8
|
||||
move 3 from 6 to 2
|
||||
move 4 from 4 to 1
|
||||
move 2 from 6 to 4
|
||||
move 4 from 2 to 6
|
||||
move 1 from 7 to 1
|
||||
move 2 from 4 to 3
|
||||
move 12 from 1 to 7
|
||||
move 5 from 6 to 3
|
||||
move 17 from 8 to 2
|
||||
move 4 from 3 to 8
|
||||
move 1 from 4 to 2
|
||||
move 20 from 8 to 7
|
||||
move 19 from 2 to 6
|
||||
move 7 from 6 to 3
|
||||
move 7 from 3 to 5
|
||||
move 2 from 5 to 7
|
||||
move 4 from 6 to 9
|
||||
move 1 from 4 to 2
|
||||
move 1 from 2 to 1
|
||||
move 2 from 3 to 6
|
||||
move 1 from 2 to 6
|
||||
move 1 from 3 to 1
|
||||
move 4 from 6 to 2
|
||||
move 1 from 5 to 9
|
||||
move 7 from 7 to 3
|
||||
move 7 from 3 to 8
|
||||
move 5 from 8 to 1
|
||||
move 2 from 8 to 3
|
||||
move 1 from 2 to 1
|
||||
move 3 from 5 to 6
|
||||
move 1 from 3 to 9
|
||||
move 2 from 9 to 2
|
||||
move 8 from 1 to 7
|
||||
move 3 from 7 to 6
|
||||
move 2 from 2 to 4
|
||||
move 21 from 7 to 3
|
||||
move 10 from 3 to 1
|
||||
move 2 from 9 to 2
|
||||
move 7 from 3 to 4
|
||||
move 3 from 3 to 7
|
||||
move 4 from 2 to 3
|
||||
move 3 from 7 to 8
|
||||
move 1 from 3 to 6
|
||||
move 1 from 3 to 2
|
||||
move 4 from 7 to 9
|
||||
move 10 from 1 to 6
|
||||
move 1 from 5 to 9
|
||||
move 6 from 7 to 2
|
||||
move 24 from 6 to 5
|
||||
move 2 from 8 to 4
|
||||
move 1 from 8 to 6
|
||||
move 2 from 2 to 9
|
||||
move 5 from 2 to 7
|
||||
move 1 from 2 to 9
|
||||
move 11 from 4 to 1
|
||||
move 3 from 3 to 2
|
||||
move 4 from 9 to 7
|
||||
move 1 from 1 to 5
|
||||
move 1 from 6 to 1
|
||||
move 5 from 1 to 9
|
||||
move 5 from 9 to 7
|
||||
move 5 from 7 to 5
|
||||
move 23 from 5 to 2
|
||||
move 5 from 7 to 8
|
||||
move 6 from 5 to 6
|
||||
move 1 from 3 to 7
|
||||
move 1 from 5 to 7
|
||||
move 6 from 7 to 8
|
||||
move 3 from 6 to 1
|
||||
move 2 from 8 to 7
|
||||
move 4 from 2 to 1
|
||||
move 4 from 8 to 5
|
||||
move 7 from 2 to 3
|
||||
move 1 from 7 to 4
|
||||
move 1 from 4 to 7
|
||||
move 4 from 3 to 8
|
||||
move 6 from 1 to 9
|
||||
move 4 from 8 to 6
|
||||
move 3 from 1 to 5
|
||||
move 3 from 8 to 5
|
||||
move 1 from 1 to 8
|
||||
move 3 from 9 to 1
|
||||
move 3 from 6 to 7
|
||||
move 1 from 7 to 9
|
||||
move 3 from 8 to 3
|
||||
move 8 from 5 to 7
|
||||
move 11 from 2 to 8
|
||||
move 5 from 8 to 3
|
||||
move 1 from 8 to 7
|
||||
move 10 from 3 to 4
|
||||
move 2 from 5 to 8
|
||||
move 3 from 9 to 2
|
||||
move 1 from 9 to 6
|
||||
move 7 from 2 to 7
|
||||
move 6 from 9 to 4
|
||||
move 1 from 8 to 5
|
||||
move 3 from 6 to 8
|
||||
move 1 from 5 to 3
|
||||
move 2 from 3 to 1
|
||||
move 6 from 1 to 3
|
||||
move 13 from 7 to 5
|
||||
move 16 from 4 to 3
|
||||
move 2 from 1 to 5
|
||||
move 5 from 5 to 4
|
||||
move 11 from 3 to 4
|
||||
move 2 from 7 to 1
|
||||
move 7 from 3 to 1
|
||||
move 2 from 8 to 3
|
||||
move 8 from 1 to 9
|
||||
move 12 from 4 to 8
|
||||
move 1 from 1 to 4
|
||||
move 2 from 6 to 2
|
||||
move 3 from 7 to 8
|
||||
move 2 from 4 to 6
|
||||
move 5 from 8 to 1
|
||||
move 3 from 7 to 5
|
||||
move 6 from 5 to 7
|
||||
move 2 from 2 to 5
|
||||
move 1 from 4 to 9
|
||||
move 5 from 1 to 8
|
||||
move 6 from 3 to 1
|
||||
move 7 from 5 to 7
|
||||
move 7 from 9 to 2
|
||||
move 1 from 6 to 7
|
||||
move 1 from 1 to 9
|
||||
move 2 from 5 to 3
|
||||
move 2 from 9 to 6
|
||||
move 13 from 7 to 3
|
||||
move 2 from 6 to 1
|
||||
move 1 from 9 to 2
|
||||
move 16 from 8 to 7
|
||||
move 6 from 8 to 5
|
||||
move 3 from 2 to 5
|
||||
move 4 from 2 to 1
|
||||
move 3 from 1 to 8
|
||||
move 2 from 8 to 9
|
||||
move 1 from 8 to 7
|
||||
move 1 from 2 to 1
|
||||
move 8 from 3 to 1
|
||||
move 1 from 4 to 5
|
||||
move 1 from 6 to 3
|
||||
move 2 from 9 to 7
|
||||
move 5 from 1 to 4
|
||||
move 15 from 7 to 9
|
||||
move 11 from 9 to 3
|
||||
move 7 from 1 to 3
|
||||
move 2 from 1 to 6
|
||||
move 1 from 6 to 3
|
||||
move 2 from 4 to 5
|
||||
move 2 from 4 to 9
|
||||
move 7 from 5 to 9
|
||||
move 5 from 9 to 3
|
||||
move 1 from 1 to 6
|
||||
move 5 from 5 to 9
|
||||
move 1 from 4 to 8
|
||||
move 1 from 8 to 4
|
||||
move 3 from 7 to 4
|
||||
move 8 from 9 to 5
|
||||
move 1 from 6 to 4
|
||||
move 4 from 9 to 3
|
||||
move 1 from 9 to 3
|
||||
move 23 from 3 to 1
|
||||
move 12 from 1 to 2
|
||||
move 6 from 1 to 9
|
||||
move 5 from 9 to 7
|
||||
move 3 from 3 to 7
|
||||
move 6 from 4 to 3
|
||||
move 1 from 6 to 8
|
||||
move 6 from 1 to 2
|
||||
move 3 from 7 to 3
|
||||
move 3 from 2 to 5
|
||||
move 10 from 3 to 5
|
||||
move 1 from 1 to 8
|
||||
move 12 from 2 to 5
|
||||
move 3 from 2 to 9
|
||||
move 2 from 8 to 4
|
||||
move 13 from 5 to 1
|
||||
move 2 from 9 to 2
|
||||
move 2 from 1 to 3
|
||||
move 11 from 3 to 1
|
||||
move 2 from 2 to 1
|
||||
move 2 from 1 to 9
|
||||
move 16 from 1 to 7
|
||||
move 17 from 5 to 8
|
||||
move 1 from 1 to 2
|
||||
move 3 from 9 to 6
|
@ -1,11 +1,133 @@
|
||||
#include "../aoc2022.h"
|
||||
|
||||
enum EMoveType {
|
||||
eManual,
|
||||
eCrateMover9001
|
||||
};
|
||||
|
||||
template <typename Output>
|
||||
struct SDay05 : public SDay<Output> {
|
||||
//Class constructor
|
||||
using SDay<Output>::SDay;
|
||||
|
||||
std::vector<std::stack<char>> stacks;
|
||||
|
||||
//Solutions to both days
|
||||
Output part1() override final { return Output(); }
|
||||
Output part2() override final { return Output(); }
|
||||
Output part1() override final {
|
||||
parseStacks();
|
||||
runInstructions(eManual);
|
||||
std::string ans = getTops();
|
||||
return 0;
|
||||
}
|
||||
Output part2() override final {
|
||||
parseStacks();
|
||||
runInstructions(eCrateMover9001);
|
||||
std::string ans = getTops();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void parseStacks() {
|
||||
stacks.clear();
|
||||
this->input.clear();
|
||||
this->input.seekg(0, std::ios::beg);
|
||||
std::stack<std::string> stackStrings;
|
||||
int stackCount{ 0 };
|
||||
std::string line{ "" };
|
||||
|
||||
while (std::getline(this->input, line))
|
||||
{
|
||||
if (line == "")
|
||||
break; //We have finished collecting stack strings
|
||||
stackStrings.push(line);
|
||||
}
|
||||
|
||||
//Get the number of stacks needed
|
||||
line = stackStrings.top();
|
||||
stackCount = line[line.size()-2]-48;
|
||||
stackStrings.pop();
|
||||
|
||||
for (int i = 0; i < stackCount; i++)
|
||||
stacks.push_back(std::stack<char>());
|
||||
|
||||
int index = 1;
|
||||
while (!stackStrings.empty())
|
||||
{
|
||||
line = stackStrings.top();
|
||||
int index = 1;
|
||||
for (int i = 0; i < stackCount; i++)
|
||||
{
|
||||
if (line[index] != ' ')
|
||||
stacks[i].push(line[index]);
|
||||
index += 4;
|
||||
}
|
||||
stackStrings.pop();
|
||||
}
|
||||
}
|
||||
|
||||
void runInstructions(EMoveType moveType) {
|
||||
std::string line{ "" };
|
||||
|
||||
while (std::getline(this->input, line))
|
||||
{
|
||||
std::stringstream ss;
|
||||
std::vector<int> nums;
|
||||
|
||||
/* Storing the whole string into string stream */
|
||||
ss << line;
|
||||
|
||||
/* Running loop till the end of the stream */
|
||||
std::string temp;
|
||||
int found;
|
||||
while (!ss.eof()) {
|
||||
|
||||
/* extracting word by word from stream */
|
||||
ss >> temp;
|
||||
|
||||
/* Checking the given word is integer or not */
|
||||
if (std::stringstream(temp) >> found)
|
||||
nums.push_back(found);
|
||||
|
||||
/* To save from space at the end of string */
|
||||
temp = "";
|
||||
}
|
||||
|
||||
moveCrates(moveType, nums);
|
||||
}
|
||||
}
|
||||
|
||||
void moveCrates(EMoveType moveType, const std::vector<int> &nums) {
|
||||
//run each step
|
||||
std::stack<char> tempStack;
|
||||
for (int i = 0; i < nums[0]; i++)
|
||||
{
|
||||
if (stacks[static_cast<size_t>(nums[1]) - 1].empty())
|
||||
break;
|
||||
if (moveType == eCrateMover9001)
|
||||
{
|
||||
tempStack.push(stacks[static_cast<size_t>(nums[1]) - 1].top());
|
||||
}
|
||||
else
|
||||
stacks[static_cast<size_t>(nums[2]) - 1].push(stacks[static_cast<size_t>(nums[1]) - 1].top());
|
||||
|
||||
stacks[static_cast<size_t>(nums[1]) - 1].pop();
|
||||
}
|
||||
|
||||
if (moveType == eCrateMover9001)
|
||||
{
|
||||
while (!tempStack.empty())
|
||||
{
|
||||
stacks[static_cast<size_t>(nums[2]) - 1].push(tempStack.top());
|
||||
tempStack.pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::string getTops() {
|
||||
std::string output;
|
||||
for (auto& stack : stacks)
|
||||
{
|
||||
output += stack.top();
|
||||
}
|
||||
return output;
|
||||
}
|
||||
};
|
53
src/main.cpp
53
src/main.cpp
@ -1,33 +1,32 @@
|
||||
#include "days/days.h"
|
||||
|
||||
template <typename Output>
|
||||
void runSolutions() {
|
||||
//Heap allocate all solutions
|
||||
std::vector<SDay<Output>*> solutions = {
|
||||
new SDay01<Output>("day01"),
|
||||
new SDay02<Output>("day02"),
|
||||
new SDay03<Output>("day03"),
|
||||
new SDay04<Output>("day04"),
|
||||
new SDay05<Output>("day05"),
|
||||
new SDay06<Output>("day06"),
|
||||
new SDay07<Output>("day07"),
|
||||
new SDay08<Output>("day08"),
|
||||
new SDay09<Output>("day09"),
|
||||
new SDay11<Output>("day11"),
|
||||
new SDay12<Output>("day12"),
|
||||
new SDay13<Output>("day13"),
|
||||
new SDay14<Output>("day14"),
|
||||
new SDay15<Output>("day15"),
|
||||
new SDay16<Output>("day16"),
|
||||
new SDay17<Output>("day17"),
|
||||
new SDay18<Output>("day18"),
|
||||
new SDay19<Output>("day19"),
|
||||
new SDay20<Output>("day20"),
|
||||
new SDay21<Output>("day21"),
|
||||
new SDay22<Output>("day22"),
|
||||
new SDay23<Output>("day23"),
|
||||
new SDay24<Output>("day24"),
|
||||
new SDay25<Output>("day25")
|
||||
std::vector<SDay<int>*> solutions = {
|
||||
new SDay01<int>("day01"),
|
||||
new SDay02<int>("day02"),
|
||||
new SDay03<int>("day03"),
|
||||
new SDay04<int>("day04"),
|
||||
new SDay05<int>("day05"),
|
||||
new SDay06<int>("day06"),
|
||||
new SDay07<int>("day07"),
|
||||
new SDay08<int>("day08"),
|
||||
new SDay09<int>("day09"),
|
||||
new SDay11<int>("day11"),
|
||||
new SDay12<int>("day12"),
|
||||
new SDay13<int>("day13"),
|
||||
new SDay14<int>("day14"),
|
||||
new SDay15<int>("day15"),
|
||||
new SDay16<int>("day16"),
|
||||
new SDay17<int>("day17"),
|
||||
new SDay18<int>("day18"),
|
||||
new SDay19<int>("day19"),
|
||||
new SDay20<int>("day20"),
|
||||
new SDay21<int>("day21"),
|
||||
new SDay22<int>("day22"),
|
||||
new SDay23<int>("day23"),
|
||||
new SDay24<int>("day24"),
|
||||
new SDay25<int>("day25")
|
||||
};
|
||||
|
||||
for (auto& solution : solutions)
|
||||
@ -58,5 +57,5 @@ void runSolutions() {
|
||||
}
|
||||
|
||||
int main() {
|
||||
runSolutions<int>();
|
||||
runSolutions();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user