1class Egg:
2 def __init__(self):
3 self.total_coverage = 0
4 self.colors = list()
5 self.tournament = None
6 self.name = None
7
8 def add_tournament(self, tournament):
9 if self.tournament is not None and self.tournament != tournament:
10 raise ValueError("An egg cannot participate in multiple tournaments")
11 self.tournament = tournament
12
13 def paint(self, *duos):
14 total = sum(percentage for _, percentage in duos)
15
16 if self.total_coverage + total > 100:
17 raise ValueError("Total coverage cannot exceed 100%")
18
19 for color, percentage in duos:
20 self.colors.append((color.lower(), percentage))
21
22 self.total_coverage += total
23
24 def __mul__(self, other_egg):
25 total_coverage_now_self = 0
26 colors_self = list()
27 for color1, percentage1 in self.colors:
28 total_coverage_now_self += percentage1
29 if total_coverage_now_self >= 50:
30 colors_self.append((color1, percentage1 - (total_coverage_now_self - 50)))
31 break
32 else:
33 colors_self.append((color1, percentage1))
34
35 total_coverage_now_other = 0
36 colors_other = list()
37 for color2, percentage2 in other_egg.colors:
38 total_coverage_now_other += percentage2
39 if total_coverage_now_other >= 50:
40 colors_other.append((color2, percentage2 - (total_coverage_now_other - 50)))
41 break
42 else:
43 colors_other.append((color2, percentage2))
44
45 final_sum_self = 0
46 for color, percentage in colors_self:
47 r = int(color[0:2], 16)
48 g = int(color[2:4], 16)
49 b = int(color[4:6], 16)
50
51 value = r + g + b
52 final_sum_self += value * percentage
53
54 final_sum_other = 0
55 for color, percentage in colors_other:
56 r = int(color[0:2], 16)
57 g = int(color[2:4], 16)
58 b = int(color[4:6], 16)
59
60 value = r + g + b
61 final_sum_other += value * percentage
62
63 if final_sum_self > final_sum_other:
64 self.tournament.leaderboard[self.name] = self.tournament.leaderboard.get(self.name, 0) + 1
65 self.tournament.battle_history[(self, other_egg, "top")] = self
66 return self
67 elif final_sum_self < final_sum_other:
68 other_egg.tournament.leaderboard[other_egg.name] = other_egg.tournament.leaderboard.get(other_egg.name, 0) + 1
69 self.tournament.battle_history[(self, other_egg, "top")] = other_egg
70 return other_egg
71
72 def __matmul__(self, other_egg):
73 total_coverage_now_self = 0
74 colors_self = list()
75 for color1, percentage1 in reversed(self.colors):
76 total_coverage_now_self += percentage1
77 if total_coverage_now_self >= 50:
78 colors_self.append((color1, percentage1 - (total_coverage_now_self - 50)))
79 break
80 else:
81 colors_self.append((color1, percentage1))
82
83 total_coverage_now_other = 0
84 colors_other = list()
85 for color2, percentage2 in reversed(other_egg.colors):
86 total_coverage_now_other += percentage2
87 if total_coverage_now_other >= 50:
88 colors_other.append((color2, percentage2 - (total_coverage_now_other - 50)))
89 break
90 else:
91 colors_other.append((color2, percentage2))
92
93 final_sum_self = 0
94 for color, percentage in colors_self:
95 r = int(color[0:2], 16)
96 g = int(color[2:4], 16)
97 b = int(color[4:6], 16)
98
99 value = r + g + b
100 final_sum_self += value * percentage
101
102 final_sum_other = 0
103 for color, percentage in colors_other:
104 r = int(color[0:2], 16)
105 g = int(color[2:4], 16)
106 b = int(color[4:6], 16)
107
108 value = r + g + b
109 final_sum_other += value * percentage
110
111 if final_sum_self > final_sum_other:
112 self.tournament.leaderboard[self.name] = self.tournament.leaderboard.get(self.name, 0) + 1
113 self.tournament.battle_history[(self, other_egg, "bottom")] = self
114 return self
115 elif final_sum_self < final_sum_other:
116 other_egg.tournament.leaderboard[other_egg.name] = other_egg.tournament.leaderboard.get(other_egg.name, 0) + 1
117 self.tournament.battle_history[(self, other_egg, "bottom")] = other_egg
118 return other_egg
119
120
121class EggTournament:
122 def __init__(self):
123 self.leaderboard = dict()
124 self.battle_history = dict()
125 self.eggs_by_name = {}
126
127 def register(self, egg, name_):
128 if not isinstance(egg, Egg):
129 raise ValueError("Only Egg instances can be registered")
130
131 for name, _ in self.leaderboard.items():
132 if name == name_:
133 raise ValueError(f"Egg with name {name_} has already been registered")
134
135 if not name_.isidentifier():
136 raise ValueError("Invalid registration name")
137
138 if egg.name in self.leaderboard or egg.tournament is not None:
139 raise ValueError("An egg cannot be registered in multiple tournaments")
140
141 self.leaderboard[name_] = 0
142 egg.name = name_
143 egg.add_tournament(self)
144 self.eggs_by_name[name_] = egg
145
146 def __getitem__(self, key):
147 if isinstance(key, tuple):
148 egg1, egg2, side = key
149 elif isinstance(key, slice):
150 egg1 = key.start
151 egg2 = key.stop
152 side = key.step
153 else:
154 raise KeyError("Invalid key man")
155
156 found1 = False
157 found2 = False
158
159 for egg_name, _ in self.leaderboard.items():
160 if egg_name == egg1.name:
161 found1 = True
162 if egg_name == egg2.name:
163 found2 = True
164
165 if not found1 or not found2:
166 raise KeyError("One or both eggs not found in the tournament")
167
168 if side == "top":
169 result = egg1.tournament.battle_history.get((egg1, egg2, "top")) or egg2.tournament.battle_history.get((egg2, egg1, "top"))
170 if result is None:
171 raise KeyError("No match found for the given eggs and side")
172 elif side == "bottom":
173 result = egg1.tournament.battle_history.get((egg1, egg2, "bottom")) or egg2.tournament.battle_history.get((egg2, egg1, "bottom"))
174 if result is None:
175 raise KeyError("No match found for the given eggs and side")
176 else:
177 raise ValueError("Invalid side. Use 'top' or 'bottom'.")
178 return result
179
180 def __rmatmul__(self, idx):
181 leaderboard_sorted = sorted(self.leaderboard.items(), key=lambda x: x[1], reverse=True)
182
183 unique_scores = []
184 for _, score in leaderboard_sorted:
185 if score not in unique_scores:
186 unique_scores.append(score)
187
188 if idx < 1 or idx > len(unique_scores):
189 raise IndexError("Index out of range")
190
191 target_score = unique_scores[idx - 1]
192 result = []
193 for egg_name, score in leaderboard_sorted:
194 if score == target_score:
195 result.append(self.eggs_by_name[egg_name])
196
197 return set(result)
198
199 def __getattr__(self, name):
200 if name not in self.leaderboard:
201 raise AttributeError("Apologies, there is no such egg registered")
202
203 scores = sorted(self.leaderboard.values(), reverse=True)
204
205 unique_scores = []
206 for score in scores:
207 if score not in unique_scores:
208 unique_scores.append(score)
209
210 return {"position": unique_scores.index(self.leaderboard[name]) + 1, "victories": self.leaderboard[name]}
211
212 def __contains__(self, egg):
213 return egg.name in self.leaderboard
214
EEEEEEEEEEEEEE...EEEEFE.FE..E...........FF....
======================================================================
ERROR: test_bottom_collision_returns_egg_with_greater_bottom_strength (test.TestEgg.test_bottom_collision_returns_egg_with_greater_bottom_strength)
A bottom collision should return the egg with the greater bottom strength.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/test.py", line 177, in test_bottom_collision_returns_egg_with_greater_bottom_strength
self.assertIs(stronger_egg @ weaker_egg, stronger_egg)
~~~~~~~~~~~~~^~~~~~~~~~~~
File "/tmp/solution.py", line 112, in __matmul__
self.tournament.leaderboard[self.name] = self.tournament.leaderboard.get(self.name, 0) + 1
^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'leaderboard'
======================================================================
ERROR: test_breaking_one_side_does_not_prevent_using_the_other_side (test.TestEgg.test_breaking_one_side_does_not_prevent_using_the_other_side)
Breaking one side of an egg should not prevent using the other side.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/test.py", line 287, in test_breaking_one_side_does_not_prevent_using_the_other_side
self.assertIs(first_egg * second_egg, second_egg)
~~~~~~~~~~^~~~~~~~~~~~
File "/tmp/solution.py", line 68, in __mul__
other_egg.tournament.leaderboard[other_egg.name] = other_egg.tournament.leaderboard.get(other_egg.name, 0) + 1
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'leaderboard'
======================================================================
ERROR: test_broken_side_raises_type_error_regardless_of_operand_position (test.TestEgg.test_broken_side_raises_type_error_regardless_of_operand_position)
Using a broken side in a collision should raise a TypeError regardless of operand position.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/test.py", line 257, in test_broken_side_raises_type_error_regardless_of_operand_position
self.assertIs(broken_top_egg * top_winner, top_winner)
~~~~~~~~~~~~~~~^~~~~~~~~~~~
File "/tmp/solution.py", line 68, in __mul__
other_egg.tournament.leaderboard[other_egg.name] = other_egg.tournament.leaderboard.get(other_egg.name, 0) + 1
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'leaderboard'
======================================================================
ERROR: test_collision_result_is_independent_of_operand_order (test.TestEgg.test_collision_result_is_independent_of_operand_order)
Swapping the egg operands should not change the collision winner.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/test.py", line 212, in test_collision_result_is_independent_of_operand_order
self.assertIs(top_first_egg * top_second_egg, top_first_egg)
~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
File "/tmp/solution.py", line 64, in __mul__
self.tournament.leaderboard[self.name] = self.tournament.leaderboard.get(self.name, 0) + 1
^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'leaderboard'
======================================================================
ERROR: test_collision_with_partially_painted_eggs (test.TestEgg.test_collision_with_partially_painted_eggs)
Partially painted eggs should collide correctly from both sides.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/test.py", line 192, in test_collision_with_partially_painted_eggs
self.assertIs(first_egg * second_egg, first_egg)
~~~~~~~~~~^~~~~~~~~~~~
File "/tmp/solution.py", line 64, in __mul__
self.tournament.leaderboard[self.name] = self.tournament.leaderboard.get(self.name, 0) + 1
^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'leaderboard'
======================================================================
ERROR: test_failed_paint_overflow_does_not_change_egg_state (test.TestEgg.test_failed_paint_overflow_does_not_change_egg_state)
Failing to paint an egg because of overflow should not change its state.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/test.py", line 91, in test_failed_paint_overflow_does_not_change_egg_state
self.assertIs(reference_egg * reference_top_opponent, reference_egg)
~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
File "/tmp/solution.py", line 64, in __mul__
self.tournament.leaderboard[self.name] = self.tournament.leaderboard.get(self.name, 0) + 1
^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'leaderboard'
======================================================================
ERROR: test_losing_side_becomes_unusable (test.TestEgg.test_losing_side_becomes_unusable)
Losing a collision should make the losing side unusable.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/test.py", line 238, in test_losing_side_becomes_unusable
self.assertIs(top_loser * top_winner, top_winner)
~~~~~~~~~~^~~~~~~~~~~~
File "/tmp/solution.py", line 68, in __mul__
other_egg.tournament.leaderboard[other_egg.name] = other_egg.tournament.leaderboard.get(other_egg.name, 0) + 1
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'leaderboard'
======================================================================
ERROR: test_paint_boundary_exactly_at_50_percent (test.TestEgg.test_paint_boundary_exactly_at_50_percent)
Painting an egg exactly to the half boundary should keep the two halves separate.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/test.py", line 130, in test_paint_boundary_exactly_at_50_percent
self.assertIs(egg * opponent, egg)
~~~~^~~~~~~~~~
File "/tmp/solution.py", line 64, in __mul__
self.tournament.leaderboard[self.name] = self.tournament.leaderboard.get(self.name, 0) + 1
^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'leaderboard'
======================================================================
ERROR: test_paint_can_be_called_multiple_times (test.TestEgg.test_paint_can_be_called_multiple_times)
Painting an egg in multiple calls should preserve the full painting order.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/test.py", line 54, in test_paint_can_be_called_multiple_times
self.assertIs(egg * top_opponent, egg)
~~~~^~~~~~~~~~~~~~
File "/tmp/solution.py", line 64, in __mul__
self.tournament.leaderboard[self.name] = self.tournament.leaderboard.get(self.name, 0) + 1
^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'leaderboard'
======================================================================
ERROR: test_paint_chunk_crossing_50_percent_boundary_is_split_correctly (test.TestEgg.test_paint_chunk_crossing_50_percent_boundary_is_split_correctly)
Painting a chunk across the half boundary should split it correctly between the two halves.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/test.py", line 138, in test_paint_chunk_crossing_50_percent_boundary_is_split_correctly
self.assertIs(egg * opponent, egg)
~~~~^~~~~~~~~~
File "/tmp/solution.py", line 64, in __mul__
self.tournament.leaderboard[self.name] = self.tournament.leaderboard.get(self.name, 0) + 1
^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'leaderboard'
======================================================================
ERROR: test_paint_exactly_to_100_percent_is_allowed (test.TestEgg.test_paint_exactly_to_100_percent_is_allowed)
Painting an egg exactly to 100 percent should not raise an error.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/test.py", line 41, in test_paint_exactly_to_100_percent_is_allowed
self.assertIs(egg @ opponent, egg)
~~~~^~~~~~~~~~
File "/tmp/solution.py", line 112, in __matmul__
self.tournament.leaderboard[self.name] = self.tournament.leaderboard.get(self.name, 0) + 1
^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'leaderboard'
======================================================================
ERROR: test_paint_is_case_insensitive_for_hex_colors (test.TestEgg.test_paint_is_case_insensitive_for_hex_colors)
Painting an egg with lowercase and uppercase hex colors should produce the same behavior.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/test.py", line 111, in test_paint_is_case_insensitive_for_hex_colors
self.assertIs(lower_case_egg * lower_case_top_opponent, lower_case_egg)
~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
File "/tmp/solution.py", line 64, in __mul__
self.tournament.leaderboard[self.name] = self.tournament.leaderboard.get(self.name, 0) + 1
^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'leaderboard'
======================================================================
ERROR: test_paint_multiple_calls_can_cross_50_percent_boundary (test.TestEgg.test_paint_multiple_calls_can_cross_50_percent_boundary)
Painting an egg across the half boundary in multiple calls should split the halves correctly.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/test.py", line 150, in test_paint_multiple_calls_can_cross_50_percent_boundary
self.assertIs(egg * opponent, egg)
~~~~^~~~~~~~~~
File "/tmp/solution.py", line 64, in __mul__
self.tournament.leaderboard[self.name] = self.tournament.leaderboard.get(self.name, 0) + 1
^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'leaderboard'
======================================================================
ERROR: test_paint_order_of_color_chunks_matters (test.TestEgg.test_paint_order_of_color_chunks_matters)
Painting the same colors in different orders should change the collision result.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/test.py", line 122, in test_paint_order_of_color_chunks_matters
self.assertIs(first_egg * second_egg, first_egg)
~~~~~~~~~~^~~~~~~~~~~~
File "/tmp/solution.py", line 64, in __mul__
self.tournament.leaderboard[self.name] = self.tournament.leaderboard.get(self.name, 0) + 1
^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'leaderboard'
======================================================================
ERROR: test_paint_overflow_with_multiple_colors_should_not_change_the_egg (test.TestEgg.test_paint_overflow_with_multiple_colors_should_not_change_the_egg)
Failing to overpaint an egg with multiple colors should not change the egg.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/test.py", line 163, in test_paint_overflow_with_multiple_colors_should_not_change_the_egg
self.assertIs(egg @ bottom_opponent, bottom_opponent)
~~~~^~~~~~~~~~~~~~~~~
File "/tmp/solution.py", line 112, in __matmul__
self.tournament.leaderboard[self.name] = self.tournament.leaderboard.get(self.name, 0) + 1
^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'leaderboard'
======================================================================
ERROR: test_paint_single_color_full_egg (test.TestEgg.test_paint_single_color_full_egg)
A fully painted single-color egg should win collisions against a weaker egg from both sides.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/test.py", line 30, in test_paint_single_color_full_egg
self.assertIs(egg * opponent, egg)
~~~~^~~~~~~~~~
File "/tmp/solution.py", line 64, in __mul__
self.tournament.leaderboard[self.name] = self.tournament.leaderboard.get(self.name, 0) + 1
^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'leaderboard'
======================================================================
ERROR: test_same_two_eggs_can_have_different_winners_for_top_and_bottom (test.TestEgg.test_same_two_eggs_can_have_different_winners_for_top_and_bottom)
The same two eggs should be able to have different winners for top and bottom collisions.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/test.py", line 184, in test_same_two_eggs_can_have_different_winners_for_top_and_bottom
self.assertIs(first_egg * second_egg, second_egg)
~~~~~~~~~~^~~~~~~~~~~~
File "/tmp/solution.py", line 68, in __mul__
other_egg.tournament.leaderboard[other_egg.name] = other_egg.tournament.leaderboard.get(other_egg.name, 0) + 1
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'leaderboard'
======================================================================
ERROR: test_top_collision_returns_egg_with_greater_top_strength (test.TestEgg.test_top_collision_returns_egg_with_greater_top_strength)
A top collision should return the egg with the greater top strength.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/test.py", line 170, in test_top_collision_returns_egg_with_greater_top_strength
self.assertIs(stronger_egg * weaker_egg, stronger_egg)
~~~~~~~~~~~~~^~~~~~~~~~~~
File "/tmp/solution.py", line 64, in __mul__
self.tournament.leaderboard[self.name] = self.tournament.leaderboard.get(self.name, 0) + 1
^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'leaderboard'
======================================================================
ERROR: test_winner_side_does_not_become_broken (test.TestEgg.test_winner_side_does_not_become_broken)
Winning a collision should not break the winning side.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/test.py", line 302, in test_winner_side_does_not_become_broken
self.assertIs(winner_egg * first_loser, winner_egg)
~~~~~~~~~~~^~~~~~~~~~~~~
File "/tmp/solution.py", line 64, in __mul__
self.tournament.leaderboard[self.name] = self.tournament.leaderboard.get(self.name, 0) + 1
^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'leaderboard'
======================================================================
ERROR: test_collision_between_unregistered_eggs_is_not_recorded (test.TestEggTournament.test_collision_between_unregistered_eggs_is_not_recorded)
A collision between unregistered eggs should not be recorded in the tournament.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/test.py", line 381, in test_collision_between_unregistered_eggs_is_not_recorded
self.assertIs(first_egg * second_egg, first_egg)
~~~~~~~~~~^~~~~~~~~~~~
File "/tmp/solution.py", line 64, in __mul__
self.tournament.leaderboard[self.name] = self.tournament.leaderboard.get(self.name, 0) + 1
^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'leaderboard'
======================================================================
ERROR: test_egg_broken_outside_tournament_remains_broken_inside_tournament (test.TestEggTournament.test_egg_broken_outside_tournament_remains_broken_inside_tournament)
Breaking an egg outside the tournament should preserve its broken state inside the tournament.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/test.py", line 404, in test_egg_broken_outside_tournament_remains_broken_inside_tournament
self.assertIs(broken_egg * outsider, outsider)
~~~~~~~~~~~^~~~~~~~~~
File "/tmp/solution.py", line 68, in __mul__
other_egg.tournament.leaderboard[other_egg.name] = other_egg.tournament.leaderboard.get(other_egg.name, 0) + 1
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'leaderboard'
======================================================================
FAIL: test_unpainted_half_loses_to_half_painted_black (test.TestEgg.test_unpainted_half_loses_to_half_painted_black)
An unpainted half should lose to a half painted in black.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/test.py", line 200, in test_unpainted_half_loses_to_half_painted_black
self.assertIs(unpainted_egg * black_egg, black_egg)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: None is not <solution.Egg object at 0x7480b738cd70>
======================================================================
FAIL: test_collision_between_two_registered_eggs_is_recorded (test.TestEggTournament.test_collision_between_two_registered_eggs_is_recorded)
A collision between two registered eggs should be recorded in the tournament.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/test.py", line 373, in test_collision_between_two_registered_eggs_is_recorded
self.assertIs(1 @ tournament, first_egg)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: {<solution.Egg object at 0x7480b73a0e50>} is not <solution.Egg object at 0x7480b73a0e50>
======================================================================
FAIL: test_ranking_unique_position_returns_single_egg (test.TestEggTournament.test_ranking_unique_position_returns_single_egg)
Looking up a unique ranking position should return a single egg.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/test.py", line 478, in test_ranking_unique_position_returns_single_egg
self.assertIs(1 @ tournament, alpha)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: {<solution.Egg object at 0x7480b73a18d0>} is not <solution.Egg object at 0x7480b73a18d0>
======================================================================
FAIL: test_ranking_uses_dense_ranking_without_skipping_places (test.TestEggTournament.test_ranking_uses_dense_ranking_without_skipping_places)
Looking up ranking positions should use dense ranking without skipping places.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/test.py", line 514, in test_ranking_uses_dense_ranking_without_skipping_places
self.assertIs(1 @ tournament, alpha)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: {<solution.Egg object at 0x7480b73a19b0>} is not <solution.Egg object at 0x7480b73a19b0>
----------------------------------------------------------------------
Ran 46 tests in 0.009s
FAILED (failures=4, errors=21)
Виктор Бечев
15.04.2026 15:35Както и при друг колега, имаш проблем - очакваш всяко яйце задължително да е част от турнир, иначе сблъсъците не работят.
А изрично сме споменали, че трябва да е възможно да сблъскваме яйца от различни турнири.
Все пак, това е едно изискване от едно много дълго домашно, и не е редно да ти коства 2 точки (толкова повече би имал ако тази част беше коректна). Просто нашите тестове така работят. Затова ти даваме една от тях обратно.
|
15.04.2026 15:47
15.04.2026 15:48
15.04.2026 15:49