From 13c9250317af138f870f4b26e16b1c90bb67cdbe Mon Sep 17 00:00:00 2001 From: Matthew Date: Wed, 12 Feb 2020 20:54:01 -0500 Subject: [PATCH 1/2] Add files via upload --- Problem_019.py | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 Problem_019.py diff --git a/Problem_019.py b/Problem_019.py new file mode 100644 index 0000000..81365da --- /dev/null +++ b/Problem_019.py @@ -0,0 +1,49 @@ +###################################################################### +# Starts at the startYear, startMonth, startWeekday (assuming you are starting at the 1st of the month). +# Counts through each month between the time period keeping track of which day of the week the start of +# each month is falling on. Adds to counter if the weekday is a Sunday on the 1st of the month and outputs. +###################################################################### + +# days in each month for normal and leap years +monthDays = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] +monthDaysLeap = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] + +# start date information +startYear = 1901 +startMonth = 1 +startWeekday = 2 + +# end date information +endYear = 2000 +endMonth = 12 + +# other variables +year = startYear +month = startMonth +weekday = startWeekday + +counter = 0 + +# main +while year < endYear: + if weekday == 1: + counter += 1 + + if year%4 == 0: + weekday = (monthDaysLeap[month-1] + weekday)%7 + else: + weekday = (monthDays[month-1] + weekday)%7 + + if month == 12: + month = 1 + year += 1 + else: + month += 1 + +print(counter) +# Solution: 171 + + + + + From 7915715119c5a532599591dc9f2e554b1e1d1930 Mon Sep 17 00:00:00 2001 From: Matthew Date: Wed, 12 Feb 2020 20:55:20 -0500 Subject: [PATCH 2/2] Update Problem_019.py --- Problem_019.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Problem_019.py b/Problem_019.py index 81365da..c91e2b9 100644 --- a/Problem_019.py +++ b/Problem_019.py @@ -42,8 +42,3 @@ while year < endYear: print(counter) # Solution: 171 - - - - -