Two armies composed of magical creatures are facing off at a
battlefield. To provide a more epic feel to the battle, the armies
have agreed that each creature will attack exactly once and that only
one creature may attack at a time.
Each creature has a might trait assigned to it. The order in
which the creatures attack is uniquely determined by the following rules:
- Creatures with higher might attack before creatures with lower
- If creatures have equal might, attacking creatures alternate
between armies. For example, if the last creature to attack was from
the first army and the next creature could be from either army, a
creature from the second army will attack next. If the very first
attack is to be decided, a creature from the first army goes first.
- If more than one creature in the same army has the same might, the
creature given earlier in the input goes first.
You will be given the descriptions of the armies as two Strings, army1 and army2.
Each element of army1 and army2 will be formatted as "NAME MIGHT" (quotes for clarity), where
NAME is the name of a creature, and MIGHT is an integer, the might of that creature.
Return a String containing the creatures' names in the order in which they attack.