Lets solve the problem that appeared in HackerRank April World Codesprint. Among the problems I have ever created, its one of my favorites.
Staircase Nim
This problem is a variation of Staircase Nim problem, which is a not-very-well-known variation of classic Nim problem. If you don't know what Nim Game is, I suggest you to first learn about it.
In Staircase nim, there is a staircase with n steps, indexed from 0 to n-1. In each step, there are zero or more coins. See the figure below: