Help us understand the problem. What is going on with this article?

Project Euler 56「もっとべき乗の数字和」

More than 1 year has passed since last update.

かい…かん

Problem 56 「もっとべき乗の数字和」

Googol (10^100)は非常に大きな数である: 1の後に0が100個続く. 100^100は想像を絶する. 1の後に0が200回続く. その大きさにも関わらず, 両者とも数字和 ( 桁の和 ) は1である.
a, b < 100 について自然数 a^b を考える. 数字和の最大値を答えよ.

def hoge(num):
    return max(sum((lambda l: (int(x) for x in l))(str(a**b)))
               for a in range(1, num)
               for b in range(1, num))

print(hoge(100))

カンニング後追記

こういう時にmap関数を使うんですね。
普段使ってないから全然出てきませんでしたわ。

map(int, str(a**b))
(lambda l: (int(x) for x in l))(str(a**b))

上の2つは同じことをやってる(つもり)。

Why do not you register as a user and use Qiita more conveniently?
  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
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  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