Correct a broken loop by changing exactly one character

I found a site with some complicated C puzzles. Right now I'm dealing with this: The following is a piece of C code, whose intention was to print a minus sign 20 times. But you can notice that, it doesn't work. #include <stdio.h> int main() { int i;

scrambling program of oneliner

It's that time of year again that programmers want to shuffle a list such that no element resides on its original position (at least in the Netherlands, we celebrate Sinterklaas and pick straws for deciding who writes who a poem). Does anyone have a

How to convert numbers to words in Erlang?

I found this interesting question about converting numbers into "words": Code Golf: Number to Words I would really like to see how you would implement this efficiently in Erlang. -module(int2txt). -export([convert/1]). convert(0) -> "zer

Inject a javascript file with as few characters as possible?

I'm working on a bookmarklet, and thought I'd throw down a challenge: how to inject an external javascript file from a link in as few characters as possible. Here's the shortest I was able to come up with: javascript:(function(d){d.body.appendChild(d

Bash text parsing golf

I am writing a shell script to, among other things, determine the last time a branch was made in a subversion repository. The following code works: DEV='http://some/svn/server/' BRANCH='some/repos/branches/' LAST_UPDATE=`svn list http://$DEV$BRANCH |

contest of the function garble

Remember that away message on aim that said how: Aoccdrnig to a rscheearch at Cmabrigde Uinervtisy, it deosn't mttaer in waht oredr the ltteers in a wrod are, the olny iprmoetnt tihng is taht the frist and lsat ltteer be at the rghit pclae. The rset

Golf Code: Happy Rewards!

It's Sunday, time for a round of code golf! Challenge Write the shortest source code by character count to determine if an input number is a "happy prime", "sad prime", "happy non-prime", or "sad non-prime." Input T

Array Code Search challenge

Here's my (code golf) challenge: Take two arrays of bytes and determine if the second array is a substring of the first. If it is, output the index at which the contents of the second array appear in the first. If you do not find the second array in

Golf code: Conjecture Collatz

Inspired by http://xkcd.com/710/ here is a code golf for it. The Challenge Given a positive integer greater than 0, print out the hailstone sequence for that number. The Hailstone Sequence See Wikipedia for more detail.. If the number is even, divide

Golf Code: Spider webs

The challenge The shortest code by character count to output a spider web with rings equal to user's input. A spider web is started by reconstructing the center ring: \_|_/ _/ \_ \___/ / | \ Then adding rings equal to the amount entered by the user.

Analysis and formatting of search results

Search: Scripting+Language Web+Pages Applications Results: ...scripting language originally...producing dynamic web pages. It has...graphical applications....purpose scripting language that is...d creating web pages as output... Suppose I want a valu

Golf Code: 2D platform

The Challenge Reach the end of the level! Bonus points if you hit each of the (C)oin blocks exactly 2 times. Disallowed Hard coding the command sequence in any way. Your favorite "One character language" that happens to do exactly one thing, whi

Golf Code: Regex Analyzer

The goal Today's Code Golf challenge is to create a regex parser in as few characters as possible. The syntax No, I'm not asking you to match Perl-style regular expressions. There's already a very reliable interpreter for those, after all! :-) Here's

Golf Code: Piano

The challenge The shortest code by character count to output a part of a piano keyboard starting from input note in a given length. Input will be composed of a note ([ACDFG]#|[A-G]) to start printing the keyboard from and a positive number representi

Golf Code: Phone number to words

Guidelines for code-golf on SO We've all seen phone numbers that are put into words: 1-800-BUY-MORE, etc. What is the shortest amount of code you can write that will produce all the possible combinations of words for a 7 digit US phone number. Input

Twitter text compression challenge

Rules Your program must have two modes: encoding and decoding. When encoding: Your program must take as input some human readable Latin1 text, presumably English. It doesn't matter if you ignore punctuation marks. You only need to worry about actual

Golf Code: MSM Random Number Generator

The challenge: The shortest code by character count that will generate a series of (pseudo)random numbers using the Middle-Square Method. The Middle-Square Method of (pseudo)random number generation was first suggested by John Von Neumann in 1946 and

Golf Code: Morris Sequence

The Challenge The shortest code by character count that will output the Morris Number Sequence. The Morris Number Sequence, also known as the Look-and-say sequence is a sequence of numbers that starts as follows: 1, 11, 21, 1211, 111221, 312211, ...

What is the shortest code to cause a stack overflow?

To commemorate the public launch of Stack Overflow, what's the shortest code to cause a stack overflow? Any language welcome. ETA: Just to be clear on this question, seeing as I'm an occasional Scheme user: tail-call "recursion" is really iterat

Golf Code New Year Edition - Full to Romain Chiffre

Write a program that take a single command line argument N and prints out the corresponding Roman Numeral. Eg N = 2009 should print MMIX. Let's say this should work for 0 < N < 3000. (Had fun playing my first ever round of code golf with the Christm

Golf Code: Number to Words

The code golf series seem to be fairly popular. I ran across some code that converts a number to its word representation. Some examples would be (powers of 2 for programming fun): 2 -> Two 1024 -> One Thousand Twenty Four 1048576 -> One Million F

Golf Code: Beehive

The challenge The shortest code by character count that will generate a beehive from user input. A beehive is defined a a grid of hexagons in a size inputted by the user as two positive numbers greater than zero (no need to validate input). The first

Golf Code: Frobenius Number

Write the shortest program that calculates the Frobenius number for a given set of positive numbers. The Frobenius number is the largest number that cannot be written as a sum of positive multiples of the numbers in the set. Example: For the set of t

Golf Code: Play Tetris

The basics: Consider the following tetrominoes and empty playing field: 0123456789 I O Z T L S J [ ] [ ] # ## ## ### # ## # [ ] # ## ## # # ## # [ ] # ## ## [ ] # [ ] [==========] The dimensions of the playing field are fixed. The numbers at the top

Golf Code - Generation of banners

When thanking someone, you don't want to just send them an e-mail saying "Thanks!", you want to have something FLASHY: Input: THANKS!! Output: TTT H H AAA N N K K SSS !!! !!! T H H A A NNN K K S !!! !!! T HHH AAA NNN KK SSS !!! !!! T H H A A N N

Golf Code: Finite state machine!

Finite state machine A deterministic finite state machine is a simple computation model, widely used as an introduction to automata theory in basic CS courses. It is a simple model, equivalent to regular expression, which determines of a certain inpu

CodeGolf: Finding Unique Paths

Here's a pretty simple idea, in this pastebin I've posted some pair of numbers. These represent Nodes of a directed graph. The input to stdin will be of the form, (they'll be numbers, i'll be using an example here) c d q r a b b c d e p q so x y mean

Golf Code: Four is magic

The puzzle A little puzzle I heard while I was in high school went something like this... The questioner would ask me to give him a number; On hearing the number, the questioner would do some sort of transformation on it repeatedly (for example, he m