All Questions

Filter by
Sorted by
Tagged with
11
votes
4answers
3k views

Recreate the classic snake Game

The challenge is to create the classic Snake game using as few bytes as possible. Here are the requirements: The game must be implemented in a typical 2-dimensional layout. The snake should be able ...
3
votes
2answers
714 views

Generate N number of “Go First” dice [closed]

Background As described here http://www.ericharshbarger.org/dice/#gofirst_4d12, "Go First" Dice is a set of four dice, each with unique numbering, so that: There will never be a tie. Each die has a ...
16
votes
2answers
1k views

win a virtual fencing match (against your fellow stack exchangers)

WARNING: this is a fairly complex problem, in a king-of-the-hill combat style, with an added randomness to it, the best code may not always win. Please read all rules in full, as it is quite complex! ...
4
votes
2answers
494 views

List ALL prime-factorized natural numbers in ANY order

This is a variant of List prime-factorized natural numbers up to N in ascending order, but the solutions can be very different. Write a program that outputs prime factorizations of all natural ...
8
votes
3answers
1k views

List prime-factorized natural numbers up to N in ascending order

For a given n list prime factorization of all natural numbers between 1 and n in ascending ...
44
votes
26answers
6k views

Crash your favorite compiler [closed]

Write a perfectly legal code in a decent language of your choice whose compiling will either crash the compiler or send it into an infinite loop (infinite compile time). Restrictions: Use a standard ...
23
votes
4answers
1k views

Solving Three Open Problems with a Halting Oracle

You are given the functions: h1(f,*args) and h2(f,*args) Both are methods which are already defined for you (here the asterisk indicates a variable number of arguments) f is a function, *args is a ...
1
vote
2answers
938 views

A doubly linked list that only stores 1 pointer per element [closed]

A favorite puzzle of mine. Not massively difficult but a tad interesting. The Objective Using a low level language (C/C++/similar level) - create a doubly linked list of elements that only stores a ...
4
votes
1answer
484 views

Minimum number of transactions so everyone has paid the same [closed]

On a road trip, N people pay for fuel. Each pays a different amount. At the end of the trip, calculate the minimum number of transactions so that each person has paid the same amount. e.g. on the ...
90
votes
98answers
18k views

When does (x == x+2)? [closed]

The challenge: Define x in such a way that the expression (x == x+2) would evaluate to true. I tagged the question with C, but ...
13
votes
5answers
512 views

Given a fair coin as input, generate any particular unfair outcome

It is easy to generate a fair coin using a unfair coin, but the reverse is harder to accomplish. Your program will receive one number X (between 0 and 1, inclusive) as input. The input must not ...
8
votes
2answers
829 views

The GolfScript Meta Par Hole

Seem like GolfScript wins all of these. So you can't beat them, join them. Write an Self-Contained Golfscript Interpreter I'm using the definition of self-contained to mean, a single program:- So no ...
23
votes
6answers
1k views

Lego gear ratios

I'm building a giant lego robot and I need to generate some particular gear ratios using a set of gears. I have lots of gears with the common lego gear sizes: 8, 16, 24, or 40 teeth. Write a program ...
1
vote
1answer
484 views

How can I make this program smaller? [closed]

I am trying my hand at writing super small programs. I wrote a simple "tree" display program for showing a graphical representation of a folder hierarchy. I have made it small in all the ways I can ...
-7
votes
2answers
1k views

Help Alice in giving candies [closed]

Alice is a kindergarden teacher. She wants to give some candies to the children in her class. All the children sit in a line and each of them has a rating score according to his or her usual ...
4
votes
2answers
1k views

Help johnny to solve this Puzzle

Scenario Little Johnny wants to play with his friends today. But his babysitter won't let him go! After a lot of begging, the heartless nanny gives him her brand new electronic puzzle and says: "If ...
5
votes
1answer
731 views

Lightbox Generator

Warning: this is a complex challenge. Overview A lightbox, in the context of computing, is a visual effect used in image sites. A list of thumbnail images is displayed; each image can be selected ...
15
votes
25answers
7k views

Calculate pi to 5 decimals

This comes from http://programmers.blogoverflow.com/2012/08/20-controversial-programming-opinions/ "Given that Pi can be estimated using the function 4 * (1 – 1/3 + 1/5 – 1/7 + …) with more terms ...
18
votes
4answers
2k views

Star programming!

The challenge Write a program or function that prints stars! The program will receive two parameters by standar input: Size of the star and number of points of the star. A star can be any size ...
7
votes
2answers
2k views

Create an acrostic

Pretty fun and simple challenge here given any input, create an acrostic poem for that input. you may use any word list of your choosing, and include any code you want to help "smarten" up your ...
6
votes
4answers
513 views

Implement half away from 0 rounding

Overview: Using you language of choice, implement a complete "half away from 0" rounding function in the shortest amount of code possible. Rules/Constraints: Direct, predefined ...
7
votes
5answers
3k views

A simple Knight's problem

How many ways are there to place a black and a white knight on an N * M chessboard such that they do not attack each other? A knight can move two squares horizontally and one square vertically, or ...
8
votes
4answers
1k views

Build a Simple Roguelike

This challenge is based on one proposed on the usenet group rec.games.roguelike.development a few years ago. I can't find the original newsgroup post, but you can have a look a the Github repo of ...
4
votes
1answer
445 views

Convert Regexes

Suppose you have existing regexes you wish to compile using one of the submissions to Compile Regexes. In as few characters as possible, write a program that: accepts an existing regex as input, as ...
8
votes
6answers
1k views

Shortest undefined behavior sample in C++ [closed]

