part 1 working and prep part 2
This commit is contained in:
parent
19147d460c
commit
4633a84ae1
1 changed files with 47 additions and 37 deletions
18
17/main.rb
18
17/main.rb
|
@ -27,6 +27,7 @@ OPERANDS = [
|
||||||
->() { :noop },
|
->() { :noop },
|
||||||
]
|
]
|
||||||
|
|
||||||
|
def execute(registers, program)
|
||||||
stdout = []
|
stdout = []
|
||||||
|
|
||||||
i = 0
|
i = 0
|
||||||
|
@ -67,13 +68,22 @@ while i < program.size
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
p registers
|
[registers, program, stdout.join(",")]
|
||||||
|
end
|
||||||
|
|
||||||
puts stdout.join(",")
|
original_registers = registers.dup
|
||||||
|
_, _, part_1 = execute(registers, program)
|
||||||
|
p part_1
|
||||||
|
|
||||||
|
registers = original_registers.dup
|
||||||
|
_, _, part_2 = execute(registers, program)
|
||||||
|
p program.join(",")
|
||||||
|
p part_2
|
||||||
|
p part_2 == program.join(",") ? "Correct!" : "Not correct!"
|
||||||
|
|
||||||
__END__
|
__END__
|
||||||
Register A: 729
|
Register A: 2024
|
||||||
Register B: 0
|
Register B: 0
|
||||||
Register C: 0
|
Register C: 0
|
||||||
|
|
||||||
Program: 0,1,5,4,3,0
|
Program: 0,3,5,4,3,0
|
||||||
|
|
Loading…
Reference in a new issue