Tc14

Vlogger

Jun 15th, 2024
676
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.22 KB | None | 0 0
  1. from datetime import date, timedelta
  2.  
  3. DAYS_IN_YEAR = 365
  4. DAYS_IN_CYCLE = DAYS_IN_YEAR * 4 + 1
  5. LEAP_DAY = 59 # Feb 29th
  6. CYCLE_START = date(2024, 1, 1)
  7.  
  8. def valid(interval, startDay):
  9.  
  10.     currentDay = startDay
  11.     VloggedDay = [False] * DAYS_IN_YEAR
  12.     VloggedLeapDay = False
  13.  
  14.     for _ in range(DAYS_IN_YEAR + 1):
  15.         if currentDay < LEAP_DAY:
  16.             VloggedDay[currentDay % DAYS_IN_YEAR] = True
  17.         elif currentDay > LEAP_DAY:
  18.             VloggedDay[(currentDay - 1) % DAYS_IN_YEAR] = True
  19.         else:
  20.             VloggedLeapDay = True
  21.  
  22.         currentDay += interval
  23.         currentDay %= DAYS_IN_CYCLE
  24.  
  25.     return all(VloggedDay) and VloggedLeapDay
  26.  
  27. for interval in range(2, 45 + 1):
  28.     for startDay in range(DAYS_IN_CYCLE):
  29.         if valid(interval, startDay):
  30.             print(f"{interval:>2}", CYCLE_START + timedelta(days=startDay))
  31.  
  32. # Output:
  33. #
  34. #  2 2024-02-29
  35. #  2 2026-03-01
  36. #  3 2024-02-29
  37. #  3 2025-03-01
  38. #  4 2024-02-29
  39. #  4 2024-03-01
  40. # 20 2024-02-29
  41. # 20 2024-03-01
  42. # 20 2024-03-02
  43. # 20 2024-03-03
  44. # 20 2024-03-04
  45. # 20 2024-03-05
  46. # 34 2025-03-01
  47. # 34 2025-03-02
  48. # 34 2025-03-03
  49. # 34 2025-03-04
  50. # 34 2025-03-05
  51. # 34 2025-03-06
  52. # 34 2025-03-07
  53. # 34 2025-03-08
  54.  
Advertisement
Add Comment
Please, Sign In to add comment