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.
Thank you sir for this kata.
this is not surprising and that's exactly the problem with undefined behavior in C/C++ ... many things can happen depending on the platform, the way the code is run, the compiler, etc. the worst case scenario is when nothing special happens, until that one day when a cryptic bug pops up from nowhere. there are some tools that can help, such as static analyzers. when i ran your code in this one, it correctly detected UB when run with an empty string (warning, this analyzer is free and online but it's a bit slow and the UB diagnostics can be a bit cryptic if you're not well versed on low-level details)
In Python everything seems to be +1-3 kyu easier, while half as fast.
thanks alot, small change big difference :)
It is because by use of
float
and real division operator/
, you introduce small inaccuracies into your solution, which sometimes, in certain circumstances, for some inputs, can trick your solution into doing some incorrect approximation, or unintended rounding, because this is how floats work. When you change line 6 of your solution to something liketime_decimal_secs = g * 60 * 60 // relative_speed
, you have no floats anymore, no inaccuracies, and (if I see correctly) solution with this change will always pass.You can check what exactly happens by recreating one of failing inputs in your IDE and running it with a step-through debugger, observing intermediate variables. You will notice how in some point, some rounding happens, which slightly changes the outcome and leads to an incorrect answer.
It's not about tests which are "rounded up". It's about your code which is a bit buggy, and sometimes performs incorrect rounding.
This comment is hidden because it contains spoiler information about the solution
Print the input.
You forgot to return the sum.
3507 is the sum of the cubic numbers, not a kata issue.
Not a kata issue.
Random tests for Python add four digits not present in string at the end of every solution:
Oh dear! is_sum_of_cubes("eiusmod labore :,! ,;. ::#. ipsum Ut ad :!!. ' dolor . . commodo 407371153 407 :.# adipiscing 0 ~;?? 153 0 153 ~ in ~, 3713710 1 velit 4071534071530") returned: '407 371 153 407 0 153 0 153 371 371 0 1 407 153 407 153 0 Lucky' should equal '407 371 153 407 0 153 0 153 371 371 0 1 407 153 407 153 0 3507 Lucky'
please don't open issues to ask for help, ask a question instead, unless you can prove that the problem comes from the test suite and not your code. there is some info about this error message in the Codewars docs
try your code with an empty string
testing("0 9026315 -827&()", "0 0 Lucky")
how do you get 2 zeros here?
if you count numbers inside numbers, then the output should be
0 0 1
worst problem description
This comment is hidden because it contains spoiler information about the solution
Loading more items...