What's the shortest, well-formed C++ code that exhibits undefined behavior?
20
votes
30answers
3k views

Print custom alphabet

The Challenge Display the alphabet from a given letter read from console input. If the letter is uppercase, you have to display the alphabet uppercased. The alphabet printed must end in the precedent ...
17
votes
2answers
957 views

Compile Regexes

In this task you have to write a program that reads a regular expression and generates another program that outputs whether an input string is accepted by that regular expression. The output must be a ...
8
votes
9answers
673 views

Working Week Completion

I work a standard nine to five. Monday through Friday. I take a half hour for lunch from 12:30 to 13:00. Write me a program which, when run, calculates the percentage of the working week that I have ...
8
votes
11answers
3k views

Find the nth Fibonnaci Prime, in the shortest code

The challenge is rather simple: Take a positive whole number n as input. Output the nth Fibonacci prime number. Input can be ...
12
votes
4answers
589 views

Draw a tiled cube of any size

Draw a tiled cube of any size, in ASCII art. You will be given three numbers a, b and c, ...
31
votes
8answers
3k views

Code-Golf: Count Islands

A simple contest, inspired by this stackoverflow question: You are given an image of a surface photographed by a satellite.The image is a bitmap where water is marked by '...
12
votes
1answer
2k views

What is the minimum set of characters with which you can write any valid python program? [duplicate]

The proof of the set of characters is that there is a translator which takes any ascii python program as input and produces a limited character set version of the program. The limited character set ...
7
votes
5answers
604 views

Output a Dance Dance Revolution arrow chart

If you're not familiar, Dance Dance Revolution is a rhythm game where you hit four receptors (left, down, up, right) with your feet as arrows scroll up the screen. One of the file formats used to lay ...
13
votes
10answers
2k views

Output a number in PrettyFont

I've designed a new font which I call PrettyFont. I've put much much time into perfecting it, but since I'm a working man I don't have time to finish it. Therefore it only contains 4 characters right ...
2
votes
0answers
489 views

Breaking Perfect Hangman in reverse, in reverse [closed]

this is the follow-up question to Perfect Hangman in reverse golfers are now asked to develop a program that uses all rules in Perfect Hangman in reverse, instead, playing the player. the program ...
5
votes
7answers
459 views

Finding variables in code

Given some code in your language as a string, find and display all the variable names. Examples in pseudocode: ...
0
votes
0answers
159 views

Find the number of strings from the list that have a Levenshtein distance of 3 or less to the string “together” [duplicate]

Possible Duplicate: Find the minimum edit distance between two strings The file below (see link) contains 58,111 lines with a single lower case word on each line. Find the number of strings from ...
4
votes
5answers
3k views

Find the first n digits of the square root of a number

Given two integers m and n, return the first m digits of ...
7
votes
4answers
755 views

Convert from binary to unary in 7x7 Manufactoria

In the game manufactoria, take in a binary number and output that number of red pieces. The catch? The board-size is only 7x7: Here's the manufactoria code for the problem: http://pleasingfungus.com/...
40
votes
32answers
5k views

Ridiculous Runtime Errors [closed]

Write programs that produce crazy, obscure, ridiculous, or just plain nutty runtime errors. Obfuscation and golfitude (shortness) not required. solutions that look like they should work fine are ...
23
votes
3answers
16k views

Solve the 15 Puzzle (the tile-sliding puzzle)

The 15 Puzzle is a famous puzzle involving sliding 15 tiles around on a 4x4 grid. Starting from a random configuration, the goal is to arrange the tiles in the correct order. Here is an example of a ...
8
votes
18answers
1k views

Square-free semiprime counting

Definition A square-free semiprime is a natural number that is the product of two distinct prime numbers. The task Given a natural number n, count all square-...
12
votes
11answers
2k views

Generate a (completely deterministic) pseudorandom bit stream

Inspired by Random with your hands tied: The Goal The goal of this challenge is to write a program that generates a pseudorandom bit stream, which is a string of 1s and 0s that appears to be purely ...
48
votes
65answers
10k views

Divide a number by 3 without using *, /, +, -, % operators

Quoting this question on SO (Spoiler alert!): This question has been asked in an Oracle interview. How would you divide a number by 3 without using *, /, +, -, %, operators? The number ...
2
votes
7answers
625 views

Random with your hands tied [closed]

Task Develop some code to generate a psuedo-random number between X and Y (taken as input). Explain why or how it works. Conditions Do not use any random generating seeds, pre-written randoms, or ...
4
votes
4answers
1k views

Use a genetic algorithm to recreate a string [closed]

AKA: the most complex way to return a string I could think of. Requirements: *Edit: * @Griffin, You are correct, the goal is to use crossover/mutation of characters in a string to eventually come up ...
7
votes
12answers
1k views

Generate the names of the keys on a piano

On a standard 88 key piano, each key has a scientific name. The first three keys are A0, B♭0, and B0. The keys then proceed through C1, D♭1, D1, E♭1, E1, F1, G♭1, G1, A♭1, A1, B♭1, B1, and start over ...
15
votes
3answers
4k views

Self-matching regex [closed]

Write a non-trivial regex that matches itself. For example, #.*$ will match a comment outside of a string in python until the end-of-line, and also matches itself ...
3
votes
13answers
602 views

Find top student from three test marks

First save the following text into a file called marks.csv Smith,6,9,24 Jones,9,12,20 Fred,5,9,20 Each line contains a ...
7
votes
14answers
1k views

Calculate golden ratio

Write the shortest code, in number of bytes, to display, return, or evaluate to the golden ratio (that is, the positive root of the quadratic equation: , approximately 1.618033988749895), to at least ...

15 30 50 per page