Skip to content

Instantly share code, notes, and snippets.

@zmaupin
Created February 27, 2020 01:49
Show Gist options
  • Select an option

  • Save zmaupin/6b704558cb39439718a98c8e47fe899f to your computer and use it in GitHub Desktop.

Select an option

Save zmaupin/6b704558cb39439718a98c8e47fe899f to your computer and use it in GitHub Desktop.
def symmetrical_difference(arr1, arr2)
arr = []
arr2.length.times do |index|
arr << arr2[index] if arr1.include?(arr2[index]) && !arr.include?(arr2[index])
arr << arr1[index] if arr2.include?(arr1[index]) && !arr.include?(arr1[index])
end
arr
end
p symmetrical_difference([1, 41, 10, 21], [30, 21, 1, 10])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment