-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathp17.hs
64 lines (14 loc) · 949 Bytes
/
p17.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
numLetterCounts :: Int
numLetterCounts = (sum $ map length (numWords)) - 27
where numWords = let otn = ["", "one", "two", "three", "four", "five",
"six", "seven", "eight", "nine"]
multsOfTen = ["twenty", "thirty", "forty", "fifty",
"sixty", "seventy", "eighty", "ninety"]
oth = otn
++ ["ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen",
"sixteen", "seventeen", "eighteen", "nineteen"]
++ foldl (++) [] (map (\w -> zipWith (++) (replicate 10 w) otn) multsOfTen)
ott = oth
++ foldl (++) [] (map (\w -> zipWith (++) (replicate 100 w) oth) (map (\w -> w ++ "hundredand") (tail otn)) )
++ ["onethousand"]
in ott