An Interest In:
Web News this Week
- March 20, 2024
- March 19, 2024
- March 18, 2024
- March 17, 2024
- March 16, 2024
- March 15, 2024
- March 14, 2024
August 7, 2020 02:06 pm GMT
Original Link: https://dev.to/thepracticaldev/daily-challenge-278-find-all-non-consecutive-numbers-1eal
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:
Tweet
View Full Article
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To