Skip to content

Latest commit

 

History

History
9 lines (6 loc) · 655 Bytes

File metadata and controls

9 lines (6 loc) · 655 Bytes

Write a method def duplicate_counter(array) that takes an array and returns a number that represents how many duplicate elements were in an array:

  • duplicate_counter([1, 7, 7, 7, 3, 5]) would return 2 because there are 2 sets of duplicate 7s.
  • duplicate_counter([5, 7, 9]) would return 0 because there are no duplicate elements.
  • duplicate_counter([0,-5,-5,33,33,33]) would return 3 because there are 3 sets of duplicates (1 set of -5s and 2 sets of 33s).

Notes:

  • Do the assignment with TDD if you want some TDD practice (you likely will need another file in addition to code.rb for your test suite if you choose to do this)!