All problems

Council of Rival Guilds

Medium · queue

A council meets in a circle of seats. The string council has one character per seat, in order: "A" is a member of the Amber guild and "T" is a member of the Teal guild.

The council runs in rounds. In a round, the seats take their turns in order from the first seat to the last. After the last seat, the next round starts again at the first seat.

On their turn, a member silences one member of the *other* guild: the first member of the other guild who is still allowed to speak, going forward from the member's own seat and wrapping round from the last seat to the first. A silenced member never takes a turn again, not even later in the same round. A seat that has been silenced is simply skipped.

The council ends the moment one guild has no member left who can speak, and the other guild wins. Return "Amber" or "Teal".

Examples

Example 1

Input: council = "AT"

Output: "Amber"

Seat 0 (Amber) silences the Teal member in seat 1, and Teal has no one left.

Example 2

Input: council = "TTAA"

Output: "Teal"

Seat 0 silences seat 2 and seat 1 silences seat 3. Amber is wiped out in the first round.

Example 3

Input: council = "ATTA"

Output: "Amber"

Seat 0 silences seat 1. Seat 2 silences seat 3 (the next Amber seat). In round two seat 0 silences seat 2, and Teal is gone.

Constraints