Shenzhen I/O: Unknown Optimization Device

Poseidon-779 a Decentralized Autonomous Corporation has decided that we need to help them go into Thorium mining. And while I wont steer off a tangent telling you about Thorium reactors, although they are pretty cool, we should just make this unknown optimization device also known as 2A27.

We get two simple inputs x and y and have to deliver a simple output with a given value. That means we at least have to use 2 micro controllers. So we should not be able to make a solution for less than 6¥.

Analyzing the solution space

we are given the following solution for the output values given the x and y coordinates. And that can seem a little bit overwhelming considering how many lines of code we have available in 2 MC4000.

Shenzhen IO - Unknown optimization device - state space

If we take another look at it we can see that the square in the middle between 40 and 80 on both x and y axis always add 50 to the value given just by the x axis. Which all of a sudden makes the solution a little bit easier. Because that means we can split the problem in two.

The first micro controller should check if we are between 40 and 80 on both x and y axis. And if that is the case output 50, otherwise output 30.

The other microcontroller needs to check if we are between 20 and 60 and in that case output 0 otherwise output 30. Then we need to add the two together and send the result to the output.

Coding the unknown optimization device

Looking at the rough sketch I outlined before it is clear to me that the first micro controller needs both the x and y input on the simple inputs, and therefore needs to send the output

with the xbus to the second micro controller which will check only the x condition, add the two results and send it via a simple output.

The solutions looks like

Shenzhen IO - Unknonwn optimization device

with the code of the first micro controller being

  tgt p0 39
+ tlt p0 80
+ tgt p1 39
+ tlt p1 80
+ mov 50 x1
- mov 0 x1  
  slp 1

And the code of the second micro controller being

  tgt p0 19
+ tlt p0 60
+ mov 0 acc
- mov 30 acc
  add x1
  mov acc p1
  slp 1

This gives a total
Cost: 6¥
Energy: 715
Lines of code: 14


Posted by Kristian

Leave a Reply