Home

Awesome

Advent Of Code

Puzzles from Advent of Code solved using Go.

My goal is to resolve problems on release day. Then, I refactor my code in order to have clean code, even if it means losing slightly in performance.

Commands

2023

Execution time with :

DayGoPart1Part2Comment
1**0.039ms1.51ms
2**0.44ms0.47ms
3**0.42ms0.55msFinding the numbers in the grid, then the symbols that are adjacent to them.
4**0.53ms0.52ms
5**0.12ms1.24msUsing intervals, implementing the splitOn method to split the interval before shifting it.
6**0.002ms47.2msNaive resolution, without calculating roots or binary search.
7**7.35ms7.59msUsing '*' instead of 'J' to represent jokers. Sorting with sort.Slice.
8**0.98ms3.96msUsing LCM (Least Common Multiple) (doesn't work for general inputs, works here because the cycle length on each path is the same).
9**1.20ms1.21msResolution without recursion.
10**6.11ms30.6msRepresentation of a pipe by a set of directions. Using ray tracing for part 2. With visualization for part 2.
11**3.89ms3.80ms
12**11.8ms117msUsing dynamic programming.
13**0.30ms0.31msUsing binary number to represent each line (in order to reduce execution time when comparing 2 lines).
14**2.30ms914msUsing memoization to avoid redundant cycles.
15**0.14ms1.17ms
16**5.55ms1217msPart 2 in brute force. With visualization for part 1.
17**519ms1844msUsing A* algorithm (Implementation of IntPriorityQueue in utils).
18**0.11ms0.13msUsing Shoelace formula and Pick's theorem.
19**1.07ms2.06msParsing with fmt.SscanfUsing. Using intervals for part 2.
20*15.6msTODO (Part 2 not yet started).
21*21.3msTODO (Reflection done, implementation to be done).
22**12.7ms118msSettling bricks from bottom to top, knowing the bricks directly below and above it.
23**17.8ms1310msTransforming the grid into a graph (directed for part 1 and undirected for part 2) using Breadth First Search, and then getting the length of the longest simple path using Depth First Search.
24*2.56msTODO (Part 2 : nonlinear system of 9 equations with 9 unknowns found, look for a solver in Go or linearize the system).
25*21.5msSeparating the graph into 2 groups by calculating the shortest path between 2 vertices (with BFS), removing edges from this path, and repeating this 3 times (The minimum cut cardinality is 3 according to the puzzle). If there is no 4th path, the 2 vertices are in a different group and the new graph is cut, otherwise start again with a new vertex. Then finding the vertices belonging to the first group using BFS.
Total46*4 stars missing: parts 2 of days 21, 22, 24 (and 25).