-
Notifications
You must be signed in to change notification settings - Fork 0
/
problem43b.py
62 lines (52 loc) · 1.48 KB
/
problem43b.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
def isPandigital(s):
array = [0 for x in range(10)]
for c in s:
d = int(c)
array[d] += 1
for i in range(0, 10):
if not array[i]== 1:
return False
return True
def merge(list1, list2):
dummyNumbs = []
for i in range(len(list1)):
lastDigitsThirt = list1[i][1:]
for j in range(len(list2)):
firstDigitsST = list2[j][:2]
if lastDigitsThirt == firstDigitsST:
dummyNumbs.append(list1[i] + list2[j][2:])
return dummyNumbs
def getMultiples(numb):
numbers = []
for i in range(0, 1000, numb):
s = str(i)
if len(s) < 3:
if len(s) > 1:
new = "0" + s
numbers.append(new)
else:
numbers.append(s)
return numbers
numbsSevenT = getMultiples(17)
numbsThirt = getMultiples(13)
dummyNumbs = merge(numbsThirt, numbsSevenT)
numbs = getMultiples(11)
dummyNumbs = merge(numbs, dummyNumbs)
numbs = getMultiples(7)
dummyNumbs = merge(numbs, dummyNumbs)
numbs = getMultiples(5)
dummyNumbs = merge(numbs, dummyNumbs)
numbs = getMultiples(3)
dummyNumbs = merge(numbs, dummyNumbs)
numbs = getMultiples(2)
dummyNumbs = merge(numbs, dummyNumbs)
actualNumbs = []
print(len(dummyNumbs))
for i in range(1,10):
for j in range(len(dummyNumbs)):
actualNumbs.append(str(i) + dummyNumbs[j])
special = []
for string in actualNumbs:
if isPandigital(string):
special.append(int(string))
print(sum(special))