Guest Posted November 18, 2009 Report Share Posted November 18, 2009 Hi, Need help on this question. On which of the two days of the week, Saturday or Sunday, does New Year's Day fall more often? Quote Link to comment Share on other sites More sharing options...
0 Guest Posted November 18, 2009 Report Share Posted November 18, 2009 Reveal hidden contents actually, both have the same probability... if the eve falls on saturday , then it wud be sunday next yr.. unless the following year is a leap yr,coz then it would be monday after saturday but this effect would be zero on the long run... Quote Link to comment Share on other sites More sharing options...
0 Guest Posted November 18, 2009 Report Share Posted November 18, 2009 This is a coding test, which means computation is required. Quote Link to comment Share on other sites More sharing options...
0 Guest Posted November 18, 2009 Report Share Posted November 18, 2009 Reveal hidden contents Maybe you should limit the timeframe, because otherwise the same probability goes not only for Saturdays and Sundays, but any other day of the week Quote Link to comment Share on other sites More sharing options...
0 Guest Posted November 18, 2009 Report Share Posted November 18, 2009 Reveal hidden contents The days of the week will fall on a certain date 4 times in a 28 year cycle. With 7 days in a week, a leap year every 4 years, the cycle of days will repeat every 28 years. This is known as the perpetual calendar. Quote Link to comment Share on other sites More sharing options...
0 superprismatic Posted November 18, 2009 Report Share Posted November 18, 2009 Reveal hidden contents The Gregorian calendar cycles through all possible yearly calendars in 400 years. You can see this because the number of days in 400 years is (3*365+366)*100-3 which is 146,097, a multiple of 7. In 400 years, New Years Day is on a Sunday 58 times and on a Saturday 56 times. So, the answer to the OP is Sunday. Quote Link to comment Share on other sites More sharing options...
0 Guest Posted November 18, 2009 Report Share Posted November 18, 2009 Reveal hidden contents I completely disagree with you and believe that the chances are equal? Your formula is flawed by only looking at 400 years. You should instead look at a multiple of 28 since the pattern will repeat every 28 years due to leap years (7 days a week * 4 years to a leap year). So the breakdown would be New Year's falling on: SU M T W F SA SU M W TH F SA M T W TH SA SU M T TH F SA SU T W TH F Year 29 would repeat the pattern of year 1. If you count the days New Year will fall out on in a 28 year period, it is completely even between every day of the week. So if you were to look at 420 years instead of 400 the results should be completely even. On 11/18/2009 at 4:10 PM, superprismatic said: Reveal hidden contents The Gregorian calendar cycles through all possible yearly calendars in 400 years. You can see this because the number of days in 400 years is (3*365+366)*100-3 which is 146,097, a multiple of 7. In 400 years, New Years Day is on a Sunday 58 times and on a Saturday 56 times. So, the answer to the OP is Sunday. Quote Link to comment Share on other sites More sharing options...
0 superprismatic Posted November 18, 2009 Report Share Posted November 18, 2009 (edited) On 11/18/2009 at 5:51 PM, wabster said: Reveal hidden contents I completely disagree with you and believe that the chances are equal? Your formula is flawed by only looking at 400 years. You should instead look at a multiple of 28 since the pattern will repeat every 28 years due to leap years (7 days a week * 4 years to a leap year). So the breakdown would be New Year's falling on: SU M T W F SA SU M W TH F SA M T W TH SA SU M T TH F SA SU T W TH F Year 29 would repeat the pattern of year 1. If you count the days New Year will fall out on in a 28 year period, it is completely even between every day of the week. So if you were to look at 420 years instead of 400 the results should be completely even. Reveal hidden contents The rule for leap year is: Y is a leap year if and only if Y is a multiple of 4 AND if it's a multiple of 100, then it must also be a multiple of 400. So, the year 2000 was a leap year, but the year 1900 was not. That 400 in the rule means that the leap year cycle is 400 years long. Edited November 18, 2009 by superprismatic Quote Link to comment Share on other sites More sharing options...
0 Guest Posted November 18, 2009 Report Share Posted November 18, 2009 On 11/18/2009 at 6:05 PM, superprismatic said: Reveal hidden contents The rule for leap year is: Y is a leap year if and only if Y is a multiple of 4 AND if it's a multiple of 100, then it must also be a multiple of 400. So, the year 2000 was a leap year, but the year 1900 was not. That 400 in the rule means that the leap year cycle is 400 years long. Reveal hidden contents New years day moves forward one day every year in a normal year. Every 4th year one day misses its chance to be new years day. Starting with Saturday as new years day in year 0 the first year to miss will be Wednesday in year 4, then Monday in year 8 and Saturday in year 12, Thursday in year 16, Tuesday in year 20, Sunday in year 24, Friday in year 28 and then we are back to Wednesday in year 32. Thus the pattern repeats over 28 years (32 – 4) Now let’s consider what happens in year 400 (when we miss a leap year); L 393 394 395 L 397 398 399 400 401 402 403 L 405 406 407 L 409 410 411 L Sat Su M Tu * Th F Sa Su M Tu W Th * Sa Su M Tu * Th F Sa Su * Tu 413 414 415 L 417 418 419 L W Th F * Su M Tu W * F (sorry folks, try as I might I cant get these to line up properly in the text window) Clearly in the 28 year cycle containing the 400th year the whole pattern resets one day earlier in the week. What this means is that in our example every 28th year NYD will be a Saturday up to year 392 and then multiples of 28 after that will be Fridays from years 420 to 784 etc as shown below; 1 – 392 = Sat 400 reset a day earlier 420 – 784 = Fri 800 reset a day earlier 812 – 1176 = Th 1200 reset a day earlier 1204 - 1596 = Wed 1600 reset a day earlier 1624 to 1988 = Tues 2000 reset a day earlier 2016 to 2380 = Mon 2400 reset a day earlier 2408 to 2772 – Sun 2800 Reset a day earlier 2800 to 2828 - Sat So that pattern repeats every 2800 years In essence, the answer is that without a time frame the question cannot be answered Steve Quote Link to comment Share on other sites More sharing options...
0 superprismatic Posted November 18, 2009 Report Share Posted November 18, 2009 On 11/18/2009 at 8:33 PM, Steve17 said: Reveal hidden contents New years day moves forward one day every year in a normal year. Every 4th year one day misses its chance to be new years day. Starting with Saturday as new years day in year 0 the first year to miss will be Wednesday in year 4, then Monday in year 8 and Saturday in year 12, Thursday in year 16, Tuesday in year 20, Sunday in year 24, Friday in year 28 and then we are back to Wednesday in year 32. Thus the pattern repeats over 28 years (32 – 4) Now let’s consider what happens in year 400 (when we miss a leap year); L 393 394 395 L 397 398 399 400 401 402 403 L 405 406 407 L 409 410 411 L Sat Su M Tu * Th F Sa Su M Tu W Th * Sa Su M Tu * Th F Sa Su * Tu 413 414 415 L 417 418 419 L W Th F * Su M Tu W * F (sorry folks, try as I might I cant get these to line up properly in the text window) Clearly in the 28 year cycle containing the 400th year the whole pattern resets one day earlier in the week. What this means is that in our example every 28th year NYD will be a Saturday up to year 392 and then multiples of 28 after that will be Fridays from years 420 to 784 etc as shown below; 1 – 392 = Sat 400 reset a day earlier 420 – 784 = Fri 800 reset a day earlier 812 – 1176 = Th 1200 reset a day earlier 1204 - 1596 = Wed 1600 reset a day earlier 1624 to 1988 = Tues 2000 reset a day earlier 2016 to 2380 = Mon 2400 reset a day earlier 2408 to 2772 – Sun 2800 Reset a day earlier 2800 to 2828 - Sat So that pattern repeats every 2800 years In essence, the answer is that without a time frame the question cannot be answered Steve You forgot to take into account that years 100, 200, and 300 are not leap years. Quote Link to comment Share on other sites More sharing options...
0 superprismatic Posted November 18, 2009 Report Share Posted November 18, 2009 On 11/18/2009 at 8:33 PM, Steve17 said: Reveal hidden contents New years day moves forward one day every year in a normal year. Every 4th year one day misses its chance to be new years day. Starting with Saturday as new years day in year 0 the first year to miss will be Wednesday in year 4, then Monday in year 8 and Saturday in year 12, Thursday in year 16, Tuesday in year 20, Sunday in year 24, Friday in year 28 and then we are back to Wednesday in year 32. Thus the pattern repeats over 28 years (32 – 4) Now let’s consider what happens in year 400 (when we miss a leap year); L 393 394 395 L 397 398 399 400 401 402 403 L 405 406 407 L 409 410 411 L Sat Su M Tu * Th F Sa Su M Tu W Th * Sa Su M Tu * Th F Sa Su * Tu 413 414 415 L 417 418 419 L W Th F * Su M Tu W * F (sorry folks, try as I might I cant get these to line up properly in the text window) Clearly in the 28 year cycle containing the 400th year the whole pattern resets one day earlier in the week. What this means is that in our example every 28th year NYD will be a Saturday up to year 392 and then multiples of 28 after that will be Fridays from years 420 to 784 etc as shown below; 1 – 392 = Sat 400 reset a day earlier 420 – 784 = Fri 800 reset a day earlier 812 – 1176 = Th 1200 reset a day earlier 1204 - 1596 = Wed 1600 reset a day earlier 1624 to 1988 = Tues 2000 reset a day earlier 2016 to 2380 = Mon 2400 reset a day earlier 2408 to 2772 – Sun 2800 Reset a day earlier 2800 to 2828 - Sat So that pattern repeats every 2800 years In essence, the answer is that without a time frame the question cannot be answered Steve But 400 is a leap year. (sorry, I forgot to put this in my previous post) Quote Link to comment Share on other sites More sharing options...
0 superprismatic Posted November 18, 2009 Report Share Posted November 18, 2009 Reveal hidden contents Let's start with the year 2000 when New Years was on a Saturday. Let 0=Sunday, 1=Monday, 2=Tuesday, 3=Wednesday, 4=Thursday, 5=Friday, and 6=Saturday. I have written the New Years day numbers on a width of 28. The year 2000 is a leap year but 2100, 2200, and 2300 are not. Other years divisible by 4 are leap years. Here's the table: New Year day numbers Years Comments 6123460124560234501235601345 2000-2027 2000 is a leap year 6123460124560234501235601345 2028-2055 6123460124560234501235601345 2056-2083 6123460124560234560124560234 2084-2111 in 2100 it's a 5 (Friday) and not a leap year 5012356013456123460124560234 2112-2139 5012356013456123460124560234 2140-2167 5012356013456123460124560234 2168-2195 5012345602345012356013456123 2196-2223 in 2200 it's a 3 (Wednesday) and not a leap year 4601245602345012356013456123 2224-2251 4601245602345012356013456123 2252-2279 4601245602345012356012345012 2280-2307 in 2300 it's a 1 (Monday) and not a leap year 3560134561234601245602345012 2308-2335 3560134561234601245602345012 2336-2363 3560134561234601245602345012 2364-2391 35601345 2392-2399 612346..... 2400-etc. in 2400 it's a 6 (Saturday) and a leap year and things are as they were in 2000, so another 400-year cycle begins. If you count the occurance of each digit you find 0 (Sunday) occurs 58 times 1 (Monday) occurs 56 times 2 (Tuesday) occurs 58 times 3 (Wednesday) occurs 57 times 4 (Thursday) occurs 57 times 5 (Friday) occurs 58 times 6 (Saturday) occurs 56 times Quote Link to comment Share on other sites More sharing options...
0 Guest Posted November 19, 2009 Report Share Posted November 19, 2009 Reveal hidden contents It's a simple code (Gregorian calendar starts 15 October 1581, so the first January 1 is in 1582, and it's a Friday.) Saturdays: 60 Sundays: 62 Run it for yourself public class Leapyear { // 0 = saturday, 1 = sunday, 2 = monday, 3 = tuesday, 4 = wednesday, 5 = thursday, 6 = friday public static void main() { int sat = 0, sun = 0; for (int year = 1582, day = 6; year <= 2009; year++) { if (day == 0) {sat++;} if (day == 1) {sun++;} if (isLeapYear(year)) {day += 2;} else {day++;} day %= 7; } System.out.println("Saturdays: " + sat + "\nSundays: " + sun); } public static boolean isLeapYear(int year) { boolean leap = false; if (year % 4 == 0) {leap = true;} if (year % 100 == 0 && year % 400 != 0) {leap = false;} return leap; } } // Outputs: // Saturdays: 60 // Sundays: 62 Quote Link to comment Share on other sites More sharing options...
0 superprismatic Posted November 19, 2009 Report Share Posted November 19, 2009 On 11/19/2009 at 4:27 AM, K4D said: Reveal hidden contents It's a simple code (Gregorian calendar starts 15 October 1581, so the first January 1 is in 1582, and it's a Friday.) Saturdays: 60 Sundays: 62 Run it for yourself { // 0 = saturday, 1 = sunday, 2 = monday, 3 = tuesday, 4 = wednesday, 5 = thursday, 6 = friday public static void main() { int sat = 0, sun = 0; for (int year = 1582, day = 6; year <= 2009; year++) { if (day == 0) {sat++;} if (day == 1) {sun++;} if (isLeapYear(year)) {day += 2;} else {day++;} day %= 7; } System.out.println("Saturdays: " + sat + "\nSundays: " + sun); } public static boolean isLeapYear(int year) { boolean leap = false; if (year % 4 == 0) {leap = true;} if (year % 100 == 0 && year % 400 != 0) {leap = false;} return leap; } } // Outputs: // Saturdays: 60 // Sundays: 62public class Leapyear Reveal hidden contents When your program is run on ANY 400 year period, say from 1582 to 1981, it always gets 58 Sundays and 56 Saturdays. Quote Link to comment Share on other sites More sharing options...
0 Guest Posted November 20, 2009 Report Share Posted November 20, 2009 On 11/19/2009 at 4:42 PM, superprismatic said: Reveal hidden contents When your program is run on ANY 400 year period, say from 1582 to 1981, it always gets 58 Sundays and 56 Saturdays. Reveal hidden contents yes, it was meant for those who thought that the number of Saturdays and Sundays were the same Quote Link to comment Share on other sites More sharing options...
0 superprismatic Posted November 20, 2009 Report Share Posted November 20, 2009 On 11/20/2009 at 5:33 AM, K4D said: Reveal hidden contents yes, it was meant for those who thought that the number of Saturdays and Sundays were the same By the way, I couldn't compile your program. I got the following error: jan1.c:1: error: expected unqualified-id before ‘public’ With a different C compiler, I got this error: jan1.c:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘class’ I don't program in C or C++, so I don't know what the problem is. Can you help? Quote Link to comment Share on other sites More sharing options...
0 Guest Posted November 20, 2009 Report Share Posted November 20, 2009 On 11/20/2009 at 1:49 PM, superprismatic said: By the way, I couldn't compile your program. I got the following error: jan1.c:1: error: expected unqualified-id before ‘public’ With a different C compiler, I got this error: jan1.c:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘class’ I don't program in C or C++, so I don't know what the problem is. Can you help? It's java Quote Link to comment Share on other sites More sharing options...
0 Guest Posted November 20, 2009 Report Share Posted November 20, 2009 On 11/20/2009 at 4:26 PM, Semper Rideo said: It's java I don't know any of the C's Quote Link to comment Share on other sites More sharing options...
0 superprismatic Posted November 20, 2009 Report Share Posted November 20, 2009 On 11/20/2009 at 6:09 PM, K4D said: I don't know any of the C's I tried Java compilation, I got the error: ---------- 1. ERROR in jan1.java (at line 1) public class Leapyear ^^^^^^^^ The public type Leapyear must be defined in its own file ---------- 1 problem (1 error) Quote Link to comment Share on other sites More sharing options...
0 Guest Posted November 21, 2009 Report Share Posted November 21, 2009 On 11/20/2009 at 9:04 PM, superprismatic said: I tried Java compilation, I got the error: ---------- 1. ERROR in jan1.java (at line 1) public class Leapyear ^^^^^^^^ The public type Leapyear must be defined in its own file ---------- 1 problem (1 error) I use http://drjava.org/ for simple java stuff, just make a new class in it and copy the program and it should work. It works for me Quote Link to comment Share on other sites More sharing options...
0 Guest Posted November 25, 2009 Report Share Posted November 25, 2009 On 11/18/2009 at 10:03 PM, superprismatic said: You forgot to take into account that years 100, 200, and 300 are not leap years. Actually I made two mistakes. I thought that it you missed a leap year every 400 when in fact you miss it every 100 and keep it every 400 (sorry). Nether the less I think the prociple still holds; Amended version; Clearly in the 28 year cycle containing the 100th year the whole pattern resets one day earlier in the week. What this means is that in our example every 28th year NYD will be a Saturday up to year 84 and then multiples of 28 after that will be Fridays from years 112 to 196 etc as shown below; 1 – 84 = Sat 100 reset a day earlier because missed leap year 112 – 196 = Fri 200 reset a day earlier because missed leap year 224 – 280 = Thurs 300 reset a day earlier because missed leap year 308 - 392 = Wed 400 NO EFFECT 420 to 476 = Wed 500 reset a day earlier because missed leap year 504 to 588 = Tues 600 reset a day earlier because missed leap year 616 to 696 – Mon 700 Reset a day earlier because missed leap year 724 to 780 - Sun 800 NO EFFECT 808 to 892 - Sun 900 reset a day earlier because missed leap year 920 to 976 - Sat 1000 reset a day earlier because missed leap year Based on the above the pattern repeats every 900 years Quote Link to comment Share on other sites More sharing options...
Question
Guest
Hi,
Need help on this question. On which of the two days of the week, Saturday or Sunday, does New Year's Day fall more often?
Link to comment
Share on other sites
20 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.