Bitmask Enumeration — Subsets & Submasks

Mode 1: count 0 … 2n−1 as subsets. Mode 2: walk the submasks of a mask with s = (s − 1) & mask.

step 0

Current value

bit = 1 (element present) in mask, not in submask bit = 0

Enumeration log

Press Step to begin. Mode 1 walks every subset; Mode 2 walks the submasks of the chosen mask.

How to read this

Self-contained visualization. A subset of {0..n-1} is the integer whose bit i is 1 iff element i is present. The submask loop visits exactly 2popcount(mask) submasks; summed over all masks this is 3n. See junior.md, middle.md, and professional.md.