Code Golf: Shortest code to find a weighted median?

后端 未结 7 621
眼角桃花
眼角桃花 2021-01-03 08:23

My try at code golfing.

The problem of finding the minimum value of ∑W_i*|X-X_i| reduces to finding the weighted median of a list of x[i] with weights <

7条回答
  •  爱一瞬间的悲伤
    2021-01-03 09:05

    Just a comment about your code : I really hope I will not have to maintain it, unless you also wrote all the unit tests that are required here :-)

    It is not related to your question of course, but usually, the "shortest way to code" is also the "hardest way to maintain". For scientific applications, it is probably not a show stopper. But for IT applications, it is.

    I think it has to be said. All the best.

提交回复
热议问题