Game schedule where each player meets only onceWhere does Documentation Center introduce the basics?Return only one numeric solution to equationintegrating with multiple indicator functions depending on each otherPiecewise function Syntax error only in debug modeWhere to look up information about some symbols, such as “,”, “[” and “]” (not string)?Where to find order of arguments for default functions

If someone else uploads my GPL'd code to Github without my permission, is that a copyright violation?

Our group keeps dying during the Lost Mine of Phandelver campaign. What are we doing wrong?

Is this cheap "air conditioner" able to cool a room?

Why can I log in to my Facebook account with a misspelled email/password?

What does VB stand for?

Why should public servants be apolitical?

Should I take out a personal loan to pay off credit card debt?

12V lead acid charger with LM317 not charging

ESTA declined to the US

Probably terminated or laid off soon; confront or not?

Does the Voyager team use a wrapper (Fortran(77?) to Python) to transmit current commands?

Does the United States guarantee any unique freedoms?

How to help new students accept function notation

Purchased new computer from DELL with pre-installed Ubuntu. Won't boot. Should assume its an error from DELL?

What are the examples (applications) of the MIPs in which the objective function has nonzero coefficients for only continuous variables?

Can ads on a page read my password?

Can I enter a rental property without giving notice if I'm afraid a tenant may be hurt?

Differentiability of operator norm

Best way to explain to my boss that I cannot attend a team summit because it is on Rosh Hashana or any other Jewish Holiday

How does the oscilloscope trigger really work?

Is Odin inconsistent about the powers of Mjolnir?

How to check a file was encrypted (really & correctly)

Does the length of a password for Wi-Fi affect speed?

Why do private jets such as Gulfstream fly higher than other civilian jets?



Game schedule where each player meets only once


Where does Documentation Center introduce the basics?Return only one numeric solution to equationintegrating with multiple indicator functions depending on each otherPiecewise function Syntax error only in debug modeWhere to look up information about some symbols, such as “,”, “[” and “]” (not string)?Where to find order of arguments for default functions






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








2












$begingroup$


I am trying to generate a game schedule where $k$ players at the time, out of $n$ participants, meet in each game, but any player meets another player only once. In each game, with $k$ simultaneous players, the $k$ players compete against each other, there are no multi-player teams.



A 'raw and basic' method for a $(7,3)$-game is shown below, but there must be a more elegant way in Mathematica. It is not very customisable for a general $(n,k)$-game. TIA.



n = 7;
mat = Table[1, x, n, y, n];
For[i = 1, i <= n, i++,
For[j = i + 1, j <= n, j++,
For[k = j + 1, k <= n, k++,
If[mat[[i,j]]*mat[[j,i]]*mat[[i,k]]*mat[[k,i]]*mat[[j,k]]*mat[[k,j]] == 1,
p = i, j, k;
Print [p];
mat[[i,j]] = 0;
mat[[j,i]] = 0;
mat[[i,k]] = 0;
mat[[k,i]] = 0;
mat[[j,k]] = 0;
mat[[k,j]] = 0;
]
]
]
]


Result: 1,2,3, 1,4,5, 1,6,7, 2,4,6, 2,5,7, 3,4,7, 3,5,6.










share|improve this question









