Skip to content

Instantly share code, notes, and snippets.

@axiomsofchoice
Created November 19, 2016 17:40
Show Gist options
  • Save axiomsofchoice/8bf678283ff36b3d7cbfc09fc2d402fc to your computer and use it in GitHub Desktop.
Save axiomsofchoice/8bf678283ff36b3d7cbfc09fc2d402fc to your computer and use it in GitHub Desktop.
#GCHQpuzzlebook solution
# Solution to http://www.bbc.co.uk/programmes/articles/5m5cv4NM5dWx108YgCQXj9J/can-you-crack-gchqs-code-breaker-challenge
# By Dan Hagon, 19/11/2016.
# CC0 License.
samuel_lines = [
# 2 7 9 2 5 2 2 5 3 8 2 6 7
"IN AAAAIAN INAAANAIA IA IAINA AI AA IAIIA IAA AAIAAINN AA IAAANN IAINANI",
"NA ANNNNMA NAANIANMN NN ANNAN NN AM MNNNN ANI MAAINNIA AM NNAMIA NNAANIN",
"AM MMIAAMA MMIMAAMMA MM AMAAA MA AM AAAMA AAA MAMAAAAM AM AAIMMM MMMMAMA"
]
# https://en.wikipedia.org/wiki/Morse_code
morse_lut = {
'I': "..",
'A': ".-",
'N': "-.",
'M': "--",
' ': " "
}
louis_line = ["".join([morse_lut[dot_dash] for dot_dash in c]) \
for c in [[samuel_lines[0][i], samuel_lines[1][i], samuel_lines[2][i]] \
for i in range(len(samuel_lines[0]))]]
#print sorted(set(louis_line))
# https://en.wikipedia.org/wiki/Braille
braille_lut = {
' ': ' ',
'-..---': 'I',
'-..-.-': 'S',
'-...--': 'J',
'-....-': 'T',
'.-----': 'A',
'.--.--': 'E',
'.--..-': 'O',
'.--...': 'Z',
'.-.---': 'B',
'.-.-.-': 'L',
'.-.-..': 'V',
'.-...-': 'R',
'..----': 'C',
'..--.-': 'M',
'..-.--': 'D',
'..-..-': 'N',
'...---': 'F',
'...-.-': 'P'
}
# https://en.wikipedia.org/wiki/L._L._Zamenhof (inventor of Esperanto)
ludwik_line = "".join([braille_lut[c] for c in louis_line])
print ludwik_line
# NI BEZONAS DIVERSECO DE PENSO EN LA MONDO POR ALFRONTI LA NOVAJI DEFIOJN
# From translate.google.com:
# WE NEED DIVERSITY OF THOUGHT IN THE WORLD to face the NOVAJI challenges
# But "New" translates as "Novaj" so I guess Tim says:
# WE NEED DIVERSITY OF THOUGHT IN THE WORLD TO FACE THE NEW CHALLENGES
# Tim is TBL:
# http://webarchive.nationalarchives.gov.uk/20141203214058/http://blogs.fco.gov.uk/ianhughes/2012/10/04/we-need-diversity-of-thought-in-the-world-to-face-the-new-challenges-tim-berners-lee-the-british-inventor-of-the-world-wide-web/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment