General Douglas MacArthur played an important part in both the First and Second World War and the Korean War. In 1944, he was ranked General of the Army, with five stars as a recognition. As such, he is one of only 5 generals that were granted five stars in American history and one of only eight that carried the title ever. Although his character was controversial, he possessed an extraordinary amount of leadership qualities.

Douglas MacArthur
Douglas MacArthur (1880-1964)

To preserve his image, for his own amusement, and to entertain his guests, MacArthur started using a mathematical trick he called "that good old 115". Here, he asks one of his guests to write down the number of the month they are born in. January has number 1, February number 2, and so on. He then clearly turns his back to the guests so as to show his guests he can't see what they are writing down. He instructs them to write down the following:

  1. give the number of the month you were born in: 2 (we use February as an example)

  2. double the number: 4

  3. add five: 9

  4. multiply by 50: 450

  5. add your age 490 (we use 40 as an example)

  6. subtract 365: 125

Now the truth comes out. He asks his guest to say the number out loud. In our example that is 125. With a little of mental arithmetic he then quickly adds 115 to the number the guest says. In our example he now has the number 240. He then says without hesitating: "Well, my friend, you were born in February and you are 40 years old."

This is how he does it. The first digit of the number — together with the second digit in case the number consists of four digits — forms the number of the month of birth of the guest, if the good old 115 is added correctly. The last two digits indicate the person's age.

Assignment

  1. Write a function guest that prints the number the guest has on his paper based on the number of the month of birth and the age of the guest — both of which should be given to the function as an argument — after executing the orders of general MacArthur.

    def guest(month, age)

  2. Write a function macArthur that prints a tuple (see section 6.7 in the text book) with the number of the month of birth and the age of the guest, based on the number the guest has said out loud. This number should be given as an argument to the function. General MacArthur presumes that his guests are no older than 100.

    def macArthur(number)

Example

>>> guest(2, 40)
125
>>> macArthur(125)
(2, 40)
>>> macArthur(guest(2, 40))
(2, 40)
>>> guest(12,35)
1120
>>> macArthur(1120)
(12, 35)
>>> guest(12,28)
1113
>>> macArthur(1113)
(12, 28)