Ad
  • Default User Avatar

    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 was 60 and your int was 59. If done on paper, those inputs indeed should return 60.0000000... or 60, 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.

  • Custom User Avatar

    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.

  • Custom User Avatar

    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.