Re:Iterating over Bit Sets Quickly
by modeless on Sunday February 25, 2024 @01:04AM
(#39498110)
I once wrote a solver to calculate the answer to a bin packing problem where the number of bins was less than 32, so I just did the whole calculation by brute force inside 32 bit integers. Placing pieces in bins and moving pieces around and testing for collisions is super easy with bitwise operations. Even in JavaScript it was more than fast enough; the whole calculation certainly fits in cache; probably completely in registers actually.
https://james.darpinian.com/pocket-palette.html