Reference no: EM132156735
Define the function marbles(n) to solve the following problem:
A company packages and sells boxes with marbles. The boxes come in two sizes: huge and small. The "huge" box contains 48 marbles and the "small" box contains 8 marbles. The company makes the most gain by selling huge boxes: CDN$26 each. Small boxes produce less gain but still some: a small box provides the company CDN$4 gain. On the other hand, the company loses CDN$ 2 per marble not packaged. Thus, the company will attempt to package as many huge boxes as possible, and then as many small boxes as possible.
This function receives as input in the parameter variable a number of marbles available and it should return a string with the following information: first, the number of huge boxes to package, followed by two dots ("..") followed by the number of small boxes to package, followed again by two dots, followed by the number of unused marbles, followed by two dots and finally the money the company makes, considering the gains (because of the boxes packaged) minus the losses (because of the unused marbles).
For example, calling this function as marbles(503) should return '10..2..7..254 ', because with 503 marbles the company can package 10 huge boxes, 2 small boxes and there are 7 unused marbles. The company makes CDN$ 254, that is, CDN$26 * 10 = CDN$ 260 because of the 10 huge boxes plus CDN$ 4 *2= CDN$ 8 minus CDN$ 2 * 7 = CDN$6 (the seven unused marbles).
Notice that the company may have a net loss, when there are not enough cookies to create any package.
For example:
cookies(7) should return '0..0..7..-14'
As an example, the following code fragment:
print (marbles(503))
should produce the output:
10..2..7..254