In-memory Spreadsheet with formula recalc

seniorjava · AI-on
  1. 1Restate the problem in one line
  2. 2Sketch the data model yourself
  3. 3Ask AI for a skeleton ONLY
  4. 4Ask AI for a test plan ONLY
  5. 5Implement the core logic yourself
  6. 6Run the tests — verify, don't trust
  7. 7Ask AI for edge cases you missed
  8. 8Ask AI to review your code
  9. 9Make the final judgment yourself

Problem

Build an in-memory spreadsheet. set(cell, expr) stores a literal number or a formula like "=A1+A2" (cell references and + only). get(cell) returns the evaluated integer value, recomputed from current inputs. Updating an input must be reflected by later reads.

iThe deal with the pair partner

The AI is deliberately fallible — it gives hints, not solutions, and sometimes proposes wrong code. It cannot touch your editor. Paste what you choose, then Run. Anything AI-derived stays UNVERIFIED until your tests go green.

Self-check

  • get recomputes from current values (no stale cache, or the cache is invalidated on set)
  • a formula references other cells and sums them
  • updating an input cell changes dependent reads
  • you stated time and space complexity
  • you named what happens on a reference cycle (even if you don't fully handle it)
Hints / what this doesn't test

This is an Opendoor-flavored applied problem: a small system with state and recomputation, not a puzzle. Restate it back before coding — "So a cell is either a number or a +-formula over other cells, and get always reflects the latest inputs?"

What this problem does not test (say so out loud): multiplication / operator precedence, ranges like A1:A3, and cycle handling are out of scope here — but a senior names the cycle case (A1=B1, B1=A1) as a known gap and how they'd detect it (visited-set during evaluation).

Solution.javaauto-runs ~0.8s after you pause
unverifiedEdited since last clean run — run to verify.

Tests

○ Not run yet — edit the code or press Run
  • literal
  • formula_sum
  • chained
  • + 1 hidden test — revealed once the visible ones pass

Pair partner (병신 모드 · 버그 잡기)

gpt-4o-mini

Ask for a skeleton or a test plan — not the answer. Then implement the core yourself and come back for edge cases. Remember: the partner is fallible. Verify everything by running it.

The partner sees your editor but cannot change it. Copy any suggestion in by hand, then Run to verify.

AI랑 먼저 페어하고 눌러