You have N marbles and K slots. You have to follow the below mentioned
rules :
1. You can put in a marble or take out a marble from slot numbered
1 at any time.
2. You can put in a marble or take out a marble from slot numbered
i only if there exists a marble at the slot i - 1.
3. The
Hi,
I hope this is correct. Please correct if I am wrong.
Short answer:
Let a = (k-n)/(n-1)
Let b = (k-n)%(n-1)
steps = (n-1)(a)(a+1)/2 + b
Put = steps + n
Remove = steps
Explanation:
Example with n = 3 k =10:
Start by putting balls in 1,2,3
1 2 3 x x x x x x
Now move balls from 1-3 to