Ad
  • Custom User Avatar

    Sorry about that, should be fixed now!

  • Default User Avatar
        test.assert_equals(to_scientific(56789), "5.678e4")
        test.assert_equals(to_scientific(50789), "5.078e4")
        test.assert_equals(to_scientific(50089), "5.008e4")
        test.assert_equals(to_scientific(50009), "5.0e4")
        test.assert_equals(to_scientific(56709), "5.67e4")
        test.assert_equals(to_scientific(56009), "5.6e4")
        
        test.assert_equals(to_scientific(456789), "4.567e5")
        test.assert_equals(to_scientific(406789), "4.067e5")
        test.assert_equals(to_scientific(400789), "4.007e5")
        test.assert_equals(to_scientific(400089), "4.0e5")
        test.assert_equals(to_scientific(400009), "4.0e5")
        test.assert_equals(to_scientific(456709), "4.567e5")
        test.assert_equals(to_scientific(456009), "4.56e5")
        test.assert_equals(to_scientific(450009), "4.5e5")
    
  • Custom User Avatar

    The input number will always be in the range of 0 < num < 1,000,000,000,000

    This statement is incorrect as random tests can go beyond this range.

  • Custom User Avatar

    Thank you very much for all of these tips! I'll be sure to change this soon!

  • Custom User Avatar
        for i in range(100):
            rand_num = randint(1,100000000000)
    

    This is generally a very bad way of doing random tests, because probability of testing interesting inputs is close to 0. For example, there is ultra small chance of having a test for numbers < 1000, and very small chance of having a test for trailing zeros. You need to have better random generators to ensure good coverage of tested scenarios. You can take a look at example kata, especially the "Leap years" one, to see how to ensure good distribution of tested scenarios.

  • Custom User Avatar

    Trailing periods are still not explained, and not tested. Inputs in form 10000000 have no fixed tests and no random tests.

  • Custom User Avatar

    Should be fixed now!

  • Custom User Avatar

    That's OK, we've all been there.

    MAke sure to test for scenarios with different amounts of trailing zeros, like: 100000, 12000, 12300, 100001, 120001, 123001

  • Custom User Avatar

    Sorry that's just my stupidity in writing the description, can you tell it's my first kata? :)

  • Custom User Avatar

    Example in description: 1000000 -> "1.000e6"

    Tests:

    '6.290e10' should equal '6.29e10'
    '9.400e10' should equal '9.4e10'
    '9.360e10' should equal '9.36e10'
    

    It should be explained how trailing zeros should be handled, and there should be explicit fixed tests, and guaranteed random tests, for inputs with trailing zeros like 1000000 and 1000001.

  • Custom User Avatar

    Thank you for the feedback, clarification has been added to the description. The digits should just be truncated / rounded down.

  • Custom User Avatar

    The description needs to specify how to handle rounding of the last digit. For example, what is the expected answer for 2345678, or 999999?

  • Custom User Avatar

    Thank you for the tips, they are very much appreciated!

  • Default User Avatar

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