Euler problem 24

Haskell

------------------------------

deleteNth n xs | n>0 = take (n-1) xs ++ drop n xs

removeItem x xs = filter (/= x) xs

sub_lexico x [] = [[]]

sub_lexico x xs = map (x:) (lexico (removeItem x xs))

merge_sub_lexico [] = []

merge_sub_lexico (x:xs) = x ++ (merge_sub_lexico xs)

lexico [] = [[]]

lexico xs = (merge_sub_lexico (map (\x -> (sub_lexico x xs)) xs))

p24 = (lexico [0,1,2,3,4,5,6,7,8,9]) !! (1000000 - 1)

------------------------------

— Me@2015-05-27 12:09:33 PM

2015.05.27 Wednesday (c) All rights reserved by ACHK