Skip to main content
OverflowAI is here! AI power for your Stack Overflow for Teams knowledge community. Learn more
532 votes

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
66 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
  • 761
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
39 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
  • 171k
36 votes
Accepted

High throughput Fizz Buzz

283 GB/s output on AMD Ryzen 9 7700X. To build (tested with GCC 13): ...
David Frank's user avatar
  • 2,424
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
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
  • 98.8k
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.9k
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.9k
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,085
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 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
  • 761
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,465
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
  • 193k
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,837
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
  • 193k
12 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
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
  • 171k
11 votes

Fastest square root of an arbitrary size

C++, 140 µs This is a trivial answer that uses GMP, but I’m submitting it anyway to drive home the point that the test cases are way too small. Scores in the range of literally nanoseconds per input ...
Anders Kaseorg's user avatar
11 votes

Compute all close strings quickly

C ...
ngn's user avatar
  • 15.3k
11 votes
Accepted

Compute the size of intersections of sets

Python 3.8 (pre-release) ...
ngn's user avatar
  • 15.3k
11 votes

fastest matrix multiplication on x86

C (GCC), 2.65× faster than mat_mul_fast (Compiled with gcc -O3 -mavx2 -mfma, measured on my Intel Comet Lake i7-10710U.) ...
Anders Kaseorg's user avatar

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