Byte Heist Home Leaderboard
Join the Heist (with Github)
Solve View

Binary Compliment Reverse Sequence

The BCR sequence consists of numbers where, if you take the binary compliment and reverse it, you get back the original number.

The Sequence on OEIS

10 is one example of a BCR number. When written in binary, 10 becomes 1010. Reverse 1010 to create 0101, and the compliment of 0101 is 1010 which is 10 in decimal.

Print all the BCR numbers from 1 to 20,000, each on their own line.

Judge

(async function*(context: Context): Challenge {
  yield (await context.run(undefined)).assertEquals(`2
10
12
38
42
52
56
142
150
170
178
204
212
232
240
542
558
598
614
666
682
722
738
796
812
852
868
920
936
976
992
2110
2142
2222
2254
2358
2390
2470
2502
2618
2650
2730
2762
2866
2898
2978
3010
3132
3164
3244
3276
3380
3412
3492
3524
3640
3672
3752
3784
3888
3920
4000
4032
8318
8382
8542
8606
8814
8878
9038
9102
9334
9398
9558
9622
9830
9894
10054
10118
10362
10426
10586
10650
10858
10922
11082
11146
11378
11442
11602
11666
11874
11938
12098
12162
12412
12476
12636
12700
12908
12972
13132
13196
13428
13492
13652
13716
13924
13988
14148
14212
14456
14520
14680
14744
14952
15016
15176
15240
15472
15536
15696
15760
15968
16032
16192
16256`);
  return context.noFailures();
})

Example Code

console.log(`2
10
12
38
42
52
56
142
150
170
178
204
212
232
240
542
558
598
614
666
682
722
738
796
812
852
868
920
936
976
992
2110
2142
2222
2254
2358
2390
2470
2502
2618
2650
2730
2762
2866
2898
2978
3010
3132
3164
3244
3276
3380
3412
3492
3524
3640
3672
3752
3784
3888
3920
4000
4032
8318
8382
8542
8606
8814
8878
9038
9102
9334
9398
9558
9622
9830
9894
10054
10118
10362
10426
10586
10650
10858
10922
11082
11146
11378
11442
11602
11666
11874
11938
12098
12162
12412
12476
12636
12700
12908
12972
13132
13196
13428
13492
13652
13716
13924
13988
14148
14212
14456
14520
14680
14744
14952
15016
15176
15240
15472
15536
15696
15760
15968
16032
16192
16256`)