Skip to content

Commit 8eab2f1

Browse files
shuklalokcclauss
authored andcommitted
Solution for Problem Euler 56 (#1131)
* Solution for Euler 56 * Adding Type and Doctest as per guideline * removing unused import * correcting the way type check works
1 parent f3c0b13 commit 8eab2f1

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

project_euler/problem_56/__init__.py

Whitespace-only changes.

project_euler/problem_56/sol1.py

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
2+
3+
def maximum_digital_sum(a: int, b: int) -> int:
4+
"""
5+
Considering natural numbers of the form, a**b, where a, b < 100,
6+
what is the maximum digital sum?
7+
:param a:
8+
:param b:
9+
:return:
10+
>>> maximum_digital_sum(10,10)
11+
45
12+
13+
>>> maximum_digital_sum(100,100)
14+
972
15+
16+
>>> maximum_digital_sum(100,200)
17+
1872
18+
"""
19+
20+
# RETURN the MAXIMUM from the list of SUMs of the list of INT converted from STR of BASE raised to the POWER
21+
return max([sum([int(x) for x in str(base**power)]) for base in range(a) for power in range(b)])
22+
23+
#Tests
24+
if __name__ == "__main__":
25+
import doctest
26+
doctest.testmod()

0 commit comments

Comments
 (0)