All Questions

19
votes
1answer
977 views

Unique Sudoku Finder

Challenge: Given a Sudoku board on standard input, find the minimum number of numbers added to make the board unique. Specifics/Rules: The input is formatted as follows (all whitespace is ...
3
votes
2answers
602 views

Arithmetic Golf: Reach 2011

This is an ai-player challenge. Your goal is to reach the number 2011 as quickly as possible, or to get as close to it as you can. Rules: A "hole" consists of a rectangular grid of digits (0-9). ...
-5
votes
3answers
5k views

Descending Sort using Standard Ascending Sort Function [closed]

Taking an array of records. For example ...
3
votes
1answer
1k views

Maximize order of operations

Here's a problem to which I don't know the answer. Suppose you have an ordered list of integers with an operator in between each consecutive pair. Let's restrict ourselves to three operations that are ...
6
votes
5answers
2k views

Detect loops in a linked list [closed]

This comes from one of my favorite interview questions, though apparently it is now a fairly well-known puzzle. I have no way of knowing, but if you have already heard the answer it would be polite to ...
4
votes
13answers
7k views

Count the number of times a function runs [closed]

This is a teaser a friend of mine sent. It seems straightforward, but I can't seem to get my head around it, probably due to my lack of sleep. You have 16 bits available. Compose a function, and ...
11
votes
39answers
3k views

Enumerate all palindromic numbers (in decimal) between 0 and n

Given a non-negative integer n, enumerate all palindromic numbers (in decimal) between 0 and n (inclusive range). A palindromic number remains the same when its digits are reversed. The first ...
10
votes
4answers
992 views

Knock down walls in a maze

Rules: In this game you start at the top of a rectangular grid of size N x M made up of walls and open spaces. The input is N lines of M characters, where a . ...
74
votes
6answers
31k views

Hard code golf: Regex for divisibility by 7

Matthias Goergens has a 25,604-character (down from the original 63,993-character) regex to match numbers divisible by 7, but that includes a lot of fluff: redundant parentheses, distribution (...
15
votes
7answers
1k views

What comes next?

Given a space-separated list of integers, your task is to find the next integer in the sequence. Each integer in the sequence is the result of applying a single mathematical operation(...
17
votes
9answers
2k views

Choose Your Own Adventure

Choose Your Own Adventure books are a form of interactive literature where the reader must make decisions that affect the outcome of the story. At certain points in the story, the reader has multiple ...
9
votes
7answers
1k views

Program to Spoonerise words [duplicate]

A spoonerisation is swapping the first letter/pronounceable syllable of two or more words. Example: A lack of pies = A pack of lies. Bad salad = Sad ballad (ish) :) Challenge: Write a program to ...
6
votes
1answer
1k views

How to encode shortest brainf_ck strings

This is an interesting one. I have written a short program in objective-c to encode a string into a brainf_ck string, this is what it looks like: ...
1
vote
4answers
705 views

Tricky Median Question

Given n points, choose a point in the given list such that the sum of distances to this point is minimum ,compared to all others. Distance is measured in the following manner. For a point (x,y) all ...
55
votes
30answers
14k views

Shortest Game of Life

Conway's Game of Life is the classic example of cellular automation. The cells form a square grid and each has two states: alive or dead. On each turn, each cell simultaneously updates according to ...
7
votes
3answers
2k views

Lights Out - Find the solution

(This code golf task is related to Code-Golf: Lights Off!. The same puzzle is used, but the task is different.) Introduction "Lights Out" is a puzzle in which you should switch off all lights in a ...
10
votes
6answers
1k views

Enumerate all binary trees with n nodes

Given an integer n, enumerate all possible full binary trees with n internal nodes. (Full binary trees have exactly 2 children on every internal node). The tree structure should be output as a pre-...
7
votes
14answers
927 views

400th Question Celebration/Challenge [closed]

I just looked and saw that there are 399 questions on this wondrous "Programming Puzzles & Code Golf" site!!! That means that...THIS IS THE 400th question!!! To celebrate this momentous occasion,...
5
votes
25answers
17k views

Program that determines whether an int is greater or lesser [closed]

Write a program which prompts a user to input two integers A and B, the program should determine whether A is greater than or lesser than B without the use of greater than [>] or less than [<] ...
7
votes
4answers
2k views

Generating BF-code with single purpose

I'd like to see you create code (in any programming language) that output working BF (Brain***k) code. Your program have a single character input on stdin. The input should be one digit ("0", "1", "2",...
4
votes
5answers
3k views

C: Output “tomorrow's date”

I'm a code golf novice, but I'm eager to give it a go. My challenge is: Write the shortest program in C which takes in a date D as input and outputs the date ...
16
votes
4answers
2k views

Wordsearch Solver

Given a list of words and a grid of letters, find all the words in the grid and remove any letters which are not part of any of the words. The words could be forwards, backwards, up, down or diagonal. ...
-4
votes
11answers
446 views

Text Statistics: Return a list/array of the number of occurrences of each character used in a text file, including spaces, tabs, and new lines [closed]

Generic Lorem Ipsum: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris felis dolor, bibendum at tincidunt vel, imperdiet eget libero. Cras vel felis purus. Phasellus a vestibulum ...
12
votes
3answers
376 views

Session-Saving Quine

Inspired by this question. Create a program that prompts the user to store some data, and when the program is quitting, spit out the program itself, except the session data changed. The user then ...
55
votes
74answers
6k views

How to randomize letters in a word

According to some controversial story, the odrer of ltteres in a wrod deos not mttaer much for raednig, as lnog as the frist and lsat lteter macth with the orignial wrod. So, for fun, what would be ...
16
votes
8answers
9k views

Compute the CRC32 table at compile-time [closed]

The reference implementation of CRC32 computes a lookup table at runtime: ...
4
votes
12answers
843 views

Multiples of 67 in a constructed array of arrays?

A triangle-shaped table is constructed such the first row is "1, 3, 5, 7, ..., 99" Each subsequent row has the following properties: One less element than the row above Each element is the sum of ...
12
votes
10answers
1k views

Creative Programming [closed]

Make a story out of your programming. Example in JavaScript: ...
5
votes
4answers
306 views

Generate a JavaDoc comment [closed]

I'm too lazy to write a JavaDoc comment myself, there's a lot of typing and it is mostly boilerplate. Write a program to generate a JavaDoc comment with $ as a ...
11
votes
5answers
1k views

Musical Score Interpreter

Given an ascii musical score, you must be able to output the note and its corresponding length. The score will contain between 5 and 15 notes inclusive, and is transcribed on a stave. A stave is ...
18
votes
1answer
2k views

Chess endgame: White to Mate In One

Given an 8x8 grid of letters representing the current state of a game of chess, your program's task is to find a next move for white that results in checkmate (the answer will always be mate in one ...
13
votes
3answers
2k views

Solving triangles with trigonometry

Time to dig up your old trigonometry notes from high school! The challenge is to solve the unknown sides and angles of different triangles. And as is customary in code golf, the smallest working code ...
6
votes
15answers
1k views

Machine Epsilon

Machine epsilon is an important floating point number to know when doing numerical calculations. One way to understand it is when this relation ...
22
votes
10answers
2k views

Meta Golf Challenge

On that challenge you have to solve that challenge. Contest is over! Check the end of the question Specs: Write the smallest code (Any language*). The score of an answer is the sum of: Code length ...
10
votes
12answers
4k 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: ...
39
votes
5answers
6k views

Solve the eight queens problem at compile-time [closed]

Can you solve the eight queens puzzle at compile-time? Pick any suitable output format. I'm particularly interested in a C++ template metaprogramming solution, but you can use languages that have ...
32
votes
7answers
2k views

Bridges and Tunnels

You are responsible for building a new freeway. However, it leads through mountainous lands and therefore needs numerous bridges and tunnels. The freeway itself should stay at a single level. Input ...
5
votes
2answers
1k views

Knuth's Power Tree

In The Art of Computer Programming, Knuth describes an algorithm to compute short addition chains. The algorithm works by computing a tree known as the Power Tree. The tree is rooted at 1, and each ...
2
votes
0answers
207 views

Proving the shortest quine in a particular language [duplicate]

Possible Duplicate: Golf you a quine for great good! People have proposed short quines in various languages. Puzzle: Find the shortest non-trivial quine in a language of your choice, and prove ...
7
votes
4answers
840 views

Unicode character classification [closed]

Real-world programs often use libraries like ICU to support Unicode. The puzzle is to create the smallest possible function that can determine whether a given Unicode character is lowercase, ...
6
votes
3answers
3k views

Magic square generator

Create the shortest function to print a magic square of given size. A magic square is a NxN matrix of distinct numbers and the sum of each row, column and diagonal is equal to a constant. A magic ...
16
votes
40answers
2k views

Undulant numbers

An undulant number is a number where its digits alternate between up and down like the following number: 461902 or 708143, or even 1010101, but not 123, because 2 < 3. Write a program or function ...
5
votes
3answers
348 views

Negative Regexp [closed]

Write the shortest function that takes one string, and returns a regular expression that matches anything EXCEPT the input string, in parenthesis. Escape necessary characters like Perl ...
13
votes
9answers
769 views

Soundex function

Write the shortest function to generate the American Soundex code for a surname only containing the uppercase letters A-Z. Your function must produce output consistent with all the linked page's ...
43
votes
2answers
2k views

Facial Recognition

The aim of this task is to identify, clean up, and mark out all the faces in any given 'image'. What's in a face? A face will be a ZxZ square where Z is an odd integer greater than 1. The top left ...
7
votes
1answer
488 views

using a Markov Chain, because this question itself as input text for example

Create a Markov Chain generator, which generates (and outputs) an Order 4 text chain. It must be able to support all plain text formatting used on this question, so be sure to check for punctuation (...
51
votes
32answers
8k views

Generate a mandelbrot fractal [closed]

Your task is to draw the mandelbrot set in ascii. It should look something like The complex number c lies in the mandelbrot set, when the sequence ...
7
votes
14answers
715 views

Another amicable number problem

Two numbers are said to be 'amicable' or 'friends' if the sum of the proper divisors of the first is equal to the second, and viceversa. For example, the proper divisors of 220 are: 1, 2, 4, 5, 10, ...
9
votes
5answers
993 views

Paint that fence

You are Tom Sawyer and you have to paint a fence of 102400 m long. Luckily, your friends decided to help you in exchange of various things. Each friend will paint L meters, starting from S with ...
16
votes
23answers
2k views

Indent a string using given parentheses

Given the following input to the program: List of block start characters List of block end characters A string to format format the string with the blocks delimited by the two character sets ...

15 30 50 per page