Watch
1
0
Fork
You've already forked advent-of-code
0

Print the generated inputs again

This commit is contained in:
Jeremy Kaplan 2019-12-06 00:00:07 -08:00
commit 204b1f7faf

View file

@ -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
puts inp
return inp
end
inp = @input.call
puts inp
inp
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