437 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 ...
user avatar
135 votes

Calculate the number of primes up to n

C, 0.026119s (Mar 12 2016) ...
user avatar
  • 207k
85 votes
Accepted

Extending OEIS: Counting Diamond Tilings

Algebra, graph theory, Möbius inversion, research, and Java The symmetry group of the hexagon is the dihedral group of order 12, and is generated by a 60 degree rotation and a mirror flip across a ...
user avatar
  • 42.8k
75 votes

How slow is Python really? (Or how fast is your language?)

Python2.7 + Numpy 1.8.1: 10.242 s Fortran 90+: 0.029 s 0.003 s 0.022 s 0.010 s Damn straight you lost your bet! Not a drop of parallelization here too, just straight Fortran 90+. EDIT I've taken ...
user avatar
  • 4,302
68 votes

How slow is Python really? (Or how fast is your language?)

Python 2.7 - 0.882s 0.283s (OP's original: 6.404s) Edit: Steven Rumbalski's optimization by precomputing F values. With this optimization cpython beats pypy's 0.365s. ...
user avatar
68 votes
Accepted

How slow is Python really? (Or how fast is your language?)

C++ bit magic 0.84ms with simple RNG, 1.67ms with c++11 std::knuth 0.16ms with slight algorithmic modification (see edit below) The python implementation runs in 7.97 seconds on my rig. So this is ...
user avatar
  • 951
61 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: ...
user avatar
  • 711
44 votes

How slow is Python really? (Or how fast is your language?)

Rust: 0.011s Original Python: 8.3 A straight translation of the original Python. ...
user avatar
  • 541
43 votes

Fastest yes in the west

C, 112 bytes, 28 TB/s, score ≈ 0.008 ...
user avatar
40 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 ...
user avatar
38 votes

How slow is Python really? (Or how fast is your language?)

C++ (VS 2012) - 0.026s 0.015s Python 2.7.6/Numpy 1.8.1 - 12s Speedup ~x800. The gap would be a lot smaller if the convolved arrays were very large... ...
user avatar
36 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. ...
user avatar
  • 145k
33 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 ...
user avatar
  • 547
25 votes

Calculate the number of primes up to n

C99/C++, 8.9208s (28 Feb 2016) ...
user avatar
24 votes
Accepted

Calculate a probability exactly and quickly

Python A closed-form formula of p(n) is An exponential generating function of p(n) is where ...
user avatar
  • 356
22 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 ...
user avatar
21 votes

How slow is Python really? (Or how fast is your language?)

C Takes 0.015s on my machine, with OP's original code taking ~ 7.7s. Tried to optimize by generating the random array and convolving in the same loop, but it doesn't seem to make a lot of difference. ...
user avatar
  • 8,956
21 votes

Find the largest prime whose length, sum and product is prime

Python 2.7 on PyPy, {2404}3{1596} (~10^4000) ...
user avatar
  • 41.3k
20 votes
Accepted

How high can you go? (A coding+algorithms challenge)

Nimrod (N=22) ...
user avatar
20 votes
Accepted

Magic Sequences of length n

Python, n≈108 ...
user avatar
  • 137k
19 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....
user avatar
18 votes

How slow is Python really? (Or how fast is your language?)

J I don't expect to beat out any compiled languages, and something tells me it'd take a miraculous machine to get less than 0.09 s with this, but I'd like to submit this J anyway, because it's pretty ...
user avatar
17 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 ...
user avatar
  • 88.3k
16 votes

How slow is Python really? (Or how fast is your language?)

Perl - 9.3X faster...830% improvement On my ancient netbook, the OP's code takes 53 seconds to run; Alistair Buxton's version takes about 6.5 seconds, and the following Perl version takes about 5.7 ...
user avatar
  • 1,245
16 votes

How Slow Is Python Really (Part II)?

C++ x150 x450 x530 Instead of array I used bits (and dark magic). Thanks @ace for the faster random function. How does it work: the first 15th bits of the integer ...
user avatar
  • 1,157
16 votes
Accepted

Fastest player for Dots and Boxes

C99 - 3x3 board in 0.084s 2020 edit/disclaimer: See comments section. It looks like there may have been errors in the original code. Proceed to the remainder of this answer with some skepticism until ...
user avatar
  • 764
15 votes

Extending OEIS: Counting Diamond Tilings

C Introduction As commented by David Carraher, the simplest way of analysing the hexagon tiling seemed to be to take advantage of its isomorphism with the 3 dimensional Young Diagram, essentially an x,...
user avatar
15 votes

Calculate the number of primes up to n

Python 2 (PyPy 4.0), 2.36961s (Feb 29 2016) ...
user avatar
  • 207k
15 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 ...
user avatar
  • 14.6k
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'...
user avatar
  • 14.6k

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