Skip to content

Instantly share code, notes, and snippets.

@AdamOnza
Created June 21, 2025 18:18
Show Gist options
  • Save AdamOnza/8103758365a54ade75dac94d87b33fbf to your computer and use it in GitHub Desktop.
Save AdamOnza/8103758365a54ade75dac94d87b33fbf to your computer and use it in GitHub Desktop.
Fight numbers. Simulate a game where players rise up and fall down based on "fights", eventually, there is just 1 player per tier. This function finds the number of fights to reach that state.
from random import choice, randint, random,shuffle
def fightnum(x):
tier = [[] for i in range(x)]
tier[x//2] = list(range(x))
for fn in range(2_000_000):
t = [i for i in range(x) if len(tier[i])>=2]
if len(t) == 0:
return fn
i = choice(t)
c = choice(tier[i])
tier[i].remove(c)
d = c
c = choice(tier[i])
tier[i].remove(c)
m = [max(0,i-1),min(x-1,i+1)]
shuffle(m)
i,j = m
tier[i] += [c]
tier[j] += [d]
raise Exception("Fight number beyond range of fn for loop.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy