Was lazy, used datetime library for this
This commit is contained in:
24
19/main.py
Normal file
24
19/main.py
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
import os
|
||||||
|
import datetime
|
||||||
|
|
||||||
|
# How many sundays fell on the first of the month in the twentieth century?
|
||||||
|
|
||||||
|
def getFirsts(minYear, maxYear):
|
||||||
|
res = 0
|
||||||
|
|
||||||
|
for year in range(minYear, maxYear + 1):
|
||||||
|
for month in range(1, 13):
|
||||||
|
if datetime.datetime(year, month, 1).weekday() == 6:
|
||||||
|
res = res + 1
|
||||||
|
|
||||||
|
return res
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
print("Hello, this is Patrick")
|
||||||
|
|
||||||
|
print(getFirsts(1901, 2000))
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
Reference in New Issue
Block a user