MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Ten chess-players...

  • To: mathgroup at smc.vnet.net
  • Subject: [mg104810] Re: [mg104219] Ten chess-players...
  • From: DrMajorBob <btreat1 at austin.rr.com>
  • Date: Tue, 10 Nov 2009 06:02:48 -0500 (EST)
  • References: <200910240638.CAA07417@smc.vnet.net>
  • Reply-to: drmajorbob at yahoo.com

And finally (I promise), here's a much nicer solution.

It's far faster, uses no memoization, and makes "byes" explicit.

Clear[roundRobinRotate, tournament]
roundRobinRotate[lst_List] :=
  Replace[lst,
   Thread[Range[2, 2 Length@lst] ->
     RotateRight[Range[2, 2 Length@lst]]], {2}]
tournament[n_?EvenQ] :=
  NestList[roundRobinRotate,
   Transpose@{Range[n/2], Range[n, n/2 + 1, -1]}, n - 2]
tournament[n_?OddQ] := tournament[n + 1] /. n + 1 :> "Bye"

tournament[10]

{{{1, 10}, {2, 9}, {3, 8}, {4, 7}, {5, 6}}, {{1, 9}, {10, 8}, {2,
    7}, {3, 6}, {4, 5}}, {{1, 8}, {9, 7}, {10, 6}, {2, 5}, {3,
    4}}, {{1, 7}, {8, 6}, {9, 5}, {10, 4}, {2, 3}}, {{1, 6}, {7,
    5}, {8, 4}, {9, 3}, {10, 2}}, {{1, 5}, {6, 4}, {7, 3}, {8, 2}, {9,
    10}}, {{1, 4}, {5, 3}, {6, 2}, {7, 10}, {8, 9}}, {{1, 3}, {4,
    2}, {5, 10}, {6, 9}, {7, 8}}, {{1, 2}, {3, 10}, {4, 9}, {5, 8}, {6,
     7}}}

Union @@ tourney == Sort@(Join @@ tourney)
Binomial[10, 2] == Total[Length /@ tourney]

True

True

tournament[9]

{{{1, "Bye"}, {2, 9}, {3, 8}, {4, 7}, {5, 6}}, {{1, 9}, {"Bye",
    8}, {2, 7}, {3, 6}, {4, 5}}, {{1, 8}, {9, 7}, {"Bye", 6}, {2,
    5}, {3, 4}}, {{1, 7}, {8, 6}, {9, 5}, {"Bye", 4}, {2, 3}}, {{1,
    6}, {7, 5}, {8, 4}, {9, 3}, {"Bye", 2}}, {{1, 5}, {6, 4}, {7,
    3}, {8, 2}, {9, "Bye"}}, {{1, 4}, {5, 3}, {6, 2}, {7, "Bye"}, {8,
    9}}, {{1, 3}, {4, 2}, {5, "Bye"}, {6, 9}, {7, 8}}, {{1, 2}, {3,
    "Bye"}, {4, 9}, {5, 8}, {6, 7}}}

Bobby

On Sat, 24 Oct 2009 01:38:47 -0500, <cmpbrn at gmail.com> wrote:

> Given 10 (1 to 10) chess-players, in one day they play 5 games (1-2,
> 6-10, 5-7, 4-8, 3-9).
> Then they need 8 more days to complete the championship (one gamer
> must play one time against any other player):
> 1-3, 2-10, 6-7, 5-8, 4-9
> 1-4, 2-3, 7-10, 6-8, 5-9
> 1-5, 2-4, 3-10, 7-8, 6-9
> 1-6, 2-5, 3-4, 7-9, 8-10
> 1-7, 2-6, 3-5, 4-10, 8-9
> 1-8, 2-7, 3-6, 4-5, 9-10
> 1-9, 2-8, 3-7, 4-6, 5-10
> 1-10, 2-9, 3-8, 4-7, 5-6
>
> How can I get the 10*(10-1)/2 = 45 pairs distributed in the 9x5
> matrix?
> What's about any other even number of players?
>
> Bruno
>


-- 
DrMajorBob at yahoo.com


  • Prev by Date: Re: incompatibilities
  • Next by Date: Re: Give arrow a certai color
  • Previous by thread: Re: Re: How to get data from solvin'
  • Next by thread: Re: Ten chess-players...