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.
216 questions
11
votes
7
answers
588
views
Sticks expectation
This was originally a question from interviewstreet.com over a decade ago
You are given an array (or whatever - your choice of input) of positive integers \$y_1,\ldots,y_n\$ that represents \$n\$ line ...
15
votes
4
answers
911
views
Identify Last-Layer Perm of a Rubik's Cube
A popular method for solving Rubik's cube consists of:
solving its first two layers, by convention starting with the white side
orienting the last layer's pieces so they face the same direction with ...
23
votes
15
answers
3k
views
Write two very different programs with the same characters
Your task is to write two programs/functions, in the same language.
Program 1: Verify that two inputs are anagrams of each other.
Program 2: Verify that two inputs differ from each other at every ...
9
votes
4
answers
646
views
Triangular Transposition Cipher
A text that can be arranged triangularly in some fashion can be read back in some other fashion effectively enciphering it.
Narrowing down a set of plausible triangular numberings allows to ...
12
votes
9
answers
1k
views
All possible swaps for the permutation
Given a permutation of {1,2,...,n} named A, do each swap of form swap A[i], A[j] exactly once, where ...
12
votes
8
answers
731
views
Unap_peel_ing permutations
Given the height, \$h\$, and width, \$w\$, describing a rectangle of the first \$hw\$ natural numbers in row-major order produce the numbers in the order they are encountered by repeatedly removing a ...
13
votes
13
answers
2k
views
Meandering over ℤ
The easiest way to understand this task is to look at this
graph,
which you can change interactively.
It defines a sequence n -> a(n) like this:
a(0) = 0; thereafter a(n) is the least integer (in ...
8
votes
6
answers
1k
views
Ranking of binary trees
Let N = [0,1,2,...n-1] be the initial segment of the natural
numbers of length n, then all permutations of N can be sorted
lexicographically, starting with the identity. The index into this
sorted ...
6
votes
3
answers
648
views
Implement any rotation-invariant function on colored dodecahedrons
Each of a regular dodecahedron's 12 faces can be painted either red or blue. Your task is to implement a function \$f\$ that takes a painted dodecahedron (as 12 booleans, in whatever order and format ...
7
votes
12
answers
812
views
Counting constrained permutations
Challenge:
Write a program or function that, given positive integers n, t, b, c, counts permutations of 1..n where:
Exactly t numbers are in their original position
Exactly b numbers are higher than ...
3
votes
4
answers
606
views
Create 251610 matrices as quickly as possible
There are 251610 6 by 6 binary matrices that are inequivalent. We say two matrices are equivalent if there is some permutation of their rows and/or columns that makes them equal.
For example:
...
5
votes
9
answers
360
views
Reorder a string of length \$2^n\$ by permuting the \$n\$ binary digits of every index
Given a binary string \$s\$ of length \$2^n\$ and a permutation \$\sigma\$ of \$\{1,\dots,n\}\$, generate the binary string \$u\$ of length \$2^n\$ which is a reordering of \$s\$ such that \$u[i^\...
13
votes
8
answers
1k
views
Lexicographically earliest permutation of the initial segment of nonnegative integers subject to divisibility constraints
The challenge is simple: Reorder the first integers {0, 1, 2, ..., n} into an ordered list so that the following three conditions are met:
If k is the last element in the list, then all of its prime ...
4
votes
18
answers
786
views
Check if two lists are permutations of each other [duplicate]
Challenge
Given two lists of equal length, find if one of them is a permutation of the other. Output truthy or falsy values, or 1 or 0.
Test case Examples
...
8
votes
8
answers
1k
views
Find the child anagrams of a word
Select any word from https://websites.umich.edu/~jlawler/wordlist with length greater than 1. For each letter on that word, remove it and check if any rearrangement of the remaining letters is present ...