For example, if the array is like 0 0 0 0 ... 0 0[n]s o m e d a t a 4 9 9 9 9 9 9 8 3 7 ..., how to move the pointer by n, without changing s o m e d a t a 4 9 9 9 ... after the pointer is moved?
For example, if the array is like 0 0 0 0 … 0 0[n]s
Share
Nice challenge. I love this language 🙂
My solution is (I think) somewhat correct, it moves the cursor after the data of length n without changing it, but it moves the data two cells to the left (or one, provided certain conditions are met). Here is the code, hope you find it useful.
The requirements are:
Here is the code:
Example: an array
7 9 6, so3tells how far to move the cursor.Now, if there is an additional empty cell to the left of the whole sequence, then we can move the data one cell to the right.
So the cursor is moved behind the data of an arbitrary length, however shifting the data one cell to the left.
Disclaimer There might be errors in the code, but the idea itself should be clear. Feel free to correct the code whenever it does not match the example.