Skip to content

Instantly share code, notes, and snippets.

@jonatasemidio
Created April 22, 2015 20:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonatasemidio/bdc3d3e7743cb43645be to your computer and use it in GitHub Desktop.
Save jonatasemidio/bdc3d3e7743cb43645be to your computer and use it in GitHub Desktop.
Problem A. Speaking in Tongues
d=[:];n='';r=''
g = 'ejp mysljylc kd kxveddknmc re jsicpdrysi rbcpc\nypc rtcsra dkh wyfrepkym veddknkmkrkcd\nde kr kd eoya kw aej tysr re ujdr lkgc jvqz'
e = 'our language is impossible to understand there\nare twenty six factorial possibilities\nso it is okay if you want to just give upzq'
g.eachWithIndex{s,i->d+=["${s}":e[i]]}
def tc(def s){d.find{it.key==s}.value}
def tl(def l){l.each{n += tc(it)};return n}
g.split('\\n').eachWithIndex{s,i->r+="Case #${i+1}: ${tl(s)}\n"}
r
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment