From 588a4f882689f88b34ee24f14a262425d70df964 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Fri, 18 Dec 2020 18:38:18 +0100 Subject: Whoohoo --- 2020/18/solve.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to '2020/18/solve.c') 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 #include -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; -- cgit v1.2.3