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.
A quick rundown of my solution versurs geoffp's:
Yes, but the code will never attempt to read it. That statement is in the if-condition, preceded by the statement "i < roman.size() - 1 && (...)". If the previous statement is false, the if-condition is "short-circuited", meaning the second statement is ignored.
I agree, this is not solved. I also had random test failures, and peeking at the first few values of the first "sorted" array in such random tests, I could find things such as: [290, 728, 75, 61, 341, 392, 361, 712, 973, 957, 866, ...]
I don't even know how my solution (or similar ones) passed with that. It did take me a few tries, at least.
The C++ starting function is erroneously and amusingly called PythagoreanTripe.
This comment is hidden because it contains spoiler information about the solution
C++ extended test cases bugged - they don't include (but require) <iomanip> and forcs users to do it in their solution if they want to solve the kata. My solution, for example, never used <iomanip>.
Floating-point rounding errors.
w/(h*h) first multiplies h and then divides w.
w/h/h first divides w and then divides it again.
The different setup of the operations can introduce little discrepancies that mess with direct floating-point comparisons.
Your solution fails on that case because of a precision loss by the function pow().
The test expected 17 decimal digits, but pow() can only go up to 16 without precision loss, because it works on doubles (maximum 53 bits of precision). 2^53 < 10^17 so it can't fit in the result double of pow().
The starting code is odd, it's very C-like for a C++ kata. It doesn't work, either. And it's plain wrong - a parameter that should be some sort of range is instead a char reference!? Thankfully, that's no big deal...
A tip for other warriors: recursion too deep == SIGSEGV.
I had similar problems with C++.
The correct combination for me was floats for the calculations and truncated result.
These "guess what it is" challenges are nasty. Those who think they're as easy as other 7 kyu katas - beware!
This comment is hidden because it contains spoiler information about the solution
For C++, the squares can be tricky because they don't fit on a byte. They can still be put on a string literal. Any string operations that assume "character == byte index" will fail on this string.
This comment is hidden because it contains spoiler information about the solution