We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
The whole thing can actually be solved in one loop. Initialize sumtotal to 0. Run the loop m times/while input exists whatever you choose, take input one by one in list/array whatever you use.
Input is of the form:
a,b,candy
do sumtotal = sumtotal + (b-a+1)x(candy)
for each input
Filling Jars
You are viewing a single comment's thread. Return to all comments →
If you're getting timeout:
The whole thing can actually be solved in one loop. Initialize sumtotal to 0. Run the loop m times/while input exists whatever you choose, take input one by one in list/array whatever you use. Input is of the form:
a,b,candy
do sumtotal = sumtotal + (b-a+1)x(candy) for each input
average = sumtotal/n