Write a function playexpertmarbles that given a number of


Write a function playExpert(marbles) that given a number of marbles returns the number of marbles that the computer will take following the expert mode rules. The number of marbles left on the pile will be a power of 2 minus 1 (e.g, 3, 7, 31) except if the size of the pile is already one less than the power of 2. In that case the computer will return a random number of marbles.

>>> playExpert(90)

27 (if computer takes 27 there will 90-27= 63 (26-1) marbles left )

>>playExpert(31) number of marbles a power of 2 minus 1
12
Make sure that your tests show that the function works for both cases.

 

Solution Preview :

Prepared by a verified Expert
Computer Engineering: Write a function playexpertmarbles that given a number of
Reference No:- TGS0663335

Now Priced at $20 (50% Discount)

Recommended (93%)

Rated (4.5/5)