# Math solver formula

**URL:** <https://connect.superhuman.com/t/math-solver-formula/28035>\
**Category:** Ask the Community\
**Created:** [January 12, 2022, 6:33pm UTC](https://connect.superhuman.com/t/math-solver-formula/28035 "2022-01-12T18:33:45Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Catalin\_M](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/catalin_m/32/8457_2.png) [@Catalin\_M](https://connect.superhuman.com/u/Catalin_M)\
**Post date:** [January 12, 2022, 6:33pm UTC](https://connect.superhuman.com/t/math-solver-formula/28035/1 "2022-01-12T18:33:45Z")

</div>

let’s say I have a text column with this input “4\*10+2”  
is there any to have the result in another column?

---

<div class="post-metadata">

**Author:** ![Scott\_Collier-Weir](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/scott_collier-weir/32/29677_2.png) [@Scott\_Collier-Weir](https://connect.superhuman.com/u/Scott_Collier-Weir)\
**Post date:** [January 12, 2022, 7:02pm UTC](https://connect.superhuman.com/t/math-solver-formula/28035/2 "2022-01-12T19:02:56Z")

</div>

Are you going to have the exact same structure every time?

Meaning will it always be:  
number\*number+number

---

<div class="post-metadata">

**Author:** ![Catalin\_Marin](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/catalin_marin/32/9030_2.png) [@Catalin\_Marin](https://connect.superhuman.com/u/Catalin_Marin)\
**Post date:** [January 12, 2022, 8:51pm UTC](https://connect.superhuman.com/t/math-solver-formula/28035/3 "2022-01-12T20:51:06Z")

</div>

Nope, it must handle any number of addends and factors in any combination

---

<div class="post-metadata">

**Author:** ![Scott\_Collier-Weir](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/scott_collier-weir/32/29677_2.png) [@Scott\_Collier-Weir](https://connect.superhuman.com/u/Scott_Collier-Weir)\
**Post date:** [January 12, 2022, 9:22pm UTC](https://connect.superhuman.com/t/math-solver-formula/28035/4 "2022-01-12T21:22:53Z")

</div>

Hmmmm ok. I think @Paul_Danyliuk might have had some way to do it utilizing his “black-magic” tricks.

There might also be a way to do it with some complex regex()/switchIf() formulas. So the short answer is yes, I believe its feasibly possible but not an easy route towards that end.

Any other geniuses on this community have ideas?

---

<div class="post-metadata">

**Author:** ![Paul\_Danyliuk](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/paul_danyliuk/32/27228_2.png) [@Paul\_Danyliuk](https://connect.superhuman.com/u/Paul_Danyliuk)\
**Post date:** [January 12, 2022, 9:35pm UTC](https://connect.superhuman.com/t/math-solver-formula/28035/5 "2022-01-12T21:35:47Z")

</div>

I think Max had it done earlier. It can indeed be done with black magic but only in a button, not a live formula for a column.

> [@A Tiny SHEET (using a 9 x 20 grid of Formulas)](https://connect.superhuman.com/t/a-tiny-sheet-using-a-9-x-20-grid-of-formulas/25972):
>
> I needed a simple no-frills spreadsheet-like page for a client project. So I built the following and decided to publish it so that others can use it as they want. You must open it in Coda to see it properly. Each ‘cell’ is a formula, labeled A 1 thru I 20 (sorry but coda puts a space between the letter and the number). Thus, when you click on a cell, you edit the formula. Move up one line to the 0 and replace it. You then replace it with a number or an entire formula. The formula can refe…

It is probably possible to build either an ASL or a shunting yard / stack machine impl in a formula for simple `[a1*b1]+[a2*b2]+...+[aN*bN]` polynomials if all that’s required is multiplication and addition, no brackets or other operators.

---

<div class="post-metadata">

**Author:** ![Paul\_Danyliuk](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/paul_danyliuk/32/27228_2.png) [@Paul\_Danyliuk](https://connect.superhuman.com/u/Paul_Danyliuk)\
**Post date:** [January 12, 2022, 9:42pm UTC](https://connect.superhuman.com/t/math-solver-formula/28035/6 "2022-01-12T21:42:26Z")

</div>

UPD: Here’s the solution for just the additions and multiplications:

https://coda.io/embed/10YlQEUZQc/_suh6d?viewMode=embedplay&hideSections=true

The formula is:

```auto
thisRow.Expression.RegexReplace("\s", "").Split("+").FormulaMap(
  CurrentValue.Split("*").FormulaMap(CurrentValue.ToNumber()).Product()
).Sum()

```

where `RegexReplace("\s", "")` removes spaces within the expression, then we split it by additions to get numbers and sequences of multiplications, then for each of those pieces we split by multiplication sign and find a product, and finally sum all those together.

---

<div class="post-metadata">

**Author:** ![Max\_OBrien](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/max_obrien/32/49285_2.png) [@Max\_OBrien](https://connect.superhuman.com/u/Max_OBrien)\
**Post date:** [January 13, 2022, 12:33pm UTC](https://connect.superhuman.com/t/math-solver-formula/28035/7 "2022-01-13T12:33:18Z")

</div>

@Paul_Danyliuk, this is brilliant

well done sir

not a sparkle nor a whiff of dark magic in sight!

but unfortunately, i cant access the document, can you look at the permissions?

max

---

<div class="post-metadata">

**Author:** ![Paul\_Danyliuk](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/paul_danyliuk/32/27228_2.png) [@Paul\_Danyliuk](https://connect.superhuman.com/u/Paul_Danyliuk)\
**Post date:** [January 13, 2022, 12:47pm UTC](https://connect.superhuman.com/t/math-solver-formula/28035/8 "2022-01-13T12:47:58Z")

</div>

Ugh sorry. Expert or not, I still fall victim to forgetting to set sharing settings 😅

---

<div class="post-metadata">

**Author:** ![Max\_OBrien](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/max_obrien/32/49285_2.png) [@Max\_OBrien](https://connect.superhuman.com/u/Max_OBrien)\
**Post date:** [January 13, 2022, 8:52pm UTC](https://connect.superhuman.com/t/math-solver-formula/28035/9 "2022-01-13T20:52:14Z")

</div>

@Paul_Danyliuk, your clever trick inspired me to do this…

This table allows you to enter simple formulas and give then names so you can refer to those names as variables in other formulas.

https://coda.io/embed/JD__hENP-s/_su-8w?viewMode=embedplay&hideSections=true

Absolutely no Black Magic, Dark-Side Forces or Occultic Voodoo used at all! Just pure, clean, supported Coda formulas is all!

enjoy  
Max

---

<div class="post-metadata">

**Author:** ![Christiaan\_Huizer](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/christiaan_huizer/32/28269_2.png) [@Christiaan\_Huizer](https://connect.superhuman.com/u/Christiaan_Huizer)\
**Post date:** [January 14, 2022, 9:05am UTC](https://connect.superhuman.com/t/math-solver-formula/28035/10 "2022-01-14T09:05:08Z")

</div>

that is very clever @Max_OBrien , thanks for sharing  
certainly those who migrate from spreadsheets might benefit from this!  
elegant is word, nice!

```auto
thisRow.Expression
  .Split('-').Join('+-')
  .Split('/').Join('*!')
  .Split('+').FormulaMap(
  CurrentValue.Split('*').FormulaMap(
    If(CurrentValue.StartsWith('!'),
      1/CurrentValue.Slice(2)
      ,CurrentValue)
  ).Product()
).Sum()

```

---

<div class="post-metadata">

**Author:** ![system](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/system/32/24484_2.png) [@system](https://connect.superhuman.com/u/system)\
**Post date:** [March 1, 2022, 6:28pm UTC](https://connect.superhuman.com/t/math-solver-formula/28035/11 "2022-03-01T18:28:41Z")

</div>

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.
