S40TIMESHARE
The task
Two streams share one wire, and every piece is out of place.
P must receive X plus Y, and Q X minus Y. Both reach dx on one wire.
The board
Key idea
Par is 7 swaps. Core mx needs 1 instruction swap and 1 operand swap; core dx needs 3 instruction swaps and 2 operand swaps. Every one of them trades two tiles that hold each other's places, so each swap mends two.
Hints
Each hint goes a step further than the one before. Open them one at a time.
Hint 1Show
mx sends Y first and X after it, so dx knows each value by its turn.
Hint 2Show
dx keeps the first value in B while it reads the second.
Hint 3Show
SUB B takes back an ADD B, so two of them after X plus Y leave X minus Y.
Solution
Reveal the Full SolutionThe complete program for TIMESHARE. Open it only when you want the answer.
The board as dealt
This is the arrangement the game deals. Framed tiles are the ones out of place.
mxSC-1 lite
OUT P0
OUT P2
IN P1
IN P2r1SC-1 lite
IN P0
OUT P1r2SC-1 lite
IN P0
OUT P1dxSC-2 standard
ADD P2
MOV B, A
IN P0
IN B
SUB B
OUT B
OUT P1
SUB P07 swaps back
Make these swaps in order. Lines are numbered from 1 in each core.
- In core
mx, swap the operandP0on line 1 withP1on line 3. - In core
mx, swap the instructionOUTon line 1 withINon line 4. - In core
dx, swap the operandP2on line 1 withP0on line 8. - In core
dx, swap the operandBon line 5 withP1on line 7. - In core
dx, swap the instructionADDon line 1 withINon line 4. - In core
dx, swap the instructionSUBon line 5 withOUTon line 6. - In core
dx, swap the instructionOUTon line 7 withSUBon line 8.
The finished program
Every tile back in place: the reference solution, which scores exactly par on every benchmark.
mxSC-1 lite
IN P1
OUT P2
IN P0
OUT P2r1SC-1 lite
IN P0
OUT P1r2SC-1 lite
IN P0
OUT P1dxSC-2 standard
IN P0
MOV B, A
IN P0
ADD B
OUT P1
SUB B
SUB B
OUT P2- CYCLES
- 436
- at par
- ENERGY
- 3276
- at par
- NODES
- 4
- at par
- INSTRUCTIONS
- 16
- at par
- SWAPS
- 7
- at par