# Creating sub-lists using a fixed list

I have a data set with 30 numbers.

LT = Range[30]


I have selected 6 numbers in this set to create a base.

base = {1, 3, 8, 10, 11, 23}


Which command I could create a list of other numbers?

Edit

I want the other 6 groups with the same numbers as base, but without repetitions.

Just this:

LT = Range[30]
base = {1, 3, 8, 10, 11, 23}
Complement[LT, base]


{2,4,5,6,7,9,12,13,14,15,16,17,18,19,20,21,22,24,25,26,27,28,29,30}

EDIT

If you want to mix a little the numbers remaining, you can do this:

comp = RandomSample@Complement[LT, base]


{9,30,25,19,14,15,18,7,24,5,6,12,22,26,29,4,27,17,16,2,13,20,21,28}

Here I have tried to get the length of the remaining numbers:

Length[comp]


Here the number of groups that you need to:

groups = 6


Here the amount of elements for each group:

elem = Length[comp]/groups


Here were created 6 groups with 4 elements each one using the numbers remaining:

comp1 = comp[[#]] & /@ Range[1, 4]
comp2 = comp[[#]] & /@ Range[5, 8]
comp3 = comp[[#]] & /@ Range[9, 12]
comp4 = comp[[#]] & /@ Range[13, 16]
comp5 = comp[[#]] & /@ Range[17, 20]
comp6 = comp[[#]] & /@ Range[21, 24]


{9,30,25,19}

{14,15,18,7}

{24,5,6,12}

{22,26,29,4}

{27,17,16,2}

{13,20,21,28}

Here were created 6 groups joining your list bbb with 6 groups of numbers remaining:

G1 = Join[base, comp1]
G2 = Join[base, comp2]
G3 = Join[base, comp3]
G4 = Join[base, comp4]
G5 = Join[base, comp5]
G6 = Join[base, comp6]


{1,3,8,10,11,23,9,30,25,19}

{1,3,8,10,11,23,14,15,18,7}

{1,3,8,10,11,23,24,5,6,12}

{1,3,8,10,11,23,22,26,29,4}

{1,3,8,10,11,23,27,17,16,2}

{1,3,8,10,11,23,13,20,21,28}

If you prefer, you can unite all groups into a single list

allG = Sort@Symbol["G" <> ToString[#]] & /@ Range[6]


{{1, 3, 8, 9, 10, 11, 19, 23, 25, 30}, {1, 3, 7, 8, 10, 11, 14, 15, 18, 23}, {1, 3, 5, 6, 8, 10, 11, 12, 23, 24}, {1, 3, 4, 8, 10, 11, 22, 23, 26, 29}, {1, 2, 3, 8, 10, 11, 16, 17, 23, 27}, {1, 3, 8, 10, 11, 13, 20, 21, 23, 28}}

Note: The results shown here represent the values obtained using RandomSample. Their results will surely be different from my own.

• This is what you asked? Sep 26, 2016 at 18:29
• This ensures that there is not repetitions? Sep 26, 2016 at 18:30

maybe like so:

base = {1, 3, 8, 10, 11, 23};
pool = Range[ 6 (30-6) + 6];
pool = Complement[pool, base];
sets=Table[(
set = RandomSample[pool, 24];
pool = Complement[pool, set];
RandomSample[Join[base, set], 30]), {6}]


you can see any pair of sets has only the base in common:

  Intersection[sets[[1]], sets[[2]]]


{1, 3, 8, 10, 11, 23}

and you can see we used every number once except for the base values:

 Sort[Tally[Flatten[sets]]]
Select[%, #[[2]] != 1 &]


{{1, 6}, {2, 1}, {3, 6}, {4, 1}, {5, 1} ... }

{{1, 6}, {3, 6}, {8, 6}, {10, 6}, {11, 6}, {23, 6}}