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.

Filter by
Sorted by
Tagged with
2
votes
0answers
105 views

Is that string garbled? [duplicate]

Mayube recently posted Garble that string. However, humans aren't too good at checking whether a string is actually garbled or not. (Actually, that's an understatement, we are really bad at it.) So, ...
20
votes
9answers
1k views

Garble that string!

Given a string as input, output one or more variants of the string such that: No character is in it's original position No character is adjacent to a character that it was originally adjacent to You ...
24
votes
38answers
2k views

Golf an Anagram Quine

In this question I asked you to guess an anagram quine based on its output. However it looks like we don't have a question asking to golf an anagram quine yet. So your task will be to make the ...
17
votes
10answers
1k views

THE Magic Hexagon

There are many magic squares, but there is just one non-trivial magic hexagon, as Dr. James Grime explained, which is the following: ...
41
votes
11answers
4k views

Find a binary needle in a decimal haystack

The challenge You're given: a non-empty, unsorted list h of positive integers (the haystack) a positive integer n (the needle) Your task is to return the list of all unique decimal concatenations ...
11
votes
7answers
1k views

Golf you an anagram for great good!

The Task In this challenge, your task is to write some code which outputs one of its anagrams chosen randomly with uniform distribution but it should never output itself. Elaboration Given no input,...
10
votes
6answers
990 views

It's Anagram Quine, not just Quine!

The Task In this challenge, your task is to write a program, which takes in no input, with as many anagrams that are quine of themselves as possible. Your score will be the number of anagrams of ...
23
votes
16answers
1k views

Random Golf of the Day #8: Shuffle an infinite list

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 ...
44
votes
12answers
2k views

Scramble words while preserving their outlines

This is much more advanced than How to randomize letters in a word and Cambridge Transposition because of the rule about which letters may be swapped with which. A simple regex will not suffice here. ...
19
votes
6answers
1k views

Anaglot Polygrams

Task Write some code that can be rearranged into n different programs in n different languages each outputting a distinct number from 1 to n. No two languages should be the same however different ...
14
votes
5answers
391 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 ...
8
votes
17answers
766 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 ...
15
votes
15answers
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 ...
1
vote
1answer
262 views

Self Referential Puzzle - medium 2 [closed]

The following puzzle was asked in puzzling SE. This puzzle is quite hard to solve by hand because every answer depends on another answer. So, for example, a solution with all answers being A does not ...
9
votes
3answers
186 views

Composition of permutations – the group product

Given two permutations in disjoint cycle form, output their product/composition in disjoint cycle form. To find the composition, convert the disjoint cycles to permutations in two-line notation. Each ...
20
votes
16answers
2k views

I give you Nth permutation, you give me N

Input: a sequence of uppercase letters (ASCII [65;90]) which is the Nth* lexicographical permutation of the multiset of its characters *permutations are numbered from 0 or 1 upwards Output: base-10 ...
24
votes
24answers
2k views

Deranged !Combinatorics: Compute the Subfactorial

The subfactorial or rencontres numbers (A000166) are a sequence of numbers similar to the factorial numbers which show up in the combinatorics of permutations. In particular the nth subfactorial !n ...
12
votes
10answers
498 views

Back-To-Front Permutation Index

The Challenge Given the number of items, n, in a non-empty, sorted list output the index, i(n), at which its "Back-To-Front ...
9
votes
7answers
677 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 ...
26
votes
11answers
1k views

