Linked Questions

0
votes
1answer
76 views

List of all “partitions”/ “cuttings” of a list [duplicate]

How do I do generate all possibilities to "partition"/ "split"/ "group" a list? ...
18
votes
9answers
921 views

Any built-in function to generate successive sublists from a list?

Given lst = {a, b, c, d} I'd like to generate {{a}, {a, b}, {a, b, c}, {a, b, c, d}} but using built-in functions only, ...
20
votes
6answers
638 views

How to generate all possible orderless partitions of a list according to another list?

This question is hard to describe in plain text. So I will post an example and a working code (brute force) to illustrate. For example I have a list: ...
10
votes
6answers
767 views

Is there concise code for the list operation I want to perform?

Is there any concise syntax for the following partitioning of a list. Given {1, 2, 3, 4}, I want to get the output as shown below. I have tried various function ...
10
votes
5answers
1k views

Subsets of a list

Consider the following demand of products for the next four months. data={1,20,3,40}; I could produce the whole demand in the first months, leading to the ...
6
votes
2answers
605 views

Partition a set into $k$ non-empty subsets

The Stirling number of the second kind is the number of ways to partition a set of $n$ objects into $k$ non-empty subsets. In Mathematica, this is implemented as ...
3
votes
3answers
175 views

Seeking a way to generate sequential partitions of a list using built in or Combinatorica functions [duplicate]

This code generates all "sequential partitions" of a list: ...
0
votes
0answers
353 views

Splitting a list into 2 sublists in all possible ways

I have a list and I want to split it into 2 sublists in all possible ways If S={1,2,3,4} I should get ...
4
votes
2answers
58 views

Groupings of the Elements of a List with at Most $k$ Elements

Given a list with $n$ elements and an integer $k$ I want to get a list with all possible groupings of these n elements in sets with at most k elements. For example, given $n=\{1,2,3,4\}$ and $k=3$ I ...
4
votes
2answers
90 views
1
vote
0answers
114 views

Partition a set of n objects into k subsets? [duplicate]

Is there some function recently added to Mathematica that facilitates forming all partitions of a n-element set into k subsets? In other words, something that easily gives the same thing as what <...
0
votes
0answers
58 views

Generating partitions of a set with a specified size of the parts [duplicate]

I tried the following (inspired by the answer here) myList = {a, b, c}; Needs["Combinatorica`"]; SetPartitions[myList] and I got this answer, ...
1
vote
0answers
47 views

In what order does Combinatorica's SetPartitions function list the partitions of a set?

For example, Needs["Combinatorica`"] n = 4; partitions = SetPartitions[Range[n]]; Table[Print[partitions[[i]]], {i, 1, BellB[n]}] generates ...