<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel rdf:about="https://community.wolfram.com">
    <title>Community RSS Feed</title>
    <link>https://community.wolfram.com</link>
    <description>RSS Feed for Wolfram Community showing any discussions tagged with Discrete Mathematics sorted by most replies.</description>
    <items>
      <rdf:Seq>
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/3027093" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/2397426" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/1569707" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/974303" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/148526" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/966640" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/2214623" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/1063480" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/1395404" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/972050" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/1846418" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/1799757" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/1637345" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/917888" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/893713" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/617724" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/1850612" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/2302672" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/1636014" />
        <rdf:li rdf:resource="https://community.wolfram.com/groups/-/m/t/975898" />
      </rdf:Seq>
    </items>
  </channel>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/3027093">
    <title>[WSG23] Daily Study Group: Introduction to Discrete Mathematics</title>
    <link>https://community.wolfram.com/groups/-/m/t/3027093</link>
    <description>A Wolfram U Daily Study Group on Introduction to Discrete Mathematics begins on **October 16th 2023**. &#xD;
&#xD;
Join me and a group of fellow learners to learn about the mathematics behind the innovations of computer science using the Wolfram Language. Our topics cover the most well-known branches of discrete mathematics, including logic, sets, discrete functions, sequences, combinatorics, algorithms, proofs, recursion and graphs.&#xD;
&#xD;
This study group aims to develop a broad understanding of discrete mathematics, with a focus on concepts useful in computer science, software engineering and programming, and make this rich and useful domain accessible for any college student, professional or interested hobbyist. A basic working knowledge of the Wolfram Language is recommended but not necessary. We are happy to help beginners get up to speed with Wolfram Language using resources already available on Wolfram U.&#xD;
&#xD;
Please feel free to use this thread to collaborate and share ideas, materials and links to other resources with fellow learners.&#xD;
&#xD;
&amp;gt; [**REGISTER HERE**][1]&#xD;
&#xD;
![2 Dimensional Cellular Automaton rule 907486931][2]&#xD;
&#xD;
&#xD;
![Wolfram U Banner][3]&#xD;
&#xD;
&#xD;
  [1]: https://www.bigmarker.com/series/daily-study-group-discrete-math-wsg46/series_details&#xD;
  [2]: https://community.wolfram.com//c/portal/getImageAttachment?filename=907486931.gif&amp;amp;userId=2311323&#xD;
  [3]: https://community.wolfram.com//c/portal/getImageAttachment?filename=banner.jpg&amp;amp;userId=2823613</description>
    <dc:creator>Marc Vicuna</dc:creator>
    <dc:date>2023-10-04T19:10:50Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/2397426">
    <title>Avoiding procedural programming</title>
    <link>https://community.wolfram.com/groups/-/m/t/2397426</link>
    <description>I am very new to Mathematica and have to rethink my &amp;#039;procedural&amp;#039; ways of programming. That is not always easy. I am making progress, but here I have no clue, besides going down the &amp;#039;repeat and if&amp;#039; rabbit hole.&#xD;
&#xD;
I create a list of random integers.&#xD;
I have a Dynamic Slider to adjust delta (between 0 and 20).&#xD;
Let&amp;#039;s say the Slider is adjusted to value 10.&#xD;
&#xD;
Now I want all the integers in the list that are 10 or less apart, to become the same integer.&#xD;
&#xD;
    E.g. myIntegers = {11,28,66,36,94,8,44}&#xD;
&#xD;
After the &amp;#039;treatment&amp;#039; the list should be :&#xD;
{11,28,66,**28**,94,**11**,44}    The 36 is within 10 from 28  and the 8 is also within 10 from 11, so in both cases the integer within the delta range gets to be the value of the first (36 becomes 28). &#xD;
&#xD;
How could I go about this problem in a functional or symbolic way?</description>
    <dc:creator>B. Cornas</dc:creator>
    <dc:date>2021-10-31T16:38:00Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/1569707">
    <title>A prime pencil: truncatable primes</title>
    <link>https://community.wolfram.com/groups/-/m/t/1569707</link>
    <description>![a very prime pencil][1]&#xD;
