Code-golf is a competition to solve a particular problem in the fewest characters or bytes of source code. If source code length is not the primary scoring criterion, consider using another tag instead.

learn more… | top users | synonyms

6
votes
5answers
397 views

Extraction of Bits

Your task is to devise a programme that extracts the bits, in order, represented by the first argument based on the set bits represented by the second argument (the mask). Formal Definition: Let ...
14
votes
0answers
231 views

Voice recognition: “Yes” or “No”?

Task Implement a program in minimum bytes of source or binary code that does voice recognition of a voice sample (me saying "yes", "yeah" or "no" in voice or in whisper, plainly or quirkily) based on ...
8
votes
3answers
274 views

SPOF Picture Hanging

Objective I have a nice picture that I want to hang on my wall. And I want it to hang there in a spectacular way, so I chose to hang it on n nails where n is any positive integer. But I'm also ...
11
votes
7answers
696 views

Two-Many Outputs

The Challenge I present to you another spy vs. spy challenge pitting obfuscators versus crackers. In this case, however, the datum to be protected is not an input but an output. The rules of the ...
14
votes
22answers
1k views

Multiply all numbers in a string

Your goal is to find all numbers in a string, and multiply each one individually by a value input by the user You will not need to worry about decimals The user will input a number and a string The ...
-3
votes
2answers
124 views

A Decent Decade [on hold]

This is a short one: Only once in American history has there been a decade in which four of the years were prime numbers. Your program has to output the decade after 1776 where four its years ...
18
votes
5answers
1k views

Take a break to make a snake!

Our classic snake has developed an inbalance of growth hormones. To make matters worse, his tail is frozen in place! Given directional input as specified in Figure 1, write a program to determine ...
-4
votes
2answers
165 views

programmers from all languages, write this with as few code as possible

i've been dabbling with a hypothetical language... now, i want to add a feature/mechanism that can easily format data in as few codes as possible. now, i need to compare my hypothetical language ...
5
votes
5answers
492 views

Can you make my terminal less boring?

Terminals are so boring these days. They used to look like this: Now they're just bland and dull and black-and-white. I want you to write me a program that will make my terminal all colorful ...
-12
votes
0answers
68 views

Please solve the message puzzles [on hold]

Jack Sparrow sends a message to Captain Davy Jones, which was intercepted by the lovely Elizabeth Swann. The previous conversation contained the following text "et tu brute?" BNBLINISLINAL US ...
0
votes
0answers
94 views

Interpret FRACTRAN [on hold]

Edit: Duplicate of stackoverflow.com/questions/1749905/code-golf-fractran, please vote close. Goal Write a program or named function to interpret the esoteric programming language FRACTRAN. Use as ...
7
votes
1answer
266 views

PNG Pixel Forces

Challenge A Pixel World is a PNG image where gravitational, electromagnetic, and nuclear forces no longer exist. Special forces known as "pixel forces" are all that remain. We define this force as ...
12
votes
7answers
382 views

Find the maximum operation

The challenge is to find the maximum number you can get from a list of integer using basic arithmetic operators (addition, substraction, multiplication, unary negation) Input A list of integers ...
11
votes
8answers
2k views

These Primes of Mine Are Always Solid Lines

Let's create a N×N grid of spaces and underscores that can be used to visually determine if a number is prime. (N may be any positive integer.) This grid has three simple rules: The nth column ...
4
votes
2answers
303 views

Interpret /// (pronounced 'slashes')

Because we can't get enough of esoteric language golfs, can we? ///—pronounced slashes—is a fun little language based on the s/// regex-replacement function of Perl fame. It contains only ...
7
votes
3answers
496 views

BrainFlow Interpreter!

BrainFlow What is BrainFlow? BrainFlow is an extension of BrainF**k (BFk) with 3 additional commands for added functionality and confusion. What commands? In addition to the normal BFk commands, ...
3
votes
2answers
337 views

Decipher a Code Stick

