Created
March 10, 2015 10:21
-
-
Save purcell/d95c237ed297f4168bbc to your computer and use it in GitHub Desktop.
This file contains 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
module Puzzle where | |
valid :: Integer -> Bool | |
valid abcde = divisibleBy bcde && divisibleBy cde && divisibleBy de && divisibleBy e | |
where divisibleBy n = n /= 0 && ((abcde `mod` n) == 0) | |
bcde = abcde `mod` 10000 | |
cde = bcde `mod` 1000 | |
de = cde `mod` 100 | |
e = de `mod` 10 | |
solve :: Integer | |
solve = head $ filter valid [99999,99998..10000] | |
-- #=> 95625 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment