Deviopath › TypeScript

Spreadsheet Formulas

Hard · Graphs

Cells are named like A1 or B12. Write evaluateSheet(cells) that returns the computed value of every cell in cells.

- A cell text is either an integer such as "5" or "-3", or a formula starting with = such as "=A1 + 3 - B2": integers and cell names joined by + and - (spaces are ignored, no unary minus inside formulas).

- If a formula uses a cell that does not exist in cells, the result is "#REF!".

- If a cell is part of a reference cycle, or depends on one, the result is "#CYCLE!".

- Errors spread: when a formula uses a cell whose value is an error, the formula gets that error. Check the terms left to right and stop at the first error.

Each cell should be computed only once (memoize).

Next: Query Engine with Typed Filters