Find the Duplicates

You’ll find multiple reasons to remove duplicates from a series of random numbers. The main reason is that the process or generating random numbers is capable of yielding duplicate values. But more importantly, if your list represents discrete items in the real world, such as playing cards, you can’t really have a duplicate value pop up.

The task for this month’s Exercise is to generate a list of 15 random values in the range of 10 to 50. Display each value. Then cull through the list to display any duplicates.

Here’s sample output from my solution:

 13 29 45 30 55 57 18 33 24 26 18 29 54 55 19

You don’t need to purge the duplicates from the array, nor do you need to count how many times a value is repeated. Just display the duplicate values.

Please try this Exercise on your own before looking at my solution.

Leave a Reply