Created
November 25, 2013 02:39
-
-
Save Chris--B/7635439 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def next(life, power, counters): | |
for _ in range(1): | |
life += 2 * power | |
counters += 2 * power | |
power = life + counters | |
return life, power, counters | |
def power_at(turn, life, power, counters): | |
return 5 ** turn * (life + power + 4 * counters) * 2 // 7 | |
def life_at(turn, life, power, counters): | |
return (power_at(turn, life, power, counters) + life - counters) // 2 | |
def counters_at(turn, life, power, counters): | |
return (power_at(turn, life, power, counters) - life + counters) // 2 | |
life, power, counters = 1, 2, 1 | |
TURNS = 10 | |
print("{:<7}{:<15}{:<15}{:<15}".format("Turn", "Life", "Power", "Counters")) | |
for turn in range(1, TURNS + 1): | |
life, power, counters = next(life, power, counters) | |
assert(life == life_at(turn, 1, 2, 1)) | |
assert(power == power_at(turn, 1, 2, 1)) | |
assert(counters == counters_at(turn, 1, 2, 1)) | |
print("{turn:<7}{life:<15} {power:<15} {counters:<15}".format(**vars())) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment