D18XOR CHECK
The task
Transmit each host message, then the XOR of all its bytes.
The ticket printers on the ferries check every line with an XOR byte: a bit that flips anywhere in the line flips the same bit of the check.
For each host message, transmit the message, then one check byte: every byte of the message combined with XOR. An empty message is just the check byte $00.
XOR A, B compares A and B bit by bit. Each bit of A ends up set where the two bits differ and clear where they match.
The board
Key idea
The check is ready the moment the message ends, so it can go out last and needs no RAM.
Hints
Each hint goes a step further than the one before. Open them one at a time.
Hint 1Show
Keep the check in B. Clear it at the start of each message and fold in every byte you transmit.
Hint 2Show
XOR B, A folds A into B. The order of the bytes does not matter, and the -1 at the end must stay out of it.
Hint 3Show
START: MOV B, 0. NEXT: HIN A, JEQ A, -1, DONE, OUT A, XOR B, A, JMP NEXT. DONE: OUT B, and the card wraps to start.
Solution
Reveal the Full SolutionThe complete program for XOR CHECK. Open it only when you want the answer.
The reference program
The game's own solution to this ticket. It passes every test and scores exactly par on every benchmark.
START: MOV B, 0
NEXT: HIN A
JEQ A, -1, DONE
OUT A
XOR B, A
JMP NEXT
DONE: OUT B- TICKS
- 137
- at par
- LINES
- 7
- at par