Source: Signals and Noise
Part 1: Given a list of strings, find the most common character in each position.
Part 1: Given a list of strings, find the most common character in each position.
Part 1: Generate a series of hashes: MD5(salt + index). For each hash starting with five zeros, write down the sixth character.
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):
Part 1: Given a list of sides, determine how many form valid triangles. (Hint: triangle inequality)
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:
Part 1: Starting at
0,0
and given a string ofL#
/R#
to turn left / right and move#
squares, where do you end up?