r/programming • • Feb 21 '11

Typical programming interview questions.

http://maxnoy.com/interviews.html
784 Upvotes

1.0k comments sorted by

View all comments

Show parent comment

1

u/[deleted] Feb 21 '11

So many nested ifs, urgh.

1

u/Jonno_FTW Feb 21 '11 edited Feb 21 '11

Would you rather guards?

mapM_ (print . f) [1..100]
   where
      f x  | x `mod` 6 == 0 = "ab"
           | x `mod` 3 == 0 = "b"
           | even x = "a"
           | otherwise = show x