Skip to content

Latest commit

 

History

History
12 lines (7 loc) · 886 Bytes

File metadata and controls

12 lines (7 loc) · 886 Bytes

Write a method def minimum_consecutive_integers(array) that takes an array of integers and returns the minimum number of integers required to make array consecutive. Consider the following examples:

  • minimum_consecutive_integers([1, 3]) would return 1 because there is 1 integer (2) which needs to be inserted in order for the sequence to be consecutive.

  • minimum_consecutive_integers([2, 5]) would return 2. 3 and 4 would need to be inserted to make the array a consecutive sequence.

  • minimum_consecutive_integers([-1, 4]) would return 4. 0, 1, 2 and 3 would be inserted to make the array a consecutive sequence.

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)!
  • Assume each inputted array would have a minimum of 2 elements.