Skip to content

Commit bf3b99b

Browse files
committed
Solution for Euler 56
1 parent f3c0b13 commit bf3b99b

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

project_euler/problem_56/__init__.py

Whitespace-only changes.

project_euler/problem_56/sol1.py

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
def maximum_digital_sum(a,b):
2+
'''
3+
Considering natural numbers of the form, a**b, where a, b < 100,
4+
what is the maximum digital sum?
5+
:param a:
6+
:param b:
7+
:return:
8+
'''
9+
# RETURN the MAXIMUM from the list of SUMs of the list of INT converted from STR of BASE raised to the POWER
10+
return max([sum([int(x) for x in str(base**power)]) for base in range(a) for power in range(b)])
11+
12+
#Tests
13+
print(maximum_digital_sum(10,10), "is 45")
14+
print(maximum_digital_sum(100,100), "is 972")
15+
print(maximum_digital_sum(100,200), "is 1872")

0 commit comments

Comments
 (0)