May 24, 2026
I’ve been experimenting with a human-friendly way to cluster list values using reversals of sub-lists. Or, in normal human words: I was playing with my toddler’s Magna-Tiles and got into a pattern with how I was sorting and grouping them, and turned it into a little… algorithm? Heuristic? Anyway, look!
Here’s a video I made for reference:
But if you prefer words over video: Let’s say you have a list where node values can be b , g , o , or r .
Initial state: bgogbrbroorrgbgorrbggo
What you do is you take the value that’s at the end (in this case o ), and you find the next value closest to the end with that same value, and you reverse the sub-list between them. So, the next iteration would be:
bgogbrbroorrgbgooggbrr ▲ ▲ └──┬─┘ this part was reversed
We reversed everything to the right of the second o from the right.
And then, you do the same thing, now that r group is at the end, you reverse the sub-list to the next r :
bgogbrbroorrrrbggoogbg ▲ ▲ └────┬───┘ this part was reversed
... continue reading