Introduction You're an American spy during the heat of the Cold War and you've managed to intercept a Russian message. Immediately you recognise it as a code stick cipher and wrap it around a pencil. ...
2
votes
2answers
234 views

Put together cut strips of paper to get original message

This question is from a programming challenge (not DARPA) which has ended. A sheet of paper consists of message, which has been shredded into vertical strips. Given the vertical strips and a ...
5
votes
4answers
456 views

Find a thumbnail in a mosaic

After the last Ludum Dare (LD) game programming contest a friend of mine made a nice mosaic of all the LD game thumbnails: After searching for my own game I quickly gave up and decided to solve it ...
8
votes
9answers
631 views

Multiply Quaternions

Write a named function or program that computes the quaternion product of two quaternions. Use as few bytes as possible. Quaternions Quaternions are an extension of the real numbers that further ...
14
votes
16answers
2k views

Find the closest palindromic number

Given a number N, output/return X so that N+X is a palindrome, where |X| has to be as small as possible. Palindrome: A number is a palindrome, if its sequence of digits is the same when reading them ...
12
votes
0answers
272 views

Life can be colorful! [duplicate]

Each cell in a life-like cellular automaton only needs one bit to represent it since it can only be alive or dead. That means there are only two colors; pretty boring. Normal images have 24 bits per ...
10
votes
3answers
498 views

Growing Manhattan Ameobas

An ameoba graph* is a type of tree whose nodes all have values from 0 to some non-negative integer N, and any particular node with value x < N connects to x+1 distinct nodes with values x+1. ...
55
votes
14answers
11k views
+100

Possibly quit your job with a polyglot

Despite your protest, you have been put to work by your boss on a program that takes a single unsigned integer as input and prints the string "prime" if that integer is prime and "not prime" if it ...
19
votes
7answers
697 views

Family Tree Solver

This is one of several challenges left for the community by Calvin's Hobbies. Take a "family tree describing" file with lines of the form: [ID] [mother ID] [father ID] [gender] [full name] such as ...
10
votes
4answers
423 views

How strong are nonary numbers?

You are given a nonary (base 9) non-negative integer consisting of the digits 0 through 8 as usual. However the number of digits in this number (with no leading zeros) is a prefect square. Because of ...
20
votes
11answers
3k views

Plug it back in tonight or this weekend

This is my first code golf so please let me know if it's too broad or if I'm missing any information for a good puzzle! Challenge In Ontario and possibly other areas of the world, electricity is ...
0
votes
15answers
789 views

Concise case changing code

Create the shortest program that given an input string it outputs the opposite-cased string. For example if I pass the string "HeLlO" the program should output "hElLo". Of course, neither aggregate ...
26
votes
31answers
3k views

Lockers vs. Crackers: The Five-Element Sequence

The Challenge A simple "spy versus spy" challenge. Write a program with the following specifications: The program may be written in any language but must not exceed 512 characters (as represented ...
72
votes
30answers
12k views

If a program terminates and there is no one to see it, does it halt?

It's time to face the truth: We will not be here forever, but at least we can write a program that will outlive the human race even if it struggles till the end of time. Your task is to write a ...
-1
votes
3answers
298 views

Linking without a Link

Introduction Hello! This is my second post, and I decided to do one which is more language specific, since my last one was very much orientated towards mathematical languages, and thus did not leave ...
14
votes
6answers
922 views

Morse Decode Golf

I've become alarmed with the growing hatred of spaces and this answer has inspired me to make sure Morse code is safe from this insidious removal of whitespace. So, your task will be to create a ...
6
votes
1answer
180 views

Swing Through Trees with Your Grappling Hook

You have found the path through the forest and now plan on travelling along it. However, just before you start on your journey, the ground turns into lava. You manage to scurry up the nearest tree ...
20
votes
3answers
873 views
+150

Drawing Epicyclogons

An epicycloid is the curve a point on a circle makes as it rolls around another circle. A cyclogon is the shape a point on a regular polygon makes as it rolls across a plane. An epicyclogon is the ...
-1
votes
0answers
96 views

“abc” strings that don't contain “ac” [duplicate]

How many strings of length n containing characters 'a', 'b' and 'c' can be formed? The substring "ac" should not be present in the string. A substring is any contiguous portion of a string. A ...
-5
votes
0answers
98 views

ll and his love [closed]

LL is so much in love with numbers that all girls stay away from him. He tried once, but was rejected. So now, he gives all his time to numbers. But cute numbers want to do the exact opposite, because ...
7
votes
5answers
403 views

Shortest script that gives the time passed since a Unix timestamp

What you need to do to win this challenge is to write the shortest "timeago" script that outputs the number of decades, years, weeks, days, hours, minutes, and seconds between a given Unix timestamp ...
-4
votes
3answers
101 views

A simple one-liner for pseudo-random binary string generation [closed]

(Cross-posted here) I'm trying to illustrate the concept of Kolmogorov complexity by comparing two seemingly-random binary strings: while one is truly random, the other can be created by a program ...
11
votes
9answers
1k views

The Symbols vs. The Letters

The Symbols vs. The Letters The ASCII characters have been divided once again! Your sets are The Letters and The Symbols. The Letters ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz The ...
11
votes
13answers
2k views

Shortest Code to randomly place points and connect them

The Task This is quite a simple coding task, all your program has to do is place a point on a canvas (or your alternative in another coding language) and connect it to all the dots already placed. ...
10
votes
6answers
520 views

Given r and n, find first n numbers of x where moving first digit of x to last gives x/r = y

Objective Given input r and n find the first n natural numbers x such that if we rotate the first digit to the last place we obtain x/r. You may assume that 2 <= r <= 9 and 1 <= n <= ...
7
votes
0answers
224 views

Write a functioning bare-bones IRCd

A bit of an unusual one, but hey, why not? :) The objective: Write a functioning IRC daemon in your language of choice that provides barebones functionality, in as few characters as possible. As long ...
9
votes
10answers
1k views

Shortest Longest Increasing Subsequence Code

The Challenge is to write the shortest implementation to find the Longest increasing subsequence . Example : Let S be the sequence 1 5 7 1 8 4 3 5 [length of S = 8 ] We have 1 sub-sequence of ...
12
votes
3answers
829 views

The ASCII Architect

You don't want to pay money for the expensive architectural program, so you decide to roll your own. You decide to use ASCII to design your buildings. Your program will take in a single string ...
7
votes
8answers
458 views

Implement bit-wise matrix multiplication

The MMIX architecture is a fairly simple big-endian RISC design. It has a couple of interesting features, one of them is the MXOR instruction, which is what you should implement. The MXOR instruction ...
2
votes
1answer
363 views

Rosetta Stone Code Challenge

I presume you've all heard of the Rosetta Stone, an ancient stone found to have essentially the same passage written on it in three different scripts. This challenge is based upon that: you have to ...
14
votes
13answers
1k views

Display a tally (in varying bases)

Tallying is a simple counting system that works in base 5. There are various different tallying systems used around the world, but the one that is used in most English-speaking countries is perhaps ...
14
votes
7answers
605 views

Organise the Gregorian Church's Music

The year is 930, and the Gregorian Church is having a problem. They have thousands of pages of chant music, but the problem is that all the sheet music was simply thrown onto a pile instead of having ...
7
votes
0answers
172 views

One source, lots of Brainfuck [duplicate]

Write a Brainfuck interpreter that can interpret multiple Brainfuck programs embedded within the same source. The syntax is the same except that the instructions must be prefixxed with the number/ID ...
11
votes
4answers
584 views

Write a program which replaces with spaces the braces in cases where braces in places cause stasis

You are a project manager. One day, one of your programmers went insane (not your fault) and took all the expressions in the codebase and added random brackets to them, before quitting on the spot, ...