An office (let's call it "The Office") is going to cut down on wasted time in 2019 by consolidating office birthday parties. Any two people with a birthday between Monday and Friday (inclusive) of the same week will be celebrated with a Shared Birthday Party some time that week. People whose birthdays fall on a Saturday or Sunday get no party at all.
Some people do not like sharing a birthday party with people who do not share their actual birthday. They will be Very Angry to have a Shared Birthday Party.
We are going to simulate an office and find the first week in which someone gets Very Angry about their Shared Birthday Party.
The Challenge
Write a program or function that outputs the first ISO week number for 2019 in which someone in a simulated office gets Very Angry about their Shared Birthday Party, subject to the following basic rules:
- input an integer N > 1, which is the number of workers in the office.
- the N birthdays themselves are distributed uniformly at random from Jan 1 to Dec 31 (ignore Feb 29).
- but the working weeks for the purposes of determining Shared Birthday Parties are the 2019 ISO Week Dates, which are between 2019-W01-1 (2018-12-31) and 2019-W52-7 (2019-12-29). A new ISO week starts every Monday. (I think this is all you really need to know about ISO weeks for this challenge).
- for the N people in the office, each has a 1/3 chance of having a Very Angry Shared Birthday Party personality type, so you'll have to simulate that too.
- but they will not be angry if the party is shared with people who have the same birthday.
- output the ISO week number (exact format for this is flexible as long as the week number is clear) for the first occurrence of a Very Angry person. If there are no angry people, you can output anything that isn't confused with an ISO week or the program can error out etc.
Some simplifying assumptions:
- as I mentioned, ignore the February 29 issue completely (an unneeded complication)
- ignore public holidays (this is an international community so our holidays will differ) and just assume the office is open on each weekday.
Rules
This is code-golf. Shortest answer in bytes for each language wins. Default loopholes forbidden.
Code explanations welcome.
Worked Examples
Contrived Example 1 with input N = 7. First and second columns are random as described in the rules (but not actually random here of course).
Angry Type
Person? Birthday ISO Week Comment
================================================================================
N 2018-12-31 W01 In the 2019 ISO week date year
Y 2018-12-31 W01 Same birthday, so no anger happens
N 2019-02-05 W06
Y 2019-03-15 W11 No anger happens because other W11 b-day is a Saturday
N 2019-03-16 W11
N 2019-09-08 W36 My birthday!
Y 2019-12-30 - Not in the 2019 ISO week date year
So no anger happens. The program or function can error out or output something not confused with an ISO week number.
Example 2 with N unspecified.
Angry Type
Person? Birthday ISO Week Comment
================================================================================
N 2019-01-19 W03
Y 2019-02-04 W06
N 2019-02-05 W06 No anger because not an angry person
... ... ... (No angry people until...)
Y 2019-03-12 W11 Very Angry Person!
N 2019-03-14 W11
... ... ... ...
The output would be W11
or something equivalent.