Skip to content

Instantly share code, notes, and snippets.

@Beneboe
Created January 13, 2014 19:32
Show Gist options
  • Save Beneboe/8406488 to your computer and use it in GitHub Desktop.
Save Beneboe/8406488 to your computer and use it in GitHub Desktop.
Erzeugung eines Turnierplans
def range(start, stop, step = 1):
x = start
while True:
if x >= stop: return
yield x
x += step
# Erzeugung eines Turnierplans mit n Teilnehmern
# Eingabe von n
n = int(input('Anzahl der Teilnehmer: '))
# Erzeugung und Ausgabe der Spielpaarungen
for i in range(0, n - 1):
print('Runde ' + str(i + 1) + ':')
print(n - 1, ':', i)
for j in range(1, n / 2):
a = (i - j + n - 1) % (n - 1)
b = (i + j - n + 1) % (n - 1)
print(a, ':', b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment