October 2015

<<September October November>>

Ponder This Challenge:

Counting the number of 1s in a 12-bit input is a function from 12 to 4 bits.

Our challenge this month is to implement it with a minimal number of 5-to-2 functions (a function that receives 5 bits input and emits 2 bits output).

The format we request is several lines. Each line consists of <5 letters> followed by <32 base-4 digits>,

followed by the last line with 4 space separated numbers.

The 5 letters are the input to the function (the first letter is the msb) and the 32 digits are the output (the msb is the first output). The last line states which bits are used as the output.

To explain the format, here is an implementation that compares 2 numbers that are 2-bit, using 2 functions of 3-to-2

acd02113302

bef21133123

7 8

The input is a,b,c,d; the first line defines e,f as a function of the 3 bits a,c,d; and the second line applies a different 3-to-2 function on b,e,f, yielding a 2-bit output (g,h).

The last line states that the output of the computation is 7,8, where 7(=g) is the msb and 8(=h) is the lsb.

In the real problem, the output contains 4 bits. In our example, the output has 2 bits.



If a=0, c=0, d=0 then e=0 and f=0

If a=0, c=0, d=1 then e=1 and f=0

If a=0, c=1, d=0 then e=0 and f=1

If a=0, c=1, d=1 then e=0 and f=1

If a=1, c=0, d=0 then e=1 and f=1

If a=1, c=0, d=1 then e=1 and f=1

If a=1, c=1, d=0 then e=0 and f=0

If a=1, c=1, d=1 then e=1 and f=0

The output (g,h) is 0,1 if, and only if, 2*a+b < 2*c+d

The output (g,h) is 1,0 if, and only if, 2*a+b = 2*c+d

The output (g,h) is 1,1 if, and only if, 2*a+b > 2*c+d

Update (06/10):

To be qualified as a solver, you need no more than 9 functions. Each function you save will earn you a "*".

We will post the names of those who submit a correct, original solution! If you don't want your name posted then please include such a statement in your submission!

We invite visitors to our website to submit an elegant solution. Send your submission to the ponder@il.ibm.com.

If you have any problems you think we might enjoy, please send them in. All replies should be sent to: ponder@il.ibm.com