@@ -41,21 +41,7 @@ def batman_day() -> None:
41
41
for year in range (2024 , 2050 ):
42
42
sep_fst = dt .strptime (str (year ) + "-09-01" , "%Y-%m-%d" )
43
43
# Batman's day is celebrated every 3rd Saturday of September
44
- match sep_fst .strftime ("%a" ):
45
- case "Sun" :
46
- days = 20
47
- case "Mon" :
48
- days = 19
49
- case "Tue" :
50
- days = 18
51
- case "Wed" :
52
- days = 17
53
- case "Thu" :
54
- days = 16
55
- case "Fri" :
56
- days = 15
57
- case _:
58
- days = 14
44
+ days = 20 - int (sep_fst .strftime ("%w" ))
59
45
bat_day = sep_fst + td (days = days )
60
46
print (f"Batman celebrates its { anniversary } th anniversary on { bat_day .strftime ('%A %B %d, %Y' )} " )
61
47
anniversary += 1
@@ -104,9 +90,13 @@ def max_alert(alerted_blocks: list) -> list:
104
90
return [x for x in alerted_blocks if x [1 ] == maximal_alert ]
105
91
106
92
107
- def activate_protocol (alerted_blocks : list ) -> None :
93
+ def activate_protocol (alerted_blocks : list ) -> bool :
94
+ activated = False
108
95
for alert in max_alert (alerted_blocks ):
109
96
print (f"\n Alert Level: { alert [1 ]} / Distance from batcave to coord { gotham [alert [0 ]][4 ]} = { calculate_distance (gotham [alert [0 ]][4 ])} " )
97
+ activated = True
98
+ break
99
+ return activated
110
100
111
101
112
102
batman_day ()
@@ -115,7 +105,11 @@ def activate_protocol(alerted_blocks: list) -> None:
115
105
sensors = gotham_sensors ()
116
106
alerted_blocks = system_monitor (gotham , sensors )
117
107
if alerted_blocks :
118
- activate_protocol (alerted_blocks )
119
- break
108
+ if activate_protocol (alerted_blocks ):
109
+ print ("To the Batmobile, Robin." )
110
+ break
111
+ else :
112
+ print ("\n No alert rises over the minimal level of risk => police can be in charge." )
120
113
else :
121
- print ("No alert rises over the minimal level of risk => police can be in charge." )
114
+ print ("\n All quiet on Gotham." )
115
+ print ("Keep tracking." )
0 commit comments