Reported September 2026
Character.AIdesign

Spreadsheet With Dependent Cells

Reported by candidates from Character.AI's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Character.AI OA. Under 2s to a working solution.
Founder's read

The data structure here is a dependency graph, and Character.AI put it in front of candidates in September 2026. You're simulating a tiny spreadsheet with SET, FORMULA and GET commands, and formulas stay live when upstream cells change. If you've got an OA coming up, expect this kind of stateful design problem. The core is a map from cell label to either a literal or a list of terms, plus an evaluation routine that walks the references. It's not hard once you see it. It's easy to overbuild. If you blank mid-assessment, StealthCoder is the invisible safety net that reads the problem and hands you a working structure.

The problem

Simulate a spreadsheet whose cells are labeled from A1 through Z26. Every cell is initially unset and evaluates to 0.
Process a finite sequence of commands:
SET cell value stores a signed integer and replaces any formula previously stored in that cell.
FORMULA cell term+term+... stores an addition formula and replaces any previous contents. Each term is either a nonnegative integer literal or a cell label. A cell label may appear more than once.
GET cell evaluates that cell using the spreadsheet's current contents.
Formula references remain live: changing a referenced cell changes every later GET whose dependency chain reaches it. Every represented formula assignment keeps the dependency graph acyclic.
Return one integer for every GET command, in command order.

Function
evaluateSpreadsheet(operations: String[]) → int[]

Examples
Example 1
operations = ["SET A1 5","SET B1 7","FORMULA C1 A1+B1","GET C1","SET A1 10","GET C1"]
return = [12,17]
The first GET C1 evaluates 5 + 7 = 12. After A1 changes to 10, the stored formula remains live and evaluates to 10 + 7 = 17.
Example 2
operations = ["SET A1 3","FORMULA B1 A1+A1+2","GET B1","FORMULA C1 B1+A1","GET C1","SET A1 4","GET C1"]
return = [8,11,14]
Repeated references count separately, so B1 = 3 + 3 + 2 = 8. Then C1 = 8 + 3 = 11. Updating A1 changes both levels, giving B1 = 10 and C1 = 14.
Example 3
operations = ["GET Z26","FORMULA A1 Z26+5","GET A1","SET Z26 2","GET A1","SET A1 -3","GET A1"]
return = [0,5,7,-3]
An unset cell evaluates to 0. The formula in A1 observes the later update to Z26. The final SET replaces the formula in A1 with the literal -3.

Constraints
1 ≤ operations.length ≤ 10000.
Every command uses a valid cell label from A1 through Z26.
Each formula contains at least one term and at most 676 terms.
The total number of formula terms across all commands is at most 200000.
Every formula assignment leaves the dependency graph acyclic.
Every stored integer and every evaluated result fits in a signed 32-bit integer.

Reported by candidates. Source: FastPrep

Pattern and pitfall

Store each cell as one of two things: a literal value or a list of terms from the formula. On GET, evaluate recursively with memoization. A cell with no entry returns 0. A formula sums its terms, where each term is either an integer literal or a recursive call on a label. Repeated references count separately, so don't dedupe terms. The graph is guaranteed acyclic, so no cycle detection is needed. The main pitfall is caching across commands. A cached value goes stale the moment any SET or FORMULA runs, so either clear the memo on every write or use a fresh memo per GET. A fresh memo per GET is simplest and safe. The grid is only 676 cells, so each GET costs at most the total stored terms, which fits the limits. Also handle negative SET values and replace old contents fully on every write. StealthCoder is your hedge in the live OA if the recursion or parsing trips you up.

StealthCoder is the hedge for the one pattern you didn't drill. It runs invisibly during the screen share.

If this hits your live OA

You can drill Spreadsheet With Dependent Cells cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. If you're reading this with an OA window open, you're who this was built for.

Get StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass Character.AI's OA.

Character.AI reuses patterns across OAs. If you're reading this with an OA window open, you're who this was built for. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Spreadsheet With Dependent Cells FAQ

What's the trick in the Character.AI spreadsheet problem?+

Store each cell as a literal or a list of terms, then evaluate on GET with recursion and a per-GET memo. Don't precompute on write. Live references mean values change when upstream cells change, so lazy evaluation keeps it correct and simple.

Do I need cycle detection?+

No. The problem guarantees every formula assignment keeps the dependency graph acyclic. Skip detection and write the plain recursive evaluator. Adding it just burns time and creates more code to get wrong.

Why does caching cause wrong answers here?+

A cached cell value goes stale after any SET or FORMULA. If you keep a memo across commands, later GETs return old numbers. Use a fresh memo per GET, or clear the cache on every write. Example 1 tests exactly this.

How should I parse the commands?+

Split each command on spaces. For SET, parse the third token as a signed integer. For FORMULA, split the third token on plus signs. A term that starts with a digit is a literal, otherwise it's a cell label. Keep repeated labels as separate terms.

How do I prepare for this in 48 hours?+

Write the solution once from scratch: a map of cells, a recursive evaluate function, and a memo reset per GET. Run the three examples, especially the unset cell and the repeated reference case. That covers nearly every edge in this problem.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Character.AI.

OA at Character.AI?
Invisible during screen share
Get it