Qiita Teams that are logged in
You are not logged in to any team

Community
Service
Qiita JobsQiita ZineQiita Blog
1
Help us understand the problem. What is going on with this article?
@yopya

Project Euler 52「置換倍数」

More than 3 years have passed since last update.

たまには「これは問の性質上n桁～m桁の範囲のみチェックすればよい（ｷﾘｯ」とか言いたいけど思いつかないので右ストレートでぶっ飛ばす、まっすぐ行ってぶっ飛ばす。

Problem 52 「置換倍数」

125874を2倍すると251748となる. これは元の数125874と順番は違うが同じ数を含む.
2x, 3x, 4x, 5x, 6x が x と同じ数を含むような最小の正整数 x を求めよ.

``````def hoge(num):
f = lambda n: sorted(str(n))
n = 1
while not all( f(n) == f(n*i) for i in range(2, num+1) ):
n += 1
return n

print(hoge(6))
``````
1
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
1. We will deliver articles that match you
By following users and tags, you can catch up information on technical fields that you are interested in as a whole
2. you can read useful information later efficiently
By "stocking" the articles you like, you can search right away