Python Implementation of Problem 52
View source code here on GitHub!
Includes
Problem Solution
Project Euler Problem 52
Problem:
It 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.
Revision 1:
Changed to return a list instead of a set so it can be used in other problems
1"""
2Project Euler Problem 52
3
4Problem:
5
6It can be seen that the number, 125874, and its double, 251748, contain exactly the same digits, but in a different
7order.
8
9Find the smallest positive integer, x, such that 2x, 3x, 4x, 5x, and 6x, contain the same digits.
10
11Revision 1:
12
13Changed to return a list instead of a set so it can be used in other problems
14"""
15from itertools import count
16
17from .lib.iters import digits
18
19
20def main() -> int:
21 for x in count(1):
22 orig = {*digits(x)}
23 if all({*digits(x * y)} == orig for y in range(2, 7)):
24 return x
25 return -1 # pragma: no cover