Ad
Games
Arrays
Data Types
Algorithms
Logic

In our time, probably everyone played computer games, starting from Tetris and ending with grandiose game projects!

In many games with two-dimensional graphics, you can face the following situation. The hero jumps on platforms that hang in the air. Often the essence of such games is that the hero would move from point A to point B. At the same time, the hero has a level of life and energy. When jumping, the hero spends one life and spends energy, which is calculated by the formula |y2-y1|where y1 and y2 are the heights at which these platforms are located.

Let's assume that you know the coordinates of all the platforms in order from left to right. Can you find the minimum amount of energy the hero needs to get from the last platform to the first?

using System;
public static class Kata
{
  public static int CalculatingTheAmountEnergy(int[] coordinates)
  {
     // here's your code
  }
}