Back
Close

Baum-Sweet Sequence

Statement

 Goal

The Baum–Sweet sequence is an infinite automatic sequence of 0s and 1s defined by the rule:
* b(n) = 1 if the binary representation of n contains no block of consecutive 0s of odd length
* b(n) = 0 otherwise
for n ≥ 0.

For example:
b(4) = 1 because 4 is 100 in base 2, contains no block of 0s of odd length
b(5) = 0 because 5 is 101 in base 2, contains a block of 0s of size 1 (odd)

Your goal is to compute the Baum-Sweet Sequence for the all the integers in the range provided in input.
Input
m n : a space-separated string containing 2 integers m and n, defining the limits of the range for which the Baum-Sweet Sequence must be computed
Output
The space-separated Baum-Sweet Sequence for the range [m, n] (m and n included): b(m) b(m+1) ... b(n)
Constraints
1≤ mn ≤ 10000
Example
Input
1 3
Output
1 0 1

Game modes
Fastest, Shortest

Test cases
Test 1 Test
Input
1 3
Output
1 0 1

Validator 1 Validator
Input
2 4
Output
0 1 1

Test 2 Test
Input
1 15
Output
1 0 1 1 0 0 1 0 1 0 0 1 0 0 1

Validator 2 Validator
Input
15 30
Output
1 1 0 0 1 0 0 0 0 0 1 0 0 1 0 0

Test 3 Test
Input
50 60
Output
0 1 0 0 0 0 0 1 0 0 1

Validator 3 Validator
Input
70 80
Output
0 0 0 1 0 0 1 0 0 1 0

Test 4 Test
Input
100 150
Output
1 0 0 1 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 1 0 0 1 0 0 1 0 1 0 0 1 0 0 1 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0

Validator 4 Validator
Input
200 250
Output
0 1 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 1 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 1 0

Test 5 Test
Input
5000 5080
Output
0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 1 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 1 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0

Validator 5 Validator
Input
4000 4080
Output
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 1 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 1 0 0 0 0 0 0 0 0 1

Solution language

Solution

Stub generator input