Comment

Comment by movpasd

My first thought was to use linear transformations over Z_2 as a field, as that would create a natural interpretation of fixing certain bits as taking a linear subspace. Interestingly this leads to the property that XOR is preserved.

I implemented this in a very quick and hacky way for 32 bits. I generated a random boolean matrix M invertible in Z_2. To turn an input number x into a corresponding number y in an N-bit space, I convert x to binary and turn that into a vector of 1s and 0s, then multiply it by that randomized matrix to get y. Here are the first few y's corresponding to x=0, 1, ...:

00000000000000000000000000000000

0xx0x000xx00x0xx000xxx00xxx0x000

x0xx000xxxx0xxx00x000xxx0xx0xx0x

xx0xx00x00x00x0x0x0xx0xxx0000x0x

x0xx0x00xxx0xx0x00xx0x0xx0xx00x0

xx0xxx0000x00xx000x0x00x0x0xx0x0

00000x0x000000xx0xxx00x0xx0xxxxx

0xx0xx0xxx00x0000xx0xxx000xx0xxx

...

(Hoping the non-monospace font doesn't ruin the alignment too much.)

Which looks... random-ish? I expect that turning these into UUIDs may result in more random-looking sequences.

Not sure how to solve the problem of search with this, but the hope would be that the linear structure gives you what you need, since fixing bytes on UUIDs should correspond to considering linear subspaces of the y vectors. Perhaps this can also be used to apply lexicographic order on the corresponding x vectors (i.e.: ordering the indexes), so that you could jump to each UUID matching the search in order.

parent movpasd 1 year ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton