Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
No imports solution in Clear category for Mountain Peaks by amandel
def check_peaks(heights: list[int]) -> bool:
return sum(ac for a,b,c in zip([0]+heights,heights,heights[1:]+[0])) > 1
print("Example:")
print(check_peaks([1, 2, 3, 2]))
# These "asserts" are used for self-checking
assert check_peaks([2, 3, 5, 6, 7, 5, 4, 2]) == False
assert check_peaks([2, 3, 6, 5, 4, 6, 3, 2]) == True
assert check_peaks([1, 2, 3, 2, 1]) == False
assert check_peaks([1, 3, 2, 1, 2, 3, 1]) == True
assert check_peaks([4, 5, 6, 7, 8, 9, 10]) == False
assert check_peaks([2, 1, 2]) == True
print("The mission is done! Click 'Check Solution' to earn rewards!")
Oct. 8, 2024
Comments: