Skip to content

Instantly share code, notes, and snippets.

@btforsythe
Created September 26, 2017 21:24
Show Gist options
  • Save btforsythe/043aa4542b703beb7cd13d9e6c885749 to your computer and use it in GitHub Desktop.
Save btforsythe/043aa4542b703beb7cd13d9e6c885749 to your computer and use it in GitHub Desktop.
Clusters Kata

Clusters kata

The problem

Let's say that we have a Collection<Integer> or an int[] (array) of numbers, and we would like to count the groups of adjacent elements with the same value (clumps).

Example

input output
1,4,4,4,9,6,6,7 2 (4s and 6s)

The tests

  1. Test for zero clusters.
  2. Test for one cluster of only two elements.
  3. Test for multiple clusters of only two elements.
  4. Test for multiple clusters where at least one cluster has more than two elements.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment