-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path32.py
32 lines (28 loc) · 757 Bytes
/
32.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
products = list()
pandigitals = list()
def split_to_digits(n):
digits = list()
for s in str(n):
digits.append(s)
return digits
def has_unique_digits(n):
return len(set(n)) == len(n)
product_sum = 0
for i in range(1,5000):
d = split_to_digits(i)
if has_unique_digits(d) and "0" not in d:
for j in range(1,5000):
if len(str(i)) + len(str(j)) + len(str(i*j)) == 9:
e = split_to_digits(j)
if has_unique_digits(e) and "0" not in e:
f = split_to_digits(i*j)
if has_unique_digits(f) and "0" not in f:
all_digits = d+e+f
if has_unique_digits(all_digits):
pandigitals.append([i,j,i*j])
products.append(i*j)
for p in set(products):
product_sum += p
print pandigitals
print set(products)
print product_sum