def run(f) horizontal = 0 depth = 0 f.each do |line| command, distance = line.split(' ') distance = Integer(distance) case command when 'forward' horizontal += distance when 'down' depth += distance when 'up' depth -= distance end end return horizontal * depth end