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.

read more...


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.

read more...


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

read more...


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:
  3. Reverse the first length elements of the list (starting at current_position)
  4. Move forward by length plus skip_size
  5. 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)?

read more...


AoC 2017 Day 9: Garbage Gobbler

Source: Stream Processing

Part 1: An input stream can contain:

  • groups are delimited by { and }, groups are nestable and may contain garbage or data (objects within a group are comma delimited)
  • garbage is delimited by < and >, groups cannot be nested within garbage, a ! within garbage is an escape character: !> does not end a garbage segment

The score of a single group is equal to how many times it is nested (the innermost group of {{{}}} has score 3).

The score of a stream is the sum of the scores of all groups in that stream.

What is the total score of your input?

read more...


AoC 2017 Day 7: Tree

Source: Recursive Circus

Part 1: A tree is defined as such:

  • node (weight) -> child1, child2, ...
  • node (weight)

Where a node always has a weight, but may or may not have child nodes.

What is the name of the root node of the tree (the node without a parent)?

read more...