Convert from binary to unary in 7x7 Manufactoria

7

In the game manufactoria, take in a binary number and output that number of red pieces. The catch? The board-size is only 7x7:

Here's the manufactoria code for the problem:

http://pleasingfungus.com/Manufactoria/?ctm=Razors;Treat_the_input_as_a_binary_number_and_output_that_number_of_reds;b:r|brr:rrrr|brb:rrrrr|brbb:rrrrrrrrrrr|:|brrrr:rrrrrrrrrrrrrrrr|brbr:rrrrrrrrrr;7;3;0;

I have a solution, so it most definitely exists.

EDIT: Least "total parts" wins (as reported by manufactoria engine)

dspyz

Posted 2012-08-04T03:53:50.710

Reputation: 875

1How do you win the competition? – beary605 – 2012-08-04T05:24:58.917

Lets say least pieces. I really just want to see if people come up with different solutions than I did – dspyz – 2012-08-04T07:28:43.553

Answers

5

21 20 19 parts! Ha!

Screenshot of Manufactoria binarty-to-unary converter

http://pleasingfungus.com/Manufactoria/?lvl=32&code=q12:9f0;c12:8f3;g9:8f1;q9:9f4;b10:8f3;p10:9f0;r10:10f1;y11:9f0;g12:5f3;c12:6f3;r9:6f3;c9:7f2;r10:6f0;p10:7f2;q11:7f1;i12:7f7;p13:7f6;r13:6f0;c13:8f0;&ctm=Razors;Treat_the_input_as_a_binary_number_and_output_that_number_of_reds;b:r|brr:rrrr|brb:rrrrr|brbb:rrrrrrrrrrr|:|brrrr:rrrrrrrrrrrrrrrr|brbr:rrrrrrrrrr;7;3;0;

Edit 2: Back to the original design, but with two parts shaved off by creative reuse of conveyors. The 7 × 7 board really does start to feel confining — I've come up with several ways to shrink this further, if I only had one more row of vertical space...

Ilmari Karonen

Posted 2012-08-04T03:53:50.710

Reputation: 19 513

2Way to steal the win over a year after the question was asked. – dspyz – 2014-02-02T03:53:57.747

4

30 26 24 22 Parts

my entry 4

Here is my entry, with 22 parts and a time of 4:16. This can be rearranged slightly to fit into a 5 wide by 7 tall space.

It works by dividing the tape into three sections: the instructions (blue and red), the data (green), and a data terminator symbol (yellow). Each cycle of operation, it reads and replaces the first instruction. It then cycles the rest on the instructions to the back of the tape until it reaches the data. For each data symbol read, it adds two of them to the back of the tape. Once the data terminator is read, the instructions are once again at the front of the tape. It deletes the first instruction (which was just executed). It then adds one more data symbol to the end of the tape if the current instruction (read earlier) is blue. The yellow symbol is then re-appended. Once there are no more instructions, then all of the green symbols are converted to red and are output.

Example: input is BBR (110 or 6)
These are the important steps in execution, in more detail than before
BBR
BBRY     #yellow is appended
YBBR     #the instructions are cycled through, execution is on the left half
YBBR     #all of the greens (none yet) are duplicated
BRG      #Y and B are removed and a G appended
BRGY     #yellow is appended
GYBR     #instructions are cycled, execution is on left half
YBRGG    #Gs are duplicated
RGGG     #Y,B removed; G added 
RGGGY    #Y added
GGGYR    #instructions are cycled, execution is on RIGHT half
YRGGGGGG #Gs duplicated
GGGGGG   #YR removed, G NOT added
GGGGGGY  #Y added
YRRRRRR  #Greens are changed to red
RRRRRR   #output

PhiNotPi

Posted 2012-08-04T03:53:50.710

Reputation: 26 739

You appear to have me beaten by one. I'm amazed at how few movers you used and it's planar. – dspyz – 2012-08-05T20:43:18.393

I just shrunk it by two more parts. It's still planar and uses even fewer movers. – PhiNotPi – 2012-08-05T22:43:13.523

Once again, shrunk by two parts, still planar, with even fewer movers. I've done a good job of compressing. – PhiNotPi – 2012-08-06T02:46:08.217

1

I managed 27 parts, but it would fit on a 5x7 grid: Razors solution

I'm using the double-and-add method. Start by putting a green to mark the start of the number and then a green or a yellow to determine whether the next digit pulled off is a zero or a one. Skip past the rest of the number and then double the number of reds currently in place. Finally add one more if the next piece is yellow. Repeat until the number goes to zero.

dspyz

Posted 2012-08-04T03:53:50.710

Reputation: 875

0

17 13 parts

I took some liberty with the specification. I'm going to define the input binary number to appear in little-endian order. You never say explicitly whether the input is little or big endian, but it appears you assume big endian because your tests assume that. I'm going to use these little-endian tests instead.

http://pleasingfungus.com/Manufactoria/?ctm=RazorsLE;Treat_the_input_as_a_little_endian_binary_number_and_output_that_num_of_red;b:r|rrb:rrrr|brb:rrrrr|bbrb:rrrrrrrrrrr|:|rrrrb:rrrrrrrrrrrrrrrr|rbrb:rrrrrrrrrr;7;3;0;

enter image description here

The code works by decrementing the binary number by 1 each loop and adding one yellow mark. At the end, it replaces the yellow with red and deletes the binary number (all blue at this point, representing -1).

Keith Randall

Posted 2012-08-04T03:53:50.710

Reputation: 19 865

1No, in Manufactoria all binary numbers are bigendian. It should pass the tests – dspyz – 2012-08-06T17:59:57.640