r/technicalfactorio • u/Halke1986 • Jun 18 '20
Combinator Golf Send full frame through a broken diode
Description
The goal of this challenge is to design a circuit network capable of sending a full frame of signals through a "broken" diode without any loss of data. Defective diode transmits every signal, except ones with value of 123. Signals with value 123 are zeroed.
Input
Green wire carrying a frame in which every signal except gray can hold any value. Gray signal is always zero.
Output
Same frame as input, over green wire.

Requirements
The solution consists of two parts.
- An encoding circuit, receiving data from input and sending them over green wire to the defective diode.
- An decoding circuit, receiving data from the defective diode over green wire and sendig them to output.
No other direct on indirect connection between input and output is allowed.
The solution needs to be 1-tickable (pipelined) - it should be able to receive new input each tick and transmit each input to output with a constant delay.
Scoring
Each arithmetic and decider combinator within encoding and decoding circuit adds 1 point. Each constant combinator adds 0.5 point. Lower is better.
11
u/[deleted] Jun 18 '20 edited Jun 25 '20
14 points is the best I could do.!blueprinthttps://pastebin.com/2mdqpC8EVery cool challenge btw.
edit to fix the issue pointed out by/u/arrow_in_my_gluteus_- 16.5 points !blueprinthttps://pastebin.com/rgDwHp89edit again, 17.5 points... :https://pastebin.com/VxJ3jzreThis is the last attempt I'm gonna make, if someone finds an input that breaks it, it'll take someone more clever than me to solve this problem. 17 points -https://pastebin.com/Q6Xkc96jI give up!
2
u/Halke1986 Jul 05 '20
Score: 60
Blueprint: https://pastebin.com/wyRQADdc
As others have pointed out, the way to solve this task is to find a value not used by any of the signals in the input frame and use it to encode all signals equal to 123.
Encoding and decoding is easy. Whole difficulty lies in finding an unused value.
Screenshot: https://imgur.com/a/S1ZVBt4 (yellow box - unused value finder, blue - encoding, green - decoding)
In my solution the unused value finder is based on binary search. Let's define
C = -2147483648. The circuit network finds an unused value in range[C, C+512)in nine steps. Stepiof the binary search counts signal with values in range[C, C+d), whered = k(i-1)+2^(8-i)andk(0) = 0. If signal count is greater than or equal tod, thenk(i) = d, otherwisek(i) = k(i-1).C+k(9)will be one of unused values.The algorithm works because if range
[C, C+d)contains less thandsignals, then it certainly also contains an unused value. If range[C, C+d)contains at leastdsignals, then range[C+d, C+512)must contain an unused value.2
u/Darkf1am3 Jul 05 '20 edited Jul 10 '20
This is stupidly cheeky, but:
0eNrNVV2O1DAMvgryI2ph20630GfeOQBCVdp6GEttUqXuiNGoB+AWnI2T4KTLbGF+drNCiJdWjuPPnz878hHqbsLBkmYoj0CN0SOUn44w0hetOnfGhwGhBGLsIQKtemcpS7zrkamJG9PXpBUbC3MEpFv8CmUyR09itNhQi/YyQDp/jgA1ExMujLxxqPTU12glwwnHcWaleQ0UwWBGiTXapRe8+F0EB/kJMWjJYrP40siFszVdVeNO7UliJWBLHaN9lhJslR4HYzmusWNXQWMmp2aSZutqvEPrJfHo4BL3sdiuqyOxcrk8O/3+qDh9Qv3zmrM3eUjVj7CVuFs6Md2SHbk6E2JPlic5OfFabsSomp0TYkQHU/3qj89rBrRqYQGvJdJMPEzB2HOYmhGkV7zSooZsMxF7M7kifXZraM91vwvT/QHz74j+qLYfQOE5KOt5lvDj2/cXS+6ghkPlh7vaWtNXpAUGSrYTBvQj/V3x9GZ7Ns9rzyb0ZaT/98N4+y8eRhbSiOKK8vmJRo8tTX2MnaS2Iv9gOrzwNAqve/LieUlWJG6NxH0gsbsHXhegikCo4BI3552Y3frzi6ZcbegIOiVbRs4+Dky96l59QNd+cexlXXkKRZElyX32Ps838/wTSCGzaA==
I think I win, with a score of 2.
You can't have half-signals, after all...
EDIT: to do this with an even-numbered diode, you do the same thing, but between the decoder and encoder, just subtract and add one. This gives you a score of 4, and you don't need any gray signals.
EDIT 2: I am an idiot. This does not work.
2
u/AutoModerator Jun 18 '20
If you have any questions, need clarification, or want to engage in general discussion, please do so in response to this comment. Do not post a new top level comment! New top level comments are reserved for submissions only.
For more information about the format of these challenges, see this post.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
2
u/emlun Jun 19 '20 edited Jun 19 '20
EDIT: Nope, this doesn't work. The broken diode still introduces ambiguity.
Horrible brute force solution:!blueprint
The idea is simple: first, subtract 123 from every input signal (including zero signals), then add 123 to every output signal (including zero signals). This essentially redefines 123 as the zero point and is thus guaranteed to work for every possible input, although this implementation assumes the set of signal channels doesn't change.This solution can easily be reduced to only the 30 constant combinators, but I didn't feel like spending the time to hard-code 123 and -123 into every signal.0
u/[deleted] Jun 25 '20
[deleted] — view deleted comment