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.3and4would need to be inserted to make the array a consecutive sequence. -
minimum_consecutive_integers([-1, 4])would return 4.0,1,2and3would 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.rbfor your test suite if you choose to do this)! - Assume each inputted
arraywould have a minimum of 2 elements.