Question: In one c++ cpp.file Code written in proper C++ There is a game known as Balls and Boxes. There are four boxes and nine balls.
In one c++ cpp.file Code written in proper C++ There is a game known as Balls and Boxes. There are four boxes and nine balls. Balls are placed into the boxes and assigned a value. To keep things simple, the value of a ball in box 1 is one, the value of a ball in box 2 is two, the value of a ball in box 3 is three, and the value of a ball in box 4 is four. The sum of all the balls is 17. An example: Four balls in box #4 and one ball in box #1 gives a total of 17. Write a program that will find and output all possible combinations of the nine balls that will have a value of 17. It is very easy to see that you must have four nested loops having a total of 10,000 or so iterations. However, the point of this program is to be as efficient as possible meaning the fewest number of iterations of each loop to get the job done. The output will be a list of the possible combinations with appropriate headers or descriptive words and the total number of iterations needed to get those combinations.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
