Ad
  • Custom User Avatar

    It seems like there's some floating point errors with the random tests:

    E.g.
    Expected: [0.29836609045702106, 0.18020364669666114, 0.12242481648117452, 0.0942457968269003, 0.08074828321098745, 0.06961875443997158, 0.05541084537058963, 0.053279659010182334, 0.045702107506511956]
    instead: [0.298366090457027, 0.18020364669666242, 0.12242481648117365, 0.09424579682689997, 0.08074828321098737, 0.06961875443997172, 0.05541084537058983, 0.053279659010182515, 0.04570210750651206]

    The elements of the arrays are accurate to 1-e14, yet tests still fail. I'd avoid comparing two floating point numbers directly.

    A quick fix to solve this would be to map the user solution with .map((v, i) => (v <= expected[i] + 1e-7 && v >= expected[i] - 1e-7) ? expected[i] : v). This will change each element to the expected element if it falls within a range of +- 1e-7.

  • Custom User Avatar

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