/packNumbers

Packing neighbouring numbers

Primary LanguageJavaScriptMIT LicenseMIT

packNumbers

Given an array of integers, pack neighbouring numbers that are the same as below:

For example, this

packNumbers([9, 9, 1, 5, 5, 5, 9])

should return

["9:2", 1, "5:3", 9]