Last active
June 16, 2017 08:54
-
-
Save purcell/aae25b25f2f1f2b7881fe73f31978818 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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?