Домашни > Хелоуин в Припят > Решения > Решението на Георги Илиев

Резултати
10 точки от тестове
0 точки от учител

10 точки общо

12 успешни теста
0 неуспешни теста
Код (Моите искрени извинения...)

  1import math
  2
  3class Candy:
  4    def __init__(self, mass: int, uranium: float):
  5        self.mass = mass
  6        self.uranium = uranium
  7
  8    def get_mass(self):
  9        return self.mass
 10
 11    def get_uranium_quantity(self):
 12        return self.mass * self.uranium
 13
 14
 15class Person:
 16    def __init__(self, position: tuple):
 17        self.position = position
 18
 19    def get_position(self):
 20        return self.position
 21
 22    def set_position(self, position: tuple):
 23        self.position = position
 24
 25    @staticmethod
 26    def dist_between(position1: tuple, position2: tuple):
 27        return math.sqrt((position2[0] - position1[0]) ** 2 + (position2[1] - position1[1]) ** 2)
 28
 29
 30class Kid(Person):
 31    CRITICAL_MASS_THRESHOLD = 20
 32
 33    def __init__(self, position: tuple, initiative: int):
 34        self.initiative = initiative
 35        self.basket = []
 36        super().__init__(position)
 37
 38    def get_initiative(self):
 39        return self.initiative
 40
 41    def add_candy(self, candy: Candy):
 42        self.basket.append(candy)
 43
 44    def is_critical(self):
 45        total_uranium = 0
 46        for candy in self.basket:
 47            total_uranium += candy.get_uranium_quantity()
 48        return total_uranium > self.CRITICAL_MASS_THRESHOLD
 49
 50
 51class Host(Person):
 52    def __init__(self, position: tuple, candies: list):
 53        self.basket = list()
 54        for candy in candies:
 55            self.basket.append(Candy(candy[0], candy[1]))
 56        super().__init__(position)
 57
 58    def remove_candy(self, predicate):
 59        if self.basket:
 60            candy = predicate(self.basket)
 61            self.basket.remove(predicate(self.basket))
 62            return candy
 63        return None
 64
 65
 66class FluxCapacitor:
 67    def __init__(self, participants: set):
 68        self.participants = participants
 69        self.hosts = [host for host in participants if isinstance(host, Host)]
 70        self.kids = [kid for kid in participants if isinstance(kid, Kid)]
 71
 72    def get_victim(self):
 73        hosts = self.hosts
 74        kids = self.kids
 75        kids_visited_hosts = {kid: [] for kid in kids}
 76
 77        while [len(visited_hosts) for visited_hosts in kids_visited_hosts.values()].count(len(hosts)) != len(kids):
 78            host_expected_kids = {host: [] for host in hosts}
 79
 80            # Determine which children will be visiting each host
 81            for kid in kids:
 82                closest_host = Host(position=(float('inf'), float('inf')), candies=[])
 83                for host in hosts:
 84                    if host not in kids_visited_hosts[kid]:
 85                        if (dist_a := Person.dist_between(kid.position, host.position)) < (
 86                                dist_b := Person.dist_between(kid.position, closest_host.position)):
 87                            closest_host = host
 88                        elif dist_a == dist_b:
 89                            if host.position[0] < closest_host.position[0]:
 90                                closest_host = host
 91                            elif host.position[0] == closest_host.position[0] and host.position[1] < closest_host.position[1]:
 92                                closest_host = host
 93                if closest_host.position != (float('inf'), float('inf')):
 94                    host_expected_kids[closest_host].append(kid)
 95
 96            # Sort kids by initiative
 97            for kids_list in host_expected_kids.values():
 98                if len(kids_list) > 1:
 99                    kids_list.sort(key=lambda x: x.initiative, reverse=True)
100
101            # Give candy to kids in defined order
102            for host in hosts:
103                # For every kid that wants to visit the host
104                for visiting_kid in host_expected_kids[host]:
105                    # Check if there is any candy left
106                    visiting_kid.set_position(host.get_position())
107                    if host.basket:
108                        # Host removes the candy from their basket and gives it to the kid
109                        visiting_kid.add_candy(host.remove_candy(lambda candy_basket: max(candy_basket, key=lambda candy: candy.get_mass())))
110                    # Kid now has visited this host and will never meet them again!
111                    kids_visited_hosts[visiting_kid].append(host)
112
113            # If there are any dead kids, return them
114            if dead_kids := set(kid for kid in kids if kid.is_critical()):
115                return dead_kids
116
117        return None

............
----------------------------------------------------------------------
Ran 12 tests in 0.001s

OK

Дискусия
История

