about | help | code help+videos | done | prefs |
Given an array of integers containing values in the range 1 to 6, inclusive, return an array of size 6 containing a count of the number of times each of the six values occur. For example, in the array {3, 1, 1, 2, 4, 4, 4, 6} the number 1 occurs 2 times, the number 2 occurs 1 time, the number 3 occurs 1 time, the number 4 occurs 3 times, the number 5 occurs 0 times, and the number 6 occurs 1 time. SUGGESTION: This can be solved with a single "for each" loop and no if statements. diceStats([3, 1, 1, 2, 4, 4, 4, 6]) → [2, 1, 1, 3, 0, 1] diceStats([3, 3, 3, 5]) → [0, 0, 3, 0, 1, 0] diceStats([6, 6, 6, 6, 6]) → [0, 0, 0, 0, 0, 5] ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 215
Copyright Nick Parlante 2017 - privacy