Skip to content

Instantly share code, notes, and snippets.

@purcell
Created March 10, 2015 10:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save purcell/d95c237ed297f4168bbc to your computer and use it in GitHub Desktop.
Save purcell/d95c237ed297f4168bbc to your computer and use it in GitHub Desktop.
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