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.
That's the point, that extra adjustment is not required. Below would work just fine:
return sum(int(d) ** (i) for i, d in enumerate(str(a),1)) == a
note: after doing this,
(i+1)
won't be necessary.This comment is hidden because it contains spoiler information about the solution
@Voile
Brilliant advice, - it worked for me. Thank you.
Not an issue, and tests are correct. As cavos said it, you have to define new instances, not mutate the original object (that's actually the principle of the decorator pattern). So the second test is actually here to check that you DO NOT mutate the original object.
Same problem, fixed it with Voile's advice and rounded twice. (also: extremely new, some extra code I could have stripped, perhaps affected the outcomes?)
This comment is hidden because it contains spoiler information about the solution
Don't forget floating point errors!
http://0.30000000000000004.com/
Because of floating point errors, if you try to add up numbers which will go exactly at
0.5
and then round it, depending on how the calculation is done it might come up slightly less than or more than0.5
, which gives out an error of 1 LSD (least significant digit) due to the discontinuous nature of rounding.A fix is to round 1 more digit first then the digit we want, but that's complicated and is not fool-proof. So you'll have to come up with something smarter.
Adjusted initial solution and example tests.
Happy Coding
^_^
these are pre-generated tests, have you checked your answers to the given ones?
To be honest, I am not sure what would cause problems like that. They have not seemed to be present in any testing of mine, even when I spam the validate solution, and they have not been reported by anyone else until now. As far as I can understand, your code looks fine.
I will leave the issue up and if I figure it out later, I will fix it, but at the moment I'm not sure what could be going wrong.
Any contributions to this kata related to fixing this issue would be greatly appreciated. Sorry for the inconveniece if you were struggling to complete it.
And it's clearly bugged in the extended tests as well. You can make it work by changing test in basic, but you don't have access to the extended tests, soooo... impossible to pass.
okay.
Print the input to the console so you can see where you went wrong.
Loading more items...