All Questions

Filter by
Sorted by
Tagged with
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. ...
bsoelch's user avatar
  • 5,677
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: ...
Wheat Wizard's user avatar
  • 96.5k
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, ...
noodle man's user avatar
  • 5,252
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 ...
3.14's user avatar
  • 327
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: ...
TKDKid1000's user avatar
1 vote
1 answer
167 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: ...
Wheat Wizard's user avatar
  • 96.5k
15 votes
16 answers
833 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 ...
mousetail's user avatar
  • 11.8k
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 ...
The Thonnu's user avatar
  • 17.8k
20 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 ...
bsoelch's user avatar
  • 5,677
6 votes
8 answers
853 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 ...
Simd's user avatar
  • 1,812
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 ...
EphraimRuttenberg's user avatar
2 votes
1 answer
200 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 ...
The Empty String Photographer's user avatar
6 votes
1 answer
232 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 ...
The Empty String Photographer's user avatar
8 votes
3 answers
635 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 ...
bsoelch's user avatar
  • 5,677
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 ...
Simd's user avatar
  • 1,812
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-...
l4m2's user avatar
  • 20.4k
8 votes
8 answers
617 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 ...
dingledooper's user avatar
  • 22.3k
12 votes
9 answers
723 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 ...
dingledooper's user avatar
  • 22.3k
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 ...
Yousername's user avatar
  • 3,650
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 ...
noodle man's user avatar
  • 5,252
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 ...
bsoelch's user avatar
  • 5,677
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 ...
Simd's user avatar
  • 1,812
11 votes
4 answers
360 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 ...
Karl's user avatar
  • 621
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 ...
Wheat Wizard's user avatar
  • 96.5k
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) = \...
alephalpha's user avatar
  • 46.5k
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 ...
bigyihsuan's user avatar
  • 8,548
8 votes
11 answers
683 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'...
KidWithComputer's user avatar
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 ...
Simd's user avatar
  • 1,812
9 votes
15 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{...
Jacob Creutzfeldt's user avatar
5 votes
4 answers
549 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 ...
Simd's user avatar
  • 1,812
8 votes
8 answers
394 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 \$\...
Wheat Wizard's user avatar
  • 96.5k
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 ...
bsoelch's user avatar
  • 5,677
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 ...
Wheat Wizard's user avatar
  • 96.5k
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)...
caird coinheringaahin g's user avatar
28 votes
17 answers
4k views

s-n-a-k-e-a-r-o-u-n-d--->

This ascii-art 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 ...
noodle man's user avatar
  • 5,252
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 ...
l4m2's user avatar
  • 20.4k
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 ...
bsoelch's user avatar
  • 5,677
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. ...
Toby Speight's user avatar
  • 6,218
19 votes
13 answers
1k views

Calculating Transitive Closure

First attempt at a question. Calculating Transitive Closure According to Wikipedia, "the transitive closure \$R^*\$ of a homogeneous binary relation \$R\$ on a set \$X\$ is the smallest ...
SanguineL's user avatar
  • 471
7 votes
19 answers
2k views

Number of bits needed to represent the product of the first primes

Input An integer \$n\$ greater than or equal to 1. Output The number of bits in the binary representation of the integer that is the product of the first \$n\$ primes. Example The product of the first ...
Simd's user avatar
  • 1,812
9 votes
5 answers
796 views

Compute the logarithm of a matrix

There have already been challenges about computing the exponential of a matrix , as well as computing the natural logarithm of a number. This challenge is about finding the (natural) logarithm of ...
bsoelch's user avatar
  • 5,677
13 votes
15 answers
2k views

Can you perform swaps?

Today's problem is easy. You're given two strings A and B of equal length consisting of only the characters ( and ). Check ...
Huỳnh Trần Khanh's user avatar
9 votes
9 answers
664 views

Print Bing's sentience

Generative AI is here! It's great for certain things, but it has a few problems. Not only has it broken our Stack Exchange community, it also makes mistakes. For example, when you ask Bing AI if it is ...
joyoforigami's user avatar
15 votes
7 answers
1k views

Solve quadratic equations when 1+1=0

There already have been multiple challenges about carryless multiplication, this challenge will work with the same calculation rules. You task is given a quadratic polynomial ...
bsoelch's user avatar
  • 5,677
17 votes
25 answers
3k views

Is this a powerful number?

A powerful number is a positive integer \$n\$ such that for every prime \$p\$ that divides \$n\$, \$p^2\$ also divides \$n\$. Or equivalently, \$n\$ is powerful if and only if it can be written in the ...
alephalpha's user avatar
  • 46.5k
21 votes
13 answers
3k views

Chinese color mixing

Objective Given two Chinese ideographs meaning basic colors, output the ideograph that means the color resulting from mixing them. Basic colors The basic colors are: 靑(U+9751; blue) 赤(U+8D64; red) 黃(...
Dannyu NDos's user avatar
  • 5,447
1 vote
1 answer
183 views

Most elegant one-liner to generate sqlite INSERTs

Challenge You find yourself in a bash terminal, and want to do some simple tests on sqlite3. So you issue the following command: ...
ChrisB's user avatar
  • 119
17 votes
22 answers
2k views

Compute this fractal matrix

The unique-disjointness matrix ( UDISJ(n) ) is a matrix on all pairs of subsets of {1...,n} with entries $$ U_{(A,B)}=\begin{cases} 0, ~ if ~ |A\cap B|=1\\ 1, ~ ...
bsoelch's user avatar
  • 5,677
32 votes
36 answers
2k views

Make a k-skip-j range

On the Mathematica Stack Exchange, 100xln2 asks: I need a list of integers […] The list contains integers and is characterized by [three] parameters, lets call them k and j [and listmax], which ...
Lynn's user avatar
  • 68.1k
17 votes
23 answers
3k views

Meta-cat program

Write a program or function that takes input and outputs/returns a full program (in the same language) that outputs said input. Note that the input may contain any printable ASCII character or newline ...
Dadsdy's user avatar
  • 2,035

15 30 50 per page