All Questions

Filter by
Sorted by
Tagged with
16 votes
12 answers
2k views

Implement glob Matcher

Implement a function of pattern and string to be matched, return true if the pattern matches the WHOLE string, otherwise false. Our glob pattern syntax is: ? ...
user avatar
  • 5,831
16 votes
4 answers
31k views

Shortest URL regex match in JavaScript [closed]

Create the shortest regular expression that will roughly match a URL in text when run in JavaScript Example: ...
user avatar
12 votes
8 answers
2k views

Build a nine-level word guessing game

The basics: You'll need to provide a nine-level word guessing game in the fewest characters possible (in your language of choice). The metrics: Provide a word-list (one word per line, seperated by a ...
user avatar
  • 1,659
40 votes
12 answers
8k views

Drawing a gradient in ASCII art

Task description: Write a program as short as possible to draw a radial gradient in ASCII art. The size of the output grid is predefined. The center point and the characters to be used for the ...
user avatar
  • 12.8k
26 votes
33 answers
9k views

Sort a list of numbers [closed]

About Code-Bowling: In golf, you try to get the lowest score (smallest application, most elegant, etc). In Bowling, you try to get the highest score. So if you follow, the goal of a Code-Bowling ...
user avatar
  • 919
14 votes
8 answers
787 views

Calculating areas.

The smallest code that gives the area between the curve p(x) = a0 + a1*x + a2*x2 + ..., the line y = 0, the line x = 0 and the line x = C (i.e. something like this: ) You can assume that p(x) >= 0 ...
user avatar
  • 5,438
9 votes
9 answers
863 views

Split a word into parts with equal scores

Assuming A=1, B=2... Z=26, and the value of a word is the sum of these letter values, it is possible to split some words into two pieces such that they have equal values. For example, "wordsplit" can ...
user avatar
  • 3,262
13 votes
10 answers
1k views

Forecast the weather

Write the shortest program to forecast the weather for the next 7 days The input (from stdin) is the weekday and the season The output (to stdout) is seven lines weekday and the temperature in ...
user avatar
  • 14.9k
29 votes
44 answers
3k views

Implement Bogosort

Is solving Sudoku too hard? Even the brute force version? Here's a coding exercise that's a little easier. I hope. :-P Write the shortest function to implement bogosort. In specific, your function ...
user avatar
23 votes
13 answers
5k views

Implement a Brute Force Sudoku Solver

Implement the shortest Sudoku solver using guessing. Since I have received a few request I have added this as an alternative question for those wishing to implement a brute force sudoku solver. ...
user avatar
9 votes
1 answer
2k views

Build an engine for a maze game

This is a follow up of Print a maze question. If you like this question, please add more maze generation algorithms ;). For this task you'll have to implement a game engine for one player who must ...
user avatar
  • 5,906
17 votes
48 answers
2k views

IPv4 Integer Conversion Function

Write the shortest function to convert an IP address into it's integer representation and output it as an integer. To change an IPv4 address to it's integer representation, the following calculation ...
user avatar
76 votes
53 answers
29k views

Tips for golfing in Ruby

What general tips can you give for golfing in Ruby? I'm looking for ideas that can be applied to code golf problems in general that are specific to Ruby. (For example, "Remove comments" would not be ...
user avatar
  • 1,247
27 votes
4 answers
3k views

Implement a Non-Guessing Sudoku Solver

Implement the shortest Sudoku solver. Sudoku Puzzle: ...
user avatar
30 votes
49 answers
6k views

Calculate ISBN-13 check digit

Write a function which, given the first 12 digits of an ISBN-13 code, will calculate the entire ISBN via calculating and appending an appropriate check digit. Your function's input is a string ...
user avatar
12 votes
8 answers
6k views

Binary tree encoding [closed]

Let's suppose you have a complete binary tree (i.e. each internal node has exactly two non empty descendants). Each node contains a nonzero integer. You are given the task of encoding and decoding the ...
user avatar
  • 5,906
8 votes
4 answers
567 views

Binary search ("bisect") tool

