Your task is simple: tell me who wins the battle of the letters.
The troops
There are three different "troops" in this battle, summarized by this table.
name | health | damage
A 25 25
B 100 5
C 10 50
You may use any three unique characters to represent the the troops, but must specify if they are not these letters.
The battle
Suppose we have a sample battle:
ABC # army 1
CBA # army 2
Each army repeatedly fires at the leftmost unit, until it is dead; then they move to the troop to the right and repeat. So army 2 attacks A
in army 1 until A
is dead, then move to B
, then C
. Army 1 attacks C
first, then B
, then A
. Assume the armies attack at the same time, and thus troops will always fire if they were alive before the round and can kill each other at the same time. They fire in order from left to right.
The battle would play out as so:
ABC
CBA
BC # A (25 hp) killed by C (-50 hp), B (100 hp) attacked by B (-5 hp) and A (-25 hp), has 70 hp
BA # C (10 hp) killed by A (-25 hp), B (100 hp) attacked by B (-5 hp) and C (-50 hp), has 45 hp
BC # B (70 hp) attacked by B (-5 hp) and A (-25 hp), has 40 hp
A # B (45 hp) killed by B (-5 hp) and C (-50 hp)
BC # B (40 hp) attacked by A (-25 hp), has 15 health
# A (25 hp) killed by B (-5 hp) and C (-50 hp), army 2 dead
Therefore, army 1 wins the battle!
Input
Two strings, the first representing army 1 and the second army 2. They are not necessarily the same size (because who said it would be a fair fight?)
Output
Any three unique, constant values to represent army 1 winning, army 2 winning, or the unlikely event of a tie. Yes, it is possible for the last troops to kill each other, ending in a tie.
Battles
ABC
CBA
Army 1
CCCCC
CCCCC
Tie
CABCAB
ABBABBA
Army 2
Standard loopholes apply. You must submit a full program.
This is code-golf, shortest solution wins.
A
beatsB
andC
tiesB
andA
tiesC
. Changing either ofA
's values to20
would make it tieB
. \$\endgroup\$ – CalculatorFeline Jun 1 '17 at 2:57