Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module Enigma where
- import Data.Char
- import Data.List
- cipher::String
- cipher = "EKMFLGDQVZNTOWYHXUSPAIBRCJ"
- plain::[Char]
- plain = ['A'..'Z']
- validateCipher::[Char]->Bool
- validateCipher ch = (sort cipher == plain)
- offsetCipher::Int->[Char]->[Char]
- offsetCipher int cipher = drop (26-int) cipher ++ take (26-int) cipher
- {-
- getIndex :: [Char] -> Char -> Int
- getIndex lst i =
- if (head lst) == i
- then 0
- else
- 1 + (getIndex (tail lst) i)
- -}
- encode::Char->Int->[Char]->Char
- encode ch int cipher =
- (offsetCipher int cipher)!!(elemIndex ch plain === Just 1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement