fork download
  1. # A quick Python code that goes through all possibilities calculates the odds of Gurubashi survival at 84.247%.
  2.  
  3. minions = [1,2,2,2,3,7]
  4. cache = {}
  5. def f(minions, volcano):
  6. code = tuple(minions + [volcano])
  7. if code in cache:
  8. return cache[code]
  9. if volcano == 0:
  10. return float(minions[-1] == 1)
  11. num_alive = sum([x>0 for x in minions])
  12. chance = 0.0
  13. for idx, minion in enumerate(minions):
  14. if minion > 0:
  15. one_tick = minions[:]
  16. one_tick[idx] -= 1
  17. chance += f(one_tick, volcano-1)/float(num_alive)
  18. cache[code] = chance
  19. return chance
  20. print(f(minions, 16))
Success #stdin #stdout 0.01s 23432KB
stdin
Standard input is empty
stdout
0.842479856744