Skip to main content
Added new solution using information in edited question
Source Link
MarcoB
  • 67.7k
  • 18
  • 96
  • 198

UPDATE:

You request no duplication in the rows, but duplication is possible in the columns. We can achieve that using RandomChoice instead of RandomSample to generate the permutations. After generation of a new list, we check that each row is free of duplicates; if not, we generate a new one until we get an appropriate new list. The following uses your definitions of the lists:

N1 = 4; N2 = 5; N3 = 7;

Do[
 newlist = RandomChoice[#, 7] & /@ {list1, list2, list3} // Transpose;
 If[And @@ (DuplicateFreeQ /@ newlist), Return[newlist]],
 200
]

If[
 And @@ (DuplicateFreeQ /@ newlist),
 {Sequence @@ #, Norm[#]} & /@ newlist,
 "no good list found"
]

The $200$ at the end of Do is there to avoid infinite loops; if no duplicate-free lists are generated, the process stops anyway after that number of attempts.


Old Answer:

If you lists had the same length, e.g. by setting:

N1 = 7; N2 = 7; N3 = 7;

Then a simple way of achieving what you want would be the following

RandomSample /@ {list1, list2, list3} // Transpose;
{Sequence @@ #, Norm[#]} & /@ %

{{-(15/7), -(15/7), 0}, {-(3/7), -(3/7), 3/7}, {-(6/7), 3/7, -(12/7)}, {3/7, -(6/7), -(15/7)}, {-(12/7), 0, -(3/7)}, {-(9/7), -(9/7), -(9/7)}, {0, -(12/7), -(6/7)}}

{{-(15/7), -(15/7), 0, (15 Sqrt[2])/7}, {-(3/7), -(3/7), 3/7, (3 Sqrt[3])/7}, {-(6/7), 3/7, -(12/7), 3 Sqrt[3/7]}, {3/7, -(6/7), -(15/7), (3 Sqrt[30])/7}, {-(12/7), 0, -(3/7), (3 Sqrt[17])/7}, {-(9/7), -(9/7), -(9/7), (9 Sqrt[3])/7}, {0, -(12/7), -(6/7), (6 Sqrt[5])/7}}

If you lists had the same length, e.g. by setting:

N1 = 7; N2 = 7; N3 = 7;

Then a simple way of achieving what you want would be the following

RandomSample /@ {list1, list2, list3} // Transpose;
{Sequence @@ #, Norm[#]} & /@ %

{{-(15/7), -(15/7), 0}, {-(3/7), -(3/7), 3/7}, {-(6/7), 3/7, -(12/7)}, {3/7, -(6/7), -(15/7)}, {-(12/7), 0, -(3/7)}, {-(9/7), -(9/7), -(9/7)}, {0, -(12/7), -(6/7)}}

{{-(15/7), -(15/7), 0, (15 Sqrt[2])/7}, {-(3/7), -(3/7), 3/7, (3 Sqrt[3])/7}, {-(6/7), 3/7, -(12/7), 3 Sqrt[3/7]}, {3/7, -(6/7), -(15/7), (3 Sqrt[30])/7}, {-(12/7), 0, -(3/7), (3 Sqrt[17])/7}, {-(9/7), -(9/7), -(9/7), (9 Sqrt[3])/7}, {0, -(12/7), -(6/7), (6 Sqrt[5])/7}}

UPDATE:

You request no duplication in the rows, but duplication is possible in the columns. We can achieve that using RandomChoice instead of RandomSample to generate the permutations. After generation of a new list, we check that each row is free of duplicates; if not, we generate a new one until we get an appropriate new list. The following uses your definitions of the lists:

N1 = 4; N2 = 5; N3 = 7;

Do[
 newlist = RandomChoice[#, 7] & /@ {list1, list2, list3} // Transpose;
 If[And @@ (DuplicateFreeQ /@ newlist), Return[newlist]],
 200
]

If[
 And @@ (DuplicateFreeQ /@ newlist),
 {Sequence @@ #, Norm[#]} & /@ newlist,
 "no good list found"
]

The $200$ at the end of Do is there to avoid infinite loops; if no duplicate-free lists are generated, the process stops anyway after that number of attempts.


Old Answer:

If you lists had the same length, e.g. by setting:

N1 = 7; N2 = 7; N3 = 7;

Then a simple way of achieving what you want would be the following

RandomSample /@ {list1, list2, list3} // Transpose;
{Sequence @@ #, Norm[#]} & /@ %

{{-(15/7), -(15/7), 0}, {-(3/7), -(3/7), 3/7}, {-(6/7), 3/7, -(12/7)}, {3/7, -(6/7), -(15/7)}, {-(12/7), 0, -(3/7)}, {-(9/7), -(9/7), -(9/7)}, {0, -(12/7), -(6/7)}}

{{-(15/7), -(15/7), 0, (15 Sqrt[2])/7}, {-(3/7), -(3/7), 3/7, (3 Sqrt[3])/7}, {-(6/7), 3/7, -(12/7), 3 Sqrt[3/7]}, {3/7, -(6/7), -(15/7), (3 Sqrt[30])/7}, {-(12/7), 0, -(3/7), (3 Sqrt[17])/7}, {-(9/7), -(9/7), -(9/7), (9 Sqrt[3])/7}, {0, -(12/7), -(6/7), (6 Sqrt[5])/7}}

Source Link
MarcoB
  • 67.7k
  • 18
  • 96
  • 198

If you lists had the same length, e.g. by setting:

N1 = 7; N2 = 7; N3 = 7;

Then a simple way of achieving what you want would be the following

RandomSample /@ {list1, list2, list3} // Transpose;
{Sequence @@ #, Norm[#]} & /@ %

{{-(15/7), -(15/7), 0}, {-(3/7), -(3/7), 3/7}, {-(6/7), 3/7, -(12/7)}, {3/7, -(6/7), -(15/7)}, {-(12/7), 0, -(3/7)}, {-(9/7), -(9/7), -(9/7)}, {0, -(12/7), -(6/7)}}

{{-(15/7), -(15/7), 0, (15 Sqrt[2])/7}, {-(3/7), -(3/7), 3/7, (3 Sqrt[3])/7}, {-(6/7), 3/7, -(12/7), 3 Sqrt[3/7]}, {3/7, -(6/7), -(15/7), (3 Sqrt[30])/7}, {-(12/7), 0, -(3/7), (3 Sqrt[17])/7}, {-(9/7), -(9/7), -(9/7), (9 Sqrt[3])/7}, {0, -(12/7), -(6/7), (6 Sqrt[5])/7}}