Домашни > Великденско домашно > Решения > Решението на Стефан Краев

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

2 точки общо

11 успешни теста
35 неуспешни теста
Код
Скрий всички коментари

  1import keyword # for egg nickname validation
  2
  3class Egg:
  4
  5    def __init__(self):
  6        self.fill = 0
  7        self.top = 0
  8        self.bottom = 0
  9        self.tournament = None
 10        self.top_is_broken = False
 11        self.bottom_is_broken = False
 12        self.bottom_is_painted_atleast_once = False
 13        self.top_is_painted_atleast_onece = False
 14
 15    def _update_strength(self, parts, percentage):
 16
 17        top_index = bottom_index = 0
 18        if self.fill + percentage <= 50:
 19            self.top_is_painted_atleast_onece = True
 20            top_index, bottom_index = 1, 0
 21        elif self.fill >= 50:
 22            self.bottom_is_painted_atleast_once = True
 23            top_index, bottom_index = 0, 1
 24        else:
 25            self.top_is_painted_atleast_onece = True
 26            self.bottom_is_painted_atleast_once = True
 27            top_index = (50 - self.fill) / percentage
 28            bottom_index = 1 - top_index
 29
 30        for hex in parts:
 31            self.top += int(hex, 16) * top_index
 32            self.bottom += int(hex, 16) * bottom_index
 33        
 34        self.fill += percentage
 35        
 36
 37    def paint(self, *args: tuple[str, int]):
 38        
 39        percentage_sum = sum(pair[1] for pair in args)
 40        if percentage_sum + self.fill > 100:
 41            raise ValueError
 42
 43        for pair in args:
 44            parts = [pair[0][i:i+2] for i in range(0, len(pair[0]), 2)]
 45            self._update_strength(parts, pair[1])
 46
 47    def __mul__(self, other_egg):
 48
 49        if self.top_is_broken or other_egg.top_is_broken:
 50            raise TypeError("The top of the egg has already been defeated in a battle!")
 51        
 52        if not self.top_is_painted_atleast_onece:
 53            winner = other_egg
 54            self.top_is_broken = True
 55        elif not other_egg.top_is_painted_atleast_onece:
 56            winner = self
 57            other_egg.top_is_broken = True
 58        elif self.top > other_egg.top:
 59            winner = self
 60            other_egg.top_is_broken = True
 61        else:
 62            winner = other_egg
 63            self.top_is_broken = True
 64
 65        if self.tournament is not None and self.tournament == other_egg.tournament:
 66            self.tournament[self, other_egg, "top"] = winner
 67    
 68    def __matmul__(self, other_egg):
 69        
 70        if self.bottom_is_broken or other_egg.bottom_is_broken:
 71            raise TypeError("The bottom of the egg has already been defeated in a battle!")
 72        
 73        if not self.bottom_is_painted_atleast_onece:
 74            winner = other_egg
 75            self.bottom_is_broken = True
 76        elif not other_egg.bottom_is_painted_atleast_onece:
 77            winner = self
 78            other_egg.bottom_is_broken = True
 79        elif self.bottom > other_egg.bottom:
 80            winner = self
 81            other_egg.bottom_is_broken = True
 82        else:
 83            winner = other_egg
 84            self.bottom_is_broken = True
 85
 86        if self.tournament is not None and self.tournament == other_egg.tournament:
 87            self.tournament[self, other_egg, "bottom"] = winner
 88    
 89class EggTournament:
 90
 91    def __init__(self):
 92        self.participants = {}
 93        self.history = {}
 94
 95    def register(self, egg, egg_nickname):
 96
 97        if egg.tournament is not None:
 98            raise ValueError("An egg cannot be registered in multiple tournaments")
 99        
