Problem 019

A place to air possible concerns or difficulties in understanding ProjectEuler problems. This forum is not meant to publish solutions. This forum is NOT meant to discuss solution methods or giving hints how a problem can be solved.
Forum rules
As your posts will be visible to the general public you are requested to be thoughtful in not posting anything that might explicitly give away how to solve a particular problem.

This forum is NOT meant to discuss solution methods for a problem.

In particular don't post any code fragments or results.

Don't start begging others to give partial answers to problems

Don't ask for hints how to solve a problem

Don't start a new topic for a problem if there already exists one


See also the topics:
Don't post any spoilers
Comments, questions and clarifications about PE problems.
nz89
Posts: 8
Joined: Mon Mar 23, 2009 2:30 pm

Problem 019

Post 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!
User avatar
daniel.is.fischer
Posts: 2400
Joined: Sun Sep 02, 2007 11:15 pm
Location: Bremen, Germany

Re: Problem 019

Post by daniel.is.fischer »

Right. Perhaps you should check whether you have your month lengths correct?
Il faut respecter la montagne -- c'est pourquoi les gypaètes sont là.
nz89
Posts: 8
Joined: Mon Mar 23, 2009 2:30 pm

Re: Problem 019

Post 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!
harryh
Posts: 2091
Joined: Tue Aug 22, 2006 9:33 pm
Location: Thessaloniki, Greece

Re: Problem 019

Post 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).
User avatar
daniel.is.fischer
Posts: 2400
Joined: Sun Sep 02, 2007 11:15 pm
Location: Bremen, Germany

Re: Problem 019

Post by daniel.is.fischer »

So do I.
Il faut respecter la montagne -- c'est pourquoi les gypaètes sont là.
nz89
Posts: 8
Joined: Mon Mar 23, 2009 2:30 pm

Re: Problem 019

Post 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?
User avatar
daniel.is.fischer
Posts: 2400
Joined: Sun Sep 02, 2007 11:15 pm
Location: Bremen, Germany

Re: Problem 019

Post 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.
Il faut respecter la montagne -- c'est pourquoi les gypaètes sont là.
nz89
Posts: 8
Joined: Mon Mar 23, 2009 2:30 pm

Re: Problem 019

Post 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 :D
Rodrigues
Posts: 2
Joined: Mon Jul 27, 2009 8:16 pm

Problem 19. Error in description?

Post 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.
User avatar
elendiastarman
Posts: 410
Joined: Sat Dec 22, 2007 8:15 pm

Re: Problem 19. Error in description?

Post by elendiastarman »

But 1 Jan 1901 was a Tuesday.
Want some
3.14159265358979323846264338327950288419716939937510
58209749445923078164062862089986280348253421170679...?
Image
Rodrigues
Posts: 2
Joined: Mon Jul 27, 2009 8:16 pm

Re: Problem 19. Error in description?

Post 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
waynecolvin
Posts: 2
Joined: Thu Apr 15, 2010 6:24 pm

Re: Problem 019

Post 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.
matthewden
Posts: 15
Joined: Wed Aug 11, 2010 6:07 pm
Location: Maryland, USA

Re: Problem 019

Post 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.............
Image
zcxvbn
Posts: 5
Joined: Sun Aug 29, 2010 4:40 pm
Location: It is sunny.

Re: Problem 019

Post 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 ...
Image
User avatar
vivekannan
Posts: 3
Joined: Tue Jun 07, 2011 2:42 pm
Location: India

Re: Problem 019

Post 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." :?
"Microsoft sells you Windows, but Linux gives you the whole house for free!"

Image
whakamaru
Posts: 47
Joined: Thu May 06, 2010 11:08 pm

Re: Problem 019

Post 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.
cppbeginner
Posts: 1
Joined: Thu Jun 28, 2012 8:51 am

Re: Problem 019

Post 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?
User avatar
jaap
Posts: 588
Joined: Tue Mar 25, 2008 3:57 pm
Contact:

Re: Problem 019

Post 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.
whakamaru
Posts: 47
Joined: Thu May 06, 2010 11:08 pm

Re: Problem 019

Post 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.
alexcs123
Posts: 1
Joined: Mon May 09, 2022 10:41 pm

Problem 019 Leap Year Coincidence?

Post 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.
Post Reply