Find a number consisting of 9 digits in which each of the digits from 1 to 9 appears only once. This number must also satisfy these divisibility requirements:
- The number should be divisible by 9.
- If the rightmost digit is removed, the remaining number should be divisible by 8.
- If the rightmost digit of the new number is removed, the remaining number should be divisible by 7.
- And so on, until there’s only one digit (which will necessarily be divisible by 1).
There are solutions in many languages in those webpages, but I wanted to write my own in Haskell, just for kicks. Here it is :
(length xs) == 0
onemore  = [[x] | x <- thelist]
onemore list = [list ++ [l] | l<-thelist,elem l list == False, check (list ++ [l]) == True]
testmore  = 
testmore (x:xs) = (onemore x) ++ (testmore xs)
result = foldl (.) id (replicate 8 testmore) (onemore )
Here is another version in Haskell, just for comparison.