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.
69
questions
20
votes
11
answers
4k
views
Ethan Finds the Maximum Element
This is a problem that the Hacker Cup team made for the 2018 Facebook Hacker Cup, but we ended up not using it (though Ethan struggles through a variety of other challenges). Normally code size isn't ...
19
votes
9
answers
956
views
Spiral Permutation Sequence
We can roll up the natural numbers in a rectangular spiral:
...
18
votes
4
answers
625
views
Permutation group operation
There is a well-known bijection between the permutations of \$n\$ elements and the numbers \$0\$ to \$n!-1\$ such that the lexicographic ordering of the permutations and the corresponding numbers is ...
18
votes
2
answers
2k
views
Random Golf of the Day #6: Roll a d20
About the Series
First off, you may treat this like any other code golf challenge, and answer it without worrying about the series at all. However, there is a leaderboard across all challenges. You ...
17
votes
17
answers
2k
views
Find all the Anagrams!
Despite having 17 questions tagged anagrams, we still don't have this question, so here it is.
Your Task
You must write a program or function that, when receiving a string, prints out all possible ...
16
votes
5
answers
1k
views
Wolves and Chickens
There's a river and there are wolves and chickens on one side of the river. They have a raft and they all need to get to the other side. However, the raft cannot travel on its own. The raft will sink ...
16
votes
3
answers
1k
views
Reconstruct a Permutation
Introduction
Suppose that you are handed a random permutation of n objects.
The permutation is sealed in a box, so you have no idea which of the ...
16
votes
15
answers
1k
views
Cheapo Enigma machine (Cops)
For robbers' post, Cheapo Enigma machine (Robbers)
A cop's submission will consist of a program/function that accepts a single byte of data and return a single byte of data. Every possible input must ...
14
votes
5
answers
458
views
Generate all Brain-Flak Snippets
This question is the second of several Brain-flak Birthday challenges designed to celebrate Brain-Flak's first Birthday! You can find more information about Brain-Flak's Birthday here
Challenge
For ...
14
votes
6
answers
2k
views
Code golf the best permutation
Challenge
Given an integer n ≥ 4, output a permutation of the integers [0, n-1] with the property that no two consecutive integers are next to each other. The value of a permutation ...
13
votes
4
answers
528
views
Possible Tetris sequences
Write code to figure out whether a run of Tetris pieces could be generated by the official Tetris algorithm. Fewest bytes wins.
Official Tetris games generate the sequence of falling pieces in a ...
13
votes
10
answers
1k
views
Permutations with Indistinguishable Items
Given a list of integers, output the number of permutations of the integers, with indistinguishable permutations counted once. If there are n integers, and each ...
13
votes
3
answers
678
views
Count the number of Hankelable matrices
Background
A binary Hankel matrix is a matrix with constant skew-diagonals (positive sloping diagonals) containing only 0s and 1...
11
votes
1
answer
934
views
Constructing an Orthogonal-Diagonal Greco-Latin Square
Consider a grid of NxN unique elements. Each element has a letter (from A to the Nth letter,...
11
votes
7
answers
785
views
Anagram Quines (Robbers' Thread)
This is a cops-and-robbers challenge the Cops' Thread can be found here
Your challenge, as robbers is to take outputs from the cops' thread and find anagrams of the output that when run as a program ...
9
votes
7
answers
403
views
Detecting anagrams within a Parent String
Given two strings, a parent string and a query string respectively, your task is to determine how many times the query string, or an anagram of the query string; appears in the parent string, in a ...
8
votes
17
answers
837
views
Cheapo Enigma machine (Robbers)
For cops' post, Cheapo Enigma machine (Cops)
A robber's submission consists of a program/function that accepts the output of a cop's code and returns the input for all the outputs provided by that cop'...
8
votes
5
answers
411
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 ...
8
votes
9
answers
610
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 ...