Skip to content

Instantly share code, notes, and snippets.

@proustibat
Created December 11, 2017 18:56
Show Gist options
  • Save proustibat/3f622e5d5a907e47c02727c872bfad81 to your computer and use it in GitHub Desktop.
Save proustibat/3f622e5d5a907e47c02727c872bfad81 to your computer and use it in GitHub Desktop.
Ratiorg got statues of different sizes as a present from CodeMaster for his birthday, each statue having an non-negative integer size. Since he likes to make things perfect, he wants to arrange them from smallest to largest so that each statue will be bigger than the previous one exactly by 1. He may need some additional statues to be able to ac…
const makeArrayConsecutive2 = statues => Math.max( ...statues ) - Math.min( ...statues ) + 1 - statues.length;
@proustibat
Copy link
Author

proustibat commented Dec 11, 2017

Example

For statues = [6, 2, 3, 8], the output should be
makeArrayConsecutive2(statues) = 3.

Ratiorg needs statues of sizes 4, 5 and 7.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment