Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
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.
It often means a problem somewhere in your code. 105 guys passed the C++ kata.
This comment is hidden because it contains spoiler information about the solution
I saw the solution and I definitely knew I had to put more works into maths. However I have a couple of questions:
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.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.
Not true. If you use
auto
you're just letting the compiler do the type deduction.Agree. If for the first year the population declines then it will never get to
p
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.
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.