# Questions tagged [permutations]

A permutation is a particular ordering of some list of objects. Problems tagged with permutation usually involve finding or generating permutations, including anagrams of text.

169 questions
Filter by
Sorted by
Tagged with
112 views

### Sums of permutations of vectors [closed]

I am looking for a more efficient way of computing the following. Let A and B be two vectors of non-negative integers of length <...
128 views

### Permutations with recursion (Beginner friendly) [closed]

This is very simple. Just write a function that takes an array and returns an array of all possible (non-repeating) permutations of that array. BUT you'll have to use recursion (in a way that would ...
2k views

### Verify a Superpermutation

A superpermutation on n symbols is a string which contains every permutation of n symbols in its body. For instance, 123121321 is a superpermutation on three ...
2k views

### Generate Gmail Dot-Aliases

Background You may be aware that periods in between letters in gmail addresses are ignored. Email sent to example@gmail.com, exam.ple@gmail.com, and e.x.a.m.p.l.e@gmail.com all end up in the same ...
530 views

### Pairs of palindromic anagramic dates separated by a palindromic number of days

Definitions: A palindrome is a string which reads the same backward or forward (not counting spaces or special characters), such as "madam" or "Sorel Eros". A date is said to be a palindrome when ...
208 views

### String permutations

Print the biggest-size subset of strings in the input that are all permutations of each other. If there are ties, any one will do. If no strings are permutations of each other (for example, only one ...
2k views

### Super permutations

Super permutations Input: A string The program should loop through all lengths of the input (decrementing one each time), generate all combinations with replacement of the string, then make ...
2k views

### Plain Hunt Bell-Ringing

Your task is to create a plain hunt (a bell ringing pattern) with n bells. An example with 6 bells: ...
808 views

### Output Distinct Factor Cuboids

Output Distinct Factor Cuboids Today's task is very simple: given a positive integer, output a representative of each cuboid formable by its factors. Explanations A cuboid's volume is the product ...
1k views

### Permutations in Disguise

Given a $n$-dimensional vector $v$ with real entries, find a closest permutation $p$ of $(1,2,...,n)$ with respect to the $l_1$-distance. Details If it is more convenient, you can use ...
2k views

I see your BIDMAS and raise you a BADMIS Challenge Given a set of numbers with operators between them: "5 + 4 * 9 / 3 - 8", return all the possible results of the expression for every permutation of ...
2k views

### Calculate Landau's function

Landau's function $g(n)$ (OEIS A000793) gives the maximum order of an element of the symmetric group $S_n$. Here, the order of a permutation $\pi$ is the smallest positive integer $k$ such ...
626 views

Introduction: In Dutch, the words leading and suffering, being 'leiden' and 'lijden' respectively, are pronounced the same way. One is written with a "short ei", and one with a "long ij&...
679 views

### Dihedral group D4 composition with custom labels

The dihedral group $D_4$ is the symmetry group of the square, that is the moves that transform a square to itself via rotations and reflections. It consists of 8 elements: rotations by 0, 90, 180, ...
1k views

### Enumerate Derangements

Given some positive integer $n$ generate all derangements of $n$ objects. Details A derangement is a permutation with no fixed point. (This means in every derangement number $i$ cannot be in ...
964 views

### Words hidden in my phone number [closed]

Telephones in the United States (and perhaps some other places) have letters associated with some of the numbers. ...
933 views

### Source permutation

A permutation of a set $S = \{s_1, s_2, \dotsc, s_n\}$ is a bijective function $\pi: S \to S$. For example, if $S = \{1,2,3,4\}$ then the function $\pi: x \mapsto 1 + (x + 1 \mod 4)$ is a ...
343 views

### Unique Brick Tilings Within A Rectangle

I was browsing Stackoverflow and saw this question about tiling an MxN rectangle, and I thought it would be great for golfing. Here is the task. Given the dimension M and N, write a program that ...
3k views

### Superpermutations

Introduction You're a criminal tasked with stealing some secret plans from the new tech startup Dejavu. You sneak in over the back wall, but find a door that requires a pin to open it. You recognize ...
1k views

### Hide the buildings

Shorter version of Skyscrapers Challenge Task Given an array of building heights and a positive integer k, find all the permutations(without duplicates) of the ...
144 views

### Doce logf a string swapper [closed]

Challenge Take an input string $s$, and split it into words $w_1, w_2, ..., w_n$. If the amount of words is odd, then return $s$. Otherwise, for each word: Take the second last letter, and swap ...
688 views

### 9erilous 9ermutations

Note: This is an attempt at recycling guest271314's permutation question(s) There's an interesting pattern that forms when you find the differences between lexographically sorted permutations of base ...
433 views

### Amidakuji (阿弥陀籤) simplification

If you have ever had any exposure to Japanese or East Asian culture you will have surely encountered the Amidakuji game: As Wikipedia explains, it is a type of lottery drawn on paper and used to ...
3k views

### Encode - Shuffle - Decode

Challenge Your task is to encode an integer as a string of ASCII characters, then successfully decode it after said string has been randomly shuffled. You will write two programs/functions, which ...
306 views

### What is the simplest reversible circuit that computes conjugacy of transpositions?

Reversible computation refers to computation in which little or no information is deleted. Reversible computation a major component of quantum computation, and reversible computation is potentially ...
645 views

### Permutation Encoding

Write a program which can encode text to avoid reusing characters, and convert back. Both normal and encoded forms are restricted to a particular character set: the space character ...
1k views

### Block Rearrangement

So your task is to take a 3x3 block where -'s mean blank spaces, and *'s mean filled spaces, for example: ...
4k views

### Levi-Civita symbol

The three-dimensional Levi-Civita symbol is a function f taking triples of numbers (i,j,k) each in ...
2k views

### Codegolf the Hafnian

The challenge is to write codegolf for the Hafnian of a matrix. The Hafnian of an 2n-by-2n symmetric matrix ...
873 views

### Conjugate permutations

A permutation of size n is a reordering of the first n positive integers. (meaning each integer appears once and exactly once). Permutations can be treated like functions that change the order of a ...
1k views

### Stitch Together a Palindrome from Palindromic Substrings

Given a string l, find all palindromic substrings p of l (including duplicates and single ...
467 views

### Deranged Rearrangements

Your task is to write a computer program such that when it is cut up into lines (split on the newline character) every arrangement of the lines will output a different number between 1 and n! (where n ...
193 views

### Flattened Spiral Permutation Index

Context Consider square matrices with n columns and rows containing the first n^2 (i.e. n ...
558 views

### How many draws are there in Quarto?

Introduction This challenge is similar to Project Euler problems. I came up with it because I was playing a deceivingly simple board game and couldn't come up with an efficient solution to answer a ...
2k views

### Find The Rank Of A Word

Definition The rank of a word is defined as the position of the word when all the possible permutations (or arrangements) of its letters are arranged alphabetically, like in a dictionary, no matter if ...
2k views

### Generate combinations that add up to a target value

Challenge Suppose you have a list of numbers, and a target value. Find the set of all combinations of your numbers which add up to the target value, returning them as list indices. Input and Output ...
837 views

### ​L​o​o​p​ ​I​t​

Note: The title of this question should be "Loop It", but because title needs to be at least 15 characters, there are some invisible spaces. This note is such that the challenge can be ...
586 views

### A Dance of Many Dimensions

Challenge Given a n-dimensional array of integers and a permutation of the first n natural numbers, permute the array dimensions ...
259 views

### Riffle shuffle a string - Robbers

Cops post A riffle shuffle is a way of shuffling cards where the deck is split into 2 roughly equal sections and the sections are riffled into each other in small groups. This is how to riffle ...
505 views

### Riffle shuffle a string - Cops

Robbers post A riffle shuffle is a way of shuffling cards where the deck is split into 2 roughly equal sections and the sections are riffled into each other in small groups. This is how to riffle ...
149 views

### String Permutations - case and order [duplicate]

Challenge For any string that is composed of alphabetical characters of any case, make a function that returns a list of all of it's variations, order and case-wise empty strings returns empty list. ...
585 views

### N-bit Variation on Subset-Sum

For another challenge I am writing, I need to verify that test cases are solveable with bounded integers. Specifically, I need to verify the following, for a non-empty array of integers ...
1k views

### Build this pyramid

Your pyramid The pyramid I want you to build is made entirely of cubes. It has 24 layers, and the Nth layer from the top contains N2 cubes arranged in an N by N square. The pyramid looks like this: ...
5k views

### Output an Anagram! No Not That One!

Given a list of unique strings that are anagrams of each other, output an anagram of those words that is different from each word in the list. The strings will be alphanumeric, and there is guaranteed ...
668 views

### Output all distinct permutations of a vector

Challenge: Output all distinct permutations of a, potentially long, list of positive integers. You may assume that the vector has less than 1,000 numbers when testing, but the process should in ...
194 views

### Those annoying grasshoppers [closed]

The problem #6 of IMO 2009 reads: Let a 1, a 2, a 3, ..., a n, be distinct positive integers and let T be a set of n-1positive integers not containing a 1+a 2+a 3+...+a n, A grasshopper is to ...
1k views

### Numbers with similar powers

Given an integer p > 1, find the smallest integer q > p such that the list of exponents in the prime factorization of q is the same of that of p, no matter the order or the value of the prime ...
2k views

### The Original Number (II)

This challenge is essentially identical to this one with just one difference: it is now allowed to shuffle letters anywhere in the string. Scenario John has an important number, and he doesn't want ...