Remix.run Logo
pixelpoet 6 hours ago

You can even build them with basically one line of code by sorting points using Morton / Z-curve order. It's linear time if you use a counting/radix sort.

Edit: lol, downvoted for this post. Never change, HN.

rdtsc an hour ago | parent | next [-]

Yeah good point, they are downsides for sure but it's a simple enough approach and most of all it can be shoved in a database (or b-tree or any 1d-sorted data structure).

And for a z-curve, the order is basically a depth-first traversal of a quadtree.

quibono 6 hours ago | parent | prev | next [-]

I'd love to see that. Could you link me to an implementation or explain this in more detail please?

johnisgood 4 hours ago | parent [-]

I would like to know about this more, too. Is there a code anywhere, ideally with comments? But I am fine without comments, too, I would just like to see the code and possibly with an example usage.

quibono an hour ago | parent [-]

Okay, I was intrigued and I did some digging. Morton / Z-order is all about interleaving the individual bits of the x and y coordinates. You end up grouping by quadrants. Python one liner:

    points.sort(key=lambda p: sum(((p[0]>>i&1)<<(2*i))|((p[1]>>i&1)<<(2*i+1)) for i in range(16)))
pavlov 6 hours ago | parent | prev [-]

It’s super easy to click the downvote button by accident on mobile when you meant to upvote. And this UI will never be fixed because this is HN after all.

proc0 3 hours ago | parent | next [-]

I just implemented an HN UI. This is good feedback as I'm aiming to have a mobile friendly web version.

https://proc0.github.io/HackerZen (it's also open source)

craftkiller 6 hours ago | parent | prev | next [-]

This is precisely the reason that I do not log in to HN on my phone. My phone is read-only and if I want to upvote or comment then I have to switch to my laptop. Pretty easy with firefox because I can send tabs to other devices.

jasonjmcghee 5 hours ago | parent | prev | next [-]

Zoom in or unvote/revote

acters 4 hours ago | parent | prev [-]

That is why I like harmonic app, there is an invite button separating the upvote and downvote. Never going to have this kind of issue