AoC 2016 Day 2: Pin Typer

Source: Bathroom Security

Part 1: Take a keypad with the following layout:

1 2 3 4 5 6 7 8 9


> Using the instructions UDLR for Up, Down, Left, and Right respectively, move a 'finger' around over the keypad. At the end of each line of instructions, output the current digit.





First, let's define the grid. We'll use the same trick with complex numbers as [last time]https://blog.jverkamp.com/2016/12/01/aoc-2016-day-1-taxicab-simulator/.

```python
grid = {
    '-1-1j': 1, '+0-1j': 2, '+1-1j': 3,
    '-1+0j': 4, '+0+0j': 5, '+1+0j': 6,
    '-1+1j': 7, '+0+1j': 8, '+1+1j': 9,
}

From there, we can move around the grid, make sure we don’t move off the end, and output a character at the end of each line:

read more...


Advent of Code: Day 24

Source

Part 1: Split a list of integers into three groups of equal sum. Find the grouping such that the smallest group has the least items, breaking ties by the smallest product for that group.

read more...


Advent of Code: Day 23

Source

Part 1: Create a simple virtual machine with two registers (a and b, non-negative integers) and six instructions:

  • hlf (a|b) - divide the given register by half, round down
  • tpl (a|b) - triple the given register
  • inc (a|b) - add 1 to the given register
  • jmp [+-]\d+ - jump forward/backwards by the given number of instructions
  • jie (a|b), [+-]\d+ - if the given register is even, jump
  • jio (a|b), [+-]\d+ - if the given register equals one, jump

read more...


Advent of Code: Day 21

Source

Part 1: Given a shop full of weapons (buy exactly one), armor (buy zero or one), and rings (buy 0, 1, or 2), determine the set of items that will defeat a given enemy for the minimum cost (see the original writeup for more details).

read more...


Advent of Code: Day 20

Source

Part 1: P(n) is defined such that for each number i, add 10i to any number divisible by i. Find the first value n such that P(n) is at least a given target number.

read more...