class A def initialize dy = [-1, 0, 0, 1] dx = [ 0, 1,-1, 0] direct = {'N' => 0, 'E' => 1, 'W' => 2, 'S' => 3} s = gets.chomp.split('') y = 0 x = 0 s.each do |d| y += dy[direct[d]] x += dx[direct[d]] end puts Math.sqrt(y**2 + x**2) end end A.new