$endgroup$




















    2












    $begingroup$


    I am trying to generate a game schedule where $k$ players at the time, out of $n$ participants, meet in each game, but any player meets another player only once. In each game, with $k$ simultaneous players, the $k$ players compete against each other, there are no multi-player teams.



    A 'raw and basic' method for a $(7,3)$-game is shown below, but there must be a more elegant way in Mathematica. It is not very customisable for a general $(n,k)$-game. TIA.



    n = 7;
    mat = Table[1, x, n, y, n];
    For[i = 1, i <= n, i++,
    For[j = i + 1, j <= n, j++,
    For[k = j + 1, k <= n, k++,
    If[mat[[i,j]]*mat[[j,i]]*mat[[i,k]]*mat[[k,i]]*mat[[j,k]]*mat[[k,j]] == 1,
    p = i, j, k;
    Print [p];
    mat[[i,j]] = 0;
    mat[[j,i]] = 0;
    mat[[i,k]] = 0;
    mat[[k,i]] = 0;
    mat[[j,k]] = 0;
    mat[[k,j]] = 0;
    ]
    ]
    ]
    ]


    Result: 1,2,3, 1,4,5, 1,6,7, 2,4,6, 2,5,7, 3,4,7, 3,5,6.










    share|improve this question









    $endgroup$
















      2












      2








      2


      2



      $begingroup$


      I am trying to generate a game schedule where $k$ players at the time, out of $n$ participants, meet in each game, but any player meets another player only once. In each game, with $k$ simultaneous players, the $k$ players compete against each other, there are no multi-player teams.



      A 'raw and basic' method for a $(7,3)$-game is shown below, but there must be a more elegant way in Mathematica. It is not very customisable for a general $(n,k)$-game. TIA.



      n = 7;
      mat = Table[1, x, n, y, n];
      For[i = 1, i <= n, i++,
      For[j = i + 1, j <= n, j++,
      For[k = j + 1, k <= n, k++,
      If[mat[[i,j]]*mat[[j,i]]*mat[[i,k]]*mat[[k,i]]*mat[[j,k]]*mat[[k,j]] == 1,
      p = i, j, k;
      Print [p];
      mat[[i,j]] = 0;
      mat[[j,i]] = 0;
      mat[[i,k]] = 0;
      mat[[k,i]] = 0;
      mat[[j,k]] = 0;
      mat[[k,j]] = 0;
      ]
      ]
      ]
      ]


      Result: 1,2,3, 1,4,5, 1,6,7, 2,4,6, 2,5,7, 3,4,7, 3,5,6.










      share|improve this question









      $endgroup$




      I am trying to generate a game schedule where $k$ players at the time, out of $n$ participants, meet in each game, but any player meets another player only once. In each game, with $k$ simultaneous players, the $k$ players compete against each other, there are no multi-player teams.



      A 'raw and basic' method for a $(7,3)$-game is shown below, but there must be a more elegant way in Mathematica. It is not very customisable for a general $(n,k)$-game. TIA.



      n = 7;
      mat = Table[1, x, n, y, n];
      For[i = 1, i <= n, i++,
      For[j = i + 1, j <= n, j++,
      For[k = j + 1, k <= n, k++,
      If[mat[[i,j]]*mat[[j,i]]*mat[[i,k]]*mat[[k,i]]*mat[[j,k]]*mat[[k,j]] == 1,
      p = i, j, k;
      Print [p];
      mat[[i,j]] = 0;
      mat[[j,i]] = 0;
      mat[[i,k]] = 0;
      mat[[k,i]] = 0;
      mat[[j,k]] = 0;
      mat[[k,j]] = 0;
      ]
      ]
      ]
      ]


      Result: 1,2,3, 1,4,5, 1,6,7, 2,4,6, 2,5,7, 3,4,7, 3,5,6.







      syntax






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 8 hours ago









      mf67mf67

      1756 bronze badges




      1756 bronze badges























          2 Answers
          2






          active

          oldest

          votes


















          6












          $begingroup$

          n = 7;
          k = 3;

          DeleteDuplicates[Subsets[Range @ n, k], Length[Intersection[##]] >= 2 &]



          1, 2, 3, 1, 4, 5, 1, 6, 7, 2, 4, 6, 2, 5, 7, 3, 4, 7, 3, 5, 6







          share|improve this answer









          $endgroup$














          • $begingroup$
            Very compact and 'neat'. Could you please explain what it does? I tried to 'decompile' it but had no luck understanding some of the 'components'.
            $endgroup$
            – mf67
            6 hours ago






          • 1




            $begingroup$
            @mf67, Subsets[Range @ n, k] gives all k-player games, a list of k-tuples , g1,g2,.... Scanning this list from left to right DeleteDuplicates step eliminates all games $g_k$ that contains two or more players from $g_j$ (for $j<k$).
            $endgroup$
            – kglr
            6 hours ago










          • $begingroup$
            I see. Much clearer now. The examples on the Mathematica help pages are often (too) short and do not display the more 'intricate' commands given on this site.
            $endgroup$
            – mf67
            5 hours ago


















          1












          $begingroup$

          n = 7;
          k = 3;


          list all possible games:



          g = Subsets[Range[n], k];


          Find a maximal-size clique of games that don't overlap:



          First@FindClique[AdjacencyGraph[Outer[Boole[Length[Intersection[##]] <= 1] &, g, g, 1]]]
          (* 1, 10, 15, 21, 24, 28, 29 *)


          Which games are these?



          g[[%]]
          (* 1, 2, 3, 1, 4, 5, 1, 6, 7, 2, 4, 6, 2, 5, 7, 3, 4, 7, 3, 5, 6 *)


          This method gives the same result as @kglr's but is much slower, so I don't recommend using it. You can view it as a proof of the other method.






          share|improve this answer











          $endgroup$

















            Your Answer








            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "387"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f203440%2fgame-schedule-where-each-player-meets-only-once%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            6












            $begingroup$

            n = 7;
            k = 3;

            DeleteDuplicates[Subsets[Range @ n, k], Length[Intersection[##]] >= 2 &]



            1, 2, 3, 1, 4, 5, 1, 6, 7, 2, 4, 6, 2, 5, 7, 3, 4, 7, 3, 5, 6







            share|improve this answer









            $endgroup$














            • $begingroup$
              Very compact and 'neat'. Could you please explain what it does? I tried to 'decompile' it but had no luck understanding some of the 'components'.
              $endgroup$
              – mf67
              6 hours ago






            • 1




              $begingroup$
              @mf67, Subsets[Range @ n, k] gives all k-player games, a list of k-tuples , g1,g2,.... Scanning this list from left to right DeleteDuplicates step eliminates all games $g_k$ that contains two or more players from $g_j$ (for $j<k$).
              $endgroup$
              – kglr
              6 hours ago










            • $begingroup$
              I see. Much clearer now. The examples on the Mathematica help pages are often (too) short and do not display the more 'intricate' commands given on this site.
              $endgroup$
              – mf67
              5 hours ago















            6












            $begingroup$

            n = 7;
            k = 3;

            DeleteDuplicates[Subsets[Range @ n, k], Length[Intersection[##]] >= 2 &]



            1, 2, 3, 1, 4, 5, 1, 6, 7, 2, 4, 6, 2, 5, 7, 3, 4, 7, 3, 5, 6







            share|improve this answer









            $endgroup$














            • $begingroup$
              Very compact and 'neat'. Could you please explain what it does? I tried to 'decompile' it but had no luck understanding some of the 'components'.
              $endgroup$
              – mf67
              6 hours ago






            • 1




              $begingroup$
              @mf67, Subsets[Range @ n, k] gives all k-player games, a list of k-tuples , g1,g2,.... Scanning this list from left to right DeleteDuplicates step eliminates all games $g_k$ that contains two or more players from $g_j$ (for $j<k$).
              $endgroup$
              – kglr
              6 hours ago










            • $begingroup$
              I see. Much clearer now. The examples on the Mathematica help pages are often (too) short and do not display the more 'intricate' commands given on this site.
              $endgroup$
              – mf67
              5 hours ago













            6












            6








            6





            $begingroup$

            n = 7;
            k = 3;

            DeleteDuplicates[Subsets[Range @ n, k], Length[Intersection[##]] >= 2 &]



            1, 2, 3, 1, 4, 5, 1, 6, 7, 2, 4, 6, 2, 5, 7, 3, 4, 7, 3, 5, 6







            share|improve this answer









            $endgroup$



            n = 7;
            k = 3;

            DeleteDuplicates[Subsets[Range @ n, k], Length[Intersection[##]] >= 2 &]



            1, 2, 3, 1, 4, 5, 1, 6, 7, 2, 4, 6, 2, 5, 7, 3, 4, 7, 3, 5, 6








            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered 6 hours ago









            kglrkglr

            209k10 gold badges241 silver badges478 bronze badges




            209k10 gold badges241 silver badges478 bronze badges














            • $begingroup$
              Very compact and 'neat'. Could you please explain what it does? I tried to 'decompile' it but had no luck understanding some of the 'components'.
              $endgroup$
              – mf67
              6 hours ago






            • 1




              $begingroup$
              @mf67, Subsets[Range @ n, k] gives all k-player games, a list of k-tuples , g1,g2,.... Scanning this list from left to right DeleteDuplicates step eliminates all games $g_k$ that contains two or more players from $g_j$ (for $j<k$).
              $endgroup$
              – kglr
              6 hours ago










            • $begingroup$
              I see. Much clearer now. The examples on the Mathematica help pages are often (too) short and do not display the more 'intricate' commands given on this site.
              $endgroup$
              – mf67
              5 hours ago
















            • $begingroup$
              Very compact and 'neat'. Could you please explain what it does? I tried to 'decompile' it but had no luck understanding some of the 'components'.
              $endgroup$
              – mf67
              6 hours ago






            • 1




              $begingroup$
              @mf67, Subsets[Range @ n, k] gives all k-player games, a list of k-tuples , g1,g2,.... Scanning this list from left to right DeleteDuplicates step eliminates all games $g_k$ that contains two or more players from $g_j$ (for $j<k$).
              $endgroup$
              – kglr
              6 hours ago










            • $begingroup$
              I see. Much clearer now. The examples on the Mathematica help pages are often (too) short and do not display the more 'intricate' commands given on this site.
              $endgroup$
              – mf67
              5 hours ago















            $begingroup$
            Very compact and 'neat'. Could you please explain what it does? I tried to 'decompile' it but had no luck understanding some of the 'components'.
            $endgroup$
            – mf67
            6 hours ago




            $begingroup$
            Very compact and 'neat'. Could you please explain what it does? I tried to 'decompile' it but had no luck understanding some of the 'components'.
            $endgroup$
            – mf67
            6 hours ago




            1




            1




            $begingroup$
            @mf67, Subsets[Range @ n, k] gives all k-player games, a list of k-tuples , g1,g2,.... Scanning this list from left to right DeleteDuplicates step eliminates all games $g_k$ that contains two or more players from $g_j$ (for $j<k$).
            $endgroup$
            – kglr
            6 hours ago




            $begingroup$
            @mf67, Subsets[Range @ n, k] gives all k-player games, a list of k-tuples , g1,g2,.... Scanning this list from left to right DeleteDuplicates step eliminates all games $g_k$ that contains two or more players from $g_j$ (for $j<k$).
            $endgroup$
            – kglr
            6 hours ago












            $begingroup$
            I see. Much clearer now. The examples on the Mathematica help pages are often (too) short and do not display the more 'intricate' commands given on this site.
            $endgroup$
            – mf67
            5 hours ago




            $begingroup$
            I see. Much clearer now. The examples on the Mathematica help pages are often (too) short and do not display the more 'intricate' commands given on this site.
            $endgroup$
            – mf67
            5 hours ago













            1












            $begingroup$

            n = 7;
            k = 3;


            list all possible games:



            g = Subsets[Range[n], k];


            Find a maximal-size clique of games that don't overlap:



            First@FindClique[AdjacencyGraph[Outer[Boole[Length[Intersection[##]] <= 1] &, g, g, 1]]]
            (* 1, 10, 15, 21, 24, 28, 29 *)


            Which games are these?



            g[[%]]
            (* 1, 2, 3, 1, 4, 5, 1, 6, 7, 2, 4, 6, 2, 5, 7, 3, 4, 7, 3, 5, 6 *)


            This method gives the same result as @kglr's but is much slower, so I don't recommend using it. You can view it as a proof of the other method.






            share|improve this answer











            $endgroup$



















              1












              $begingroup$

              n = 7;
              k = 3;


              list all possible games:



              g = Subsets[Range[n], k];


              Find a maximal-size clique of games that don't overlap:



              First@FindClique[AdjacencyGraph[Outer[Boole[Length[Intersection[##]] <= 1] &, g, g, 1]]]
              (* 1, 10, 15, 21, 24, 28, 29 *)


              Which games are these?



              g[[%]]
              (* 1, 2, 3, 1, 4, 5, 1, 6, 7, 2, 4, 6, 2, 5, 7, 3, 4, 7, 3, 5, 6 *)


              This method gives the same result as @kglr's but is much slower, so I don't recommend using it. You can view it as a proof of the other method.






              share|improve this answer











              $endgroup$

















                1












                1








                1





                $begingroup$

                n = 7;
                k = 3;


                list all possible games:



                g = Subsets[Range[n], k];


                Find a maximal-size clique of games that don't overlap:



                First@FindClique[AdjacencyGraph[Outer[Boole[Length[Intersection[##]] <= 1] &, g, g, 1]]]
                (* 1, 10, 15, 21, 24, 28, 29 *)


                Which games are these?



                g[[%]]
                (* 1, 2, 3, 1, 4, 5, 1, 6, 7, 2, 4, 6, 2, 5, 7, 3, 4, 7, 3, 5, 6 *)


                This method gives the same result as @kglr's but is much slower, so I don't recommend using it. You can view it as a proof of the other method.






                share|improve this answer











                $endgroup$



                n = 7;
                k = 3;


                list all possible games:



                g = Subsets[Range[n], k];


                Find a maximal-size clique of games that don't overlap:



                First@FindClique[AdjacencyGraph[Outer[Boole[Length[Intersection[##]] <= 1] &, g, g, 1]]]
                (* 1, 10, 15, 21, 24, 28, 29 *)


                Which games are these?



                g[[%]]
                (* 1, 2, 3, 1, 4, 5, 1, 6, 7, 2, 4, 6, 2, 5, 7, 3, 4, 7, 3, 5, 6 *)


                This method gives the same result as @kglr's but is much slower, so I don't recommend using it. You can view it as a proof of the other method.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited 6 hours ago

























                answered 6 hours ago









                RomanRoman

                15.2k1 gold badge21 silver badges52 bronze badges




                15.2k1 gold badge21 silver badges52 bronze badges






























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Mathematica Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    Use MathJax to format equations. MathJax reference.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f203440%2fgame-schedule-where-each-player-meets-only-once%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Canceling a color specificationRandomly assigning color to Graphics3D objects?Default color for Filling in Mathematica 9Coloring specific elements of sets with a prime modified order in an array plotHow to pick a color differing significantly from the colors already in a given color list?Detection of the text colorColor numbers based on their valueCan color schemes for use with ColorData include opacity specification?My dynamic color schemes

                    Invision Community Contents History See also References External links Navigation menuProprietaryinvisioncommunity.comIPS Community ForumsIPS Community Forumsthis blog entry"License Changes, IP.Board 3.4, and the Future""Interview -- Matt Mecham of Ibforums""CEO Invision Power Board, Matt Mecham Is a Liar, Thief!"IPB License Explanation 1.3, 1.3.1, 2.0, and 2.1ArchivedSecurity Fixes, Updates And Enhancements For IPB 1.3.1Archived"New Demo Accounts - Invision Power Services"the original"New Default Skin"the original"Invision Power Board 3.0.0 and Applications Released"the original"Archived copy"the original"Perpetual licenses being done away with""Release Notes - Invision Power Services""Introducing: IPS Community Suite 4!"Invision Community Release Notes

                    199年 目錄 大件事 到箇年出世嗰人 到箇年死嗰人 節慶、風俗習慣 導覽選單