MathGroup Archive 2009

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

Search the Archive

Re: Ten chess-players...

  • To: mathgroup at smc.vnet.net
  • Subject: [mg99352] Re: Ten chess-players...
  • From: "Bruno Campanini" <BC at gmail.com>
  • Date: Sun, 3 May 2009 05:23:58 -0400 (EDT)
  • References: <36a5dba2-11b9-45df-84c3-9e712e47fec9@q33g2000pra.googlegroups.com> <gth5l5$f3c$1@smc.vnet.net>

"Leonid Shifrin" <lshifr at gmail.com> wrote in message 
news:gth5l5$f3c$1 at smc.vnet.net...

> If I understand correctly, you would like to find some player arrangement
> such that each player plays each day exactly once, and at the end,
> each player plays with all the others. While I don't know the general way
> to efficiently produce all such solutions, this code seems to get some
> particular one in about a second or less on the average on my PC. It is
> rather ad hoc in the way it looks for a solution - perhaps there are 
> faster
> and more systematic and elegant ways but I did not figure them out.
>
> In[1] =
>
> getSolution[numOfPlayers_?EvenQ] :=
[..]

You understood very well what I'd like to do and your formula
works perfectly!
But it's very hard to me to understand the algorithm you used
because of my very poor knowledge of Mathematica.
Then I tried resembling something from my Visual Basic routine:

Do[numPlayers := 10;
 If[OddQ[numPlayers], odd = 1; numPlayers = numPlayers + odd,
  odd = 0]; a1 = Range[2, numPlayers];
 If[odd == 1, a1 = a1 /. a1[[numPlayers - 1]] -> 0];
 a3 = Range[1, numPlayers/2];
 a4 = Range[numPlayers, numPlayers/2 + 1, -1];
 For[i = 1, i < 10, i++, a1 = RotateLeft[a1];
  b1 = Join[{1}, a1];
  For[j = 1, j < numPlayers/2 + 1, j++,
   Print[b1[[a3[[j]]]] , " ", b1[[a4[[j]]]]]]], {1}]

I works also ok but I'm unable to get it printing by columns, i.e:
1  2          1  3          1  4
3  10        4  2          5  3
4  9          5   10       6  2
5  8          6  9          7  10
6  7          7  8          8  9
etc.

Could you help me?

Bruno

PS
I works even with an odd number of players, adding 1 to that
number and replacing the last player with zero.



  • Prev by Date: Re: Introducing the Wolfram Mathematica Tutorial Collection
  • Next by Date: Re: New Wolfram Tutorial Collection documentation is ready
  • Previous by thread: Re: Ten chess-players...
  • Next by thread: Re: Re: Ten chess-players...