Skip to content

Instantly share code, notes, and snippets.

@purcell
Last active June 16, 2017 08: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 purcell/aae25b25f2f1f2b7881fe73f31978818 to your computer and use it in GitHub Desktop.
Save purcell/aae25b25f2f1f2b7881fe73f31978818 to your computer and use it in GitHub Desktop.
module Puzzle where
import Data.List (permutations)
import Control.Monad (guard)
solution = do
[a,b,c,d,e,f] <- permutations "123456"
guard $ multiple 6 [a,b,c,d,e,f]
guard $ multiple 5 [a,b,c,d,e]
guard $ multiple 4 [a,b,c,d]
guard $ multiple 3 [a,b,c]
guard $ multiple 2 [a,b]
return [a,b,c,d,e,f]
where multiple n digits = mod (read digits) n == 0
@purcell
Copy link
Author

purcell commented Jun 16, 2017

A six digit number "abcdef" is formed using each of the digits 1,2,3,4,5,6 once and only once so that "abcdef" is a multiple of 6, "abcde" is a multiple of 5, "abcd" is a multiple of 4, "abc" is a multiple of 3 and "ab" is a multiple of 2.
a) Find a solution for "abcdef"
b) Is the solution you find unique?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment