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