From 086ee02a6bbcc8239e22ad4477f934e3daca54ec Mon Sep 17 00:00:00 2001 From: daviddoji Date: Sun, 26 Sep 2021 16:07:52 +0200 Subject: [PATCH] Solution to problem 52 --- src/Python/Problem052.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/Python/Problem052.py diff --git a/src/Python/Problem052.py b/src/Python/Problem052.py new file mode 100644 index 0000000..b586043 --- /dev/null +++ b/src/Python/Problem052.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python3 +""" +Created on 26 Sep 2021 + +@author: David Doblas Jiménez +@email: daviddoji@pm.me + +Solution for problem 52 of Project Euler +https://projecteuler.net/problem=52 +""" + +from utils import timeit + + +@timeit("Problem 52") +def compute(): + """ + 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. + """ + + for number in range(123456, 1_000_000): + if sorted(str(number)) \ + == sorted(str(2*number)) \ + == sorted(str(3*number)) \ + == sorted(str(4*number)) \ + == sorted(str(5*number)) == sorted(str(6*number)): + return number + + +if __name__ == "__main__": + + print(f"Result for Problem 52: {compute()}") \ No newline at end of file