Skip to content

Instantly share code, notes, and snippets.

@sshine
Last active September 29, 2016 16:09
Show Gist options
  • Save sshine/b9aaea2b67236b01bbe7c5cbfdb9bcc3 to your computer and use it in GitHub Desktop.
Save sshine/b9aaea2b67236b01bbe7c5cbfdb9bcc3 to your computer and use it in GitHub Desktop.
import Data.Char
import Control.Monad
import Control.Applicative
para :: (a -> b -> [a] -> b) -> b -> [a] -> b
para f e [] = e
para f e (x:xs) = para f (f x e xs) xs
main = do
n <- getLine
let digits = map (\d -> ord d - ord '0') n
let isMagic = para (\d b ds -> b && d > sum ds) True digits
when isMagic $ putStrLn n
main
$_=<>;/^(.)(.*)/;$s=$1;$t=$2;$t=~tr/[a-y]z/[b-z]a/;print"$s$t"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment