# Tag Info

Accepted

...
• 47.9k

### generating tuples of ones and zeroes with a fixed number of ones

L[n_, m_] := Permutations@Array[Boole[# <= m] &, n] L[3, 2] (* {{1, 1, 0}, {1, 0, 1}, {0, 1, 1}} *)
• 47.9k
Accepted

### How do I get a list of all possible sums in a list nested list?

Total[Tuples@rn, {2}] should do. For cases where a very large number of tuples would be generated, ...
• 25.8k

### List of tuples without duplicates & repeated values

The accepted answer will quickly blow up with arguments of more than trivial sizes. For example, with vals = {10, 20, 5, a, b, c} and ...
• 25.8k
Accepted

### How to create all $1$'s vectors of length $n$ without using Tuples[]?

ArrayPad[IdentityMatrix[n], {{0, 1}, {0, 0}}, 1] Or PadRight[IdentityMatrix[n], {n + 1, n}, 1] Or ...
• 28.9k

### Tuples of elements from list excluding anything with repeated values

Just use Permutations: Permutations[lst] {{a, b, s, t}, {a, b, t, s}, {a, s, b, t}, {a, s, t, b}, {a, t, b, s}, {a, t, ...
• 131k

### What is the identity for Tuples?

If {{1},{2},{3}} is fine, you can use Nothing: ...

### generating tuples of ones and zeroes with a fixed number of ones

With[{n = 5, k = 2}, ReplacePart[ConstantArray[0, n], Thread[# -> 1]] & /@ Subsets[Range[n], {k}]] ...
• 74.8k
Accepted

### Faster searching for subsets with pairwise conditions

Might be faster to cull as you go. I compile the selection function (possibly it can be made faster). Also I set the history length to zero although that does not help too much because the ...
• 59.1k
Accepted

### List of tuples without duplicates & repeated values

n = 2; vals = {0, 1}; Tuples[vals, {n}] // DeleteDuplicatesBy[#, Sort] & As the comment said ...
• 9,928

### Generating representatives of rotation classes of tuples of ones and zeros with a fixed number of ones

Not sure whether this works always correctly. Say you want the lost of all $n$-tuples with $k$ 1 up to rotation. You can encode such a tuple by going through it in ...

### Faster searching for subsets with pairwise conditions

Correct me if I'm wrong, you're looking for 10,000 lists each with length 13, every element can be {1,2,3,4} and each list has at least 5 hamming distances from the ...
• 9,289
Accepted

### Working with tables: add new level of nested tables

We can use FrobeniusSolve to solve the equation $$x_1+x_2+\cdots +x_n= m$$ Here n and m may ...
• 74.8k

### How do I get a list of all possible sums in a list nested list?

Few additional alternatives: Distribute[foo @@ rn, List, foo, List, Plus] Flatten @ Outer[Plus, ## & @@ rn] Activate @ Tuples[Inactive[Plus] @@ rn]
• 396k
Accepted

### How to list all possible 3-tuples with entries of the 3 tuples from 2 different sets?

{a, b} = {Range[4], Range[5, 8]}; triples = Tuples[{a, a, b}] ...
• 396k
Accepted

### Sorted Tuples without Filtering

The function you are looking for is: Subsets. E.g. for a list with n=5 elements and tuples with m=3 elements (note, you should not use capitalized variable names as those are used by the system): <...
• 52.6k

### How to create all $1$'s vectors of length $n$ without using Tuples[]?

You almost got the result you wanted, but somewhere you took a wrong turn. The question states The problem I have here, is that I want to concatenate this 1's vector with an identity matrix. The ...
• 4,907

### What is the identity for Tuples?

You can use Inactive[Sequence][] as identity like this: Tuples[{{Inactive[Sequence][]},{q}}]//Activate {{q}}
• 8,834
Accepted

### Generating a list of tuples that meet certain criteria without running out of memory

Clear["Global`*"] pool = Table[Range[3], 7] // Flatten; Rather than produce all tuples, produce a tuple on demand ...
• 159k
Accepted

### Selecting from a list returned by Tuples

There was an excelent answer with an illustration, but I would like to point out the specific mistakes: Pure function in the second argmuent should end with & <...
• 4,948
Accepted

### Duplicate Tuples

Rather than use For loops, I suggest a route through Outer: ...
• 67.3k

### What is the identity for Tuples?

Use TagSetDelayed to define a function that behaves as desired: ...
• 396k

### generating tuples of ones and zeroes with a fixed number of ones

f[len_,wt_] := Table[ Boole[MemberQ[sub,i]], {sub,Subsets[Range[len],{wt}]}, {i,len} ] Try it online! ...
• 150

### generating tuples of ones and zeroes with a fixed number of ones

ClearAll[L2] L2[n_, m_] := Permute[PadRight[ConstantArray[1, m], n], SymmetricGroup @ n] L2[3, 2] ...
• 396k
Accepted

### Tuples which treats re-ordering as equivalent

You may use IntegerPartitions. ...
• 42.3k

### Working with tables: add new level of nested tables

One possible implementation could be: ...
• 55.3k

### How to find repeating elements in the following grid?

If you know the lengths Length@grid1 == 6, Length@grid2 == 6, Length@grid3 == 5, then you ...
• 23.7k
Accepted

### How to find repeating elements in the following grid?

If we know that tuples is constructed from ngrids input grids and if each grid has at least one non-repeating element, we can ...
• 396k

### generating tuples of ones and zeroes with a fixed number of ones

ClearAll[f0] f0 = Module[{ss = MapIndexed[Thread[{#2[[1]], #}] &, Subsets[Range@#, {#2}]]}, SparseArray[Join @@ ss -> 1, {Length@ss, #}]] &; ...
• 396k