# AoC 2017 Day 15: Two Generators

### Source: Dueling Generators

Part 1: Create a pair of generators A and B where:

• A_n = 16807 A_{n-1} \mod 2147483647
• B_n = 48271 B_{n-1} \mod 2147483647

How many of the first 40 million values have matching values for the low 16 bits of each generator?

# AoC 2017 Day 14: Knot Hash Gridinator

### Source: Disk Defragmentation

Part 1: Create a 128x128 grid. Generate each row by taking the knot hash of salt-{index}. The bits of the hash represent if a tile in the grid is free (0) or used (1).

Given your salt as input, how many squares are used?

# AoC 2017 Day 13: Firewall Puncher

### Source: Packet Scanners

Part 1: Multiple layers are defined with rules of the form:

• {index}: {depth}

Each layer will start at position 0, then once per tick will advance towards depth. Once it hits depth-1, it will return to position 0, taking 2*depth-1 per full cycle.

Calculate the sum of index * depth for any scanners that are at position 0 when you pass through them given an initial starting time.

# Dynamic Automatic Proxies

On of the advantages of working in computer programming is that I can work from anywhere I have a computer and an internet connection. One of the disadvantages is that many of the resources that I need to do my job are locked to only be accessible within a specific network (albeit with a bastion host).

I long ago set up my SSH config to create an SSH tunnel and I can proxy many applications through that just by setting the HTTP_PROXY and/or HTTPS_PROXY environment variables. The downside of this though is that if I’m actually on a ‘safe’ network, there’s no reason to use the bastion host and I would actually be putting extra load on it.

My goal: write something that would let me automatically proxy applications when I need to but not when I don’t.

# Men at Arms

Continuing the story of Guards! Guards!, Men at Arms follows all of my favorite characters from that former on a grand new adventure (of sorts).

We have Corporal Carrot:

# AoC 2017 Day 12: Gridlock

### Source: Digital Plumber

Part 1: A network of nodes is defined by a list of lines formatted as such:

2 <-> 0, 3, 4


In this case, node 2 is connected to 0, 3, and 4 and vice versa.

How many nodes are in the group that contains the node 0?

# AoC 2017 Day 11: It's Full Of Hexagons

### Source: Hex Ed1

Part 1: Work on a hex grid:

  \ n  /
nw +--+ ne
/    \
-+      +-
\    /
sw +--+ se
/ s  \


Given a series of steps (n, se, ne) etc, how many steps away from the origin do you end up?

# Deterministic Shuffling Using Hashes

Whenever I create my yearly reading list, I need a way to order the books. Sure, I could just shuffle them normally, but that leads me to the temptation of cheating and re-shuffling them so that the books I want to read most are first. What I really need is a shuffle that will shuffle the same way every time.

Enter: hashsort

# AoC 2017 Day 10: Knot Cool

### Source: Knot Hash

Part 1: Starting with a list of the numbers from 1 to n and a list of lengths (as input):

1. Initialize current_position and skip_size to 0
2. For each length element in the lengths list:
1. Reverse the first length elements of the list (starting at current_position)
2. Move forward by length plus skip_size
3. Increment skip_size by 1

After applying the above algorithm, what is the product of the first two elements in the list (from the original first position, not the current_position)?

# Migrating to Hugo

A long time ago1, in a galaxy far, far away2, I moved my blog from WordPress to a custom written static blog generator in Racket. And for a while, all was well.