Tagged Questions

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

6
votes
0answers
76 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 ...
8
votes
4answers
238 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
17answers
2k 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
324 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
196 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
145 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
146 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 ...
43
votes
24answers
7k 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
170 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 ...
9
votes
3answers
348 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
238 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
107 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
30answers
3k views
+100

A Different Kind of Meta Regex Golf

Notice: I'm considering to relax the rules after the current bounty expires. Please see the comments below for details and vote to indicate your preference. In regex golf, you're given two sets ...
9
votes
6answers
807 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
735 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
242 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 ...
8
votes
5answers
839 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
224 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
266 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
177 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
337 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
906 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
378 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
256 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
385 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
7answers
820 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
216answers
17k 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
259 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
472 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 ...
7
votes
0answers
295 views

Keep my Trip Cool!

Challenge Walking around Marks and Spencers, I noticed that they had air conditioning units placed randomly around the shop. Wanting to keep cool, I wondered what was the easiest way to move around ...
12
votes
0answers
147 views

Organize Halloween Candy - Hole #4

See Hole #1 if you are confused. What does every kid do after he/she collects buckets of candy over Halloween? Sort it by type and size, of course1! The Challenge Given a dumped-out bag of candy ...
54
votes
7answers
3k views

Square, Circle, Triangle, …Gear?

Using Algodoo and Paint I made these six 300×300 monochromatic images of four convenient shapes: This class of images has the following properties: They are always 300×300 pixels, ...
14
votes
1answer
449 views

Compiling English for your Boss

Your boss has recently learned of this interesting programming language called English. He has had this "revolutionary" idea, he wants to code with you to double code production rates! Since he is not ...
4
votes
7answers
296 views

Google Code Jam - New Lottery Game

I was looking around on the web and I found this Google Code Jam Puzzle. I really liked it so I decided to post it here. New Lottery Game The Lottery is changing! The Lottery used to have a ...
14
votes
5answers
622 views

Mondrian painting description language

This challenge consists in coding an interpreter for a Mondrian painting description language (MPDL). Language definition The language operates on a stack of rectangles. A rectangle is defined by ...
6
votes
3answers
345 views

Code to toggle a program

Challenge Write a program that toggles another. Your program should accept exactly two command arguments. Specifically, your two tasks are: If the names of any running processes are identical to ...
-4
votes
0answers
81 views

I woz ere. Ere I woz [duplicate]

In as few amount of Unicode characters as possible, print the following: I woz ere. Ere I woz. Woz I ere? Course I woz! Exact punctuation and capitalization is required. You must create the ...
-2
votes
5answers
612 views

The Most Complex Chinese Character

Challenge You must output the Chinese character for biáng. Your program must not access any external sources and must exactly reproduce this SVG in every way. Note that the image below is just a gif ...
29
votes
26answers
3k views

Character Cross

I was expecting to post something more complex as my first puzzle in PCG, but a particular, uh... homework question on Stack Overflow inspired me to post this. They want to: print the following ...
11
votes
4answers
819 views

Convert x-illion into standard form

Given a string, consisting of a prefix and then "illion", convert this number into standard form. For example: "million" -> 10^6 "trillion" -> 10^12 "quattuordecillion" -> 10^45 The ...
8
votes
4answers
330 views

Decompose a number into a sum of repdigits

Repdigits are numbers of the form a * (10^n - 1)/9 with a in [-9,9]\{0} (in other words 111, -3333, 66, numbers which are made by repeating only one digit) Goal: Write a program or function which ...
8
votes
37answers
2k views

Print the ASCII table

The task is to display n characters of the ASCII table. You may write a function (or a program that takes the argument as a parameter, STDIN is allowed as well) that takes a parameter n, which will ...
19
votes
1answer
560 views

Can you hear me now?

Background You are a rich executive of a software empire. Your time is worth a lot of money. As such, you must always travel in the most efficient route possible. However, as an executive, you spend ...