Skip to content

Files

Latest commit

8336045 · Feb 3, 2019

History

History

array-dot-diff

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Feb 3, 2019
Feb 3, 2019

Array.diff

View on Codewars

Your goal in this kata is to implement a difference function, which subtracts one list from another and returns the result.

It should remove all values from list a, which are present in list b.

array_diff([1,2],[1]) == [2]
array_diff([1,2],[1]) == [2]
array_diff([1,2],[1]) == [2]
array_diff([1,2],[1]) == [2]
difference [1,2] [1] == [2]
Kata.ArrayDiff(new int[] {1, 2}, new int[] {1}) => new int[] {2}
array_diff(vec![1,2], vec![1]) == vec![2]
(= (array-diff [1 2] [1]) [2])
Kata.arrayDiff([1,2],[1]) == [2]
arraydiff([1,2],[1]) == [2]
arrayDiff(@[1,2],@[1]) == @[2]
arrayDiff([1,2],[1]) == [2]
array_diff(c(1, 2), 1) == 2

If a value is present in b, all of its occurrences must be removed from the other:

array_diff([1,2,2,2,3],[2]) == [1,3]
array_diff([1,2],[1]) == [2]
array_diff([1,2,2,2,3],[2]) == [1,3]
array_diff([1,2,2,2,3],[2]) == [1,3]
difference [1,2,2,2,3] [2] == [1,3]
Kata.ArrayDiff(new int[] {1, 2, 2, 2, 3}, new int[] {2}) => new int[] {1, 3}
array_diff(vec![1,2,2,2,3], vec![2]) == vec![1,3]
(= (array-diff [1,2,2,2,3] [2]) [1,3])
Kata.arrayDiff([1,2,2,2,3],[2]) == [1,3]
arraydiff([1,2,2,2,3],[2]) == [1,3]
arrayDiff(@[1,2,2,2,3],@[2]) == @[1,3]
arrayDiff([1,2,2,2,3],[2]) == [1,3]
array_diff(c(1, 2, 2, 2, 3), 2) == c(1, 3)

Timeline

  • Created: 2013-09-22
  • Published: 2013-09-22
  • Approved: null
  • Completed: 2019-01-26