Skip to content

Instantly share code, notes, and snippets.

@kakkun61
Created January 11, 2021 17:54
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 kakkun61/db75a57723cdfec40dbc0c7ca8f1b30d to your computer and use it in GitHub Desktop.
Save kakkun61/db75a57723cdfec40dbc0c7ca8f1b30d to your computer and use it in GitHub Desktop.
import Control.Monad (guard, replicateM)
import Data.List (foldl')
main :: IO ()
main = do
print $ head $ do
[a, b, c, d, e, g, h, j] <- replicateM 8 [0 .. 9]
[f, i] <- replicateM 2 [1 .. 9]
guard $ h * h `mod` 10 == h
guard $ dec [f, d, c, a, j, h] * dec [i, b, c, f, e, h] == dec [f, b, a, e, c, i, i, j, e, g, i, h]
pure (a, b, c, d, e, f, g, h, i, j)
dec :: [Int] -> Int
dec = foldl' (\acc n -> 10 * acc + n) 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment