Print the generated inputs again
This commit is contained in:
parent
45bc074396
commit
204b1f7faf
1 changed files with 8 additions and 8 deletions
|
|
@ -90,7 +90,7 @@ module Intcode
|
||||||
r = @mem[@ip + 1]
|
r = @mem[@ip + 1]
|
||||||
raise StandardError, "unexpected mode: #{mode[0]}" if mode[0] != 0
|
raise StandardError, "unexpected mode: #{mode[0]}" if mode[0] != 0
|
||||||
|
|
||||||
@mem[r] = user_input.nil? ? input : user_input.call
|
@mem[r] = input(&user_input)
|
||||||
@ip += 2
|
@ip += 2
|
||||||
when 4
|
when 4
|
||||||
output = read(@ip + 1, mode[0])
|
output = read(@ip + 1, mode[0])
|
||||||
|
|
@ -131,17 +131,17 @@ module Intcode
|
||||||
|
|
||||||
def input
|
def input
|
||||||
print 'input> '
|
print 'input> '
|
||||||
return default_input if @input.nil?
|
if block_given?
|
||||||
|
inp = yield
|
||||||
inp = @input.call
|
|
||||||
puts inp
|
puts inp
|
||||||
inp
|
return inp
|
||||||
end
|
end
|
||||||
|
|
||||||
def default_input
|
|
||||||
gets.to_i
|
gets.to_i
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def default_input; end
|
||||||
|
|
||||||
def operation(cell)
|
def operation(cell)
|
||||||
(cell % 100)
|
(cell % 100)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue