Consider the following problem: Imagine you choose 3 squares out of a 3x3 field. So you can have a line upwords or downwords, two squares downwords and one to the right etc. So let's number every square (see MWE). Now it is just a mathematicaly problem: $binom(9,3)$.

But since the squares all look the same, there is no difference between (1,2,3) and (3,2,1) and so on. So when we take a look here it is a pretty good solution, but we got the problem with the duplicates.

I thought of writing a python script which exoprts the correct permuations into a .csv file and then TikZ or pgfplots(maybe it can be done there, too) can read the file and solve the "square problem".

So my question is: How can I "cross out" the duplicates in order to get sth. like in the MWE?




    \draw (\oxpos,-\oypos) circle(.5) node {#1};
    \draw (\txpos,-\typos) circle(.5) node {#2};
    \draw (\thxpos,-\thypos) circle(.5) node {#3};
        \foreach \x in {1,...,9}

            \draw (\xpos,-\ypos) circle(.5) node {\x};






  • I most likely completely miss the point. But if you were to sort the lists, then you wouldn't have any duplicates because then (1,3,2) and (2,3,1) will all be (1,2,3). What am I doing wrong? And to get all inequivalent sorted lists you could just use texwelt.de/wissen/antwort_link/24383, for instance. – user121799 Mar 12 '19 at 17:13
  • @marmot When I "plot" the results (1,3,2), (2,3,1) and (1,2,3), the output will look the same. So when I plot all results, I would get these duplicates. I want to display all combinations without the repeating sequences in the form of a grid (so (1,2,3) got for example the position (1,1) etc.) It's just a visualisation of all permutations … I hope it's clear now … – current_user Mar 12 '19 at 20:44
  • Yes, but if you would plot the permutation only if the arguments are ascending, you would not plot duplicates. In this case, out of (1,3,2), (2,3,1) and (1,2,3) you would only plot (1,2,3) but suppress the duplicates (1,3,2) and (2,3,1). – user121799 Mar 12 '19 at 20:49
  • @marmot Exactly what I mean! – current_user Mar 12 '19 at 20:50

This draws all the inequivalent combinations.

\begin{tikzpicture}[insert circle/.style={insert path={%
({mod(#1-1,3)*0.75},{int((#1-1)/3)*0.75}) node[circle,draw]{#1}}}]
\foreach \X [evaluate=\X as \Ymin using {int(\X+1)}] in {1,...,9}
{\foreach \Y [evaluate=\Y as \Zmin using {int(\X+1)}]in {\Ymin,...,9}
{\foreach \Z in {\Zmin,...,9}
      \path[insert circle/.list={\X,\Y,\Z}];
\typeout{\number\value{mystep}\space combinations}

enter image description here

| improve this answer | |
  • Nice one, marmot! – voices Jul 10 '19 at 23:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.