t1import matht1import math
22
3class Candy:3class Candy:
4    def __init__(self, mass: int, uranium: float):4    def __init__(self, mass: int, uranium: float):
5        self.mass = mass5        self.mass = mass
6        self.uranium = uranium6        self.uranium = uranium
77
8    def get_mass(self):8    def get_mass(self):
9        return self.mass9        return self.mass
1010
11    def get_uranium_quantity(self):11    def get_uranium_quantity(self):
12        return self.mass * self.uranium12        return self.mass * self.uranium
1313
1414
15class Person:15class Person:
16    def __init__(self, position: tuple):16    def __init__(self, position: tuple):
17        self.position = position17        self.position = position
1818
19    def get_position(self):19    def get_position(self):
20        return self.position20        return self.position
2121
22    def set_position(self, position: tuple):22    def set_position(self, position: tuple):
23        self.position = position23        self.position = position
2424
25    @staticmethod25    @staticmethod
26    def dist_between(position1: tuple, position2: tuple):26    def dist_between(position1: tuple, position2: tuple):
27        return math.sqrt((position2[0] - position1[0]) ** 2 + (position2[1] - position1[1]) ** 2)27        return math.sqrt((position2[0] - position1[0]) ** 2 + (position2[1] - position1[1]) ** 2)
2828
2929
30class Kid(Person):30class Kid(Person):
31    CRITICAL_MASS_THRESHOLD = 2031    CRITICAL_MASS_THRESHOLD = 20
3232
33    def __init__(self, position: tuple, initiative: int):33    def __init__(self, position: tuple, initiative: int):
34        self.initiative = initiative34        self.initiative = initiative
35        self.basket = []35        self.basket = []
36        super().__init__(position)36        super().__init__(position)
3737
38    def get_initiative(self):38    def get_initiative(self):
39        return self.initiative39        return self.initiative
4040
41    def add_candy(self, candy: Candy):41    def add_candy(self, candy: Candy):
42        self.basket.append(candy)42        self.basket.append(candy)
4343
44    def is_critical(self):44    def is_critical(self):
45        total_uranium = 045        total_uranium = 0
46        for candy in self.basket:46        for candy in self.basket:
47            total_uranium += candy.get_uranium_quantity()47            total_uranium += candy.get_uranium_quantity()
48        return total_uranium > self.CRITICAL_MASS_THRESHOLD48        return total_uranium > self.CRITICAL_MASS_THRESHOLD
4949
5050
51class Host(Person):51class Host(Person):
52    def __init__(self, position: tuple, candies: list):52    def __init__(self, position: tuple, candies: list):
53        self.basket = list()53        self.basket = list()
54        for candy in candies:54        for candy in candies:
55            self.basket.append(Candy(candy[0], candy[1]))55            self.basket.append(Candy(candy[0], candy[1]))
56        super().__init__(position)56        super().__init__(position)
5757
58    def remove_candy(self, predicate):58    def remove_candy(self, predicate):
59        if self.basket:59        if self.basket:
60            candy = predicate(self.basket)60            candy = predicate(self.basket)
61            self.basket.remove(predicate(self.basket))61            self.basket.remove(predicate(self.basket))
62            return candy62            return candy
63        return None63        return None
6464
6565
66class FluxCapacitor:66class FluxCapacitor:
67    def __init__(self, participants: set):67    def __init__(self, participants: set):
68        self.participants = participants68        self.participants = participants
69        self.hosts = [host for host in participants if isinstance(host, Host)]69        self.hosts = [host for host in participants if isinstance(host, Host)]
70        self.kids = [kid for kid in participants if isinstance(kid, Kid)]70        self.kids = [kid for kid in participants if isinstance(kid, Kid)]
7171
72    def get_victim(self):72    def get_victim(self):
73        hosts = self.hosts73        hosts = self.hosts
74        kids = self.kids74        kids = self.kids
75        kids_visited_hosts = {kid: [] for kid in kids}75        kids_visited_hosts = {kid: [] for kid in kids}
7676
77        while [len(visited_hosts) for visited_hosts in kids_visited_hosts.values()].count(len(hosts)) != len(kids):77        while [len(visited_hosts) for visited_hosts in kids_visited_hosts.values()].count(len(hosts)) != len(kids):
78            host_expected_kids = {host: [] for host in hosts}78            host_expected_kids = {host: [] for host in hosts}
7979
80            # Determine which children will be visiting each host80            # Determine which children will be visiting each host
81            for kid in kids:81            for kid in kids:
82                closest_host = Host(position=(float('inf'), float('inf')), candies=[])82                closest_host = Host(position=(float('inf'), float('inf')), candies=[])
83                for host in hosts:83                for host in hosts:
84                    if host not in kids_visited_hosts[kid]:84                    if host not in kids_visited_hosts[kid]:
85                        if (dist_a := Person.dist_between(kid.position, host.position)) < (85                        if (dist_a := Person.dist_between(kid.position, host.position)) < (
86                                dist_b := Person.dist_between(kid.position, closest_host.position)):86                                dist_b := Person.dist_between(kid.position, closest_host.position)):
87                            closest_host = host87                            closest_host = host
88                        elif dist_a == dist_b:88                        elif dist_a == dist_b:
89                            if host.position[0] < closest_host.position[0]:89                            if host.position[0] < closest_host.position[0]:
90                                closest_host = host90                                closest_host = host
91                            elif host.position[0] == closest_host.position[0] and host.position[1] < closest_host.position[1]:91                            elif host.position[0] == closest_host.position[0] and host.position[1] < closest_host.position[1]:
92                                closest_host = host92                                closest_host = host
93                if closest_host.position != (float('inf'), float('inf')):93                if closest_host.position != (float('inf'), float('inf')):
94                    host_expected_kids[closest_host].append(kid)94                    host_expected_kids[closest_host].append(kid)
9595
96            # Sort kids by initiative96            # Sort kids by initiative
97            for kids_list in host_expected_kids.values():97            for kids_list in host_expected_kids.values():
98                if len(kids_list) > 1:98                if len(kids_list) > 1:
99                    kids_list.sort(key=lambda x: x.initiative, reverse=True)99                    kids_list.sort(key=lambda x: x.initiative, reverse=True)
100100
101            # Give candy to kids in defined order101            # Give candy to kids in defined order
102            for host in hosts:102            for host in hosts:
103                # For every kid that wants to visit the host103                # For every kid that wants to visit the host
104                for visiting_kid in host_expected_kids[host]:104                for visiting_kid in host_expected_kids[host]:
105                    # Check if there is any candy left105                    # Check if there is any candy left
106                    visiting_kid.set_position(host.get_position())106                    visiting_kid.set_position(host.get_position())
107                    if host.basket:107                    if host.basket:
108                        # Host removes the candy from their basket and gives it to the kid108                        # Host removes the candy from their basket and gives it to the kid
109                        visiting_kid.add_candy(host.remove_candy(lambda candy_basket: max(candy_basket, key=lambda candy: candy.get_mass())))109                        visiting_kid.add_candy(host.remove_candy(lambda candy_basket: max(candy_basket, key=lambda candy: candy.get_mass())))
110                    # Kid now has visited this host and will never meet them again!110                    # Kid now has visited this host and will never meet them again!
111                    kids_visited_hosts[visiting_kid].append(host)111                    kids_visited_hosts[visiting_kid].append(host)
112112
113            # If there are any dead kids, return them113            # If there are any dead kids, return them
114            if dead_kids := set(kid for kid in kids if kid.is_critical()):114            if dead_kids := set(kid for kid in kids if kid.is_critical()):
115                return dead_kids115                return dead_kids
116116
117        return None117        return None
Legends
Colors
 Added 
Changed
Deleted
Links
(f)irst change
(n)ext change
(t)op

