← RoseCode

ROSECODE 126

Flip-flop Bit Sets

Philippe_57721 · Math ·

Let B be the binary digits of an integer N
B = { b1, b2, b3, ..., bn } b1 is the least significant bit and bn = 1

Consider the subsets of B whose elements are alternately 0 and 1

Example: N = 40, B = { 0, 0, 0, 1, 0, 1 }

There are 11 such flip-flop subsets (including the empty set):

Index Values
[]{}
[1, 4]{0, 1}
[1, 6]{0, 1}
[2, 4]{0, 1}
[2, 6]{0, 1}
[3, 4]{0, 1}
[3, 6]{0, 1}
[5, 6]{0, 1}
[1, 4, 5, 6]{0, 1, 0, 1}
[2, 4, 5, 6]{0, 1, 0, 1}
[3, 4, 5, 6]{0, 1, 0, 1}
How many flip-flop subsets are there for N = 1234567891011121314?

[My timing: < 100ms]