desguar += and -=
This commit is contained in:
@@ -16,7 +16,7 @@ func solve[ops: Array, e: Array] : i64
|
||||
op : str = array.nth(ops, array.nth(indices, i))
|
||||
|
||||
if str.equal(op, "add")
|
||||
res = res + array.nth(e_1, i + 1)
|
||||
res += array.nth(e_1, i + 1)
|
||||
else if str.equal(op, "mul")
|
||||
res = res * array.nth(e_1, i + 1)
|
||||
else if str.equal(op, "concat")
|
||||
@@ -33,7 +33,7 @@ func solve[ops: Array, e: Array] : i64
|
||||
done = false
|
||||
break
|
||||
array.set(indices, i, 0)
|
||||
i = i - 1
|
||||
i -= 1
|
||||
|
||||
if done
|
||||
return 0
|
||||
@@ -42,7 +42,7 @@ func part1[equations: Array] : void
|
||||
out := 0
|
||||
|
||||
for i in 0..equations->size
|
||||
out = out + solve(["add", "mul"], array.nth(equations, i))
|
||||
out += solve(["add", "mul"], array.nth(equations, i))
|
||||
|
||||
io.println_i64(out)
|
||||
|
||||
@@ -50,7 +50,7 @@ func part2[equations: Array] : void
|
||||
out := 0
|
||||
|
||||
for i in 0..equations->size
|
||||
out = out + solve(["add", "mul", "concat"], array.nth(equations, i))
|
||||
out += solve(["add", "mul", "concat"], array.nth(equations, i))
|
||||
|
||||
io.println_i64(out)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user