On the Subject of Termites
Bugged module. Pls fix.
- This module consists of a 9 by 9 grid of cells, each with an LED. At the centre of this grid is a termite facing north.
- Once active, the termite will begin to move forwards.
Once it leaves a cell, the on/off state of its LED is toggled.
- If the termite enters a cell with a lit LED, it will turn to its left or right according to its instruction tape before moving to the next cell and the next instruction in the tape.
If there are no more instructions in the tape, it is rewound to its first instruction.
To defuse this module, construct the instruction tape used by the termite and determine its path around the grid, then select the point at the edge of the grid from which the termite escapes.
- Interpret the first character of the serial number as a base 36 digit, and zero-index into the table, in reading order, to obtain the first set of instructions.
- The second set of instructions lies in the cell of table whose row is equal to the number of batteries modulo 6, where the top row is row 0, and whose column is equal to the number of ports modulo 6, where the left column is column 0.
- Take the sum of the digits in the serial number and the number of indicators modulo 36, and zero-index into the table, in reading order, to obtain the third set of instructions.
- Concatenate the three sets of instructions in the order they were obtained.
- If the tape has an even number of instructions, remove the last.
- The tape is checked from left to right for substrings of three inputs repeated twice in a row. If one is discovered, the latter substring is inverted.
- The following substrings of instructions are invalid:
If one is discovered, the last instruction in the invalid substring is inverted.