diff options
author | Marvin Borner | 2020-12-18 18:38:18 +0100 |
---|---|---|
committer | Marvin Borner | 2020-12-18 18:38:18 +0100 |
commit | 588a4f882689f88b34ee24f14a262425d70df964 (patch) | |
tree | 72b1f01e1096a81c140223b6c50a7fdd0f68db53 /2020/18/solve.c | |
parent | 3552f1a1e29504ff3f3e633478ef5566d53eb1b8 (diff) |
Whoohoo
Diffstat (limited to '2020/18/solve.c')
-rw-r--r-- | 2020/18/solve.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/2020/18/solve.c b/2020/18/solve.c index ae319fe..0fc3eb4 100644 --- a/2020/18/solve.c +++ b/2020/18/solve.c @@ -4,7 +4,7 @@ #include <string.h> #include <time.h> -long add_or_mul(long *res, int num, int mul) +long add_or_mul(long *res, long num, int mul) { if (mul == 0) *res += num; @@ -36,6 +36,8 @@ long evil(char *str, int prec) } else if (*p == ')') { break; // That's why I don't use switch..case } else if (*p == '*') { + if (prec) + return add_or_mul(&res, evil(p + 1, prec), 1); mul = 1; } else if (*p == '+') { mul = 0; |