The runtime speed of the solution is a criterion of this challenge. "Faster, faster would be better."
2
votes
2answers
473 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 ...
0
votes
1answer
164 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 ...
0
votes
1answer
332 views
Find nth root of variable without using math operators/functions
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 ...
12
votes
3answers
1k 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 n as input which specifies the size of the board.
Starting ...
11
votes
6answers
1k 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, ...
6
votes
3answers
1k 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 ...
5
votes
2answers
313 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 ...
5
votes
7answers
653 views
Super speedy totient function
The goal is simple: calculate the totient function for as many numbers as you can in 10 seconds and sum the numbers.
You must print your result at the end and you must actually calculate it. No ...
6
votes
16answers
1k 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 n as possible within 10 seconds.
...
10
votes
7answers
1k 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 B, Tthat satisfy either of the following criterion.
...
19
votes
10answers
4k 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 ...
34
votes
13answers
9k 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 ...
104
votes
19answers
47k views
How slow is python really? (Or how fast is your language?)
I have this code which I have written in python/numpy
from __future__ import division
import numpy as np
import itertools
n=6
iters = 1000
firstzero = 0
bothzero = 0
""" The next line iterates over ...
4
votes
3answers
181 views
Autoscale complex function
Context: We are working on a complex image drawing program to produce mugs, t-shirts, and so on. Here is an example of such function
However, we are facing the following problem: Random generated ...
2
votes
2answers
152 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 made of lines that have the same format : A concatenation of a fixed-size key (the same among all the file ...
4
votes
2answers
390 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 ...
-5
votes
3answers
138 views
Making “Code runner” [closed]
The task is to execute functions stored in a database, preferably xml. For example a function containing system.out.println("a"); is stored in a file code.xml and has been extracted as a string, how ...
6
votes
7answers
830 views
Count the Zeros
For a given n, count the total number of zeros in the decimal representation of the positive integers less than or equal to n. For instance, there are 11 zeros in the decimal representations of the ...
1
vote
4answers
249 views
Creating a catalogue index
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 ...
7
votes
7answers
682 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 ...
3
votes
2answers
592 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 ...
6
votes
3answers
479 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 ...
17
votes
2answers
821 views
The number of possible numeric outcomes of parenthesizations of 2^2^…^2
Consider an expression 2^2^...^2 with n operators ^. Operator ^ means exponentiation ("to the power of"). Assume that it has no default assosiativity, so the expression needs to be fully parenthesized ...
2
votes
5answers
771 views
Challenge: take ciphered text and decipher, also print out if it was offset to the left or right [closed]
Problem:
Take input text like this: (all input should be considered strings)
Upi djpi;f ytu yu[omh pmr yp yjr ;rgy.
And figure out if it was offset left or offset right (on a standard qwerty ...
5
votes
3answers
469 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, ...
5
votes
2answers
2k 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 fastest code possible to do this. I will test the code on values starting at ...
6
votes
6answers
574 views
Count the number of cyclic words in an input
Cyclic Words
Problem Statement
We can think of a cyclic word as a word written in a circle. To
represent a cyclic word, we choose an arbitrary starting position and
read the characters in ...
0
votes
4answers
475 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 ...
8
votes
3answers
1k 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), ...
3
votes
3answers
751 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 ...
2
votes
1answer
201 views
Bob's Financial Planning (Maximize)
Bob's Financial Planning
Bob lives in Pecunia. It is a small island city completely governed by the Pecunia City Council (PCC). PCC has decided to encourage foreign investments in the city by waiving ...
8
votes
2answers
2k views
Fastest semiprime factorization
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:
...
2
votes
2answers
260 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?
clc; clear;
sms=0;
count = 1;
x=0;
for i=11:28123
fac = factor(i);
sm = 1;
for j = 1:length(fac)-1
...
2
votes
2answers
325 views
List ALL prime-factorized natural numbers in ANY order
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 ...
3
votes
2answers
695 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 order. For example, for n = 10 the output would be:
1:
2: 2^1
3: 3^1
4: 2^2
5: 5^1
6: 2^1 3^1
7: 7^1
8: 2^3
...
2
votes
2answers
661 views
Help johnny to solve this Puzzle
Scenario
Little Johnny wants to play with his friends today. But his babysitter won't let him go! After a lot of begging, the heartless nanny gives him her brand new electronic puzzle and says: "If ...
0
votes
3answers
424 views
Prime tester + nth-prime finder (TO BE CLOSED) [duplicate]
Possible Duplicate:
List of first n prime numbers most efficiently and in shortest code
This is to be closed soon - please don't answer (mod- please close!)
This challenge is to write the ...
2
votes
9answers
2k views
Triangle Puzzle
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 ...
5
votes
1answer
1k views
Sudoku board generator
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 ...
5
votes
12answers
4k views
Random sampling without replacement
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 ...
8
votes
5answers
985 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 ...
-2
votes
5answers
2k 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
goal
the winner is the code which runs in minimum time ...
-6
votes
5answers
616 views
write a code the find n-th number of Gray Code list
Write a function that, given N >= 0, finds the Nth number in a standard Gray code.
Example input:
1
2
3
4
Example output:
1
3
2
6
Additional reference
2
votes
11answers
458 views
position of the only 1 in a number in binary format
Given N is a number from this list : 1, 2, 4, 8, 16, .... 2^i
as you know there is only a single "1" in binary representation of above numbers.
Question : write a code to find out the position of ...
35
votes
3answers
2k views
Help Indiana Jones to get the treasure
Story
Indiana Jones was exploring a cave where a precious treasure is located. Suddenly, an earthquake was happen.
When the earthquake was ended, he noticed that some rocks fell from the ceiling ...
2
votes
2answers
459 views
Fastest C/C++ comparison function for an opaque field containing doubles
Description:
Write the fastest comparison function for an opaque field containing a double. Here is my example:
// Three-way comparison function:
// if a < b: negative result
// if a > b: ...
1
vote
1answer
545 views
Write a Program to Solve the Secret Code
There is a secret code, 12 characters in length. Each character can be either a number or a letter. Every two hours, a random character in the secret code is revealed.
For example:
Hour 2:
_ _ Q _ ...
8
votes
12answers
2k views
Write the fastest Fibonacci
This is yet another challenge about the Fibonacci numbers.
The goal is to compute the 20'000'000th Fibonacii number as fast as possible. The decimal output is about 4 MiB large; it starts with:
...
6
votes
3answers
1k views
Lottery Ball Problem
A woman works at a lottery ball factory. She's instructed to open up a lottery ball creation kit composed of 1 red rubber ball and n strips of digits from 0 through 9.
She's instructed to do the ...
3
votes
13answers
2k views
Check if number is a sum of consecutive numbers or not
Write a program that checks if a given positive integer can be represented as sum of two or more consecutive positive integers.
Example:
43 can be represented as 21 + 22
10 = 1+2+3+4
but 4 cannot ...