system
A chat on subreddit /r/me_irl
human
Could you explain it for us still in plato's cave?
gpt
Sure. Easy-peasy. No sweat, no worries, not a problem at all.

Here goes.

So, okay. My previous work was about grant allocation eligibility. One criterion was that if someone had held their PHD for 10 years, they were a junior. Any more and they were senior. Juniors could apply for senior grants, but seniors could not apply for junior grants. Accordingly, researchers were incentivised to try and stay a junior for as long as possible.

I was tasked with writing a program to compute if a researcher was eligible. This seems simple enough; you just use DateDiff to calculate the days, and figure out how many days there are between Now() vs Now()-Years(10), and that should be easy. Right?

Not so fast. You see, researchers could also have "career disruptions". Any time spent in a career disruption was subtracted from this time. So say someone got their PHD 11 years ago (clearly a senior), but they had taken 4 years off to have a kid. In the eyes of the institution, they had not had their PHD for 11 years, but 7. So they were a junior.

Now factor in that there were some limitations on career disruptions. For example, a career disruption had to be equal to or greater than 90 days to count. We don't care if you're sick for three days, it's only a serious disruption. Again, sounds simple, just sum up all the DateDiffs between dates of career disruptions, subtract them from the total, and we're done.

Not so fast. See, any career disruptions that are concurrent should be stringed together. So if someone takes 7 weeks off because their father died (49 days), then takes another 5 weeks off because their mother died (49 days), neither of these things should actually count. But that's actually 98 days of combined career-disrupted days, so it would count because they were back to back.

But if they were not back to back, say they were a year apart, it wouldn't count.

And even when you answer these questions, not so fast. You see, these do not have to be full-time career disruptions. According to the rules we have to account for part-time career disruptions as well and weight them accordingly. These are declared in terms of start date, end date, and percentage (e.g. "33%").

Sounds simple, right? 

But already the ambiguities are starting to creep in. When we said "90 days", is that 90 calendar days or 90 working days? Is a week 5 days or 7? Do you count weekends? Are they a "day"? What about public holidays? What about Christmas and the Christmas shutdown that happens here in Oz? What about Ramadan? What about the Indian Festival of Lights? Is that fair to Atheists?

What is "concurrent" anyway? What happens if someone goes through the year, dutifully declaring disruption periods of Monday-&gt;Friday, Monday-&gt;Friday, in 5 day blocks? If you add those up, over 15 weeks it's going to be 75 days (clearly not eligible), but if you count weekends, that's 105 days (clearly eligible).

We had someone who did this, by the way. They even dutifully excluded public holidays. So where others had said "I took two years off to have a kid" and then just blocked out 730 days in one big chunk, but when this person went through and did it week by week. If there was a public holiday on Wednesday, they would declare Monday-Tuesday, then Thursday-&gt;Friday, then Monday-Friday the next week.

So over the YEARS they took off, they never had a 90 day block. But obviously, this person is clearly eligible for a career disruption, so the algorithm must accommodate this.

So now the algorithm is also stitching together "concurrent" blocks that are in some cases only two or one days long, but it's also got to deal with weekends. Most people assume that if I told you "I worked for two weeks", that's Monday-&gt;Friday, Monday-&gt;Friday. So to stitch these weeks together, we have to add in two days, and allow for two days gap.

But what if there's a public holiday on Friday? So now we're allowing for *three* days between concurrent weeks. But then Ramadan is weeks long, Christmas can be weeks long, plus Easter, plus... etc etc etc. What is "concurrent"? How are you defining that? How many days, weeks, months should we allow for "concurrent" breaks? How much is fair?

What happens if someone has an 80 day disruption, and an 80 day disruption, but a week between them? Should we say they have 160 days, or 170 days, or 0 days because both blocks are shorter than 90 and they're not contiguous? What if there's a public holiday in that period?

Also, consider that then there's the issue of days, as I alluded to earlier. The way humans perceive days is basically from about 8:00am to 8:00pm. We also have an implicit understanding of when we're talking about inclusive vs exclusive, or how to link weeks together. Computers, however, do not. Computers see days as being a 24 hour period between midnight to midnight.

This causes a lot of confusion. For example, if I asked you, "How many days are between June the 14th and June the 16th?", you would answer... well, a few things. You would likely answer either 1 (there is only one day "between" these days). You could also answer "3", because you could be *inclusive* of those days.

But a computer would say, "How many 24 hour periods are between midnight of the 14th and midnight of the 16th?". And then they would answer "2". 24 hours between midnight of the 14th and midnight of the 15th, and 24 hours between midnight of the 15th and midnight of the 16th.

So the human answers "1" or "3", quite ambiguously, whereas the computer confidently and always answers "2".

Then take another question. "How many days are there on the 13th of January?". Because humans think of a day as 8:00am to 8:00pm, they answer "1". But a computer goes, "How many 24 hour blocks between 12:00 midnight on the 13th of January and 12:00 midnight on the 13th of January?". Well, zero of course, so they answer 0.

So already we're starting to see some of the ambiguities and how they can creep in. It's easy to accommodate this if you know what you're looking for, understand how computers perceive time, and explain it to your users appropriately.

But this "simple algorithm" is now dealing with a LOT.

So take the following situation (this is an entirely reasonable situation by the way). Someone gets married and has a kid. In order to accommodate this, they:

- Take six months off to travel internationally to get married, while working from "home" 1 day a week
- Take a full year off to have the kid
- Work part time (Monday and Tuesday off, Wednesday, Thursday and Friday on) for three years
- In the middle of that, have their father die and take four months off full time
- Return to work 1 day a week for two years
- Return to work 3 days a week for two years
- Return to week 4.5 days a week, taking every alternate Friday off

An algorithm that accommodates this, and accurately and reliably accounts for *all possible human interpretations* of how a human being might enter this information, is now extremely complex. It's not just going, "what is the difference in two dates", it's compiling a massive linked list of date periods for each applicant, iterating through these blocks of time, testing to see if each bock is 90 days or greater (of either pre or post-adjusted time), then giving them a weighting according to the percentage.

Then think about other things!

If someone says that they worked 50% of the time, is that Monday, Tuesday, Wednesday one week, then Monday and Tuesday the next, or is it 50% of Monday-&gt;Sunday? Is it 3.5 days or 2.5 days? That shit adds up fast, especially when you're dealing with 90 day blocks. And if you're going to have partial days, what happens to the partial days? Do they get summed together? If someone has a 91 day career disruption weighted at 50% (45.5 days), then another career disruption of 89 days at 50% (44.5 days), is that 90 days (eligible) or 88 days (ineligible)? Do you round up or down? What if someone has three blocks of 90.3 days linked together? Do they have 270 days, or 270.9 days, or is .9 of a day enough to make it 271 days total?

How do you define a day?

AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA