This challenge is open to any programming or scripting language.

learn more… | top users | synonyms

-5
votes
2answers
114 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 ...
0
votes
2answers
134 views

How to shorten this J code? (Or write shorter code in another language)

I decided to learn J so that I could better take part in code golfing. Starting it off relatively simple, I tried writing a solution to this problem: Find the sum of all the multiples of 3 or 5 ...
-2
votes
0answers
91 views

What happens when you perform “++” operation on an integer with it's max possible value? [closed]

So, it's a classic but I can't find an answer anywhere. Suppose I've an integer 'x' and int takes 32 bits on this platform. I'm performing the "++" operation in a loop. Something like this: int ...
2
votes
7answers
372 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 ...
16
votes
5answers
434 views

Shortest common superstring

Given a list of strings s_0, s_1, ..., s_n find the shortest string S that contains each of s_0, s_1, ..., s_n as a substring. Examples: S('LOREM', 'DOLOR', 'SED', 'DO', 'MAGNA', 'AD', ...
15
votes
0answers
312 views

The number of possible numeric outcomes of parenthesizations of 2^2^…^2

Consider an expression 2^2^...^2 with n operators ^. Operator ^ means exponentiation ("to the power of"). Assume that it has no default assosiativity, so the expression needs to be fully parenthesized ...
4
votes
4answers
202 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 ...
-4
votes
6answers
131 views

Return the number of digits in any given number

Objective Given any terminating, rational number, return the number of digits the number contains. Do not count zeros if they're the last digits. Examples 0 returns 1 -1 returns 1 6.23 returns 3 ...
1
vote
0answers
174 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
430 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 ...
1
vote
2answers
129 views

Find the generating function of a sequence [duplicate]

Given a set of space-delimited integers, you've gotta either return a function that can generate that sequence, or return "There isn't any such function". Sample input: "1 11 41 79" - x^3+x^2-1 ...
2
votes
2answers
120 views

Zebra stripe command output

I have a script: $ cat ~/zebra.pl #!/bin/perl use Term::ANSIColor; $Term::ANSIColor::EACHLINE = "\n"; my $zebra = 1; # Are zebras black with white stripes, or white with black stripes?! my $black ...
15
votes
4answers
911 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 ...
19
votes
21answers
2k views

Shortest code to determine if a string is a palindrome

A palindrome is some string that is spelled the same way both backwards and forwards. For instance, 'Eva, can I stab bats in a cave?' is a palindrome (EVACANISTAB | BATSINACAVE) For this code golf, ...
7
votes
3answers
220 views

Advanced Code Golf - Disk Operations, and File Allocation

Good Afternoon Golfgeneers. This is reasonably long and detailed question. Given what it was asking, it needed to be. If you have any questions, please ask them. If there is anything that isn't ...
7
votes
7answers
334 views

Sibling Rivalry

Objective Requirements A main 'parent' file and a 'child' file. The parent file creates a new child file that contains code that must execute after creation. The child file that is created must ...
3
votes
4answers
188 views

Count characters in lo..ol and print a phrase [duplicate]

Assuming 'lol' with a variavle number of 'o's. Print a the following phrase: What does 1st, 2nd, 3rd, 4th ... 'o' stand for? Examples: lol -> What does 1st 'o' stand for? loooool -> What ...
12
votes
19answers
875 views

Give the smallest number that has N divisors

Your function takes a natural number and returns the smallest natural number that has exactly that amount of divisors, including itself. Exemples: f(1) = 1 [1] f(2) = 2 [1, 2] f(3) = 4 [1, 2, 4] ...
17
votes
12answers
619 views

Incrementing Numbers, Over Multiple Sessions

Good Evening Golf Agents, Your mission is on behalf of notorious entertainment giant Eviltronic Arts. As part of their nefarious plan for world enslavement and entertainment, they must sell as many ...
1
vote
1answer
170 views

Implement DFA/NFA/epsilon-NFA

Write the shortest code that implements a: DFA NFA epsilon-NFA The program should accept as input: a string(that we want to see if is accepted or not) the delta function, represented in ...
12
votes
21answers
1k views

The world ends in ed

Taken straight from the ACM Winter Programming Contest 2013. You are a person who likes to take things literally. Therefore, for you, the end of The World is ed; the last letters of "The" and "World" ...
2
votes
0answers
181 views

chess - calculate all legal moves from fen string ignoring castling and en passant

Write the shortest code that calculates all possible (legal) moves of current player from a given FEN string. What is FEN string? (Wikipedia) Shortest code wins, language doesn't matter. Output ...
0
votes
0answers
60 views

Minimalist web server [duplicate]

The challenge is to make the shortest fully functioning web server possible. You should give fully working code that can serve static pages from a given local directory. The code can be in any free ...
11
votes
3answers
1k views

Solve Rubik's cube

Write the shortest program that solves Rubik's cube (3*3*3) within a reasonable amount of time and moves (say, max. 5 seconds on your machine and less than 1000 moves). The input is in the format: ...
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 ...
4
votes
4answers
447 views

Print ASCII histogram

The challenge is to give as short code as possible to print an ASCII histogram of a set of data. Input. The number of bins followed by a number of integers representing the data. The data are space ...
8
votes
6answers
906 views

Pong in the shortest code

The challenge is simple. Give the shortest code possible to reproduce the classic 2-player game of pong http://en.wikipedia.org/wiki/Pong . The level of graphics and functionality should be as close ...
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 ...
4
votes
5answers
443 views

Cropping an image succintly

I am constantly frustrated by how complicated it is to write graphical programs that would have been only a few lines of code 20+ years ago. Since the invention of the mouse this has become even ...
6
votes
1answer
321 views

Simple redstone simulator

Redstone is a material in the game Minecraft, and it is used for many complex contraptions. For this program, you will only need to simulate three items: the redstone wire (noted with R), redstone ...
7
votes
7answers
754 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. ...
6
votes
5answers
217 views

Gregorian to Noxu Time System Conversion

The world's changing to a new time system! We need to update our computer programs. Given an input of epoch time (number of seconds since January 1st, 1970 00:00), print out a time in the new Noxu ...
4
votes
3answers
215 views

Determine which of two ImageMagick .TXT images is more saturated

You have two images (64x64 pixels each): Your program must take the file names of each of them as command line arguments and determine which has more average saturation among their pixels. The ...
8
votes
1answer
299 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 ...
10
votes
24answers
2k views

Emulate a 7-segment display

Task The task is to display any of the 128 possible states of a 7-segment display. Your program should accept a string of 7 characters ("bits") that are either 0 or 1. First bit of input corresponds ...
3
votes
4answers
289 views

Convert the Binary Champernowne Constant to Decimal

The Champernowne constant is a transcendental decimal number whose digits are the concatination of all positive integers. C10 = 0.12345678910111213141516...10 The binary version of this is C2 = ...
0
votes
0answers
210 views

Generate Esolangs

Given a file named hello_world that contains 2-100 bytes of printable ASCII, create a Turing-complete language in which hello_world is a valid program that prints "Hello World!". The output should be ...
7
votes
1answer
190 views

Cryptographic quine variant

Create a program that prints the MD5 sum of its source in the form: MD5 sum of my source is: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx No cheating - you can't just read the source file and compute its sum. ...
12
votes
20answers
1k views

Write a program that uses all printable non-alphanumeric ASCII symbols

In particular, use each of these symbols at least once in your source code: ! " # $ % & ' () * + , - . / : ; < = > ? @ [ \ ] ^ _ ` { | } ~ Symbols inside comments, string literals, ...
2
votes
1answer
240 views

Determine the original sequence

Write a program that will determine the original sequence given five variations. The original sequence will be contain n unique elements in any order. A variation is made by making a copy of the ...
6
votes
8answers
503 views

The Strange Unsorting Machine for Nefarious Purposes

Good Evening Golfers! Your challenge is to completely unsort a series of numbers. Input Exactly 100 integers will be fed to your program. Your program may accept the input either as a file, or via ...
4
votes
9answers
502 views

Ode-cay Olf-gay

Write a program which accepts a sentence into stdin, and writes that sentence to stdout in pig latin. Here are some test cases which your program should handle: Input: Read your script Output: ...
2
votes
1answer
140 views

Bob's Financial Planning (Maximize)

Bob's Financial Planning Bob lives in Pecunia. It is a small island city completely governed by the Pecunia City Council (PCC). PCC has decided to encourage foreign investments in the city by waiving ...
7
votes
4answers
393 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
8answers
673 views

Turing Machine Simulator

Write a Turing machine simulator. For simplicity we can assume statuses as integer, symbols as char, blank symbol equals whitespace 5-tuple in the form of current state, input symbol, next state, ...
7
votes
6answers
460 views

Find the Pisano Period of a number

Input: An integer 0 < n < 2^30, taken from stdin. Output: The Pisano period of n (the length of the cycle of the Fibonacci sequence mod n) Input is smaller than 2^30 so that intermediate ...
3
votes
4answers
595 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 ...
16
votes
30answers
2k views

Print this diamond

This question has been spreading like a virus in my office. There are quite a variety of approaches: Print the following: 1 121 12321 1234321 123454321 12345654321 ...
10
votes
4answers
717 views

Create a GUI Piano

Challenge Create a GUI Keyboard with as few characters as possible. Example Because this was an assignment in one of my courses, I can't show the source code. However, here is a screen shot of my ...

1 2 3