Linux.org.ru chess tournament logs and tables
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
1014B

  1. #!/usr/bin/python2
  2. # -*- coding: utf-8 -*-
  3. def roundRobin(units, sets=None):
  4. """ Generates a schedule of "fair" pairings from a list of units """
  5. if len(units) % 2:
  6. units.append(None)
  7. count = len(units)
  8. sets = sets or (count - 1)
  9. half = count / 2
  10. schedule = []
  11. for turn in range(sets):
  12. pairings = []
  13. for i in range(half):
  14. pairings.append((units[i], units[count-i-1]))
  15. units.insert(1, units.pop())
  16. schedule.append(pairings)
  17. return schedule
  18. # LOR sheduler
  19. players = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"]
  20. tour_count = 0
  21. # Generate LORCODE for pairings.
  22. # Also generate "reversal" for autumm season.
  23. for pairings in roundRobin(players):
  24. tours = (len(players) - 1) * 2
  25. tour_count = tour_count + 1
  26. print "[b]Тур №" + str(tour_count) + "[/b]"
  27. print "[list]"
  28. for pair in pairings:
  29. print "[*]" + pair[0] + " играет против " + pair[1]
  30. print "[/list]"