# Tag Info

Accepted

### Faster derangements?

Chunks of derangements Since I've already written library link code generating permutations, generating derangements requires just few tweaks: ...
• 15.1k

### Faster derangements?

This is the fastest method I have come up with: ...
• 272k
Accepted

### Solving word search puzzles

Here we go... ...
• 70.7k
Accepted

### How to generate all Feynman diagrams with Mathematica?

Here is a piece of code that is inspired by quantum field theory. The physics background can be found in this physics.SE post. First, we define some auxiliary functions: ...
Accepted

...
• 396k

### House of Santa Claus

This is of course the Chinese postman problem, which is solved by the function FindPostmanTour[]. First, represent the edges of the directed graph: ...

### Transform a number to a factorial

An example target, a bit over half-a-million digits: x = 123456!; IntegerLength@x 574965 Results for target, and a non-hit: ...
• 25.8k
Accepted

### Lazy form of Tuples/Outer to loop over list of lists

The implementation of lazy tuples here pretty much contains the solution to the lazy Outer problem. I will take the relevant parts from that code. The following ...
• 114k

### Faster derangements?

Here is one way to generate them directly: it is based on a way to generate all permutations but discards invalid ones early: ...
• 8,774
Accepted

### Generating set partition diagrams

I need to reproduce this diagram ... We can use the function blobF from this answer to generate blobs around subsets: ...
• 396k
Accepted

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

A solution using Repeated, ReplaceList, and the Orderless attribute. ...
• 272k

### Permutations of nested parentheses (Dyck words)

StringReplaceList I just realized that there is a comparatively clean though not highly efficient way to write this using ...
• 272k
Accepted

### Mathematica implementation of Zeilberger's algorithm (previously done in Maple)

There is also a newer package, HolonomicFunctions, that has an implementation of Chyzak's generalization of Zeilberger's algorithm. To perform the desired task, use the following commands: ...

### 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 ...
• 85k
Accepted

### List all possible license plate numbers

I would use a = Alphabet[]; (* letter *) d = Range[0, 9]; (* digit *) result = Tuples[{a, a, d, d, d, d}];
• 235k

### Transform a number to a factorial

Stirling's approximation, $n! \sim n^ne^{-n}$, is the Swiss army knife of factorial problems. If $x = n!$, this implies that $\ln x \sim n \ln n - n$; and surprisingly this can be solved with a ...
• 15.2k

### Can you give a faster implementation with Mathematica for these q-analog functions?

There are lots of QFunctions (see also wikipedia) Some are the q(,t)-analog version of the original MATH objects. (orthogonal polynomials, special functions, etc. ) However, it seems to me that some ...
• 1,373

### Lazy form of Tuples/Outer to loop over list of lists

Overview Here is a refinement of @Leonid's approach that is a bit faster. The basic idea is to create a TuplesFunction that encapsulates the tuples information, ...
• 131k

### Solving word search puzzles

Update To allow string with multiple words separated by single space, and possible multiple instances of word and non empty intersection of positions: ...
• 61.6k

### Permutations of lists of fixed even numbers

The permutation you described is called "derangement". There is a function Derangement in Combinatoricapackage. ...
• 7,921
Accepted

### Permutations of lists of fixed even numbers

Permutations where no element remains in its original place are called derangements. Counting them is easy enough: the number of derangements of a set of size $n$ is $!n$, or the subfactorial of $n$. ...
• 8,774

### All possible combinations of ways to write an equation

Tuples + Dot: Tuples[{1, -1}, 3].{q, p1, p2} {p1 + p2 + q, p1 - p2 + q, -p1 + p2 + q, -...
• 396k
Accepted

### How can I correctly use LazySubsets from Wolfram's Lazy package?

The package doesn't seem to be well-documented, so I have to guess. If I guess it right, those Lazy* functions are supposed to work only on ...
• 66.8k
Accepted

### Cyclic and Non-cyclic Permutations

Per the request, I post my comment as an answer: First question cy := Permute[#, CyclicGroup[Length@#]] & cy[Range@5] {{1, 2, 3, 4, 5}, {2, 3, 4, 5, 1}, {3, 4,...
• 26.8k
Accepted

### Tuples optimization challenge

Don't use brute force, instead compute probabilities for each amount of leading zero bits in OrderDistribution for the smallest entry of ...
• 19.1k

### Tuples with one "joker" digit?

Permutations can do this. You just need to give it enough copies of 1 and 2 such that they ...
• 8,774

### 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 ...
• 25.8k

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

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