Consider all 2^n
different binary strings of length n
and assume n > 2
. You are allowed to delete exactly b < n/2
bits from each of the binary strings, leaving strings of length n-b
remaining. The number of distinct strings remaining depends on which bits you delete. Assuming your aim is to leave as few remaining different strings as possible, this challenge is to write code to compute how few can you leave as a function of n
.
Example, n=3
and b = 1
. You can leave only the two strings 11
and 00
.
For n=9
and b = 1,2,3,4
we have 70,18,6,2
For n=8
and b = 1,2,3
we have 40,10,4
For n=7
and b = 1,2,3
we have 20,6,2
For n=6
and b = 1,2
we have 12,4
For n=5
and b = 1,2
we have 6,2
This question was originally posed by me in 2014 in a different form on MO.
Input and output
Your code should take in an integern
and output a single integer for each value of b
starting at b = 0
and increasing.
Score
Your score is the largest n
for which your code completes for all b < n/2
in under a minute on my Linux based PC. In case of tie breaks, the largest b
your code gets to for the joint largest n
wins. In case of tie breaks on that criterion too, the fastest code for the largest values of n
and b
decides. If the times are within a second or two of each other, the first posted answer wins.
Languages and libraries
You can use any language of library you like. Because I have to run your code, it would help if it was free (as in beer) and worked in Linux.
b > 0
as additional input-requirement? Or wouldn=3
andb=0
simply output2^n
as result? \$\endgroup\$2^n
indeed. \$\endgroup\$n
and a singleb
, but the score is the largestn
for which the code completes allb < n/2
in under a minute. Wouldn't it be better to have a single inputn
in that case, and output all results for0 <= b < n/2
? Or should we provide two programs/functions: one taking two inputsn
andb
, and one taking only inputn
and outputting all results in the range0 <= b < n/2
? \$\endgroup\$