Ad
  • Custom User Avatar

    changed that test. i ran the full tests a bunch of time with the reference solution and the user solution using different order of operations, and tests passed consistently, so these problematic cases should be exceedingly rare.

  • Custom User Avatar

    To avoid copying of a std::vector

  • Custom User Avatar

    What's the reason for changing the function signature?

  • Custom User Avatar

    Still got the same issue here in cpp

  • Custom User Avatar

    I think it also makes a difference if you calculate as w/(h*h) or w/h/h

    The test cases should not sit on floating point boundary.

  • Custom User Avatar

    Almost a year later, still the same issue.

  • Custom User Avatar

    And actually, the test is not even an edge-case which causes weird floating point rounding in typical implementations. The test-case is actually simply wrong:

    w = 86.7000000000000028421709430404007434844970703125
    h = 1.6999999999999999555910790149937383830547332763671875

    so w>86.7, h<1.7, so w/(h* h) > 86.7/(1.7^2) = 30. So Obese is actually correct, given the input.

  • Custom User Avatar

    There are a problem in C++ test with bmi = 30.0 when w = 86.7 and h = 1.7

    Expected: equal to "Overweight"
    Actual: "Obese"

    The first two fixed tests and all random tests work correctly.

    if you know how floating numbers work (in a binary system as well), then you'll know why computers can't accurately count some values.