Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Index Power by a8696tk
def index_power(ar: list[int], n: int) -> int:
if n > len(ar) - 1:
return -1
return ar[n]**n
print("Example:")
print(index_power([1, 2, 3], 2))
# These "asserts" are used for self-checking
assert index_power([1, 2, 3, 4], 2) == 9
assert index_power([1, 3, 10, 100], 3) == 1000000
assert index_power([0, 1], 0) == 1
assert index_power([1, 2], 3) == -1
print("The mission is done! Click 'Check Solution' to earn rewards!")
March 6, 2024