The runtime speed of the solution is a criterion of this challenge. "Faster, faster would be better."

learn more… | top users | synonyms

4
votes
0answers
252 views

Fastest simple regex matcher

Write a regex matcher that supports the following special characters. ? -> matches 1 or none of the previous character, class, or group * -> 0 or more of the previous character, class, or ...
16
votes
0answers
384 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
488 views

Challenge: take ciphered text and decipher, also print out if it was offset to the left or right

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 ...
3
votes
3answers
336 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, ...
3
votes
2answers
566 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 ...
5
votes
6answers
404 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
404 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 ...
5
votes
3answers
525 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
409 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
141 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 ...
6
votes
2answers
697 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
1answer
363 views

tic-tac-toe data structure design challenge [closed]

Design a data structure such that getWinner method runs in O(1) time. Assume you call put(x, y, Player) for each move. Best space efficient solution wins.
2
votes
2answers
182 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 ...
1
vote
2answers
230 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 ...
2
votes
2answers
269 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
416 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
298 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
982 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
2k 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 ...
6
votes
4answers
608 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 ...
-3
votes
5answers
734 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 ...
-7
votes
5answers
415 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
1
vote
5answers
287 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 ...
30
votes
2answers
1k 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
349 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: ...
0
votes
1answer
422 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
11answers
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: ...
3
votes
13answers
1k 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 ...
56
votes
23answers
6k views

Contest: fastest way to sort a big array of Gaussian-distributed data

Following the interest in this question, I thought it would be interesting to make answers a bit more objective and quantitative by proposing a contest. The idea is simple: I have generated a binary ...
11
votes
2answers
651 views

Fastest python code to find a set of winning words in this game

This is a word game from a set of activity cards for children. Below the rules is code to find the best triplet using /usr/share/dict/words. I thought it was an interesting optimization problem, and ...
4
votes
4answers
489 views

Code-Challenge:The Nearest Prime

Challenge In this task you would be given an integer N you have to output the nearest prime to the integer. If the number is prime itself output the number. The input N is given in a single ...
3
votes
4answers
391 views

Code-Challenge: Farey sequence (II)

Challenge In this task you would be given an integer N (less than 10^6), output the number of terms in the Farey sequence of order N. The input N is given in a single line,the inputs are ...
7
votes
2answers
488 views

Break the broken cipher

I have designed a simple random generator that cycles two numbers in a chaotic way using a multiply and modulus method. It works great for that. If I were to use it as a cipher generator it would ...
2
votes
4answers
722 views

Carmichael Numbers

EDIT: I am changing the challenge. Write a program to print Carmichael numbers. The challenge is to print the maximum number of them in less than 5 secs. The numbers should be in increasing order. ...
6
votes
3answers
406 views

Fast Topswops calculation

From AZSPCS: Suppose you have a deck containing n cards. Each card contains a number from 1 to n, and each number appears on exactly one card. You look at the number on the top card -- let's says ...
4
votes
4answers
888 views

Fast line drawing algorithm

The task is to find a way to draw a horizontal line in an array of 16-bit integers. We're assuming a 256x192 pixel array with 16 pixels per word. A line is a contiguous run of set (1) bits. Lines ...