Spreadsheet evaluator

Write codeHard45 minMicrosoft and Google style

Your task

Evaluate a tiny spreadsheet. You get cells, a list of [name, formula] pairs. A formula is either a plain integer literal (e.g. '5') or a sum expression of the form 'A+B+C' where each operand is either an integer or another cell name (operands joined by '+'). Resolve every cell to its integer value, handling dependencies in any order. If there is a cyclic dependency, return the string 'CYCLE'. Otherwise return a list of [name, value] sorted by name ascending. Cell names are non-empty alphanumeric strings; every referenced name is defined.

Examples

eval_sheet(cells: list[list]) -> object
Example 1
Inputeval_sheet([["A", "1"], ["B", "A+2"], ["C", "A+B"]])
Output[["A", 1], ["B", 3], ["C", 4]]