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

5
votes
3answers
74 views

Mobius inversion

Your goal is to implement Möbius inversion, a linear operation on a sequence of numbers that is used in combinatorics and number theory. Fewest bytes wins. What is Möbius inversion? Given a (finite) ...
10
votes
5answers
582 views

Play Wythoff's Nim perfectly

Your goal is to write a perfect player for the game of Wythoff's Nim. Rules of Wythoff's Nim Wythoff's Nim is a deterministic two-player game played with two piles of identical counters. Players ...
10
votes
11answers
810 views

Look-and-say: Conway revisited

You should all be familiar with the Conway sequence (a.k.a. 'look-and-say'-sequence) by now: 1 11 21 1211 111221 312211 etc You can also start by any arbitrary number as starting ...
-1
votes
0answers
58 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 ...
15
votes
9answers
1k 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 ...
27
votes
38answers
4k 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: ...
31
votes
5answers
2k 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
85 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
128 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 ...
2
votes
2answers
131 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
44 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 ...
10
votes
6answers
502 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
16answers
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
50 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
480 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
95 views

Container wars! [closed]

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 ...
2
votes
8answers
846 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
174 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
8answers
511 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. ...
12
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
426 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
213 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
164 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
156 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
187 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
393 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
243 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
117 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 ...
38
votes
41answers
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
816 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
771 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
248 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
867 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
230 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
183 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
346 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
920 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
383 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
260 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
393 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
946 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 ...
97
votes
220answers
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 ...