The Nightmare’s Observers are on the brink of destruction by an army of undead. The Observers have been sending crows to the masters at the Bastion containing information critical to defeating this army of the dead. Unfortunately, the enemy noticed the reception of these crows, sent his forces to the Bastion and destroyed it.
In the rubble, you’ve found burnt books, torn scrolls, and smudged handwritten copies of all the messages. Each message was assigned an identifier and stored in triplicate (some master earned his black iron merit badge that day!), so you’re sure you have at least one copy of all of the important messages. Sadly however, the order of the messages was lost and some of the messages are completely unrelated!
Luckily you have the identifier of a single message that you know came from the Nightmare’s Observers. Can you put together the rest of the messages in order? Humanity is now in your hands. Save Vivinteros by determining the order of the messages sent by the Nightmare’s Observers!
Over stdin, you are provided with a JSON-formatted list of all messages received. A message consists of an identifier and a body.
In this case, an example message might be:
The next message might be:
This is a valid next message, because the SHA-256 HMAC of the message
hate using the key
Your input will be a JSON-formatted list of these messages, and your program will receive a command line argument that is the only message identifier you know to be valid and from the Nightmare’s Observers.
Your program should output the starting message and all of the messages that follow it in order (UTF-8 encoded).
The output should be in the form of a string containing the message’s bodies in the correct order with each word separated by a space (without spaces at the beginning or end).
[ ["9df38df03f2fa666615ae8337ff37b589e8f2b0cfb1359122982b1c1dbd2471b", "love"], ["7188d84b812e2692a25a5579e9b8bee488f0555b454c56ca4338d6c86d05b57b", "hate"], ["eac0a2e3d11c82f6ec77e7bfe9f69ad1939e26f564a0d3bc89921b950886c296", "Undead"], ["e19eace0b3359f43aee2836052c8eb2f6cffed1610a15a57f8970ae659210c21", "obsidian!"], ["7188d84b812e2692a25a5579e9b8bee488f0555b454c56ca4338d6c86d05b57b", "hate"], ["e06b63528a69d22a5375bc20c09b8ed82a6a5bb44ff79e77431618e896fe5c2c", "hugs!"] ]
Undead hate obsidian!
You'll need to Log in with GitHub to start this problem.