**214 combinatorics questions.**

Introduction
In a private chat, a friend of mine apparently recently stumbled across a security system which has the following two restrictions on its valid pins:
Each digit must be unique (that is "...

Here's a programming puzzle for you:
Given a list of pairs of strings and corresponding numbers, for example, [[A,37],[B,27],[C,21],[D,11],[E,10],[F,9],[G,3],[H,2]], output another list which will ...

A deck of cards is the Cartesian product of S suits and R ranks.
Many, though not all, card games use S=4 and R∊{6,8,13}.
A hand of H cards is dealt from the deck.
Its distribution, a.k.a. "hand ...

Introduction
A disk is a linear container with blocks indexed 0 through size-1.
A file is a named list of block indexes used by that file.
An example filesystem is expressed like this:
15 ALPHA=3,...

When given a a list of values and a positive integer n, your code should output the cartesian product of the list with itself n times.
For example, in pseudocode your function could be similar to:
...

Given a nonempty list of positive integers [X, Y, Z, ...], your job is to determine the number of unique values of ± X ± Y ± Z ...
For example, consider the list [1, 2, 2]. There are eight possible ...

You have a 3x3 grid. Each cell can be colored black or white. Display all 512 of these colorings. Fewest bytes wins.
You can display the grids in any formation as long as they are visually separated ...

Introduction
Dobble/SpotIt is a card game, where people have to spot same symbol on pair of cards in shortest time, indicate it and move to next pair. Each card has multiple symbols (8 in normal ...

Make a code that takes a list and a number as input, and generates all possible combinations with the length of the number. For example, with the list {0,1} and the number 2:
00
01
10
11
Your ...

Who needs to compare things case insensitively when you're able to generate every permutation of uppercase and lowercase? No one! That's the answer. No one does. Your task is to achieve this feat; ...

Background
The Sidi polynomial of degree n – or the (n + 1)th Sidi polynomial – is defined as follows.
The Sidi polynomials have several interesting properties, but so do their coefficients. The ...

Problem definition
Print out the powerset of a given set. For example:
[1, 2, 3] => [[], [1], [2], [3], [1, 2], [1, 3], [2, 3], [1, 2, 3]]
Each element is to be printed on a separate line, so ...

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

In this task you are given an odd number of white balls and the same number of black balls. The task is to count all the ways of putting the balls into bins so that in each bin there is an odd number ...

Consider the process of "picking" a nested list. Picking is defined as follows:
If the argument is a list, take an element from the list at random (uniformly), and pick from that.
If the argument is ...

Write a function that takes as input a set of integers (can be a list, array or any other container with distinct numbers), and outputs the list of all its permutations.
Python (95 chars):
p=lambda ...

Description
Let a permutation of the integers {1, 2, ..., n} be called minimally interpolable if no set of k+2 points (together with their indices) fall on a polynomial of degree k.
That is,
No ...

The nth Motzkin Number is the number of paths from (0, 0) to (n, 0) where each step is of the form (1, -1), (1, 0) or (1, 1), and the path never goes below y = 0.
Here's an illustration of these ...

The challenge is to create an iterator(/generator) which iterates (in any order so as to reach all of them... ie no set should occur at infinity) over all possible non-empty finite sets(/tuples/lists) ...

Mash Up Time!
This is instalment #5 of both my Random Golf of the Day and Optimizer's ASCII Art of the Day series. Your submission(s) in this challenge will count towards both leaderboards (which you ...

Background
I was inspired by 3Blue1Brown's recent video about the necklace splitting problem (or as he calls it, the stolen necklace problem) and its relationship to the Borsuk-Ulam theorem.
In this ...

Given a list of stack heights, calculate the number of ways those heights could have been arrived at by stacking blocks one at a time. Shortest code wins.
Test cases:
[2, 2] 6
[3,3,3] 1680
[1,5,9,1] ...

A little genetics lesson
When you only have access to someone's visible traits or phenotype, a pedigree of their family history is often used to figure out the actual genetic information or, genotype ...

Polystrips are a subset of polyominoes conforming to the following rules:
each piece consist of 1 or more cells
no cell can have more than two neighbours
the cells should not enclose a hole
Free ...

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 searched for.
...

Write the shortest code you can solving the following problem:
Input:
An integer X with 2 <= X and X <= 100
Output:
Total combinations of 2, 3, and 5 (repetition is allowed, order matters) ...

Problem
Consider a square 3 by 3 grid of non-negative integers. For each row i the sum of the integers is set to be r_i. Similarly for each column j the sum of integers in that column is set to be ...

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

Pascal's triangle is generated by starting with a 1 on the first row. On subsequent rows, the number is determined by the sum of the two numbers directly above it to the left and right.
To ...

Yesterday I asked this question about riffle shuffles. It seems that yesterdays question was a bit too hard so this question is a related but much easier task.
Today you are asked to determine if a ...

The Catalan numbers (OEIS) are a sequence of natural numbers often appearing in combinatorics.
The nth Catalan number is the number of Dyck words (balanced strings of parenthesis or brackets such as ...

There are n places set around a circular table. Alice is sat on one of them. At each place, there's a cake. Alice eats her cake, but it doesn't taste very nice. Then the Mad Hatter comes in. He gives ...

This is a follow-up to Chess960 position generator.
In Chess960, there are 960 possible starting positions that can be enumerated from 0 to 959 (or, at your choice, from 1 to 960). The enumeration ...

quintopia has posted here a challenge to compute multinomial coefficients (some of the text here is copied from there). There is a fun algorithm to compute multinomial coefficients mod 2.
Given a ...

Time for another easy challenge in which all can participate!
The multinomial theorem states:
The expression in parentheses is the multinomial coefficient, defined as:
Allowing the terms ki to ...

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

When multiplying monomials in the Milnor basis for the Steenrod algebra, part of the algorithm involves enumerating certain "allowable matrices".
Given two lists of nonnegative integers r1, ... ,rm ...

Your task is to write a program that will output a readable list of every five letter words with the structure:
consonant - vowel - consonant - vowel - consonant
The output should be sorted ...

Inspiration. Posted with permission.
Print one of the possible XKCD calendar "facts":
You can get the raw text and structure from my APL reference implementation or from Explain XKCD's transcript (...

Definition
An "integer triangle" is one with integer coordinates. For example the following triangle is an integer triangle:
(0, 0), (0, 1), (1, 2) with perimeter 1 + sqrt(2) + sqrt(5) ≈ 4.650.
...

A riffle shuffle is a type of shuffle where the deck is split into two partitions and the partitions are then spliced back together to create a new shuffled deck.
The cards are spliced together in ...

Inspired by Taken from a question at Stack Overflow.
The challenge
Given an integer n>1, output all arrays that can be obtained by swapping exactly two entries in the array [1, 2, ..., n].
The ...

Challenge description
Dominoes is a game played with tiles with two values on it - one on the left, one on the right, for example [2|4] or [4|5]. Two tiles can be joined together if they contain a ...

Write a program or function that takes N, and S and outputs the number of palindromes of length S you can build using an alphabet of size N such that any prefix of size between 2 and S-1 is not a ...

The partition number of a positive integer is defined as the number of ways it can be expressed as a sum of positive integers. In other words, the number of integer partitions it has. For example, the ...

The challenge is to list all ordered partitions (composition (combinatorics)) of a given positive integer n. These are the lists of numbers from 1 to n whose sum is n. For example, given input n = 4, ...

Your challenge is simple: GIven an integer N, ouput every list of positive integers that sums to N. For example, if the input was 5, you should output
[1, 1, 1, 1, 1]
[1, 1, 1, 2]
[1, 1, 3]
[1, 2, 2]...

List all of the combinations with replacement (or combinations with repetition) of size k from a set of n elements.
A combination with replacement is an unordered multiset that every element in it ...

2013 has the prime factorization 3*11*61. 2014 has the prime factorization 2*19*53. An interesting property regarding these factorizations is that there exist distinct primes in the factorizations of ...

The question: Given an a number n ≥ 2, how many distinct pairs of points on an n-dimensional n x n x n x n x n x n ... x n lattice, where the coordinates range from 0 to n - 1, are a distance at least ...

- code-golf
- math
- sequence
- permutations
- number
- number-theory
- fastest-code
- code-challenge
- set-partitions
- integer-partitions
- arithmetic
- string
- array-manipulation
- grid
- graph-theory
- counting
- decision-problem
- tiling
- ascii-art
- game
- binary
- card-games
- primes
- geometry
- random

- Are there shanty towns in Paris?
- 'Earth-based' adjective counterpart to 'Lunar' or 'Solar'
- How to set personal hygiene standards with my boyfriend?
- Prevent Auto-Playing in Google Chrome?
- What is the word for using one word to replace another for cosmetic reasons?
- MultiClassing and Gaining Abilities on Level up
- What should my redraft phase entail?
- Why is the movie named "Knight of Cups"?
- Why do Indian reservations still exist in North America?
- Does everyone get to see the color of a train card drawn from the pile?
- If iron can’t undergo fusion, does that mean a black hole is mostly iron?
- A word denoting something taking place for the last time in an indefinitely large series
- Were external floppy drives for Atari ST and Amiga inter-compatible?
- Execute a Superb Shuffle™
- Flyback diode is acting weird
- Block diagrams can be different and still works for the same system?
- Should I punish my teenage sister, whom I have full custody of, for lying to me in order to secretly see her boyfriend?
- What does one typically use as a money reservoir for stocks, when they are "on sale"?
- Metal-Feathered Macaw Viability
- How do I apply integrating factor to solve this differential equation?
- Is there a name for illustrations with non-rectangular borders?
- A word for taking a picture by satellite
- How to move my SOQL query outside for loop?
- If a triangle can be displaced without distortion, must the surface have constant curvature?