Life Goes On

まあまあだけど楽しんでる方です

113問目

http://projecteuler.net/index.php?section=problems&id=113
各桁の数字が昇順または降順に並ぶ数が10100未満でいくつあるか求める。
重複順列です。

main = print $ euler113 100

euler113 :: Integer -> Integer
euler113 n = sum $ map nonBouncy [1..n]

nonBouncy :: Integer -> Integer
nonBouncy n = increasing + decreasing - 10
    where increasing = div (product [n+1..n+8]) (product [1..8])
          decreasing = div (product [n+1..n+9]) (product [1..9])