All Questions
13,814
questions
10
votes
2
answers
473
views
Find a string in the middle
Given two strings \$A\$ and \$B\$ with edit (Levenshtein) distance \$x\$, find a third string with edit distance \$a\$ to \$A\$ and edit distance \$b\$ to \$B\$ so that \$a+b=x\$ and \$a=int(x/2)\$ (...
17
votes
12
answers
906
views
Is it a canonical elementary CA rule number?
Background
Given an elementary cellular automaton rule number like, for example, 28 = 00011100…
We can swap \$\color{red}{\text{the 2nd bit with the 5th bit}}\$ ...
12
votes
4
answers
395
views
Zeckendorf to F(4k+2) representation
Background
Fibonacci numbers are defined as follows:
$$
F_0 = 0, F_1 = 1, F_n = F_{n-1} + F_{n-2}
$$
The Zeckendorf representation is a representation of positive integers as a sum of one or more non-...
7
votes
5
answers
475
views
Multiply multivariate polynomials
We already have a challenge about multiplying multiply single-variable polynomials. This challenge is about multiply two polynomials with multiple variables
Your task is given two multi-variable ...
11
votes
10
answers
401
views
Stevin's Notation
Stevin's Notation is a way to represent decimals in a non-fractional way.
The Flemish mathematician and engineer Simon Stevin is
remembered for his study of decimal fractions. Although he was not the
...
1
vote
0
answers
58
views
How Many Staircases [duplicate]
Problem
You're a staircase engineer on a house and realize you only have n rectangles to create a staircase. So you are tasked with finding the number of ways to ...
10
votes
5
answers
1k
views
Decode Chess Move
As the title says, given a valid chess move in algebraic notation, produce the string describing the move.
Example:
...
26
votes
39
answers
4k
views
Repeat your program to print Fibonacci numbers
Write a program fragment so that, when repeated N times it prints the Nth Fibonacci number. For example, if your program is print(x) then:
...
11
votes
16
answers
1k
views
The rectangle spanned by two numbers
One way to generalize the concept of a range from the integers to the Gaussian integers (complex numbers with integer real and imaginary part) is taking all numbers contained in the rectangle enclosed ...
9
votes
11
answers
721
views
Otteretto Classic game scoring method
Brief description of the game
In the game Otteretto Classic (which you can test directly in your browser; try it!) the player has to form palindromic sequences using adjacent cells on a square grid. ...
8
votes
18
answers
1k
views
Piecing Paired Primes
Problem
You've stumbled upon a paradoxical mathematical phenomenon related to prime numbers. Consider the following scenario:
You have an infinite list of prime numbers: $$2, 3, 5, 7, 11, 13, 17, 19, ....
6
votes
4
answers
487
views
Walk by walls in a room
Challenge
You just entered a room. Here's how it looks (you are the X):
|\ /|
| \/ |
| X |
| |
|----|
You challenge yourself to see if you can reach where you ...
15
votes
18
answers
2k
views
First odd then even indices
Your task is to find out how often you need to "shuffle" a given list with the following operation until you get back the original list.
...
13
votes
9
answers
3k
views
Give the fool's Fibonacci sequence
Recently I asked for tips on improving some code-golf of mine. The code was supposed to output every third value of the Fibonacci sequence starting with 2:
...
14
votes
10
answers
3k
views
When in {country}, do as the {countrians} do
(or: Output the plural demonym.)
When in Rome, do as the Romans do. This is a well-known English phrase meaning that it’s best to follow what others are doing around you — to go with the flow. Today, ...
10
votes
12
answers
2k
views
Encrypting Emojis
Problem
You are tasked with creating a program that performs emoji encryption on a given string of emojis. In this encryption scheme, each emoji is replaced by a unique character (from ...
12
votes
18
answers
1k
views
Print a meter of numbers to a specified limit
Given a positive integer n, output a number meter formatted like this:
...
1
vote
1
answer
158
views
Shorten this recursive even fibonacci implementation [closed]
I have the following Haskell code to generate the the values of the Fibonacci sequence which are even as an infinite list:
...
15
votes
16
answers
830
views
Output the smallest increasing sequence where each term is coprime to preceding 3 terms
This sequence is defined as
Starts with 1, 2, 3
The next element of the sequence is the first number greater than the previous three that is co-prime with each of the previous 3 elements in the ...
11
votes
4
answers
1k
views
Optimal Duck Game Moves
How to play the duck game
This is a 2-player game.
First, we start with a line of blue rubber ducks (represented here as circles):
🔵🔵🔵🔵🔵🔵🔵
Now, in each ...
19
votes
10
answers
2k
views
How Turing complete is your language?
Find the maximum possible number of disjoint sets of characters, that are Turing complete subsets of your language.
Rules:
You can assume your Turing complete subset is contained in/called from a ...
6
votes
8
answers
845
views
Iterate over strings II
This is a successor to a previous challenge.
Input
An integer \$1 \leq n \leq 5\$.
Task
Your code should produce all strings that satisfy the following properties:
Your string should contain exactly ...
16
votes
17
answers
1k
views
Count N-Rich Permutations of an Integer Sequence
Given a sequence of integers with length \$L\$ and an integer \$1 \le N \le L\$, an "\$N\$-rich" permutation is one whose the longest strictly increasing contiguous subsequence has length ...
2
votes
1
answer
182
views
Hashers and Crashers (Robbers)
This is the robbers thread of this cops and robbers challenge. The cops thread is here.
Related, but hashes numbers instead of strings and uses a different scoring system.
Definitions
A hash collision ...
6
votes
1
answer
217
views
Hashers and Crashers (Cops)
This is the cops thread of this cops and robbers challenge. The robbers thread is here.
Related, but hashes numbers instead of strings and uses a different scoring system.
Definitions
A hash collision ...
8
votes
3
answers
625
views
Compressed UTF-8
In the UTF-8 encoding bytes of the Form 10****** can only appear within multi-byte sequences, with the length of the sequence already being determined by the first ...
16
votes
11
answers
1k
views
Iterate over all non-equivalent strings
Input
A single positive integer \$ 10 \geq n \geq 2\$
Output
A list of strings, each of length \$2n\$, satisfying the following properties.
Each string will contain each of the first \$n\$ lowercase ...
14
votes
12
answers
1k
views
Shift Braille down
Braille Patterns in Unicode contains 8 dots(⣿) and occupy area U+2800-U+28FF. Given a Braille Pattern character, where the bottom two dots are not used(aka. U+2800-...
8
votes
8
answers
602
views
Magic OEIS formulae (Robbers' thread)
This is the robbers' thread. See the cops' thread here.
In this cops and robbers challenge, the cops will be tasked with writing an algorithm that computes some function of their choice, while the ...
12
votes
9
answers
700
views
Magic OEIS formulae (Cops' thread)
This is the cops' thread. See the robbers' thread here.
In this cops and robbers challenge, the cops will be tasked with writing an algorithm that computes some function of their choice, while the ...
20
votes
9
answers
2k
views
Cutting a Circular Pizza Vertically
Most people would cut circular pizzas into circular sectors to divide them up evenly, but it's also possible to divide them evenly by cutting them vertically like so, where each piece has the same ...
11
votes
34
answers
2k
views
Convert binary to unary
The title says it all; Given a number in the binary (base-2) number system, output the same number expressed in unary (base-1).
You should take the binary number as a string (optionally with a ...
16
votes
15
answers
1k
views
Find separating sets
Two points pand q in a topological space can be separated if there are open sets U and ...
20
votes
16
answers
1k
views
Evenly spread values
Given a sorted list of unique positive floats (none of which are integers) such as:
[0.1, 0.2, 1.4, 2.3, 2.4, 2.5, 3.2]
Evenly spread out the values that fall ...
11
votes
4
answers
350
views
Generate the vertices of a geodesic sphere
As in this challenge, the task is to generate the vertices of a polyhedron. The polyhedron here is the one obtained by dividing a regular icosahedron's triangular faces into smaller triangles so that ...
8
votes
11
answers
2k
views
Reverse engineer colors for a layout
This challenge was originally posted on codidact.
At my job we have to sometimes lay out materials. Materials come in large long rolls and are cut into smaller pieces when being laid out.
When we ...
19
votes
14
answers
2k
views
Rook Polynomials
In combinatorics, the rook polynomial \$R_{m,n}(x)\$ of a \$m \times n\$ chessboard is the generating function for the numbers of arrangements of non-attacking rooks. To be precise:
$$R_{m,n}(x) = \...
16
votes
6
answers
3k
views
Is it a valid Go type?
Write the shortest program or function that will determine if an input is a valid Go type.
Spec
This challenge will use the following simplified subset of Go types. For more information, see the ...
8
votes
11
answers
679
views
Buzzing Bill's Newspaper: Four Letter Splits
"Buzzing" Bill is a well respected beaver. He is the hardest working in his home dam. He was a strong beaver and was able to lift more logs than anyone at the dam. Unfortunately Buzzing Bill'...
14
votes
11
answers
2k
views
Round up to a smoother number
Input
Two positive integers a > b
Output
The smallest integer c >= a so that c can be ...
8
votes
14
answers
1k
views
Calculate the aspect ratio of the Nepal flag
Above is the picture of the flag of the country Nepal. Pretty cool.
What's cooler, is the aspect ratio, which is defined under the constitution as:
That formula in copyable form:
$$ 1 : \frac{...
4
votes
4
answers
507
views
Compute convolution quickly and accurately
Input
An array A of integers of length 100,000. The array will contain only integers in the range 0 to 1e7.
Output
The convolution of A with itself. As this will be of length 199999 you should time ...
8
votes
8
answers
387
views
Near miss prime multiples
This challenge was originally posted on codidact.
Given a number \$n \geq 3\$ as input output the smallest number \$k\$ such that the modular residues of \$k\$ by the first \$n\$ primes is exactly \$\...
19
votes
17
answers
1k
views
Compute the convolution of two strings
While implementing polynomial multiplication in Itr I found the following interesting operation on strings
To compute the convolution of two strings (for instance ...
17
votes
13
answers
1k
views
Efficient censorship
This challenge was originally posted on codidact.
You are a low-level censor working for the Ministry of Media Accuracy. Part of your job is to make sure that certain words don't appear in ...
11
votes
12
answers
1k
views
The all-high powerful numbers
We've had powerful numbers, yes, but what about highly powerful numbers?
Highly powerful numbers
Let \$n\$ be a positive integer in the form
$$n = p_1^{e_{p_1}(n)}p_2^{e_{p_2}(n)}\cdots p_k^{e_{p_k}(n)...
26
votes
17
answers
4k
views
s-n-a-k-e-a-r-o-u-n-d--->
This code-golf challenge is about walking around a string like a snake.
s-n-a-k
.---. e
d <-' a
n-u-o-r
You will be given a string \$ S \$ of length \$ l \$ and ...
20
votes
5
answers
1k
views
Repeating occupied pattern in Hilbert's hotel
Imagine a countable infinite amount of empty rooms. When an infinite amount of guests come, they occupy the 1st, 3rd, 5th...(all odd) empty rooms. Therefore there's always an infinite amount of empty ...
21
votes
18
answers
2k
views
Is this set laminar?
A family of sets is called laminar if for any two sets \$A\$ and \$B\$ in the family one of the following is true:
\$ A \subseteq B \$
\$ A \supseteq B \$
\$ A \cap B = \emptyset \$
Or less ...
15
votes
14
answers
2k
views
How many trailing zeros in the hyperfactorial?
We have a challenge to calculate the hyperfactorial and one to count the trailing zeros of the factorial, so it seems logical to put them together and count the trailing zeros in the hyperfactorial.
...