17
votes
Upside-Down Pyramid Addition...REVERSED!
JavaScript (ES6), 62 58 49 46 bytes
Saved 3 bytes thanks to @Oliver
Returns the list as a comma-separated string.
...
11
votes
Accepted
Bumping Series Implementation
Charcoal, 21 bytes
NθI⊘×⊕θX²↔⁻θ⊕×⊖⌈₂θ⌈₂θ
Try it online! Link is to verbose version of code. Outputs the nth term. Explanation:
<...
10
votes
RADD decomposition of an integer
C++11 (gcc), O(log(n))
This algorithm can check, if a number n has a RADD-decomp and calculate the decomp in O(D)=O(log(n)), where D is the number of digits. It also includes a pre-test, with shorter ...
10
votes
Compute how many are no larger than each item in an array
Python, \$O(n \frac{\log n}{\log \log n})\$
Uses the approach from the paper "Optimal Algorithms for List Indexing and Subset Rank".
...
9
votes
8
votes
Upside-Down Pyramid Addition...REVERSED!
Haskell, 22 bytes
foldl(flip$scanr(-))[]
Try it online!
8
votes
7
votes
Accepted
Approximate floating point number with n-digit precision
JavaScript, O(10p) & 72 bytes
r=>p=>{for(a=0,b=1,t=10**p;(a/b*t|0)-(r*t|0);a/b<r?a++:b++);return[a,b]}
It is trivial to prove that the loop will be ...
7
votes
7
votes
Upside-Down Pyramid Addition...REVERSED!
Haskell, 42 bytes
f[]=[]
f a=f(zipWith(-)a$tail a)++[last a]
Try it online!
7
votes
6
votes
Upside-Down Pyramid Addition...REVERSED!
TI-BASIC, 54 bytes
Ans→L₁:dim(L₁→dim(L₂:While 1-Ans:L₁(Ans→L₂(Ans:-ΔList(L₁→L₁:dim(Ans:End:L₁(Ans→L₂(Ans:L₂
Input is the list of the right side of the triangle ...
6
votes
6
votes
5
votes
Accepted
5
votes
Accepted
Remove entries from array to sort it and maximize sum of elements
Haskell, \$O(n \log n)\$ time, \$O(n)\$ space
...
5
votes
Accepted
Leon's shooting range problem
Area-based algorithm, \$O(k^2+n\log(k))\$
Our general strategy is to instead select points (outside the sticker rectangles) from the square (-1,-1) to (1,1), then repeat if we don't get a point within ...
5
votes
Bumping Series Implementation
Jelly, 13 bytes
Port of Neil's answer (I was working towards it myself but he nailed it).
Unsure of the complexity of this closed-form formula, but think it is \$O(M(B(n))B(n))\$ where \$n\$ is the ...
5
votes
(Cops) Fast and Golfiest Season 1: The Lord of the Strings
ATOI string to integer, 130 Bytes, Python 3 (IDLE), probably \$O(n)\$ or worse, 9:10 am UTC (it's DST in uk), Cracked in 18 min, so 0 points :( 4 points under new system :)
...
5
votes
Compute how many are no larger than each item in an array
Python, \$O(n \log n)\$
Simple algorithm based on merge sort that runs in \$O(n \log n)\$ for inputs in any range (assuming comparisons are \$O(1)\$).
...
4
votes
Accepted
Fastest way to perform the equivalent of an if-statement in x86 assembly
And then I realised that we can be faster, and use no additional registers:
...
4
votes
Approximate floating point number with n-digit precision
Haskell, O(10p) in worst case 121 119 bytes
...
4
votes
Upside-Down Pyramid Addition...REVERSED!
MathGolf, 14 11 bytes
xÆ‼├│?;∟;]x
Try it online!
Explanation
...
4
votes
Upside-Down Pyramid Addition...REVERSED!
Jelly, 6 bytes
ṚIƬZḢṚ
A monadic Link accepting a list of integers which yields a list of integers.
Try it online!
How?
Builds the whole triangle then extracts ...
4
votes
Accepted
How many ways can given subsequence occur in given sequence?
Ruby, \$\mathcal{O}(nm)\$
I think I got the analysis for this right. Should be \$\mathcal{O}(nm)\$ because for each of the \$n\$ characters in the master sequence, it goes through at most \$m\$ steps ...
4
votes
(Cops) Fast and Golfiest Season 1: The Lord of the Strings
Concatenated Words, Python, 177 bytes, \$O(n)\$ time assuming input is a set where \$n\$ is the number of words, Cracked by Cursor Coercer, 7 points
This is \$O(2^L)\$ where \$L\$ is the length of ...
4
votes
(Cops) Fast and Golfiest Season 1: The Lord of the Strings
Removing Stars From a String, C (GCC), 47 bytes, \$O(n)\$ complexity, Cracked by jimmy23013, 25 points
f(char*s){for(char*p=s;*s-42?*p++=*s:p--;s++);}
Attempt This ...
4
votes
(Cops) Fast and Golfiest Season 1: The Lord of the Strings
Generate Parenthesis, ><> (Fish), 178 bytes, \$O(n!)\$, Cracked by C--
Time: 2023-07-21 12:35:24Z
Hover over any symbol to see what it does. If this appears glitched unformulated version ...
4
votes
Pick a random string at a fixed edit distance
Python, \$\mathcal{O}((n+k)^{2k})\leq\mathcal{O}(4^k n^{2k})\$
...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
fastest-algorithm × 79math × 17
code-golf × 10
code-challenge × 9
string × 6
combinatorics × 6
geometry × 5
subsequence × 5
array × 5
sequence × 4
decision-problem × 4
integer × 4
graph-theory × 4
arithmetic × 3
number-theory × 3
fastest-code × 3
algorithm × 3
number × 2
matrix × 2
permutations × 2
cops-and-robbers × 2
counting × 2
optimization × 2
palindrome × 2
puzzle-solver × 2