A code challenge is a competition for creative ways to solve a programming puzzle for an objective criterion other than code size. Challenges to produce the shortest working code should be tagged [tag:code-golf].

learn more… | top users | synonyms

-5
votes
2answers
142 views

Beer Friday Challenge #1: Dynamic conditional puzzle [closed]

Solve, ((15, 'less_than', 30) == true) Use any language you are comfortable with. The only thing you must not do is mentally substitute the words for the symbols. Here's a link to the gist if you ...
-2
votes
0answers
63 views

Build a reusable, customizable menu widget using angularjs [closed]

Build a reusable, customizable menu widget using angularjs that allows you to have as many levels as you like and is reusable in the vain of: Sudo code: -- ul template ul template open for each in ...
3
votes
4answers
259 views

Encode a program with the fewest distinct characters possible,

The goal is to write a program that encodes an other program (input) with the fewest character possible. Scoring The score is equal to the different number of characters needed for the output. ...
-3
votes
2answers
162 views

Search for all the possible permutations of one String in another string

Suppose you are given two strings like String 1 = "ipsum" String 2 = "Lorem ipsum is simply dummy text of the printing and typesetting industry. Lorem sipum has been the industry's standard ...
2
votes
7answers
426 views

Compute the number of ways how you can express a number as a sum

For a given natural number n, compute the number of ways how one can express n as a sum of positive natural numbers. For example, for n = 1 there is just one way. For n = 4 we have 5 possible ways: 1 ...
6
votes
5answers
283 views

Avoid duplicate entries using a sign change

This anecdote contains the following intriguing exchange: "Fine, Fred," Avi interrupted. "Then how would you change this to avoid duplicate entries?" "Oh, just change that one there to a negative ...
1
vote
0answers
194 views

Write a Polish notation interpreter, then change it to RPN in shortest number of chars

Write a program to convert Polish prefix notation to infix notation, then change it to an RPN-to-infix converter in the shortest number of chars. Your score is 100 minus the number of characters ...
2
votes
5answers
439 views

Challenge: take ciphered text and decipher, also print out if it was offset to the left or right

