Fixed subtraction
This commit is contained in:
parent
317ad4674d
commit
eea76b7e5b
15
tree.go
15
tree.go
@ -259,10 +259,21 @@ func (operation *Operation) Solution () (solution int64, err error) {
|
|||||||
solution += subSolution
|
solution += subSolution
|
||||||
}
|
}
|
||||||
case OpcodeSubtract:
|
case OpcodeSubtract:
|
||||||
for _, operand := range operation.operands {
|
if len(operation.operands) == 1 {
|
||||||
|
solution, err = operation.operands[0].Solution()
|
||||||
|
solution *= -1
|
||||||
|
if err != nil { return }
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
for index, operand := range operation.operands {
|
||||||
subSolution, err = operand.Solution()
|
subSolution, err = operand.Solution()
|
||||||
if err != nil { return }
|
if err != nil { return }
|
||||||
solution -= subSolution
|
if index == 0 {
|
||||||
|
solution = subSolution
|
||||||
|
} else {
|
||||||
|
solution -= subSolution
|
||||||
|
}
|
||||||
}
|
}
|
||||||
case OpcodeMultiply:
|
case OpcodeMultiply:
|
||||||
solution = 1
|
solution = 1
|
||||||
|
Loading…
Reference in New Issue
Block a user