Get digit^power using memoization (DP optimization).
(digit: int, power: int)
| 63 | power_cache: dict[tuple[int, int], int] = {} |
| 64 | |
| 65 | def get_digit_power(digit: int, power: int) -> int: |
| 66 | """Get digit^power using memoization (DP optimization).""" |
| 67 | if (power, digit) not in power_cache: |
| 68 | power_cache[(power, digit)] = digit**power |
| 69 | return power_cache[(power, digit)] |
| 70 | |
| 71 | # Check each number up to the limit |
| 72 | for number in range(limit): |
no outgoing calls
no test coverage detected