Skip to content

Instantly share code, notes, and snippets.

@rohith180211
rohith180211 / polkadot_score.py
Created April 30, 2026 02:59
Polkadot score calculation (counting peaks and valleys in an array)
nums = [63,62,17,88,51,77,61,56,72,38,52,47,75,71,50,99,29,35,64,41,1,101,87,23,92]
count = 0
for i in range(1, len(nums) - 1):
if (nums[i] > nums[i - 1] and nums[i] > nums[i + 1]) or \
(nums[i] < nums[i - 1] and nums[i] < nums[i + 1]):
count += 1
print(count)