Ad
  • Custom User Avatar

    The test works fine. It only does that if you're wrong (it simply prints "Test Passed" otherwise), but that doesn't take away the issue that it has problems with printing an std::pair.

    It prints "unsupported type" for both the user's answers and the expected answers -- that can't a problem with the user code.

    I did pass the test eventually, but it was difficult not being able to see what your program returns and what the expected answers are.

  • Custom User Avatar

    It often means a problem somewhere in your code. 105 guys passed the C++ kata.

  • Custom User Avatar

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

  • Custom User Avatar

    I saw the solution and I definitely knew I had to put more works into maths. However I have a couple of questions:

    1. How does round(10*t) in some answers manage to pass all tests? I thought that should fail since the time is quantized and height is not a linear function of time.

    2. Why does a naive approach fail? My first answer was basically: get t, get the previous and next time step, compare heights. Theoretically this is just a brute force approach to the problem so I'm wondering why it fails the random tests.

  • Custom User Avatar

    Not true. If you use auto you're just letting the compiler do the type deduction.

  • Custom User Avatar

    Agree. If for the first year the population declines then it will never get to p

  • Custom User Avatar

    Each year you have to discard the fractional part if it exists.

    I haven't done any high level maths so I don't know if it's possible to take that into account. I tried collapsing the recursive function to a naive mathematical formula but it outright failed for most data sets that are not perfectly divisible.

  • Custom User Avatar

    To those who are asking about truncate or round:

    The problem domain is about population, number of inhabitants. You can't keep a record where there's a decimal part so the number should always be truncated. A 0.643 human shoudn't be rounded up to 1.