7
$\begingroup$

The Day/Month/Year date system commonly used in Britain (and much of Europe?) and the Month/Day/Year system commonly used in the US can lead to confusion when, for example, we write 9/3/2018 for the 9th of March and Americans interpret it as the 3rd of September. Fortunately, at least in this case, adding the day of the week resolves the ambiguity: Friday 9/3/2018 can only mean one thing, because the 3rd of September is a Monday. I'm guessing, however, that this isn't always the case, and some dates will still be ambiguous even with the day of the week included.

How many dates are there with both day/month and month/day on the same day of the week?

Obviously, equal pairs such as 7/7 are excluded.


Disclaimer: I don't know the answer to this one. I hope there will be a nice neat way of solving it - I've added the tag to emphasise that brute-force coding solutions won't be accepted - but solve at your own risk :-)

$\endgroup$
6
  • $\begingroup$ Your question and title seem opposite - if the dates are on the same day of the week, they are ambiguous, aren't they? (Btw, I think I have an approach that works - working it out further and writing now) $\endgroup$
    – Lolgast
    Feb 22, 2018 at 13:02
  • $\begingroup$ @Lolgast Well, they're equivalent - one set would be the complement of the other :-P Fixed. $\endgroup$ Feb 22, 2018 at 13:05
  • $\begingroup$ Of course they are, but it got me puzzled for a while as to which one I should calculate :P Though my approach works with ambiguous dates, and I'd simply subtract that number if I had to calculate the other. $\endgroup$
    – Lolgast
    Feb 22, 2018 at 13:06
  • 1
    $\begingroup$ I have an answer, but I cheated by doing a brute-force search in Excel, so won't post it. One thing of particular interest that I was reminded of when reviewing the answer is that TWO of the ambiguous dates are amongst the set of "doomsdays" that allow people who've memorised the procedure to figure out the day of the week for any day of the year in their head - see e.g. timeanddate.com/date/doomsday-rule.html $\endgroup$
    – Steve
    Feb 22, 2018 at 15:47
  • $\begingroup$ For anyone else that wants to "cheat" using excel, the key formula to use was WEEKDAY(DATE(2016,A1,B1))=WEEKDAY(DATE(2016,B1,A1)) $\endgroup$
    – Steve
    Feb 22, 2018 at 15:52

2 Answers 2

8
$\begingroup$

Well, since we want the days to be on the same weekday:

We want a precise number of weeks to have elapsed, i.e. 0 (mod 7) days. We have the following lengths for the months (total and mod 7, respectively):

