All Questions

Filter by
Sorted by
Tagged with
11
votes
8answers
1k views

Build a typing speed test / measuring CPM

The Rules It's time to build a typing speed test in your language of choice! 1. You provide a file with a dictionary of choice (every 'word' in it must be newline delimited). Pipe it in via ...
37
votes
16answers
4k views

Executable haiku that outputs a haiku [closed]

Puzzle: Write a short, three-line program which: has 5/7/5 syllables per line when read aloud outputs a haiku when run. An example of a program having the correct structure, but non-haiku output, ...
-8
votes
1answer
418 views

Sort an array with values of integer [closed]

There is an array of integer values to be sorted.During the sorting process, the places of two numbers can be interchanged. Each interchange has a cost, which is the sum of the two numbers involved. ...
8
votes
2answers
2k views

PHP golfing tips: Reading/writing files and the CLI

I have been participating in a number of PHP code golf challenges recently and some of the techniques that are used to read data from a file such as fopen() and <...
20
votes
2answers
9k views

Shortest ELF for “Hello world\n”? [duplicate]

Is it possible to write (pack) a shorter than 145 bytes version of a program with "Hello world" (plus new line) output if the length of the program is measured as a number of bytes in program's ELF (...
9
votes
0answers
1k views

Minimal Sudoku Generator [closed]

Ask questions if you need to, I'll elaborate on anything that needs clarified. My challenge is to unsolve a sudoku to a minimal state. Basically take a supplied, solved, sudoku board and unsolve it ...
4
votes
3answers
595 views

Pretty-printing polynomials

A polynomial over a variable x is a function of the form p(x) = anxn + an-1xn-1 + ... + a1x + a0 where a0 ... an are the coefficients. In the simplest case, the coefficients are integers, e.g. ...
16
votes
4answers
6k views

Best Scoring Boggle Board

I was interested in seeing the answers to this (now defunct) question, but it has never been corrected/improved. Given a set of 6-sided Boggle dice (configuration stolen from this question), ...
11
votes
16answers
2k views

ASCII Ball in Box Animation

Write a program that displays a moving ASCII ball * inside a rectangle (20 by 10 chars including border). The ball must not cross the rectangle, e.g. bump off when ...
8
votes
3answers
731 views

Use NVM to tenaciously resume operation whenever aborted

We'll be trying to write a program that remembers what it has been doing so far and continues towards its goal if aborted an re-run. This is a tenacious program. It will be using a Non-Volatile Memory ...
71
votes
112answers
15k views

Print the alphabet without using each vowel

