Skip to content

Instantly share code, notes, and snippets.

@gvaughn
Last active November 27, 2015 19:20
Show Gist options
  • Save gvaughn/b295e69b4eb302a4fab5 to your computer and use it in GitHub Desktop.
Save gvaughn/b295e69b4eb302a4fab5 to your computer and use it in GitHub Desktop.
Caesar Cipher ElixirGolf
# for an offset range of -26 to + 26
# 114 characters
[n,p]=IO.gets("")|>String.split",";IO.puts for c<-to_char_list(p),do: c<97&&c||97+rem c-71-String.to_integer(n),26
# for any offset range
# 122 characters
[n,p]=IO.gets("")|>String.split",";IO.puts for c<-to_char_list(p),do: c<97&&c||97+rem c-71-rem(String.to_integer(n),26),26
# with @MPAherns use of a binary generator in the list comprehension
# 103 characters
[n,p]=IO.gets("")|>String.split",";IO.puts for<<c<-p>>,do: c<97&&c||97+rem c-71-String.to_integer(n),26
@emson
Copy link

emson commented Nov 23, 2015

Great work... the rules don't state anything about offsets over 26 chars so, it's perfectly valid. Thanks for writing the descriptions I'll be sure to link to it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment