17 lines
564 B
Haskell
17 lines
564 B
Haskell
-- The cube, 41063625 (345^3), can be permuted to produce two other cubes:
|
|
-- 56623104 (384^3) and 66430125 (405^3). In fact, 41063625 is the smallest
|
|
-- cube which has exactly three permutations of its digits which are also cube.
|
|
--
|
|
-- Find the smallest cube for which exactly five permutations of its digits are
|
|
-- cube.
|
|
|
|
import Euler
|
|
|
|
main = print $ head $ do
|
|
let cubes = map (^3) [1..]
|
|
x <- cubes
|
|
let ps = filter ((== sort (toDigits x)) . sort . toDigits)
|
|
$ takeWhile (< 10 * x) $ dropWhile (< x) cubes
|
|
guard $ length ps == 5
|
|
return x
|