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:


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).


Number words

Today’s five minute post brought to you via Programming Praxis / Career Cup:

Given a positive integer, return all the ways that the integer can be represented by letters using the mapping 1 -> A, 2 -> B, …, 26 -> Z. For instance, the number 1234 can be represented by the words ABCD, AWD and LCD.


Decoding escaped Unicode strings

In one of my current research projects involving large amounts of Twitter data from a variety of countries, I came across an interesting problem. The Twitter stream is encoded as a series of JSON objects–each of which has been written out using ASCII characters. But not all of the Tweets (or even a majority in this case) can be represented with only ASCII. So what happens?

Well, it turns out that they encode the data as JSON strings with Unicode escape characters. So if we had the Russian hashtag #победазанами (victory is ours), that would be encoded as such: