Page 1 of 2
Problem 019
Posted: Mon Apr 13, 2009 4:49 pm
by nz89
hello all..i wrote the code for this problem but i still can't get the right answer so i want to make sure i understood it correctly.
"How many Sundays fell on the first of the month during the twentieth century (1 Jan 1901 to 31 Dec 2000)?"
for example:
if 1/2/1901 was a Sunday
and 1/5/1950 was a Sunday
that way we have 2 Sundays on the first of the month right?
nevermind the very small number of Sundays in the example..
any help appreciated!
Re: Problem 019
Posted: Mon Apr 13, 2009 6:37 pm
by daniel.is.fischer
Right. Perhaps you should check whether you have your month lengths correct?
Re: Problem 019
Posted: Mon Apr 13, 2009 8:11 pm
by nz89
i already did,and i checked the first 4 years (1901-1904) with a calendar and my program gave identical values.
8 Sundays fell on the first of the month from 1901 to 1904,it might help if i know if this value is wrong so i can find out where the problem is.
thanks!
Re: Problem 019
Posted: Mon Apr 13, 2009 8:28 pm
by harryh
I make it 7 Sundays for the first four years (2 in 1901, 1 in 1902, 3 in 1903 and 1 in 1904).
Re: Problem 019
Posted: Mon Apr 13, 2009 9:33 pm
by daniel.is.fischer
So do I.
Re: Problem 019
Posted: Mon Apr 13, 2009 11:50 pm
by nz89
that's right,i added the one at the beginning of the year by mistake 1905 (1/1/1905).
i checked exactly in which months Sundays fall on the first and i got the same answer as harry (2 in 1901(september and december), 1 in 1902 (june), 3 in 1903(february,march and november) and 1 in 1904(may)).
is there a possibility that there's a problem from the server or something?
Re: Problem 019
Posted: Tue Apr 14, 2009 1:21 am
by daniel.is.fischer
A faint possibility. You're not accidentally entering whitespace along with the number?
You could PM me your result so I could see if it's correct.
Re: Problem 019
Posted: Tue Apr 14, 2009 2:20 pm
by nz89
nevermind,i tried numbers that range in -5,+5 from the answer i got with my program and i got the right answer.
but i still don't know what's wrong with it,i'll check the thread for the problem..thanks for the help

Problem 19. Error in description?
Posted: Mon Jul 27, 2009 8:24 pm
by Rodrigues
In
Problem 19 (
View Problem) the description says that:
1 Jan 1900 was a Monday
I think it was meant to be
1901 and not
1900, since 1 Jan 1900 was not a Monday.
Re: Problem 19. Error in description?
Posted: Mon Jul 27, 2009 8:39 pm
by elendiastarman
But 1 Jan 1901 was a
Tuesday.
Re: Problem 19. Error in description?
Posted: Mon Jul 27, 2009 9:14 pm
by Rodrigues
Yeah, you're right. I checked and re-checked without realizing I was using the wrong year (2000 instead of 1900)

.
Sorry for my mistake. Maybe an admin should delete this thread.
Cheers
Re: Problem 019
Posted: Sat Apr 17, 2010 12:02 pm
by waynecolvin
I was just retesting my date iterator, checking it against "cal" on the command line, and my program was correctly finding all the Mondays. Started to wonder if 1900/2000 should be included/excluded whatever. Didn't notice the problem was asking for Sundays instead! OOPS!! In a couple minutes this will be my 25th solved.
Re: Problem 019
Posted: Mon Oct 11, 2010 6:59 pm
by matthewden
WOW. I really can't follow directions...
First, I tried to find ALL the Sundays from January 1901 to December 2000, in each month. That wasn't right.
I next tried to find all the Sundays from January 1901 to December 2000, just in January. That, too, wasn't right...
As I was reading this thread, I saw:
harryh wrote:I make it 7 Sundays for the first four years (2 in 1901, 1 in 1902, 3 in 1903 and 1 in 1904).
And wondered how there could be only 2 Sundays in January in 1901, 1 in 1902, etc. So I re-read the problem...incorrectly again.
As I write this, I thought, "wait, how can there be 2 Sundays that BOTH fall on the first of January???".
On my
5th try, lets see if understood what the problem was asking.............
Re: Problem 019
Posted: Mon Oct 11, 2010 10:33 pm
by zcxvbn
The problem could be stated as:
Find the total number of months between January 1901 and December 2000 inclusive, whose 1st was a Sunday. For example, April 1st, 1900 was a Sunday, so the month of April 1900 is counted.
Maybe this will clear up some confusion ...
Re: Problem 019
Posted: Sun Dec 18, 2011 2:57 am
by vivekannan
Is this sum based on the fact that if the first day of any month is a Sunday then the 13th will be a Friday and so Friday the 13th?
Look at what I found on wiki,
"Any month's 13th day will fall on a Friday if the month starts on a Sunday."

Re: Problem 019
Posted: Thu Feb 23, 2012 2:44 am
by whakamaru
This problem should have set to find the number of months that begin on the Monday, as for the 1st of Jan 1900. That would have gezumpt some smarties.
The variation of results for all seven days is a surprise... to me... after I reread the question, as others appear to have been mistaken. ASM. another senior moment.
Re: Problem 019
Posted: Thu Jun 28, 2012 8:52 am
by cppbeginner
I had a doubt.
"How many Sundays fell on the first of the month during the twentieth century (1 Jan 1901 to 31 Dec 2000)?"
The twentieth century also includes the year 1900. So, we don't have to consider 1900 while computing the number of Sundays or do we have to do include it?
Re: Problem 019
Posted: Thu Jun 28, 2012 9:19 am
by jaap
cppbeginner wrote:I had a doubt.
"How many Sundays fell on the first of the month during the twentieth century (1 Jan 1901 to 31 Dec 2000)?"
The twentieth century also includes the year 1900. So, we don't have to consider 1900 while computing the number of Sundays or do we have to do include it?
No 1900 is part of the 19th century. As the part in brackets shows, you must exclude 1900 but include 2000.
Re: Problem 019
Posted: Wed Jan 23, 2013 9:09 pm
by whakamaru
What about the other days? This problem could have been set to find Wednesays, Thursdays or Fridays, which would have gezumped those smarties who litter the answers forum with a simplistic non-program solution. Setting it for 1900-1999 would have required one extra test since 1900 is not a leap year, although high-level languages using a date function would still work.
Problem 019 Leap Year Coincidence?
Posted: Mon May 09, 2022 10:49 pm
by alexcs123
Hello all,
I was just revisiting my old solutions for refactoring, during which I noticed something odd with problem 019. It seems that if I remove my conditional statement which determines if a year is a leap year, it has no effect on the answer. I KNOW that this does depend on the way I've written it, so to dive deeper I would have to publish snippets (not allowed), but I currently have a working 4-line python solution which returns the correct answer without ANY leap year determination, all years are considered non-leap. Is this a mad coincidence? I've checked and it does obviosuly result in the internal calendar becoming incorrect from 1904 onwards, but still...
I'd be interested to know if anyone else has the same experience.