Calculating the number of days between two arbitrary dates is doable for humans and trivial on modern computers. However, calculating the number of working days: Mondays through Fridays, is more complicated. In this puzzle you are asked to devise an algorithm for doing this. It is something you can do on the back of a napkin, so you don’t need anything besides pen, paper and the rational part of your brain.
Given two dates where , what is the number of workdays between these two dates? Assume that only Saturdays and Sundays are not workdays: holidays can be ignored.
You may use the following definitions augmented with any standard mathematical functions, like and .
- is a date
- Subscripts are used to indicate different dates:
- yields the number of days between two dates. This is negative if and zero if the dates are identical
- gives the day of the week for the given date as a number (1 = Monday, 2 = Tuesday, …, 7 = Sunday)
- gives the number of the week for the specified date (in the range 1 up to including 53)
- is the set of numbers that represent working days (a subset of the domain of the weekday function)
Try to work out a solution first, then expand mine below.
Assume a country where every family wants to have a boy and continues having babies until they actually have one. We consider only one generation. The probability of having a boy or a girl is always the same. After some time has passed, what is the ratio between boys and girls in the country? Try to work it out yourself and then expand the solution below.
Background: I will occasionally present a small (mathematical) puzzle here. These are a tribute to the column “Vuiks Verhandelingen”, written by Kees Vuik which regularly appeared in the Dutch PCM Magazine nearly a decade ago. Sometimes I may think of them myself, and sometimes they may come from elsewhere.
Let’s get started: 114 students applied for a specific study, only 100 were eventually admitted by lottery. Among the 114 students were 5 foreign students. However, none of these foreigners were among the 100 that were admitted. Intuitively this seems quite unlikely. But how unlikely is it really? Were the foreigners intentionally not admitted?
Your task: find the probability that the 5 foreign students were left out due to chance. This can be solved with basic knowledge of probability and set theory. First try it yourself, then click below to expand the solution and check your answer.