Skip to main content

Questions tagged [fastest-code]

The winner of a fastest-code challenge is determined by the runtime performance of the submissions. For fairness, all submissions should be benchmarked on the same machine, which usually means all submissions have to be tested by the host of the challenge. Alternatively, the submission can be compared to a reference program. For scoring by asymptotic time complexity, use [fastest-algorithm] instead.

Filter by
Sorted by
Tagged with
14 votes
6 answers
610 views

False Positives on an Integer Lattice

Leaderboard ...
Martin Ender's user avatar
14 votes
8 answers
1k views

Digit sum of central binomial coefficients

The task is simply to see how much faster you can calculate n choose n/2 (for even n) than the builtin function in python. Of course for large n this is a rather large number so rather than output ...
user avatar
6 votes
3 answers
2k views

Another Euler Brick in the Wall

A Euler Brick is a cuboid where the length of all the edges are integers and all of the diagonals of the faces are integers as well. All sides must also be different. Your program has to find as many ...
Beta Decay's user avatar
  • 23.4k
7 votes
3 answers
903 views

The distance between circles

Imagine you are given two lists of numbers which are to be interpreted as points on a circle of circumference 1000. Let us say ...
user avatar
6 votes
3 answers
2k views

2nd byte bias of RC4

Short version RC4, designed in 1987, is one of the most famous stream ciphers. This question asks you to practically demonstrate its 2nd byte bias (for a ...
hola's user avatar
  • 147
37 votes
12 answers
6k views

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

The number 113 is the first prime whose length 3 is prime, digital sum 5 = 1 + 1 + 3 is ...
Calvin's Hobbies's user avatar
6 votes
1 answer
988 views

'Number' Crunching Benchmark

I just want to do some benchmarking of different programming languages. So here is a tip: You can use as many characters as you want. In the end there is only the time your program needed. So, here ...
Armin's user avatar
  • 171
2 votes
0 answers
122 views

Write program which finds shortest expression for number [duplicate]

Write program which finds shortest expression for big integer. Expression may consist of + - * / ^ ! ( ) operations. ! stands ...
Somnium's user avatar
  • 2,669
13 votes
3 answers
776 views

Write a FAST word equation solver

This question is similar to Write a word equation solver by David Frank but different in three important ways: (1) David asked for just the first solution found, and I am asking for all the solutions. ...
JeffSB's user avatar
  • 427
6 votes
1 answer
2k views

Optimal Minesweeper on the Largest Board

Overview: Your challenge is to write a program that will play minesweeper optimally, giving the best move in any position. Moreover, you must do this on the largest board possible. Game details: ...
isaacg's user avatar
  • 42.1k
5 votes
2 answers
898 views

Longest mathematical expression in a grid

Given a grid which contains these signs: 0..9, x, =, write the fastest code that outputs the longest string of connected (horizontally, vertically, and diagonally adjacent), distinct cells which is a ...
user3585425's user avatar
0 votes
1 answer
344 views

Find the fastest swim relay (shortest path of unique nodes and types)

fastest relay time = lowest possible total integer value of (a freestyle swimmers time) + (1 breastroke swimmers time) + (another backstroke swimmers time) + (another butterfly swimmers time) Each ...
InfinteScroll's user avatar
2 votes
1 answer
1k views

Find nth root of variable without using math operators/functions [closed]

Write a program which, given two positive integers n and x, will display the n-th root of x (which is also x1/n) in decimal to an accuracy of 0.00001. The program must output the resulting number in ...
Timothy Smith's user avatar
18 votes
3 answers
8k views

Fastest player for Dots and Boxes

The challenge is to write a solver for the classic pencil and paper game Dots and Boxes . Your code should take two integers m and ...
user avatar
18 votes
5 answers
4k views

Fast Trig Calculation

Fast Trigonometry Calculations Your task is to create a program which can calculate the sine, cosine and tangent of an angle in degrees. Rules No built-in trigonometry functions (not even secant, ...
user avatar
5 votes
3 answers
2k views

Super fast sampling from a tricky random distribution

This is a micro-optimization challenge. The task is to sample from the maximally skewed stable distribution F(x;1,-1,Pi/2,0). See Table 1 of http://arxiv.org/pdf/0908.3961v2.pdf . It is easiest to ...
user avatar
9 votes
2 answers
567 views

Filter a large file in small memory

The challenge is a follow-up to Filter a large file quickly which had two submissions where were as fast as wc! This time the difficulty is that RAM is severely restricted which means that new ...
user avatar
22 votes
11 answers
21k views

Super speedy totient range

The goal is simple: calculate Euler's totient function for as many numbers in the range 1 to N in 10 seconds. You must actually calculate every value! To verify your results, also print the sum; test ...
qwr's user avatar
  • 12.3k
14 votes
16 answers
8k views

How much can you quickly multiply?

With the recent Python bashing, here's an attempt to show Python's strengths. Your challenge is to write a program that calculates the factorial of as high a number ...
user80551's user avatar
  • 2,608
14 votes
8 answers
2k views

Filter a large file quickly

The challenge is to filter a large file quickly. Input: Each line has three space separated positive integers. Output: All input lines A ...
user avatar
36 votes
11 answers
9k views

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

Now that everyone has developed their (often amazing) low level coding expertise for How slow is Python really? (Or how fast is your language?) and How Slow Is Python Really (Part II)? it is time for ...
user avatar
55 votes
14 answers
20k views

How Slow Is Python Really (Part II)?

This is a follow up to How slow is Python really? (Or how fast is your language?). It turns out it was a bit too easy to get a x100 speedup for my last question. For those who have enjoyed the ...
user avatar
155 votes
21 answers
112k views

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

I have this code which I have written in Python/NumPy ...
user avatar
2 votes
2 answers
221 views

Merging text files based on a prefix key

Imagine an ordered file set : file1, file2, ... fileN. Each file is a textual file that is ...
Steve Schnepp's user avatar
5 votes
2 answers
732 views

Analysing the most common words in a text, and replacing them with a single byte

This is a very crude text encoding algorithm I came up with the other day. It won't work if the text has more than 256 different characters in it – but it does support Unicode, at least in my Python ...
Jetlef's user avatar
  • 221
1 vote
4 answers
313 views

Creating a catalogue index [closed]

You have a program which creates an index for a catalogue. The last step is missing: it must find and consolidate page ranges within the list of pages for each entry. Each entry is currently an ...
Tom Dudman's user avatar
7 votes
8 answers
3k views

Enumerate all number that are palindromic in at least two of base 2, 8, 10, 16 or 64

Multi palindromic numbers Finding all number for which at least two** representation are palindromic, with more than one** characters, if in decimal, octal, hexadecimal, binary or in base64. ** have ...
F. Hauri  - Give Up GitHub's user avatar
6 votes
2 answers
3k views

Fastest modular exponentiation

The challenge is to write code in any open source, available on linux, language of your choice to perform modular exponentiation. The input will be two randomly chosen 2048 bit positive integers ...
user avatar
10 votes
3 answers
733 views

Quickly divide in Manufactoria

Background Manufactoria has been marketed as a game, but we code-golfers can see it for what it really is: a two-dimensional programming language. The Manufactoria programming language is based ...
PhiNotPi's user avatar
  • 29.1k
20 votes
3 answers
1k views

The number of possible numeric outcomes of parenthesizations of 2^2^...^2

Consider an expression 2^2^...^2 with n operators ^. Operator ...
Vladimir Reshetnikov's user avatar
6 votes
3 answers
2k views

The making of "Spot It!": Finding almost unique sets

Puzzle: Find a deck of c cards, each containing p pictures, such that no two pictures match on a given card, and exactly 1 picture on each card matches exactly 1 picture on each of the other cards, ...
Edward Brey's user avatar
22 votes
4 answers
23k views

Fastest code to find the next prime

The problem is as follows. Input: An integer n Output: The smallest prime bigger than n. The challenge is to give the ...
user avatar
1 vote
4 answers
586 views

Race to a Million

This falls under the Code puzzles the best. Fastest way to render the numbers 1-million in a web browser. Preferably using PHP, but use what you must. Numbers must be more than one on a line in the ...
CEPA's user avatar
  • 131
17 votes
3 answers
4k views

Longest non-repeating Game-of-Life sequence

Given a positive integer N, determine the starting pattern on a N x N-grid that yield the longest non-repeating sequence under Game of Life-rules, and ends with a fixed pattern (cycle of length 1), ...
Per Alexandersson's user avatar
4 votes
3 answers
5k views

Secret Santa Challenge [duplicate]

Possible Duplicate: Holiday Gift Exchange Background: Secret Santa is a Western Christmas tradition in which members of a group or community are randomly assigned a person to whom they ...
StudleyJr's user avatar
  • 285
37 votes
4 answers
18k views

Fastest semiprime factorization [closed]

Write a program to factorize a semi-prime number in the shortest amount of time. For testing purposes, use this: \$38!+1\$ (\$523022617466601111760007224100074291200000001\$) It is equal to: \$...
Soham Chowdhury's user avatar
2 votes
2 answers
446 views

given prime factors of a number, what is the fastest way to calculate it's proper divisors? [closed]

Given prime factors of a number, what is the fastest way to calculate divisors? ...
S L's user avatar
  • 123
4 votes
2 answers
565 views

List ALL prime-factorized natural numbers in ANY order [closed]

This is a variant of List prime-factorized natural numbers up to N in ascending order, but the solutions can be very different. Write a program that outputs prime factorizations of all natural ...
Petr's user avatar
  • 4,380
8 votes
4 answers
1k views

List prime-factorized natural numbers up to N in ascending order

For a given n list prime factorization of all natural numbers between 1 and n in ascending ...
Petr's user avatar
  • 4,380
10 votes
19 answers
1k views

Square-free semiprime counting

Definition A square-free semiprime is a natural number that is the product of two distinct prime numbers. The task Given a natural number n, count all square-free ...
ardnew's user avatar
  • 2,317
-1 votes
10 answers
10k views

Triangle Puzzle [closed]

Triangle Puzzle Consider the triangle below. This triangle would be represented by the following input file.    5   9 6  4 6 8 0 7 1 5 By starting at the top and ...
Sammy's user avatar
  • 63
6 votes
4 answers
16k views

Solve the Magic Hexagon [closed]

A magic hexagon is a hexagon where every row and every diagonal add up to the same value. In this case the value is 38. Each number from 1 to 19 must be used exactly once. This image shows a solution ...
PriestVallon's user avatar
6 votes
1 answer
2k views

Sudoku board generator [closed]

A program that randomly generates a Sudoku game board with varying degrees of difficulty (however you decide to measure difficulty). Sudoku requires that there is only one solution, so your program ...
Jim McKeeth's user avatar
10 votes
16 answers
13k views

Random sampling without replacement [closed]

Create a function that will output a set of distinct random numbers drawn from a range. The order of the elements in the set is unimportant (they can even be sorted), but it must be possible for the ...
Jim McKeeth's user avatar
15 votes
5 answers
3k views

Fastest Sort in BrainF***

After having implemented QuickSort in BrainF***, I realized it probably wasn't that quick. Operations that are O(1) in normal languages (like array indexing) are significantly longer in BF. Most of ...
AShelly's user avatar
  • 4,671
2 votes
11 answers
8k views

compute number of 1 bits in a binary representation of a number

The goal is to write a program that returns number of 1 bits in a given number. Examples 5 -> 2 1254 -> 6 56465 -> 8 Winner The winning ...
Ali1S232's user avatar
  • 435
-6 votes
3 answers
1k views

write a code the find n-th number of Gray Code list [closed]

Write a function that, given N >= 0, finds the Nth number in a standard Gray code. Example input: 1 2 3 4 Example output: ...
mohammad shamsi's user avatar
1 vote
13 answers
2k views

position of the only 1 in a number in binary format [closed]

Every number of the form 2i (where i is a non-negative integer) has a single 1 in its binary representation. Given such a number, output the 1-based position of the ...
mohammad shamsi's user avatar
45 votes
3 answers
4k views

Help Indiana Jones to get the treasure

Story Indiana Jones was exploring a cave where a precious treasure is located. Suddenly, an earthquake happened. When the earthquake ended, he noticed that some rocks that had fallen from the ...
JiminP's user avatar
  • 3,462
4 votes
3 answers
2k views

Fastest python implementation of multiplication table

I'd be interested to see who can come up with the fastest function to produce multiplication tables, in the following format: ...
bluepnume's user avatar
  • 143