Considering natural numbers of the form, a**b, where a, b < 100, what is the maximum digital sum? :param a: :param b: :return: >>> solution(10,10) 45 >>> solution(100,100) 972 >>> solution(100,200) 1872
(a: int = 100, b: int = 100)
| 11 | |
| 12 | |
| 13 | def solution(a: int = 100, b: int = 100) -> int: |
| 14 | """ |
| 15 | Considering natural numbers of the form, a**b, where a, b < 100, |
| 16 | what is the maximum digital sum? |
| 17 | :param a: |
| 18 | :param b: |
| 19 | :return: |
| 20 | >>> solution(10,10) |
| 21 | 45 |
| 22 | |
| 23 | >>> solution(100,100) |
| 24 | 972 |
| 25 | |
| 26 | >>> solution(100,200) |
| 27 | 1872 |
| 28 | """ |
| 29 | |
| 30 | # RETURN the MAXIMUM from the list of SUMs of the list of INT converted from STR of |
| 31 | # BASE raised to the POWER |
| 32 | return max( |
| 33 | sum(int(x) for x in str(base**power)) for base in range(a) for power in range(b) |
| 34 | ) |
| 35 | |
| 36 | |
| 37 | # Tests |
nothing calls this directly
no outgoing calls
no test coverage detected