Last active
November 27, 2015 19:20
-
-
Save gvaughn/b295e69b4eb302a4fab5 to your computer and use it in GitHub Desktop.
Caesar Cipher ElixirGolf
This file contains hidden or 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
# 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.