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.
I was bored so I copied your code and added a print statement near the end. Before converting from float to int, it printed something like
59.9999999999...
, the expected result was60
and your int was59
. If done on paper, those inputs indeed should return60.0000000...
or60
, so the programmed function doesn't match the description. I'm no programming guru but I think its a case of one of those small changes that sometimes happens when using floats. So your solution is correct except for the occasional "off by one" -error caused by floating point calculation. My hint is to reduce the number of floating point operations one way or another.All test folowing same pattern:
assert_eq!(expected, convert(s));
even random one.For the random test
expected
value is calculated when it is needed.If you believe your solution is right please post here the values you geting: input string, expected value and your calculated value (dont forget mark post as spoiler).
Without knowing thouse values I can't check if here is an issue with the test.
Thanks for your report.
Is the problem that actual and expected values are switched in the test asserts?
This can make for surreal failure messages. It's also easy to diagnose and easy to fix, without all the "I think .." and "Maybe ..".
If you are going to post an
Issue
, in general, you should be sure it's actually a kata issue, which means you pretty much have to know what the problem is.