brewersfan1976

array_change.py

Apr 29th, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.32 KB | None | 0 0
  1. def arrayChange(inputArray):
  2.     x = 1
  3.     moves = 0
  4.    
  5.     while x < len(inputArray):
  6.           if inputArray[x] <= inputArray[x - 1]:
  7.              moves = moves + abs(inputArray[x] - inputArray[x - 1]) + 1
  8.              inputArray[x] = inputArray[x - 1] + 1
  9.              
  10.           x = x + 1
  11.        
  12.     return moves
Advertisement
Add Comment
Please, Sign In to add comment