6 kyu

Earth-mover's distance

18 of 96geoffp
Description
Loading description...
Fundamentals
Algorithms
Mathematics
Arrays
  • Please sign in or sign up to leave a comment.
  • natan Avatar

    python:

    tests are affected by solutions mutating input, and should change to decorator-style and import test lib/solution

    I would have submitted a fork, but python (same as all the other languages) are directly added from within the kata editor so I'm not sure how I'd go about that.

  • depial Avatar

    R version has no random tests

  • Koistinen Avatar

    This is for C: While the probability values look ok, the position values of test #4 in Random_Tests are consistently wrong and seem to be very large and not in order.

    11,8 {(-16807268829305383559342375576237254726043224244224.000000, 0.054688), (-16441893419972657829791454368058183971129241108480.000000, 0.109375), (24845527834625349609462642156176811334150853230592.000000, 0.015625), (-8769009823985417509222108996297698117935595257856.000000, 0.234375), (28499281927952606904971854237967518883290684588032.000000, 0.132812), (365375409332725729550921208179070754913983135744.000000, 0.046875), (24480152425292623879911720947997740579236870094848.000000, 0.070312), (28133906518619881175420933029788448128376701452288.000000, 0.085938), (10595886870649046156976715037193051892505510936576.000000, 0.070312), (-2923003274661805836407369665432566039311865085952.000000, 0.039062), (-8038259005319966050120266579939556608107628986368.000000, 0.140625)}

    {(-13884265554643577722935005910804688686731359158272.000000, 0.109375), (-7307508186654514591018424163581415098279662714880.000000, 0.156250), (-21191773741298092313953430074386103785011021873152.000000, 0.031250), (-12788139326645400534282242286267476421989409751040.000000, 0.234375), (-30326158974616235552726460278862872657860600266752.000000, 0.078125), (-5115255730658160213712896914506990568795763900416.000000, 0.171875), (-25210903243958075339013563364355882089064836366336.000000, 0.171875), (-2192252455996354377305527249074424529483898814464.000000, 0.046875)}

  • elmstedt Avatar

    R translation is broken.

    Test cases include random NA values in px and py, and there is no consistency in the expected test result. Sometimes the test wants the function to return NA other times it seems to want a missing px value to be treated as 1.

    Nowhere in the description is it suggested there may be NA values in the test cases, if you intend to include them you must indicate the proper way to handle them.

  • u10root Avatar

    This comment has been hidden.

  • u10root Avatar

    This comment has been hidden.

  • hobovsky Avatar

    In C++, is there some particular reason to have params passed as const value? Why not const reference, or just mutable value?

  • Madjosz Avatar

    Java has no sample Tests.

    Maybe mention in the description that the x and y are not sorted.

  • mouwat Avatar

    This comment has been hidden.

  • tonylicoding Avatar

    Maybe test.expect would be better than test.assert_equals for the last test prohibiting the use of the module.

  • geoffp Avatar

    I'll admit I was disconcerted to see my kata approved so soon. I'd have preferred to leave it in beta for a while longer to see some solutions in other languages and gather opinions on the right rank for it. I'd thought 5-6 kyu, but wouldn't have been put out if it ended up 4 kyu.

    I knew about the existing R package that solves this problem, but wasn't aware of the Python module. Evidently some people did, though; I guess that's the beta process working as intended. By the time I'd added a test to block the use of the library in Python, the kata was already approved.

    The reason this kata appears to be from 2017 is that I had a couple of draft kata that I'd been using for casual experimentation and trying stuff out. Then in 2020 I decided I didn't need both of them, and turned one of them into the Earth-mover's distance kata.

  • user7820265 Avatar

    This is only a math problem,don't need to know it and solve it.waste time!

  • Mercy Madmask Avatar

    In the description, you write (1/6) * (2-1) + (2/6) * (4-2) + (1/6) * (5-3) = 1.

    But if I'm not wrong this is: 1/6 * 1 + 2/6 * 2 + 1/6 * 2 = 1/6 + 4/6 + 2/6 = 7/6 != 1