52 was so easy that at first I thought my code was bugged

This commit is contained in:
2021-04-06 01:56:27 +02:00
parent a4d31debeb
commit cc10f8f4e0
2 changed files with 40 additions and 5 deletions

37
52/main.py Normal file
View File

@@ -0,0 +1,37 @@
'''
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.
'''
import time
import math
def findMultiples(factors):
result = 1
while True:
products = [[s for s in str(f * result)] for f in factors]
sresult = [s for s in str(result)]
skip = False
for i in range(len(products) - 1):
if len(products[i]) != len(sresult) or set(products[i]) != set(sresult):
skip = True
if skip:
result += 1
continue
return result
def main():
print("Hello, this is Patrick")
t0 = time.time()
print(findMultiples([2, 3, 4, 5, 6]), time.time() - t0)
if __name__ == "__main__":
main()

View File

@@ -1,12 +1,10 @@
import os
import time
import math
import numpy as np
def main():
print("Hello, this is Patrick")
print("Hello, this is Patrick")
if __name__ == "__main__":
main()
main()