Question: code javascript: Given a subset of a series of dice roll results, and the arithmetic mean of all results, find the missing results. Task description
code javascript:
Given a subset of a series of dice roll results, and the arithmetic mean of all results, find the missing results.
Task description
You have just rolled a dice several times. The N roll results that you remember are described by an array A However, there are F rolls whose results you have forgotten. The arithmetic mean of all of the roll results the sum of all the roll results divided by the number of rolls equals M
What are the possible results of the missing rolls?
Write a function:
function solutionA F M;
that, given an array A of length N an integer F and an integer M returns an array containing possible results of the missed rolls. The returned array should contain F integers from to valid dice rolls If such an array does not exist then the function should return
Examples:
Given A F M your function should return The arithmetic mean of all the rolls is
Given A F M your function may return or among others
Given A F M your function should return It is not possible to obtain such a mean.
Given A F M your function should return It is not possible to obtain such a mean.
Write an efficient algorithm for the following assumptions:
N and F are integers within the range ;
each element of array A is an integer within the range ;
M is an integer within the range
Remember, all submissions are being checked for plagiarism. Your recruiter will be informed in case suspicious activity is detected.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