f1import mathf1import math
22
3class Candy:3class Candy:
4    def __init__(self, mass: int, uranium: float):4    def __init__(self, mass: int, uranium: float):
5        self.mass = mass5        self.mass = mass
6        self.uranium = uranium6        self.uranium = uranium
77
8    def get_mass(self):8    def get_mass(self):
9        return self.mass9        return self.mass
1010
11    def get_uranium_quantity(self):11    def get_uranium_quantity(self):
12        return self.mass * self.uranium12        return self.mass * self.uranium
1313
1414
15class Person:15class Person:
16    def __init__(self, position: tuple):16    def __init__(self, position: tuple):
17        self.position = position17        self.position = position
1818
19    def get_position(self):19    def get_position(self):
20        return self.position20        return self.position
2121
22    def set_position(self, position: tuple):22    def set_position(self, position: tuple):
23        self.position = position23        self.position = position
2424
25    @staticmethod25    @staticmethod
26    def dist_between(position1: tuple, position2: tuple):26    def dist_between(position1: tuple, position2: tuple):
27        return math.sqrt((position2[0] - position1[0]) ** 2 + (position2[1] - position1[1]) ** 2)27        return math.sqrt((position2[0] - position1[0]) ** 2 + (position2[1] - position1[1]) ** 2)
2828
2929
30class Kid(Person):30class Kid(Person):
31    CRITICAL_MASS_THRESHOLD = 2031    CRITICAL_MASS_THRESHOLD = 20
3232
33    def __init__(self, position: tuple, initiative: int):33    def __init__(self, position: tuple, initiative: int):
34        self.initiative = initiative34        self.initiative = initiative
35        self.basket = []35        self.basket = []
36        super().__init__(position)36        super().__init__(position)
3737
38    def get_initiative(self):38    def get_initiative(self):
39        return self.initiative39        return self.initiative
4040
41    def add_candy(self, candy: Candy):41    def add_candy(self, candy: Candy):
42        self.basket.append(candy)42        self.basket.append(candy)
4343
44    def is_critical(self):44    def is_critical(self):
45        total_uranium = 045        total_uranium = 0
46        for candy in self.basket:46        for candy in self.basket:
47            total_uranium += candy.get_uranium_quantity()47            total_uranium += candy.get_uranium_quantity()
48        return total_uranium > self.CRITICAL_MASS_THRESHOLD48        return total_uranium > self.CRITICAL_MASS_THRESHOLD
4949
5050
51class Host(Person):51class Host(Person):
52    def __init__(self, position: tuple, candies: list):52    def __init__(self, position: tuple, candies: list):
53        self.basket = list()53        self.basket = list()
54        for candy in candies:54        for candy in candies:
55            self.basket.append(Candy(candy[0], candy[1]))55            self.basket.append(Candy(candy[0], candy[1]))
56        super().__init__(position)56        super().__init__(position)
5757
58    def remove_candy(self, predicate):58    def remove_candy(self, predicate):
59        if self.basket:59        if self.basket:
60            candy = predicate(self.basket)60            candy = predicate(self.basket)
61            self.basket.remove(predicate(self.basket))61            self.basket.remove(predicate(self.basket))
62            return candy62            return candy
63        return None63        return None
6464
6565
66class FluxCapacitor:66class FluxCapacitor:
67    def __init__(self, participants: set):67    def __init__(self, participants: set):
68        self.participants = participants68        self.participants = participants
69        self.hosts = [host for host in participants if isinstance(host, Host)]69        self.hosts = [host for host in participants if isinstance(host, Host)]
70        self.kids = [kid for kid in participants if isinstance(kid, Kid)]70        self.kids = [kid for kid in participants if isinstance(kid, Kid)]
7171
72    def get_victim(self):72    def get_victim(self):
73        hosts = self.hosts73        hosts = self.hosts
74        kids = self.kids74        kids = self.kids
75        kids_visited_hosts = {kid: [] for kid in kids}75        kids_visited_hosts = {kid: [] for kid in kids}
7676
77        while [len(visited_hosts) for visited_hosts in kids_visited_hosts.values()].count(len(hosts)) != len(kids):77        while [len(visited_hosts) for visited_hosts in kids_visited_hosts.values()].count(len(hosts)) != len(kids):
78            host_expected_kids = {host: [] for host in hosts}78            host_expected_kids = {host: [] for host in hosts}
7979
80            # Determine which children will be visiting each host80            # Determine which children will be visiting each host
81            for kid in kids:81            for kid in kids:
82                closest_host = Host(position=(float('inf'), float('inf')), candies=[])82                closest_host = Host(position=(float('inf'), float('inf')), candies=[])
83                for host in hosts:83                for host in hosts:
84                    if host not in kids_visited_hosts[kid]:84                    if host not in kids_visited_hosts[kid]:
n85                        if (distA := Person.dist_between(kid.position, host.position)) < (n85                        if (dist_a := Person.dist_between(kid.position, host.position)) < (
86                                distB := Person.dist_between(kid.position, closest_host.position)):86                                dist_b := Person.dist_between(kid.position, closest_host.position)):
87                            closest_host = host87                            closest_host = host
t88                        elif distA == distB:t88                        elif dist_a == dist_b:
89                            if host.position[0] < closest_host.position[0]:89                            if host.position[0] < closest_host.position[0]:
90                                closest_host = host90                                closest_host = host
91                            elif host.position[0] == closest_host.position[0] and host.position[1] < closest_host.position[1]:91                            elif host.position[0] == closest_host.position[0] and host.position[1] < closest_host.position[1]:
92                                closest_host = host92                                closest_host = host
93                if closest_host.position != (float('inf'), float('inf')):93                if closest_host.position != (float('inf'), float('inf')):
94                    host_expected_kids[closest_host].append(kid)94                    host_expected_kids[closest_host].append(kid)
9595
96            # Sort kids by initiative96            # Sort kids by initiative
97            for kids_list in host_expected_kids.values():97            for kids_list in host_expected_kids.values():
98                if len(kids_list) > 1:98                if len(kids_list) > 1:
99                    kids_list.sort(key=lambda x: x.initiative, reverse=True)99                    kids_list.sort(key=lambda x: x.initiative, reverse=True)
100100
101            # Give candy to kids in defined order101            # Give candy to kids in defined order
102            for host in hosts:102            for host in hosts:
103                # For every kid that wants to visit the host103                # For every kid that wants to visit the host
104                for visiting_kid in host_expected_kids[host]:104                for visiting_kid in host_expected_kids[host]:
105                    # Check if there is any candy left105                    # Check if there is any candy left
106                    visiting_kid.set_position(host.get_position())106                    visiting_kid.set_position(host.get_position())
107                    if host.basket:107                    if host.basket:
108                        # Host removes the candy from their basket and gives it to the kid108                        # Host removes the candy from their basket and gives it to the kid
109                        visiting_kid.add_candy(host.remove_candy(lambda candy_basket: max(candy_basket, key=lambda candy: candy.get_mass())))109                        visiting_kid.add_candy(host.remove_candy(lambda candy_basket: max(candy_basket, key=lambda candy: candy.get_mass())))
110                    # Kid now has visited this host and will never meet them again!110                    # Kid now has visited this host and will never meet them again!
111                    kids_visited_hosts[visiting_kid].append(host)111                    kids_visited_hosts[visiting_kid].append(host)
112112
113            # If there are any dead kids, return them113            # If there are any dead kids, return them
114            if dead_kids := set(kid for kid in kids if kid.is_critical()):114            if dead_kids := set(kid for kid in kids if kid.is_critical()):
115                return dead_kids115                return dead_kids
116116
117        return None117        return None
Legends
Colors
 Added 
