3 msΒ·
This could be useful for combinatorial tasks such as iterating over all the ways to draw π items without replacement from a bag containing π distinct items. Y
by bumbledraven 3y ago
This could be useful for combinatorial tasks such as iterating over all the ways to draw π items without replacement from a bag containing π distinct items. You start out with 1<<π β 1 (which has its π low-order bits set to 1) and keep going up to the next higher integer with the same popcount until bit π is set to 1, at which point you stop.