PK creative Spring Festival, I am participating in the “Spring Festival creative submission contest”, please see: Spring Festival creative submission Contest

preface

I am writing this on January 13, 2022, 17 days before Chinese New Year.

Every time I mention everybody happy New Year, because can put annual leave, can go home to eat delicious, but for me, the one who leave hometown to work in hangzhou, and always will experience the annual “together with” respectively, the Chinese New Year back home and family together is happy, travel-stained from hangzhou back to an ordinary county in Shanxi Province, take the whole day, To see my parents and brothers, no matter how tired it is, my parents are also happy to see me. But whenever the holiday is about to end, from home to leave the time, see temples gradually white, can only rely on black to show “not old” parents, heart is always very ashamed. Throughout the year the two places are thousands of miles apart, nothing can be taken care of at home, on weekdays I am also busy working too busy to chat with my parents, count down and do not know how much can be left with their parents together, this is not the taste of the people who can see their parents every day I am afraid to experience. This is the Denver nuggets event, I want to write a code to calculate how much time I can spend with my parents in the future.

Train of thought

  1. To estimate the life expectancy of a relative, I referred to the average life expectancy of the population in Baidu Encyclopedia. Based on the existing data, we can assume that the relative’s life expectancy is 77.3 years, rounded to 80 years [dog head].

  2. According to the current holiday arrangement system of The State Council, the days of my future holidays are calculated as follows:

    • New Year’s day for 3 days
    • 7 days of the Spring Festival
    • Qingming Festival 3 days
    • Labor Day 5 days
    • Dragon Boat Festival 3 days
    • Mid-Autumn Festival 3 days
    • National Day 7 days

    In addition, after simplification, I only provide two plans for going home. The first plan is to go home with parents during all holidays, and the second plan is to go home with parents during Spring Festival just like me. Either way, we also need to eliminate the commute, which is hourly, because it takes me a long time to get back to my hometown.

  3. For the calculated results, we can translate them into hours, days, weeks, months, and years.

Python code implementation

Def MeetTime(age, isAll=False, waste=0): "" :type age: int current age: type isAll: bool Whether to go home for holidays :type waste: Int total travel time for each holiday """ result = 0 if isAll: holidays = [3, 7, 3, 5, 3, 3, 7] result += (80 - age) * sum(holidays) * 24 result -= (80 - age) * waste * len(holidays) else: Holidays = [7] result += (80-age) * sum(holidays) * 24 result -= (80-age) * waste * len(holidays) return f } {result: 3 f hours/day {} the result / 24:3 f / {result/(24 * 7) : 3 f} weeks / {result/(24 * 30) : 3 f} / {result / 24 * (365) : 3 f} years"Copy the code

My data

Print (MeetTime(53, False, 48)) can also spend 3240.000 hours / 135.000 days / 19.286 weeks / 4.500 months / 0.370 years with loved onesCopy the code

The tail down

With this little Python code, we can calculate how much time we can theoretically spend with our loved ones. Here I would like to encourage you to go home and stay with your parents more often if you have time. I have calculated the results and should be able to find that there are only 135 days left. I really envy those who can turn around their parents all day.