Train Now

Start training on this collection. Each time you skip or complete a kata you will be taken to the next kata in the series. Once you cycle through the items in the collection you will revert back to your normal training routine.

Description

def dirReduc(arr)
arr.each_with_index do |direction, index|
if direction == "NORTH"
if arr[index + 1] == "SOUTH"
arr.slice!(index, 2)
dirReduc(arr)
end
elsif direction == "SOUTH"
if arr[index + 1] == "NORTH"
arr.slice!(index, 2)
dirReduc(arr)
end
elsif direction == "EAST"
if arr[index + 1] == "WEST"
arr.slice!(index, 2)
dirReduc(arr)
end
elsif direction == "WEST"
if arr[index + 1] == "EAST"
arr.slice!(index, 2)
dirReduc(arr)
end
else
return arr
end
end
end

Ad