Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Unlucky Days by wolicki.mikolaj
import datetime
def checkio(year):
wynik=0
data=datetime.date(year, 1, 1)
data2=datetime.date(year+1, 1, 1)
#print data2
while data!=data2:
if data.day==13 and data.isoweekday()==5:
wynik=wynik+1
a=data.day+1
try:
data=data.replace(day=a)
except:
try :
mon=data.month
mon=mon+1
data=data.replace(month=mon,day=1)
except:
data=data2
return wynik
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"
Nov. 26, 2016