Simple: stop looking at the numbers!

Copy the data into a second array.

Sort it.

Look through, comparing each number with the previous two...

Sorting is built in and pretty efficient, and after that it's a single pass check to find the repeats.

Alternatively, since you only have 6 numbers to work from: set up a second array of six integers - call it the counts array. Zero the new array. Loop through the dice rolls array, and increment the appropriate index in the counts array for each roll value.

A quick pass through the counts array afterwards tells you how many times each value has been rolled.

15,664,272 members