# Tag Info

Accepted

### Efficient lazy weak compositions

Chunks of weak compositions Here is slightly modified version of algorithm used in CombinatoricaNextComposition converted to a ...

### Partitioning with varying partition size

New in 11.2 is TakeList: TakeList[Range, {2, 3, 5}] {{1, 2}, {3, 4, 5}, {6, 7, 8, 9, 10}}

### Partitioning a number into consecutive integers

The sum of consecutive numbers from $a$ to $b$ is $$\frac{(a+b)(b-a+1)}{2}$$ hence simply ...
Accepted

### How to split a number

You can also use NumberDecompose with the basis {10000, 100, 1}: ...

### Improving speed of code computing number of nonrepeating partitions

Here is a summary of comments (before @ciao's best answer above), with a change in notation. These functions calculate the number of partitions of n into exactly <...
Accepted

### Improving speed of code computing number of nonrepeating partitions

This seems pretty quick, particularly on larger cases / larger k, e.g. 451, 29, 101 finishes in a few seconds on the loungebook. N.B. - I have not tested this ...

### Partition a list by count of a number

It is always good to start with System functions: Flatten /@ Partition[Split[list, #1 =!= 2 &], UpTo] ...

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

Li = Range; TakeDrop[Li, #] & /@ Range[Length[Li]-1] // Column[Row/@#]& or, slightly shorter, ...
Accepted

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

A solution using Repeated, ReplaceList, and the Orderless attribute. ...

### Improving speed of code computing number of nonrepeating partitions

Here is a totally different approach based on the fact that successive products forming the generating function are due to multiplication by a binomial $1+t*z^j$. Form a matrix $v$ of zeros with $n+1$ ...
Accepted

...

### Partitioning with varying partition size

This can be implemented elegantly with FoldPairList and TakeDrop (both new in v10.2), in fact it's one of the examples in the ...

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

Permutations treats repeated elements as identical, so you can get a flattened version of the desired result with something like ...
Accepted

### Partitioning an image based on features

You can use ImageTrim to extract the bounding boxes from the image. ...

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

This is literally the canonical example from the ReplaceList documentation: ...
Accepted

### Index-based Array splitting

For the simple case of even and odd, you can do either: ...

### While partitioning the elements in a list using GatherBy, can I correspondingly partition the elements of an unrelated list?

Here is another approach. The basic idea is that GatherBy creates a list of representatives corresponding to the input, then partitions the input based on those ...
Accepted

### Goldbach Partition

Take a look at IntegerPartitions, although it relies on brute-force enumeration that is unlikely to scale well. ...

### Any alternative way to compute IntegerPartitions?

There are 190,569,292 unrestricted integer partitions of 100 (PartitionsP@100). This will need >1gb of RAM just to keep the final result. You can generate them in ...

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

It's far from pretty, using pattern matching (OrderlessPatternSequence): ...

...
Accepted

### Merge list repeating elements

lst = {{{a, b}, {c, d}}, {{e, f}, {h, i}}}; You can use Tuples or Outer or ...
Accepted

### Partitioning a number into consecutive integers

I took it as a challenge to avoid using Solve, which can be slower than a direct assault. If $a$ is the first number in the sum of consecutive positive integers, ...

### How can I extract parts from a ragged nested list?

Using Part you could do something like the following: ...

### generating integer partitions

I needed to do this sometime ago while investigating Bell polynomial analogs. Normally, you'd do FrobeniusSolve[Range[n], n] but the fastest variation (and quite ...
Accepted

### GatherBy/SplitBy and Sort a list

As noted by @SimonWoods in the comments, using #.#& instead of Norm gives a huge speed up. ...

### How to split a number

DateList[{IntegerString @ #, {"Year", "", "Month", "", "Day"}}][[;; 3]] & @ 19001231 ...

### Any alternative way to compute IntegerPartitions?

You may use PartitionsP to skip calculating the partitions. This will improve performance "infinity-fold" (in practical terms) for the integer frequency counts on ...