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]
|
||||
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
|
||||
when 4
|
||||
output = read(@ip + 1, mode[0])
|
||||
|
|
@ -131,17 +131,17 @@ module Intcode
|
|||
|
||||
def input
|
||||
print 'input> '
|
||||
return default_input if @input.nil?
|
||||
|
||||
inp = @input.call
|
||||
if block_given?
|
||||
inp = yield
|
||||
puts inp
|
||||
inp
|
||||
return inp
|
||||
end
|
||||
|
||||
def default_input
|
||||
gets.to_i
|
||||
end
|
||||
|
||||
def default_input; end
|
||||
|
||||
def operation(cell)
|
||||
(cell % 100)
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue