Problem 90

http://projecteuler.net/index.php?section=problems&id=90

組み合わせを数えるときも、6と9を区別しないのかと思っていたり、同じ数字が二度以上出てくると思っていたり。

まったく、これだから英語の問題は

squ = [[(,1)],[(,4)],[(,9),(,6)],[(1,6),(1,9)],[(2,5)],
[(3,6),(3,9)],[(4,9),(4,6)],[(6,4),(9,4)],[(8,1)]]
sortPerm _  = [[]]
sortPerm [] _ = []
sortPerm (x:xs) (n+1) = (map (x:) . sortPerm xs) n ++ sortPerm xs (n+1)
display xs ys (a,b) = elem a xs && elem b ys || elem b xs && elem a ys
allDisplay xs ys = all (any $display xs ys) $squ
main = print.length$[(a,b)|a<-digits,b<-takeWhile(<a)digits,allDisplay a b]
where digits = sortPerm [..9] 6
More Reading
Newer// Problem 87
Older// Problem 91