The Three-Element Duel of Corvelline College
The Magisters of Corvelline College settle their quarrels by formal spell-duel, and the College pays a bounty to any adventurer who can judge the duels fairly, for the Magisters trust no one of their own.
In a duel, each of two Magisters casts a sequence of spells, one per round, and each spell is one of three elements: "fire", "frost" or "storm". In round i, the first Magister's i-th spell is matched against the second Magister's i-th spell. The rules of the round are:
"fire"beats"frost""frost"beats"storm""storm"beats"fire"- if both cast the same element, nobody wins that round.
Write duelVerdict(first, second).
firstis an array of strings: the first Magister's spells in round order.secondis an array of strings: the second Magister's spells in round order.- Both arrays have the same length, which may be zero, and every string is exactly one of
"fire","frost"or"storm".
Return a string: "first" if the first Magister won more rounds than the second, "second" if the second Magister won more rounds than the first, and "draw" if they won the same number of rounds.
examples
- case 1
first = ["fire", "fire"], second = ["storm", "frost"]"draw" - storm beats fire in round 1, fire beats frost in round 2, so each Magister wins one round - case 2
first = ["frost", "frost", "fire", "storm"], second = ["fire", "storm", "storm", "frost"]"second" - the second Magister wins rounds 1, 3 and 4; the first wins only round 2 - case 3
first = [], second = []"draw" - no rounds were fought, so neither Magister won any
- reward
- 210 XP
- signature
duelVerdict
TypeScript, run as ES2022 — types are stripped, not checked. If a JS engine would run it, so will we.
- first sweeps every round
- one round each is a draw
- empty duel
- single matching round
- second wins three to one
- first wins amid matching rounds
- single decisive round for second
- single round storm beats fire