Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
August 7, 2020 02:06 pm GMT

Daily Challenge 278 - Find all non-consecutive numbers

Your task is to find all the elements of an array that are non consecutive. A number is considered non consecutive if it is not exactly one larger than the previous element in the array. The first element always gets a pass.

You should return the results as an array of objects with two values i: and n: .

Example

For the the array [1,2,3,4,6,7,8,10], the result should be:

nconsecutive([1,2,3,4,6,7,8,10])[  {'i': 4, 'n': 6},  {'i': 7, 'n': 15}]

Tests

[6,7,8,9,11,12]
[100,101,102,112,113,114,129]

Good luck!

This challenge comes from thecodeite on CodeWars. Thank you to CodeWars, who has licensed redistribution of this challenge under the 2-Clause BSD License!

Want to propose a challenge idea for a future post? Email [email protected] with your suggestions!


Original Link: https://dev.to/thepracticaldev/daily-challenge-278-find-all-non-consecutive-numbers-1eal

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To