22 lines
1.3 KiB
Markdown
22 lines
1.3 KiB
Markdown
## Day 6: Trash Compactor
|
|
|
|
This marks the halfway point of the Advent of Code for this year, and so far, I've been really enjoying the whole process.
|
|
|
|
Puzzle 1, again, took 30 or so minutes. Puzzle 2, a little over an hour.
|
|
|
|
I did manage to do these back-to-back on the night of release (thanks to the extra time afforded by the weekend), even though it took me until after 2 AM to finish (that's OK, I don't have anything to do in the morning).
|
|
|
|
I initially tried to keep my parsing from Puzzle 1 for Puzzle 2, but after getting unexpected results, I could see the errors of my ways (the rows that the individual numbers appear in are not arbitrary and do not follow a simple patterns, like being aligned to the most or least significant digit). Going back to the drawing board, I realized that the key was to know where the break points are, and use them to trigger the necessary calculations. Finally, I needed to add the last result (after the `for`-loop exits).
|
|
|
|
One more general thing to note - I don't normally use `for`-loops in my work code (since we're mostly transforming arrays, we use `map` or `reduce`), so I've been enjoying the reliance on them (it reminds me of my early days writing BASIC).
|
|
|
|
Anyways, these were fun, I look forward to the rest of the puzzles!
|
|
|
|
### JS Solutions
|
|
|
|
```
|
|
cd js
|
|
node day06a.js
|
|
node day06b.js
|
|
```
|