Daily Challenge #252 - Everybody hates Mondays

dev.to staff - Jun 3 '20 - - Dev Community

Nobody likes Mondays! You spent the weekend partying and hanging out with friends, and then Monday comes, and you have to get up early, put on some business clothes and go to work. So how many of these horrible days does someone have to endure? Well, let's find out.

Create a method to find the number of Mondays given a person's birthday and the current date. Do not worry about holidays/vacation, sick leave etc. Assume a person has a job and goes to work throughout a year if they are of working age. To keep things simple, assume someone starts working when they are 22 years old and retires when he/she is 78. That's right, Mondays don't count as bad days if you are at school/university or a pensioner! And although not having to work on the weekends is a rather recent fad (look it up!) assume that Mondays where and will always be bad days at any era.

Examples

Mondays.count(LocalDate.of(1995, 4, 3), LocalDate.of(2017, 4, 3))
=> 1 Monday

Mondays.count(LocalDate.of(1995, 4, 2), LocalDate.of(2018, 4, 2))
=> 53 Mondays

Tests

Mondays.count(LocalDate.of(1700, 9, 20), LocalDate.of(1762, 9, 26))
Mondays.count(LocalDate.of(-300, 12, 20), LocalDate.of(-258, 12, 22))
Mondays.count(LocalDate.of(1000000, 2, 25), LocalDate.of(1000022, 12, 28))


This challenge comes from shadowmanos on CodeWars. Thank you to CodeWars, who has licensed redistribution of this challenge under the 2-Clause BSD License!

Want to propose a challenge idea for a future post? Email yo+challenge@dev.to with your suggestions!

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Terabox Video Player