1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env python

init_hp = 200000
ticks_per_minute = 3600 # LCM of speed values
swords = [
    ('blue',   100, ticks_per_minute/80),
    ('red',    80,  ticks_per_minute/100),
    ('yellow', 150, ticks_per_minute/50),
    ('green',  50,  ticks_per_minute/180),
]        
armors = [
    ('blue',   -12, .10),
    ('red',     -8, .15),
    ('yellow', -20,  .0),
    ('green',    0, .24),
]

"Fight two tuples, returns True if player 1 wins."
def fight(s1, a1, s2, a2):
    hp1 = init_hp
    hp2 = init_hp
    next_attack1 = 0
    next_attack2 = 0
    tick = 0
    while True:
        if next_attack1 == tick:
            hp2 -= (1-a2[2])*(s1[1]+a2[1])
            if hp2 <= 0:
                return True
            next_attack1 += s1[2]
        if next_attack2 == tick:
            hp1 -= (1-a1[2])*(s2[1]+a1[1])
            if hp1 <= 0:
                return False
            next_attack2 += s2[2]
        tick += 1

def main():
    combos = []
    for s in swords:
        for a in armors:
            # sword, armor, win counter
            combos.append([s, a, 0])

    while combos:
        for c1 in combos:
            for c2 in combos:
                if fight(c1[0], c1[1], c2[0], c2[1]):
                    c1[2] += 1
                else:
                    c2[2] += 1
        print ""
        print "Pass " + str(17-len(combos)) + ":"
        combos = sorted(combos, key=lambda combo: combo[2])
        for c in combos:
            print str(c[2]) + ": " + c[0][0] + "/" + c[1][0]  
            c[2] = 0
        del combos[0]

if __name__ == '__main__':
    main()