Project Euler: Problem 52

https://projecteuler.net/problem=52

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.

First, write a function same_digits(x,y) that returns True if two integers x and y have the exact same set of digits and multiplicities and False if they have different digits.


In [7]:
def same_digits(x, y):
    if [x.split()] == [y.split()]:
        return True
    else:
        return False

In [8]:
assert same_digits('132', '321')
assert not same_digits('123', '3')
assert not same_digits('456', '0987654321')


---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
<ipython-input-8-4d2369f19b4d> in <module>()
----> 1 assert same_digits('132', '321')
      2 assert not same_digits('123', '3')
      3 assert not same_digits('456', '0987654321')

AssertionError: 

Now use the same_digits function to solve this Euler problem. As you work on this problem, be careful to debug and test your code on small integers before trying it on the full search.


In [ ]:
# YOUR CODE HERE
raise NotImplementedError()

In [ ]:
assert True # leave this cell to grade the solution