Created
January 2, 2012 05:32
-
-
Save dmalikov/1549475 to your computer and use it in GitHub Desktop.
Project Euler 112 (2s)
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 PECore (numToList, listToNum) | |
import Control.Monad (ap) | |
import Data.List (sort) | |
bouncy :: (Num a, Ord a) => [a] -> Bool | |
bouncy = not . (\x -> all (>=0) x || all (<=0) x) . map (uncurry (-)) . ap zip tail | |
bouncyNumber :: Integer -> Bool | |
bouncyNumber = bouncy . numToList | |
main = print . snd . head . dropWhile ( (/= 990) . fst ) . map ( \(x,y) -> (1000 * x `div` y, y) ) . ( zip `ap` filter bouncyNumber ) $ [1..] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment