Questions tagged [fastest-code]
The winner of a fastest-code challenge is determined by the runtime performance of the submissions. For fairness, all submissions should be benchmarked on the same machine, which usually means all submissions have to be tested by the host of the challenge. Alternatively, the submission can be compared to a reference program. For scoring by asymptotic time complexity, use [fastest-algorithm] instead.
208
questions
3
votes
2
answers
178
views
Non-Decreasing Fibonacci Sequence modulo M
Given integers \$a,b,m, k, n\$ and array \$F = (f_1, f_2,...,f_n)\$ defined as:
\begin{cases}
f_1 = \text{a}\\
f_2 = \text{b}\\
f_i = (f_{i-1} + f_{i-2}) \text{ mod m},∀i > 2
\end{cases}
When \$F\$ ...
11
votes
5
answers
1k
views
9-16-25 2D Matrix
Given three grids and the sum of rows and columns of each grid, your task is:
Grid \$3×3\$: Fill the grid from \$1\$ to \$9\$, ensure no repeats within the grid.
Grid \$4×4\$: Fill the grid from \$1\...
-1
votes
3
answers
471
views
Sum of Positive and Negative Powers of 2
Given a binary string equivalent to \$n\$, write out the least possible number of terms needed to express \$n\$.
A term is defined as an addition of either \$2^k\$ or \$(-2^k)\$, where \$k\$ is a non-...
3
votes
4
answers
682
views
Fastest count of certain hypercubes with labeled vertices
CHALLENGE
This is a fastest-code challenge.
Count how many n-dimensional hypercubes with n=1,2,3,4 exist, with vertices labeled with either 1 or 0, such that there does not exist any rectangle formed ...
2
votes
2
answers
243
views
Binary expansion and partition numbers [closed]
Not sure if it's correct to ask such a question on this site, but let's try.
Let a(n) be a sequence of positive integer such that a(1) = 1. To reproduce the sequence a(n) through itself, use the ...
9
votes
5
answers
2k
views
Random factorized numbers
Input
The code should take an integer \$n\$ between 1 and 1000.
Output
The code should output positive integers with \$n\$ bits. Accompanying each integer should be its full factorization. Each ...
6
votes
5
answers
763
views
Count the size of the Levenshtein neighborhood
Input
A binary string \$s\$ of length \$n\$ and a positive integer \$k \leq n\$.
Output
The number of binary strings with Levenshtein distance exactly \$k\$ from the string \$s\$.
Example outputs
Each ...
5
votes
4
answers
634
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 ...
15
votes
5
answers
845
views
Compute the chromatic number of special graphs
This challenge is about computing the chromatic number of special types of graphs.
Input
The input will consist of two integers.
A positive integer \$n > 1\$.
A distance \$d < n\$.
Task
The ...
12
votes
10
answers
3k
views
Calculate max depth of JSON data
Challenge
Given some JSON data, calculate the maximum depth reached. (Both arrays and dictionaries increase the depth)
Input/Output
The program is expected to read a JSON string from stdin and as soon ...
21
votes
7
answers
1k
views
How many sorting networks?
Below on the left is a picture of a sorting network that can sort 4 inputs. On the right you can see it sorting the input 3,2,4,1.
A sorting network of size ...
0
votes
1
answer
285
views
Generate all possible equations from a list of numbers [closed]
This is my first codegolf post so let me know if I have missed anything. Thanks :)
Description
You are given a list of numbers with 2 < n <= 6 length i.e. [1, ...
10
votes
5
answers
618
views
Record Least Uncommon Multiple Counts
The Greatest Common Divisor, or gcd, of two positive integers \$x\$ and \$y\$ is the largest positive integer that divides both \$x\$ and \$y\$.
The Least Common Multiple, or lcm, of two positive ...
10
votes
1
answer
432
views
Find the linear transformation
Given a set of bit vectors \$A\$ and a binary matrix \$M\$, we can define the set \$MA = \{ Mx : x \in A \}\$, where \$ M x \$ is the result of the matrix multiplication of \$ M \$ by \$ x \$ over \$\...
4
votes
1
answer
231
views
Triangularly embed a graph on a surface
This challenge arises from a claim made in a MathOverflow answer and a paper linked in that answer which seems to back up the claim:
Searching for triangular embeddings is much quicker than ...