- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
Latest commit
41 lines (32 loc) · 1.31 KB
/
Copy pathtest.py
File metadata and controls
41 lines (32 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
defsolution(s, times):
answer= [1,1]
#[year, month, day, hour, minutes, second]
start=list(map(int, s.split(":")))
end=list(map(int, s.split(":")))
fortintimes:
splited_t=list(map(int,t.split(":")))
save_date=saving_date_calculator(end, splited_t)
ifis_over_a_day(end, save_date):
answer[0] =0
end=save_date
answer[1] =day_calculator(start, end)
returnanswer
defsaving_date_calculator(before_save, save_date):
minutes, second=my_divmod(0, before_save[5], save_date[3], 60)
hour, minutes=my_divmod(minutes, before_save[4], save_date[2], 60)
day, hour=my_divmod(hour, before_save[3], save_date[1], 24)
month, day=my_divmod(day, before_save[2], save_date[0], 30)
year, month=my_divmod(month, before_save[1], 0, 12)
year+=before_save[0]
return [year, month, day, hour, minutes, second]
defmy_divmod(target, before, after, num):
a, b=divmod(target+before+after, num)
return [a,b]
defis_over_a_day(before_save, save_date):
returnTrueifsave_date[2] -before_save[2] >1elseFalse
defday_calculator(start,end):
year=end[0] -start[0]
month=end[1] -start[1]
day=end[2] -start[2]
return360*year+30*month+day+1
print(solution("2020:12:30:23:59:0", []))