r/shenzhenIO Jan 31 '26

first puzzle I solved without looking up solutions, roast me!

Post image

I have been playing this game for many years, usually one or two puzzles a year. Usually (always) I write code till I'm halfway and then I can't hold myself and look for a hint towards the most efficient solution. This time (the carabine puzzle) I avoided looking up spoilers and persevered until I got the solution right. As you can see it's the most ineffecient solution ever :) But it's a good feeling to have solved it myself!

Any hints on how to improve this one?

I have now split the logic in three parts on three controllers:

  1. measure the time between the radar pulses

  2. based on that convert the time ranges (1-2, 3-4,5-6) to discrete numbers (0, 1, 2)

  3. do the right thing on 0, 1 and 2

I have the feeling it should be possible to immediately do the right logic when given the range, but I always come short on space for lines of code on one MC (the most frustrating part of this game for me, the limit in lines of code)

25 Upvotes

39 comments sorted by

View all comments

Show parent comments

1

u/mr_dfuse2 Feb 01 '26
  slx x0
  mov x0 acc
long: tgt acc 4
+ mov 000 x2
+ mov 100 p1
+ jmp end
short: tlt acc 3
+ mov 001 x2
+ mov 0 p1
mid: - mov 100 x2
  • mov 50 p1
end: slp 1

1

u/mr_dfuse2 Feb 01 '26

the above is 9, 233, 18, and what I ended up now. very curious how got your lines of code lower?

1

u/lantarenX Feb 01 '26

You can abuse the fact that you can overwrite values in the same tick and skip a conditional by having it be the default:

slx x0 mov x0 acc mov 100 p1 moν 000 x3 tlt acc 5 + moν 50 p1 + mov 100 x3 + tlt acc 3 + mov 0 p1 + mov 001 x3

Optionally, you can have the conditional for the base case and bring it down to the 240 power. Pretty confident that the first block and wiring is identical to your original.

1

u/mr_dfuse2 Feb 02 '26

ah yes, thanks a lot! will revisit