SHENZHEN I/O

I think we are at problem number 7 in Shezhen I/O where we are asked to help a security company design a passive infrared sensor that will trigger an alarm between a given time interval, if there is too much activity. We are given a problem where were have the a simple sensor input and a simple alarm output. We also have a simple input giving us time. Further more we have 2 xbus inputs giving us the on and off times. The problem description is simple enough, if the timer is between the on and off time (loop) and the sensor reading is 20 or higher we should trigger the alarm. Just like the signals here tells us

Structure of the passive infrared sensor

I already used the trick of a DX300 last time to convert between an xbus signal and a simple output that only flips on and off. So if we use that again we have 2 simple pins and 3 xbus pins. Which means that a MC6000 can cover all of it, if there is enough room for the lines of codes needed. But let us start coding based on the following structure of the design.

Coding the thing

Since the timing if cyclical I haven’t found a way to just check if the time if between the two, since it varies in the different test cases. On the other hand the clock never skips a beat. So we can just flip a switch whenever the time equals the on or off time. I have used the acc register for it, and used the following code

That means we know that if the acc is 100 then the sensor is active. Actually checking whether the alarm should be triggered is fairly trivial and uses the code.

We start by checking if we are activated. If that is the case we check if the signal is larger then 19, since we need to trigger if the signal is 20 or higher. If that is the case. We will move 10 to x2 as the connection gives us a 100 on the output side for that, and then sleep. If we shouldn’t trigger we will move 0 to x2.

Shenzhen I/o Programming Language

In total that gives us 9 lines of code plus a few comments. Easily fittable withing the available 14 lines of code that we can put into the MC6000 unit.

All in all that means the solution will look like

  • Shenzhen I/O was designed with the same niche audience in mind, specifically people interested in programming. The idea of using the city of Shenzhen, which is a major electronics and high technology manufacturing center in China, as the setting came from Barth reading blogs from Andrew 'bunnie' Huang about his experiences there.
  • Shenzhen I/O is a puzzle game from Zachtronics, of SpaceChem, Infinifactory and TIS-100 fame. Set in a futuristic Shenzhen, global manufacturing hub, you must create the electronic circuits and program the microprocessors to build whatever your job requires!

Buy SHENZHEN I O - PC PC game key from Green Man Gaming Now. Official retailer and remember to sign in for our best price.

This gives us a solution in

Cost: 6
Energy: 358
Lines of code: 9

I know that some managed to find a solution in fewer lines of code, but I cannot figure out how to do that.

Related posts

Once again we are going to make equipment for military use. Someone in the company is not going to be happy about it. This time it is a Carbine Target illuminator, so we can see the bad guys before we shoot them. With the use of radar we are going to measure the distance to the bad guy by counting the number of cycles between output and input to the radar. Based on that we will turn on the laser sight and or the flood light in the following configuration.

If we can cram all the code into one MC6000 we should be able to do it with the following structure on the problem.

That would leave us with a price of 7¥ which is pretty respectable.

Coding the Carbine Target Illuminator

First we need to code something that will reset the counter on a radar-out signal and increase the count when we don’t receive anything on the radar in. That can be done with the follow bits.

That will do exactly what we need and only continue if we get something on the radar-in.

The rest of the code is mostly trivial to write, all we need is to go through and check how long we waited and then set the output as needed.

All in all the solution looks like

Shenzhen i/o reddit

Shenzhen I/o

This gives us a solution in

Cost: 6¥
Energy: 211
Lines of code: 14

Which is the lowest possible production cost, but the lines of code and energy usage could be lower. If they can with this structure I don’t know. I haven’t found better solutions than this. I tried fiddling around with the latter part where we set the outputs, but I haven’t figured out a way to improve it.

Shenzhen I O Review

Related posts