100        if egg_nickname in self.participants.values():
101            raise ValueError(f"Egg with name {egg_nickname} has already been registered")
102        
103        if not egg_nickname.isidentifier() or keyword.iskeyword(egg_nickname):
104            raise ValueError("Invalid registration name")
105
106        self.participants[egg] = egg_nickname
107        egg.tournament = self
108
109    def __setitem__(self, key, winner_egg):
110
111        if isinstance(key, slice):
112            egg_first = key.start
113            egg_second = key.stop
114            side = key.step
115        else:
116            egg_first, egg_second, side = key
117
118        self.history[(egg_first, egg_second, side)] = winner_egg
119        self.history[(egg_second, egg_first, side)] = winner_egg
120
121    def __getitem__(self, key):
122
123        if isinstance(key, slice):
124            key = (key.start, key.stop, key.step)
125
126        if key not in self.history:
127            raise KeyError("No such battle recorded!")
128
129        return self.history[key]
130    
131    def __rmatmul__(self, place):
132
133        win_counts = {}
134        for winner in self.history.values():
135            win_counts[winner] = win_counts.get(winner, 0) + 1
136        
137        if not win_counts:
138            raise IndexError("No winners yet.")
139
140        buckets = {}
141        for egg, count in win_counts.items():
142            if count not in buckets:
143                buckets[count] = []
144            buckets[count].append(egg)
145
146        unique_scores = sorted(buckets.keys(), reverse=True)
147
148        if place <= 0 or place > len(unique_scores):
149            raise IndexError("Invalid place index!")
150
151        target_score = unique_scores[place - 1] # first place but zero indexed array
152        return buckets[target_score]
153    
154    def __getattr__(self, nickname):
155
156        if nickname not in self.participants.values():
157            raise AttributeError("Apologies, there is no such egg registered")
158        
159        reverse_participants = {v: k for k, v in self.participants.items()}
160        wanted_egg = reverse_participants.get(nickname)
161        
162        win_counts = {}
163        for winner in self.history.values():
164            win_counts[winner] = win_counts.get(winner, 0) + 1
165
166        if not win_counts or wanted_egg not in win_counts:
167            raise IndexError("Coward or looser")
168
169        buckets = {}
170        for egg, count in win_counts.items():
171            buckets.setdefault(count, []).append(egg)
172
173        unique_scores = sorted(buckets.keys(), reverse=True)
174
175        egg_wins = win_counts[wanted_egg]
176
177        position = unique_scores.index(egg_wins) + 1
178        
179        return {"position": position, "victories": egg_wins // 2}
180        
181
182    
183    def __contains__(self, egg):
184        return egg.tournament is self

EFFFFFFFFFEFFF...EFFFFFFFF..F..F.FFFF.FFFF..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 73, in __matmul__
if not self.bottom_is_painted_atleast_onece:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'Egg' object has no attribute 'bottom_is_painted_atleast_onece'. Did you mean: 'bottom_is_painted_atleast_once'?

======================================================================
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 73, in __matmul__
if not self.bottom_is_painted_atleast_onece:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'Egg' object has no attribute 'bottom_is_painted_atleast_onece'. Did you mean: 'bottom_is_painted_atleast_once'?

======================================================================
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 73, in __matmul__
if not self.bottom_is_painted_atleast_onece:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'Egg' object has no attribute 'bottom_is_painted_atleast_onece'. Did you mean: 'bottom_is_painted_atleast_once'?

======================================================================
FAIL: 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)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: None is not <solution.Egg object at 0x720b7d7c6ad0>

======================================================================
FAIL: 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)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: None is not <solution.Egg object at 0x720b7d7c6ad0>

======================================================================
FAIL: 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)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: None is not <solution.Egg object at 0x720b7d7c6850>

======================================================================
FAIL: 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)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: None is not <solution.Egg object at 0x720b7d7c6850>

======================================================================
FAIL: 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)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: None is not <solution.Egg object at 0x720b7d7c6850>

======================================================================
FAIL: 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)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: None is not <solution.Egg object at 0x720b7d7c6990>

======================================================================
FAIL: 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)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
AssertionError: None is not <solution.Egg object at 0x720b7d7c6850>

======================================================================
FAIL: 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)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: None is not <solution.Egg object at 0x720b7d7c6850>

======================================================================
FAIL: 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)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
AssertionError: None is not <solution.Egg object at 0x720b7d7c6850>

======================================================================
FAIL: 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)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: None is not <solution.Egg object at 0x720b7d7c6850>

======================================================================
FAIL: 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)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
AssertionError: None is not <solution.Egg object at 0x720b7d7c6850>

======================================================================
FAIL: 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)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: None is not <solution.Egg object at 0x720b7d7c6850>

======================================================================
FAIL: 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)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
AssertionError: None is not <solution.Egg object at 0x720b7d7c6850>

======================================================================
FAIL: 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)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: None is not <solution.Egg object at 0x720b7d7c6990>

======================================================================
FAIL: 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)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: None is not <solution.Egg object at 0x720b7d7c6850>

======================================================================
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 0x720b7d7c6990>

======================================================================
FAIL: 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)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: None is not <solution.Egg object at 0x720b7d7c6850>

======================================================================
FAIL: test_collision_between_registered_and_unregistered_egg_is_not_recorded (test.TestEggTournament.test_collision_between_registered_and_unregistered_egg_is_not_recorded)
A collision between a registered and an unregistered egg should not be recorded in the tournament.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/test.py", line 392, in test_collision_between_registered_and_unregistered_egg_is_not_recorded
self.assertIs(registered_egg * unregistered_egg, registered_egg)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: None is not <solution.Egg object at 0x720b7d7c6850>

======================================================================
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 371, in test_collision_between_two_registered_eggs_is_recorded
self.assertIs(first_egg * second_egg, first_egg)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: None is not <solution.Egg object at 0x720b7d7c6990>

======================================================================
FAIL: 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)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: None is not <solution.Egg object at 0x720b7d7c7110>

======================================================================
FAIL: 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)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: None is not <solution.Egg object at 0x720b7d7c7390>

