Stepping Stones Game

  • + 6 comments

    In this problem, you throw a stone x blocks far, and the next time you throw the stone x+1 blocks far, then x+2 blocks far and so on... The problem asks if you can reach the N-th block in this way. That means to know if a sum of integers can reach the value N. We know that the sum of the first x integers (from 1 to x) is given by the formula x*(x+1)/2. So we have to know if x*(x+1)/2 = N is true for an integer value of x. Solving for x you get the equation x^2 + x - 2N = 0, then x = (-1 + sqrt(1+8N))/2. If x is an integer you have a solution, otherwise you will be more lucky next time :)