&#xD;
I just got a set of these pencils, from [Mathsgear][2].&#xD;
The number printed on it is prime, and will remain so as you sharpen the pencil from the left, all the way down to the last digit, 7.&#xD;
Here is a recursive construction of all such *truncatable primes*.&#xD;
&#xD;
    TruncatablePrimes[p_Integer?PrimeQ] :=&#xD;
     With[{digits = IntegerDigits[p]},&#xD;
      {p, TruncatablePrimes /@ (FromDigits /@ (Prepend[digits, #] &amp;amp; /@ Range[9]))}&#xD;
      ];&#xD;
    TruncatablePrimes[p_Integer] := {}&#xD;
&#xD;
   The one on the pencil is the largest one,&#xD;
&#xD;
    In[7]:= Take[Sort[Flatten[TruncatablePrimes /@ Range[9]]], -5]&#xD;
    &#xD;
    Out[7]= {&#xD;
    9918918997653319693967, &#xD;
    57686312646216567629137, &#xD;
    95918918997653319693967, &#xD;
    96686312646216567629137,&#xD;
    357686312646216567629137}&#xD;
    &#xD;
 [1]: https://community.wolfram.com//c/portal/getImageAttachment?filename=IMG_20181212_120939.jpg&amp;amp;userId=143131&#xD;
 [2]: https://mathsgear.co.uk/products/truncatable-prime-pencil</description>
    <dc:creator>Roman Maeder</dc:creator>
    <dc:date>2018-12-12T12:01:36Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/974303">
    <title>Solving Sudoku as an integer programming problem</title>
    <link>https://community.wolfram.com/groups/-/m/t/974303</link>
    <description>It is fairly straight forward to solve a Sudoku as an integer programming problem, by creating 9 binary variables for each cell, only one of which is one in the solution.  The walk-through below and attached notebook illustrates this for the problem shown.&#xD;
&#xD;
![enter image description here][1]&#xD;
&#xD;
# Implementation &#xD;
&#xD;
 Given values, as `{row, column, value}`&#xD;
&#xD;
    input = {&#xD;
    {1,4,4},{1,5,9},{1,8,5},{2,1,6},{2,5,3},{3,1,4},&#xD;
    {3,2,5},{3,4,6},{3,5,2},{3,7,3},{3,9,7},{4,1,5},&#xD;
    {4,3,2},{4,4,7},{4,7,9},{4,8,8},{5,1,3},{5,3,6},&#xD;
    {5,7,2},{5,9,1},{6,2,9},{6,3,1},{6,6,2},{6,7,6},&#xD;
    {6,9,5},{7,1,2},{7,3,5},{7,5,1},{7,6,4},{7,8,3},&#xD;
    {7,9,8},{8,5,8},{8,9,9},{9,2,1},{9,5,7},{9,6,3}};&#xD;
&#xD;
 Display given values&#xD;
&#xD;
    viewmat = Table[&amp;#034;&amp;#034;, {9}, {9}];    &#xD;
    Do[viewmat[[input[[i, 1]], input[[i, 2]]]] = ToString[input[[i, 3]]], {i, Length[input]}]&#xD;
    Grid[viewmat, Frame -&amp;gt; All]&#xD;
&#xD;
![enter image description here][2]&#xD;
&#xD;
 Variables, as 9 x 9 x 9 matrix&#xD;
&#xD;
    varmat = Table[m[i, j, k], {i, 9}, {j, 9}, {k, 9}];&#xD;
&#xD;
 Variables as a list&#xD;
&#xD;
    vars = Flatten[varmat];&#xD;
&#xD;
 Constrain the input cells to their value&#xD;
&#xD;
    cons1 = (varmat[[Sequence @@ #]] == 1 &amp;amp;) /@ input&#xD;
&#xD;
![enter image description here][3]&#xD;
&#xD;
 The sum of the binary variables for each cell is 1&#xD;
&#xD;
    cons2 = Flatten @ Table[ (Sum[varmat[[i, j, k]], {k, 9}] == 1), {i, 9}, {j, 9}];&#xD;
&#xD;
 All different constraint for the rows&#xD;
&#xD;
    cons3 = Flatten @ Table[ (Sum[varmat[[i, j, k]], {i, 9}] == 1), {j, 9}, {k, 9}];&#xD;
&#xD;
 All different constraint for the columns&#xD;
&#xD;
    cons4 = Flatten @ Table[ (Sum[varmat[[i, j, k]], {j, 9}] == 1), {i, 9}, {k, 9}];&#xD;
&#xD;
 All different constraint for the submatrices&#xD;
&#xD;
    sm[di_, dj_] := Flatten [Table[{i, j}, {i, 1 + 3*(di - 1), 3*di}, {j, 1 + 3*(dj - 1), 3*dj}],1]&#xD;
    cons5 = Flatten @ Table[(Total[m[Sequence @@ #, k] &amp;amp; /@ sm[i, j]] == 1), {i, 3}, {j, 3}, {k, 9}];&#xD;
&#xD;
 Confine the variables to the range 0 to 1&#xD;
&#xD;
    cons6 = Thread[0 &amp;lt;= vars &amp;lt;= 1];&#xD;
&#xD;
 Combine the constraints&#xD;
&#xD;
    Length[allcons = Join[cons1, cons2, cons3, cons4, cons5, cons6]]&#xD;
&#xD;
`1089`&#xD;
&#xD;
 Solve the problem, specifying that the variables are integers.&#xD;
&#xD;
    AbsoluteTiming[sol = FindMinimum[{0, allcons, Element[vars, Integers]}, vars];]&#xD;
&#xD;
`{0.0946335, Null}`&#xD;
&#xD;
 Find the values for each cell&#xD;
&#xD;
    resmat = Table[Sum[k*m[i, j, k], {k, 9}], {i, 9}, {j, 9}] /. sol[[2]]&#xD;
&#xD;
![enter image description here][4]&#xD;
&#xD;
 Display the input and result&#xD;
&#xD;
    {Grid[viewmat, Frame -&amp;gt; All], Grid[resmat, Frame -&amp;gt; All]}&#xD;
&#xD;
![enter image description here][5]&#xD;
&#xD;
Check the result &#xD;
&#xD;
    And @@ Table[Unequal[Sequence @@ resmat[[i]]], {i, 9}]&#xD;
&#xD;
`True`&#xD;
&#xD;
    And @@ Table[Unequal[Sequence @@ Transpose[resmat][[i]]], {i, 9}]&#xD;
&#xD;
`True`&#xD;
&#xD;
    And @@ Flatten @ Table[Unequal[resmat[[Sequence @@ #]] &amp;amp; /@ sm[i, j]], {i, 3}, {j, 3}]&#xD;
&#xD;
`True`&#xD;
&#xD;
&#xD;
  [1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=sukoku_problem.jpg&amp;amp;userId=29126&#xD;
  [2]: http://community.wolfram.com//c/portal/getImageAttachment?filename=sdsdf4qehtrngfsbdvsd.png&amp;amp;userId=11733&#xD;
  [3]: http://community.wolfram.com//c/portal/getImageAttachment?filename=sdafq4356y4trett4egqrafzgber.png&amp;amp;userId=11733&#xD;
  [4]: http://community.wolfram.com//c/portal/getImageAttachment?filename=dfg657q43wregdfsbdg.png&amp;amp;userId=11733&#xD;
  [5]: http://community.wolfram.com//c/portal/getImageAttachment?filename=afgdfgtyuiytouuyrter24356.png&amp;amp;userId=11733</description>
    <dc:creator>Frank Kampas</dc:creator>
    <dc:date>2016-12-05T14:23:11Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/148526">
    <title>Chromatic polynomials for custom graphs</title>
    <link>https://community.wolfram.com/groups/-/m/t/148526</link>
    <description>1 ) How to use the math functions over graphs  that are not in the data graph of Mathematica?
2 ) How to compute Chromatic Poynomials for a graph introduced by myself ?</description>
    <dc:creator>Reinaldo Giudici</dc:creator>
    <dc:date>2013-11-04T13:57:36Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/966640">
    <title>Sort pairs that add up to a perfect square?</title>
    <link>https://community.wolfram.com/groups/-/m/t/966640</link>
    <description>To be more specific, I am working on a code to help me find patterns and solve this problem:  Which sets of numbers of size n (starting at one) can be divided into pairs that add up to a perfect square, such that every number has a partner, and there are no repeats?  A simple known solution is 8, because the set 8 can be paired (1,8) (2,7) (3,6) and (4,5) with each pair adding to 9.&#xD;
&#xD;
Here is my code that works:&#xD;
&#xD;
    Remove[&amp;#034;Global`*&amp;#034;]&#xD;
    f[n_] := Permutations[Table[i, {i, 1, n}], {2}]&#xD;
    listfunction[n_] :=&#xD;
     Module[&#xD;
      {},&#xD;
      newlist = {};&#xD;
      duplicates = {};&#xD;
      Do[&#xD;
       If[&#xD;
        f[n][[j, 1]] &amp;lt; f[n][[j, 2]],&#xD;
        AppendTo[ newlist, f[n][[j]]],&#xD;
        AppendTo[duplicates, f[n][[j]]]]&#xD;
       , {j, 1, (n!/(n - 2)!)}]; Module[{},&#xD;
       perfectsquares100 =&#xD;
        Table[x^2, {x, 1, 100}];&#xD;
       possibles = {};&#xD;
       impossibles = {};&#xD;
       Do[&#xD;
        If[&#xD;
         MemberQ[perfectsquares100, newlist[[k, 1]] + newlist[[k, 2]]], &#xD;
         AppendTo[possibles, newlist[[k]]],&#xD;
         AppendTo[impossibles, newlist[[k]]]],&#xD;
        {k, 1, Length[newlist]}]; Print[possibles]]]&#xD;
&#xD;
Which generates the list for n of all the pairs whose sum is a perfect square.&#xD;
&#xD;
So now, I need to whittle that list down to the numbers 1 to n, so that each digit is only represented once, eliminating extra pairs.  &#xD;
&#xD;
This is the code I have come up with to do that, that doesn&amp;#039;t work.&#xD;
*The following code will use the immediate output from the above code.*&#xD;
&#xD;
    finallist[possibles] = Module[{},&#xD;
      rejects = {};&#xD;
      answer = {};&#xD;
      Do[&#xD;
       If[MemberQ[possibles[[h + 1 ;; Length[possibles]]], &#xD;
          possibles[[h, 1]], 2] \[And] &#xD;
         MemberQ[possibles[[h + 1 ;; Length[possibles]]], &#xD;
          possibles[[h, 2]], 2], AppendTo[rejects, possibles[[h]]], &#xD;
        AppendTo[answer, possibles[[h]]]], {h, 1, Length[possibles]}];&#xD;
      Print[answer]]&#xD;
&#xD;
I built the code working from n=8, but when I tried it on n=16, it fails to provide the correct answer.  &#xD;
&#xD;
So, any ideas on what commands might work?</description>
    <dc:creator>Ashley Louk</dc:creator>
    <dc:date>2016-11-19T22:34:47Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/2214623">
    <title>Toward a Foundation of Mathematics based on A New Kind of Science</title>
    <link>https://community.wolfram.com/groups/-/m/t/2214623</link>
    <description>&amp;amp;[Wolfram Notebook][1]&#xD;
&#xD;
&#xD;
  [1]: https://www.wolframcloud.com/obj/e083449a-81bf-418b-83e9-c700f4a6938c</description>
    <dc:creator>José Manuel Rodríguez Caballero</dc:creator>
    <dc:date>2021-03-09T18:09:17Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/1063480">
    <title>Formula for computing sqrt(2) of binary numbers</title>
    <link>https://community.wolfram.com/groups/-/m/t/1063480</link>
    <description>&amp;amp;[Wolfram Notebook][1]&#xD;
&#xD;
&#xD;
  [1]: https://www.wolframcloud.com/obj/373ccb1d-e97f-40ec-aa0a-0d3001c4728d</description>
    <dc:creator>Mariusz Iwaniuk</dc:creator>
    <dc:date>2017-04-16T22:38:51Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/1395404">
    <title>Find the &amp;#034;nth&amp;#034; of a large PrimeNumber?</title>
    <link>https://community.wolfram.com/groups/-/m/t/1395404</link>
    <description>Hi Guys! I hope all of you are fine :) Maybe someone can tell me here how can I find with Wolfram Alpha or Mathematica the nth&amp;#039;s of larger primes? I used &amp;#034;PrimePi&amp;#034;, but &amp;#034;PrimePi&amp;#034; works not with large primes (primes like these 1921773217311523519374373 do not work...too large...). Is there a criterion, method and or a script with which I can find the nth&amp;#039;s of larger primes? &#xD;
&#xD;
I have also used the &amp;#034;nthprime&amp;#034; function, but i think this is not what i need, but when there is a method with the nth prime function to find the &amp;#034;th&amp;#039;s&amp;#034; of larger primes, can someone here show me, how it works? To better understanding what i mean, here an example:&#xD;
&#xD;
 - 2 is the 1(&amp;lt;-i need this number).Primenumber&#xD;
 - 3 is the 2(&amp;lt;-i need this number).Primenumber&#xD;
 - 5 is the 3(&amp;lt;-i need this number).Primenumber&#xD;
 - 7 is the 4(&amp;lt;-i need this number).Primenumber&#xD;
&#xD;
and so on...another example: &#xD;
&#xD;
19 is the 8th (!) Prime, 23 is the 9th (!) Prime, 29 is the 10th (!) Prime... now i need a function to find which prime is 1921773217311523519374373? I need a function to get that out, i hope anybody here has an idea how can i find with WolframAlpha or Mathematica which/what (!) prime is 1921773217311523519374373.&#xD;
 &#xD;
I hope anyone can help me here. Kind regards and best wishes.</description>
    <dc:creator>Nural I.</dc:creator>
    <dc:date>2018-07-31T18:14:09Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/972050">
    <title>Solve for best teams?</title>
    <link>https://community.wolfram.com/groups/-/m/t/972050</link>
    <description>Hello &#xD;
&#xD;
I have an algorithmus which I like to undestand and solve with Mathematica. It is about cooking. You need at least 18 people for it. Each group (2 people) are cooking either appetizer, main dish or dessert at their place. 2 other groups are visiting them. For the other two courses the group is the invited to another hosts&amp;#039; homes. Each location you meet new people (2 new groups). That means at the end you met 6 groups (12 people). Its a lot of fun. I want to organize this for my birthday party. &#xD;
&#xD;
&#xD;
&#xD;
&#xD;
Goal is it, to maximise the happinies factor. Only this way you can make sure, that in each different location you will see new people that you will not meet in the 2 other locations. &#xD;
&#xD;
![enter image description here][2]&#xD;
&#xD;
&#xD;
There are some constrains which we have to consider: &#xD;
&#xD;
&#xD;
&#xD;
I like to know how to handle this problem with Mathematica. Where do I start? Which equation do I have to solve here? I don&amp;#039;t see what I realy need to do...&#xD;
&#xD;
As I sad, you need  minimum 18 people. That means we have 9 teams and 3 major groups. Ok, but I don&amp;#039;t know what to do next and how I implement this in Mathematica. I guess it should not be so difficult but I need some help from you!</description>
    <dc:creator>Peter Parker</dc:creator>
    <dc:date>2016-11-30T23:26:19Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/1846418">
    <title>All possible combinations of x1 + ... + xk = s</title>
    <link>https://community.wolfram.com/groups/-/m/t/1846418</link>
    <description>I have a vague memory of having done this some time ago but I don&amp;#039;t remember the formula. What I need is all possible combinations of positive integers xi (i=1,..,k) that yield s when they are summed. For instance, for k=2 and s=2 there are the 3 combinations {0,2}, {1,1} and {2,0} the first number in a bracket representing x1 and the second x2. This can be done with the code&#xD;
&#xD;
    f[k_, s_] := Module[{c, x},&#xD;
      c = 0;&#xD;
      Do[&#xD;
       If[Sum[x[i], {i, 1, k}] == s, c++],&#xD;
       Evaluate[Apply[Sequence, Table[{x[i], 0, s}, {i, 1, k}]]]];&#xD;
      Return[c]]&#xD;
But I need a fast function as I will calculate it for very big k and s. So this code is too slow. Do you remember the formula involving factorials? Or is there a Mathematica function that does this?</description>
    <dc:creator>Ulrich Utiger</dc:creator>
    <dc:date>2019-12-22T18:06:32Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/1799757">
    <title>See all halomethanes</title>
    <link>https://community.wolfram.com/groups/-/m/t/1799757</link>
    <description># Introduction:&#xD;
&#xD;
*One problem in chemistry is finding all possible molecules, as there are rotations and reflections. All the possibilities of existence of halomethanes (even unstable ones) are addressed here. This is a question similar to the sequence: Doubly triangular numbers (A002817OEIS, N. J. A. Sloane, Apr 18, 2017):* *Number of inequivalent ways to color vertices of a square using &amp;lt;= n colors, allowing rotations and reflections* ... , a(n)=n*(n+1)*(n^ 2+n+2)/8.&#xD;
&#xD;
*However as described in the sequence A002817OEIS, only the total result of the possibilities is addressed, while here in this post I visually demonstrate all possibilities, both in list, 2D and 3D graphs and mass list.*&#xD;
&#xD;
# Function Code:&#xD;
&#xD;
With this function below it is possible to find and visualize **all possibilities of halomethanes**, taking into account all rotations and reflections of the molecules. I developed this function with some options (Mode) besides the list of terms. Examples of options: &amp;#034;Color&amp;#034;, &amp;#034;Visual&amp;#034;, &amp;#034;Visual3D&amp;#034;, &amp;#034;Mass&amp;#034;.&#xD;
&#xD;
Here the function demonstration is done with all halogens (except radioactive halogens, by choice), but any of the  possible elements can be used as an argument in the function. Example: {&amp;#034;H&amp;#034;}, {&amp;#034;F&amp;#034;, &amp;#034;Br&amp;#034;, &amp;#034;I&amp;#034;}, {...} ... {&amp;#034;H&amp;#034;, &amp;#034;F&amp;#034;, &amp;#034;Cl&amp;#034;, &amp;#034;Br&amp;#034;, &amp;#034;I&amp;#034; }.&#xD;
&#xD;
    Halomethanes[elem_, OptionsPattern[]] := &#xD;
     Module[{eleu, z, cc, a, a1, f, rP, ap, n, b}, z = Length@elem; &#xD;
      Options[Halomethanes] = {&amp;#034;Mode&amp;#034; -&amp;gt; &amp;#034;Table&amp;#034;}; eleu = elem[[1]]; &#xD;
      a = Tuples[elem, 4] /. {&amp;#034;Cl&amp;#034; -&amp;gt; &amp;#034;D&amp;#034;, &amp;#034;Br&amp;#034; -&amp;gt; &amp;#034;B&amp;#034;}; n[x_] := {x}; &#xD;
      cc = {&amp;#034;C&amp;#034; -&amp;gt; GrayLevel[0.5], &amp;#034;F&amp;#034; -&amp;gt; RGBColor[1, 0.5, 0.5], &#xD;
        &amp;#034;Cl&amp;#034; -&amp;gt; RGBColor[0, 0.56, 0], &amp;#034;Br&amp;#034; -&amp;gt; RGBColor[0.6, 0.4, 0.2], &#xD;
        &amp;#034;I&amp;#034; -&amp;gt; RGBColor[1, 0, 0], &amp;#034;H&amp;#034; -&amp;gt; RGBColor[0, 1, 1]}; a1 = a[[1]]; &#xD;
      f[a_] := Module[{bt, ct, dt, e1, e2, ft, gt, r1}, &#xD;
        bt = Table[StringJoin[a[[b]]], {b, 1, Length@a}]; &#xD;
        ct = Table[StringJoin@Table[a[[c]], 2], {c, 1, Length@a}]; &#xD;
        dt = Table[&#xD;
          StringJoin[a[[d]][[4]], a[[d]][[3]], a[[d]][[2]], &#xD;
           a[[d]][[1]]], {d, 1, Length@a}]; &#xD;
        e1 = Table[&#xD;
          StringCases[ct[[i]], RegularExpression[bt[[1]]]], {i, 1, &#xD;
           Length@ct}]; &#xD;
        e2 = Table[&#xD;
          StringCases[ct[[i]], RegularExpression[dt[[1]]]], {i, 1, &#xD;
           Length@ct}]; &#xD;
        ft = Table[{Length@(e1[[j]]), &#xD;
            Length@(e2[[j]])} /. {{2, 2} -&amp;gt; bt[[j]], {2, 0} -&amp;gt; &#xD;
             bt[[j]], {0, 2} -&amp;gt; {&amp;#034;copy&amp;#034;}, {0, 0} -&amp;gt; bt[[j]], {2, 1} -&amp;gt; &#xD;
             bt[[j]], {1, 2} -&amp;gt; {&amp;#034;copy&amp;#034;}, {1, 0} -&amp;gt; {&amp;#034;copy&amp;#034;}, {0, &#xD;
              1} -&amp;gt; {&amp;#034;copy&amp;#034;}, {1, 1} -&amp;gt; {&amp;#034;copy&amp;#034;}}, {j, 1, Length@ct}]; &#xD;
        gt = Table[&#xD;
          StringPartition[DeleteCases[ft, {&amp;#034;copy&amp;#034;}][[o]], 1], {o, 1, &#xD;
           Length@DeleteCases[ft, {&amp;#034;copy&amp;#034;}]}]; &#xD;
        r1 = If[gt != {}, If[gt[[1]] == a[[1]], gt[[1]], {}], {}]; {rP = &#xD;
          DeleteCases[r1, {}], &#xD;
         ap = If[r1 != {}, DeleteCases[gt, r1], gt]}]; &#xD;
      Do[b = AppendTo[n[a1], {a = f[a][[2]], f[a][[1]]}[[2]]], &#xD;
       z*(z + 1)*(z^2 + z + 2)/8 - 1]; &#xD;
      OptionValue[&#xD;
        &amp;#034;Mode&amp;#034;] /. {&amp;#034;Table&amp;#034; -&amp;gt; &#xD;
         If[z == 1, {{eleu, eleu, eleu, eleu}}, &#xD;
          b /. {&amp;#034;D&amp;#034; -&amp;gt; &amp;#034;Cl&amp;#034;, &amp;#034;B&amp;#034; -&amp;gt; &amp;#034;Br&amp;#034;}], &#xD;
        &amp;#034;Color&amp;#034; -&amp;gt; {TableForm[{{&amp;#034;H&amp;#034;, &#xD;
             Text[Style[&amp;#034;Cyan&amp;#034;, RGBColor[0, 1, 1], Medium]]}, {&amp;#034;F&amp;#034;, &#xD;
             Text[Style[&amp;#034;Pink&amp;#034;, RGBColor[1, 0.5, 0.5], Medium]]}, {&amp;#034;Cl&amp;#034;, &#xD;
             Text[Style[&amp;#034;Green&amp;#034;, RGBColor[0, 0.56, 0], Medium]]}, {&amp;#034;Br&amp;#034;, &#xD;
             Text[Style[&amp;#034;Brown&amp;#034;, RGBColor[0.6, 0.4, 0.2], Medium]]}, {&amp;#034;I&amp;#034;,&#xD;
              Text[Style[&amp;#034;Red&amp;#034;, RGBColor[1, 0, 0], Medium]]}}, &#xD;
           TableHeadings -&amp;gt; {None, {&amp;#034;Atom&amp;#034;, &amp;#034;Color&amp;#034;}}], &#xD;
          If[z == 1, {Flatten@Table[elem, 4]}, &#xD;
            b /. {&amp;#034;D&amp;#034; -&amp;gt; &amp;#034;Cl&amp;#034;, &amp;#034;B&amp;#034; -&amp;gt; &amp;#034;Br&amp;#034;}] /. cc}, &#xD;
        &amp;#034;Visual&amp;#034; -&amp;gt; &#xD;
         If[z == 1, &#xD;
          MoleculePlot[&#xD;
           Molecule[{&amp;#034;C&amp;#034;, eleu, eleu, eleu, eleu}, {Bond[{1, 2}], &#xD;
             Bond[{1, 3}], Bond[{1, 4}], Bond[{1, 5}]}], ColorRules -&amp;gt; cc,&#xD;
            ImageSize -&amp;gt; 100], &#xD;
          Table[MoleculePlot[&#xD;
            Molecule[&#xD;
             Join[{&amp;#034;C&amp;#034;}, (b /. {&amp;#034;D&amp;#034; -&amp;gt; &amp;#034;Cl&amp;#034;, &amp;#034;B&amp;#034; -&amp;gt; &amp;#034;Br&amp;#034;})[[&#xD;
               h]]], {Bond[{1, 2}], Bond[{1, 3}], Bond[{1, 4}], &#xD;
              Bond[{1, 5}]}], ColorRules -&amp;gt; cc, ImageSize -&amp;gt; 100], {h, 1, &#xD;
            Length@b}]], &#xD;
        &amp;#034;Visual3D&amp;#034; -&amp;gt; &#xD;
         If[z == 1, &#xD;
          MoleculePlot3D[&#xD;
           Molecule[{&amp;#034;C&amp;#034;, eleu, eleu, eleu, eleu}, {Bond[{1, 2}], &#xD;
             Bond[{1, 3}], Bond[{1, 4}], Bond[{1, 5}]}], ColorRules -&amp;gt; cc,&#xD;
            ImageSize -&amp;gt; 100], &#xD;
          Table[MoleculePlot3D[&#xD;
            Molecule[&#xD;
             Join[{&amp;#034;C&amp;#034;}, (b /. {&amp;#034;D&amp;#034; -&amp;gt; &amp;#034;Cl&amp;#034;, &amp;#034;B&amp;#034; -&amp;gt; &amp;#034;Br&amp;#034;})[[&#xD;
               h]]], {Bond[{1, 2}], Bond[{1, 3}], Bond[{1, 4}], &#xD;
              Bond[{1, 5}]}], ColorRules -&amp;gt; cc, ImageSize -&amp;gt; 80], {h, 1, &#xD;
            Length@b}]], &#xD;
        &amp;#034;Mass&amp;#034; -&amp;gt; &#xD;
         If[z == 1, &#xD;
          MoleculeValue[&#xD;
           Molecule[{&amp;#034;C&amp;#034;, eleu, eleu, eleu, eleu}, {Bond[{1, 2}], &#xD;
             Bond[{1, 3}], Bond[{1, 4}], Bond[{1, 5}]}], &amp;#034;MolecularMass&amp;#034;],&#xD;
           Table[MoleculeValue[&#xD;
            Molecule[&#xD;
             Join[{&amp;#034;C&amp;#034;}, (b /. {&amp;#034;D&amp;#034; -&amp;gt; &amp;#034;Cl&amp;#034;, &amp;#034;B&amp;#034; -&amp;gt; &amp;#034;Br&amp;#034;})[[&#xD;
               h]]], {Bond[{1, 2}], Bond[{1, 3}], Bond[{1, 4}], &#xD;
              Bond[{1, 5}]}], &amp;#034;MolecularMass&amp;#034;], {h, 1, Length@b}]]}]&#xD;
&#xD;
# Visualization:&#xD;
&#xD;
- **TERMS TABLE**:&#xD;
&#xD;
In the simplest form, with only one argument, a list of all halomethane molecules is generated.&#xD;
&#xD;
    rp = Halomethanes[{&amp;#034;H&amp;#034;, &amp;#034;F&amp;#034;, &amp;#034;Cl&amp;#034;, &amp;#034;Br&amp;#034;, &amp;#034;I&amp;#034;}]&#xD;
    &#xD;
    Length@rp&#xD;
&#xD;
![im1][1]&#xD;
&#xD;
- **COLOR TABLE**:&#xD;
&#xD;
Optionally, a list of molecules with their respective illustrative colors is generated with the &amp;#034;Mode&amp;#034; -&amp;gt; &amp;#034;Color&amp;#034; option.&#xD;
&#xD;
    Halomethanes[{&amp;#034;H&amp;#034;, &amp;#034;F&amp;#034;, &amp;#034;Cl&amp;#034;, &amp;#034;Br&amp;#034;, &amp;#034;I&amp;#034;}, &amp;#034;Mode&amp;#034; -&amp;gt; &amp;#034;Color&amp;#034;]&#xD;
&#xD;
![im2][2]&#xD;
&#xD;
- **2D VISUAL TABLE**:&#xD;
&#xD;
Optionally, a list of molecules with 2D structural representations is generated with the &amp;#034;Mode&amp;#034; -&amp;gt; &amp;#034;Visual&amp;#034; option (the 2D model can better represent stereoisomerism than the 3D model).&#xD;
&#xD;
    Halomethanes[{&amp;#034;H&amp;#034;, &amp;#034;F&amp;#034;, &amp;#034;Cl&amp;#034;, &amp;#034;Br&amp;#034;, &amp;#034;I&amp;#034;}, &amp;#034;Mode&amp;#034; -&amp;gt; &amp;#034;Visual&amp;#034;]&#xD;
&#xD;
![im3][3]&#xD;
&#xD;
- **3D VISUAL TABLE** (interactive):&#xD;
&#xD;
Optionally, a list of molecules with 3D structural representations is generated with the &amp;#034;Mode&amp;#034; -&amp;gt; &amp;#034;Visual3D&amp;#034; option. This list is interactive, and each molecule can be rotated for better viewing (stereoisomerism is not very well represented in these 3D models as the representations are tetrahedral, for example, the isomers {&amp;#034;H&amp;#034;,&amp;#034;F&amp;#034;,&amp;#034;H&amp;#034;,&amp;#034;F&amp;#034;} and {&amp;#034;F&amp;#034;,&amp;#034;F&amp;#034;,&amp;#034;H,H} are very similar in this view).&#xD;
&#xD;
    Halomethanes[{&amp;#034;H&amp;#034;, &amp;#034;F&amp;#034;, &amp;#034;Cl&amp;#034;, &amp;#034;Br&amp;#034;, &amp;#034;I&amp;#034;}, &amp;#034;Mode&amp;#034; -&amp;gt; &amp;#034;Visual3D&amp;#034;]&#xD;
&#xD;
![im4][4]&#xD;
&#xD;
- **MASS TABLE**:&#xD;
&#xD;
Finally, a list of the masses of all halomethanes can be generated with the argument &amp;#034;Mode&amp;#034; -&amp;gt; &amp;#034;Mass&amp;#034; (some of them, although unstable, are mentioned in the list).&#xD;
&#xD;
    resp2 = Halomethanes[{&amp;#034;H&amp;#034;, &amp;#034;F&amp;#034;, &amp;#034;Cl&amp;#034;, &amp;#034;Br&amp;#034;, &amp;#034;I&amp;#034;}, &amp;#034;Mode&amp;#034; -&amp;gt; &amp;#034;Mass&amp;#034;]&#xD;
&#xD;
![im5][5]&#xD;
&#xD;
Illustrative graph of the mass distributions of all possible halomethanes:&#xD;
&#xD;
    ListPlot[resp2, AxesLabel -&amp;gt; {&amp;#034;n&amp;#034;, &amp;#034;Mass(u)&amp;#034;}, &#xD;
     LabelStyle -&amp;gt; Directive[&amp;#034;Subsubsection&amp;#034;, RGBColor[0.07, 0.5, 0.5]], &#xD;
     PlotLabel -&amp;gt; &amp;#034;Halomethanes Mass&amp;#034;, PlotRange -&amp;gt; {{0, 130}, {0, 550}}, &#xD;
     PlotStyle -&amp;gt; Directive[RGBColor[0.91, 0.08, 0.5], PointSize[Large]], &#xD;
     ImageSize -&amp;gt; Large]&#xD;
&#xD;
![im6][6]&#xD;
&#xD;
**Link**: (Doubly triangular numbers, A002817OEIS, sequence):&#xD;
&#xD;
https://oeis.org/A002817&#xD;
&#xD;
Thanks.&#xD;
&#xD;
&#xD;
  [1]: https://community.wolfram.com//c/portal/getImageAttachment?filename=table1.png&amp;amp;userId=1316061&#xD;
  [2]: https://community.wolfram.com//c/portal/getImageAttachment?filename=tableColor.png&amp;amp;userId=1316061&#xD;
  [3]: https://community.wolfram.com//c/portal/getImageAttachment?filename=graphtest.png&amp;amp;userId=1316061&#xD;
  [4]: https://community.wolfram.com//c/portal/getImageAttachment?filename=visual3D.png&amp;amp;userId=1316061&#xD;
  [5]: https://community.wolfram.com//c/portal/getImageAttachment?filename=tablemass.png&amp;amp;userId=1316061&#xD;
  [6]: https://community.wolfram.com//c/portal/getImageAttachment?filename=graph.png&amp;amp;userId=1316061</description>
    <dc:creator>Claudio Chaib</dc:creator>
    <dc:date>2019-10-03T03:01:17Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/1637345">
    <title>Representation of symmetric group</title>
    <link>https://community.wolfram.com/groups/-/m/t/1637345</link>
    <description>I can&amp;#039;t seem to find any information/algorithms on generating matrix representations of the symmetric group. Can someone point me in the right direction?</description>
    <dc:creator>John Garrison</dc:creator>
    <dc:date>2019-03-22T05:31:30Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/917888">
    <title>Solve a system of recurrence relations?</title>
    <link>https://community.wolfram.com/groups/-/m/t/917888</link>
    <description>Hi all!&#xD;
&#xD;
I&amp;#039;m new to the Wolfram Forum community and it is a pleasure to be here. &#xD;
&#xD;
I have a quick question for those who have expertise in the use of Mathematica....&#xD;
&#xD;
Is Mathematica able to solve the following system of recurrence relations? I&amp;#039;m looking for a &amp;#034;closed-form&amp;#034; formula for w(2n+1).&#xD;
&#xD;
-------------------------------------------------&#xD;
For n greater than or equal to 3,&#xD;
&#xD;
w(2n+1) = a(n+1),&#xD;
a(n) = 3*a(n-1) + a(n-2) - a(n-3),&#xD;
&#xD;
a(0) = 1, a(1) = 2, a(2) = 7, w(1) = 2, w(3) = 7, and w(5) = 22. &#xD;
&#xD;
&#xD;
Any help is greatly appreciated!&#xD;
&#xD;
Sincerely,&#xD;
Richard M. Low &#xD;
&#xD;
richard.low@sjsu.edu</description>
    <dc:creator>Richard Low</dc:creator>
    <dc:date>2016-09-02T22:27:52Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/893713">
    <title>Find natural numbers&amp;gt;0 divisible by 37 using FindInstance?</title>
    <link>https://community.wolfram.com/groups/-/m/t/893713</link>
    <description>As part of a larger Problem I have to find natural numbers&amp;gt;0 that are divisible by 37, which is a trival Problem.&#xD;
I write:&#xD;
&#xD;
    b1[n_] := Divisible[n, 37]&#xD;
    FindInstance[{n &amp;gt; 0, b1[n]}, n, Integers]&#xD;
&#xD;
I get:&#xD;
&#xD;
    FindInstance::naqs: n&amp;gt;0&amp;amp;&amp;amp;Divisible[n,37] is not a quantified system of equations and inequalities. &amp;gt;&amp;gt;&#xD;
&#xD;
The same happens wit Solve. What is wrong with that Code?&#xD;
&#xD;
Actually I have to find numbers which respect a lot of logical conditions, some of them quite complex. That is why I put the conditions into seperate functions.&#xD;
&#xD;
But even if I write:&#xD;
&#xD;
    FindInstance[{n &amp;gt; 0, Divisible[n, 37]}, n, Integers]&#xD;
&#xD;
I get the same error.</description>
    <dc:creator>Werner Geiger</dc:creator>
    <dc:date>2016-07-25T12:11:23Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/617724">
    <title>Understanding result for prime factorization of 25</title>
    <link>https://community.wolfram.com/groups/-/m/t/617724</link>
    <description>Input: &amp;#034;factor 25&amp;#034; (http://www.wolframalpha.com/input/?i=factor+25)&#xD;
-----------------------------------------------------------------&#xD;
**Incorrect result returned:**&#xD;
&#xD;
![Incorrect prime factorization of 25][1]&#xD;
&#xD;
We should get **5^2**&#xD;
&#xD;
&#xD;
**Using *Mathematica* we get the correct factorization**&#xD;
![Prime factorization of 25 using **Mathematica**][2]&#xD;
&#xD;
&#xD;
  [1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=Captura.PNG&amp;amp;userId=410040&#xD;
  [2]: http://community.wolfram.com//c/portal/getImageAttachment?filename=Captura2.PNG&amp;amp;userId=410040&#xD;
Why did Wolfram|Alpha return that result?</description>
    <dc:creator>RorriNator 7</dc:creator>
    <dc:date>2015-11-19T16:46:50Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/1850612">
    <title>Compiled function uses too much memory</title>
    <link>https://community.wolfram.com/groups/-/m/t/1850612</link>
    <description>This algorithm calculates the probability that S of n biological mtMRCA lineages survive after v generations. In the beginning (generation v=1), there are n mothers that have each randomly between 0 and d daughters. I have a fast analytical solution. But I need to check it with this algorithm. The uncompiled function is slow of course, but it does not need much memory. Unfortunately, memory usage of the compiled version is exponential for d &amp;gt; 2, n &amp;gt; 4  and V &amp;gt; 7 for a reason I don&amp;#039;t understand. Can anyone help?&#xD;
&#xD;
    ClearAll[&amp;#034;Global`*&amp;#034;]&#xD;
    Clear[distribution];&#xD;
    distribution = &#xD;
    Compile[{{d, _Integer}, {n, _Integer}, {S, _Integer}, {z, _Integer}, \&#xD;
    {V, _Integer}},&#xD;
      Module[{w, r, v, s, c, K},&#xD;
       w = Table[0, {V}]; r = Table[0, {n}];&#xD;
       Do[&#xD;
        v = 1; s = 0;&#xD;
        Do[&#xD;
         c = RandomInteger[{0, d}];&#xD;
         If[c != 0, s++; r[[k]] = c],&#xD;
         {k, 1, n}];&#xD;
        If[s == S, w[[v]]++];&#xD;
        While[s != 0,&#xD;
         v++; If[v == V, Break[]];&#xD;
         K = s; s = 0;&#xD;
         Do[&#xD;
          c = Total[RandomInteger[{0, d}, r[[k]]]];&#xD;
          If[c != 0, s++; r[[k]] = c],&#xD;
          {k, 1, K}];&#xD;
         If[s == S, w[[v]]++]],&#xD;
        {z}]; Return[Table[{v, w[[v]]/z // N}, {v, 1, V - 1}]]],&#xD;
      CompilationTarget -&amp;gt; &amp;#034;C&amp;#034;]</description>
    <dc:creator>Ulrich Utiger</dc:creator>
    <dc:date>2020-01-01T15:37:56Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/2302672">
    <title>Graphing a large set of Pythagorean triples</title>
    <link>https://community.wolfram.com/groups/-/m/t/2302672</link>
    <description>Sorry, I need to give more info on my problem.&#xD;
&#xD;
I have a large set of primitive Pythagorean triples, generated by the code in the PrimitivePythagoreanTriple.nb:&#xD;
&#xD;
    prim=With[{max=100},\[IndentingNewLine]Map[Last,List@@(Reduce[x^2+y^2\[Equal]z^2 &amp;amp;&amp;amp; 0&amp;lt; x &amp;lt; y &amp;lt;max&amp;amp;&amp;amp;0&amp;lt;z&amp;lt;max &amp;amp;&amp;amp;GCD[x,y,z]\[Equal]1,{x,y,z},Integers,Backsubstitution-&amp;gt;True]/.And:&amp;gt;List),{2}]]&#xD;
&#xD;
I wish to graph this discrete set in the xy-plane using  **ListPlot** (after I add  Table[ ... ] to the resulting set of pairs).&#xD;
&#xD;
This requires changing the triples {x,y,z} to pairs {x,y}, same first and second coordinates.  &#xD;
I can do it on a single triple, obviously, but how do I write a code to make the new list of pairs from the list of triples?  &#xD;
&#xD;
Here&amp;#039;s a sample of what the outcome should look like (see attached).&#xD;
&#xD;
I&amp;#039;ve tried everything I can find and/or think of.  &#xD;
Any suggestions will be appreciated.  &#xD;
&#xD;
Thanks,  &#xD;
JP</description>
    <dc:creator>James Parks</dc:creator>
    <dc:date>2021-06-30T16:32:06Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/1636014">
    <title>Get symbolic expressions for summing sequences?</title>
    <link>https://community.wolfram.com/groups/-/m/t/1636014</link>
    <description>Hello!&#xD;
&#xD;
Let&amp;#039;s say that I am having this sequence:&#xD;
&#xD;
    a(n) = 2*a(n-1) - a(n-2) + 2*a(n-3) + a(n-4) + a(n-5) - a(n-7) - a(n-8)&#xD;
&#xD;
with  a[1] == 1, a[2] == 1, a[3] == 1,  a[4] == 2, a[5] == 6, a[6] == 14, a[7] == 28,  a[8] == 56 as the base cases.&#xD;
&#xD;
Now, I want to find the sum of a(1)^3 + a(2)^3 + .... + a(n)^3 SYMBOLICALLY, with respect to the first 8 base cases. There will be of course some cross terms ie. a(1)*a(2), etc, but it should be in terms of only the first 8 base cases.&#xD;
&#xD;
I can use the RecurrenceTable and Total for finding numbers, but how can I do it symbolically and also simplify it to only the first 8 base cases?&#xD;
&#xD;
Thank you very much in advance.</description>
    <dc:creator>Thanos Papas</dc:creator>
    <dc:date>2019-03-19T15:37:21Z</dc:date>
  </item>
  <item rdf:about="https://community.wolfram.com/groups/-/m/t/975898">
    <title>LinearProgramming approach for &amp;#034;best teams&amp;#034; algorithm</title>
    <link>https://community.wolfram.com/groups/-/m/t/975898</link>
    <description>Here is the solution I outlined in my comments for this problem: [Solve algorithm for best teams?][1]&#xD;
&#xD;
I do find the original formulation in the discussion opening inconsistent. The constraint formulations below are slightly different from the ones in OP&amp;#039;s descriptions. The approach allows relatively easily the constraints to be changed or other constraints to be added.&#xD;
&#xD;
The constraints and objective function were programmed in a way that allows the finding of the number groups for different number of teams and number of courses.&#xD;
&#xD;
For another, detailed explanation of the used approach see&#xD;
[this answer](http://mathematica.stackexchange.com/questions/111725/how-to-fill-a-grid-make-its-total-be-largest/112210#112210) of the&#xD;
Mathematica Stackexchange question [&amp;#034;How to fill a grid make its total be largest&amp;#034;](http://mathematica.stackexchange.com/q/111725/34008). &#xD;
&#xD;
# Original Formulation &#xD;
&#xD;
&amp;gt; The problem is about cooking. You need at least 18 people for it. Each group (2 people) are cooking either appetizer, main dish or dessert at their place. 2 other groups are visiting them. For the other two courses the group is the invited to another hosts&amp;#039; homes. Each location you meet new people (2 new groups). That means at the end you met 6 groups (12 people). &#xD;
&#xD;
![enter image description here][2]&#xD;
&#xD;
# New Formulation&#xD;
&#xD;
## Variables&#xD;
&#xD;
#### Number of variables&#xD;
&#xD;
Assuming the number of groups is un-known we can select a large number for `ng` and then include the corresponding variables in the conditions and objective function.&#xD;
&#xD;
Number of teams:&#xD;
&#xD;
    nt = 9;&#xD;
&#xD;
Number of groups:&#xD;
&#xD;
    ng = 6;&#xD;
&#xD;
Number of courses:&#xD;
&#xD;
    nc = 3;&#xD;
&#xD;
#### Variable arrays&#xD;
&#xD;
    Clear[t, g, c, vt, vg, vc]&#xD;
&#xD;
Binary variables telling that $i$-th team is going to be used (formed).&#xD;
&#xD;
    vt = Array[t, nt];&#xD;
&#xD;
Binary variables telling that $i$-th group is going to be used (formed).&#xD;
&#xD;
    vg = Array[g, ng];&#xD;
&#xD;
Binary variable for &#xD;
&#xD;
    vc = Array[c, nc];&#xD;
&#xD;
#### Teams in groups&#xD;
    Clear[ctg, vctg]&#xD;
&#xD;
Each group has three teams. Each team is assigned to exactly one group per course.&#xD;
&#xD;
Binary variables:&#xD;
&#xD;
    vctg = Flatten@Table[ctg[ci, ti, gi], {ci, nc}, {ti, nt}, {gi, ng}];&#xD;
    Length[vctg]&#xD;
    (* 162 *)&#xD;
&#xD;
#### Chefs&#xD;
&#xD;
    Clear[ch, vch]&#xD;
&#xD;
Each team can be the chef for a given group and course. There is only one chef per group and course pair.&#xD;
&#xD;
Binary variable:&#xD;
&#xD;
    vch = Flatten@Table[ch[ci, ti, gi], {ci, nc}, {ti, nt}, {gi, ng}];&#xD;
    Length[vch]&#xD;
&#xD;
    (* 162 *)&#xD;
&#xD;
#### Happiness&#xD;
&#xD;
Happiness of team $t_i$ to prepare course $c_j$&#xD;
&#xD;
    Clear[H, vh]&#xD;
    vh = Flatten@Table[H[ci, ci], {ci, nc}, {ti, nt}];&#xD;
    Do[H[ci, ti] = RandomInteger[{0, 3}], {ci, nc}, {ti, nt}]&#xD;
&#xD;
## Constraints&#xD;
&#xD;
#### Each team should have 3 courses&#xD;
&#xD;
Each team should have 3 ($nc$) courses. &#xD;
&#xD;
    eachTeamHadFullMeal = &#xD;
      Flatten@Table[Sum[ctg[ci, ti, gi], {gi, ng}, {ci, nc}] == nc, {ti, nt}];&#xD;
    Length[eachTeamHadFullMeal]&#xD;
    (*eachTeamHadFullMeal[[1;;2]]*)&#xD;
&#xD;
    (* 9 *)&#xD;
#### Each team is assigned to one group per course.&#xD;
&#xD;
Each team is assigned to one group per course.&#xD;
&#xD;
    oneGroupPerTeamPerCourse = &#xD;
      Flatten@Table[&#xD;
        Sum[ctg[ci, ti, gi], {gi, ng}] == 1, {ti, nt}, {ci, nc}];&#xD;
    Length[oneGroupPerTeamPerCourse]&#xD;
    oneGroupPerTeamPerCourse[[1 ;; 2]]&#xD;
&#xD;
    (* 27 *)&#xD;
&#xD;
    (* {ctg[1, 1, 1] + ctg[1, 1, 2] + ctg[1, 1, 3] + ctg[1, 1, 4] + &#xD;
    ctg[1, 1, 5] + ctg[1, 1, 6] == 1, &#xD;
    ctg[2, 1, 1] + ctg[2, 1, 2] + ctg[2, 1, 3] + ctg[2, 1, 4] + &#xD;
    ctg[2, 1, 5] + ctg[2, 1, 6] == 1} *)&#xD;
&#xD;
#### Each group has three teams.&#xD;
&#xD;
Each group has three teams.&#xD;
&#xD;
    threeTeamsPerGroupPerCourse = &#xD;
      Flatten@Table[&#xD;
        Sum[ctg[ci, ti, gi], {ti, nt}] - 3 g[gi] == 0, {gi, ng}, {ci, &#xD;
         nc}];&#xD;
    Length[threeTeamsPerGroupPerCourse]&#xD;
    threeTeamsPerGroupPerCourse[[1 ;; 2]]&#xD;
&#xD;
    (* 18 *)&#xD;
&#xD;
    (* {ctg[1, 1, 1] + ctg[1, 2, 1] + ctg[1, 3, 1] + ctg[1, 4, 1] + &#xD;
    ctg[1, 5, 1] + ctg[1, 6, 1] + ctg[1, 7, 1] + ctg[1, 8, 1] + &#xD;
    ctg[1, 9, 1] - 3 g[1] == 0, &#xD;
    ctg[2, 1, 1] + ctg[2, 2, 1] + ctg[2, 3, 1] + ctg[2, 4, 1] + &#xD;
    ctg[2, 5, 1] + ctg[2, 6, 1] + ctg[2, 7, 1] + ctg[2, 8, 1] + &#xD;
    ctg[2, 9, 1] - 3 g[1] == 0} *)&#xD;
&#xD;
#### There can be only one chef per group per course.&#xD;
&#xD;
There can be only one chef per group per course. Not every team has to be a chef of a course.&#xD;
&#xD;
    oneChefPerGroupPerCourse = &#xD;
      Flatten@Table[&#xD;
        Sum[ch[ci, ti, gi], {ti, nt}] - 1 g[gi] == 0, {gi, ng}, {ci, nc}];&#xD;
    Length[oneChefPerGroupPerCourse]&#xD;
    oneChefPerGroupPerCourse[[1 ;; 3]]&#xD;
&#xD;
    (* 18 *)&#xD;
&#xD;
    (* {ch[1, 1, 1] + ch[1, 2, 1] + ch[1, 3, 1] + ch[1, 4, 1] + ch[1, 5, 1] +&#xD;
     ch[1, 6, 1] + ch[1, 7, 1] + ch[1, 8, 1] + ch[1, 9, 1] - g[1] == 0,&#xD;
     ch[2, 1, 1] + ch[2, 2, 1] + ch[2, 3, 1] + ch[2, 4, 1] + &#xD;
     ch[2, 5, 1] + ch[2, 6, 1] + ch[2, 7, 1] + ch[2, 8, 1] + &#xD;
     ch[2, 9, 1] - g[1] == 0, &#xD;
     ch[3, 1, 1] + ch[3, 2, 1] + ch[3, 3, 1] + ch[3, 4, 1] + ch[3, 5, 1] +&#xD;
     ch[3, 6, 1] + ch[3, 7, 1] + ch[3, 8, 1] + ch[3, 9, 1] - g[1] == 0} *)&#xD;
&#xD;
#### Connect the $\text{ch}$ variables with $\text{ctg}$ variables.&#xD;
&#xD;
    connectChefTGAndCourseTG = &#xD;
      Flatten@Table[-ch[ci, ti, gi] + ctg[ci, ti, gi] &amp;gt;= 0, {ci, nc}, {ti,&#xD;
          nt}, {gi, ng}];&#xD;
    Length[connectChefTGAndCourseTG]&#xD;
    connectChefTGAndCourseTG[[1 ;; 3]]&#xD;
&#xD;
    (* 162 *)&#xD;
 &#xD;
    (* {-ch[1, 1, 1] + ctg[1, 1, 1] &amp;gt;= 0, -ch[1, 1, 2] + ctg[1, 1, 2] &amp;gt;= 0, -ch[1, 1, 3] + ctg[1, 1, 3] &amp;gt;= 0} *)&#xD;
&#xD;
#### Set any team to be a chef only once.&#xD;
&#xD;
Set any team to be a chef only once. (I think this means *at most once* given the previous constraint verbal formulation.)&#xD;
&#xD;
    anyTeamChefAtMostOnce = &#xD;
      Table[Sum[ch[ci, ti, gi], {gi, ng}, {ci, nc}] &amp;lt;= 1, {ti, nt}];&#xD;
    Length[anyTeamChefAtMostOnce]&#xD;
    anyTeamChefAtMostOnce[[1 ;; 2]]&#xD;
&#xD;
    (* 9 *)&#xD;
&#xD;
    (* {ch[1, 1, 1] + ch[1, 1, 2] + ch[1, 1, 3] + ch[1, 1, 4] + ch[1, 1, 5] +&#xD;
    ch[1, 1, 6] + ch[2, 1, 1] + ch[2, 1, 2] + ch[2, 1, 3] + &#xD;
    ch[2, 1, 4] + ch[2, 1, 5] + ch[2, 1, 6] + ch[3, 1, 1] + &#xD;
    ch[3, 1, 2] + ch[3, 1, 3] + ch[3, 1, 4] + ch[3, 1, 5] + &#xD;
    ch[3, 1, 6] &amp;lt;= 1, &#xD;
    ch[1, 2, 1] + ch[1, 2, 2] + ch[1, 2, 3] + ch[1, 2, 4] + ch[1, 2, 5] +&#xD;
    ch[1, 2, 6] + ch[2, 2, 1] + ch[2, 2, 2] + ch[2, 2, 3] + &#xD;
    ch[2, 2, 4] + ch[2, 2, 5] + ch[2, 2, 6] + ch[3, 2, 1] + &#xD;
    ch[3, 2, 2] + ch[3, 2, 3] + ch[3, 2, 4] + ch[3, 2, 5] + &#xD;
    ch[3, 2, 6] &amp;lt;= 1} *)&#xD;
&#xD;
#### Team in group cap, less than 4&#xD;
&#xD;
    teamInGroup = &#xD;
      Table[Sum[ctg[ci, ti, gi], {ci, nc}, {gi, ng}] &amp;lt;= 4, {ti, nt}];&#xD;
    Length[teamInGroup]&#xD;
    teamInGroup[[1 ;; 2]]&#xD;
&#xD;
    (* 9 *)&#xD;
&#xD;
    (* {ctg[1, 1, 1] + ctg[1, 1, 2] + ctg[1, 1, 3] + ctg[1, 1, 4] + &#xD;
     ctg[1, 1, 5] + ctg[1, 1, 6] + ctg[2, 1, 1] + ctg[2, 1, 2] + &#xD;
     ctg[2, 1, 3] + ctg[2, 1, 4] + ctg[2, 1, 5] + ctg[2, 1, 6] + &#xD;
     ctg[3, 1, 1] + ctg[3, 1, 2] + ctg[3, 1, 3] + ctg[3, 1, 4] + &#xD;
     ctg[3, 1, 5] + ctg[3, 1, 6] &amp;lt;= 4, &#xD;
     ctg[1, 2, 1] + ctg[1, 2, 2] + ctg[1, 2, 3] + ctg[1, 2, 4] + &#xD;
     ctg[1, 2, 5] + ctg[1, 2, 6] + ctg[2, 2, 1] + ctg[2, 2, 2] + &#xD;
     ctg[2, 2, 3] + ctg[2, 2, 4] + ctg[2, 2, 5] + ctg[2, 2, 6] + &#xD;
     ctg[3, 2, 1] + ctg[3, 2, 2] + ctg[3, 2, 3] + ctg[3, 2, 4] + &#xD;
     ctg[3, 2, 5] + ctg[3, 2, 6] &amp;lt;= 4} *)&#xD;
&#xD;
#### All variables are binary&#xD;
&#xD;
All variables are binary constraints. Needed if `Maximize` is used.&#xD;
&#xD;
    varConstraints = Map[0 &amp;lt;= # &amp;lt;= 1 &amp;amp;, Join[vctg, vch, vg]];&#xD;
    varConstraints[[1 ;; 4]]&#xD;
&#xD;
    (* {0 &amp;lt;= ctg[1, 1, 1] &amp;lt;= 1, 0 &amp;lt;= ctg[1, 1, 2] &amp;lt;= 1, &#xD;
      0 &amp;lt;= ctg[1, 1, 3] &amp;lt;= 1, 0 &amp;lt;= ctg[1, 1, 4] &amp;lt;= 1} *)&#xD;
&#xD;
### Objective function&#xD;
&#xD;
    objFunc =&#xD;
      Sum[H[ci, ti] ch[ci, ti, gi], {ti, nt}, {ci, nc}, {gi, ng}];&#xD;
&#xD;
We can use this objective function in order to minimize the number of groups:&#xD;
&#xD;
    objFuncMinNG = &#xD;
      Sum[H[ci, ti] ch[ci, ti, gi], {ti, nt}, {ci, nc}, {gi, ng}] - Total[vg];  &#xD;
&#xD;
# Solving with LinearProgramming&#xD;
&#xD;
Using `Maximize` is very slow, so we have to convert the conditions into matrix-vector formulation to be given to `LinearProgramming`. &#xD;
&#xD;
All variables&#xD;
&#xD;
    vars = Join[vctg, vch, vg];&#xD;
    Length[vars]&#xD;
&#xD;
    (* 330 *)&#xD;
&#xD;
## Convert conditions to matrices&#xD;
&#xD;
    {zeroMat, mat0} = CoefficientArrays[eachTeamHadFullMeal[[All, 1]], vars];&#xD;
    Dimensions[mat0]&#xD;
&#xD;
    {zeroMat, mat1} = &#xD;
      CoefficientArrays[oneGroupPerTeamPerCourse[[All, 1]], vars];&#xD;
    Dimensions[mat1]&#xD;
&#xD;
    {zeroMat, mat2} = &#xD;
      CoefficientArrays[threeTeamsPerGroupPerCourse[[All, 1]], vars];&#xD;
    Dimensions[mat2]&#xD;
&#xD;
    {zeroMat, mat3} = &#xD;
      CoefficientArrays[oneChefPerGroupPerCourse[[All, 1]], vars];&#xD;
    Dimensions[mat3]&#xD;
&#xD;
    {zeroMat, mat4} = &#xD;
      CoefficientArrays[connectChefTGAndCourseTG[[All, 1]], vars];&#xD;
    Dimensions[mat4]&#xD;
&#xD;
    {zeroMat, mat5} = &#xD;
      CoefficientArrays[anyTeamChefAtMostOnce[[All, 1]], vars];&#xD;
    Dimensions[mat5]&#xD;
&#xD;
    {zeroMat, mat6} = CoefficientArrays[teamInGroup[[All, 1]], vars];&#xD;
    Dimensions[mat6]&#xD;
&#xD;
    bVec =&#xD;
      Join[&#xD;
       Table[{nc, 0}, {Dimensions[mat0][[1]]}],&#xD;
       Table[{1, 0}, {Dimensions[mat1][[1]]}],&#xD;
       Table[{0, 0}, {Dimensions[mat2][[1]]}],&#xD;
       Table[{0, 0}, {Dimensions[mat3][[1]]}],&#xD;
       Table[{0, 1}, {Dimensions[mat4][[1]]}],&#xD;
       Table[{1, -1}, {Dimensions[mat5][[1]]}],&#xD;
       Table[{4, -1}, {Dimensions[mat6][[1]]}]&#xD;
       ];&#xD;
    Length[bVec]&#xD;
&#xD;
    condMat = Join[mat0, mat1, mat2, mat3, mat4, mat5, mat6];&#xD;
    MatrixQ[condMat]&#xD;
&#xD;
    MatrixPlot[condMat]&#xD;
&#xD;
![enter image description here][3]&#xD;
&#xD;
    objVec = Normal@CoefficientArrays[{objFunc}, vars][[2]][[1]];&#xD;
    Length[objVec]&#xD;
    (* 330 *)&#xD;
&#xD;
&#xD;
## Solving&#xD;
&#xD;
    AbsoluteTiming[&#xD;
     nsol = LinearProgramming[-objVec, condMat, bVec, &#xD;
        Table[{0, 1}, {Length[vars]}], Integers];&#xD;
     ]&#xD;
    (* {0.063444, Null} *)&#xD;
&#xD;
    objVec.nsol&#xD;
    (* 23 *)&#xD;
&#xD;
    sol = Thread[vars -&amp;gt; nsol];&#xD;
&#xD;
# Tabulate solution&#xD;
&#xD;
## Find non-zero groups&#xD;
&#xD;
    gnzInds = &#xD;
      Table[Sum[ctg[ci, ti, gi], {ci, nc}, {ti, nt}] &amp;gt; 0, {gi, ng}] /. sol;&#xD;
    gnzInds = Pick[Range[ng], gnzInds]&#xD;
&#xD;
## Tabulation per group&#xD;
 &#xD;
This package is for the function `CrossTabulate`.&#xD;
&#xD;
    Import[&amp;#034;https://raw.githubusercontent.com/antononcube/MathematicaForPrediction/master/MathematicaForPredictionUtilities.m&amp;#034;]&#xD;
&#xD;
In red are the chef team assigments.&#xD;
&#xD;
    Table[&#xD;
     Column[{Row[{&amp;#034;group:&amp;#034;, gi}], &#xD;
       mf = MatrixForm[&#xD;
         CrossTabulate[&#xD;
          Flatten[Table[{&amp;#034;team:&amp;#034; &amp;lt;&amp;gt; ToString[ti], &#xD;
              &amp;#034;course:&amp;#034; &amp;lt;&amp;gt; ToString[ci], ctg[ci, ti, gi]}, {ti, nt}, {ci, &#xD;
              nc}] /. sol, 1]]];&#xD;
       Do[If[(ch[ci, ti, gi] /. sol) == 1, &#xD;
         mf[[1, ti, ci]] = Style[mf[[1, ti, ci]], Red]], {ti, nt}, {ci, nc}];&#xD;
       mf&#xD;
       }],&#xD;
     {gi, gnzInds}]&#xD;
   &#xD;
![enter image description here][4]&#xD;
&#xD;
# Visualize the solution&#xD;
&#xD;
Here is a solution visualization with a graph plot:&#xD;
&#xD;
    graphEdges = &#xD;
      Map[Labeled[(&amp;#034;team:&amp;#034; &amp;lt;&amp;gt; ToString[#[[2]]]) -&amp;gt; (&amp;#034;group:&amp;#034; &amp;lt;&amp;gt; &#xD;
            ToString[#[[3]]]), &amp;#034;course:&amp;#034; &amp;lt;&amp;gt; ToString[#[[1]]]] &amp;amp;, &#xD;
       Cases[sol, HoldPattern[ctg[___] -&amp;gt; 1], \[Infinity]][[All, 1]]];&#xD;
    &#xD;
    vertices = Union[Flatten[List @@@ graphEdges[[All, 1]]]];&#xD;
    &#xD;
    vcoords =&#xD;
      Join[&#xD;
       Block[{t = Flatten@StringCases[vertices, &amp;#034;group:&amp;#034; ~~ ___]}, &#xD;
        MapIndexed[# -&amp;gt; 0.3 {Cos[#2[[1]] 2 \[Pi]/Length[t]], Sin[#2[[1]] 2 \[Pi]/Length[t]]} &amp;amp;, t]], &#xD;
       Block[{t = Flatten@StringCases[vertices, &amp;#034;team:&amp;#034; ~~ ___]}, &#xD;
        MapIndexed[# -&amp;gt; 0.7 {Cos[#2[[1]] 2 \[Pi]/Length[t]], Sin[#2[[1]] 2 \[Pi]/Length[t]]} &amp;amp;, t]]&#xD;
       ];&#xD;
    &#xD;
    Legended[&#xD;
     GraphPlot[List @@@ graphEdges,&#xD;
      MultiedgeStyle -&amp;gt; All,&#xD;
      VertexRenderingFunction -&amp;gt; ({If[StringMatchQ[#2, &amp;#034;team:&amp;#034; ~~ __], &#xD;
           RGBColor[0.8, 0.8, 1], RGBColor[1, 0.8, 0.8]], EdgeForm[Black],&#xD;
           Rectangle[# - {0.1, 0.05}, # + {0.1, 0.05}], Black, &#xD;
          Text[#2, #1]} &amp;amp;),&#xD;
      VertexCoordinateRules -&amp;gt; vcoords,&#xD;
      EdgeRenderingFunction -&amp;gt; (With[{cind = &#xD;
            ToExpression[&#xD;
             StringCases[#3, &amp;#034;course:&amp;#034; ~~ x__ :&amp;gt; x][[1]]]}, {{Green, &#xD;
             Brown, Pink}[[cind]], Line[#], Black, &#xD;
           Inset[cind, Mean[#], Automatic, Automatic, #[[1]] - #[[2]], &#xD;
            Background -&amp;gt; White]}] &amp;amp;),&#xD;
      ImageSize -&amp;gt; 900],&#xD;
     Thread[{Green, Brown, Pink} -&amp;gt; &#xD;
       Map[&amp;#034;course:&amp;#034; &amp;lt;&amp;gt; ToString[#] &amp;amp;, Range[nc]]]]&#xD;
&#xD;
![enter image description here][5]&#xD;
&#xD;
&#xD;
  [1]: http://community.wolfram.com/groups/-/m/t/972050&#xD;
  [2]: http://community.wolfram.com//c/portal/getImageAttachment?filename=SADFETRHSGBDFV.png&amp;amp;userId=11733&#xD;
  [3]: http://community.wolfram.com//c/portal/getImageAttachment?filename=Hplnz8cm.png&amp;amp;userId=143837&#xD;
  [4]: http://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2016-12-05at10.13.42PM.png&amp;amp;userId=143837&#xD;
  [5]: http://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2016-12-09at7.07.44AM.png&amp;amp;userId=143837</description>
    <dc:creator>Anton Antonov</dc:creator>
    <dc:date>2016-12-07T21:06:58Z</dc:date>
  </item>
</rdf:RDF>

