If you’re looking for a brain teaser over the weekend, David Hunt, PGCE Computer Science Subject Leader in the School of Education, has devised a computer coding style challenge, based on classic computing problems. This is similar to what he uses with his trainee computer science teachers.
A wine merchant (who was rather too fond of his job) ordered a very large consignment of wine from the most prestigious vineyard. He had an obsessive-compulsive personality and would not release any of his wine stocks unless he managed to sell exactly 25% of the bottles he held in store. If the number of bottles left did not divide equally by 4, he would stop trading!
The wine was so good that he managed to take orders for exactly 25% of his delivery on the first day, so that evening he opened a bottle and quaffed it all by himself.
On the second day, with a sore head, he sold a perfect 25% of his remaining stock, so foolishly opened another bottle.
On the third day, he sold precisely 25% more of the stock he had left and celebrated by sipping at another bottle that evening.
This pattern continued for the rest of the week. On the seventh day, it was not possible to sell exactly 25% of the bottles left, so the merchant stopped trading (and drinking).
Challenge
What is the smallest consignment of wine bottles that he originally took delivery of and how many bottles was he left with at the end of day 6?
ANSWER:
4092 with 725 left over
This type of problem can be solved by a computer using a ‘brute force’ approach, where the computer tries out all the different answers until it finds the correct one.