# Questions tagged [combinatorics]

For challenges involving combinatorics.

353 questions
Filter by
Sorted by
Tagged with
139 views

### Generate a Kirkman triple system

Given a universe of $v$ elements, a Kirkman triple system is a set of $(v-1)/2$ classes each having $v/3$ blocks each having three elements, so that every pair of elements appears in exactly ...
964 views

### Restricted Integer Partitions

Pk(n) means the number of partitions of n into exactly k parts. Given n and ...
2k views

### How many partitions do I have?

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 ...
1k views

### Cryptic Multiplications

Given two non-negative integers e.g. 27, 96 their multiplication expression would be 27 x 96 = 2592. If now each digits is ...
2k views

### Calculate the partitions of N

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 ...
1k views

### Sum of combinations with repetition

Write the shortest code you can solving the following problem: Input: An integer X with 2 <= X and X <= 100 Output: ...
260 views

563 views

### Counting Fountains

A fountain is arrangement of coins in rows so that each coin touches two coins in the row below it, or is in the bottom row, and the bottom row is connected. Here's a 21 coin fountain: Your challenge ...
3k views

### Cartesian product of a list with itself n times

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

### AoCG2021 Day 5: Balancing sleigh with lots of trunks

Part of Advent of Code Golf 2021 event. See the linked meta post for details. The story continues from AoC2015 Day 24, Part 2. Here's why I'm posting instead of Bubbler To recap: Santa gives you the ...
1k views

### Enumerate all pure sets

In set theory, a set is an unordered group of unique elements. A pure set is either the empty set $\{\}$ or a set containing only pure sets, like $\{\{\},\{\{\}\}\}$. Your challenge is to write a ...
2k views

### The Coin Problem

Background The official currency of the imaginary nation of Golfenistan is the foo, and there are only three kinds of coins in circulation: 3 foos, 7 foos and 8 foos. One can see that it's not ...
3k views

### Consecutive coin flips

This is a cross-post of a problem I posted to anarchy golf: http://golf.shinh.org/p.rb?tails Given two integers $n$ and $k$ $(0 \le k \le n)$, count the number of combinations of $n$ ...
1k views

### Topologically distinct ways of dissecting a square into rectangles

I was asked by OEIS contributor Andrew Howroyd to post a Code Golf Challenge to extend OEIS sequence A049021. Would be super great to get a couple more terms for [...] A049021. Kind of thing [...] ...
755 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 ...
905 views

### Generate all groupings

Let's define a grouping as a flat list, which is either: just 0 2 groupings followed by the literal integer 2 3 groupings ...
1k views

### Number of complete rhyme schemes

A rhyme scheme is the pattern of rhymes at the end of the lines in a poem. They are typically represented using letters, like ABAB. We consider two rhyme schemes ...
724 views

### Count alternating permutations

An alternating permutation is a permutation of the first $n$ integers $\{ 1 ... n \}$, such that adjacent pairs of values in the permutation alternate between increasing and decreasing (or ...
244 views

### Sort my Cups︎︎︎︎︎︎︎︎︎︎ [closed]

I have a set of colored plastic cups. They come in four colors: green, yellow, pink, and blue. When I put them on my shelf, I like to stack them in a certain pattern. Your job is, given a list of any ...
645 views

### Increasing permutation trees

For this challenge a "binary tree" is a rooted tree where each node has 0 children (leaf) or 2. The children of a node are unordered, meaning that while you might draw the tree with left ...
217 views

### Find run ascending lists faster

In this question I asked you to determine if a run ascending list could be made. It was code-golf so naturally most the answers are very slow. But what if we want it to be fast. In this challenge I ...
1k views

9k views

### Generate Pascal's triangle

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 ...
1k views

### Matching ABACABA-type patterns

(This challenge is related to the challenge "Generate the Abacaba sequence.") Zimin words (also called "sesquipowers") are an important idea in the subject of "combinatorics ...
775 views

### Lean golf: Pascal vs. Fibonacci

The Pascal's triangle and the Fibonacci sequence have an interesting connection: Source: Math is Fun - Pascal's triangle Your job is to prove this property in Lean theorem prover (Lean 3 + mathlib). ...
1k views

### Verify a Superpowerset

A superpowerset (analogous to superpermutation) on $n$ symbols is a string over the alphabet $\{1,2,...,n\}$ such that every subset of $\{1,2,...,n\}$ appears as a substring (in some order). For ...
3k views

### Decompose a permutation into cycles

There is a well-known theorem that any permutation can be decomposed into a set of cycles. Your job is to write the shortest possible program to do so. Input: Two lines. The first contains a ...
530 views

### Output a Steiner quadruple system

A Steiner quadruple system $SQS(n)$ is a collection of subsets (blocks) of size 4 of a set $S$ of size $n$ such that every subset of $S$ of size 3 is in exactly one block. It is easy to show ...
649 views

### Acyclic orientations of an n-dimensional cube

The goal of this challenge is to check and extend the OEIS sequence A334248: Number of distinct acyclic orientations of the edges of an n-dimensional cube. Take an n-dimensional cube (if n=1, this is ...
2k views

### Never trust a mastermind

You probably know the game mastermind: The player tries to guess a code of 4 slots, with 8 possible colors - no duplicates this time. Let's call those colors A through H, so possible solutions could ...
1k views

### Square-free words of a length

A square-free word is a word consisting of arbitrary symbols where the pattern $XX$ (for an arbitrary non-empty word $X$) does not appear. This pattern is termed a "square". For example, ...
7k views

### Don't repeat yourself in Rock-Paper-Scissors

Upon the rumor that Codegolf will have a Rock-Paper-Scissors tournament you look into the topic of square-free words. A word made of the letters R, ...
124 views

### Matching fuzzies [closed]

Introduction Congratulations! You've been selected to do research a a newly discovered animal called a fuzzy, a docile, simple creature that strongly resembles a cotton ball. Fuzzies love to be near ...