Skip to content

Instantly share code, notes, and snippets.

@purcell purcell/puzzle.hs

Created Mar 10, 2015
Embed
What would you like to do?
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
You can’t perform that action at this time.