Intel's Ronler Acres Plant

Silicon Forest

Thursday, July 14, 2016

Simple Safecracking

TRPA Code of Ordinances SECRET DECODER RING
Since me Linux box is busted (again!), I'm reduced to working on little puzzle programs on CodinGame dot com. I just finished one that involved decrypting a simple message to reveal the combination to a mythical safe. The puzzle doesn't furnish much of an explanation, just this:
Find the safe combination. The only thing you find lying next to the safe is a note with a message that looks like gibberish.
The gibberish looks like this:
 Aol zhml jvtipuhapvu pz: zpe-mvby-zpe-mvby-aoyll
which isn't much help at all. Fortunately, there are several test cases, and examining the gibberish from these other cases reveals that they have certain commonalities. All examples have:

  • one colon
  • the same number of groups of letters before (to the left of) the colon 
  • the number of letters in each of these groups (before the colon) are the same all examples
  • all the groups of letters:
    • before the colon are separated by spaces
    • after the colon are:
      • separated by hyphens
      • relatively short (none as long as the long word on the left)
From this I deduce that the words before the colon are a message, what you might call a 'label', and the words to the right are digits of the combination written out as English words. Okay, that might be, but how do you decode this gibberish?
    You could start with the digits on the right, and starting with the length and the limited number of letters involved, 
efghnorsuvwxz
only 15,  you might be able to sort it out.
    What about the message on the left hand side? Just looking at the number of letters, I'm guessing it's 
"the safe combination is"
So I write my program to use my guess to decode the message. I read a letter of the gibberish clue, then use that letter as index into my decoder array, and store the corresponding letter from my guess into that slot. I don't get all the letters, but it might be enough to make an educated guess as what the answer might be.
    I take each word from the combination in the clue and translate as many letters as I can using my decoder array. Then I compare the result with the names of all the digits that have the same length, and I count how many letters match. The digit with the highest score becomes part of the answer.

    Now we get to the interesting part of this problem. A couple other people have also solved this puzzle using the same programming language: Go, so I took a look at their solutions. They had taken their decryption efforts to another level and figured out mathematical formula that was being used to translate the clue into gibberish and back again. It's a very simple formula take simple involves adding an offset to the encoded letter to get the original back again.
    I like my solution better, because, well, it's my solution, and second of all, I didn't have to figure out what the translation formula was, which means mine is not dependent on the mathematical formula being the same all the time. Matter of fact, I don't care what formula you are using, as long as you are doing simple letter substitution.

   Do I need to emphasize that this is a simple, nay, trivial, decryption problem, and working on it is only a form of recreation? I dunno, people take things so seriously these days, it's sometimes hard to tell the wheat from the chaff. Let me reiterate: this problem is chaff, but it's fun chaff.

P.S. I have no idea what TRPA stands for. The only web reference I found was the Tahoe Regional Planning Agency, and I don't think they are in the secret decoder ring business.

P.P.S. Kind of odd that the set of letters needed to write the names of the digits includes 5 of the last 6 letters of the alphabet, don'cha think?

2 comments:

Anonymous said...

Helpfull article ;) helped me solving the exercise

Chuck Pergiel said...

You were lucky. Coding Game deleted the link from my forum post. I didn't think I was giving anything away, but evidently they thought differently.