Syscall 2: Firmware, home

ShuffleChapter 10: Meshes

S37DOG EAR

The task

The rectifier is all here, swapped about. Swap it back.

P0 reads a sine that swings either side of 50 percent.

Fold it: the duty on P1 is the distance from the middle, doubled.

The board

The chip of DOG EARChip u1 with 2 ports: P0 analog in, reaching V2, CH1; P1 pwm out, reaching R1, C1, CH2.u1CHIP SC-2P0ANALOG INV2, CH1P1PWM OUTR1, C1, CH2
The chip's ports, each with its kind and the parts its signal reaches. Cyan reads, lemon writes. On a narrow screen, scroll the board sideways to see all of it.
Sources
V1 2.5 V and V2 2 V sine at 50 Hz
Resistors
R1 1 kΩ
Capacitors
C1 1 µF
Probes
CH1 and CH2

Key idea

Par is 6 swaps. Core u1 needs 4 instruction swaps and 2 operand swaps. 2 of them trade two tiles that hold each other's places; look for those first, since one swap mends both.

Hints

Each hint goes a step further than the one before. Open them one at a time.

Hint 1Show

SUB 50 measures from the middle. Below it, the result is negative.

Hint 2Show

JG skips the NEG when the distance is already positive.

Hint 3Show

MUL 2 doubles whatever reaches it, so it comes after the fold.

Solution

Reveal the Full SolutionThe complete program for DOG EAR. 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.

u1SC-2 standard

OUT 2
MUL 50
SUB P0
NEG
W: IN W
JG P1

6 swaps back

Make these swaps in order. Lines are numbered from 1 in each core.

  1. In core u1, swap the operand 2 on line 1 with P0 on line 3.
  2. In core u1, swap the operand 2 on line 3 with W on line 5.
  3. In core u1, swap the instruction OUT on line 1 with IN on line 5.
  4. In core u1, swap the instruction MUL on line 2 with SUB on line 3.
  5. In core u1, swap the instruction MUL on line 3 with JG on line 6.
  6. In core u1, swap the instruction OUT on line 5 with MUL on line 6.

The finished program

Every tile back in place: the reference solution, which scores exactly par on every benchmark.

u1SC-2 standard

IN P0
SUB 50
JG W
NEG
W: MUL 2
OUT P1
CYCLES
400
at par
ENERGY
800
at par
NODES
1
at par
INSTRUCTIONS
6
at par
SWAPS
6
at par