5 kyu

Find the "center" point

55 of 68myjinxin2015
Description
Loading description...
Puzzles
  • Please sign in or sign up to leave a comment.
  • RealKenshiro Avatar
    1. assertSimilar is deprecated, use assert.deepEqual
    2. has the minimum Pythagorean distance to the other points

    should be

    has the minimum sum of the pythagorean distances to the other points

  • trashy_incel Avatar

    needs Node 14.x and assert.deepEqual

    • dfhwze Avatar

      done

      Issue marked resolved by dfhwze 3 months ago
    • trashy_incel Avatar

      thanks for your efforts, could you take a look at multi level sorting that you recently upgraded to Node 18 ?

      when you use assert.deepEqual() you almost always need chai.config.truncateThreshold = 0; (also for strictEqual() on long-ish strings). currently the test's output looks like this:

      expected undefined to deeply equal [ { name: 'gisela', …(5) }, …(16) ]
      

      which makes it hard to debug. also, the random tests generate records that are missing certain keys, but i dont know whether you wrote them, as the fork has no diff.

      (I would have posted this on the fork, but I get the good old "Comment Owners is invalid" error ...)

  • JohanWiltink Avatar

    If I leave the spaces in the random tests fail.

    If I take the spaces out the static tests fail.

    • JohanWiltink Avatar

      When using Math.hypot(dx, dy) tests succeed. When using Math.sqrt(dx*dx + dy*dy) one static test fails. I have not looked into rounding intermediate results to six figures after the decimal point.

      I do think you should specify in the description spaces should be taken out.

      I haven't thought hard enough about how and why Math.hypot and Math.sqrt differ, and how to solve that. But fixing that somehow, if possible, would probably be a good thing.

    • myjinxin2015 Avatar

      I'll improve later ;-)

    • myjinxin2015 Avatar

      Description update ;-) Something more clear: Do not calculate the distance with the spaces; rounding to 6 decimal place when compare distance.

      But I don't know why If I take the spaces out the static tests fail. Math.hypot(dx, dy) and Math.sqrt(dxdx + dydy) should got same result, isn't it?(I'm not test for it, perhaps later ;-))

    • JohanWiltink Avatar

      I absolutely agree. It should work.

      Also, world peace and free beer .. :P

    • Voile Avatar

      ;-)

      Issue marked resolved by Voile 8 years ago
  • JohanWiltink Avatar

    Manhattan distance or Pythagoras distance?

  • kazk Avatar

    This comment has been hidden.

    • myjinxin2015 Avatar

      I'm a little busy right now, I will have a test later. I guess it's because I didn't calculate the distance to the space.

    • myjinxin2015 Avatar
      [ [ '38.854893', 'I' ],
        [ '39.732833', 'F' ],
        [ '35.441404', 'A' ],
        [ '28.575290', 'D' ],
        [ '28.127003', 'E' ],
        [ '28.771395', 'H' ],
        [ '29.699757', 'B' ],
        [ '28.991322', 'G' ],
        [ '36.767667', 'C' ] ]
      

      In my calculations, all the numerical values are almost half of the difference. I guess you calculate space as 1. And based on my true intentions, the spaces are not calculated from the distance. That is: From one point to the next, the distance is 1. For example:

      . . . .
      . A B .
      . C . .
      . . . .
      

      In this matrix, the distance from A to C is 1, right? So, the distance from A to B is 1 too. Do you understand?

      But it's really a bug in my description, because it's not clear. So I'll fix my description ;-)

    • myjinxin2015 Avatar

      Description update ;-)

    • kazk Avatar

      Thanks. Ignoring the spaces and rounding to 6 decimal spaces before comparing made it pass :)

      Question marked resolved by kazk 9 years ago