-
Notifications
You must be signed in to change notification settings - Fork 0
/
017.py
64 lines (59 loc) · 1.2 KB
/
017.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
wordy = [
"",
"one",
"two",
"three",
"four",
"five",
"six",
"seven",
"eight",
"nine",
"ten",
"eleven",
"twelve",
"thirteen",
"fourteen",
"fifteen",
"sixteen",
"seventeen",
"eighteen",
"nineteen",
"twenty"
]
decadey = [
"",
"",
"twenty",
"thirty",
"forty", # 40의 정확한 spelling은 forty 이다... -> 처음에 fourty로 해서 답이 21224가 나왔었다...
"fifty",
"sixty",
"seventy",
"eighty",
"ninety"
]
res = 0
def euler():
global res
for x in range(1,20):
print(wordy[x], len(wordy[x]))
res += len(wordy[x])
for y in range(20,100):
wort = decadey[y//10] + wordy[y%10]
print(wort, len(wort))
res += len(wort)
for z in range(100, 1000):
if z % 100 == 0:
hundword = wordy[z//100] + "hundred"
elif int(str(z)[1:])//10 <= 1:
hundword = wordy[z//100] + "hundredand" + decadey[int(str(z)[1:])//10] + wordy[int(str(z)[1:])]
else:
hundword = wordy[z//100] + "hundredand" + decadey[int(str(z)[1:])//10] + wordy[int(str(z)[2])]
print(hundword, len(hundword))
res += len(hundword)
print("onethousand", len("onethousand"))
res += len("onethousand")
print("result : ", res)
euler()
# 21124