please look at the journeyToMoon() function, rest of the code has been pre-generated by hackerrank.
journeyToMoon()
soln: https://ide.codingblocks.com/s/259767