Inspiration: in 1939, a man named Ernest Vincent Wright wrote a novel called Gadsby without using the letter 'e'. Your task is to write a set of (up to 5) programs in any language (which has a text-...
22
votes
7answers
899 views

Reverse Engineer Polling Statistics

Introduction Given a set of percentages of choices in a poll, calculate the minimum number of voters there must be in the poll to generate those statistics. Example: What is your favorite pet? Dog: ...
11
votes
2answers
298 views

How many mesas begin with a given string?

Let's call a non-empty list of strings a mesa if the following conditions hold: Each listed string is non-empty and uses only characters that occur in the first string. Each successive string ...
8
votes
3answers
2k views

Solve the 14-Pegs puzzle

Introduction A common puzzle involves a triangular board with 15 holes for tees/pegs as shown in the image below: Starting with all the pegs in the board except for a hole at the top, the point of ...
27
votes
35answers
4k views

Implement hyperexponentiation/tetration without the use of '^'

The Challenge Implement tetration (aka Power Tower or Hyperexponentiation) with the least amount of characters. The Conditions Don't use the 'power' operator or its equivalents (such as ...
14
votes
5answers
6k views

Shortest Hello World program with no semi colons

I recently saw some questions on SO that asked if you could make a Hello World program without using any semi colons using C#. The challenge is to do this again, but in the shortest amount of code ...
23
votes
50answers
6k views

Is string X a subsequence of string Y?

Given strings X and Y, determine whether X is a subsequence of Y. The empty string is regarded as a subsequence of every string. (E.g., '' and ...
5
votes
13answers
862 views

Generate the list [1, 0, -1, 0, 1, 0, -1, 0, …] [closed]

In the spirit of a question on math.se: given an integer n, return the integer in position n of the sequence [1, 0, -1, 0, 1, 0, ...
12
votes
2answers
1k views

Code Golf: What is the spaceship's fate? [floating point version]

This question is slightly harder than the ASCII art version. There is no art, and now you get to do some floating point arithmetic! The Challenge The U.S.S. StackExchange was traveling through the ...
28
votes
7answers
3k views

Score a Cribbage Hand

This challenge is to score a Cribbage hand. If you don't play Cribbage, you've got some learning to do. We play with a standard poker deck, and a hand consists of four cards plus the "up card". ...
14
votes
1answer
2k views

Code Golf: What is the spaceship's fate? [ASCII art version]

Background In a galaxy (and possibly a universe) far, far away... there was a spaceship and a bunch of planets. A malfunction on board caused the spaceship to run out of fuel. It is now moving at a ...
25
votes
6answers
2k views

Can you Meta Quine?

Similar to other quine puzzles (more specifically, this one), write a program that produces the source for itself. Here's the new twist: The code produced should NOT be identical to the source. ...
15
votes
14answers
1k views

Calculate a user's privileges on CodeGolf.SE

The Challenge Your goal is to write the shortest program possible that will take a list of events (such as upvote, downvote, etc) and return the user's reputation and the privileges that he has ...
19
votes
2answers
1k views

Play Connect 4!

Write a program to play the game of Connect 4. You are given the state of the board as input and you must decide which column to place your piece in to either get 4 in a row (horizontally, vertically,...
33
votes
7answers
3k views

Anti-aliasing ASCII art

Background ASCII art is the practice of creating images by using ASCII text to form shapes. Aliasing is the effect created by the large "pixels" of ASCII art, which are the size of characters. The ...
15
votes
16answers
2k views

Rosetta Stone Challenge: Find the rule for a series

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 ...
16
votes
3answers
2k views

Code golf: Solve a Knights and Knaves logic problem by parsing English

Background There are two people, Bill and John. One of them is a knight, which always tells the truth, and the other is a knave, which always tells a lie. You don't know who is the knight and who is ...
32
votes
10answers
10k views

Brainf*** Golfer

One of easiest code written by a programming language is a program printing sequence of characters (ex. "Hello, world!"). However, some esoteric programming languages like Brainfuck, even this ...
10
votes
6answers
432 views

Print the sizes of intervals inside of a piece of music

Background In Western music, every single music note has an assigned name. Within each octave, there are twelve unique notes in the following order: "C C#/Db D D#/Eb E F F#/Gb G G#/Ab A A#/Bb B C", ...
4
votes
2answers
6k views

Water-Bucket problem [closed]

This challenge is to calculate how to measure 4 liters of water with just two unevenly sized buckets, one of 3 liters and another of 5 liters, in minimum number of steps. To extend and generalize this,...
6
votes
1answer
1k views

Lorem Ipsum Random Code Generation

An IDE developer has hired you to write a program that generates (by printing to stdout) n lines of randomly generated code. They will use your program to create sample code for use in marketing their ...
12
votes
13answers
5k views

create an ascii progress bar

well, it's something similar to this question but with a little differences. you have to write a program to ask for width of progress bar and how much work is done. and then draw a progress bar with ...
0
votes
0answers
130 views

Code Golf: Expression Evaluator [duplicate]

Possible Duplicate: Advanced Calculator The goal of this is to take a mathematical expression, evaluate it, and return the value. The value of the input string will never be more than 2^31-1, ...
8
votes
3answers
1k views

Did I win the lotto?

I just submitted an answer to this question, and then looked about at some news stories about the MegaMillions lottery craze going on right now in the US. This news article stated that an individual ...
2
votes
1answer
303 views

Implement a model of computation using a type system

Implement any model of computation as powerful as a Turing machine using any existing language's type system. Your solution should handle the computation using the language's type system, not the ...
33
votes
3answers
2k views

Underhanded Password Hashing [closed]

In the spirit of the Underhanded C Contest, I'm starting an Underhanded Code Contest. The objective of this contest is to straightforwardly implement some code, while subtly hiding a nefarious bug ...
2
votes
1answer
519 views

Code Golf: Make a Web Crawler

A Web Crawler is a program that starts with a small list of websites and gets the source code for all of them. It then finds all the links in those source codes, gets the website it links to then puts ...
4
votes
29answers
1k views

Constant output program [closed]

I was wondering how one might go and produce a program that takes input from some kind of random source and uses it to produce constant output. An obvious way is, for example, to take an integer x and ...
81
votes
35answers
8k views

Tips for golfing in <all languages>

The aim of this post is to gather all the golfing tips that can be easily applied to <all languages> rather than a specific one. Only post answers that its ...
13
votes
17answers
2k views

Scrolling Marquee

Following my entry to the Obfuscated Hello World I thought it might be fun to share the underlying code. But why just show the code, lets make it a golf too! Challenge Write a script that scrolls a ...
5
votes
3answers
915 views

Generate number in reverse polish notation

Your task is to write a function which accepts a number N and creates a string of Reverse Polish Notation which will generate that number. Valid operations are: ...
11
votes
3answers
1k views

Create a multi-level 5x5x5 Labyrinth with only one solution

The aim of this challenge is to create the shortest code (in characters) that successfully do the following: Specifications: Must create a 5x5x5 labyrinth with ...
35
votes
17answers
4k views

Tips for golfing in GolfScript

What, this post doesn't exist yet? Of course, GolfScript is made for golfing, so you might think that no specific tips are really needed. But to make full use of GolfScript's features, you need to ...
24
votes
5answers
4k views

Solving Mastermind in 6 or less moves

Your goal is to write a program that will solve any Mastermind puzzle in 6 or less moves. Background Mastermind is a board game. The goal of the game is to exactly guess the combination (colours and ...
18
votes
4answers
2k views

Convert Fractran into Brainfuck

Background Fractran is an esoteric Turing-complete programming language invented by John Conway. A Fractran program consists of an ordered list of fractions. The program starts by taking a single ...
2
votes
3answers
360 views

shortest progam to scan a line and print it using befunge!

well, I'm newly introduced to befunge. it seems to be an amazing language but a bit hard to start with! anyway after about 2 hours of hard work I've created a code which could read a line from stdin ...
17
votes
4answers
3k views

Rotate an ASCII art image

Out of all of the ASCII characters, it is easy to tell that some of them form groups that are rotations of the same basic character. For example, V > ^ <. ...
10
votes
9answers
1k views

Encode an image inside of the source

The golf challenge is to encode and compress the following image inside a source file. To do this you need to write 3 functions: red, ...
13
votes
12answers
3k views

Implement a One-Time Pad

Background A one-time pad is a form of encryption that has been proven impossible to crack if used properly. Encryption is performed by taking a plaintext (comprised of only letters A-Z) and ...
16
votes
33answers
3k views

Tips for golfing in VBA

Similar to this, this, and this question... What general tips do you have for golfing in VBA? I'm looking for ideas that can be applied to code golf problems in ...

15 30 50 per page