@@ -73,6 +73,30 @@ done only once, but since re-ordering can result in a new conflict with another
7373page ordering rule, you might need to do this more often until all page ordering
7474rules are met!).
7575
76+ ## Day 6
77+ ** Part 1:** Solved part 1 right away. Using an integer encoded Dir enum (4
78+ values to represent up, right, down and left and convert that to a `@Vector(2,
79+ isize)` value with a helper method) helped a lot. A right turn is then just a
80+ ` +1 ` on the dir integer modulo 4 (use ` @intFromEnum ` ). My main work went into
81+ parsing the map and adding ANSI control sequence based animation. ` moveGuard `
82+ takes the guards position and checks if it would hit an obstacle (` # ` only for
83+ part 1), if so change the ` dir ` property with ` turnRight ` , otherwise move the
84+ guard into the current ` dir ` direction. Store all not-yet visited positions
85+ (used a copy of ` buffer ` first for this, after a fresh rewrite for part 2, I
86+ just used my then available ` VectorSet ` ), the count of thees is the result.
87+
88+ ** Part 2:** Initially I started implementing part 2 but didn't get the right
89+ result for my puzzle input (though it worked for the example input). So I
90+ left it for some time and came back after a few weeks to solve it. After
91+ wrapping my head around what I did before and where a potential bug could be, I
92+ went for a rewrite. Using my then available ` VectorSet ` to store the visited
93+ path of the guard and the history of the position + direction (encoded in a
94+ ` @Vector(3, isize) ` ), I finally got the correct answer. With ` VectorSet ` it was
95+ quite easy: store each guards position/direction combination for each step in a
96+ ` @Vector(3, isize) ` and use ` VectorSet.contains() ` to check if the guard has
97+ been on that position before (with the same direction). If that's the case, the
98+ guard moves in a loop.
99+
76100## Day 7
77101** Part1:** parse the equations and use recursion to check if any of the options
78102is valid.
0 commit comments