Count xor subsets by rank
transcript
Count the subsets with a given xor. A hundred thousand masks. You cannot try them all.
Reduce each mask from its top bit. If it becomes zero, it is redundant. Otherwise it joins the basis.
Take the masks three, five and six. The six is the xor of three and five. So the rank is two.
Reduce the target by the basis. If it reaches zero, it can be built. If not, the count is zero.
Three masks, rank two. Every buildable target has two to the power of one subsets. That is two.
The basis never exceeds twenty masks. Each mask takes twenty steps. Two to the n comes from doubling, modulo the prime.
Write a slow twin that tries every subset. Run both on short lists of small masks. Stop at the first difference, and shrink it.
A hundred thousand masks have two to the hundred thousand subsets. No program can list them. The basis needs only twenty steps per mask.
Build a basis. Then take two to the n minus rank. Full breakdown in the lecture.