News for hackers. Stuff that matters.
Re:Iterating over Bit Sets Quickly by halfcat on Saturday February 24, 2024 @04:32PM (#39495310)
Ah, brings back memories of chess programming where this stuff was discussed often. See [1] for more of this. I always found Kogge Stone [2] pretty cool, a kind of bit-twiddling flood-fill.

[1] https://www.chessprogramming.org/Bit-Twiddling

[2] https://www.chessprogramming.org/Kogge-Stone_Algorithm

Re:Iterating over Bit Sets Quickly by vjerancrnjak on Saturday February 24, 2024 @06:03PM (#39495951)
n-queens too, a simple example that can benefit from this bit trick. Eventually you're looking for free columns in the current row where queen can be put. Instead of going over all columns, with a few bit operations iteration can only go directly through free columns.