Anagram Quines (Cops' Thread)

This is a cops-and-robbers challenge the Robbers' Thread can be found here Your challenge is to write a program that outputs an anagram of its source code but not the original source code itself. ...
13
votes
16answers
993 views

Number of string permutations that are palindromes

Your input will be a string consisting of small english letters. Your task is to determine the number of distinct permutations of the original string that are a palindrome. The input string has up ...
17
votes
5answers
396 views

Twisting Sentences

Rules The program should receive a string/array of words as input. For each word in the string/array, it will reconstruct the word by taking characters in alternating fashion from the front and back ...
17
votes
1answer
617 views

Hold'em or Fold'em?

Your friend invited you to a high-stakes poker game at the last minute and, as a computer scientist, you've decided to use your skills to gain an edge on the game. Your task will be, given ...
8
votes
0answers
376 views

Total Derangement (Difficulty Level: Hard)

The problem: Write a function which, given a cycle length n and a number of cycles m, where 'm' is within ...
16
votes
15answers
2k views

Hidden Inversions (Robbers' Thread)

This is a cops-and-robbers puzzle, the cops' thread can be found here. Your task will be to find an anagram of the provided programs in the cops' thread that performs its left inverse. Once you ...
35
votes
17answers
3k views

Hidden Inversions (Cops' Thread)

This is a cops-and-robbers puzzle the robbers' thread can be found here. Your task will be two write two programs (or functions) such that they are anagrams of each other and one performs the left ...
30
votes
21answers
2k views

Generate a random derangement

Challenge description A "derangement" of a sequence is a permutation where no element appears in its original position. For example ECABD is a derangement of ...
102
votes
32answers
11k views

What are the five most powerful characters in your language?

Choose any five characters your language supports. There are 5! = 5×4×3×2×1 = 120 ways these can be arranged into a 5-character string that contains each character once; 120 ...
15
votes
2answers
801 views

Match the permutations!

Your challenge is to create a regex that matches every string permutation of itself, and nothing else. The match must also be case-sensitive. So, for example, if your regex is: ...
27
votes
29answers
2k views

Alphabetically permute a string

Task Your goal, should you choose to accept it, is to write a program, that, given an input string (or array of characters), outputs every possible permutation of the letters in that string. I'm ...
8
votes
14answers
763 views

Quine Anagrams! (Robbers' Thread)

This is the robbers' thread. For the cops' thread, click here. Cops' Task For the cops' thread, click here. Robbers' Task Find an uncracked submission on the cops' thread. (A submission may only ...
22
votes
25answers
2k views

Quine Anagrams! (Cops' Thread)

This is the cops' thread. For the robbers' thread, click here. Cops' Task First, write a quine in a language of your choosing. Next, scramble the quine. Make sure to do this well as the robbers will ...
13
votes
8answers
620 views

Generate antsy permutations

Introduction I defined the class of antsy permutations in an earlier challenge. As a reminder, a permutation p of the numbers from 0 to r-1 is antsy, if for every entry p[i] except the first, there ...
37
votes
23answers
2k views

Antsy permutations

Introduction Suppose you have a ruler with numbers from 0 to r-1. You place an ant between any two of the numbers, and it starts to crawl erratically on the ruler. The ruler is so narrow that the ant ...
16
votes
5answers
844 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 ...
17
votes
15answers
2k views

Compute the Eulerian number

The Eulerian number A(n, m) is the number of permutations of [1, 2, ..., n] in which exactly ...
17
votes
13answers
1k views

Inverse permutation index

Introduction The lexicographical permutations of a list with n elements can be numbered from 0 to n! - 1. For example, the 3! = 6 permutations of (1,2,3) would be <...
23
votes
27answers
2k views

List all ordered partitions of n

The challenge is to list all ordered partitions (composition (combinatorics)) of a given positive integer n. These are the lists of numbers from ...
21
votes
10answers
1k views

Prime factors buddies

Given an integer N > 1, output all other numbers which prime decompositions have the same digits as the prime decomposition of ...
9
votes
15answers
903 views

Shuffle a mapping

We define a map as a set of key-value pairs. For this challenge, you need to take each of the values and assign them to a randomly chosen key. You must randomly shuffle the values, and output the ...
2
votes
11answers
414 views

Noah's (upgraded) ark

As preparation for the nth Exodus, Noah decides to write a program that will decide If he will let animals on his ark. However, Noah wants to go back to grass roots. Thus he decides that the program ...
45
votes
20answers
4k views

Greater than less than greater than something fishy

Given a length N string of less-than and greater-than signs (<, >), insert the integers 0 through N at the start and end ...
42
votes
26answers
3k views

Sheffle tho vawols ureund!

Given an input string, output that string with all vowels a, e, i, ...
10
votes
5answers
241 views

Steps of Permutation

Write a function which takes a set of integers and prints every permutation of the set, and the swap performed in between each step Input a set of integers, for example (0, 1, 2) Output the list ...
25
votes
8answers
2k views

The Permutation Pigeon-hole Principle

In the game of sudoku, many players like to "pencil in" possible numbers that can go in each square: The above row can be represented as an array: ...
8
votes
1answer
293 views

Extendable Train Swapping Problem

Extended Train Swapping Problem Part 1: Normal Train Swapping Problem In the 1996 CCC (Canadian Computing Competition), the first Stage 2 problem was a Train Swapping Problem. You can visit the link ...
3
votes
1answer
171 views

Check if input is permutation of source [duplicate]

Inspired by Input ∩ Source Code. Task Your task is to determine whether the input is a permutation of the source code. Input A string. Input is flexible; it should be able to handle the character ...
18
votes
14answers
2k views

Permutapalindromic numbers

Given an integer N as input, output the Nth permutapalindromic number. A permutapalindromic number is a strictly positive ...
6
votes
3answers
195 views

Permute a string using Bit-Reversal

Previously, we computed the Bit-Reversal Permutation where we found how the order of indices would be permuted. In that case, we received an input n which was the order of the permutation of the ...
23
votes
12answers
2k views

Number of cycles of a permutation

Consider a permutation of the integers 1, ..., n, such as this one for n = 6: ...