======================================================================
FAIL: test_history_lookup_is_symmetric_with_respect_to_egg_order (test.TestEggTournament.test_history_lookup_is_symmetric_with_respect_to_egg_order)
Looking up a recorded collision in reversed egg order should return the same winner.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/test.py", line 445, in test_history_lookup_is_symmetric_with_respect_to_egg_order
self.assertIs(first_egg * second_egg, first_egg)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: None is not <solution.Egg object at 0x720b7d7c7610>

======================================================================
FAIL: test_history_lookup_returns_winner_for_top_and_bottom (test.TestEggTournament.test_history_lookup_returns_winner_for_top_and_bottom)
Looking up recorded top and bottom collisions should return the correct winners.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/test.py", line 415, in test_history_lookup_returns_winner_for_top_and_bottom
self.assertIs(first_egg * second_egg, second_egg)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: None is not <solution.Egg object at 0x720b7d7c7d90>

======================================================================
FAIL: test_history_lookup_top_and_bottom_are_distinct (test.TestEggTournament.test_history_lookup_top_and_bottom_are_distinct)
Looking up top and bottom collisions should treat them as distinct entries.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/test.py", line 456, in test_history_lookup_top_and_bottom_are_distinct
self.assertIs(first_egg * second_egg, second_egg)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: None is not <solution.Egg object at 0x720b7d5c8050>

======================================================================
FAIL: test_history_lookup_with_slice_key (test.TestEggTournament.test_history_lookup_with_slice_key)
Looking up a recorded collision with a slice key should return the winner.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/test.py", line 436, in test_history_lookup_with_slice_key
self.assertIs(first_egg * second_egg, first_egg)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: None is not <solution.Egg object at 0x720b7d5c8190>

======================================================================
FAIL: test_history_lookup_with_tuple_key (test.TestEggTournament.test_history_lookup_with_tuple_key)
Looking up a recorded collision with a tuple key should return the winner.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/test.py", line 427, in test_history_lookup_with_tuple_key
self.assertIs(first_egg * second_egg, first_egg)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: None is not <solution.Egg object at 0x720b7d5c8410>

======================================================================
FAIL: test_ranking_missing_position_raises_index_error (test.TestEggTournament.test_ranking_missing_position_raises_index_error)
Looking up a missing ranking position should raise an IndexError.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/test.py", line 533, in test_ranking_missing_position_raises_index_error
self.assertIs(alpha * beta, alpha)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
AssertionError: None is not <solution.Egg object at 0x720b7d5c8690>

======================================================================
FAIL: test_ranking_tied_position_returns_set_of_eggs (test.TestEggTournament.test_ranking_tied_position_returns_set_of_eggs)
Looking up a tied ranking position should return a set of eggs.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/test.py", line 489, in test_ranking_tied_position_returns_set_of_eggs
self.assertIs(alpha * gamma, alpha)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^
AssertionError: None is not <solution.Egg object at 0x720b7d5c8e10>

======================================================================
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 477, in test_ranking_unique_position_returns_single_egg
self.assertIs(alpha * beta, alpha)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
AssertionError: None is not <solution.Egg object at 0x720b7d5c9450>

======================================================================
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 509, in test_ranking_uses_dense_ranking_without_skipping_places
self.assertIs(alpha * beta, alpha)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
AssertionError: None is not <solution.Egg object at 0x720b7d7c7b10>

======================================================================
FAIL: test_registered_egg_attribute_returns_position_and_victories (test.TestEggTournament.test_registered_egg_attribute_returns_position_and_victories)
Accessing a registered egg as an attribute should return its position and victories.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/test.py", line 556, in test_registered_egg_attribute_returns_position_and_victories
self.assertIs(alpha * beta, alpha)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
AssertionError: None is not <solution.Egg object at 0x720b7d5c9f90>

======================================================================
FAIL: test_registered_egg_attribute_with_zero_victories_is_accessible (test.TestEggTournament.test_registered_egg_attribute_with_zero_victories_is_accessible)
Accessing a registered egg with zero victories should return its position and victories.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/test.py", line 572, in test_registered_egg_attribute_with_zero_victories_is_accessible
self.assertIs(alpha * beta, alpha)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
AssertionError: None is not <solution.Egg object at 0x720b7d5ca710>

----------------------------------------------------------------------
Ran 46 tests in 0.008s

FAILED (failures=32, errors=3)

Дискусия
Виктор Бечев
15.04.2026 15:23

Важно е да е да връщаш победител при сблъсък на яйца, както в примерите. Ако го беше имплементирал - би имал някоя друга точка в повече. Пропуснал си ключова част от задачата, без която няма как да минат повечето тестове. Вероятно би могъл (резонно) да ни репликираш, че не сме упоменали изрично, че трябва нещо да бъде върнато. И ще си наполовина прав. Имаме това: `# my_egg @ your_egg би върнало същото, но повече за това в следващия абзац` Но трябва да признаем, че е малко скришно. Затова ще ти дадем още една от точките, които иначе би заслужил. Най-малкото си се постарал да напишеш цялото това решение. Cheers.
История
Това решение има само една версия.