Problem: Take input text like this: (all input should be considered strings) Upi djpi;f ytu yu[omh pmr yp yjr ;rgy. And figure out if it was offset left or offset right (on a standard qwerty ...
50
votes
52answers
5k views

-ENDED- Do something that looks like something else

Write a snippet, a function, a programm, ... that is obfuscated in a way that it looks clear at the first sight that it does something else. For example: write a bit of code that adds two number, but ...
6
votes
4answers
373 views

Display a bézier curve in the browser

The goal is to display a bézier curve in any classical browser (except maybe old IE versions, because... are they really browsers?) client side. Rules: You must provide one or more files (or their ...
23
votes
5answers
1k views

Fault-Tolerant Hello World (a.k.a. the Interview)

At the end of your interview, the Evil Interviewer tells you, "We make all of our applicants take a short coding test, to see if they really know what they are talking about. Don't worry; it's easy. ...
24
votes
24answers
2k views

Print a string in as few distinct characters as possible

The task is simple: print The quick brown fox jumps over the lazy dog using as few distinct characters in your source code as possible. print "The quick brown fox jumps over the lazy dog" has a score ...
3
votes
9answers
384 views

Eight Queens Obsfucation

You've probably heard of the classic Eight Queens Puzzle. For those of you who haven't it goes something like this: Position 8 queens on an 8×8 chessboard so that no two queens threaten each ...
7
votes
3answers
263 views

Rosetta Stone Challenge: Draw a Box Plot

The goal of a Rosetta Stone Challenge is to write solutions in as many languages as possible. Show off your programming multilingualism! The Challenge Your challenge is to implement a program that ...
15
votes
4answers
928 views

(Re)Implementing Tetris

In the spirit of re-implementing classic video games, I would like to invite the community to create their best implementation of Tetris. For reference, a screenshot of the official NES version of ...
7
votes
1answer
335 views

Generate a number by using a given list of numbers and arithmetic operators

You have a list of numbers L = [17, 5, 9, 17, 59, 14], a dictionary of operators O = {+:7, -:3, *:5, /:1} and a number N = 569. Task Output an equation that uses all numbers in L on the left-hand ...
-2
votes
3answers
322 views

Write a program to print squares of integers up to 25 in java without using variables?

I asked this question on programmers 10 days back but wasn't able to get the answer that I wanted. Write program in java to print the squares of first 25 integers(1-25) without using any variables. ...
1
vote
1answer
225 views

Build a 12-hour digital clock

In my essay "Use the 24-hour clock", I claim that trying to represent the 12-hour clock directly in data is a terrible exercise in patchy, inelegant programming: "No problem, we'll just use ...
12
votes
5answers
709 views

Find largest prime which is still a prime after digit deletion

Over at http://math.stackexchange.com/questions/33094/deleting-any-digit-yields-a-prime-is-there-a-name-for-this the following question is asked. How many primes are there that remain prime after you ...
9
votes
5answers
548 views

Swapping numbers

This is a common puzzle many of you have solved manually. Now this is the time to write an algorithm to solve the same. There are equal number match sticks lined up in two different side facing each ...
5
votes
2answers
344 views

Drawing 3d nets - Archimedean solids

I have a weakness for 3d nets which when cut out and folded allow you to make 3d shapes out of paper or card. The task is simple, written the shortest program you can that draws nets for the 13 ...
7
votes
4answers
697 views

Breakout in half an hour

When I was a young teen I had a very boastful friend who claimed he could code up breakout (http://en.wikipedia.org/wiki/Breakout_(video_game)) in half an hour. Half an hour later he had done a great ...
7
votes
7answers
760 views

Write ASCII-Art Obfuscated Code, read as, and resulting in: “DFTBA”

The challenge is to write the most elaborate code, embedded in ASCII art that reads and prints "DFTBA". For example, the following reads DFTBA: oooooooooo. oooooooooooo ooooooooooooo oooooooooo. ...
5
votes
2answers
671 views

Bouncing ball simulation

Print, on STDOUT, a pattern which shows in what direction a bouncing ball will take. The following assumptions are made: The ball starts at the top left corner: 0, 0 with zero initial velocity. ...
-2
votes
1answer
250 views

Emulate an Intel 8086… COMPLETELY [duplicate]

Possible Duplicate: Emulate an Intel 8086 CPU I know that there already is a code golf for this, but that one didn't require much. This one, however, is for masochists only! >:) OK, you ...
16
votes
7answers
623 views

Find The Wordiest Combination Lock

I have a combination padlock which has letters instead of numbers. It looks like this: http://pictures.picpedia.com/2012/09/Word_Combination_Padlock.jpg There are 5 reels, each of which has 10 ...
17
votes
9answers
1k views

Write the longest sentence using keywords of a programming language

This is not exactly a programming challenge, but a programming-related word challenge. If this is not fit for the site then feel free to close. As the title said, the challenge is to write the ...
8
votes
1answer
300 views

Compact a Befunge program

Befunge is a 2-dimensional esoteric programming language. The basic idea is that (one-character) commands are placed on a 2-dimensional grid. Control flow walks across the grid, executing commands it ...
0
votes
7answers
480 views

Implementing bool() without any conditionals

Title says it all. Given some input, turn it into a boolean value (0 or 1), without using conditional statements (e.x. == > < <= >= != ~=), or any function which uses conditional ...
9
votes
7answers
474 views

C: replace AES FIPS-197 SubBytes table by constant-time code

In FIPS-197 (the Advanced Encryption Standard, known as AES), it is made heavy use of SubBytes, which could be implemented as unsigned char SubBytes(unsigned char x) { static const unsigned char ...
1
vote
4answers
346 views

Four weights to produce integer scale differences from 0 through 40 pounds

Just-in-time edit: I decided to reveal part of the answer and highlight a single aspect of the challenge. Show how 4 weights, of 1, 3, 9, and 27 lbs. can be used to produce "weight differences" ...
3
votes
2answers
276 views

Pseudosort a list in 2*n comparisons

Write a program that takes a list of n space-separated integers, and outputs a permutation of that list using a maximum of 2*n comparisons. It should loop this until an empty line is input. ...
3
votes
2answers
287 views

Write a java code to detect the JVM version

The objective is to write java code that detects the JVM version relying in compatibility changes, side effects, bugs and/or undefined behavior that works in a way in one version and another way in ...
3
votes
3answers
405 views

Secret Santa Challenge [duplicate]

Possible Duplicate: Holiday Gift Exchange Background: Secret Santa is a Western Christmas tradition in which members of a group or community are randomly assigned a person to whom they ...
-2
votes
1answer
233 views

Write a program that becomes slower when a single line is added [closed]

Write a program that become much, much slower on the addition of a line of code. Rules: No sleep( ) statements, please. No loops with huge LCVs. As always, may the shortest win!
2
votes
0answers
269 views

Best Scoring Scrabble Board

Challenge Your challenge is simply to write a program in the language of your choosing that when run, determines the highest possible score for a board of Scrabble - For the sake of this challenge, a ...
-3
votes
7answers
333 views

Swap 2 objects, without using a temporary variable [closed]

There are two objects: Object1, Object2 You can easily swap them by: Object3 = Object1 Object1 = Object2 Object2 = Object3 However, you must solve this problem by using no temporary object and ...
3
votes
2answers
267 views

Compiled quine variant

Thinking about various quine puzzles here, I got an idea for another one: Compose a program that outputs its own compiled code to a file (or multiple files, if the compiled code is). (This means that ...
5
votes
3answers
643 views

Create a C program that takes the longest period of time to compile in gcc

Create a short C program that takes an absurdly long time to compile with gcc. Entries will be scored by timing the compilation then subtracting the reference program's compile time. Rules Any C ...
7
votes
4answers
394 views

Program my microwave oven

I'm very lazy so I try to always program my microwave with the fewest possible button presses. My microwave has the following buttons: A "minute plus" button which may only be pressed first and ...
-5
votes
2answers
290 views

Implementing a Traffic Light Checker

A three-color traffic light must switch lights in the following order: red, green, yellow, red. To indicate when crossing slowly without a stop is permitted, the yellow signal may be flashed. To ...
3
votes
4answers
600 views

RPN calculator without pointers

Me and some other students were at a bar discussing programming languages, in particular the C programming language. At some point a first year student said he didn't need no damn pointers. Another ...
5
votes
2answers
527 views

Domino Effect Problem

Last week we had a programming contest in my university and I am very curious about one of the problems , one which only one team (but from another city) was able to solve. May be its not that hard, ...
2
votes
3answers
331 views

m3ph1st0s's programming puzzle 4 (C/C++): “3-way swap”

My last puzzle has generated some confusion and controversy so I decided to give up, for now, on those "replace one character"-type puzzles. Hope this 4th puzzle will redeem myself after all the ...
10
votes
1answer
558 views

Recreate an xkcd graph procedurally with your favorite plotting tool

Lately there have been quite a number of questions regarding the recreation of xkcd-style graphs like the following one (1064) in various languages. Your goal is to recreate any existing xkcd comic ...
7
votes
2answers
441 views

m3ph1st0s's programming puzzle 3 (C): “Easy bug”

This is the 3rd of my series of C/C++ puzzles; in case you missed the first 2 they are here: (1) m3ph1st0s's programming puzzle 1 (C++) (2) m3ph1st0s's programming puzzle 2 (C++): "Call ...
0
votes
0answers
181 views

My Language is Better Than Yours! [closed]

this is a For-Fun challenge. The challenge is pretty simple, and one that for once, I don't think golfscript or anything similar has a chance to win! The goal is simple, write code in whatever ...
2
votes
4answers
311 views

m3ph1st0s's programming puzzle 2 (C++): “Call hard!”

I am back with a brand new puzzle for C/C++ addicts. Following the feedback received on the 1st puzzle, this time I will try to make the requirements crystal clear and to provide a perfectly valid ...
16
votes
13answers
1k views

m3ph1st0s's programming puzzle 1 (C++)

Hello C++ programmers! This is the first of a series of C++ puzzles for you. Hope you will enjoy. So, puzzle no.1: Given the following program: #include <iostream> int main() { const int ...
1
vote
9answers
414 views

Generate a valid sequence of numbers with specific rules

The challenge The program must return a valid sequence of numbers into some rules Rules x is the size of the sequence; x cannot be less than 4 or greater than 9 (Thanks David Carraher); Digits of ...

1 2 3 4