Implement the binary search algorithm as used to identify the source code revision that breaks a computer software program. Your tool should take two arguments specifying the earliest and latest ...
user avatar
  • 5,557
9 votes
10 answers
2k views

Crossword numbering

Produce a program to correctly number a crossword grid. Input The input will be the name of a file representing the crossword grid. The input filename may be passed as an argument, on the standard ...
user avatar
131 votes
136 answers
42k views

Obfuscated Hello World

Create the shortest possible obfuscated program that displays the text "Hello World". In order to be considered an obfuscated program, it must meet at least two of the following requirements: Does ...
user avatar
9 votes
3 answers
893 views

Project Euler Problem 12: optimize memory usage

I am referring to Project Euler #12. Write the solution in any language you want, but consume the least amount of memory while executing. Running time is not measure in this case. The sequence of ...
user avatar
  • 285
18 votes
2 answers
787 views

Quine that takes as input the name of a language and outputs the same thing implemented in the input language

From Quine central: Write a quine that takes as input the name of a language and outputs the same thing implemented in the input language. The source article has something you can work from, but as ...
user avatar
  • 12.2k
15 votes
41 answers
5k views

Shortest Floor Function

Your task is to implement a floor function in as few bytes as possible. A floor function is a function that takes a real number and returns the largest integer less than or equal to the input. Your ...
user avatar
48 votes
11 answers
16k views

Write an interpreter for the untyped lambda calculus

The challenge is to write an interpreter for the untyped lambda calculus in as few characters as possible. We define the untyped lambda calculus as follows: Syntax There are the following three ...
user avatar
  • 1,769
30 votes
19 answers
13k views

Twinkle Twinkle Little Star

