Hopscotch minimum cost
Your task
A hopscotch course for a game level is a row of stones, each with a height. Your character starts on the first stone and must reach the last one, hopping either to the next stone or over one stone to the stone after it. A hop from stone i to stone j costs the absolute height difference between them. Given the heights (at least one stone), return the minimum total cost to reach the last stone. For example, [10, 30, 40, 20] costs 30.
Examples
min_hop_cost(heights: list[int]) -> intExample 1
Input
min_hop_cost([10, 30, 40, 20])Output
30Example 2
Input
min_hop_cost([30, 10, 60, 10, 60, 50])Output
40