In this challenge, you need to simulate a frog jumping back and forth on lily pads. The pond is infinitely big, has a line of an infinite number of lily pads, and the frog can jump across as many lily pads as he likes.
This frog likes to jump back and forth: after jumping forward, he always jumps backwards, and vice versa.
You are passed a list of integers, which represents his jumps. You need to output the result of his jumps.
For example, say you are passed
Our frog starts by jumping 2 lily pads forward:
Then 3 lily pads back:
Then 6 lily pads forward:
Then finally, 2 lily pads forward (notice how the 2 overwrites the 3):
To be more explicit: Your input is an an array of numbers
S, you need to output
S[K] at the position
S[K] - S[K-1] + S[K-2] - S[K-3]....
- If multiple numbers are to be printed at a certain location, print only the one with the highest index.
- You are to use
_if a particular location is empty
- If a number has multiple digits, it does not take up multiple locations. (In other words, a location can consist of multiple characters)
- You can assume that your list is non-empty, and that all integers are greater than 0.
5 ____5 2,2 2_2 4,3,2,1 3124 5,3,2,1 _3125 2,3,6,8,2 8_2__2__6 10,3,12,4,1,12,16 ___12__3__10____41__1216 100,4,7,2,2 _______________________________________________________________________________________________4___1002_2
This is a code-golf, so answer it in as few characters as possible!