Changed
Deleted
Links
(f)irst change
(n)ext change
(t)op

nn1import math
2 
1class Candy:3class Candy:
2    def __init__(self, mass: int, uranium: float):4    def __init__(self, mass: int, uranium: float):
3        self.mass = mass5        self.mass = mass
4        self.uranium = uranium6        self.uranium = uranium
57
6    def get_mass(self):8    def get_mass(self):
7        return self.mass9        return self.mass
810
9    def get_uranium_quantity(self):11    def get_uranium_quantity(self):
10        return self.mass * self.uranium12        return self.mass * self.uranium
1113
1214
13class Person:15class Person:
14    def __init__(self, position: tuple):16    def __init__(self, position: tuple):
15        self.position = position17        self.position = position
1618
17    def get_position(self):19    def get_position(self):
18        return self.position20        return self.position
1921
20    def set_position(self, position: tuple):22    def set_position(self, position: tuple):
21        self.position = position23        self.position = position
2224
nn25    @staticmethod
26    def dist_between(position1: tuple, position2: tuple):
27        return math.sqrt((position2[0] - position1[0]) ** 2 + (position2[1] - position1[1]) ** 2)
28 
2329
24class Kid(Person):30class Kid(Person):
nn31    CRITICAL_MASS_THRESHOLD = 20
32 
25    def __init__(self, position: tuple, initiative: int):33    def __init__(self, position: tuple, initiative: int):
26        self.initiative = initiative34        self.initiative = initiative
27        self.basket = []35        self.basket = []
28        super().__init__(position)36        super().__init__(position)
2937
30    def get_initiative(self):38    def get_initiative(self):
31        return self.initiative39        return self.initiative
3240
33    def add_candy(self, candy: Candy):41    def add_candy(self, candy: Candy):
34        self.basket.append(candy)42        self.basket.append(candy)
3543
36    def is_critical(self):44    def is_critical(self):
37        total_uranium = 045        total_uranium = 0
38        for candy in self.basket:46        for candy in self.basket:
n39            total_uranium += candy.mass * candy.uraniumn47            total_uranium += candy.get_uranium_quantity()
40        return total_uranium > 2048        return total_uranium > self.CRITICAL_MASS_THRESHOLD
4149
4250
43class Host(Person):51class Host(Person):
44    def __init__(self, position: tuple, candies: list):52    def __init__(self, position: tuple, candies: list):
45        self.basket = list()53        self.basket = list()
46        for candy in candies:54        for candy in candies:
n47            self.basket.append(candy)n55            self.basket.append(Candy(candy[0], candy[1]))
48        super().__init__(position)56        super().__init__(position)
4957
50    def remove_candy(self, predicate):58    def remove_candy(self, predicate):
n51        if self.basket.empty():n59        if self.basket:
52            return None
53        candy = predicate(self.basket)60            candy = predicate(self.basket)
54        self.basket.remove(predicate(self.basket))61            self.basket.remove(predicate(self.basket))
55        return candy62            return candy
56 63        return None
57 
58def dist_between(position1: tuple, position2: tuple):
59    return sqrt((position2[0] - position1[0]) ** 2 + (position2[1] - position1[1]) ** 2)
6064
6165
62class FluxCapacitor:66class FluxCapacitor:
63    def __init__(self, participants: set):67    def __init__(self, participants: set):
64        self.participants = participants68        self.participants = participants
nn69        self.hosts = [host for host in participants if isinstance(host, Host)]
70        self.kids = [kid for kid in participants if isinstance(kid, Kid)]
6571
66    def get_victim(self):72    def get_victim(self):
n67        hosts = set(host for host in self.participants if isinstance(host, Host) and len(host.basket) > 0)n73        hosts = self.hosts
68        kids = set(kid for kid in self.participants if isinstance(kid, Kid))74        kids = self.kids
69        kids_visited_hosts = {kid: () for kid in kids}75        kids_visited_hosts = {kid: [] for kid in kids}
7076
n71        while len(kids) > 0 and len(hosts) > 0:n77        while [len(visited_hosts) for visited_hosts in kids_visited_hosts.values()].count(len(hosts)) != len(kids):
72            host_expected_kids = {host: () for host in hosts}78            host_expected_kids = {host: [] for host in hosts}
7379
74            # Determine which children will be visiting each host80            # Determine which children will be visiting each host
75            for kid in kids:81            for kid in kids:
n76                closes_host: Host = Host(position=(int('inf'), int('inf')), candies=[])n82                closest_host = Host(position=(float('inf'), float('inf')), candies=[])
77                for host in hosts:83                for host in hosts:
78                    if host not in kids_visited_hosts[kid]:84                    if host not in kids_visited_hosts[kid]:
n79                        if (distA := dist_between(kid.position, host.position)) < (n85                        if (distA := Person.dist_between(kid.position, host.position)) < (
80                                distB := dist_between(kid.position, closes_host.position)):86                                distB := Person.dist_between(kid.position, closest_host.position)):
81                            closes_host = host87                            closest_host = host
82                        elif distA == distB:88                        elif distA == distB:
n83                            if host.position[0] < closes_host.position[0]:n89                            if host.position[0] < closest_host.position[0]:
84                                closes_host = host90                                closest_host = host
85                            elif host.position[0] == closes_host.position[0]:91                            elif host.position[0] == closest_host.position[0] and host.position[1] < closest_host.position[1]:
86                                if host.position[1] < closes_host.position[1]:
87                                    closes_host = host92                                closest_host = host
88                if closes_host.position != (int('inf'), int('inf')):93                if closest_host.position != (float('inf'), float('inf')):
89                    host_expected_kids[closes_host].add(kid)94                    host_expected_kids[closest_host].append(kid)
9095
91            # Sort kids by initiative96            # Sort kids by initiative
n92            for kids_list in host_expected_kids:n97            for kids_list in host_expected_kids.values():
93                if len(kids_list) > 1:98                if len(kids_list) > 1:
94                    kids_list.sort(key=lambda x: x.initiative, reverse=True)99                    kids_list.sort(key=lambda x: x.initiative, reverse=True)
n95 n
96            # Sort host's candies in descending order
97            for host in hosts:
98                host.basket.sort(key=lambda x: x.mass, reverse=True)
99100
100            # Give candy to kids in defined order101            # Give candy to kids in defined order
101            for host in hosts:102            for host in hosts:
102                # For every kid that wants to visit the host103                # For every kid that wants to visit the host
103                for visiting_kid in host_expected_kids[host]:104                for visiting_kid in host_expected_kids[host]:
104                    # Check if there is any candy left105                    # Check if there is any candy left
nn106                    visiting_kid.set_position(host.get_position())
105                    if len(host.basket) == 0:107                    if host.basket:
106                        # Kid does a trick to the owner, transforming them into a frog or smth
107                        pass
108                    else:
109                        # Host removes the candy from their basket and gives it to the kid108                        # Host removes the candy from their basket and gives it to the kid
n110                        visiting_kid.add_candy(host.remove_candy(host.basket[0]))n109                        visiting_kid.add_candy(host.remove_candy(lambda candy_basket: max(candy_basket, key=lambda candy: candy.get_mass())))
111                    # Kid now has visited this host and will never meet them again!110                    # Kid now has visited this host and will never meet them again!
n112                    kids_visited_hosts[visiting_kid].add(host)n111                    kids_visited_hosts[visiting_kid].append(host)
113112
114            # If there are any dead kids, return them113            # If there are any dead kids, return them
n115            if len(dead_kids := set(kid for kid in kids if kid.is_critical())) > 0:n114            if dead_kids := set(kid for kid in kids if kid.is_critical()):
116                return dead_kids115                return dead_kids
117116
t118            # Update kids and hosts to continue if there were no victimst117        return None
119            kids = [kid for kid in kids if not kid.is_critical()]
120            hosts = set(host for host in self.participants if isinstance(host, Host) and len(host.basket) > 0)
Legends
Colors
 Added 
