Skip to main content
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. ...
Arnauld's user avatar
  • 198k
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: <...
Neil's user avatar
  • 177k
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 ...
Sebastian's user avatar
  • 221
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". ...
Command Master's user avatar
9 votes

Sum of the sum of all possible subsets raised to power k

Python, \$\mathcal O(NK^2)\$ ...
loopy walt's user avatar
  • 16.8k
8 votes

Upside-Down Pyramid Addition...REVERSED!

Haskell, 22 bytes foldl(flip$scanr(-))[] Try it online!
xnor's user avatar
  • 147k
8 votes

Sum of the sum of all possible subsets raised to power k

Python, \$O(N K \log K)\$ ...
Command Master's user avatar
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 ...
tsh's user avatar
  • 35.6k
7 votes

Find the longest uninterrupted arc

Python 3, O(n*log(n)), 167 bytes ...
ovs's user avatar
  • 60.6k
7 votes

Upside-Down Pyramid Addition...REVERSED!

Haskell, 42 bytes f[]=[] f a=f(zipWith(-)a$tail a)++[last a] Try it online!
nimi's user avatar
  • 35.9k
7 votes

Pick a random string at a fixed edit distance

Python, 3453 bytes ...
gsitcia's user avatar
  • 3,401
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 ...
absoluteAquarian's user avatar
6 votes

Is this number a palindrome?

APL (Dyalog Unicode), O(1) ⊃∘'111111111110… …...
Adám's user avatar
  • 31.1k
6 votes

Pick a random string at a fixed edit distance

Python, 932 bytes, \$O(4^k\cdot n^{2k+2})\$ ...
bsoelch's user avatar
  • 6,035
5 votes
Accepted

Find the longest uninterrupted arc

JavaScript (Node.js), O(n), 234 229 228 211 bytes ...
l4m2's user avatar
  • 28.3k
5 votes
Accepted

Remove entries from array to sort it and maximize sum of elements

Haskell, \$O(n \log n)\$ time, \$O(n)\$ space ...
Anders Kaseorg's user avatar
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 ...
fireflame241's user avatar
  • 16.3k
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 ...
Jonathan Allan's user avatar
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 :) ...
The Empty String Photographer's user avatar
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)\$). ...
Anders Kaseorg's user avatar
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: ...
peter ferrie's user avatar
  • 1,135
4 votes

Approximate floating point number with n-digit precision

Haskell, O(10p) in worst case 121 119 bytes ...
jferard's user avatar
  • 1,794
4 votes

Upside-Down Pyramid Addition...REVERSED!

MathGolf, 14 11 bytes xÆ‼├│?;∟;]x Try it online! Explanation ...
maxb's user avatar
  • 6,947
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 ...
Jonathan Allan's user avatar
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 ...
Value Ink's user avatar
  • 12.6k
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 ...
mousetail 'he-him''s user avatar
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 ...
c--'s user avatar
  • 2,513
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 ...
mousetail 'he-him''s user avatar
4 votes

Pick a random string at a fixed edit distance

Python, \$\mathcal{O}((n+k)^{2k})\leq\mathcal{O}(4^k n^{2k})\$ ...
Value Ink's user avatar
  • 12.6k

Only top scored, non community-wiki answers of a minimum length are eligible