Ad
  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    Thank you for the fun exercise!
    Rust translation of the kata doesn't handle floating point comparisons well. Usually, with the tests that include floating numbers, it is common to specify the precision with which they should be compared. However, I cannot see what this kata has to do with floating numbers. They don't add any value in comparison to integers, only technical problems.

  • Custom User Avatar

    My code had problems in dealing with numbers that are more than 4 digits long. There are no such numbers in example tests. I used 20000 and 1, with expected output (3, 10000, 21001): 1000, 10000, 10001.

  • Custom User Avatar

    After refreshing the page, the problem with negative inputs seems to be solved. Thanks!

  • Custom User Avatar

    Nope. It still tests my function on negative numbers: thread 'random_tests' panicked at 'n = -7458'.

  • Custom User Avatar

    The output says:

    Failure Info:
    
    ---- random_tests stdout ----
    	-8
    -58
    -94
    -178
    -8
    -78
    -87
    -7
    -87
    thread 'random_tests' panicked at 'explicit panic', main.rs:49
    

    My program has this line:

    if n < 0 { panic!() }
    
  • Custom User Avatar

    Talking about Rust. What should the program do with negative inputs? Instructions say it should operate only on non-negative, but random tests suggest that the reference implementation does something non-trivial to them: it's neither panic, nor negated thirt(n.abs()) value.