aboutsummaryrefslogtreecommitdiff
path: root/python/19-counting_sundays.py
diff options
context:
space:
mode:
authorCharles <sircharlesaze@gmail.com>2019-08-11 22:41:34 +0200
committerCharles <sircharlesaze@gmail.com>2019-08-11 22:41:34 +0200
commit1879caa1dd80cb11dd62403663917ad4bf7cc68e (patch)
treeea41c6dd83a9f9bbfe0a891237674342de92d533 /python/19-counting_sundays.py
parent6b16d921543a62d880171791d39bcc58560785fa (diff)
downloadproject_euler-1879caa1dd80cb11dd62403663917ad4bf7cc68e.tar.gz
project_euler-1879caa1dd80cb11dd62403663917ad4bf7cc68e.tar.bz2
project_euler-1879caa1dd80cb11dd62403663917ad4bf7cc68e.zip
rename all file with 3 zero padding
Diffstat (limited to 'python/19-counting_sundays.py')
-rw-r--r--python/19-counting_sundays.py34
1 files changed, 0 insertions, 34 deletions
diff --git a/python/19-counting_sundays.py b/python/19-counting_sundays.py
deleted file mode 100644
index f018e05..0000000
--- a/python/19-counting_sundays.py
+++ /dev/null
@@ -1,34 +0,0 @@
-def month_days(index, leap_year):
- if index == 2:
- if leap_year:
- return 29
- return 28
- if index in [4, 6, 9, 11]:
- return 30
- return 31
-
-
-def is_leap_year(year):
- if str(year)[2:] == '00' and year % 400 != 0:
- return False
- if year % 4 == 0:
- return True
- return False
-
-def next_day(current):
- if current == 7:
- return 1
- return current + 1
-
-months = [x for x in range(1, 13)]
-day = 1
-sundays_counter = 0
-
-for year in range(1900, 2001):
- for month in months:
- for d in range(month_days(month, is_leap_year(year))):
- if day == 7 and d == 0 and year >= 1901:
- sundays_counter += 1
- day = next_day(day)
-
-print(sundays_counter)