Skip to content

Instantly share code, notes, and snippets.

@Chris--B
Created November 25, 2013 02:39
Show Gist options
  • Save Chris--B/7635439 to your computer and use it in GitHub Desktop.
Save Chris--B/7635439 to your computer and use it in GitHub Desktop.
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