Ad
  • Custom User Avatar

    Hi @rsschool_94d9c29d4afff48c ;

    As this kata has the puzzle tag, it normally means that the description is allowed to be a bit less detailed (because, in this case, any more information will basically spoil the answer), but the test cases are correct.

    Maybe the wording is not 100% clear: it is asking not for the total amount of grain but rather, which square will you "reach" for a given amount of grains.

    For input 3 grains: you can place 1 grain on square 1, since first square has "capacity" of 1 grain. Then you can place 2 grains on second square since it has capacity of 2 grains.

    You now have 3-1-2 = 0 grains remaining so you are finished - and you have successfully placed all 3 grains and you only needed 2 squares to do this.

    For 4 grains, the second square is full so you need to move to the next available square (square #3) which has spare capacity. So answer for 4 grains is 3 squares.