@@ -41,21 +41,7 @@ def batman_day() -> None:
4141 for year in range (2024 , 2050 ):
4242 sep_fst = dt .strptime (str (year ) + "-09-01" , "%Y-%m-%d" )
4343 # 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" ))
5945 bat_day = sep_fst + td (days = days )
6046 print (f"Batman celebrates its { anniversary } th anniversary on { bat_day .strftime ('%A %B %d, %Y' )} " )
6147 anniversary += 1
@@ -104,9 +90,13 @@ def max_alert(alerted_blocks: list) -> list:
10490 return [x for x in alerted_blocks if x [1 ] == maximal_alert ]
10591
10692
107- def activate_protocol (alerted_blocks : list ) -> None :
93+ def activate_protocol (alerted_blocks : list ) -> bool :
94+ activated = False
10895 for alert in max_alert (alerted_blocks ):
10996 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
110100
111101
112102batman_day ()
@@ -115,7 +105,11 @@ def activate_protocol(alerted_blocks: list) -> None:
115105 sensors = gotham_sensors ()
116106 alerted_blocks = system_monitor (gotham , sensors )
117107 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." )
120113 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