- 31, 3
- 28 or 29, 0 or 1 (depending on whether it's a leap year)
- 31, 3
- 30, 2
- 31, 3
- 30, 2
- 31, 3
- 31, 3
- 30, 2
- 31, 3
- 30, 2
- 31, 3 (although this isn't really important, since we won't progress past this.)

Then:

It's easy to determine whether January xth is on the same day as October xth, by simply adding those numbers (mod 7). However, reversing the date complicates things a bit. We can get around this by using the difference in day and month, and adding/subtracting that from the found number.

That is, January 3rd becomes March 1st. January -> March gives a 3 or 4 day difference. March 1st is 2 days before March 3rd, so we subtract 2, giving 1 or 2. Thus, as 3/1/18 (dd/mm/yy) is on Wednesday, and 2018 is not a leap year, 1/3/18 (dd/mm/yy) is a Thursday. (Yes, I did check my calendar here to see if my approach actually works.)

Finishing up:

Since the difference between the same day in the other month, and the actual reversed date is constant for each month, we can combine those:

Jan -> Feb: 3-1 = 2 days difference.
Jan -> Mar: 3 or 4 -2 = 1 or 2 days difference (as before).
Jan -> Apr: 6 or 7 -3 = 3 or 4 days difference.
Jan -> May: 8 or 9 - 4 = 4 or 5 days difference.
Jan -> Jun: 11 or 12 -5 = 6 or 7 days difference - We have an ambiguous date in leap years!
Jan -> Jul: 13 or 14 -7 = 7 or 8 days difference - Ambiguous in non-leap years.

We can simply continue this approach. If we only consider dates where the reverse is later in the year (i.e. 3/1 will be considered in January, so 1/3 not in March), we get:

Jan: 1 in leap years - June, 2 in non-leap years - July and November.
Feb: 2 in leap years (Mar/Dec), 1 in non-leap years (Aug)
Mar: 1 (Dec) (Note: Leap years don't matter any more, since we're past February)
Apr: 0
May: 1 (Sep)
Jun: 0
Jul: 1 (Nov)
All the other months don't have ambiguous dates with months later than that one.

EDIT: Here's a picture of an excel sheet with my approach (made after doing all of this by hand...):

Excel sheet of approach
The green cells indicate matching months. Out of view I have a list with the month lengths mod 7, where I can easily change Feb from 0 to 1 for leap years.

Giving a total of:

6 ambiguous dates in both leap and non-leap years.

I surely hope I didn't make any mistakes counting (Edit: January was actually wrong. Correcter that, which nicely ensures we have the same number in every year :D). I checked one or two of them which were correct, but I won't give any guarantees. Also, I noticed I got rather annoyed by the fact that July and August both have 31 days, rather than simply alternating like the /normal/ months.

$\endgroup$
8
  • $\begingroup$ You've currently got at least 1 mistake - the calendar on my desk has 07/01/18 and 01/07/18 as Sundays, but 12/01/18 was a Friday, and 01/12/18 will be a Saturday. Only one of the non-leap ambiguities you show for Jan really is ambiguous... $\endgroup$
    – Steve
    Feb 22, 2018 at 15:58
  • $\begingroup$ Interesting - I'll have a look where I went wrong. Might've just miscounted. $\endgroup$
    – Lolgast
    Feb 22, 2018 at 16:00
  • $\begingroup$ @Steve Fixed January (and verified). It seems I just had a miscount in my sequence. Hope I didn't make anymore mistakes. $\endgroup$
    – Lolgast
    Feb 22, 2018 at 17:19
  • $\begingroup$ lespakketten == leap? $\endgroup$
    – ferret
    Feb 22, 2018 at 20:42
  • $\begingroup$ @frabjrew Ah, autocorrect :P And yes, that was supposed to say 6 in every year. Edit was done on mobile, so not very well written :P $\endgroup$
    – Lolgast
    Feb 22, 2018 at 21:00
1
$\begingroup$

I decided to approach this by exclusion:

When it's the same day as the month, it doesn't matter, so that gives us 12 days in a year, which leaves us with 353 days left. Next up, remove any day bigger than 13, we only have 12 months in a year. Each month has at least 16 days bigger than that, but to simplify math, we can count the days that are less than 12. There are, unsurprisingly, 12 of each for each month, and removing the duplicate day/month, that leaves us with 11 days per month. In a year, that makes it 132 days.

Now to sort out the week day problem:

If this is a leap year, January, April and July will coincide in day and day of week, which would make 1/4, 4/1, 1/7 and 7/1 ambiguous (skipping 4/7 and 7/4 as those will show up again further ahead). Leap counter: 6. If it's not a leap year, January only coincides with October, making 1/10 and 10/1 ambiguous. Non-leap counter: 2. Rinse and repeat throughout the months:
February coincides with June on leap years (6+1=7) and with March and November on non-leap years (2+4=8). Months after February will remain the same regardless of leap year. So we can just safely assume leap years will naturally have 1 less ambiguous date than non-leap years. March coincides with November only, so non-leaps are now 10. April coincides with July, so 10+2=12. May, June, July and August don't coincide with any further month. September coincides with December, so 12+2=14. October, November and December don't coincide with further months.

So my final answer is:

14 days in non-leap years, 13 days in leap years.

My technique:

Looking for when the day of the week of the first day of each month coincided with the day of the week of the first day of other months, then grab the dates of each of them that can be inverted. Ignore days greater than 12. Ignore days that coincide with the month. Account for leap years on the first couple months, since they shift the day of the week of months ahead of them.

$\endgroup$
1
  • $\begingroup$ See my answer - Just checking the first day of the month doesn't work :P $\endgroup$
    – Lolgast
    Feb 22, 2018 at 15:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.