Last active
September 29, 2016 16:09
-
-
Save sshine/b9aaea2b67236b01bbe7c5cbfdb9bcc3 to your computer and use it in GitHub Desktop.
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 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 |
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
$_=<>;/^(.)(.*)/;$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