Changed
Deleted
Links
(f)irst change
(n)ext change
(t)op

f1class Candy:f1class Candy:
2    def __init__(self, mass: int, uranium: float):2    def __init__(self, mass: int, uranium: float):
3        self.mass = mass3        self.mass = mass
4        self.uranium = uranium4        self.uranium = uranium
55
6    def get_mass(self):6    def get_mass(self):
7        return self.mass7        return self.mass
88
9    def get_uranium_quantity(self):9    def get_uranium_quantity(self):
10        return self.mass * self.uranium10        return self.mass * self.uranium
1111
1212
13class Person:13class Person:
14    def __init__(self, position: tuple):14    def __init__(self, position: tuple):
15        self.position = position15        self.position = position
1616
17    def get_position(self):17    def get_position(self):
18        return self.position18        return self.position
1919
20    def set_position(self, position: tuple):20    def set_position(self, position: tuple):
21        self.position = position21        self.position = position
2222
2323
24class Kid(Person):24class Kid(Person):
25    def __init__(self, position: tuple, initiative: int):25    def __init__(self, position: tuple, initiative: int):
26        self.initiative = initiative26        self.initiative = initiative
27        self.basket = []27        self.basket = []
28        super().__init__(position)28        super().__init__(position)
2929
30    def get_initiative(self):30    def get_initiative(self):
31        return self.initiative31        return self.initiative
3232
33    def add_candy(self, candy: Candy):33    def add_candy(self, candy: Candy):
34        self.basket.append(candy)34        self.basket.append(candy)
3535
36    def is_critical(self):36    def is_critical(self):
37        total_uranium = 037        total_uranium = 0
38        for candy in self.basket:38        for candy in self.basket:
39            total_uranium += candy.mass * candy.uranium39            total_uranium += candy.mass * candy.uranium
40        return total_uranium > 2040        return total_uranium > 20
4141
4242
43class Host(Person):43class Host(Person):
44    def __init__(self, position: tuple, candies: list):44    def __init__(self, position: tuple, candies: list):
45        self.basket = list()45        self.basket = list()
46        for candy in candies:46        for candy in candies:
47            self.basket.append(candy)47            self.basket.append(candy)
48        super().__init__(position)48        super().__init__(position)
4949
50    def remove_candy(self, predicate):50    def remove_candy(self, predicate):
51        if self.basket.empty():51        if self.basket.empty():
52            return None52            return None
53        candy = predicate(self.basket)53        candy = predicate(self.basket)
54        self.basket.remove(predicate(self.basket))54        self.basket.remove(predicate(self.basket))
55        return candy55        return candy
5656
5757
58def dist_between(position1: tuple, position2: tuple):58def dist_between(position1: tuple, position2: tuple):
59    return sqrt((position2[0] - position1[0]) ** 2 + (position2[1] - position1[1]) ** 2)59    return sqrt((position2[0] - position1[0]) ** 2 + (position2[1] - position1[1]) ** 2)
6060
6161
62class FluxCapacitor:62class FluxCapacitor:
63    def __init__(self, participants: set):63    def __init__(self, participants: set):
64        self.participants = participants64        self.participants = participants
6565
66    def get_victim(self):66    def get_victim(self):
67        hosts = set(host for host in self.participants if isinstance(host, Host) and len(host.basket) > 0)67        hosts = set(host for host in self.participants if isinstance(host, Host) and len(host.basket) > 0)
68        kids = set(kid for kid in self.participants if isinstance(kid, Kid))68        kids = set(kid for kid in self.participants if isinstance(kid, Kid))
69        kids_visited_hosts = {kid: () for kid in kids}69        kids_visited_hosts = {kid: () for kid in kids}
7070
71        while len(kids) > 0 and len(hosts) > 0:71        while len(kids) > 0 and len(hosts) > 0:
72            host_expected_kids = {host: () for host in hosts}72            host_expected_kids = {host: () for host in hosts}
7373
74            # Determine which children will be visiting each host74            # Determine which children will be visiting each host
75            for kid in kids:75            for kid in kids:
76                closes_host: Host = Host(position=(int('inf'), int('inf')), candies=[])76                closes_host: Host = Host(position=(int('inf'), int('inf')), candies=[])
77                for host in hosts:77                for host in hosts:
78                    if host not in kids_visited_hosts[kid]:78                    if host not in kids_visited_hosts[kid]:
79                        if (distA := dist_between(kid.position, host.position)) < (79                        if (distA := dist_between(kid.position, host.position)) < (
80                                distB := dist_between(kid.position, closes_host.position)):80                                distB := dist_between(kid.position, closes_host.position)):
81                            closes_host = host81                            closes_host = host
82                        elif distA == distB:82                        elif distA == distB:
83                            if host.position[0] < closes_host.position[0]:83                            if host.position[0] < closes_host.position[0]:
84                                closes_host = host84                                closes_host = host
85                            elif host.position[0] == closes_host.position[0]:85                            elif host.position[0] == closes_host.position[0]:
86                                if host.position[1] < closes_host.position[1]:86                                if host.position[1] < closes_host.position[1]:
87                                    closes_host = host87                                    closes_host = host
88                if closes_host.position != (int('inf'), int('inf')):88                if closes_host.position != (int('inf'), int('inf')):
89                    host_expected_kids[closes_host].add(kid)89                    host_expected_kids[closes_host].add(kid)
9090
91            # Sort kids by initiative91            # Sort kids by initiative
92            for kids_list in host_expected_kids:92            for kids_list in host_expected_kids:
93                if len(kids_list) > 1:93                if len(kids_list) > 1:
94                    kids_list.sort(key=lambda x: x.initiative, reverse=True)94                    kids_list.sort(key=lambda x: x.initiative, reverse=True)
9595
96            # Sort host's candies in descending order96            # Sort host's candies in descending order
97            for host in hosts:97            for host in hosts:
98                host.basket.sort(key=lambda x: x.mass, reverse=True)98                host.basket.sort(key=lambda x: x.mass, reverse=True)
9999
100            # Give candy to kids in defined order100            # Give candy to kids in defined order
101            for host in hosts:101            for host in hosts:
102                # For every kid that wants to visit the host102                # For every kid that wants to visit the host
103                for visiting_kid in host_expected_kids[host]:103                for visiting_kid in host_expected_kids[host]:
104                    # Check if there is any candy left104                    # Check if there is any candy left
105                    if len(host.basket) == 0:105                    if len(host.basket) == 0:
106                        # Kid does a trick to the owner, transforming them into a frog or smth106                        # Kid does a trick to the owner, transforming them into a frog or smth
107                        pass107                        pass
108                    else:108                    else:
109                        # Host removes the candy from their basket and gives it to the kid109                        # Host removes the candy from their basket and gives it to the kid
110                        visiting_kid.add_candy(host.remove_candy(host.basket[0]))110                        visiting_kid.add_candy(host.remove_candy(host.basket[0]))
111                    # Kid now has visited this host and will never meet them again!111                    # Kid now has visited this host and will never meet them again!
112                    kids_visited_hosts[visiting_kid].add(host)112                    kids_visited_hosts[visiting_kid].add(host)
113113
114            # If there are any dead kids, return them114            # If there are any dead kids, return them
115            if len(dead_kids := set(kid for kid in kids if kid.is_critical())) > 0:115            if len(dead_kids := set(kid for kid in kids if kid.is_critical())) > 0:
116                return dead_kids116                return dead_kids
117117
118            # Update kids and hosts to continue if there were no victims118            # Update kids and hosts to continue if there were no victims
119            kids = [kid for kid in kids if not kid.is_critical()]119            kids = [kid for kid in kids if not kid.is_critical()]
120            hosts = set(host for host in self.participants if isinstance(host, Host) and len(host.basket) > 0)120            hosts = set(host for host in self.participants if isinstance(host, Host) and len(host.basket) > 0)
t121 t
122 
123if __name__ == "__main__":
124    kid = Kid((1, 1), 1)
Legends
Colors
 Added 
