204k views
2 votes
On the planet Mongo, each year has 15 months and each month has 26 days.

Write a function compute_mongo_age(birthYear, birthMonth, birthDay, currentYear, currentMonth, currentDay)
that residents of Mongo can use to compute their age. It should take 6 positive integers as input: the person's birthdate (year, month from 1 to 15, and day from 1 to 26) and the current date (year, month from 1 to 15, and day from 1 to 26), and return a float of the age of the person in years.

For example, print(compute_mongo_age(2879,8,11,2892,2,21)) should print 12.6256410256, the age (in Mongo years) of a person, who was born on the 11th day of the 8th month of the year 2879, is on the 21st day of the 2nd month of the year 2892.

1 Answer

2 votes

Final answer:

To compute a person's age on the planet Mongo, you need to calculate the number of days between the birthdate and the current date and then convert it into Mongo years.

Step-by-step explanation:

To compute a person's age on the planet Mongo, you need to calculate the number of days between the birthdate and the current date and then convert it into Mongo years. Since each month on Mongo has 26 days and there are 15 months in a year, you can multiply the number of birth years and the current years by 15 and add the number of birth months and current months to get the total number of months. Finally, divide the total number of days by the total number of months to get the age in Mongo years.

For example, if a person was born on the 11th day of the 8th month of the year 2879 and the current date is the 21st day of the 2nd month of the year 2892, you would calculate the age as follows:

(2892 - 2879) * 15 + (2 - 8) = 208

(208 * 26 + 21 - 11) / 208 = 12.6256410256

User Schpet
by
4.1k points