Write a program to play the popular English nursery rhyme. (This file is licensed under the Creative Commons Attribution-Share Alike 3.0 Unported license. Attribution: Helix84 at the English language ...
user avatar
  • 5,557
6 votes
1 answer
2k views

Nokia mystery puzzle [closed]

A friend sent me this puzzle. I'm pretty sure solving it will require some programming. Can anyone crack it? The original is here in case of encoding issues in the past below. ...
user avatar
  • 12.2k
11 votes
2 answers
4k views

Decryption by pattern analysis

You are given an encrypted string, encrypted using a very simple substitution cipher. Problem You do not know what the cipher is but you do know the ciphertext is English and that the most frequent ...
user avatar
  • 3,262
27 votes
19 answers
9k views

Print 1 to 1000 in C++ without semi-colons

Following this popular question, present your solution which prints the numbers 1 to 1000 (all of them, not the string "1 to 1000" verbatim or something funny) in C++ without using any semi-colons. ...
user avatar
  • 12.2k
19 votes
5 answers
5k views

Print a random maze

Write a program that generates and prints a random maze using the algorithm of your choice. The maze should be different for multiple runs of the program. Height and width are given as command line ...
user avatar
  • 5,906
63 votes
121 answers
10k views

Reverse stdin and place on stdout

Requirements: Take an input on stdin including new lines / carriage returns of unlimited length (only bounded by system memory; that is, there is no inherent limit in the program.) Output the reverse ...
user avatar
  • 3,262
44 votes
43 answers
10k views

Reverse Polish notation

You must evaluate a string written in Reverse Polish notation and output the result. The program must accept an input and return the output. For programming languages that do not have functions to ...
user avatar
18 votes
12 answers
861 views

Compute modular inverse

Given two positive numbers \$x\$ and \$n\$ with \$x<2^n\$, write the shortest possible function to compute \$x^{-1} \mod 2^n\$. In other words, find \$y\$ such that \$xy=1 \mod 2^n\$. Your ...
user avatar
17 votes
2 answers
1k views

Slot Machine Hacker

Problem: Slot Machine Hacker from Facebook Hacker Cup 2011 Round 1B Goal: Shortest code in your favourite language using stdin/stdout. You cannot assume ...
user avatar
  • 12.2k
15 votes
4 answers
956 views

Freely available books for code golfing? [closed]

Can you recommend any freely available books about code golfing in general and especially in Java and C++?
49 votes
49 answers
7k views

Tips for golfing in PowerShell

What general tips do you have for golfing in Windows PowerShell? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to PowerShell (e.g. "...
user avatar
  • 12.8k
33 votes
14 answers
19k views

Drawing a cube in ASCII art

Task description: Draw a cube in ASCII art in roughly a cabinet projection. Monospaced fonts often have characters that are about twice as high as they are wide. ...
user avatar
  • 12.8k
6 votes
33 answers
3k views

Print largest integer you can with the fewest characters [closed]

Find a way to output a large integer with few characters. Solutions will be scored based on the magnitude of the number and shortness of code. EDIT: Let's impose a time limit of a minute on sensible ...
user avatar
  • 12.2k
25 votes
35 answers
2k views

Finding "sub-palindromes".

The shortest code that finds all unique "sub-palindromes" of a string, that is: any substring with length > 1 that is a palindrome. eg.1 ...
user avatar
  • 5,438
71 votes
56 answers
18k views

Tips for code-golfing in C#

What general tips do you have for golfing in C#? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to C# (e.g. "remove comments" is not an ...
user avatar
  • 1,783
38 votes
53 answers
4k views

196 algorithm code golf

Write a short program for 196-algorithm. The algorithm starts from an integer, then adds its reverse to it until a palindrome is reached. e.g. ...
user avatar
  • 5,438
13 votes
1 answer
1k views

Shortest path in a graph

Write a program to take a graph (from either standard input or a file, your choice) and find a shortest path in the graph. Graphs are specified using the following format: ...
user avatar
6 votes
3 answers
424 views

Compress programs

Write a program/script that decompresses and passes any compressed data appended at the end of the binary/file as standard input to a program specified as arguments. ...
user avatar
  • 5,906
11 votes
1 answer
717 views

Write a compressing util for gzip files

The task of this challenge is as following: Write a program that reads a file of reasonable size (let's say <16 MB) from stdin or anywhere else (however you like, but must not be hardcoded), and ...
user avatar
  • 9,960
60 votes
28 answers
17k views

Tips for golfing in C++

What general tips do you have for golfing in C++? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to C++ (e.g. "remove comments" is not ...
user avatar
  • 12.2k
35 votes
26 answers
29k views

Morse code translator

Write the shortest program to transform the standard input into Morse code. Characters not in the table should be printed as they are.
user avatar
  • 5,906
-1 votes
1 answer
5k views

Poisson random number generator [closed]

What is the shortest function (implemented in C) that will return a random draw from a Poisson distribution (given the mean or λ parameter)? ...
user avatar
12 votes
2 answers
3k views

Test if a given number is a Vampire Number [duplicate]

EDIT: In the interest of increasing the complexity, i've added more to the challenge. In mathematics, a vampire number (or true vampire number) is a composite natural number v, with an even ...
user avatar
  • 2,140
5 votes
5 answers
896 views

Tree traversal. [closed]

Write the shortest code that traverses a tree, breadth-first. Input any way you like Output a list of "names" of the nodes in correct order.
user avatar
  • 5,438
33 votes
52 answers
5k views

Sum of primes between given range

Write the shortest code for finding the sum of primes between \$a\$ and \$b\$ (inclusive). Input \$a\$ and \$b\$ can be taken from command line or stdin (space seperated) Assume \$1 \le a \le b \le ...
user avatar
  • 2,140
4 votes
3 answers
261 views

Sharing Inherited Land [closed]

You and your brother have inherited a rectanglar block of land. This block of land's corners are read in from stdio as TLX,TLY,TRX,TRY,BLX,BLY,BRX,BRY (all decimal ...
user avatar
  • 1,009
48 votes
41 answers
17k views

Obfuscated FizzBuzz Golf [closed]

Create the shortest possible obfuscated FizzBuzz implementation. To be considered obfuscated, it should satisfy at least one of the following: Does not contain any of the words "Fizz", "Buzz", or "...
user avatar
  • 1,189

15 30 50 per page