Code-golf is a competition to solve a particular problem in the fewest bytes of source code. If you want to score by characters instead of bytes, state this explicitly in the challenge. If source code length is not the primary scoring criterion, consider using another tag instead.

learn more… | top users | synonyms

0
votes
0answers
43 views

Circular Quines [duplicate]

A quine is a program that, when run, produces the same output as the program itself. In other words, it is a self-replicating program. We will define a circular quine as follows: given a program A in ...
10
votes
7answers
489 views

Undo the square roots

Your job is to convert decimals back into the sum of the square roots of integers. The result has to have an accuracy of at least 6 significant decimal digits. Input: A number indicating the number ...
16
votes
24answers
2k views

Is a number divisible by each of its digits?

My friend and I were working on a lab in our AP Computer Science class and decided to code golf one one the problems since we still had half the class free after we finished. Here is the question: ...
19
votes
5answers
854 views

Numbers as Circular Graphics

First, study this puzzle to get a feel for what you will be producing. Your challenge is to write a program or function which will output a circular graphic like the ones from the puzzle, given a ...
-1
votes
0answers
74 views

Unholy HTML parsing [duplicate]

Inspired by this classic, Your goal is to write a program that will output this exactly: You can't parse [X]HTML with regex. Because HTML can't be parsed by regex. Regex is not a tool that can ...
1
vote
1answer
121 views

Challenge Ulamspiral [duplicate]

The challenge Get familiar with the Ulam spiral: The aim is to print the spiral like in the picture above! Rules Write a function ulam(n) where n is a odd positive integer and describes the size ...
1
vote
1answer
102 views

Shortest Code to Translate a PHP array

NOTE: This question was migrated from http://stackoverflow.com/q/27134588/1442685 PHP QUESTION Almost purely out of curiousity, how can I take an array like this: array( 'fruit' => 'banana', ...
1
vote
0answers
35 views

Solving Des Chiffres Et Des Lettres - The total is right [duplicate]

One of the games of the French TV show Des chiffres et des lettres, called Le compte est bon ('The total is right'), consists of the following : You get a number A between 101 and 999 as well as six ...
9
votes
4answers
360 views

12 Days of Golfmas

Challenge On each of the 12 days of Christmas, output the appropriate verse of "12 days of Christmas", according to the date, otherwise output the chorus of "I Wish It Could Be Christmas Everyday". ...
10
votes
18answers
2k views

Sum of strings without converting

You have to take 2 string inputs and output the sum of these two strings without converting them to int or using any numeric data type. ex. string one = "123"; string two = "456"; string sum = ...
1
vote
0answers
48 views

Automate xmpp requests to ESL website to challenge opponents [on hold]

ESL gaming, where you can challenge players to play games. I've provided some steps you can take manually to challenge a player. Note that you have to signup for an account and have to be logged in to ...
4
votes
4answers
466 views

Shortest program to split special array

Background Imagine, you have a big array A, which is mostly zeroes, but contains a short subarray B which has only strictly positive entries. For instance: | A | [0 0 0 ...
0
votes
0answers
89 views

Container wars! [on hold]

There's a simple problem: suppose we have a list of items, and a container to fill. The maximum weight of the container is 1000 units and the volume of the container is 1000 units. The goal is to have ...
1
vote
7answers
753 views

Wait, but what's e^N?

Objective: The objective is to calculate e^N for some real or imaginary N (e.g. 2, -3i, 0.7, 2.5i, but not 3+2i). This is code golf, so, shortest code (in bytes) wins. So, for example: N = 3, e^N ...
7
votes
1answer
170 views

Cyclically Equivalent Words

Cyclic Equivalence Let L be a list of pairs of letters, for example [(a,b), (a,c)]. We call L a list of commutators. Two words are cyclically equivalent over L, if one can be transformed into the ...
11
votes
7answers
478 views

Balanced Ternary Converter

Credits for the challenge idea go to @AndrewPiliser. His original proposal in the sandbox was abandoned and since he has not been active here for several months, I have taken over the challenge. ...
11
votes
24answers
3k views

Find i^n, given n

The Challenge In as few characters as possible, find the value of i^n, given n, a positive integer greater than 0. This should be outputted as a String. For those that don't know, i is defined such ...
6
votes
6answers
412 views

Short drawing programme

You just invited a liberal arts major to your house and you're telling him/her "You know, I am a great programmer and I can do x and y and z..." He/she quickly gets bored and asks you: "If ...
7
votes
1answer
211 views

Complete a Tournament Bracket

Your task is to create a program which outputs a completed tournament bracket given a list of entrants, their seeds, and their scores in each game; in the fewest characters possible. Input Your ...
2
votes
0answers
161 views

Bag of words and bag of letters

Challenge You have a bag of words, and a bag of letters. Return a list of all words that can be created from any combination of letters. However, once you created a word the letters that it uses are ...
4
votes
0answers
154 views

Compute the specificity of a CSS selector

Today, your task is to write a program (or a function) that accepts a string and outputs (or returns) four integers. Input The input string is a CSS3 selector, and can contain basically any ...
47
votes
24answers
10k views

418: I'm a teapot

As we all should know, there's a HTTP status code 418: I'm a teapot. Your mission, should you choose to accept it, is to use your creativitea and write the smallest possible server that responds with ...
-3
votes
1answer
179 views

Throwing uncatchable ExecutionEngineException

The shortest C# code that generates an uncatchable ExecutionEngineException wins. You are not allowed to call FailFast directly or indirectly.
23
votes
7answers
3k views

Golf Practice: Python

This is a challenge of practicing golf optimization in Python -- reusable tricks and shortcuts to shave off a few characters. Many will be familiar to Python golfers and use common ideas from the ...
10
votes
3answers
388 views

Print the intersection of sequences

Sequences You are given four number sequences, numbered 1 through 4. OEIS The location of 0's when the natural numbers are listed in binary. Here's an example of how to calculate the sequence: ...
8
votes
3answers
241 views

“Snail” number sequence lookup

You are given integers N and M, 1 <= N,M <= 10^6 and indexes i and j. Your job is to find the integer at position [i][j]. The sequence looks like this (for N=M=5, i=1, j=3 the result is 23): 1 ...
-6
votes
1answer
115 views

Help Potatoes make the best Coding French Fries [closed]

Will your potato make the best coding french fry? You will take input such as '10'. The input is grams of salt. The best tasting coding french fries have 20 grams of salt. Your output will be how good ...
21
votes
13answers
2k views

DVI Connector Pins

This is supposed to be a code golf challenge on the simpler end of the spectrum. But I figured it could be nice to bring out some micro-optimisation here. There are three basic types of DVI ...
37
votes
40answers
4k views

A Different Kind of Meta Regex Golf

Notice: Following popular demand I have slightly relaxed the rules: The maximum regex size grows by 1 byte every 5 answers. Answer N may use up to 29 + ⌈N/5⌉ bytes. The score of each ...
9
votes
6answers
813 views

Michael Crichton's Mousetrap

In 1984, Michael Crichton wrote a security program in BASIC that was published in Creative Computing magazine. The program would ask the user to type a phrase of her choice, record the intervals ...
16
votes
6answers
746 views

Predict the Falling Rocks

In this challenge, you are given a map of a two-dimensional terrain, viewed from the side. Unfortunately, some parts of the terrain are floating in the air, which means they'll come crashing down. ...
9
votes
2answers
247 views

Generalized Quine Generator

The Challenge In this challenge, you specify a source language S and a target language T. Your task is to write the following program P in the language S. If a valid program Q in the language T is ...
9
votes
5answers
859 views

Calculate the Delacorte Number of a square

Challenge: implement calculation of a Delacorte Number in any language. Shortest code wins. For a given square matrix of distinct integers 1..n² (possible side length n at least between 3 and 27), ...
1
vote
0answers
227 views

Implement multiplication without using any loops, branches or function calls [closed]

I came up with the following in GNU C r=0;m(a,b){x:goto*(int*[]){&&x,&&y}[r+=a&1?0:b,a>>=1,b<<=1,a<1];y:;} One could argue there is a branch here a&1?0:b So ...
4
votes
1answer
271 views

Evaluate CDF of Student-t distribution

The goal of this codegolf is evaluating the cumulative distribution function of the student-t probability distribution. This is not trivial since there is no closed form and the function is dependent ...
-1
votes
0answers
181 views

Make Copying Easier!

Introduction Writing essays was made so much easier with the invention of Wikipedia. The thing is that you get these annoying links in your text and left behind citations[3] giving you the job of ...
8
votes
2answers
343 views

Group the Numbers With the Same Sum

Your task is, given a square grid of digits (0-9), output one of the ways that the digits can be grouped such that: Each digit is part of exactly one group All groups have the same number of digits ...
20
votes
3answers
918 views

Place a Carcassonne tile

The board game In the board game "Carcassonne" players place tiles by matching their edges and earn the highest scores through creating large contiguous areas of terrain. The following are (roughly) ...
14
votes
4answers
382 views

Decompose a number with bit-xor without the digits 0, 3, 7

Challenge Write a function or program which takes a positive decimal number, call it A, and output two positive numbers, B and C, such that: A == B bitxor C B and C must not contain any of the ...
23
votes
11answers
2k views

It's Spanish Time!

I have a simple task that should be relatively easy to implement by means of code. Your goal is to write a program that will output the time written in Spanish, given the time in HH:MM format. Many ...
-2
votes
1answer
278 views

Append element to array only if it exists?

I know that, given an array a and an element e, a.push(e) appends it. However, consider an object o and the following code: // o = {...} var a = [o.one]; a.push(o.two); Assuming o.one = 1 and o.two ...
7
votes
2answers
258 views

Calculate a pi-based sequence with a pi-based frequence

Introduction Pi is 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089... Let's treat each digit as an instruction as to how to get to the next digit. The first ...
8
votes
1answer
392 views

WinAli - Virtual CPU for understanding assembly language

WinAli is a model assembler for Windows. It emulates a real CPU and is meant to help students learning and understanding the Assembly language. German Wikipedia article: ...
37
votes
7answers
3k views

Avoiding Rivers

Background In typography, rivers are visual gaps in a block of text, which occur due to coincidental alignment of spaces. These are particularly annoying since your brain seems to pick them up more ...
10
votes
8answers
923 views

Graphical Representation of Koch Snowflake

Generate a Koch Snowflake A Koch snowflake is a triangle that for each n, another equilateral point is added in the middle of each side: http://en.wikipedia.org/wiki/Koch_snowflake#Properties We ...
95
votes
218answers
18k views

Unscramble the Source Code

In this game of cops-and-robbers, each cop will write a simple program to give a single output. They will then make public four things about their program: The language The program length The ...
2
votes
1answer
263 views

Make your own clock! [closed]

Write a program which produces a digital clock on the screen. The clock must update every second, and show time in the format 01:23:45 PM. However, you may not use the computer's built-in clock, or ...
34
votes
9answers
4k views

Eating Candy in the Correct Order

When it comes to eating candy, I hold myself to higher standards than the typical layperson. There is a delicate balance between "mixing it up" and "saving the best for last." In this challenge, you ...
14
votes
2answers
475 views

A Good Time to Refuse

The Setup Suppose you're given n fuses, with 1 ≤ n ≤ 5, each of which is a meter long, and where each fuse has an associated burn rate of N meters per D hours. A fuse can be lit at one or ...
30
votes
8answers
2k views

How Many Guineas in a Gross of Threepennies?

Until decimalization in 1971, British money was based on dividing the pound into 240 pennies. A shilling was 12 pennies so 20 shillings made a pound. The smallest denomination was the farthing at one ...