05/part1.rb
# Given opcodes, an instruction pointer, and an access mode
# return a valid value.
#
# If the mode is 0, we take the value at the instruction pointer
# as a relative value.
#
# If the mode is 1, we take the value as-is.
Given opcodes, an instruction pointer, and an access mode
return a valid value.

If the mode is 0, we take the value at the instruction pointer
as a relative value.

If the mode is 1, we take the value as-is.
Given opcodes an instruction pointer and an access mode return a valid value . If the mode is 0 we take the value at the instruction pointer as a relative value . If the mode is 1 we take the value as - is .
def value(opcodes, ip, mode)
  value = opcodes[ip]
  case mode
  when 0
    opcodes[value]
  when 1
    value
  else
    raise "WAT"
  end
end
def value ( opcodes , ip , mode ) value = opcodes [ ip ] case mode when 0 opcodes [ value ] when 1 value else raise "WAT" end end
Given opcodes, an instruction pointer, and an access mode
return a valid value.
Given opcodes an instruction pointer and an access mode return a valid value .
opcodes
<not_specific>
ip
<not_specific>
mode
<not_specific>