Changed
Deleted
Links
(f)irst change
(n)ext change
(t)op

f1class Candy:f1class Candy:
2    def __init__(self, mass: int, uranium: float):2    def __init__(self, mass: int, uranium: float):
3        self.mass = mass3        self.mass = mass
4        self.uranium = uranium4        self.uranium = uranium
55
6    def get_mass(self):6    def get_mass(self):
7        return self.mass7        return self.mass
88
9    def get_uranium_quantity(self):9    def get_uranium_quantity(self):
10        return self.mass * self.uranium10        return self.mass * self.uranium
1111
1212
13class Person:13class Person:
14    def __init__(self, position: tuple):14    def __init__(self, position: tuple):
15        self.position = position15        self.position = position
1616
17    def get_position(self):17    def get_position(self):
18        return self.position18        return self.position
1919
20    def set_position(self, position: tuple):20    def set_position(self, position: tuple):
21        self.position = position21        self.position = position
2222
2323
24class Kid(Person):24class Kid(Person):
n25    def __int__(self, position: tuple, initiative: int):n25    def __init__(self, position: tuple, initiative: int):
26        self.initiative = initiative26        self.initiative = initiative
27        self.basket = []27        self.basket = []
28        super().__init__(position)28        super().__init__(position)
2929
30    def get_initiative(self):30    def get_initiative(self):
31        return self.initiative31        return self.initiative
3232
33    def add_candy(self, candy: Candy):33    def add_candy(self, candy: Candy):
34        self.basket.append(candy)34        self.basket.append(candy)
3535
36    def is_critical(self):36    def is_critical(self):
37        total_uranium = 037        total_uranium = 0
38        for candy in self.basket:38        for candy in self.basket:
39            total_uranium += candy.mass * candy.uranium39            total_uranium += candy.mass * candy.uranium
40        return total_uranium > 2040        return total_uranium > 20
4141
4242
43class Host(Person):43class Host(Person):
44    def __init__(self, position: tuple, candies: list):44    def __init__(self, position: tuple, candies: list):
45        self.basket = list()45        self.basket = list()
46        for candy in candies:46        for candy in candies:
47            self.basket.append(candy)47            self.basket.append(candy)
48        super().__init__(position)48        super().__init__(position)
4949
50    def remove_candy(self, predicate):50    def remove_candy(self, predicate):
51        if self.basket.empty():51        if self.basket.empty():
52            return None52            return None
53        candy = predicate(self.basket)53        candy = predicate(self.basket)
54        self.basket.remove(predicate(self.basket))54        self.basket.remove(predicate(self.basket))
55        return candy55        return candy
5656
5757
58def dist_between(position1: tuple, position2: tuple):58def dist_between(position1: tuple, position2: tuple):
59    return sqrt((position2[0] - position1[0]) ** 2 + (position2[1] - position1[1]) ** 2)59    return sqrt((position2[0] - position1[0]) ** 2 + (position2[1] - position1[1]) ** 2)
6060
6161
62class FluxCapacitor:62class FluxCapacitor:
63    def __init__(self, participants: set):63    def __init__(self, participants: set):
64        self.participants = participants64        self.participants = participants
6565
66    def get_victim(self):66    def get_victim(self):
67        hosts = set(host for host in self.participants if isinstance(host, Host) and len(host.basket) > 0)67        hosts = set(host for host in self.participants if isinstance(host, Host) and len(host.basket) > 0)
68        kids = set(kid for kid in self.participants if isinstance(kid, Kid))68        kids = set(kid for kid in self.participants if isinstance(kid, Kid))
69        kids_visited_hosts = {kid: () for kid in kids}69        kids_visited_hosts = {kid: () for kid in kids}
7070
71        while len(kids) > 0 and len(hosts) > 0:71        while len(kids) > 0 and len(hosts) > 0:
72            host_expected_kids = {host: () for host in hosts}72            host_expected_kids = {host: () for host in hosts}
7373
74            # Determine which children will be visiting each host74            # Determine which children will be visiting each host
75            for kid in kids:75            for kid in kids:
76                closes_host: Host = Host(position=(int('inf'), int('inf')), candies=[])76                closes_host: Host = Host(position=(int('inf'), int('inf')), candies=[])
77                for host in hosts:77                for host in hosts:
78                    if host not in kids_visited_hosts[kid]:78                    if host not in kids_visited_hosts[kid]:
79                        if (distA := dist_between(kid.position, host.position)) < (79                        if (distA := dist_between(kid.position, host.position)) < (
80                                distB := dist_between(kid.position, closes_host.position)):80                                distB := dist_between(kid.position, closes_host.position)):
81                            closes_host = host81                            closes_host = host
82                        elif distA == distB:82                        elif distA == distB:
83                            if host.position[0] < closes_host.position[0]:83                            if host.position[0] < closes_host.position[0]:
84                                closes_host = host84                                closes_host = host
85                            elif host.position[0] == closes_host.position[0]:85                            elif host.position[0] == closes_host.position[0]:
86                                if host.position[1] < closes_host.position[1]:86                                if host.position[1] < closes_host.position[1]:
87                                    closes_host = host87                                    closes_host = host
88                if closes_host.position != (int('inf'), int('inf')):88                if closes_host.position != (int('inf'), int('inf')):
89                    host_expected_kids[closes_host].add(kid)89                    host_expected_kids[closes_host].add(kid)
9090
91            # Sort kids by initiative91            # Sort kids by initiative
92            for kids_list in host_expected_kids:92            for kids_list in host_expected_kids:
93                if len(kids_list) > 1:93                if len(kids_list) > 1:
94                    kids_list.sort(key=lambda x: x.initiative, reverse=True)94                    kids_list.sort(key=lambda x: x.initiative, reverse=True)
9595
96            # Sort host's candies in descending order96            # Sort host's candies in descending order
97            for host in hosts:97            for host in hosts:
98                host.basket.sort(key=lambda x: x.mass, reverse=True)98                host.basket.sort(key=lambda x: x.mass, reverse=True)
9999
100            # Give candy to kids in defined order100            # Give candy to kids in defined order
101            for host in hosts:101            for host in hosts:
102                # For every kid that wants to visit the host102                # For every kid that wants to visit the host
103                for visiting_kid in host_expected_kids[host]:103                for visiting_kid in host_expected_kids[host]:
104                    # Check if there is any candy left104                    # Check if there is any candy left
105                    if len(host.basket) == 0:105                    if len(host.basket) == 0:
106                        # Kid does a trick to the owner, transforming them into a frog or smth106                        # Kid does a trick to the owner, transforming them into a frog or smth
107                        pass107                        pass
108                    else:108                    else:
109                        # Host removes the candy from their basket and gives it to the kid109                        # Host removes the candy from their basket and gives it to the kid
110                        visiting_kid.add_candy(host.remove_candy(host.basket[0]))110                        visiting_kid.add_candy(host.remove_candy(host.basket[0]))
111                    # Kid now has visited this host and will never meet them again!111                    # Kid now has visited this host and will never meet them again!
112                    kids_visited_hosts[visiting_kid].add(host)112                    kids_visited_hosts[visiting_kid].add(host)
113113
114            # If there are any dead kids, return them114            # If there are any dead kids, return them
115            if len(dead_kids := set(kid for kid in kids if kid.is_critical())) > 0:115            if len(dead_kids := set(kid for kid in kids if kid.is_critical())) > 0:
116                return dead_kids116                return dead_kids
117117
118            # Update kids and hosts to continue if there were no victims118            # Update kids and hosts to continue if there were no victims
119            kids = [kid for kid in kids if not kid.is_critical()]119            kids = [kid for kid in kids if not kid.is_critical()]
120            hosts = set(host for host in self.participants if isinstance(host, Host) and len(host.basket) > 0)120            hosts = set(host for host in self.participants if isinstance(host, Host) and len(host.basket) > 0)
tt121 
122 
123if __name__ == "__main__":
124    kid = Kid((1, 1), 1)
Legends
Colors
 Added 
