Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Unlucky Days solution in Clear category for Unlucky Days by graffme
from datetime import date
import calendar
def checkio(year):
unlucky_days = 0
c = calendar.TextCalendar(calendar.SUNDAY)
for m in range(1,13):
for i in c.itermonthdays(year,m):
if i != 0:
day = date(year,m,i)
if day.weekday() == 4 and i == 13:
unlucky_days += 1
return unlucky_days
if __name__ == '__main__':
#These "asserts" using only for self-checking and not necessary for auto-testing
assert checkio(2015) == 3, "First - 2015"
assert checkio(1986) == 1, "Second - 1986"
Jan. 14, 2017