Questions tagged [restricted-time]

For challenges with a restriction on the amount of time a submission is allowed to use.

Filter by
Sorted by
Tagged with
91 votes
216 answers
22k views

Find the Factorial!

Create the shortest program or function that finds the factorial of a non-negative integer. The factorial, represented with ! is defined as such $$n!:=\begin{...
Kevin Brown-Silva's user avatar
67 votes
9 answers
5k views

Addition in base -1+i

Gaussian integers are complex numbers of the form a+bi where a and b are both integers. In ...
Sp3000's user avatar
  • 61.8k
56 votes
16 answers
8k views

Extreme Fibonacci

There have been a billion iterations of Fibonacci challenges on this website, so lets spice things up with a Fibonacci challenge of a billion iterations! Your challenge is to output the first 1000 ...
user1502040's user avatar
  • 3,779
45 votes
3 answers
3k views

Enumerate valid Brainf**k programs

Golunar/Unary is a way to encode all valid Brainfuck programs, but it is not an enumeration, since most natural numbers do not correspond to a valid program. For the purpose of this challenge, assume ...
Dennis's user avatar
  • 210k
44 votes
69 answers
4k views

Fibonacci-orial

Definition Fibonacci sequence F(n), on the positive integers, are defined as such: ...
Leaky Nun's user avatar
  • 49.7k
43 votes
9 answers
7k views

Text compression and decompression — "Nevermore."

With the recent discussion about the use of compression tools in code golf, I thought it would be a nice challenge to write your own text compressor and decompressor. Challenge: Write two programs: ...
Ilmari Karonen's user avatar
39 votes
18 answers
7k views

11 = (1+2+3+4+5) - (1+2+3) + (6) - (4)

Given a positive integer N, your task is to return the number of steps required by the following algorithm to reach N: Find the smallest triangular number Ti such that Ti ≥ N. Build the ...
Arnauld's user avatar
  • 191k
39 votes
3 answers
24k views

Solve Rubik's cube

Write the shortest program that solves Rubik's cube (3*3*3) within a reasonable amount of time and moves (say, max. 5 seconds on your machine and less than 1000 moves). The input is in the format: <...
aditsu quit because SE is EVIL's user avatar
36 votes
18 answers
6k views

Calculate 500 digits of pi

Write a program to calculate the first 500 digits of pi, meeting the rules below: It must be less than 500 characters in length. It cannot include "pi", "math.pi" or similar pi constants, nor may it ...
Thomas O's user avatar
  • 3,338
34 votes
6 answers
3k views

Finding Snakes in a Matrix

Challenge Given a binary matrix and a binary string, determine if that binary string can be found starting at any point in the matrix and moving in any direction at any subsequent point to form the ...
hyper-neutrino's user avatar
  • 41.4k
32 votes
3 answers
5k views

Area of a Self-Intersecting Polygon

Consider a potentially self-intersecting polygon, defined by a list of vertices in 2D space. E.g. ...
Martin Ender's user avatar
30 votes
13 answers
7k views

Multiply two numbers without using any numbers

You are given as input two strings representing positive integers in base 10, such as "12345" and "42". Your task is to output a ...
N. Virgo's user avatar
  • 7,254
29 votes
1 answer
1k views

Find the area of the largest convex polygon

Given a list of integer coordinates, find the area of the biggest convex polygon you can construct from the list such that - every vertex is in the list no element of the list is contained within ...
orlp's user avatar
  • 39.1k
28 votes
19 answers
2k views

Find the sortable years

The year 2013 had an interesting property: the digits are consecutive when sorted (0123). Let's call this type of number a sortable number: a non-negative integer whose base-10 digits are consecutive ...
ETHproductions's user avatar
28 votes
5 answers
3k views

Shortest common superstring

Given a list of strings s_0, s_1, ..., s_n find the shortest string S that contains each of ...
Zakharia Stanley's user avatar
27 votes
17 answers
3k views

Compute the multinomial coefficient

Time for another easy challenge in which all can participate! The multinomial theorem states: $$(x_1 + x_2 + \cdots + x_m)^n = \sum_{k_1 + k_2 + \cdots + k_m = n} \binom n {k_1, k_2, \dots, k_m} \...
quintopia's user avatar
  • 4,087
27 votes
19 answers
5k views

Last non-zero digit of n!

Given an integer 1 ≤ N ≤ 1,000,000 as input, output the last non-zero digit of N!, where ! is the factorial (the product of all numbers from 1 to N, inclusive). This is OEIS sequence A008904. Your ...
fR0DDY's user avatar
  • 4,579
25 votes
14 answers
5k views

Hamming numbers

Hamming numbers are numbers which evenly divide a power of 60. Equivalently, their prime factors are all \$ \le 5 \$. Given a positive integer, print that many Hamming numbers, in order. Rules: Input ...
grokus's user avatar
  • 1,267
25 votes
6 answers
1k views

Fraction to exact decimal

Write a program or function that given two integers a, b outputs a string containing a decimal number representing the fraction a/b exactly. If a/b is integer, simply output the value, without a ...
orlp's user avatar
  • 39.1k
24 votes
26 answers
3k views

Find the prime factors

In this task, you have to write a program, that computes the prime factors of a number. The input is a natural number 1 < n < 2^32. The output is a list of the prime factors of the number in the ...
FUZxxl's user avatar
  • 10.1k
24 votes
22 answers
10k views

Check if a number is a product of consecutive integer numbers

Some numbers such as: 6, 12, 20, 30, 42, 56, 60, 90, 120 and so on as can be expressed as a product of consecutive integer numbers as shown below. ...
Suraz's user avatar
  • 371
24 votes
9 answers
933 views

Animal-Alphabetical Sequence

The Animal-Alphabetical Sequence is an infinite string of letters built accordingly to the following procedure: Start with the letter A; Replace each letter with ...
Jyenas's user avatar
  • 248
23 votes
23 answers
4k views

Encode - Shuffle - Decode

Challenge Your task is to encode an integer as a string of ASCII characters, then successfully decode it after said string has been randomly shuffled. You will write two programs/functions, which ...
Delfad0r's user avatar
  • 6,246
23 votes
28 answers
2k views

Count forth and back then double up

Let's count... Count up to 2 and back to 1 Count up to 4 and back to 1 Count up to 6 and back to 1 ... ok you got it... put all these together and you'll get the following sequence ...
user avatar
23 votes
5 answers
1k views

Can this pattern be made with dominoes?

Given a pattern of squares on a grid, determine if it is possible to create that pattern with non-overlapping dominoes. In case you are not familiar, a domino is a rectangular shape created by joining ...
Beefster's user avatar
  • 9,901
23 votes
2 answers
964 views

Optimize sorting, using "Sub-vector reversals"

This is a fewest-operations challenge where the objective is to sort a vector into ascending order using the fewest reversals. Your algorithm can only sort the vector using "sub-vector reversals"1, ...
Stewie Griffin's user avatar
22 votes
16 answers
4k views

Four Squares Together

Lagrange's four square theorem tells us any natural number can be represented as the sum of four square numbers. Your task is to write a program that does this. Input: A natural number (below 1 ...
qwr's user avatar
  • 12.1k
22 votes
9 answers
1k views

Calculating Collatz Cousins

Define the function f(n) for a positive integer n as follows: n / 2, if n is even 3 * n + 1, if n is odd If you repeatedly apply this function to any n greater than 0, the result always seems to ...
DLosc's user avatar
  • 38.5k
22 votes
2 answers
1k views

The Combinatorics of Transistor

The video game Transistor features a very interesting ability system. You collect 16 "Functions" which you can use in 16 different slots. What's interesting is that there are 3 types of slots and ...
Martin Ender's user avatar
22 votes
10 answers
1k views

Last Nonzero Digits of a Factorial in Base

You should write a program or function which given three positive integers n b k as input outputs or returns the last k digits ...
randomra's user avatar
  • 20.8k
22 votes
2 answers
1k views

Each step of the Levenshtein distance

In this challenge you will write a program that takes two newline-separated strings, s1 (the first line) and s2 (the second line), as input (STDIN or closest). You can assume that the length of s1 ...
xenia's user avatar
  • 8,112
21 votes
9 answers
4k views

Compute the inverse of an integer modulo 100000000003

The task is the following. Given an integer x (such that x modulo 100000000003 is not equal ...
user avatar
21 votes
11 answers
2k views

Fruit bagging factory

Your mission is to build an algorithm (program or function) that can optimize packing fruit from a conveyor belt into bags to be sent off to retailers, optimizing for a largest number of bags. Each ...
Angs's user avatar
  • 4,957
21 votes
3 answers
2k views

Piet (Mondrian)'s Puzzle

For more information, watch this video, and go to A276523 for a related sequence. The Mondrian Puzzle (for an integer n) is the following: Fit non-congruent ...
clismique's user avatar
  • 6,982
21 votes
3 answers
679 views

Reaching one's lucky numbers in reputation

A new code-golfer, Joe, just registered to the site. He has 1 reputation but determined to reach all his lucky numbers in reputation exactly. Joe believes in higher powers which will help him to ...
randomra's user avatar
  • 20.8k
21 votes
1 answer
936 views

How should I tile my kitchen?

I recently ordered some new and colorful tiles to replace my boring old white tiling for my kitchen. However, when the tiles arrived, they were all in a weird shape! Therefore, I need a program to ...
Nathan Merrill's user avatar
21 votes
7 answers
2k views

The Tic Tac Toe Dictionary

A TicTacToe game can be represented by a string denoting the sequence of positions as the players make their move. 0 1 2 3 4 5 6 7 8 Assume ...
st0le's user avatar
  • 2,208
20 votes
12 answers
3k views

Fastest draw in the west! [closed]

We're going rootin' tootin' cow-poke shootin! This is a simple contest, first program to draw their pistol wins. How it works: I require 2 things from you, an executable, and a command to be run from ...
tuskiomi's user avatar
  • 3,831
20 votes
9 answers
623 views

Zeroes at end of \$n!\$ in base \$m\$

Related: Zeroes at the end of a factorial Today, we are going to calculate how many zeroes are there at the end of \$n!\$ (the factorial of \$n\$) in base \$m\$. Or in other words: For given integers \...
tsh's user avatar
  • 34.5k
20 votes
2 answers
378 views

Exactly N in a line

Given a number N from 2 to 8, place any nonzero number of queens on a grid of any size so that every queen has exactly N queens (counting itself) in each of its row, column, and each diagonal. This ...
xnor's user avatar
  • 145k
20 votes
10 answers
584 views

Counting Fountains

A fountain is arrangement of coins in rows so that each coin touches two coins in the row below it, or is in the bottom row, and the bottom row is connected. Here's a 21 coin fountain: Your challenge ...
isaacg's user avatar
  • 41.9k
20 votes
4 answers
2k views

The Fatal Error Challenge

Objective Write a routine that accepts a string of printable ASCII characters, s, and returns a string containing the same characters as s, reordered so that no two-character substring appears more ...
COTO's user avatar
  • 3,691
20 votes
2 answers
511 views

Maximal Substring Construction

In this challenge, you are passed two things: A string length, N A list of strings, L, each with an assigned point value. Any ...
Nathan Merrill's user avatar
19 votes
7 answers
2k views

Number of distinct non-empty subsequences of binary expansion

A subsequence is any sequence that you can get from another by deleting any amount of characters. The distinct non-empty subsequences of 100 are ...
orlp's user avatar
  • 39.1k
19 votes
2 answers
717 views

Counting creatures on a hexagonal tiling

This challenge will have you count "creatures" in the tile game Palago. A creature is any closed shape that can be formed by Palago tiles of matching colour in a hexagonal grid. The game Palago ...
Peter Kagey's user avatar
  • 8,659
19 votes
6 answers
1k views

Fastest tweetable integer factorizer

The task is to find a non-trivial factor of a composite number. Write code that finds a non-trivial factor of a composite number as quickly as possible subject to your code being no more than 140 ...
user avatar
18 votes
10 answers
2k views

Reciprocal copycats

Let \$A\$ be a positive integer consisting of \$n\$ decimal digits \$d_1,d_2,...,d_n\$. Let \$B\$ be another positive integer. For the purpose of this challenge, we call \$A\$ a copycat of \$B\$ if ...
Arnauld's user avatar
  • 191k
18 votes
7 answers
1k views

Find The Wordiest Combination Lock

I have a combination padlock which has letters instead of numbers. It looks like this: http://pictures.picpedia.com/2012/09/Word_Combination_Padlock.jpg There are 5 reels, each of which has 10 ...
Edwin Young's user avatar
17 votes
3 answers
1k views

Plight of the Concorde

Background The traveling salesman problem (TSP) asks for the shortest circuit that visits a given collection of cities. For the purposes of this question, the cities will be points in the plane and ...
A. Rex's user avatar
  • 2,579
17 votes
3 answers
1k views

Solve Rubik's Clock

Rubik's Clock is a round(ish) puzzle with two flat sides. On each side, front and back, there are 9 clock faces, arranged on a 3x3 grid. In addition, there are 4 pegs (switches) in between the clock ...
Jitse's user avatar
  • 6,896