-
Notifications
You must be signed in to change notification settings - Fork 1
/
euler017.py
30 lines (16 loc) · 860 Bytes
/
euler017.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
digits = ["one", "two", "three", "four", "five", "six","seven", "eight", "nine"]
tens = ["ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"]
tenprefixes = ["twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"]
hundredprefixes= ["onehundred","twohundred","threehundred","fourhundred","fivehundred","sixhundred","sevenhundred","eighthundred","ninehundred"]
sumdigits = sum(map(len, digits))
sumtens = sum(map(len, tens))
for p in tenprefixes:
print p,
sumtens = sumtens + len(p)*10 +sumdigits
print sumtens + sumdigits
sumdigitsandtens = sumdigits + sumtens
sumhundreds=0
for h in hundredprefixes:
sumhundreds=sumhundreds+len(h) + (len(h)+3)*99 + sumdigitsandtens
suma=sumdigitsandtens+sumhundreds
print suma + len("onethousand")