what is the fastest way to find the number of occurrences of x bits in y bits?

is there a faster way than merely counting/ looping/ simulating them?

can it be calculated or partially calculated instead?

for instance what are the number of 5 bits occurring in 7 bits.

below, all the occurrences of 2 bits in 4 bits:

1100, 0110, 0011, 1010, 0101, 1001

More Brian Barnard's questions See All
Similar questions and discussions