Update Amplifier.scala

This commit is contained in:
kamoshi 2019-12-07 19:16:06 +01:00 committed by GitHub
parent 3049cfe9a2
commit 7710b34de7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -27,8 +27,8 @@ class Amplifier(input: Array[Int])
case (_, _, _, OpCode99) => case (_, _, _, OpCode99) =>
halted = true halted = true
this this
case (_, _, m1, outputInstr: Output) => this case (_, _, _, outputInstr: Output) => this
case (_, _, m1, inputInstr: Input) => this case (_, _, _, inputInstr: Input) => this
case (m3, m2, m1, instruction: Jump) => case (m3, m2, m1, instruction: Jump) =>
val (bool, jmpPtr) = instruction.checkConditionAndJump(software, software(pointer+1), software(pointer+2), software(pointer+3), m1, m2, m3) val (bool, jmpPtr) = instruction.checkConditionAndJump(software, software(pointer+1), software(pointer+2), software(pointer+3), m1, m2, m3)
if (bool) pointer = jmpPtr if (bool) pointer = jmpPtr
@ -51,9 +51,9 @@ class Amplifier(input: Array[Int])
case (_, _, m1, inputInstr: Input) => case (_, _, m1, inputInstr: Input) =>
inputInstr.input(software, software(pointer+1), m1, input) inputInstr.input(software, software(pointer+1), m1, input)
pointer += inputInstr.length pointer += inputInstr.length
this
case _ => throw new Exception("Unexpected instruction") case _ => throw new Exception("Unexpected instruction")
} }
this
} }
def runOutput(): Int = def runOutput(): Int =