Ad
  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    So after bashing my head against this kata for an absurd amount of time and trying many small variations, I finally came to a successful solution that was irritatingly close to what my original code was. It seems like multiple people are having similar issues. The problem many have with this kata is that the test numbers used, at least where I was having my struggles, can return just SLIGHTLY different answers depending on the exact syntax used in a solution. Here are my pieces of advice:

    First, make sure you are not ROUNDING UP at any point. While it's not perfectly clear, you will never consider a fraction of a person a person. This means simply truncating any decimal places at all times. Certain methods of casting (looking at YOU Convert.ToInt32) can actually round up instead of just outright dropping the decimal places, so be aware of this.

    Secondly, if using a loop, make sure your condition is correct. I see multiple people stuck on a certain test parameter that, in my experience, is caused by simply having just a slightly wrong statement in declaring your loop. Remember once you have reached a population that is greater than or equal to the desired population you are done. The order and style in which you compare your current population with the desired population will have a direct impact on how many iterations you perform on your loop.