516 votes
Accepted

High throughput Fizz Buzz

x86-64+AVX2 assembly language (Linux, gcc+gas) Build and usage instructions This program is most conveniently built using ...
ais523 - high effort answers's user avatar
138 votes

Calculate the number of primes up to n

C, 0.026119s (Mar 12 2016) ...
Dennis's user avatar
  • 209k
65 votes

High throughput Fizz Buzz

After much trial and error, with the goal of not resorting to Assembly while achieving the best single-threaded performance, this is my entry: ...
Isaac G.'s user avatar
  • 751
46 votes
Accepted

Fastest yes in the west

C, 112 bytes, 28 TB/s, score ≈ 0.008 ...
Anders Kaseorg's user avatar
43 votes

Fastest Mini-Flak Quine

Mini-Flak, 6851113 cycles The program (literally) I know most people aren't likely expecting a Mini-Flak quine to be using unprintable characters and even multi-byte characters (making the encoding ...
ais523 - high effort answers's user avatar
38 votes

High throughput Fizz Buzz

I was struggling to get more than 2.75GB/s on my rig but then I realised I wasn't compiling with -O3 which bumped me up to 6.75GB/s. ...
Neil's user avatar
  • 163k
34 votes

Fastest yes in the west

Bash, 3 bytes, 1.9 GB/s yes Try it online! Admittedly this is a troll solution, but the rules do not explicitly forbid it, and it should get you a value close ...
Yonatan N's user avatar
  • 557
25 votes

Calculate the number of primes up to n

C99/C++, 8.9208s (28 Feb 2016) ...
arjan de lumens's user avatar
23 votes

High throughput Fizz Buzz

I tweaked Neil's code a bit (so most credit goes to him) and managed to squeeze some more performance out of it; I also prepared it for unrolling more loops but ultimately I gave up (that's why the ...
Kamila Szewczyk's user avatar
22 votes

High throughput Fizz Buzz

Here is my attempt at using just-in-time compilation to emit fast FizzBuzz assembly that is specialized for every digit length. It's basically the same idea as Neil's answer, just more overengineered....
Paolo Bonzini's user avatar
18 votes

Fastest Mini-Flak Quine

128,673,515 cycles Try it online Explanation The reason that Miniflak quines are destined to be slow is Miniflak's lack of random access. To get around this I create a block of code that takes in a ...
Wheat Wizard's user avatar
  • 95.5k
16 votes
Accepted

Approximating a special case of the Riemann Theta function

C++ No more naive approach. Only evaluate inside the ellipsoid. Uses the armadillo, ntl, gsl and pthread libraries. Install using ...
Ton Hospel's user avatar
  • 14.8k
15 votes

Calculate the number of primes up to n

Python 2 (PyPy 4.0), 2.36961s (Feb 29 2016) ...
Dennis's user avatar
  • 209k
15 votes
Accepted

Calculate the permanent as quickly as possible

gcc C++ n ≈ 36 (57 seconds on my system) Uses Glynn formula with a Gray code for updates if all column sums are even, otherwise uses Ryser's method. Threaded and vectorized. Optimized for AVX, so don'...
Ton Hospel's user avatar
  • 14.8k
15 votes

Bentley's coding challenge: k most frequent words

C++ (a la Knuth) I was curious how Knuth's program would fare, so I translated his (originally Pascal) program into C++. Even though Knuth's primary goal was not speed but to illustrate his WEB system ...
ShreevatsaR's user avatar
  • 1,073
15 votes
Accepted

The fastest Sudoku solver

C++ - 0.201s official score Using Tdoku (code; design; benchmarks) gives these results: ~/tdoku$ lscpu | grep Model.name Model name: Intel(R) Core(TM) i7-4930K CPU @ 3.40GHz ~/tdoku$ # ...
53x15's user avatar
  • 349
14 votes

Calculate the number of primes up to n

Java, 25,725.315 seconds on this machine This is not going to win, I just wanted to post an answer that does not use any sieves. UPDATE: This is currently ranked at about 150,440.4386 times slower ...
Addison Crump's user avatar
14 votes

Calculate the Hafnian as quickly as possible

Haskell ...
Christian Sievers's user avatar
14 votes

Prime containment numbers (speed edition)

C++ (GCC) + x86 assembly, score 32 36 62 in 259 seconds (official) Results computed so far. My computer runs out of memory after 65. ...
japh's user avatar
  • 751
14 votes

High throughput Fizz Buzz

Coded in rust- modern languages can be fast too. Build with cargo build --release* and run with ./target/release/fizz_buzz. The ...
Aiden4's user avatar
  • 2,435
13 votes

Prime containment numbers (speed edition)

JavaScript (Node.js), score 24 in 241 seconds Results \$a(1)\$ to \$a(21)\$ are solved in ~15 seconds on TIO \$a(22)=231129413434717353759619679\$ was found in ~70 seconds on my laptop \$a(23)=...
Arnauld's user avatar
  • 186k
13 votes
Accepted

Find the number of n-by-n (-1, 0, 1) matrices with zero permanent as quickly as possible

Rust, \$A(5) = 186481694371\$ in 0.2 s, \$A(6) = 19733690332538577\$ in 580 s (Unofficial times on a Core i7-10710U with 6 cores/12 threads.) src/main.rs ...
Anders Kaseorg's user avatar
13 votes

Fastest yes in the west

x86-64 machine code (Linux system calls), 29B * 4.7GB/6.6GB = ~20.6 on tmpfs on Skylake (Or even 28 bytes, but I haven't benchmarked Noah's suggestion of using the low 16 bits of the address as the ...
Peter Cordes's user avatar
  • 4,718
13 votes

The smallest area of a convex grid polygon

JavaScript (Node.js), \$n=19\$ This is a very early attempt. Given 10 minutes, it is only able to compute up to \$n=19\$ on my laptop and finds the same values as the ones listed in A070911. It ...
Arnauld's user avatar
  • 186k
12 votes

Sum of smallest prime factors

Nim, 3.6e13 Simply sieving is not the best answer when trying to calculate the highest N possible since the memory requirements become too high. Here's a different approach (started with Nim a couple ...
Nicolás Siplis's user avatar
12 votes

Fastest draw in the west!

...
Riolku's user avatar
  • 451
12 votes

How many sorting networks?

Rust, \$n = 6\$ in ≈ 59 seconds The main simplifying observation here is that we don’t need to run the network on all \$n!\$ permutations; it suffices to run it on all \$2^n\$ binary strings. We can ...
Anders Kaseorg's user avatar
11 votes

Calculate the number of primes up to n

Rust, 0.37001 sec (12 June 2016) About 10 times slower than slower than Dennis' C answer, but 10 times faster than his Python entry. This answer is made possible by ...
11 votes

Fastest yes in the west

C (clang), 88 63 bytes, 2.5GB/s b[2048];main(){for(wmemset(b,'\ny\ny',2048);write(1,b,8192););} Try it online! Edit: Saved 25 bytes thanks to @ceilingcat by ...
Neil's user avatar
  • 163k
11 votes
Accepted

How quickly can you convert an NFA to a DFA?

Rust, score 15 in ≈ 6000 s Most of my optimization effort has actually gone into memory usage rather than speed, for reasons you can see in this table of results on my system (AMD Ryzen 1800X): ...
Anders Kaseorg's user avatar

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