Created
April 15, 2012 21:47
-
-
Save dnene/2394980 to your computer and use it in GitHub Desktop.
Solution to Google Code Jam Problem - Problem A. Speaking in Tongues
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 | |
ejp mysljylc kd kxveddknmc re jsicpdrysi | |
rbcpc ypc rtcsra dkh wyfrepkym veddknkmkrkcd | |
de kr kd eoya kw aej tysr re ujdr lkgc jv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# python3 | |
# Problem description at : http://code.google.com/codejam/contest/1460488/dashboard | |
# Suggested Java solution at : http://www.harshadura.net/2012/04/googlecodejam-my-answer-algorithm-for.html | |
# Post on suggested clojure solution at : http://bestinclass.dk/index.clj/2012/04/google-code-jam-1.html | |
from functools import reduce | |
g = ["ejp mysljylc kd kxveddknmc re jsicpdrysi", | |
"rbcpc ypc rtcsra dkh wyfrepkym veddknkmkrkcd", | |
"de kr kd eoya kw aej tysr re ujdr lkgc jv"] | |
e = ["our language is impossible to understand", | |
"there are twenty six factorial possibilities", | |
"so it is okay if you want to just give up"] | |
def m(d, p) : return d if (p[0] in d) else ( d.update({p[0]:p[1]}) or d) | |
d = reduce(m,zip("".join(g),"".join(e)),{}) | |
lines=input() | |
for i in range(int(lines)): | |
j=input() | |
print("Case #%s: %s"%(i+1,"".join("".join(d[c] for c in l) for l in j))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just to make this complete, you might want to add the missing translations to
g
ande
: