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.
Thanks for clarifying 👍
In
'foobar0100' should equal 'foobar100'
the first value is what your function returned, not the input. To see the input, print it.I got
'foobar0100' should equal 'foobar100'
...but shouldn't it be
'foobar0100' should equal 'foobar0101' instead?
"foobar00" turns into "foobar01" because the end result after the string was incremented was 2, which did not take up both digits. If it was "foobar09", then it would turn into "foobar10", because the result now takes up both zeros which were in the input. In the case of "foobar099", 99 turns into 100, meaning it now takes up 3 digits. In "foobar099", there are 3 numbers at the end, so you would not include the extra 0 after incrementation.
Documentation is your best friend too
OP solved it, closing
I hate this one
Nice Kata!
This kata seems has some logical issues(my opinon) like if "foobar00" --> "foobar01" (here second last 0 wasn't excluded) then "foobar099" --> "foobar100" (why the 3rd last zero wasn't included!? It could be "foobar0100")
That's a problem with your code, not a kata issue. The first value in the error message is what your function returns, not the input. To see it, print it.
'foobar910' should equal 'foobar100'
Do explain the logic behind this !!!
Print the input, the first value in the error message is what your function wrongly returned instead of the expected value. It's even explained in the post directly below yours. Also, the number you should increase is the one at the end, not any number in the string:
My solution fails due to: "'fo100obar100' should equal 'fo99obar100'" - IMO it should be 'fo101obar101'...
If the number ends in 99, 9, or 999, 0 must be subtracted
This is how the test suite provides you with the information:
String = 'foobar000': 'foobar1' should equal 'foobar001'
For the test "foobar000", your code incorrectly returns "foobar1", not a kata issue.
Loading more items...