Changed
Deleted
Links
(f)irst change
(n)ext change
(t)op

t1class Candy:t1class Candy:
2    def __init__(self, mass: int, uranium: float):2    def __init__(self, mass: int, uranium: float):
3        self.mass = mass3        self.mass = mass
4        self.uranium = uranium4        self.uranium = uranium
55
6    def get_mass(self):6    def get_mass(self):
7        return self.mass7        return self.mass
88
9    def get_uranium_quantity(self):9    def get_uranium_quantity(self):
10        return self.mass * self.uranium10        return self.mass * self.uranium
1111
1212
13class Person:13class Person:
14    def __init__(self, position: tuple):14    def __init__(self, position: tuple):
15        self.position = position15        self.position = position
1616
17    def get_position(self):17    def get_position(self):
18        return self.position18        return self.position
1919
20    def set_position(self, position: tuple):20    def set_position(self, position: tuple):
21        self.position = position21        self.position = position
2222
2323
24class Kid(Person):24class Kid(Person):
25    def __int__(self, position: tuple, initiative: int):25    def __int__(self, position: tuple, initiative: int):
26        self.initiative = initiative26        self.initiative = initiative
27        self.basket = []27        self.basket = []
28        super().__init__(position)28        super().__init__(position)
2929
30    def get_initiative(self):30    def get_initiative(self):
31        return self.initiative31        return self.initiative
3232
33    def add_candy(self, candy: Candy):33    def add_candy(self, candy: Candy):
34        self.basket.append(candy)34        self.basket.append(candy)
3535
36    def is_critical(self):36    def is_critical(self):
37        total_uranium = 037        total_uranium = 0
38        for candy in self.basket:38        for candy in self.basket:
39            total_uranium += candy.mass * candy.uranium39            total_uranium += candy.mass * candy.uranium
40        return total_uranium > 2040        return total_uranium > 20
4141
4242
43class Host(Person):43class Host(Person):
44    def __init__(self, position: tuple, candies: list):44    def __init__(self, position: tuple, candies: list):
45        self.basket = list()45        self.basket = list()
46        for candy in candies:46        for candy in candies:
47            self.basket.append(candy)47            self.basket.append(candy)
48        super().__init__(position)48        super().__init__(position)
4949
50    def remove_candy(self, predicate):50    def remove_candy(self, predicate):
51        if self.basket.empty():51        if self.basket.empty():
52            return None52            return None
53        candy = predicate(self.basket)53        candy = predicate(self.basket)
54        self.basket.remove(predicate(self.basket))54        self.basket.remove(predicate(self.basket))
55        return candy55        return candy
5656
5757
58def dist_between(position1: tuple, position2: tuple):58def dist_between(position1: tuple, position2: tuple):
59    return sqrt((position2[0] - position1[0]) ** 2 + (position2[1] - position1[1]) ** 2)59    return sqrt((position2[0] - position1[0]) ** 2 + (position2[1] - position1[1]) ** 2)
6060
6161
62class FluxCapacitor:62class FluxCapacitor:
63    def __init__(self, participants: set):63    def __init__(self, participants: set):
64        self.participants = participants64        self.participants = participants
6565
66    def get_victim(self):66    def get_victim(self):
67        hosts = set(host for host in self.participants if isinstance(host, Host) and len(host.basket) > 0)67        hosts = set(host for host in self.participants if isinstance(host, Host) and len(host.basket) > 0)
68        kids = set(kid for kid in self.participants if isinstance(kid, Kid))68        kids = set(kid for kid in self.participants if isinstance(kid, Kid))
69        kids_visited_hosts = {kid: () for kid in kids}69        kids_visited_hosts = {kid: () for kid in kids}
7070
71        while len(kids) > 0 and len(hosts) > 0:71        while len(kids) > 0 and len(hosts) > 0:
72            host_expected_kids = {host: () for host in hosts}72            host_expected_kids = {host: () for host in hosts}
7373
74            # Determine which children will be visiting each host74            # Determine which children will be visiting each host
75            for kid in kids:75            for kid in kids:
76                closes_host: Host = Host(position=(int('inf'), int('inf')), candies=[])76                closes_host: Host = Host(position=(int('inf'), int('inf')), candies=[])
77                for host in hosts:77                for host in hosts:
78                    if host not in kids_visited_hosts[kid]:78                    if host not in kids_visited_hosts[kid]:
79                        if (distA := dist_between(kid.position, host.position)) < (79                        if (distA := dist_between(kid.position, host.position)) < (
80                                distB := dist_between(kid.position, closes_host.position)):80                                distB := dist_between(kid.position, closes_host.position)):
81                            closes_host = host81                            closes_host = host
82                        elif distA == distB:82                        elif distA == distB:
83                            if host.position[0] < closes_host.position[0]:83                            if host.position[0] < closes_host.position[0]:
84                                closes_host = host84                                closes_host = host
85                            elif host.position[0] == closes_host.position[0]:85                            elif host.position[0] == closes_host.position[0]:
86                                if host.position[1] < closes_host.position[1]:86                                if host.position[1] < closes_host.position[1]:
87                                    closes_host = host87                                    closes_host = host
88                if closes_host.position != (int('inf'), int('inf')):88                if closes_host.position != (int('inf'), int('inf')):
89                    host_expected_kids[closes_host].add(kid)89                    host_expected_kids[closes_host].add(kid)
9090
91            # Sort kids by initiative91            # Sort kids by initiative
92            for kids_list in host_expected_kids:92            for kids_list in host_expected_kids:
93                if len(kids_list) > 1:93                if len(kids_list) > 1:
94                    kids_list.sort(key=lambda x: x.initiative, reverse=True)94                    kids_list.sort(key=lambda x: x.initiative, reverse=True)
9595
96            # Sort host's candies in descending order96            # Sort host's candies in descending order
97            for host in hosts:97            for host in hosts:
98                host.basket.sort(key=lambda x: x.mass, reverse=True)98                host.basket.sort(key=lambda x: x.mass, reverse=True)
9999
100            # Give candy to kids in defined order100            # Give candy to kids in defined order
101            for host in hosts:101            for host in hosts:
102                # For every kid that wants to visit the host102                # For every kid that wants to visit the host
103                for visiting_kid in host_expected_kids[host]:103                for visiting_kid in host_expected_kids[host]:
104                    # Check if there is any candy left104                    # Check if there is any candy left
105                    if len(host.basket) == 0:105                    if len(host.basket) == 0:
106                        # Kid does a trick to the owner, transforming them into a frog or smth106                        # Kid does a trick to the owner, transforming them into a frog or smth
107                        pass107                        pass
108                    else:108                    else:
109                        # Host removes the candy from their basket and gives it to the kid109                        # Host removes the candy from their basket and gives it to the kid
110                        visiting_kid.add_candy(host.remove_candy(host.basket[0]))110                        visiting_kid.add_candy(host.remove_candy(host.basket[0]))
111                    # Kid now has visited this host and will never meet them again!111                    # Kid now has visited this host and will never meet them again!
112                    kids_visited_hosts[visiting_kid].add(host)112                    kids_visited_hosts[visiting_kid].add(host)
113113
114            # If there are any dead kids, return them114            # If there are any dead kids, return them
115            if len(dead_kids := set(kid for kid in kids if kid.is_critical())) > 0:115            if len(dead_kids := set(kid for kid in kids if kid.is_critical())) > 0:
116                return dead_kids116                return dead_kids
117117
118            # Update kids and hosts to continue if there were no victims118            # Update kids and hosts to continue if there were no victims
119            kids = [kid for kid in kids if not kid.is_critical()]119            kids = [kid for kid in kids if not kid.is_critical()]
120            hosts = set(host for host in self.participants if isinstance(host, Host) and len(host.basket) > 0)120            hosts = set(host for host in self.participants if isinstance(host, Host) and len(host.basket) > 0)
Legends
Colors
 Added 
Changed
Deleted
Links
(f)irst change
(n)ext change
(t)op