Skip to content

Commit

Permalink
VPW 2011: gelukkig
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy Georges committed Apr 26, 2011
1 parent 152ae69 commit f5c88fd
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions 2011/cat1/gelukkig.hs
@@ -0,0 +1,24 @@
module Main where

import Data.List (elem)


happy :: [Int] -> Int -> String
happy is i
| i == 1 = "JA"
| otherwise = let s = sq i
in case s `elem` is of
True -> "NEE"
False -> happy (s:is) s

sq :: Int -> Int
sq 0 = 0
sq i = r*r + sq q
where q = i `div` 10
r = i `mod` 10

main = do
lss <- lines `fmap` getContents
let cases = read $ head lss :: Int

putStr $ unlines $ map (happy [] . read) $ tail lss

0 comments on commit f5c88fd

Please sign in to comment.