Daniele Fucini 3a09f3d4f5
Add more solutions and minor improvements
Added solutions for problem 66, 67, 68, 69 and 70 in C and python.
Also, minor improvements to the code for a few older problems.
2019-09-29 13:26:34 +02:00

35 lines
1.0 KiB
Python

#!/usr/bin/python
# 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.
from numpy import zeros
from timeit import default_timer
def main():
start = default_timer()
i = 1
# Brute force approach, try every integer number until the desired one is found.
while True:
if ''.join(sorted(str(i))) == ''.join(sorted(str(2*i))) and\
''.join(sorted(str(i))) == ''.join(sorted(str(3*i))) and\
''.join(sorted(str(i))) == ''.join(sorted(str(4*i))) and\
''.join(sorted(str(i))) == ''.join(sorted(str(5*i))) and\
''.join(sorted(str(i))) == ''.join(sorted(str(6*i))):
break
i = i + 1
end = default_timer()
print('Project Euler, Problem 52')
print('Answer: {}'.format(i))
print('Elapsed time: {:.9f} seconds'.format(end - start))
if __name__ == '__main__':
main()