1
0

Don't actually need recursion

This commit is contained in:
Hubert Van De Walle 2020-12-18 13:11:20 +01:00
parent b9d62c2835
commit 83b5a09e73

View File

@ -43,7 +43,7 @@ class Day18(@Lines val input: Input<List<String>>) {
private fun solveGroup(group: String, precedence: Boolean) = solveGroup(parseGroup(group), precedence)
private tailrec fun solveGroup(group: Pair<LinkedList<Long>, LinkedList<Operator>>, precedence: Boolean): Long {
private fun solveGroup(group: Pair<LinkedList<Long>, LinkedList<Operator>>, precedence: Boolean): Long {
val (operands, operators) = group
println(operands)
println(operators)
@ -79,7 +79,7 @@ class Day18(@Lines val input: Input<List<String>>) {
i++
}
return solveGroup(operands to operators, precedence = false)
return operands.reduce { a, b -> Operator.Multiply(a, b) }
}
}