Created
February 27, 2020 01:49
-
-
Save zmaupin/6b704558cb39439718a98c8e47fe899f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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