Skip to content

Instantly share code, notes, and snippets.

@lux01
Created May 1, 2015 13:08
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 lux01/c4d14d61524166832feb to your computer and use it in GitHub Desktop.
Save lux01/c4d14d61524166832feb to your computer and use it in GitHub Desktop.
Daily Programmer #212 Easy
-- Implementation of Reddit /r/DailyProgrammer challenge #212 [Easy]
-- Rövarspråket
import Data.Char (isUpper, toLower)
type Consonants = [Char]
robberEncode :: Consonants -> String -> String
robberEncode cons = concat . map mapper
where mapper :: Char -> String
mapper c
| (toLower c) `elem` cons = [c, 'o', toLower c]
| otherwise = [c]
robberDecode :: Consonants -> String -> String
robberDecode cons [] = []
robberDecode cons (c:cs)
| (toLower c) `elem` cons && length cs > 1 = c : robberDecode cons (drop 2 cs)
| otherwise = c : robberDecode cons cs
swedishConsonants :: Consonants
swedishConsonants = "bcdfghjklmnpqrstvwxz"
englishConsonants :: Consonants
englishConsonants = swedishConsonants
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment