Once again, I've decided to semi-seriously take part in this year's Advent of Code. I'll be solving this year's puzzles in JavaScript.
Math.round()
vs.Math.floor()
- recursion in part two
Day 2: 1202 Program Alarm
- memory, instructions, instruction pointer
- tried to copy an Array by doing
arr.splice()
without args which doesn't work, went witharr.concat([])
instead
Day 3: Crossed Wires
- remeber Manhattan distance?
- tried to rewrite an ugly if-then (4 possible single-character options) into a switch-case, looked even uglier. fuck switch-case.
- TODO my variable/function naming sucks, how can we improve?
- TODO should we try visualizing the 'wires'? would that look cool?
Day 4: Secure Container
- reading and concentrating on the task was the hardest part, the implementation itself is quite trivial
- TODO tidy up
Day 6: Universal Orbit Map
- had to Google for part 2, decided on a pretty limited data structure for part 1 and didn't know how to quickly dig myself out of that
- figured finding common ancestor would be the way to go, if we're already traversing each object's path backward towards root, might as well return the paths & compare
- TODO do a couple more Tree, Graph, shortest-path, Dijkstra problems to remember / learn more
Day 7: Amplification Circuit
- figured I needed permutations, googled this blogpost for a quick JavaScript solution
- part 2 was much more difficult, because we need to keep track of memory & instruction pointer and crucially, leave the 'amplifier' waiting for next input
- decided I wanted to try a more object-oriented approach to defining an
Amplifier
with it's internal data & methods, end result currently looks a bit like FizzBuzz Enterprise Edition - TODO rewrite/grok permutation method
Day 8: Space Image Format
- playing with characters, but not much learned otherwise?
- TODO parsing integers in current solution, but we might go back to string form, as we don't really need integers right?