-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproblem 52
More file actions
34 lines (27 loc) · 696 Bytes
/
Copy pathproblem 52
File metadata and controls
34 lines (27 loc) · 696 Bytes
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
"""
can be seen that the number, 125874, and its double, 251748, contain exactly the same digits, but in a different order.
Find the smallest positive integer, x, such that 2x, 3x, 4x, 5x, and 6x, contain the same digits.
"""
from collections import defaultdict
def num2digits(num):
digits = defaultdict(lambda: 0)
for x in str(num):
digits[int(x)] += 1
return digits
def test_num(i):
digits1 = num2digits(i)
for j in range(2, 7):
k = i * j
digits2 = num2digits(k)
if digits1 != digits2:
return False
return True
def main():
i = 1
while not test_num(i):
i += 1
return i
print(main())
solution = main()
for i in range(2, 7):
print(i*solution)