Advertisement
kdzhr

BUGS

Feb 29th, 2020
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.09 KB | None | 0 0
  1. import datetime as dt
  2.  
  3.  
  4. def in_range(cur):
  5.     cur = cur - null_date
  6.     cur = cur.days
  7.     return birth <= cur <= death
  8.  
  9.  
  10. first = [int(x) for x in input().split()]
  11. second = [int(x) for x in input().split()]
  12. birth = [int(x) for x in input().split()]
  13. death = [int(x) for x in input().split()]
  14. first = dt.date(year=first[0], month=first[1], day=first[2])
  15. second = dt.date(year=second[0], month=second[1], day=second[2])
  16. birth = dt.date(year=birth[0], month=birth[1], day=birth[2])
  17. death = dt.date(year=death[0], month=death[1], day=death[2])
  18. null_date = dt.date(year=1, month=1, day=1)
  19.  
  20. delta = second - first
  21.  
  22. birth = birth - null_date
  23. birth = birth.days
  24.  
  25. death = death - null_date
  26. death = death.days
  27.  
  28. ans = 0
  29.  
  30. if in_range(first):
  31.     ans += 1
  32.  
  33. cur_first = first
  34. while True:
  35.     try:
  36.         cur_first += delta
  37.         if in_range(cur_first):
  38.             ans += 1
  39.     except Exception:
  40.         break
  41.  
  42. cur_first = first
  43. while True:
  44.     try:
  45.         cur_first -= delta
  46.         if in_range(cur_first):
  47.             ans += 1
  48.     except Exception:
  49.         break
  50. print(ans)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement