Skip to content

Instantly share code, notes, and snippets.

@Denommus
Created March 21, 2016 17:57
Show Gist options
  • Save Denommus/038b62f611d91c595206 to your computer and use it in GitHub Desktop.
Save Denommus/038b62f611d91c595206 to your computer and use it in GitHub Desktop.
List every trilegal number
trilegals :: [Int]
trilegals = filter isTrilegal [100..1000]
isTrilegal :: Int -> Bool
isTrilegal n
| n < 100 || n > 999 = False
| otherwise = u - d == (d - c)*3
where [c, d, u] = map (read . (:"")) (show n) :: [Int]
main :: IO ()
main = print trilegals
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment