0
$\begingroup$

How can I generate all possible non-duplicate eighttupleList where each element, $a_i$, can be an integer from the set {-2, 0, 2}?

eighttupleList = {{a1, a2, a3, a4, a5, a6, a7, a8}, {a3, a2, a1, a6, a5, 
    a4, a8, a7}, {-a1 - a3, a2, a1, -a4 - a6, a5, a4, -a7 - a8, 
    a7}, {a1, a2, -a1 - a3, a4, a5, -a4 - a6, 
    a7, -a7 - a8}, {-a1 - a3, a2, a3, -a4 - a6, a5, a6, -a7 - a8, 
    a8}, {a3, a2, -a1 - a3, a6, a5, -a4 - a6, a8, -a7 - a8}};

The motivation is similar to my previous thread; I want to group all elements in a list with a pattern.

inputTup = Tuples[{-2, 0, 2}, 8];
eighttupleList = {{a1, a2, a3, a4, a5, a6, a7, a8}, {a3, a2, a1, a6, 
    a5, a4, a8, a7}, {-a1 - a3, a2, a1, -a4 - a6, a5, a4, -a7 - a8, 
    a7}, {a1, a2, -a1 - a3, a4, a5, -a4 - a6, 
    a7, -a7 - a8}, {-a1 - a3, a2, a3, -a4 - a6, a5, a6, -a7 - a8, 
    a8}, {a3, a2, -a1 - a3, a6, a5, -a4 - a6, a8, -a7 - a8}};

If I can generate all eighttupleList, then I basically already gathered inputTup into the eighttupleList pattern.

I can do something like that, but some of them are duplicates.

rule = Thread[{a1, a2, a3, a4, a5, a6, a7, a8} -> #] & /@ Tuples[{-2, 0, 2}, {8}]; 
eighttupleList /. rule
$\endgroup$
8
  • $\begingroup$ When you say "non-duplicate list of tuples", do you mean list of tuples such that that list does not contain the same tuple twice? $\endgroup$
    – thorimur
    Commented Mar 7 at 2:49
  • $\begingroup$ Does eightTupleList[{a1_, a2_, a3_, a4_, a5_, a6_, a7_, a8_}] := {{a1, a2, a3, a4, a5, a6, a7, a8}, {a3, a2, a1, a6, a5, a4, a8, a7}, {-a1 - a3, a2, a1, -a4 - a6, a5, a4, -a7 - a8, a7}, {a1, a2, -a1 - a3, a4, a5, -a4 - a6, a7, -a7 - a8}, {-a1 - a3, a2, a3, -a4 - a6, a5, a6, -a7 - a8, a8}, {a3, a2, -a1 - a3, a6, a5, -a4 - a6, a8, -a7 - a8}}; Select[eightTupleList /@ Tuples[{-2,0,2}, 8], DuplicateFreeQ] do what you expect? $\endgroup$
    – thorimur
    Commented Mar 7 at 2:53
  • $\begingroup$ I meant two eight-tuple lists do not duplicate. For example, I can do something like that, but some of them are duplicates. rule = Thread[{a1, a2, a3, a4, a5, a6, a7, a8} -> #] & /@ Tuples[{-2, 0, 2}, {8}]; eighttupleList /. rule $\endgroup$
    – emnha
    Commented Mar 7 at 2:57
  • $\begingroup$ @thorimur Sorry for the confusion. I have just updated the post to provide more details. $\endgroup$
    – emnha
    Commented Mar 7 at 3:07
  • $\begingroup$ This is still hard to follow. Do you mean like this? Map[DeleteDuplicates, eighttupleList /. rule]? This deletes duplicates in each sublist. $\endgroup$
    – march
    Commented Mar 7 at 16:39

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.