avatar Bite 300. 🥳 PTO Calculator

We've all been affected by COVID-19 in one way or another. One way that I've been affected is with my vacation time or PTO ("paid time off"). In the job that I do, I can't simply take time off. A replacement has to be flown in so the company has "Vacation Coverage" guys.

We were recently told that due to the pandemic all non-essential travel is prohibited, so no vacation coverage! On top of that, company policy to "use or lose" vacation was still in effect. So we have to figure out how to use our vacation time before the year ends or we lose it!

I dabble in Python a bit, so I figured that I could leverage those skills into creating a list of dates that I can take off and what better days to take off than Friday and Monday, therefore maximizing the time off at my disposal! At the same time, I wanted to be able to generate a list of my actual work days left for the remainder of the year.

Sounds simple, but there are some things to consider like federal holidays. If a holiday falls on either of those days, then I don't consider that a valid staycation weekend. The company frowns on taking extra days off on holiday weekends. Also, I'm working from home a couple of days per week so those must not be counted as work days either.

I know, it's unrealistic that I only work one day per week, but just play along for now.

Four Day Weekend Report

This report should include the following:

- number of four-day weekends left until the end of the year

- display your current PTO hours (days)

- your PTO balance if you were to take every Friday and Monday off until the end of the year

- list the dates of valid four day weekends, i.e. [Friday, Monday]

- indicate which weekend marks the point were you will start losing vacation days if you don't start taking days off with an asterisk

Example of what it should look like

  18 Four-Day Weekends
========================
  PTO: 200 (25 days)
BALANCE: -88 (11 days)

2020-08-07 - 2020-08-10
...
2020-09-18 - 2020-09-21 *
...
2020-12-18 - 2020-12-21

Work Day Report

For this portion of the code, you will generate a report like the last one, but this time with the following:

- remaining work hours/days

- list of dates

Example of what it should look like

Remaining Work Days: 184 (23 days)
2020-08-03
2020-08-06
...

The function

Your task for this challenge will be to complete the four_day_weekends() function. The function will take three named arguments, start_month, paid_time_off and show_workdays, each having default values.

If the function is called without specifying which variable it belongs to, a ValueError should be raised with the provided ERROR_MSG variable.

Valid calls

four_day_weekends()
four_day_weekends(start_month=9)
four_day_weekends(paid_time_off=80)
four_day_weekends(show_workdays=True)
four_day_weekends(start_month=7, show_workdays=True)

Invalid calls

four_day_weekends(8)
four_day_weekends(True)

Conclusion

I usually tend to guide you towards a certain solution. In this Bite, I'm leaving it up to you how you accomplish it. As long as you get the same results, it will do. Have fun!

Login and get coding
go back Advanced level
Bitecoin 10X

29 out of 33 users completed this Bite.
Will you be the 30th person to crack this Bite?
Resolution time: ~99 min. (avg. submissions of 5-240 min.)
Our community rates this Bite 8.0 on a 1-10 difficulty scale.
» Up for a challenge? 💪

Focus on this Bite hiding sidebars, turn on Focus Mode.

Ask for Help