On a coding assignment, I want my program to detect 3 groups of any number going from 1 to 6. eg. 1 3 4 5 5 3 5 There is 1 group of three 5's but how would I specify that there are three fives? Also, how may pairs of 3 are there in the numbers going from one to 6? eg. 1,2,3 or 4,5,6.
Asked
Active
Viewed 23 times
1 Answers
0
You should post this on Stack Overflow, and not Mathematics... But anyway, you can create a 2nd array of size 6 (since we have 6 optional values) and then loop through the original array, and for each value in it, add one in the counter array (e.g. counterArr[value-1]++). Then all you need to do is just loop through counterArr and check for values >= 3.
talbi
- 896
- 4
- 18
-
Thanks so much! – Luis Briceno Jan 16 '21 at 16:28