Answer architecture round 3: open each place with the dimensions it moves, fail a scoring run nothing calls, test the base rule and a standing ratchet, and state the base rule whole
This commit is contained in:
@@ -23,8 +23,8 @@ def votes(seats: list[Seat]) -> dict[str, list[str]] | Failure:
|
||||
line = vote_line(seat.name, seat.said)
|
||||
if isinstance(line, Failure):
|
||||
return line
|
||||
if unnamed := [place for place in seat.places if not any(re.search(rf"\b{name}\b", place) for name in DIMENSIONS)]:
|
||||
return Failure(f"{seat.name}'s place names none of {', '.join(DIMENSIONS)}, spelled so: {unnamed[0]}")
|
||||
if unnamed := [place for place in seat.places if not place_dimensions(place)]:
|
||||
return Failure(f"{seat.name}'s place does not open with the dimensions it moves, each one of {', '.join(DIMENSIONS)}, then `: `: {unnamed[0]}")
|
||||
said[seat.name] = line
|
||||
first, second, *more = (each[-1] for each in counted(seats, said).values())
|
||||
if more and first == second:
|
||||
@@ -38,7 +38,13 @@ def counted(seats: list[Seat], said: dict[str, list[str]]) -> dict[str, list[str
|
||||
|
||||
|
||||
def names_a_place(seat: Seat, dimension: str) -> bool:
|
||||
return any(PLACE.search(place) and (dimension == DIMENSIONS[-1] or re.search(rf"\b{dimension}\b", place)) for place in seat.places)
|
||||
return any(PLACE.search(place) and (dimension == DIMENSIONS[-1] or dimension in place_dimensions(place)) for place in seat.places)
|
||||
|
||||
|
||||
def place_dimensions(place: str) -> list[str]:
|
||||
"""The dimensions a place opens with, as in `Locality, Shape: `path:line` ...`; empty when any name before the first `: ` is no dimension."""
|
||||
named = place.partition(": ")[0].split(", ")
|
||||
return named if all(name in DIMENSIONS for name in named) else []
|
||||
|
||||
|
||||
def ruling(counted: list[str]) -> str | None:
|
||||
|
||||
Reference in New Issue
Block a user