Spreadsheet Problem
Aug. 14th, 2022 02:55 pmDesign 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.
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.
no subject
Date: 2022-08-15 12:11 am (UTC)A little more high level though... Even without loops (self-references) spreadsheet is some graph (recursion) and the first take solution "flattens" it.
no subject
Date: 2022-08-15 07:45 am (UTC)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.
no subject
Date: 2022-08-15 01:32 pm (UTC)