AoC 2016 Day 12: Assembunny

Source: Leonardo’s Monorail

Part 1: Create a virtual machine that has four registers (a, b, c, and d) and can process the following instructions:

  • cpy x y - copies x into y (x can be an integer or a register)
  • inc x - increases register x by one
  • dec x - decreases register x by one
  • jnz x y - jumps over y instructions if x is not zero (x can be an integer or a register)

What is the final value in register a?

read more...


AoC 2016 Day 11: Radiation Avoider

Source: Radioisotope Thermoelectric Generators

Part 1: Input will be a list of the following form:

  • The first floor contains a hydrogen-compatible microchip and a lithium-compatible microchip.
  • The second floor contains a hydrogen generator.
  • The third floor contains a lithium generator.
  • The fourth floor contains nothing relevant.

You have an elevator that can move exactly 1 or 2 items. You can only leave a microchip on a floor with a non-matching generator if a matching generator is also present.

Move all items to the top (4th) floor.

read more...


AoC 2016 Day 10: Bot Simulator

Source: Balance Bots

Part 1: Create a sorting machine using input of the following form:

  • value X goes to bot A - an input to bot A
  • bot A gives low to (bot|output) B and high to (bot|output) C - a sorter that takes two inputs and sends them to the specified bots or output channels

Find the bot that compares the values 17 and 61.

read more...


AoC 2016 Day 8: Tiny Screen Simulator

Source: Two-Factor Authentication

Part 1: Implement a 50x6 pixel screen with the following commands:

  • rect AxB turn on a rectangle of pixels in the top left corner
  • rotate row y=A by B rotates row A right by B pixels
  • rotate column x=A by B rotates column A down by B pixels

After a given sequence of commands, how many pixels are on?

read more...


AoC 2016 Day 4: Room Validator

Source: Security Through Obscurity1

Part 1: A room is described as a name, a sector ID, and a checksum as follows:

aaaaa-bbb-z-y-x-123[abxyz]

name: aaaaa-bbb-z-y-x sector ID: 123 checksum: abxyz


> A room is valid if the checksum contains the five most common letters if the name (ties broken alphabetically).





An interesting problem. The first thing that we have to do is parse the input:

```python
with open(args.input_file, 'r') as fin:
    for room in fin:
        m = re.match(r'([a-z-]+)-(\d+)\[([a-z]+)\]', room)
        name, sector_id, checksum = m.groups()

        ...

The next thing we want to do is generate a checksum (so we can see if it’s correct):

read more...