Return the last color of the input in Manufactoria

10

This puzzle is the next in my series of Manufactoria challenges.

Background

Manufactoria is a game / two-dimensional programming language. The player must create programs that will manipulate a queue to arrive at the desired output. It is easy to learn but hard to master, so it lends itself to creating a wide variety of challenges. If you don't know what I am talking about, I advise that you play the first few tutorial levels of the game.

Challenge

Your challenge is to create a machine that will return the very last element of the input string. To make this even more challenging, the input string can be any combination of all four colors.

The official custom level to be used is found here:

http://pleasingfungus.com/Manufactoria/?ctm=Last_in_Line!;IN:_a_series_of_colors_OUT:_the_very_last_color;byrgyrbyrrgry:y|bbrrbryyyrrbr:r|ggryybrryr:r|b:b|:|gyrbrygbrygbyrb:b|brbrbryyrygbrg:g|rrrrrrrrrr:r;13;3;0;

This week's challenge is mostly focused on the idea of compression. I chose this challenge to require a huge mess of conveyor belts. The fact that all four colors appear in the input means that it is very hard to store information.

Although I did not attempt compression, my first working prototype had 114 parts and fit into the 13x13 space with almost no room to spare.

Scoring

The goal of this challenge is to use a few parts as possible. The score is the number of parts placed, and the lowest score wins.

Although there are only 8 test cases, your creation should be able to theoretically function under any test case. The test cases provided are for debugging purposes.

Examples

in:  byrgyrbyrrgry
out: y
in:  ggryybrryr
out: r
in:         #don't you love degenerate cases?
out:
in:  gyrbrygbrygbyrb
out: b

PhiNotPi

Posted 2013-06-14T17:22:00.920

Reputation: 26 739

Answers

6

65 parts

enter image description here To be honest I couldn't even come up with the idea of putting pairs of readers directly against each other until I saw it in the already-posted solutions. But later I started to come up with a lot of optimization tricks.

Link

feersum

Posted 2013-06-14T17:22:00.920

Reputation: 29 566

...you can put conveyor belts on top of eachother? – SuperJedi224 – 2016-04-15T13:58:38.633

4

Howard

Posted 2013-06-14T17:22:00.920

Reputation: 23 109

A little rearranging of conveyor belts reduced this down to 81 parts. See here. Also, changing the colours around seems to make it faster (although it really doesn't matter) from 6:23 to 5:38. See this paste for the URL.

– Volatility – 2013-06-15T07:14:28.420

@Volatility Thank you for the 3 parts. The seems faster totally depends on the test cases, so it really doesn't matter ;-) – Howard – 2013-06-15T07:47:59.953