Skip to content

Instantly share code, notes, and snippets.

@smcl
Created April 11, 2011 23:20
Show Gist options
  • Save smcl/914591 to your computer and use it in GitHub Desktop.
Save smcl/914591 to your computer and use it in GitHub Desktop.
I hate myself
--Project Euler problem 38
-- What is the largest 1 to 9 pandigital 9-digit number that can be formed as
-- the concatenated product of an integer with (1,2, ... , n) where n > 1?
import Data.List
pandigital9 = map (\x -> read x :: Integer) $ permutations "123456789"
main = print $ last $ sort $ takeWhile (<987654321) $ concat $ map (\y -> filter (`elem` pandigital9) $ takeWhile (<987654321) $ map (\x -> read (concat $ map (show) $ map (y*) [1..x]) :: Integer) [1..]) [1..]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment