[personal profile] aklepatc
Design and implement a simplified spreadsheet. Spreadsheet consists of cells. Every cell has a string id. All ids are valid so there is no need to validate them. A cell contains an integer value or a formula like "=A1+B1". You can assume that all formulas are valid and "+" is the only operation that needs to be supported.

What is wrong and what is very wrong with my original solution?
https://go.dev/play/p/v0SXCGdaQsu

JIC: this is not meant to be language-specific. If you at least can read my Go then you are all set.

Date: 2022-08-15 12:00 am (UTC)
From: [personal profile] sassa_nf
No recursion support? No self-reference check?

Date: 2022-08-15 07:45 am (UTC)
From: [personal profile] sassa_nf
The quoted solution doesn't flatten it. It assumes the referenced cells always contain a value, not another formula. That's what I mean by recursion support.

I don't see other problems - except normally you'd want to initialize the accumulator before the loop; it works here only because it happens we want it to be 0, just what s.val[...] does on missing key, but I'd still call out the absence of a deliberate initialization.

Curious to know what else is wrong with it.

Profile

aklepatc

May 2024

S M T W T F S
   1234
567 891011
12131415161718
19202122232425
262728293031 

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Feb. 27th, 2026 11:14 pm
Powered by Dreamwidth Studios