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;
$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.
syntax
$endgroup$
add a comment |
$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.
syntax
$endgroup$
add a comment |
$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.
syntax
$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
syntax
asked 8 hours ago
mf67mf67
1756 bronze badges
1756 bronze badges
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
$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
$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 rightDeleteDuplicates
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
add a comment |
$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.
$endgroup$
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
$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
$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 rightDeleteDuplicates
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
add a comment |
$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
$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 rightDeleteDuplicates
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
add a comment |
$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
$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
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 rightDeleteDuplicates
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
add a comment |
$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 rightDeleteDuplicates
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
add a comment |
$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.
$endgroup$
add a comment |
$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.
$endgroup$
add a comment |
$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.
$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.
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
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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