Skip to content

Conversation

@ErdemT09
Copy link
Collaborator

@ErdemT09 ErdemT09 commented Jul 25, 2021

Resolves: #242

Algorithm:

When calculating the value of each cell, there are 2 possibilities:

  1. The cell only has a value.
  2. The cell points to a collection of cells and/or rectangles.

set() method updates the value of some cell to an integer.
sum() method updates the value of some cell to a collection of cell names.

In order to get the value of summed cells, 2. type of cells, we try to calculate the value of each cell/rectangle they point at.
Let's say: D4 = [B1:C2, A2]. In order to calculate D4, we need to calculate The range B1:C2. This range might also contain references to other ranges, for example a case might be: B2 = [A1:A3]. For calculating this, we also need to sum this range. This yields a recursive method where we calculate the value of each cell each time by calculating the ranges they point to. When values are updated, the structure recalculates such values each time again, so we don't have to worry about updating something like the prefix sum etc.

In implementation, cells are Objects that are either Integer, pure value, or String[], reference to other cells by name, which gets parsed by the calculate() method.

@ErdemT09 ErdemT09 marked this pull request as ready for review July 25, 2021 11:20
Copy link
Collaborator

@altay9 altay9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution Erdem.
Quite clear code and explanation.

@ErdemT09 ErdemT09 merged commit a89783b into master Jul 26, 2021
@ErdemT09 ErdemT09 deleted the 631.-Design-Excel-Sum-Formula branch July 26, 2021 04:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

631. Design Excel Sum Formula

3 participants