Topic: Calendar Calculation: Year offset question
 Message: Posted by: Scott Cram (Nov 4, 2011 07:01PM)
I'm trying to find a particular approach to calendar calculation. Maybe it already exists and I just don't know about it, or maybe we'll just have to blaze new territory here.

My question concerns the year key, or the year offset. In other words, the question is about the number you use in calendar calculation to adjust for the given year.

For any given century, the years ending in 00, 01, 02, 03, 04, 05, and 09 will all always have different year offsets. Since there are 7 different weekdays, these 7 years cover all the offsets.

What I'd like to do is find a way to reduce any given year, 00 through 99, to one of the corresponding years above with the same year offset.

Obviously, there's one problem right off: If someone choose, say, 55, the corresponding year above would be 04 (because they both have the same year offset), even though 55 isn't a leap year and 04 is a leap year. Conversely, you might go from, say, 80 (a leap year) to 02 (a non-leap year). For the purposes of this question, assume that isn't a problem, and a leap year compensation is made later.

The first step that strikes me is to take the year you're given and subtracting 28, 56, or 84 from it, due to the 28-year cycle of year offset numbers. This reduces the problem to dealing with years from 00 to 27.

Put mathematically, I'm looking for some function x (or algorithm) that gives the following results (formulas will most likely ignore the leading zeroes, I'm just including them for clarity):

f(00) = 00
f(01) = 01
f(02) = 02
f(03) = 03
f(04) = 04
f(05) = 05
f(06) = 00
f(07) = 01
f(08) = 03
f(09) = 09
f(10) = 04
f(11) = 05
f(12) = 01
f(13) = 02
f(14) = 03
f(15) = 09
f(16) = 05
f(17) = 00
f(18) = 01
f(19) = 02
f(20) = 09
f(21) = 04
f(22) = 05
f(23) = 00
f(24) = 02
f(25) = 03
f(26) = 09
f(27) = 04

...and so on, repeating every 28 years within the same 00-99 range.

It's important to note that I'm trying to covert a given year to an equivalent year, not a given year to a year offset number.
 Message: Posted by: Scott Cram (Nov 4, 2011 11:22PM)
So far, I've got the following algorithm, but it's hardly handy for mental arithmetic. It does work every time, however.

Starting with the year reduced via modulo 28 to an equivalent year from 00-27:

From a leap year: Subtract 5, 11, or 22 (example: 24 - 22 = 02)
From an even non-leap year: Subtract 6, 11, or 17 (example: 26 - 17 = 09)
1 year [b]after[/b] a leap year: Subtract 11, 17, or 22 (example: 21 - 17 = 04)
1 year [b]before[/b] a leap year: Subtract 6, 17, or 23 (example: 19 - 17 = 02)

Can anyone simplify this to where it is easier to recall and perform in your head?
 Message: Posted by: Michael Daniels (Nov 5, 2011 03:24AM)
I have never been able to devise a quick and simple algorithm for the Year Code, which is why I went with mnemonics for Speed Dating.

Mike
 Message: Posted by: hcs (Nov 5, 2011 03:25AM)
I cover this problems in my book [b]Encyclopedia[/b] of Weekday Calculation. Send me a pm with your e-mail-adress and you will get the corresponding pages.
HCS

The book and its contents is available here:
http://www.lulu.com/product/hardcover/enzyklop%C3%A4die-der-wochentagsberechnung/18566167?
 Message: Posted by: landmark (Nov 5, 2011 08:28AM)
If anyone can do this, or has done this, it's our own stanalger, who has done extensive work on the calendar problem. Perhaps he'll weigh in?
 Message: Posted by: hcs (Nov 5, 2011 02:37PM)
[quote]
On 2011-11-05 09:28, landmark wrote:
If anyone can do this, or has done this, it's our own stanalger..[/quote]Of course he can! He owns my book :=))
(And I cite him :=) with courtesy as great mathmatician.)
 Message: Posted by: WilburrUK (Nov 5, 2011 02:51PM)
Best I can do is:
Given the year, get to a number 0-27 (as above)

Multiply the result by 5/4 (rounding down to a whole number)
Take the remainder of dividing this by 7

Now we need to map the result to the values 0-6 and 9
if the result is 4, use 9
If the result is 4-7 sbtract 1

[code]
x 5x/4 MOD7 MAP
00 00 00 00
01 01 01 01
02 02 02 02
03 03 03 03
04 05 05 04
05 06 06 05
06 07 07 00
07 08 01 01
08 10 03 03
09 11 04 09
10 12 05 04
11 13 06 05
12 15 01 01
13 16 02 02
14 17 03 03
15 18 04 09
16 20 06 05
17 21 00 00
18 22 01 01
19 23 02 02
20 25 04 09
21 26 05 04
22 27 06 05
23 28 00 00
24 30 02 02
25 31 03 03
26 32 04 09
27 33 05 04
[/code]
I think that's right, it kindof makes sense too.
 Message: Posted by: hcs (Nov 5, 2011 03:42PM)
The quest is to answer for example:

In which years of the 16th century January 16th was a Sunday?
1605 / 1611 / 1622 / 1628  and also 1600 / 1633 / 1639 / 1650 / 1656 / 1661 / 1667 / 1678 / 1684 / 1689 and 1695

You can solve by mental calculation or memorization (see my book).
 Message: Posted by: WilburrUK (Nov 7, 2011 06:22AM)
Hcs, I'm sorry to tell you that the answers you gave to your own question are all incorrect.
 Message: Posted by: hcs (Nov 8, 2011 05:33AM)
Oh yes, I mean the years in 16xx - the 17th century.

The Gregorian calendar was introduced by pope Gregory XIII in october, 15th 1582 in a few catholic countries. The calendar was adopted in Britain and its colonies in 1752.
Because I'm a German I consider the years since 1582, British and Americans since 1752.

So I convert my question:
In which years in 20xx (21th century) January, 16th was a Sunday?
 Message: Posted by: stanalger (Nov 8, 2011 07:13PM)
[quote]
On 2011-11-05 09:28, landmark wrote:
If anyone can do this, or has done this, it's our own stanalger, who has done extensive work on the calendar problem. Perhaps he'll weigh in?
[/quote]

I'm getting to this thread a bit late. Seems there's nothing left for me to do.
Get Hans-Christian Solka's book. If you can't read German, you've always got google translate at your disposal.

When I find some spare time, I'm going to write up an interesting day-of-week calculation method that involves manipulating a packet of cards.

Al Stanger
 Message: Posted by: TomasB (Nov 9, 2011 07:28AM)
Ok, stanalger let the cat out of the bag himself.

His real name is indeed Al Stanger.

/Tomas

PS The packet av cards thing sounds nothing short of brilliant
 Message: Posted by: hcs (Nov 17, 2011 07:05AM)
I published a new book entitled "Gregorian calendarsheets 1582 - 2399". The hardcover book is in English.
http://www.lulu.com/product/hardcover/gregorian-calendar-sheets-of-the-years-1582---2399/18667311

This book contains Gregorian calendar sheets with weekday, day of month and month for the years 1582 to 2399.

The book is a "must have" for mentalists who do the calendar feat.
The book enables a 3rd party audience member to prove your answers or to correct a spectator who gave you a wrong day of the week.
In the book an easy formula is given for calculating mentally the page corresponding to particular years. So a mentalist can make his response in form of an additional trick.
For example "July 4th 1776 was a - Thursday, please prove my answer at page 24 of this book. Page 24 contains the calendar of 1776, is this correct?"