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. ...
  • 170k
9 votes
Accepted

Fastest way to compute order of magnitude in x86 assembly

7 cycles, constant time Here's a solution based on my answer to this SO Question. It uses BSR to count how many bits are needed to hold the number. It looks up how many decimal digits needed to ...
  • 4,421
8 votes

Upside-Down Pyramid Addition...REVERSED!

Haskell, 22 bytes foldl(flip$scanr(-))[] Try it online!
  • 139k
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 ...
  • 30.8k
7 votes

Find the longest uninterrupted arc

Python 3, O(n*log(n)), 167 bytes ...
  • 55.2k
7 votes

Upside-Down Pyramid Addition...REVERSED!

Haskell, 42 bytes f[]=[] f a=f(zipWith(-)a$tail a)++[last a] Try it online!
  • 35.4k
6 votes

Fastest way to compute order of magnitude in x86 assembly

Best case 8 cycles, Worst case 12 cycles Since it is not clear in the question, I am basing this off the Ivy Bridge latencies. The approach here is to use the bsr (...
6 votes

Same word when missing letters

C++11 Excuse the variable names. Calculates hamming distance between each pair of words then tries replacing characters in words with '-', and calculates hamming distance between the word with '-' ...
  • 9,165
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

Is this number a palindrome?

APL (Dyalog Unicode), O(1) ⊃∘'111111111110… …...
  • 28.3k
5 votes
Accepted

Determine the move in which a LOGO turtle crosses a point that it has already visited

C, O(n), 65 95 102 bytes After I made at least one additional test case, some more code naturally needed to be added. Thanks to Serge Mosin for finding another bug. ...
  • 30.9k
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

Find the longest uninterrupted arc

JavaScript (Node.js), O(n), 234 229 228 211 bytes ...
  • 13k
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 ...
  • 16.1k
4 votes

Free a Binary Tree

C99, 94, O(n) Edit: everyone seems to refer to struct Node just as Node as if the typedefed ...
4 votes

Heaviest increasing subsequence

Python, O(n log n) I didn't golf this, because I'm competing primarily on the fastest code side of things. My solution is the heaviest_subseq function, and a test ...
  • 41.4k
4 votes

Same word when missing letters

C++, Where l is the word length, m is the number of "wildcards" (or dashes) and n is the number of words (of length l.) Skimming over the submissions, it seems that they're all either inherently ...
  • 711
4 votes

Approximate floating point number with n-digit precision

Haskell, O(10p) in worst case 121 119 bytes ...
  • 1,784
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: ...
  • 1,105
4 votes

Upside-Down Pyramid Addition...REVERSED!

MathGolf, 14 11 bytes xÆ‼├│?;∟;]x Try it online! Explanation ...
  • 6,677
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 ...
  • 11.5k
3 votes

Determine the move in which a LOGO turtle crosses a point that it has already visited

Here is a solution in JavaScript ...
3 votes
Accepted

Mr. Moneybag's Money Piles

O(K log N), many characters of Python Edit: Improved by replacing merge sort with radix sort. This is an improvement over my previous answer, but I'm posting it separately because it's a different ...
  • 139k
3 votes

Same word when missing letters

Because this needs more Java Streaming: Running the unofficial 351k word list at 11, 3 in ~7 seconds, beating the JavaScript version by only 4 minutes and 3 seconds. ;) My secret: instead of ...
  • 339
3 votes

Same word when missing letters

JavaScript (E6) + HTML or C# console or C++ console Edit 3 At last, here is the C++ version. It's not exactly C++11 as it compiles with Visual Studio 2010, but requires -std=c++11 with gcc. Compiled ...
  • 31.8k
3 votes
Accepted

Heaviest increasing subsequence

javascript (ES6) O(n log n) 253 characters ...
3 votes

Hard Puzzle Game Solver

Python 2.7, runs almost instantly (0.02 seconds on my laptop) ...
  • 2,871
3 votes

Digital River (Shortest And Fastest Solution)

JavaScript (ES6) This is a quite fast answer using a quite slow language. Really, executing time should not be a problem using any language with hash tables. All my tests under 100 ms. Anonymous ...
  • 31.8k

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