# Tag Info

Accepted

### Faster derangements?

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

### Solving word search puzzles

Here we go... ...

### Faster derangements?

This is the fastest method I have come up with: ...
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

...

### 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: ...
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 ...

### 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: ...
Accepted

### Generating Tuples with restrictions

Select[ IntegerPartitions[24, {8}, Range], #.# == 86 & ] ...
Accepted

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

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

### 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 ...

### How to count all cliques (not just maximal ones) in graphs?

Mathematica only finds maximal cliques, i.e. cliques (complete subgraphs) that are not part of a larger clique. Computing the number of all cliques given the maximal ones is not trivial because some ...
Accepted

...
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 ...
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}];

### 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 ...

### 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 ...

### 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, ...

### 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: ...

### Permutations of lists of fixed even numbers

The permutation you described is called "derangement". There is a function Derangement in Combinatoricapackage. ...
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$. ...
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: ...

### 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, -...
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 ...
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 ...

### Tuples with one "joker" digit?

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