Complete problem

This commit is contained in:
2020-10-12 21:49:31 +02:00
parent ddc4943f57
commit d770dd831e

View File

@@ -1,16 +1,14 @@
totalSum=0 from itertools import permutations
usedFactors = [] from math import ceil
for i in range(1, 10000):
if i%100==0:
print(str(i/100) + "%")
for j in range(1, 10000):
x=i*j
if len(str(i))+len(str(j))+len(str(x))==9:
result = sum([int(k) for k in str(x)])
result += sum([int(k) for k in str(i)])
result += sum([int(k) for k in str(j)])
if sum==1+2+3+4+5+6+7+8+9:
totalSum+=x
print(totalSum) def isPanDigital(i,j,x):
#HINT: Some products can be obtained in more than one way so be sure to only include it once in your sum. return sorted(str(i) + str(j) + str(x)) == ['1' ,'2', '3', '4', '5', '6', '7', '8', '9']
panDigits = []
for i in range(1,10000):
for j in range(1,ceil(10000/i)):
prod = i*j
if isPanDigital(i, j, prod) and not prod in panDigits:
panDigits.append(prod)
print(sum(panDigits))