 # xHell
We are given an Excel spreadsheet with around 80 rows and fivecolumns. The values in the A column are parameters (we will see thatthese are instructions later), and columns B to E are computed using alarge formula, except in the first row, where they are user-providedparameters.
The formula is (example from D14, line breaks and indentation forclarity):
```=IF(MID($A14,4,1)=TEXT(COLUMN()-1,"0"),IF(MID($A14,1,1)="1",    MOD(SUM(        INDIRECT(ADDRESS(ROW()-1,1+MID($A14,2,1))),        INDIRECT(ADDRESS(ROW()-1,1+MID($A14,3,1)))),256),IF(MID($A14,1,1)="2",    MOD(        SUM(INDIRECT(ADDRESS(ROW()-1,1+MID($A14,2,1))),        -INDIRECT(ADDRESS(ROW()-1,1+MID($A14,3,1)))),256),IF(MID($A14,1,1)="3",    MOD(PRODUCT(        INDIRECT(ADDRESS(ROW()-1,1+MID($A14,2,1))),        INDIRECT(ADDRESS(ROW()-1,1+MID($A14,3,1)))),256),IF(MID($A14,1,1)="4",    MOD(MOD(        INDIRECT(ADDRESS(ROW()-1,1+MID($A14,2,1))),        INDIRECT(ADDRESS(ROW()-1,1+MID($A14,3,1)))),256),IF(MID($A14,1,1)="5",    MOD(BITAND(        INDIRECT(ADDRESS(ROW()-1,1+MID($A14,2,1))),        INDIRECT(ADDRESS(ROW()-1,1+MID($A14,3,1)))),256),IF(MID($A14,1,1)="6",    MOD(BITOR(        INDIRECT(ADDRESS(ROW()-1,1+MID($A14,2,1))),        INDIRECT(ADDRESS(ROW()-1,1+MID($A14,3,1)))),256),IF(MID($A14,1,1)="7",    IF(INDIRECT(ADDRESS(ROW()-1,1+MID($A14,2,1)))    =INDIRECT(ADDRESS(ROW()-1,1+MID($A14,3,1))),        1,        0),"X"))))))),D13)```
We can see that this reads an instruction from the A column (afour-digit number), splits it into digits and uses them to compute thevalues in that row. Let's name the digits, in order, `dest`, `x`, `y`and `op`.
We can treat the spreadsheet as an execution trace for a program whichhas four registers `b`, `c`, `d` and `e`, and instructions given inthe A column. The instructions are decoded as:
* take the values in registers `x` and `y` as parameters (where `1`  encodes `b`, `2` encodes `c`, and so on),* compute the result of operation `op` with parameters `x` and `y`,  where values from `1` to `7` encode addition, subtraction, product,  modulus, bitwise-and, bitwise-or and equality testing,* take the result modulo 256, and* write it to the register encoded by `dest`.
The cell which tests if our parameters are accepted checks for threeconditions. For initial values of the registers, we have `b - c == 46`and `e - d == 119`. Further, the final value of `e` must be `1`. Thefirst two checks let us compute `c` and `d` from `b` and `e`, so wecan try all possible values for these two registers (from 0 to 255, sothis doesn't take long) to find one that satisfies the final check andget the flag.