This is my solution to Project Euler Problem 52 - Permuted Multiples. In the problem I'm searching for the smallest value of x such that x, 2x, 3x, 4x, 5x, and 6x use the same digits.
x = 125874
while True:
x += 1
if sorted(set(str(x))) == sorted(set(str(x * 2))) == \
sorted(set(str(x * 3))) == sorted(set(str(x * 4))) == \
sorted(set(str(x * 5))) == sorted(set(str(x * 6))):
print x
break
Is this bad Python? Is there a better way to write this instead of using a while True
loop? I've tried adding the if condition to the while
loop, but keep getting an infinite loop.