Welcome back to the weekly programming contests! If you are new to the contest or need a refresher don’t forget to read up on the rules and information Posted Here
This week’s challenge is to write a method (you can call it anything you want) that takes in an integer array and returns the number of “clumps” of integers in the array. For this challenge a clump will be a series of two or more adjacent elements of the same value.
Examples:
clumps([6, 9, 9, 9, 9, 9, 5, 7]) -> 1
clumps([5, 5, 5, 8, 5, 1, 5, 5]) -> 2
clumps([5, 1, 3, 5, 4, 6, 4, 8]) -> 0
clumps([7, 1, 7, 7, 7, 2, 2, 6]) -> 2
clumps([8, 1, 4, 5, 6, 1, 4, 7]) -> 0
clumps([2, 7, 8, 3, 7, 9, 9, 2]) -> 1
clumps([5, 3, 6, 3, 2, 9, 9, 2]) -> 1
clumps([2, 2, 8, 6, 9, 9, 8, 9]) -> 2
clumps([2, 4, 1, 2, 2, 9, 2, 4]) -> 1
clumps([7, 9, 9, 6, 4, 5, 5, 3]) -> 2
Also, if you like these weekly programming problems, please make some suggestions for the contest or specific challenges (in the main thread)! This takes time out of my Sunday and its not always fun! Using suggested challenges makes it a lot faster and easier for me.
Imports are allowed for this challenge!
Challenge Closes: Sunday 1/24/16
Good luck!