Guest User

Untitled

a guest
Apr 7th, 2021
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.71 KB | None | 0 0
  1. days = [31,28,31,30,31,30,31,31,30,31,30,31]
  2. leap = lambda rok: (rok % 4 == 0 and rok % 100 != 0) or rok % 400 == 0
  3.  
  4. def mdays(year, month):
  5.     if month == 1 and leap(year):
  6.         return 29
  7.     else:
  8.         return days[month]
  9.  
  10. year, month, day = 2000, 0, 6 #7 stycznia 2000, pierwszy piatek roku
  11. stop = 1000000000
  12.  
  13. p = 0
  14. l = 0
  15.  
  16. while year < stop:
  17.     l += [365, 366][leap(year)]
  18.     while month < 12:
  19.         while day < mdays(year, month):
  20.             if day == 12:
  21.                 #print("year: %d month: %d day: %d" % (year, month, day))
  22.                 p += 1
  23.             day += 7
  24.         day = (day + 7) % mdays(year, month)
  25.         month += 1
  26.     month = 0
  27.     year += 1
  28.    
  29. print (p/l)
Advertisement
Add Comment
Please, Sign In to add comment