Created
October 14, 2020 05:28
-
-
Save projjal1/31011f780a629ab285f4196eb8da65d7 to your computer and use it in GitHub Desktop.
CodeVita 2016 Round 2 Question: The Mystery of Sky
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Question available at https://www.programminggeek.in/2016/08/codevita-2016-round-2-question-mystery.html#.X4Z9AObitPY | |
| #Question available at https://www.programminggeek.in/2016/08/codevita-2016-round-2-question-mystery.html#.X4Z9AObitPY | |
| import datetime | |
| days_in_week={'Sunday':0,'Monday':1,'Tuesday':2,'Wednesday':3,'Thursday':4,'Friday':5,'Saturday':6} | |
| t=int(input()) | |
| def calc_stars(diff,year,day,dobj): | |
| diff=diff-1 | |
| day_idx=diff%7+day | |
| if day_idx==0 or day_idx==6: | |
| return 0 | |
| else: | |
| dref=datetime.date(year,1,1) | |
| return (dobj-dref).days+1 | |
| for x in range(t): | |
| day=days_in_week[input().strip()] | |
| date=input().split('/') | |
| #Initial date | |
| d1=datetime.date(1,1,1) | |
| #Using datetime object | |
| try: | |
| d2=datetime.date(int(date[2]),int(date[1]),int(date[0])) | |
| except: | |
| print("Invalid Date") | |
| continue | |
| #Calculate diff of days | |
| diff=(d2-d1).days+1 | |
| #Check for discharge day | |
| if (diff%4==0): | |
| print("Invalid Day") | |
| else: | |
| print(calc_stars(diff,int(date[2]),day,d2)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment