This Sandbox is being retired in favor of the newer model.

Just to keep the scrolling to a reasonable level. Please feel free to continue to work or vote on question in older sandboxes.

Upvote when you think a question is ready.

This question replaces the earlier Sandbox mk. II and Sandbox mk. I which were getting too crowded.

Please update the faq as well when you make new sandboxes because that's how I got here three links later :) –  mellamokb Oct 29 '11 at 1:33
Thanks @mellamokb. Done. And I'll try to remember in the future. –  dmckee Oct 29 '11 at 1:42
Er.. maybe I'm getting senile, but the link on the faq still seems to point to sandbox I. –  mellamokb Oct 29 '11 at 2:28
Comes here for me. Could something be caching the FAQ for you? –  dmckee Oct 29 '11 at 2:52
Works now... must have been caching (I thought I CTRL+F5'd but I guess that wasn't good enough). Thanks! :) –  mellamokb Oct 29 '11 at 3:23
At what point do we create Mk IV? :-) –  Gaffi Jun 15 '12 at 12:45
@Gaffi: Soon I think. Indeed, feel free to do yourself and I'll close this one. –  dmckee Jun 15 '12 at 13:35
@dmckee I just posted a new item in this one... Is it possible for a mod to move an answer from one question to another? Should I leave mine open in this one? Should I delete this one any copy the contents to the new? –  Gaffi Jun 15 '12 at 14:28
@Gaffi: I'm afraid there is no easy way to move single answers, but closing this question doesn't prevent votes or comment (but does prevent edits). How about close this one when roughly a day has passed since the last activity here? –  dmckee Jun 15 '12 at 14:32
@dmckee That would be great, except I already ran with it and made Mk. IV :-) I'll just move it over... –  Gaffi Jun 15 '12 at 14:33
@dmckee The faq should then also be amended to point to the new sandbox. –  Howard Jun 17 '12 at 10:33
@Howard: Done. Thanks. –  dmckee Jun 17 '12 at 15:06
add comment

15 Answers

TRON Light Cycles Competition

In the spirit of 1P5: Iterated Prisoner's Dilemma, the TRON Light Cycles Competition is a challenge to built the best Light Cycle driver. For those not familiar with the game, the idea is that two players are on a grid and move around the grid with the goal of trapping the other player. Each place that your Light Cycle has already been must not be crossed again by either player (think Snake, with infinitely growing snakes). Play ends when either a player is forced to hit the previous path of a Light Cycle, a player is forced off the edge of the board, or the two players crash into each other (or in this case, it may be caused by a bad programming bug rather than being forced).

The specs of the gameplay are as follows:

  1. The game board is 21x21, consisting of a grid of possible locations where you may travel.
  2. Two players start at the top and bottom at the center, one board space from the outer edge, facing the other (toward the center). In (x,y) coordinate terms (1-based), this would be (11, 2) and (11, 20).
  3. Each player uses information about the current state of the board - which is the list of previous moves each player made (i.e., SSLRR...) - to determine their own next move, which is either stay straight (S), turn left (L), or turn right (R). A turn is performed first then the player moves straight, so that an (R) would mean the player's next location will be to the right of the previous one and also facing to the right of the previous move.
  4. After each player's move has been calculated, the simulator applies both moves. If the move causes either player to be out of the boundaries of the board, or on a location previously traversed, that player immediately loses. If both players fall into the losing category, the game is considered a draw.
  5. Each round consists of a series of 100 simulations between two players. In each simulation round, a win yields 1 point, and a draw yields 0 points. I will maintain a matrix of scores between each combination of contestants, and the winner is the player with the highest total score across all of their rounds after roughly two weeks of competitions (11/11/11), depending on the level of participation.

Your job as a contestant is to write the function that performs a move. Your function should use the following guidance spec:

  1. You will be given two strings via stdin as two lines, each a sequence of S, L, and R representing the moves made by a player. The first line will be your own moves, and the second line your opponent's.
  2. Your return value onto stdout should be your choice of move (as a single character with an optional line return following): S, L, or R. Any input that does not follow this spec will automatically be assumed as an S (move straight).
  3. The simulator will begin the game with a call to both contestants with an initial input of empty strings and both players assumed to be at their initial locations. Each move will be simulated on a board to verify that both players are still in the game, and then appended to the sequence of moves for passing to each contestant program representing the next move.

Suggestions welcome: This is a rough overview, feel free to edit or throw out suggestions. I'm not certain how big the board should be. Also, there may be a better format for the input to each move because SLR information will be difficult to process. You'll probably find yourself needing to generate a virtual board and simulate all the previous moves so you can see what places are taken and where the other player is. On the other hand, this gives you absolutely every piece of information if you want to infer about the other player's strategy. Ideas on input/output spec are welcome too.

The "SLR" format has the advantage that it makes the "Who starts where?" question irrelevant while a NSEW type format would require that data. –  dmckee Oct 29 '11 at 2:57
The scaffold and scorer is going to require careful vetting, but I really like this. –  dmckee Oct 29 '11 at 2:58
^ What he said. Need to ensure that the results are reproducible across computers, because the Prisoners' Dilemma caused a lot of confusion there - we never did work out what was going on. –  Peter Taylor Nov 4 '11 at 12:23
This might also be fun to see under different setups (i.e. different "board" sizes and different starting locations) –  Gaffi Mar 19 '12 at 19:00
yeah the IPD did turn into a mess... which I had no small part in. That said this seems like another really awesome coding challenge. –  arrdem Mar 23 '12 at 18:54
add comment

Binary Tetris

There was recently some buzz on programming websites about an implementation of Tetris in 140 Bytes. ...

It turns out that although it is small, it is a simplified version of Tetris, and not even a complete implementation. Only the core logic function fits in 140 bytes of Javascript. To actually run it, you need another ~840 characters of HTML.

We can do better!
This challenge is to implement a complete version of "Binary Tetris" in as few tweets as possible.

Binary Tetris Rules:

  • The program must display a playing field containing at least 5 columns and 6 rows of cells.
    • Any method of display may be used, as long as the blocks and the edges of the field are clearly marked.
  • There must be at least two types of blocks: # and ##.
  • New blocks are added to the field in the top row, and one block cell must occupy the center column.
  • Blocks descend towards the bottom row at a fixed rate. Blocks must descend even without user input.
  • When blocks touch the bottom of the field or a lower block, they stop falling and are fixed in place. A new block is added.
  • When all the columns in the row are filled with blocks, the row is emptied, and all the fixed blocks above drop down one row.
  • The program must respond to keypresses. There must be 3 unique keys that perform the following functions
    • shift current block left 1 column
    • shift current block right 1 column
    • shift current block down 1 row

Golfing Rules:
Because the original implementation was "tweetable", this challenge requires the same. Entries must be able to be transmitted as a series of tweets (lines of 140 characters or less).

  • The first tweet must contain the name of the compiler/interpreter, the name of the program, and any command line arguments
    • it will be saved as file "P0"
  • The following N tweets must contain the program as a series of lines.
    • Each tweet will be stored in a file with the name T<n>, where n is 1..N
  • Each line will be added to the previous lines and compiled or interpreted. It must produce a valid object file or program.
  • The program does not need to be functional until the last line is added.
  • The program will be run in the following manner (pseudo-bash)

    interp,prog,args = split P0 /\s/ 
    touch $prog
    for file in ./T* do
      cat $prog file > $prog
      $interp $prog $args
      die("FAIL") if $? #detect error

    The interpreter must be a commonly available executable program that does not already implement Tetris.

Fewest Tweets, including P0. Ties broken by largest number of spare characters (140 * num tweets - total character count).

Example Entries

chrome a.htm
<html><div id="output"></div></html>
<script>cool java script here</script>

Score = 3 (334 spare)

cc a.c ;a.out
main(){/*cool prog here*/}

Score = 2 (241 spare)


Score = 1 (134 spare) if it were legal, which it's not


  • Is the scoring reasonable? I like the idea of golfing to a slightly different metric.

  • Is the requirement for each subprogram to compile reasonable? It works well for my Ruby entry, but may be nearly impossible in other languages. But without it, the scoring reduces to pure character count again.

  • Is my pseudo-bash understandable? correct? I may replace it with an equivalent Ruby program

I was also thinking about modifying the scoring to add bonus spare characters for certain enhancements, in order encourage more interesting end results. Something like +2 for every doubling of the board size, +5 for rotate, +3 for each additional block type... Is this a good idea or not? If it is, how do I calibrate the bonuses?

I find the interpretation of the "compilable sup-programs" requirement to be a bit opaque. Is it sufficient that each stage produce an object file? I'm think of c here...a incomplete program will not compile to an executable. Would it be sufficient that no function or global declaration spanned a tweet boundary? –  dmckee Feb 24 '12 at 21:24
"No function spans a boundary" is what I was thinking of for c. I didn't think through the fact that main can't be first or last without causing a compile error. I would like some way to make the tweet boundaries significant. I'm not sure how to specify that in a way that applies to c, perl, and golfscript simultaneously. –  AShelly Feb 24 '12 at 21:31
c-like languages are fine as long a producing a valid object file is acceptable for the purposes of that condition. You only require a valid executable after the last tweet is added. –  dmckee Feb 24 '12 at 21:35
You could allow the poster to specify two different compile commands: one for use on the incomplete code (gcc -c $file -o /dev/null just tests compilablity) and one for use on the complete code (gcc $file -o $exe) actually compiles the code. –  dmckee Feb 24 '12 at 21:39
I think I'll stick to valid program/object file, rather than a 2nd command. –  AShelly Feb 24 '12 at 23:53
To make the boundaries significant, just glue the tweets together with a newline. That forces people to optimise the placement of keywords. (BTW There's no need to worry about GolfScript, since getting interactive input via shelling out to Ruby is such a pain in the neck that no-one will do it). –  Peter Taylor Feb 25 '12 at 9:54
Good point about GS. Maybe the newline is a good compromise. I guess I need to balance adding an interesting twist vs making it so convoluted no one wants to try. Any feedback about the rest? –  AShelly Feb 25 '12 at 21:12
add comment

Underhanded C Contest [Posted]

It looks like the Underhanded C Contest has gone the way of bit-rot. I'd like to do one of those contests here. We could just do the "losing my freakin’ luggage" contest as it was never judged, or do something new. I have an idea for an encryption-related one, or perhaps someone else has an idea.

We'd need a volunteer or two for judging.

I'm unlikely to enter a contest limited to C, but I'd volunteer to judge, and if it gets a bit of momentum I'd chip in some rep for the prize pool. –  Peter Taylor Jan 28 '12 at 10:02
add comment

Play a perfect game of Mu Torere [POSTED]

The explanation is clear enough. I think it's quite different to tic-tac-toe, which can be reduced to three simple heuristics. However, as a challenge it's not very challenging, so I would make it a code golf. –  Peter Taylor May 23 '12 at 8:46
In terms of output formatting, a square grid allows you to show the full connectivity: w-w-w\n|\\|/|\nb-o-w\n|/|\\|\nb-b-b (comment formatting is quite limited...) If you go for that approach, a numbering system which reads across and down would probably be more intuitive. –  Peter Taylor May 23 '12 at 11:59
@PeterTaylor Ok, I have changed the format. –  PhiNotPi May 23 '12 at 21:00
I would suggeswt to remove the constraint 'in the form of a square' - why prohibit an octagon or circle? And I would remove the restriction of using stdout - why not printing on a web page, in a Qt-Widget or something more elaborated? –  user unknown May 26 '12 at 15:06
add comment

The Sleigh Packing problem [Posted]

I would put the Constraints before the Input (and certainly before the Output - I got to that and I was thinking, "But where in the input were the dimensions of the sleigh?"). –  Peter Taylor Dec 22 '11 at 16:27
@PeterTaylor Fair point, I'll change that. –  Gareth Dec 22 '11 at 16:42
add comment

Lowest unique bid auction [Posted]

Should it be possible to identify the bidding history of the program itself? Can it for example always be the first column? –  hammar Jan 31 '12 at 16:28
@hammar Ok, putting the current program's bids in the first column seems fair enough. An alternative might be to give the column number of your program as the first line of input before the bidding history. –  Gareth Jan 31 '12 at 16:40
The order should otherwise be randomised, to make it slightly more difficult to pick on a bot called aaron or Zozo. I think this is a very nice idea - clearly in the same kind of territory as the previous Prisoners' Dilemma, but with quite different interaction. –  Peter Taylor Jan 31 '12 at 23:15
@PeterTaylor Just to clarify - you mean that each column would still represent one bot through every round, but that it wouldn't be possible to know from its position which bot it is? –  Gareth Feb 1 '12 at 8:24
Exactly. (pad)(pad) –  Peter Taylor Feb 1 '12 at 9:44
@PeterTaylor Ok, my first draft of the scoring program doesn't include that, but it will as soon as I've figured out a good way to do it. –  Gareth Feb 1 '12 at 23:59
For testing purposes you could seed with your pid. –  Peter Taylor Feb 2 '12 at 9:11
Posted now, right? –  minitech Feb 8 '12 at 15:01
@minitech Yes, I'll change it now. Might be an idea for you to edit your question afterwards so that it doesn't get hidden from the index page by my edit. –  Gareth Feb 8 '12 at 16:05
add comment

Play Simple 2-Dimensional Minecraft

Recently I found this video of "HansLemurson" showing a computer that was built in minecraft, which runs minecraft. He is playing minecraft on a computer that was built in minecraft that is running on his computer. To be specific, it is a two dimensional version with an 8x8 grid of cells. There is gravity, block placement, and even jumping. It is worth noting that the computer is single purpose. The same person has built programmable computers, but making them single purpose allows the computer to be much smaller.


The minecraft world is an 8x8 grid (one horizontal and one vertical dimension). The grid is comprised of either Xs (representing blocks) or empty spaces. The player is an X that is blinking on and off about once every second.

There are two modes in the game, controlled by a toggle switch. The first mode is movement. This is controlled by a WASD-like button arrangement. If the player chooses to move left/right/down, the computer checks to see if the space immediately in that direction is empty. If so, then the player moves into that space.

If the player chooses to move up, then the computer checks that the block underneath the player is solid. If so, then the player moves upward two units. Notice that this can propel the player into a solid block. If this happens, the player is obscured by the solid block, but can still move to an empty block next to him. When the player is inside on a solid block, the game continues as if the block isn't there, although the block is still there once the player leaves it.

After each move, the player falls down one unit if there is empty space there. This simulates gravity. This is also why moving up moves up two units, so that the gravity makes a net movement of up one unit. Gravity does not cause the player to fall all of the way to the ground, just one unit.

The second mode is block placement. In this mode, the same exact WASD buttons are used. Instead of moving the player, they toggle the state of the block in that direction. If the player presses "left" and there is a block there, then the block is destroyed. If there is not a block there, then a block is placed. Again after this move, the player is again subject to gravity. The blocks are not subject to falling.

Toggling the toggle switch does not count as a move, and does not invoke gravity.

The game board is a torus, so all actions (movement, block creation) can wrap around the board. The board does not scroll with the player. The player moves, and the blocks stay in the same place.

The challenge

You challenge is to write the shortest program that simulates this game. Your program should display and update the map correctly (with Xs as blocks, and with the blinking player). It should accept input from a button that toggles the state and four buttons for movement and actions. This is code golf.

There are imaginary bonus points for adding more features (block types, game size, etc) to your game.


With more complicated challenges I find that it helps to do a reference implementation so that you have a very concrete idea of how much work is involved. Aside from that, I like it. –  dmckee Jun 3 '12 at 20:11
Is the blink rate selected to fit with the ANSI escape sequence? Either way I would explicitly allow that, because it's the obvious way to do it on compatible terminals. –  Peter Taylor Jun 5 '12 at 7:14
The blink rate wasn't selected to be anything specific. I think that I will broaden the restriction. Maybe any blink rate between 3 blinks per second to 1 blink every 2 seconds. –  PhiNotPi Jun 5 '12 at 20:21
add comment

One-way system [Posted]

We have several existing problems that reduce to finding paths in undirected graphs. This may be the first that requires path finding on a directed graph. The lexical requirement for disambiguating redundant solutions is interesting as it boosts the problem to finding all shortest paths unless you can insure the search order is lexical. –  dmckee Jan 9 '12 at 16:28
Are the nodes all assigned single letter names? Are they all alphabetic and upper-case? –  dmckee Jan 9 '12 at 16:29
@dmckee Yes, my intention was for the nodes to all be single upper-case letters. I'm flexible on that if you think it'd make a better problem though. –  Gareth Jan 9 '12 at 16:39
I'm not calling for a change, just clarification. Generally simpler and more restrictive input language allow the players more ways to cheat and optimize. For instance, if the names are restricted to a small category like ASCII characters I might consider implementing the list as an adjacency array in a language like c that does not support native maps. –  dmckee Jan 9 '12 at 16:43
@dmckee Ok, I'll clarify that point in the question. –  Gareth Jan 9 '12 at 16:46
add comment

Pluralize it! [Posted]

Similar to this. Would we need to code in every possible pluralization including odd ones like ox->oxen and sheep->sheep, or just a subset? –  Gareth Feb 8 '12 at 16:53
Good challenge, but you need to think carefully about the official test set. As Gareth notes, English has a lot of pluralization form some of which are highly irregular. You might also want to note explicitly if and data file the function/program uses should be counted. Finally, you specify a function taking one word, ad then specify repeated inputs...does the looping code count or not? –  dmckee Feb 8 '12 at 16:59
@dmckee: My intent was to call the function repeatedly in the testing code - not as part of the entry. And yes, I'll add some sample test sets now. –  minitech Feb 8 '12 at 19:33
@Gareth: As per the recently added test cases, it will be as many as you can (hence the scoring system). –  minitech Feb 8 '12 at 19:39
While the scoring may be objective after the fact (if you publish the word list, we can check the scores), you are in effect asking us to optimise against an unknown function. It's a gambling game, not a code golf. –  Peter Taylor Feb 9 '12 at 18:37
@PeterTaylor: Well, the idea is to accept as many words as possible. I don't want somebody to throw the test cases into some kind of compressed array and reference them. –  minitech Feb 9 '12 at 19:33
add comment

I've Got The Key, I've Got The Secret

A cryptography challenge in 2 parts.

Part 1

Implement a pair of programs in any language (the two programs could be in different languages if you wanted) to encode and decode a string of plaintext.

Input and Output

The encoder must take the plaintext (and an optional key) and return an encoded string. The decoder must take the cyphertext (and an optional key) and return the plaintext exactly as it was given to the encoder.


  • The encoding and decoding code must be entirely implemented in the language - no libraries or cryptography functions may be used.
  • The code (encoder+decoder) cannot be longer than 1024 characters.

Part 2

Implement programs (multiple programs per answer, one answer per entrant) which crack your opponents encryption algorithms.


The cyphertext.


The plaintext that generated the ciphertext.


I will upvote all answers to part 1 which have working encryption and have obviously made an attempt at golfing their answer.

In order to be eligible to win, an entrant will have to have taken part in both parts of the question. Overall score will be (length of shortest program that cracks your code-(length of encoder+length of decoder)). Highest score wins and winning entrant's entries will be accepted on both questions.

The obvious place for this to fall flat on its face is if someone is able to implement AES or something similar within the 1024 character restriction. –  Gareth Jun 13 '12 at 13:06
Probably better if the methods of the part one programs are disclosed in non-obfuscated language, though with the short length restriction this may not be necessary. –  dmckee Jun 13 '12 at 15:23
Forget AES: RSA is easily doable. That aside, you need to define "crack" in part 2. –  Peter Taylor Jun 13 '12 at 15:35
Also, it's not clear whether "optional key" means that it's optional to make the algorithm unkeyed (doesn't make much sense, I admit) or optional to supply it, in which case it uses a default key. –  Peter Taylor Jun 13 '12 at 15:42
@PeterTaylor I just put optional in to leave it up to the implementer whether or not they wanted to have the key input or hard-coded (or use no key). I'd have thought everyone would have the key input into their program, but I didn't want anyone to feel forced into it by the spec. Hmm, if RSA is doable within the character restriction I'll end up with a load of unbreakable codes which would make for a pretty crap part 2. By crack I meant cyphertext goes in, some time later plaintext comes out. Would restricting the character count further help, or is this question beyond help? –  Gareth Jun 13 '12 at 16:05
On that definition of crack, I can brute force for the length of the decoder plus a few bytes to iterate over all keys of the right length and some heuristics to check plausibility of the plaintext. The brute force cracker might even be shorter than the decoder if the decoder wasn't written in GolfScript... I think this question may be beyond help. –  Peter Taylor Jun 13 '12 at 16:28
@PeterTaylor Okay, thanks. I like the 'build your own - knock everyone else's down' aspect of this question though. I'll have to find another area where it could apply. –  Gareth Jun 13 '12 at 16:34
@Gareth I too like the competitive nature of this idea. I'm looking forward to a question with this plan in mind! –  Gaffi Jun 13 '12 at 19:31
add comment

Meta Quine [POSTED]

Ah...maybe "meta-quine". Question: How non-identical is non-identical enough? Certainly different languages would qualify, but what if the two versions differed only in the value of some string constant? –  dmckee Apr 3 '12 at 21:08
@dmckee I like that title. :-) And your question is the crux of the situation... my proposed 10% rule could potentially allow that type on solution, but that defeats the purpose of the challenge. –  Gaffi Apr 3 '12 at 21:11
Modification of challenge suggestion: create a quine cycle of any length > 1. Grading criteria suggestion: mean (not sum to make long cycles plausible) of the lengths of all programs times some factor that encourages the use of multiple languages like 1/(number of languages+1). Multi-language cycles would have a big advantage. –  dmckee Apr 3 '12 at 21:13
@dmckee My first link is already done with 2 languages, and I do see another out there attempting to do more than that. ( Not that that's a bad idea, but I wanted to add something a little more unique by trying to stay within one language. Perhaps 2 languages, but 2 variations on the source per language? But I still feel like even that can be cheated as previously mentioned. –  Gaffi Apr 3 '12 at 21:17
Possible definition of "different": if a simple ASTs (abstract syntax trees) for the two programs would have a different shape then they are "different". This would exclude pairs that differed only in a string constant, but would allow pairs where the "if" and "else" clauses of a conditional were reversed as long as the two branches did something non-trivial and non-identical. Unfortunately this is not something that can be evaluated automatically. –  dmckee Apr 3 '12 at 21:18
@dmckee Now we're getting somewhere... Is there a simple way to check for that without knowing all the language options? Honor system/additional support with judging? –  Gaffi Apr 3 '12 at 21:21
Just edited the last comment, some languages might have tools to make it clear, but few people write tools to print out ASTs (especially for interpreters) so I doubt it can be made completely mechanical. –  dmckee Apr 3 '12 at 21:22
BTW: I think your first link doesn't go where you think it does. Right now it goes to the earliest quine question here. Your second link goes to a answer on the mutual quine question. –  dmckee Apr 3 '12 at 21:45
@dmckee Whoops. Fixed. Well, if others are interested after a few days, I'll put down some hard rules on the non-meta site. Thanks for your input! –  Gaffi Apr 3 '12 at 22:50
I've posted the question, but the system flagged me with this message before I did: "The question you're asking appears subjective and is likely to be closed." heh –  Gaffi Apr 13 '12 at 13:05
add comment

Rock, Paper, Scissors! (I)


The challenge:

Write the best rock, paper, scissors bot you can, in any language. It can be a function, a complete program, anything - though this isn't a code golf challenge.


Score = Number of wins × 2 + Number of ties


A list of all previous tries against the current opponent and a list of all of the current opponent's throws against the running bot, in that order. On STDIN, it could be, for example:

$ ./rpsbot
4    // number of tries
rpsr // my previous tries against this opponent
rrpp // this opponent's previous tries against me

As arguments (JavaScript example):

rpsBot(['r', 'p', 's', 'r'], ['r', 'r', 'p', 'p']);


A return value or STDOUT. r, s, or p.

Hmmm...there is a deleted proposal for Rock-paper-scissors-lizard-Spock. As far as I'm concern this is a perfectly acceptable game, but I don't know how much interest you'll get. –  dmckee Feb 25 '12 at 18:54
I deleted it because Peter Taylor pointed out that the best strategy is to pick your go at random. If you're allowing entries that are just a function in a number of different languages, how are you going to pit those functions against each other? Are you going to add the extra code to create complete programs? –  Gareth Feb 25 '12 at 19:12
@Gareth: Yes, I'll turn them into complete programs. And the best strategy isn't to pick at random - here, we'll see each other's entries. It'll be rather difficult. –  minitech Feb 25 '12 at 19:17
What I said precisely was: > I don't think it's a particularly interesting problem because, unlike the iterated prisoner's dilemma, it's solved. The Nash equilibrium is to pick at random. –  Peter Taylor Feb 25 '12 at 21:00
There is no strategy which beats picking at random, and a tight loop of metagaming to try to identify the sub-optimal opponents and target them isn't really very pointful. I'm not going to vote -1 because I don't want to discourage using the sandbox, but I think this is a bad challenge. –  Peter Taylor Feb 25 '12 at 21:01
How about Rock, Paper, Scissors with the caveat that all behavior must be strictly deterministic? –  slackwear Apr 5 '12 at 13:47
In a contest called Rock Paper Azure, they introduced dynamite which beat everything except the water balloon, which itself lost to everything except dynamite. The catch was that there was a limited supply of dynamite (100 for a first-to-1000-points game). This made play non-trivial. They also made it so that points can accumulate. If there were three ties, then the winner of the next round gets four points, not the usual one point. –  PhiNotPi Apr 22 '12 at 12:41
add comment


Build an asci-art-graph to attach to some source on stdin which provides numerical informations to be presented.

Sample output:

    |   |X X|                        X| 
    |  X|X|X|X   X     X X| |X       X|X| 
 8k-| |X|X|X|X|X|X|   |X|X|X|X|X    |X|X|X X
    |X|X|X|X|X|X|X|X|X|X|X|X|X|X|  X|X|X|X|X
    |X|X|X|X|X|X|X|X|X|X|X|X|X|X| |X|X|X|X|X
    |X|X|X|X|X|X|X|X|X|X|X|X|X|X| |X|X|X|X|X
    9           12           15          18

sample invocation:

tail -f xy.log | ./ | foolang -d "\n" 
  • How you get your input is your problem and doesn't belong to the contest (for example tail -f xy.log).
  • If you need to filter your input: again your job, but ooc. Example: tail -f /var/log/syslog | egrep -o "[0-9]+"
  • The invocation of your program might contain a delimiter specification, so that you can read delimited by newline or whitespace in general and this will not count towards the score. You needn't do it this way, but a flexible program is expected.
  • The graph shall be self-formatting. Each datarow (-point) is one char wide on the x-coordinate, the height should always be close to the maximum. It shall adopt to growing maxima, but not to falling ones. Old values needn't be repainted, since they move out of scope.

Questions in preparation of the challenge:

  • How clearly do I specify the decoration of the axis?
  • Shall I allow non-ascii, but graphical output?
  • Shall the x-coordinate be specified by time or is the incoming data the clock-tick? Allow both (OR) or make it configuralbe?
  • Related: The x-Coordinate could be provided from the input source as well. So that would mean: you get a pair of values, (x,y)
  • The size of the graph shall take most of the available space of the terminal, so if your terminal size is 80x40 50x25 for the data would be fine - not just a stamp as shown in my example. If it can adopt to the current shell size: fine. Else: make it take parameters:

    generator | foolang -d "\n" -x 70 -y 20

Passing the parameters gets no penalty.

This is code golf.

  • Is this an interesting challenge?
  • Is it clearly stated?
  • What else needs to be specified?
  • How shall I improve the challenge?
I'm going to split this up so that it's clearer what an upvote means. Firstly, you should clearly state early in the problem description that the graph updates as it receives new input rather than waiting for EOF before it does anything. –  Peter Taylor Apr 23 '12 at 8:46
With regards to the x-axis, if you allow the input to specify x-values you should make it clear that they will be non-decreasing, but I think it's more sensible to just assume that they arrive at a constant rate so each update is simply adding one column and possibly losing the first one. –  Peter Taylor Apr 23 '12 at 8:50
As to how clear to be on the description of the axes: a bit of flexibility is useful, but you should make it clear what is fixed and what is flexible. E.g. you could say that the x-axis labels must have one character underneath the corresponding column, but can be left-aligned, right-aligned, or centre-aligned. (I would also suggest requiring a + instead of - under the corresponding column to make it clear which column is being labelled, and writing some spec for which columns to label or how many labels to use). –  Peter Taylor Apr 23 '12 at 8:55
add comment

Count Syllables

The goal of this challenge is to write a program that can count the syllables in a word as accurately as possible.


On STDIN, your program will receive a number X followed by X lines, each containing a single word. Simple enough. (Should there be a limit on the size of X?) The words will come from this list.



Your output should be to STDOUT and have X lines. On each line should be the number of syllables counted in that word.



To score you program, it will receive a long secret list of words to test. All programs will receive the same list of words. For each word, the number of syllables that your program got wrong will be added to the score of the program. If it output a 4 or a 2 when the word had 3 syllables, then one point will be added. If it said a 15 instead of a 3, then 12 points will be added to the score. The lower the score, the better.

For example, if for the above input your program output 3 2 2 2 (which would be produced by a program that counts strings of vowels), then the program would receive a score of 2.


Your program should not access any external files (such as the word list). Also, your program should be no more than 5,000 bytes long (is this a reasonable limit?).

The winner will be the person whose program has the lowest score, therefor the most accurate syllable counter. The deadline for submissions is [some time at least a month away].


I am open to all constructive criticism. Is 5,000 bytes a reasonable limit for the program size? How long should the official scoring test be? How long should the deadline be?

This has one major flaw: the output is subjective. How many syllables do these words have? Every; victory; hierarchy; desire; oil; hour; poem. The only real way I see to work around this is for you to produce a marked-up version of the word list. –  Peter Taylor May 29 '12 at 20:40
I was really worried about that, and I don't see a way around it. –  PhiNotPi May 29 '12 at 20:42
I personally would love to see more language processing challenges. I agree with @PeterTaylor on the difficulty of some words. Perhaps taking a specific text(s) and identifying explicitly in the challenge which words will have how many syllables? –  Gaffi Jun 8 '12 at 3:34
add comment

Simulate a Minsky Register Machine (II) [Posted]

PS for those who haven't guessed, part III would be adding a macro syntax, à la Verilog. –  Peter Taylor Nov 2 '11 at 18:57
add comment

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .