A code challenge is a competition for creative ways to solve a programming puzzle with an objective winning criterion not covered by other scoring tags (e.g. code-golf).
16
votes
21answers
3k views
Valid Through The Ages
Inspired by this question on SO, your task is to produce a program that is valid in (at least) two major versions of your chosen language that produce different output.
Rules
Any language that has ...
14
votes
17answers
2k views
Draw a regular polygon
The goal of this code golf is to draw a regular polygon (one with equal side lengths) given the number of sides and radius (distance from center to vertex).
The number of sides and the radius can be ...
-2
votes
0answers
126 views
Parameter passing exercise [on hold]
Task
Write a program that behaves differently according to how the compiler approaches parameter passing. Treat these cases as imaginary: "if I had a compilator that passes by reference" or "if the ...
11
votes
4answers
1k views
Shortest code to write longest code
Your challenge is to create a shortest code in your language of choice which writes on a .txt file the longest code to multiply two numbers by taking two numbers as input and output the answer.
NO ...
12
votes
1answer
663 views
Juggling by Numbers
Your task is to generate a valid juggling pattern by completing a given template. But first, you probably need to know how such a pattern is denoted.
Introduction to Siteswap
Siteswap is the ...
16
votes
3answers
500 views
Tower of Hanoi Sort
Write a function/subroutine to sort a list of integers, Tower of Hanoi style.
You will be given a stack of integers. This is the main stack.
You are also given two more helper stacks. These helper ...
18
votes
29answers
3k views
Sort-a-number. Sorta
Inspired by the ill-fated sorting-a-numbers-digits-without-using-an-array, but I thought it made a better code golf than SO question.
Given a positive integer, sort the digits in that integer.
...
3
votes
1answer
396 views
Ration your integers and feed the people [closed]
It is wartime, and rationing is taking place in certain regions of your country. Your cities' region is one such region. The city chooses to give everyone the same amount, but in reality, larger ...
14
votes
7answers
2k views
The Random Quine
Write a program that is capable of randomly generating itself.
It must do this based on the tokens used in its source code. If your program's source code is composed of 50 unique tokens and is 60 ...
10
votes
1answer
536 views
How many Sudoku puzzles exist?
This is not a Sudoku solver, nor a Sudoku checker.
Your challenge is to write a function or script that, given as input the "block" size of a 2D Sudoku puzzle (which is 3 for the classic 9x9 board, 4 ...
10
votes
6answers
319 views
Print a specific value in this generated binary matrix
Suppose we define an infinite matrix M, on N^2 -> {0, 1} (where N starts from 1 instead of 0) in this manner:
M(1, 1) = 0.
For every x > 1, M(x, 1) = 1 if x is prime, and 0 otherwise.
For ...
10
votes
14answers
1k views
Golfed+Fast sorting in C
[Latest update: benchmark program and preliminary resuls available, see below]
So I want to test the speed/complexity tradeoff with a classic application: sorting.
Write an ANSI C function that ...
1
vote
7answers
339 views
Cross Language Troll [duplicate]
The Setup
Jim the student who attempts to use Stack Overflow to do his homework has asked how to get his program to say "Hello World" in under 100 lines of code, you decide mere mortal trolling is not ...
4
votes
1answer
337 views
ASCII Art Generator
Your goal is to write a program / script which "converts" real images into ascii art.
General:
Your program will get a path to a image file over stdin or as parameter (whatever you prefer). The ...
-2
votes
4answers
172 views
Calculate Fibonacci series from nth term to mth term [duplicate]
Your goal is to calculate the sum of Fibonacci series from n th term to m th term (including both terms).
No use of / * % or mathematically what they are in your language of choice.
No use of ...
5
votes
3answers
637 views
Eiffel Tower in 3D
This challenge asks you to draw the Eiffel Tower in 3D using different ASCII characters to represent the different sides, similar to this cube:
@@@
@@@@@@@@@
@@@@@@@@@@@@@@@
...
-4
votes
4answers
219 views
“Hello, world!” with n distinct characters
Write a series of programs in the same language that print “Hello, world!” using n distinct source characters, where n is in [1..10] inclusive (“distinct” meaning that duplicate characters are ignored ...
4
votes
4answers
288 views
Partially Solve the halting problem for brainf***
To solve the Halting Problem you are given a description of a program, and must determine whether or not it will ever finish. You can never do this for all programs. Yet for programs like (in ...
36
votes
1answer
861 views
Minimal keystrokes needed to type a given text
We all know that programmers tend to be lazy. In order to maximize your free time, you decide to write a program that outputs a minimal number of keystrokes for text fed into it.
Input: Text that ...
8
votes
2answers
349 views
Robots! Collect these pickles!
I seem to have gotten myself into a bit of a pickle. Literally. I dropped a bunch of pickles on the floor and now they're all scattered about! I need you to help me collect them all. Oh, did I mention ...
22
votes
4answers
2k views
Implement ROT-47… in ROT-47
Challenge: Implement ROT-47 in code that works as both itself and as the ROT-47 version of itself.
Scoring:
Your score is calculated as a percentage of used, ROT-47 eligible bytes in total of both ...
53
votes
64answers
8k views
Call a method without calling it
Inspired by a now deleted StackOverflow question. Can you come up with a way to get a particular method executed, without explicitly calling it? The more indirect it is, the better.
Here's what I ...
2
votes
1answer
256 views
Determining part of speech of most words [closed]
Write a program to output the part of speech of any word inputted to it. I doubt that anyone could get a perfect algorithm, so I will give the code a batch of words in order to ascertain what ...
-5
votes
5answers
140 views
Append to an external text file - Code Golf [closed]
The Challenge
You must create a function that can append to an external text (.txt) file. No text needs to be appended, it is just the function that matters. Any language is welcome and you can use ...
-6
votes
3answers
311 views
Make a golfing language [closed]
In this challenge, you get to create a language. Although you have to provide code in other languages, you will only be rated based on the language. Here are the requirements.
You must invent a ...
12
votes
9answers
709 views
Kind of meta: get the longest of the shortest answers
Your task - if you accept it - is to write a program which helps understanding my proposal on meta by calculating the winner of a code-golf-reversed competition. Of course, answers to this question ...
4
votes
2answers
347 views
Analysing the most common words in a text, and replacing them with a single byte
This is a very crude text encoding algorithm I came up with the other day. It won't work if the text has more than 256 different characters in it – but it does support Unicode, at least in my Python ...
5
votes
2answers
191 views
2D javascript table graphics
The challenge
Make a JavaScript program that can use a HTML table as a canvas, having each cell a pixel.
You can either input the position and color values in a form or by using the console.
Score ...
10
votes
8answers
1k views
Is it a prime? w/o math
Write a program or function in any language that tells if the input is a prime number.
The input is a string representing a natural number in base-10.
The output is one of the two strings "Prime" or ...
1
vote
4answers
312 views
Theoretical algorithm to compute Graham's number
Graham's number G is defined in that way:
3^n = 3*..n times ...*3
3^^n = 3^(3^n)
3^^^n = 3^^(3^^n)
3^^^^n = 3^^^(3^^^n)
g1 = 3^^^^3
g2 = 3^^...g1 times^^3
g3 = 3^^...g2 times^^3
...
G = 3^^...g63 ...
2
votes
0answers
187 views
Shortest Sub Segment Problem [closed]
Given a paragraph of text, and a list of k words, write a program to find the first shortest sub-segment that contains each of the given k words at least once. The length of a segment is the number of ...
8
votes
3answers
458 views
Write code to determine the accepted answer
Post an answer to this question that evaluates any answer to this question and determines whether it wins.
Who wins:
Winner is the answer that wins according to the most answers at 1700 UTC, ...
-3
votes
2answers
302 views
Make “The day we fight back” Logo
Seeing that Feb. 11, 2014 is being celebrated as "The day we fight back", your code-challenge is to make a
Day we fight back Logo, similar to the once shown below, in the language of your choice.
...
6
votes
2answers
231 views
Eco-ize data for printing
Inspired by ecofont.
Given a string containing # and , output it more eco-friendly by cutting out circles, while keeping it "recognizable" (defined later, in the Circles section). # represents ...
6
votes
1answer
253 views
Graphical, networked, two-(human)-player Tic-Tac-Toe
Create a Tic-Tac-Toe game that allows two human players to play against each other using two networked devices.
Requirements:
Network play.
Program must let both players know whose turn it is.
...
3
votes
2answers
254 views
Build a program that creates a minimal one-ohm resistor diagram for a given resistance
You are a contractor for a company who designs electrical circuits for the various products they make. One day, the company accidentally gets a huge shipment of one-ohm resistors and absolutely ...
6
votes
2answers
144 views
Inverse CIDR whitelist
The task
The task is to write a program that turns a list of IPv6 addresses into a shortest possible list of CIDR masks, such that everything but those IPs is matched.
CIDR masks
A CIDR mask ...
3
votes
6answers
325 views
Rotate simple ASCII art
This is similar to a previous question on this site, but with much simpler rules, so we should get much shorter results (in bytes):
Input: ASCII art with only two possible characters: space and ...
0
votes
0answers
182 views
Find the best path in a “match-3” game
Suppose you want to cheat in a "match-3" game. In this "match-3" game:
In each turn you can move a gem along a path. For example, you can move a gem right-right-down, as in A. (The gems are ...
5
votes
5answers
444 views
Add an integer to a set and take it back out
Definition: a set is a datatype which allows testing of inclusion ("does set X contain element Y?") but does not have order. Its size is the number of distinct elements it contains.
Define an ...
5
votes
4answers
447 views
Golf with a bowling ball: hello world with high complexity yet short code
In this challenge, you must write a Hello World program that is both short and complex. We measure complexity by Cyclomatic McCabe complexity, and length by the number of bytes (not characters).
...
20
votes
11answers
1k views
Smallest chess board compression
Write an algorithm or program that can encode and decode a chess board. The goal is to make the smallest representation of a chessboard that could be used (once decoded) to determine all movement ...
13
votes
10answers
2k views
Insanity Check Program
Insanity: doing the same thing over and over again and expecting different results.
Write a program that just throws an exception (runtime error) each time it is run. The challenge being to have ...
1
vote
1answer
143 views
Alphanumeric recursive meeting
This challenge is about finding the perfect match between your program sourcecode and the output from your program.
Scoring table for the output:
Each letters (a-z|A-Z) :
`a` or `A` ...
0
votes
7answers
172 views
Find all problems that equal an integer [duplicate]
In this challenge, your job is to write a program that allows a user to enter an integer. Then, the program must find all the possible ways of multiplying two numbers to get the user's integer.
Rules:
...
7
votes
5answers
256 views
Metapoem equinox
Objective:
Write one program that outputs sourcecode for another program that outputs words.
General information:
Any programming language.
Rules:
Your programs should not take any input. ...
20
votes
6answers
797 views
Wikipedia: Philosophy!
As many geeks may know most pages (95% i think) on wikipedia eventually lead to Philosophy like this:
Click on the first non-italic or in parentheses link that is to another normal article: (i.e. not ...
3
votes
6answers
337 views
Compute every combination of operations written in a .TXT file
Your task is to create a program that computes every combination of the operations written in a .TXT file.
Example TXT File:
1
+
2
/
3
Example Output:
1+2/3=1
1+3/2=2
2+1/3=1
2+3/1=5
3+2/1=5
...
2
votes
6answers
498 views
Produce a palindrome from this text
Copy and paste or curl this text:
http://lorem-ipsum.me/api/text
Using any language make the text palindromic.
You may remove letters.
You may rearrange letters.
The goal is to make the text ...
-5
votes
3answers
125 views
Making “Code runner” [closed]
The task is to execute functions stored in a database, preferably xml. For example a function containing system.out.println("a"); is stored in a file code.xml and has been extracted as a string, how ...