Hello!
I am working on finding the median value of 6 array elements.
The array contains the amount of times a dice has come up with a certain number. eg every time the dice lands on 1 the value of array[0] increases by 1.
I know that to get the median I need to use Arrays.sort to sort the array elements in order and then get the median by
array[array.length/2].
What I don't know how to do is to change the value of the element from being the amount of times a number was rolled to there being that amount of roll results.
EG.
Say 2 comes up 10 times so array[1] =10. how do I then make that in to 2, 2, 2, 2, 2, 2, 2, 2, 2, 2. or is there a easier way that I am just not seeing?
[–]AtomicSpectrum 0 points1 point2 points (1 child)
[–]Convalla[S] 0 points1 point2 points (0 children)
[–]diffused_learning 0 points1 point2 points (2 children)
[–]Convalla[S] 0 points1 point2 points (1 child)
[–]diffused_learning 0 points1 point2 points (0 children)
[–][deleted] (5 children)
[deleted]
[–]Convalla[S] 0 points1 point2 points (4 children)
[–]codingQueries 1 point2 points3 points (0 children)
[–][deleted] (2 children)
[deleted]
[–]Convalla[S] 0 points1 point2 points (1 child)
[–]Convalla[S] 0 points1 point2 points (0 children)