7
\$\begingroup\$

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)

\$\endgroup\$
  • 1
    \$\begingroup\$ How do you win the competition? \$\endgroup\$ – beary605 Aug 4 '12 at 5:24
  • \$\begingroup\$ Lets say least pieces. I really just want to see if people come up with different solutions than I did \$\endgroup\$ – dspyz Aug 4 '12 at 7:28
5
\$\begingroup\$

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...

\$\endgroup\$
  • 2
    \$\begingroup\$ Way to steal the win over a year after the question was asked. \$\endgroup\$ – dspyz Feb 2 '14 at 3:53
4
\$\begingroup\$

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
\$\endgroup\$
  • \$\begingroup\$ You appear to have me beaten by one. I'm amazed at how few movers you used and it's planar. \$\endgroup\$ – dspyz Aug 5 '12 at 20:43
  • \$\begingroup\$ I just shrunk it by two more parts. It's still planar and uses even fewer movers. \$\endgroup\$ – PhiNotPi Aug 5 '12 at 22:43
  • \$\begingroup\$ Once again, shrunk by two parts, still planar, with even fewer movers. I've done a good job of compressing. \$\endgroup\$ – PhiNotPi Aug 6 '12 at 2:46
1
\$\begingroup\$

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.

\$\endgroup\$
0
\$\begingroup\$

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).

\$\endgroup\$
  • 1
    \$\begingroup\$ No, in Manufactoria all binary numbers are bigendian. It should pass the tests \$\endgroup\$ – dspyz Aug 6 '12 at 17:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.