From cc10f8f4e08fd94e3ceb640bb7eadd9b075b9497 Mon Sep 17 00:00:00 2001 From: Philippe Zwietering Date: Tue, 6 Apr 2021 01:56:27 +0200 Subject: [PATCH] 52 was so easy that at first I thought my code was bugged --- 52/main.py | 37 +++++++++++++++++++++++++++++++++++++ base.py | 8 +++----- 2 files changed, 40 insertions(+), 5 deletions(-) create mode 100644 52/main.py diff --git a/52/main.py b/52/main.py new file mode 100644 index 0000000..8f050ff --- /dev/null +++ b/52/main.py @@ -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() \ No newline at end of file diff --git a/base.py b/base.py index 2c6b5ea..f4c0059 100644 --- a/base.py +++ b/base.py @@ -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() \ No newline at end of file + main() \ No newline at end of file