Created
October 15, 2017 20:45
-
-
Save aleksandersumowski/f39a8f796f637dd386fb65c1d1a615a1 to your computer and use it in GitHub Desktop.
vigenere
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
import Data.Char | |
import Debug.Trace | |
vigenere input keyword = let in_ord = trace "1" (map ((subtract 65) . ord) input) | |
key_ord = (map ((subtract 65) . ord) $ take (length input) (cycle keyword)) | |
sum_ord = zipWith (+) in_ord key_ord | |
next = map (mod 25) sum_ord | |
last = map (+ 65) sum_ord | |
in map chr last |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment