# What is the Sandbox?

This "Sandbox" is a place where Code Golf users can get feedback on prospective challenges they wish to post to the main page. This is useful because writing a clear and fully specified challenge on the first try can be difficult. There is a much better chance of your challenge being well received if you post it in the Sandbox first.

See the Sandbox FAQ for more information on how to use the Sandbox.

## Get the Sandbox Viewer to view the sandbox more easily

To add an inline tag to a proposal use shortcut link syntax with a prefix: [tag:king-of-the-hill]

• How are tags added to questions? – guest271314 Jan 9 at 7:51
• @guest271314 You can use this markup to create a tag in a draft: [tag:code-golf] – DJMcMayhem Aug 29 at 15:19
• Why no featured anymore? Can't we have it auto-added or something? – JL2210 Sep 26 at 15:57
• @JL2210 We now have a permanent info box that links to the Sandbox, so the featured tag isn't necessary – caird coinheringaahing Sep 29 at 13:43

Note: This challenge might not work out on this site, please down vote this answer if you feel like it won't work and up vote if you think it could. If you down vote, a comment would be appreciated. I don't see the point in limiting the freedom of the participants since I think it will make things less fun/interesting.

# Your love you want to show 'em, generate them a poem.

Poetry is not easy;
Rhyming is too hard.
Generate me a poem that's not too cheesy.
If it's good enough we'll call it art.


In all honesty, poetry really is tough beans. So for this challenge I ask you to write some code in the language of your choice that will generate poetry.

## Restrictions

Your program has to be able to output a large amount of generated poetry of reasonable quality. This means that you can't write code that tries to 'generate' a poem that already exists. You also can't sample parts of existing poetry (this includes poetry invented by you). It is okay if some (or even most) of your code's poems make no sense and there are only a small percentage of good poems. I'm sure that code that consistently generates good poetry will be more popular though. Other than that there are no restrictions, you can use dictionaries, you can use the internet, you can strive for a certain rhyming scheme or several. It's poetry, get creative.

• Your full code or a link to it.
• An explanation of your strategy.
• Some of your favorite poems generated by your code.

## The winner

This is a , so the answer with the most votes wins.

## But what's a poem?

I see where you're going with this. You could output a list of words and claim it's poetry. I fear the other users won't be too impressed with that though and you won't get many votes (if you can avoid down votes). However, that doesn't mean it absolutely has to rhyme, there are plenty of ways of making poetry interesting and if you can have your code generate non-rhyming poetry that other people like, you deserve those votes. Explaining your strategy will also help people see why what you did is interesting.

• This seems to be a bit too broad. What classifies as "poetry" for this challenge? Poetry doesn't necessarily need to rhyme, or follow any form or rhythm. I could claim for almost any text that it's poetry of some weird abstract form. You might want to place some restrictions on that. Also, if you're disallowing sampling parts of existing poetry, does that mean I can't submit a solution which just fills in blanks in a fixed structure or randomly combines a predetermined set of lines? Where do you draw the line between sampling a dictionary and sampling existing poetry? – Martin Ender Jul 27 '14 at 15:38
• @Martin I would say that taking combinations of words from existing poetry is sampling, filling in a structure wouldn't be. As for it being too broad, I feel like making it less broad would make the challenge less fun. Since the quality of the output is subjective, should we really be putting strict restrictions on what we want as an output? Or is this explicitly against the rules of SE? Maybe the poems should have a minimum length though. – overactor Jul 27 '14 at 15:48
• It's not necessarily against the rules, but there's a close-vote reason for questions being "too broad", and I could see this being closed as it stands. You'll just get people producing completely random chains of words and claiming that they are poetry. – Martin Ender Jul 27 '14 at 15:51
• @Martin Those should get downvoted though. Poetry is hard to define and I don't want to restrict people's creativity by failing to define it. If people like the output of a program, who's to say it's not poetry? – overactor Jul 27 '14 at 15:54
• I get your point, I'm just saying people are still very likely to close your challenge. The question isn't whether there are too many possible answers which would be upvoted but too many possible valid answers. And in fact I even think there might be too many possible answers that could be upvoted. There are just so many different kinds of (more or less weird) poetry. – Martin Ender Jul 27 '14 at 15:58
• Do you think that means the challenge isn't a good challenge or not a good fit for SE? – overactor Jul 27 '14 at 16:03
• It's certainly a very interesting challenge, but as it stands too broad for SE, I think. – Martin Ender Jul 27 '14 at 16:05
• There are many subclasses of poetry already well defined. Often a restricted format leads to more creativity, not less (both in writing poetry and in writing code). – trichoplax Aug 10 '14 at 2:07
• I, for one, find this a perfectly fine challenge. – BobTheAwesome Mar 15 '15 at 22:19

# Program calculating its own length code-golf

Your task is simple: write a program that produces its own length, without using any literals or built-in constants other than 0 (or its equivalents in your language).

## Rules

1. Your code must print its own length in bytes when run, followed by a single newline.
2. Your code cannot use any literals other than 0 (or whatever equivalents your language might have). This includes string and character literals.
3. Your code cannot use any built-in constants of your language, unless these are guaranteed to always have the value 0.
4. Any functions and operators provided by your language can be used.
5. You're not allowed to use any external libraries or external resources in your program.

## Scoring

The score of a valid program is its length in bytes. The score of an invalid program is ∞.
As this is code golf, lowest score wins.

• Does "any literals" include the more involved ones like function, array and object literals? Apart from this restriction, I'm pretty sure this has been asked before. – Martin Ender Aug 3 '14 at 17:54
• @MartinBüttner Probably a dupe: codegolf.stackexchange.com/q/27079/16402 – user16402 Aug 3 '14 at 17:58
• Would this Python entry be valid (not golfed)? It uses only globals. text = open(__file__, 'rb').read(); length = len(text); print(length) – Isiah Meadows Aug 12 '14 at 5:41
• May we use built-in lists that are guaranteed to be []? – Adám Feb 8 at 8:28
• In Jelly (and likely much more esolangs), a empty program outputs 0, producing an answer that is very hard to beat; Try it online! – someone May 24 at 8:44

## Find a multiple of 42 that is spelled with all of the characters that make up the word "forty-two".

Rules:

1. All of the characters in "forty-two" must be included at least once. Dashes count as characters, and each character must be used cumulatively (dog doesn't contain all of the characters that make up the word dogg, for example).
2. The result can be any multiple of 42 that meets the defined criteria, presented in numerical form.
3. Result must be multiple of greater than 1 (or less than -1). In other words, 42 and -42 are not allowed.
4. Additional characters not in the word "forty-two" are O.K.
5. The program must calculate its result without utilizing prior knowledge of a multiple known to include the right letters. Clarification:

• This means that self trivial solutions such as hard-coding the program to print 42,000 are not allowed.
• As an exception to this rule, prior knowledge of the maximum result possibility (42,000, for example) may be used to define the program's ability to name numbers up to the necessary size.

The shortest code (counting in bytes) to do so in any language wins.

• This was down-voted in the original post, so I've improved it and posted here to see if it might be further improved to the point of liking. It seems to me like a nice challenge. – Viziionary Aug 4 '14 at 20:30
• I think that the specification are good now and the challenge would be fun, but this seems to be pretty much a duplicate of Converting integers to English words just with an added loop and comparison. There are some more questions like that here already, which can be found searching for site:codegolf.stackexchange.com english number – tim Aug 4 '14 at 22:45
• @tim perhaps a small creative twist, then? – Viziionary Aug 5 '14 at 1:32

# Dining Philosophers (Incomplete)

Please do not vote or comment yet.

# Introduction

Cooperate with other Philosophers in order to eat your dinner as quickly as possible.

# Game

You will be randomly paired with two other philosophers. Each philosopher begins with one fork. A philosopher needs two forks to eat his dinner. Each round you may take one of six actions:

• Take the fork on your left
• Take the fork on your right
• Place a fork to your left
• Place a fork to your right
• Eat
• Wait

The following behaviors will cause you to wait by default.

• Attempting to take a fork that is not there
• Attempting to place a fork you do not have
• Attempting to eat with less than two forks
• Attempting to take a fork when you are already holding two

Once every philosopher has successfully eaten, the trial is completed. Each participant is scored according to how long it took all three participants to eat.

# Input

Input description here.

For Java submissions, input will be passed via parameter. For non-Java submissions, input will be provided via a command argument.

# Output

Output description here.

# Deliverables

Java Submissions

You must submit a unique title and a Java class that extends the abstract Philosopher class written below.

public abstract class Human {
public abstract String takeAction(String arg);
}


Non-Java Submissions

You must submit a unique title, a program, and a Windows command line string that will run your program. Remember that an argument may be appended to that string. For example:

• python Aristotle.py
• Note that this one has no args. This is round one! Be prepared for this.
• python Aristotle.py args

# Scoring

Your final score will be the median of your scores across ____ trials.

# Tennis Tournament (Incomplete)

Please do not vote or comment yet.

# Introduction

Insert tennis themed introduction here.

# Game

Insert description of the tournament hierarchy, player seeding, and program flow.

# Input

You will be passed the current set of matches. Matches will be comma (,) delimited. Players within a match will be dash (-) delimited. Players will be represented by ID and strength in the format <ID>$<Strength>. Byes will be represented by 0$0.

Java submissions will be supplied input via argument to the takeAction() function. Non-Java submissions will be supplied input via command line argument.

Example

The following input represents a three player tournament. The players' IDs are 2, 1, and 3. Their strengths are 1, 2, and 2, respectively. Player 3 has a bye.

2$1-1$2,0$0-3$2

# Output

Return the string "play" if you want to play. Return the string "concede" if you want to concede.

# Deliverables

Java Submissions

You must submit a unique title and a Java class that extends the abstract Athlete class written below.

public abstract class Athlete {
public abstract String takeAction(String arg);
}


Non-Java Submissions

You must submit a unique title, a program, and a Windows command line string that will run your program. Remember that an argument will be appended to that string. For example:

• python RafaelNadal.py args

# Scoring

Your final score will be the median of your scores across ____ trials.

# Teach me to play clarinet

(might be an optimization problem for )

This is mostly a work in progress until I figure out the best input and output notation/formatting.

The clarinet is a very complicated instrument, as there are more keys than I have fingers. Additionally, there may be multiple ways to play the same note. I dream of becoming a professional clarinetist one day, but I am very lazy at everything I do. When playing music, I try to move my fingers as little as possible.*

The input will be a series of musical notes, which each note consisting of a note name (like E or G#) and a number which represents which octave of the clarinet is being discussed.

Examples:

E1 - low E, the bottom note
C1 - C below the staff
E2 - E at the bottom of the staff
F#3 - F# at the top line of the staff
G4 - G that is 4 ledger lines above the staff, the highest note needed


An example input might be

Eb2 D2 F#3 F3 F#3 G3 F#3


From this list of notes, your program should determine which fingerings I should use to play these notes in the easiest way possible. "Easiest" means that the total number of finger movements should be minimized (how to explain?).

The output should describe my finger position for each note in terms of the location of each of my fingers.

One problem I see is that there is no standardized fingering chart for clarinet. Furthermore, no fingering charts actually specify which fingers are used to play which keys. One thing I would have to do is create a list of all possible positions for each finger. Then, a single fingering "diagram" would consist of the list of keys, telling which are open/closed/either. There would be multiple fingering diagrams for each note.

The next problem is that the number of distinct fingerings can grow to be quite large when certain tricks are taken into account such as "leaving the right hand down while playing throat tones." This would be the reason for adding the "either" option to the fingering charts.

I must figure out how to notate the fingering charts and format the output.

*this is actually a good thing and not lazy

• As for the fingering charts, my clarinet book has a chart labeling each key with a character, A-Q, I think. The holes could be 1-6. Would this be helpful? – Hosch250 Sep 18 '14 at 2:19

# Chess: End Game KOTH

You design a bot that plays the final moves of a chess game against other bots. The chess board will be in the end game stage (relatively few pieces) with either a winning position for white, or a force draw. Points will be scored on the outcome of the game in each board situation. Bots will play both the black and white sides for each position (10 unique positions, 20 games in total).

## Rules

1. Basic chess rules apply

2. No outside help whatsoever (chess engines, endgame tablebases, stored patterns)

3. Notation will be in the ICCF numeric notation format
4. Round-robin tournament setup (see scoring below)
5. 20 games per match (1 match is one bot-to-bot pairing)

• Each bot plays 10 games as white and 10 games as black
• 8 of these games will be force wins for white, the remaining 2 are force draws (but winnable by either player)
• The same 10 games will be repeated, so each bot will play the same position as both colors.
6. Time limit of 1 minute per match? (very flexibly here)

• Maximum time per move is X seconds (possible Fischer Delay bonus?)
• Failure to move in the time limit per move will result in a loss for the current game

## Scoring

These values will surely change

+---------------------+------------+------------+-------------+-------------+
| Board Situation     | White Wins | Black Wins | Black Draws | White Draws |
+---------------------+------------+------------+-------------+-------------+
| Force Win for White | 100        | 500        | 250         | -50         |
| Force Draw          | 250        | 350        | 50          | 50          |
+---------------------+------------+------------+-------------+-------------+

1. Need to figure in number of moves into points
2. Overall winner is the bot with the most points at the end of the round-robin

## How To Play

1. Controller will be written in python and will communicate to bots via STDIN/STDOUT

• Bots can be programmed in any language that support persistent polling of STDIN and STDOUT
2. A board will be generated by the controller and sent to both players at the same time (will include information for castling in a TBD format). Each bot will be given ~50 ms to process the board information, but they don't know what side they are playing.

3. Following the short pause, each of the bots will be sent either B or W character to indicate which side they will play for the next game. At this time, the white bot timer is activated and it can return his move any time afterwards.

4. The bot will response via its STDOUT the move in ICCF numeric notation

5453

1. After the move has been validated by the controller, the time remaining for both opponents and the move history will be sent to the each bot, and then the other bot begins their turn. Time will be outputted in ms in the following format WXXXXX BXXXXX. The following is the output given to each bot after each ply.
W54000 B60000 1) 5453
W54000 B48000 1) 5453 7872
W52000 B48000 1) 5453 7872 2) 6512

1. This will repeat (steps 4&5) until the game is won, drawn, or time runs out, after which the bots will be sent the final score of the game and time remaining for the next game of the match
W35000 B47000 W+300 B+50


## Things that might be a problem

1. The efficiency of the language (i.e., C++ vs perl) might bias towards language used instead of algorithm developed
2. Generating board situations (could grab them through an online DB automatically)
3. Too hard/easy to program?
• Do you want to accept or exclude the approach of exhaustively evaluating all future moves? I guess this will affect how long you give per move, and per match (as future moves calculated in the previous turn can be stored and added to on each new turn). For example, if you're near enough to the end of the game that it takes 30 seconds to evaluate all possibilities, then a few moves in a bot could have full knowledge, as some futures will be trimmed by the moves taken so far. – trichoplax Aug 11 '14 at 21:45
• This won't apply if you choose end games that still have a lot of options open - I don't know if you mean 2 pieces left each or several. – trichoplax Aug 11 '14 at 21:48

# Tetromino Game king-of-the-hill

### (name suggestions?)

This game is based off of L game, an abstract puzzle game by Edward de Bono.

## Rules

Every player is assigned a random position in the list of players. Every round, each player gets a turn, in the order defined by the list of players. The game is over once only 1 player remains.

The board is a 2-dimensional grid containing the tetrominoes, as well as 1x1 neutral pieces. It does not wrap. It is generated randomly and all of the pieces are placed on it, with a good amount of neutral pieces (should equal roughly half the amount of empty blocks, and just over 2/3 the total amount of players).

On each turn, the player must move their piece to another position on the board, and optionally a single neutral piece. This can be anywhere, however, no pieces can intersect.

The player loses if they cannot move their tetromino anywhere; they are no longer given any turns, but their tetromino stays.

After 20 rounds, on every round, a neutral piece will be placed randomly on the board.

A player's score is equal to the amount of turns that they have played.

## Submissions

Communication with the controller is done through STDIN and STDOUT. Your submission will run for the entire length of the game. If your program is expected to produce output and doesn't within 4 seconds, you will lose.

At the start of the game, your submission will be launched and you are expected to produce a tetromino to play with. You should output a number from 0 to 4, corresponding to these tetrominoes:

(modified version of this)

They are in order of strategical complexity; 4 is the most complex.

Then, the initial game data will be passed to your game.

The first line contains 3 space-separated integers: your position in the list (starting with 0), board width, and board height.

The rest is a rendering of the board: A player's tetromino is made of the last digit of the base-93 number (ascii 33 to 125) of their position in the list. A space is an empty space, and ~ is a neutral piece.

On every turn except your own, your bot will receive information about the turn. The first line can be one of either M 0 0 0 or L; the first is for motion (see next paragraph), and L is for that player being unable to make any moves and losing.

The motion line is in the format M x y r f, where x and y is the new position of the upper-left block in the bounding box of that player's tetromino, and r is the amount of rotation (0 for 0 degrees, 1 for 90, 2 for 180, 3 for 270, clockwise).

f is either 0 or 1; 1 if the player flipped their piece along the x axis (this happens before rotation). Optionally x y x y could also be on the end of the line, the first pair of coords being that of a neutral piece, and the next being its target location. It is followed by the new board.

On your turn, GO will be given to you on STDIN and you will be expected to produce a string x y r f and optionally x y x y, similar to the one in the paragraphs just above this. The controller will evaluate whether or not there are possible moves for you just before your turn, and will eliminate you automatically if necessary.

If your output is invalid, you will receive ERROR on STDIN and you will be expected to produce a new output. If this happens 5 times in a row, you lose.

Submissions are allowed to store data in files, and initial data for the file can be included with the submission.

## Scoring

Each player's score is equal to the amount of turns they play; however the submission's final score is the sum of all their scores in multiple trials. Trials will be run until the leading submission is 5 points away from the runner-up.

## Name?

Ideas: "Tetromeano" (suggested as a joke on chat), "Space Tetris".

Discuss the game here.

This is a rough idea for a challenge, if possible I would like someone else to help me with it and possibly host the challenge (and consequently getting all of the up votes :] ).

# Pecking Birds - input wanted

You're a bird and birds need to eat. There's not all that much food, so you might need to fight for it.

## Haven't you heard about the bird?

Birds live on a continuous torus where food drops at random places at an increasingly slow rate. They can only see food from a certain distance, they can see all other birds on the torus though. Birds can only move over a limited distance at a time and can peck at either birds, food or nothing within a certain radius. Birds can see a bird's last action, but they can't distinguish between pecks at food and pecks at nothing if they're too far away. Birds that are pecked to death, turn into food. Food disappears after a fixed amount of birds have taken a peck at it. Birds' health goes down every turn, but get refilled a bit if they peck at food.

# Input and Output

If I end up hosting this challenge myself, the controller will be in Java and submissions will be either a java class or a program in another language. Both types of answers will be allowed to persist between turns. Java submissions will have the state of the game copied into global variables and be called to act through a method and send their output as a return value. There will also likely be helper functions available for java submissions. Other submissions will get their info through STDIN and asked to send their output to STDOUT. There will be two actions every turn, a pecking action and a moving action. before being asked what to do, you will get the position of each bird, their last pecking action and the position and plentitude of all food withing your sight. On your pecking turn you will be asked to either peck at food, peck at a bird, peck at nothing or not peck at all. On the movement turn you will asked to return a position within your movement radius to move to. All birds peck at the same time and then move at the same time alternately. the winner is the last bird standing.

## The competition

Each player will start with 10(?) birds on a sqrt(n)*50(?) sized torus, where n is the amount of entries. Your score will be determined by the amount of rounds your last bird died before the last bird standing. Obviously a lower score is better. The simulation will be run several times and some sort of average will be taken to determine the overall winner.

## Jenga code

I think everyone knows what Jenga is.

As per Wikipedia:

Jenga is a game of physical and mental skill [...] During the game, players take turns removing one block at a time from a tower constructed of 54 blocks. Each block removed is then balanced on top of the tower, creating a progressively taller but less stable structure.

Challenge

Write a program that behaves as a Jenga tower. Every time a randomly chosen piece of code is removed and placed at the bottom of your program, the code should re-run. Goal is to achieve the tallest running code tower.

Rules

• The starting tower (or source code) must be of exactly 15 lines of code. Such lines must be divisible by 3 forming a 15x3n grid composed by 15 lines of 1xn bricks.
• A brick is removed randomly from the code and placed at the bottom from left to right until the 3n block line is complete. The process goes on at the bottom of the new formed line.
• If a brick has strictly more consecutive whitespaces than any consecutive characters in it its considered broken and fails to sustain the tower.
• A brick must always be present for each row (2 holes and 1 brick), but its position in the row is not important.
• A tower is tall 20 lines if the 20th line tower runs with no errors.
• A brick cannot start nor end with comment start or end tags of your chosen language (e.g /* or //)

Output

Each tower must output its own height.

Scoring system

Your score is simply the avarage tower height for your program:

SCORE = (MAX TOWER + MIN TOWER) / 2


Where MIN TOWER refers to the minimun non-running tower while MAX TOWER refers to the maximum running tower.

(It would be nice if in the answer both towers are shown)

Proposed tag:

• I think the basic idea is good, but it lacks some definition; you should probably specify that a line has to be more than just a comment and does something related to the rest of the program. What prevents me from declaring a new variable on every line and then printing a hardcoded string on one line? I'm not sure if thsi idea could work, but it certainly doesn't work like this. – overactor Aug 18 '14 at 12:25
• Maybe the randomly picked rule is also not beneficial. I believe that if people can specify the order in which the lines are picked, they can get more creative. – overactor Aug 18 '14 at 12:26
• Can't understand your point on the comment line. If the middle brick is taken from that line and placed at the bottom, the code shoulnd't work, right? Or you mean that every single brick has/is a comment? – Narmer Aug 18 '14 at 12:28
• For the line picking I can add the rule to choose a integer sequence of choice and use the sequence to choose the line (starting again from top when end is reached while counting). – Narmer Aug 18 '14 at 12:35
• @Narmer What overactor is referring to is that any brick could be /* my comment */ which could be removed and moved anywhere without breaking the program. But there are other ways. It is trivial to get the maximum score of 50 in many languages by writing 44 bricks of the form someVariableName = 0; and one brick of the form print "I win!". (That was overactor's other point in his first comment.) I agree that the idea is interesting but it needs some work. – Martin Ender Aug 18 '14 at 12:38
• @MartinBüttner I see your point now. First is easily avoidable removing comments, but the second one is tough. I'll think for a solution. – Narmer Aug 18 '14 at 12:41
• The only thing I can think of is using the output. Something like "every compiled tower must output its height". – Narmer Aug 18 '14 at 12:45
• In no particular order, I see the following problems. 1. Is "compiled" intended to exclude interpreted languages (in as much as that distinction makes sense nowadays)? 2. The stuff about holes makes no sense to me. In particular, a) there's nothing stopping a brick from containing a hole; b) the number 4 appears from nowhere and doesn't fit with n-char bricks. 3. What are MIN TOWER and MAX TOWER in the scoring? 4. I can easily write code which does absolutely nothing but compiles. E.g. make each brick for(;;)break;. – Peter Taylor Aug 18 '14 at 12:55
• Edited to match the comments. Ugh, just seen @PeterTaylor comment. – Narmer Aug 18 '14 at 12:55
• Making each tower output its height is easy: just make each brick end in a // / # as appropriate to comment out the remaining bricks on the line. E.g. in GolfScript making each brick 0or)# would achieve that. – Peter Taylor Aug 18 '14 at 12:56
• @PeterTaylor for your last comment, see my edit. Min tower refers to the minimum non compiling tower, while max tower is for the maximum compiling tower. I'll clear that out. – Narmer Aug 18 '14 at 12:57
• For the hole part I was trying to avoid trivial solution where a brick is composed by only < 4 chars (and the line by more than 12), making the tower almost "brickless". I'm still trying to figure out how to make that clear, maybe I should change it in a more clear "if a brick has more whitespaces than characters in it its considered broken and fails to sustain the tower" – Narmer Aug 18 '14 at 13:05
• And last but not least for compiling I mean "working with no errors, regardless they are compile or runtime". Don't know why I used such a silly word. – Narmer Aug 18 '14 at 13:18
• Pretty much any language which can do a cheat quine by reading its own source can do that and print the newline count in one block, and then do nothing useful in all the other blocks, achieving a perfect score. (I can also see how to get a perfect score in GolfScript by counting newlines without reading the source, but that's actually an interesting answer. OTOH it does mean that the question would be pretty much killed once someone posts it). – Peter Taylor Aug 19 '14 at 9:21
• I think that's unavoidable. A single block has to have the possibilty to live on its own, otherwise a single brick line in not possible. I think I have to exploit again the output to alter the program code. Maybe instead of simply the height the program should output an ascii representation of the tower, with XXX for brick and void for hole. Let me know what you think. – Narmer Aug 19 '14 at 10:16

# Analyze Tonguetwisters code-golfnatural-languagestring

Your task is to write a program which will accept an English tonguetwister, search for commonly used sounds and decide why it is difficult to pronounce.

1. Calculate the frequency of every sound used in the input sentence.
2. Count identical sounds (for example, ea and ee) as the same thing.
3. Ignore those sound groups (see below) which occur less than 0.1 times per character of the input.
4. From the sounds that remain, group members of the same group together and separate by a forward slash (/).
5. Arrange the groups by decreasing number of occurences.
6. Separate groups by commas.
7. Output.

## Identical Sounds [under construction]

ee = ea (in step 2, replace ea by ee)


## Sound Groups [under construction]

e,ee
s,sh,c,ch
f,th,ph


## Examples

Input: She sells sea-shells on the sea-shore.

Output: s/sh,e/ee

Input: The seething sea ceaseth and thus the seething sea sufficeth us.

Output: s/c,e/ee

## Rules

• Receive input on STDIN, as command-line arguments or otherwise. You may not expect it to be stored in a variable.
• Output to STDOUT or equivalent.
• Standard loopholes are banned.
• Are you going to provide a data file which maps words to the pronunciations in a standardised format? – Peter Taylor Aug 21 '14 at 13:37
• @PeterTaylor It wasn't in my original plan (which was just to assume that c,sh,s, and ch are always similar, which is not the case as c can be pronounced s or k), but if there is such a file somewhere I can alter the challenge for it to be used – user16402 Aug 21 '14 at 14:08
• – Peter Taylor Aug 21 '14 at 14:13

# Gun Fight at High Noon

## Gameplay

This will be a 5 or 4 stage (the decision will be explained later) tournament where programs are pitched against each other to solve an integration problem faster than the other. The fastest will then go on to the next round.

Number of rounds: Due to tournament bracketing, the number of rounds will be decided by the reception of the challenge. For four rounds, sixteen entrants are needed. For five rounds, thirty two entrants are needed.

## The controller

The controller will be written in Python, using time.time() as the timer. When run, it will time one entrant, print the output and time the other entrant and print the output. I will then put the results into a text file and post the results on the question.

## The problem

The problem will be a simple elementary function integration problem with long numbers included. These will be generated randomly when the controller is initiated and both entrants will be given the same problem.

## Rules

1. No inbuilt functions can be used to solve the problems
2. If you fail to calculate the problem correctly, you will lose immediately
3. In event of a tie, the match will be replayed with a different problem

Inbuilt Functions

Inbuilt functions include functions that solve integration problems themselves you must have a hand written integral solving algorithm in your code.

## Example and Arguments

All information will be transferred via stdout and stdin. The integral will be in the following format:

And f(x) being like where a and n will be replaced for integers when passed to your program:

With arguments being passed like so:

programname a b f(x)


The reply will be stdout as a floating point integer to a precision of 5 decimal points. An example from one of my tests:

~python3 showdowncontroller.py Test1 'python3 int1.py' Test2 'python3 int2.py' A,B: 3,36 Function: 10*x**3 Result: 4199187.88575 Test1: 0.04052305221557617 True 4199187.88575 <- name time correct? output Test2: 0.04041910171508789 True 4199187.88575 Win: Test2  The command run for each program was: python3 [program name].py 3 36 10*x**36  And the response was: 4199187.88575  ## Other In your answer you will need the following: • Name of your program • Command to compile your program (if necessary) • Command to run your program • Your code • A short description of your integration method Your program can be in any language as long as I can compile and run it on Ubuntu 12.04 Precise. There will be a 0.00005 error tolerance: any more or any less and your program will lose the match. The controller uses Simpson's Rule. # Generate numbers a=random.randint(1, 50) n=random.randint(1, 10) b=random.randint(1, 50) c=random.randint(1, 50) # Integration using the Simpson method def integrate(f, a, b): h = (b-a)/100 meth = lambda f,x,h: (f(x) + f(x+h))/2.0 ival = Decimal(h * sum(meth(f, a+i*h, h) for i in range(100))) return ival # Call function func = lambda x: eval(str(a)+'*x**'+str(n)) result = round(integrate(func, c, b), 5)  Test programs will be posted with their running times so people can tell how fast my computer is. I will post no hardware specifications (processor type, speed) though - that will remain a mystery. ## Controller code # Gun Fight at High Noon import subprocess, random, time, sys from decimal import Decimal # Get program names prog1 = sys.argv[1] prog1command = sys.argv[2] prog2 = sys.argv[3] prog2command = sys.argv[4] # Generate numbers a=random.randint(1, 50) n=random.randint(1, 10) b=random.randint(1, 50) c=random.randint(1, 50) # Integration using the Simpson method def integrate(f, a, b): h = (b-a)/100 meth = lambda f,x,h: (f(x) + f(x+h))/2.0 ival = Decimal(h * sum(meth(f, a+i*h, h) for i in range(100))) return ival # Call function func = lambda x: eval(str(a)+'*x**'+str(n)) result = round(integrate(func, c, b), 5) function=str(a)+'*x**'+str(n) print('A,B: '+str(c)+','+str(b)) print('Function: '+function) print('Result: '+str(result)) # Run program and evaluate output def runprog(command, result, f, a, b): start = time.time() answer = subprocess.Popen(command+' '+str(a)+' '+str(b)+' '+f, stdout=subprocess.PIPE, shell=True).communicate()[0].decode('utf-8') end = time.time() elapsed = end-start if Decimal(answer) > result-Decimal(0.00005) and Decimal(answer) < result+Decimal(0.00005): correct = True else: correct = False return elapsed, correct, answer p1time, p1correct, p1answer = runprog(prog1command, result, function, c, b) p2time, p2correct, p2answer = runprog(prog2command, result, function, c, b) print('\n'+prog1+': '+str(p1time)+' '+str(p1correct)+' '+p1answer) print(prog2+': '+str(p2time)+' '+str(p2correct)+' '+p2answer) if p1correct: if p2correct: if p1time < p2time: print('\nWin: '+prog1) elif p1time == p2time: print('\nTie') else: print('\nWin: '+prog2) else: print('\nWin: '+prog1) else: if p2correct: print('\nWin: '+prog2) else: print('\nTie')  • To be properly specified you need to define a) the class of functions which should be integrated; b) the I/O format; c) the error tolerance (and the method of computing the reference value against which you'll check). As a separate issue, what do you mean by "credentials" in the last sentence? – Peter Taylor Aug 22 '14 at 10:27 • @PeterTaylor My answer has been edited to incorporate all of your suggestions – Beta Decay Aug 22 '14 at 14:48 • I don't see point a) addressed anywhere, and the part of point b) which relates to how the formula is serialised is also unaddressed. And on the basis of the example, no-one should waste their time answering. The spec allows "a 0.005 error tolerance" but the error in the controller's calculation is apparently 350.38575. I think the standard English term for processor type, speed, etc. would be "hardware specifications". "Credentials" in the context of computing generally means either username+password or a cryptographic token serving a similar purpose. – Peter Taylor Aug 22 '14 at 15:10 • @PeterTaylor What do you mean by class of functions then? – Beta Decay Aug 22 '14 at 15:16 • Are answers supposed to integrate polynomials, rational polynomials, hypergeometrics, the closure under field operations of elementary functions, ...? – Peter Taylor Aug 22 '14 at 15:51 • @PeterTaylor Elementary functions – Beta Decay Aug 22 '14 at 15:57 • How is this significantly different than if it was simply a [fastest-code] problem instead of having a tournament set up? You could just give a large set of test cases, and the fastest code would still win, right? – Geobits Aug 22 '14 at 17:56 Rubik's Cube Simulator I had posted a rubik's cube question a few days back which turned out to be quite close to an existing one although I made a few amendments. This is a different question altogether. The idea is to simulate operation of a rubik's cube. INPUT: Take a preset sticker configuration for each face as input Your program must interpret the configuration and suggest a list of moves to generate the said configuration from a perfect Rubik's cube. Your program must also check if the sticker combination is an invalid one, and print an error message saying that it is not possible to generate such a configuration. Question should probably be used as a popularity contest given the length and complexity of code, but based on response, a code golf follow-up is on the cards. Suggestions are most welcome. • I don't know a whole lot about Rubik's cube, but going from state Finish to In-between any different than In-between to Finish? – Nathan Merrill Aug 25 '14 at 12:42 • I don't think using [popularity-contest] is a good idea if there are better alternatives. That should be reserved for cases, when it's hard to make the validation criteria objective. In your case [code-golf] seems fine. Alternatively, you could think about a [code-challenge] for returning the smallest number of moves. – Martin Ender Aug 25 '14 at 12:43 • Okay, will do. Code-challenge seems more accurate. – CrazyMod Aug 25 '14 at 12:45 • ...awaiting response... – CrazyMod Aug 26 '14 at 14:18 # American Roulette Roulette is one of the simplest casino games to understand, so I invite you all to see who gets the most money. ## Coding You will be supplied with a singe argument via the command line. This argument will be the amount of money you have. [command to run your code] [arg1]  Your output must be in the following format: [bet]|[amount of money you bet]  The following is a list of valid bets: http://www.predictem.com/images/roulette.gif Name | Example -----------------------+----------------------- Any number of numbers | 12|100 or 36,19,18|100 00 | 00|1000 0 | 0|126 1st 12 (see image) | 1st12|100 2nd 12 (see image) | 2nd12|439 3rd 12 (see image) | 3rd12|679 1 to 18 | 1-18|8 19-36 | 19-36|10000 Red numbers | red|1722 Black numbers | black|1384 Odd numbers | odd|100 Even numbers | even|21900  Payout will be calculated using the following equation where n is the number of squares your bet will win on: http://upload.wikimedia.org/math/6/6/9/66946b321361a701f6b6903d5eae4b44.png In your answer, I need the name of your program, your code and a command to run it. ## Winning When enough people enter, I will run the controller twice a week. After four weeks, I will announce the winner (the person with the most money). ### I realise that is may be ambiguous and/or poorly worded so any feedback on how to pad this question out would be helpful. • 1. This is not a king-of-the-hill challenge, due to the lack of interaction. This is basically just a code-challenge. 2. "n is the number of squares" should probable be "...the number of squares your bet will win on". 3. In roulette, can you actually bet on "any number of numbers"? I thought only the groups indicated on the mat are possible. 4. You might want to specify "American Roulette" because of the 00. 5. 5. How much money do we start with? 6. I guess you won't be just doing a single test for each bot, so how many trials will there be and how is the overall score determined? – Martin Ender Sep 1 '14 at 15:55 • How can the bots interact? It looks to random and too "player versus environment"-y. – Vi. Sep 1 '14 at 15:55 • Casino? The best strategy is not to play at all... – Vi. Sep 1 '14 at 15:57 • @MartinBüttner I know that any number of numbers violates the conventional rules, but I'll keep it just so I don't need to code the layout of a roulette table. – Beta Decay Sep 1 '14 at 16:07 • @Vi. Depends on the game, but in the case of Roulette you can't win in the long run. So I guess a reasonable winning criterion would be "most rounds until bankrupt". Still, I'm not sure Roulette provides enough strategical depth to be interesting. – Martin Ender Sep 1 '14 at 16:10 • @MartinBüttner, but this isn't normal roulette. If you bet 0,00,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36|all-your-money you make a guaranteed profit of (38/36 - 1)*all-your-money. – Peter Taylor Sep 1 '14 at 17:13 • @PeterTaylor lol, good point, although I don't see how that provides "enough strategical depth to be interesting" :P – Martin Ender Sep 1 '14 at 17:16 • @PeterTaylor You would make a guaranteed loss with that. yourmoney -= bet; yourmoney += (38/36)-1 – Beta Decay Sep 1 '14 at 17:20 • @BetaDecay wait what, your payout is not multiplied by your bet? o.O – Martin Ender Sep 1 '14 at 18:11 • @MartinBüttner Oh yeah... I should add that... – Beta Decay Sep 1 '14 at 18:28 # Print the Constitutional Amendment Given a number from 1 to 27, print the appropriate amendment to the US Constitution, using this text. Your score is the byte count of your source code, divided by the byte count of the best answer to this question in the same language. Therefore, you must use a language which had an answer to that question before September 1, 2014. ## Question Is this too similar to existing Kolmogorov-complexity challenges? • Hm, I think there's little regularity to the output which could be exploited, so this seems to boil down to just using any plain compression. – Martin Ender Sep 5 '14 at 8:19 ## Capture the flag ## Basic rules There is a rectangular map of cells, each bot has current cell. Bots compete 1 vs 1 at a time, let's call them red and blue. There are N instances of red bot and N instances of the blue bot on the map. Additionally, there is unmovable red base and blue base, both having initially the red flag and blue flag respectively. Bot instances can move around, supress enemy bot instances, capture the enemy's flag. The goal is to bring enemy's flag to the base (which should have the flag). The flag can be returned back to the base. Bots can pass the flag around. ## Selectable rules (to be decided) ### Map style • 2D, 3D or 2.5D; • Wrapped-around or not; • With walls (destructible, indestructible, buildable by bots) or without; • Bases positions and bots initial positions: random, selectable by player, hardcoded in a map? • Random-generated, pre-programmed, partially selectable by the player? ### Bot capabilities • Moving diagonally? Dodging? • Seeing the entire map or only surroundings? ### Intra-team bot communication • Uninhibited • Only using messages that takes a move to create or read and that travel not too fast; • Inhibited (only indirect by observing positions); ### Prior knowledge • Should bots know the walls of the map from the beginning? • Should bots know the bases posisions from the beginning? • Should bots know enemy bots positions from the beginning? • If communication between bots is not free, should bots know initial frindly bots position from the beginning? ### Attacking • Only nearby bots or also "shooting"? • Multiple weapons or not? • Dodge/protect move? • One-hit or health points? ### Abandoned flag • Is reset to the appropriate base after timeout; • Is reset to the appropriate base instantly; • Needs to be carried by the bot manually; ### Scoring • Reset the game after each flag score or continue the game for N moves or N scores? • What to do in case of stalemate? ## Questions 1. Is this challenge a good idea? 2. Which set of proposed rule variants to choose? My current choice is: • Rectangular 2D map without wraparound, with big walls pre-programmed, random single wall-lets placed randomly; • Bases positions are pre-defined and known in advance to all bots; • Bots having 10 health points, carrying chainsaw (5 damage, 1 distance) and a gun (2 damage, 10 distance); • Bots can stay&defend (half of received damage), move 1 cell to 8 directions, attack (without moving); build up to 8 pieces of wall in neighbouring cell, destroy 1 piece of neighbouring wall, capture the flag, score the goal, send a message. • Bots can cee a 11x11 rectangle, centered around them, including through walls; • Bots are stateful, but can't communicate with other instances directly. They can observe movements of other bots in the vision field or receive messages (if any). The message is a 4 bytes of data (i.e. a number from 0 to 2^32-1) + 1 byte of signal strength, it travels 5 cells per move, decreasing signal strength by one. Message gets received (including the current "signal strength" parameter) by all bots (including enemy ones). Bots reads the message (if any) before making a move. If there are multiple messages, only one with larger signal strength gets received. Hovewer if signal strengths differ only by 1, contect gets XORed. • Player choses initial positions (relative to own base) of all his bots; • All bots know the initial walls in the map; • While the bots stays close to own base, it's health gets recovered by 1 point per move, up to 10, if the flag is present. • Each round gets until one of the team scores 5 goals. This team wins (5-x) points, where x is number of opposin team's goals. • Abandoned flag can be picked up by either team. All bots know relative position of the own flag at any moment. # A game of chance Hello! Thought I would try out the sandbox, a rather useful tool that I haven't utilized yet! This is a game I thought up with some colleagues, basic in theory but has some deeper algorithms to win. I'm thinking of tagging this as code-challenge, any opinions welcome, especially a better name. # How to Play Every turn, you get one number, pseudo-randomly generated, you need to put this number in a list. The list must always be in numerical order, from lowest to highest, and cannot be changed after the turn has ended. If you can no longer put the number anywhere, where it will still be in numerical order, you lose. The list is 100 entries, which start as empty slots (seen as "-" or unique characters for your language) and slowly becomes a list of numbers (example that just lost). # Rules • You cannot edit the position of a value in the list. • The value will be inputted every turn. • The random numbers are X-Y. Both X and Y will always be positive and from 0 to 65535. • I'm willing to input the number in most ways • Any language that I can run! I have both Windows 7 and Linux Mint + VMs for other versions. # Scoring You get 1 point for every round you last. There are 10 (TBD) rounds for each score, resulting in a maximum score of 1000 (which is very unlikely to ever get). • Assuming your PRNG is uniform, how could there be a better strategy than just mapping 1 to 100 to the range the PRNG can produce and then rounding to the nearest empty cell? Or is the range of the PRNG unknown and different for each game? – Martin Ender Sep 4 '14 at 16:47 • Assuming the PRNG has an even chance to spit out any number in the range, the challenge can be solved optimally, so scoring by rounds lasted is not a good idea. – Rainbolt Sep 4 '14 at 16:48 • Assume you get the answer 99, would it be best to put it in the 99th slot or the 98th slot? If you put it in the 99th slot, and you get 100 twice - you lose. However if you put it in the 98th, you don't. It's not to get all 100 slots filled, it's to get as far as possible. It's a better game with the random numbers out of 1000, which I have just changed. – Alexander Craggs Sep 4 '14 at 16:51 • @PopeyGilbert I don't think it makes sense on average to leave that extra room for a second 100, because you might as well get more numbers below 99 than you have space there. I do believe this becomes a lot more interesting, if we're talking about an unknown PRNG range though. You'd need the first few moves to decide how much you'll spread out the numbers. – Martin Ender Sep 4 '14 at 16:54 • @MartinBüttner That's actually a very good idea. Do people suggest that I do that? – Alexander Craggs Sep 4 '14 at 16:55 • @PopeyGilbert At the same time, in order not to make it too complicated, a good compromise might be to choose the endpoints of the range randomly from some small finite known set. – Martin Ender Sep 4 '14 at 17:04 • @PopeyGilbert I should have said "An optimal guess exists" instead of "An optimal solution exists". This is basically just building a tree and then taking the path that gives you the best odds. Making the endpoints variable just means you have to guess at that too. It might be so hard to guess that you can't make an optimal guess in a reasonable amount of time, so you may want to add a time restriction. When you add a time restriction, things get hairy and people want to know what machine they'll be running on. – Rainbolt Sep 4 '14 at 17:13 • @MartinBüttner I'm taking your suggestion, and I'll make the points random! RainBolt, you have some very good points, I think I do understand what your saying =) I'm already understanding how amazingly useful "The Sandbox" is. – Alexander Craggs Sep 4 '14 at 17:16 • If the deeper problems can be fixed, there are some minor changes which I think would make it easier to understand. I would talk about an array rather than a list, because I think it has stronger connotations of being a fixed size. I would clarify whether the - in X-Y is a subtraction or giving bounds of a range. And I would ask the program to give output of the array index every time it receives an input, so that your control program can validate its moves. – Peter Taylor Sep 5 '14 at 22:47 • You refer to both numerical order and alphabetical order. Are these meant to both say numerical order, or is there an extra challenge that I have missed? – trichoplax Sep 5 '14 at 23:04 • @PeterTaylor Thanks for the advice! I'll fix them tomorrow. Also, GithubPhagocyte, they're both meant to be numerical order =) Will correct too :D – Alexander Craggs Sep 6 '14 at 21:16 ## Finding repeated words in a passage This challenge is inspired by a question on the Software Recommendations website. Write a program that outputs the repeated words in a passage on a paragraph by paragraph basis. The program should take three text files as input: • passage: contains the paragraphs to be analyzed • blacklist: contains a list of additional pairs that should be considered as repetitions, such as: eat, ate; begin, began, begun • whitelist: contains a list of exceptions that should not be flagged, such as the, a, an, to, for Specifications: • In each paragraph, find the repeated words that are not in the whitelist. The keywords in the whitelist file may be separated with commas or line breaks. You are free to choose the one that best suits your needs. • The repetitions should be allowed to differ in case, prefixes, suffixes, declension or in grammatical number. For example: allow and Allowed, friend and friends, eat and eaten should count as pairs of repetition • Each pair specified in the blacklist should also be considered as a repetition. You are also free to choose how the words in the blacklist are separated. Ideally, these would be copied from a table of irregularites found by a simple online search • It should support alternate spellings of German umlauts and the "double s" character in the list files. For example: Fränze and Fraenze, Jörg and Joerg, Müller and Mueller, Gauß and Gauss. The list need only contain one of these words, but both spellings should be searched • The output should write the paragraph number, then list the repeated words and their count. For example:  2: eat*3 + however*5 4: moreover*4 + despite*2 5: began/begun*3 or any representation that is just as readable Rules: • This is a code golf challenge; lowest byte count wins • The input file names are excluded from the byte count • How are we supposed to deal with the grammatical variation? We can't possibly implement every single declension/conjugation of all words. Could you provide a list of words/forms which are to be treated as identical? – Martin Ender Sep 13 '14 at 9:03 • @MartinBüttner Good idea! I should add a blacklist file – Tymric Sep 13 '14 at 13:43 • Few people write both the "umlauted" and "non-umlauted" spellings in the same piece of text. One writes, say, "Mueller" because one's environment does not support umlauts. – Soham Chowdhury Sep 23 '14 at 10:23 • @SohamChowdhury True, but I am assuming that the person who writes the lists is not necessarily the same as the person writing the texts (student/teacher for example). Also, some people still prefer one spelling to another even when the environment supports it (For example, "dass" is much more common than "daß", even though they are both used) – Tymric Sep 23 '14 at 10:31 • @Timmy I agree with your first point. – Soham Chowdhury Sep 24 '14 at 2:17 I liked my first idea, maybe changing the game helps. ## Sliding Code A sliding puzzle, sliding block puzzle, or sliding tile puzzle is a puzzle that challenges a player to slide usually flat pieces along certain routes (usually on a board) to establish a certain end-configuration. The fifteen puzzle is the oldest type of sliding block puzzle. The challenge Write a code that behaves as a sliding board. Given a configuration it should run when such configuration is solvable and not run (aka have compile/runtime errors) if the configuration is not solvable. Rules • The board is your code. It is a 4x4 grid with a total of 15 square tiles with side length >= 1. • Each tile, taken alone, should output it's number in the board (from k + 1 to k + 15 with int k of your choice). Output Each tile should output its static value (not the actual value). The tile that outputs 13 will output 13 in every different configuration. The whole board should output true (or 1 or whatever while it express a truthy value) if the configuration can reach the final state: ascending tile numbers on the board from left to right, up to down and the k void tile in the bottom right position. Score This is tile , the minimum tile side length wins, meaning a minimum score of 1 can be achieved. If a tie, the greatest k value serves as tie-breaker. • The tiles should be squares. side*side = side^2 thus the score only depends by the side. I'll remove code-challenge tag. – Narmer Sep 16 '14 at 14:55 • Oh okay, that makes sense then. – Martin Ender Sep 16 '14 at 14:56 ## Facing a martian fractal They can be used for a very large number of pratical purposes, from antennas to self-similarity of complex networks. One of the most fantastic uses of fractals tough remains 3D terrain landscaping. With such technique you can create awesome landscapes: The red planet is surrounded in a veil of mistery for its early earth-like life. Also, as you know, is full of martians: In this photo we are facing a martian face on mars. The Challenge Your task is to create a fractal landscape which resembles the martian face. • The prospective can be the most convinient for you as long as the face and the landscape are recognizable. • The output should be a few frames GIF of landcape creation, to ensure that fractal approach has been used (just like the one above). • You don't need to use the martian face, another landscape can be used as model as long as it has a pareidolic effect of a face in it. You can also not use a model and "draw" the face yourself. • Colors are optional. Obviously they will give a greater chance to get more votes. Here are some other models if you are a bit short of ideas: • While this sounds quite fun, I'm not entirely sure where the programming challenge is in that. In the end it just comes down to who finds the best parameters for the fractal they use. Moreover, it should be possible to automate this by restricting oneself to using octaves of sines and figuring out which ones to use by Fourier transforming the desired output. – Martin Ender Sep 18 '14 at 10:31 • At the moment this is too broad and set up as an art contest. You need to define what qualifies as a "fractal approach": saying that you'll eyeball a gif is neither objective nor accurate, because I could just hard-code a mesh, run some simplification, and output the frames in reverse order. And allowing the use of any target model whatsoever means it will be judged on those models. This could be reworked into a programming contest if the program has to search a parameter space to find parameters which make a specific fractal generation technique generate the best approximation to Cydonia. – Peter Taylor Sep 18 '14 at 10:35 • Although that does still leave an issue of hard-coding, as Martin alludes to. – Peter Taylor Sep 18 '14 at 10:35 • I think this slips into the implementation vs output in popularity contests diatribe. In the challenge there is no input, I can't understand how restricting oneself to using octaves of sines and figuring out which ones to use by Fourier transforming the desired output is considered hard coding. Isn't it the point of the challenge? Moreover a fractal approach is self explanatory: generate random fractal terrain, explaining why is fractal and which algorithm was used is answerer's task. – Narmer Sep 18 '14 at 10:48 • I should add that standard loopholes doesn't apply, but at this point I tought it to be paid. – Narmer Sep 18 '14 at 10:49 • It is most certainly not self-explanatory that "a fractal approach" means that randomness is involved. Most of the best known fractals have no randomness whatsoever. The defining attribute of a fractal is debated, so if the spec requires a fractal you should give a working definition, and if you use a common one such as a non-integral Hausdorff dimension then ideally you should provide a link to some kind of tool for estimating it. – Peter Taylor Sep 19 '14 at 19:52 Position the Border Guard [Currently INCOMPLETE. Posting here to save.] You are in charge of defending an island from an invasion force. To do this, you decide to place n guard posts around the perimeter of your island. You decide that the most effective way to ensure that the whole island is equally guarded is to equally distribute your guard posts around the perimeter of the island. In other words, if someone went around the perimeter your island with a surveyor's wheel, measuring the distance between guard posts walking on the perimeter, it would be equal for every guard post. For instance, if the island were a perfect circle, and I had to place 2 guard posts, they would be placed opposite to each other. Of course, the island is not a perfect circle. We can describe the shape of the island as sequence of arcs joined together as one cohesive shape, like the clouds in this question. The one difference is that in this question, there will never be a hole in the island. Given an input in the form n island  Where n is the number of guard posts to place and island is a space separated list of comma separated tuples x,y,r indicating the x position, y position, and radius of the circles that construct the island, output n 2-tuples indicating the x and y positions to place the guard posts in. # Make a Ray Tracer A ray tracer is a program which, for each pixel in an virtual screen, traces a path from an imaginary eye through that pixel and calculates the color of the object visible through it. Ray tracers are famously small enough to fit on a business card! Code and explanation here. Tired of seeing ray tracers that just render a spheres or a sphere and a box and, if you're lucky, a torus? This challenge addresses this. This task is to a ray tracer that renders a true color scene specified by arguments. The arguments are: 1. A triangle mesh, specified by the filename of an .obj mesh file 2. The diffuse, ambient and specular (more) colors for the entire mesh 3. A camera, specified by position, direction, up and field-of-view in degrees 4. A point light source, specified by position and color 5. A directional light source, specified by direction and color The output shall be a .ppm file, which can be converted to jpg for inclusion in the answer. There are lots of .obj files available on the Internet e.g. a teapot, cow and teddy bear and these standard test meshes. • Very much related: codegolf.stackexchange.com/questions/17270/… ... Also you might want to include a bit more about ambient, diffuse and specular materials, or ray tracing in general. The current spec basically assumes that everyone knows how a ray tracer works. – Martin Ender Sep 20 '14 at 18:14 • Requiring loading an obj and mtl file is a stretch for a codegolf. – Sparr Sep 20 '14 at 18:23 • @Sparr I strip the mtl but the obj is just a few lines, at least in Python. This is codegolf but C and Java etc are going to stand a chance and, by making the input external, entrants cannot try and golf the scene itself. – Will Sep 20 '14 at 19:31 • I don't know what the "normal" of a camera is, but to properly specify a camera takes three vectors, typically position, look, and up. (And some clipping planes, and a width of field). – Peter Taylor Sep 20 '14 at 20:46 • @Will if you're allowing a python library that loads obj files to be used, that's even worse. that puts any language without an obj library at a debilitating disadvantage – Sparr Sep 20 '14 at 21:58 • @Sparr no, I meant loading obj in pure python is not many lines. I picked it as the simplest mesh format out there. The key thing is, if people embed the scene in the code then this becomes an art contest, which is hated with a passion on this site. – Will Sep 21 '14 at 6:24 • @Will You could provide a heightmap as textual input. That would be a suitably simple input case for a code golf, imho – Sparr Sep 21 '14 at 15:38 • @Sparr to convince myself that parsing an obj file is super trivial, here's the pure Python, not even golfed: gist.github.com/williame/5799b75baf6bff3137ba ; obj is just a list of vertices and a list of faces. – Will Sep 21 '14 at 16:20 Well, I suppose my last suggestion was way too complex, so here's something else. # Blade Competition (Simple Card Game) Certain RPG's include mini games that are quite a bit simpler than board and card games such as chess and poker, not too hard to implement and understand, but still complex enough to be interesting. So let's play Blade. # Rules Images are better than words, so here's a short video of me playing Blade. I'm not trying to win, I'm trying to show off some interesting cases. Should be self-explanatory, the goal is to get as many points as possible. 32 cards (see below). 2 players get a deck of 16 cards each (randomly). They both draw 10 cards initially and take turns discarding cards to their field. The goal is to maximize the sum of the card's values on your side of the field. Before they start taking turns, both players draw a card from their deck and place it on their field. The player with the lower score begins. If their scores are equal, both player a new card from their decks. When a player discard a card to his field, he loses if his new score is still lower than his opponent's score. When the player's score is higher, the game moves on to the opponents turn. When both player's scores are equal, all cards on the field are discarded, and they draw a new card from their decks as described above. There are 9 different card. Numbered cards from 1 to 7, whose value is 1-7. And two special cards, called Bolt and Mirror, whose value is 1 when they are used as the initial card. When a player plays Mirror, both player's fields are exchanged with each other. When a player plays Bolt, the last card played by the opponent gets invalidated and does not count towards the score anymore. It gets removed permanently once the opponent plays a numbered card 1-7. A player may play a "1" and discard it to re-validate his invalidated card. See the github for a detailed explanation of the rules. This is only for reference, the rules as implemented by the controller program are final. If you think there's a bug, leave a comment. # Input • stdin • One line, including a newline, with a json object representing the current state of the game. • json["file"] is the absolute path of a file you may use for storing information, it gets cleared once when the controller program is started. • Your program (cli) gets called once for each decision it needs to make. • That is, choosing a card to play, or choosing an initial card when there are no cards left in your deck. # Response • stdout • A number, including a newline, representing the card you wish to play. • 0 corresponds to the first card in the json["player"]["hand"] array. # Scoring • both players start with a score of 0 • N (to be decided) turns, timelimit T (tbd), for each turn: • Draw: score +1 • Win: score +2 • Lose: score +0 • Each program plays against each other program, the program with the highest score wins. I may add a few players of my own, but they won't be ranked. # Controller Program Github ruby controller.rb <playerfile> <timelimit> <rounds> <quiet>  See players.txt for the syntax of the playerfile. Set quiet to y to suppress debug output. Set it to n to to get a lot of information about the match, use this for debugging or if the rules are unclear. See below for a sample match with quiet set to n. Please provide a cli line I can use to run your program on linux. I might be able to get Windows on a virtual machine. # Deck Card_Designation Number_of_Cards (Card's Value) 1 2 (1) 2 3 (2) 3 4 (3) 4 4 (4) 5 4 (5) 6 3 (6) 7 2 (7) B 6 (1) M 4 (1)  (B=Bolt, M=Mirror) # Sample JSON input • link, sample below • newlines and spaces added for legibility • file is the absolute path of a file you may use for storing information, it gets cleared once when the controller program is started • lastmove is the last card played by the player / opponent, or null if no move has been made yet • card types 1-7 correspond to the cards 1 to 7, card type 0 is Bolt, 8 is Mirror Everything else should be self-explanatory. { "file": "/home/.../cg_blade/files/basic", "turn": 15, "player": { "hand": [ { "type": 8, "value": 1, "valid": true }, ...... ], "field": [ { "type": 8, "value": 1, "valid": true }, ...... { "type": 7, "value": 7, "valid": true } ], "deck": 5, "score": 30, "lastmove": { "type": 6, "value": 6, "valid": true } }, "opponent": { "hand": 2, "field": [ { "type": 3, "value": 3, "valid": true }, ...... { "type": 6, "value": 6, "valid": true } ], "deck": 5, "score": 32, "lastmove": { "type": 8, "value": 1, "valid": true } } }  # Sample match Link, sample below. A sample match generated with the controller program and quiet set to n. A bit long, but shows a few interesting cases. Match between both players starts. <basic> vs. <basic> Initializing round 0. Each player gets a deck of 16 cards. Player 0: 3 6 5 3 6 7 B 5 2 4 B B 5 1 B B Player 1: 1 2 4 4 3 3 M B M 5 2 6 7 4 2 M Each player draws 10 cards. Player 0: 1 2 4 5 5 B B B B B Player 1: 2 2 4 5 6 7 B M M M Cards remaining in each deck: Player 0: 3 6 5 3 6 7 Player 1: 1 2 4 4 3 3 Round 0 starts. Field initialization starts. Player 0 draws initial card. Player draws 7, and puts it on the field. Player 1 draws initial card. Player draws 3, and puts it on the field. Player 1 gets first turn. # Number in parentheses is the total score of the cards on the field. Turn 0 starts. Player 1's turn. Player 0's field: 7 (7) Player 1's field: 3 (3) Player 0's hand (10): 1 2 4 5 5 B B B B B Player 1's hand (10): 2 2 4 5 6 7 B M M M Cards remaining in player 0's deck: 5. Cards remaining in player 1's deck: 5. Player 1 plays 5. Player 1 ends his turn. Player 0's field: 7 (7) Player 1's field: 3 5 (8) Turn 1 starts. Player 0's turn. Player 0's field: 7 (7) Player 1's field: 3 5 (8) Player 0's hand (10): 1 2 4 5 5 B B B B B Player 1's hand (9): 2 2 4 6 7 B M M M Cards remaining in player 0's deck: 5. Cards remaining in player 1's deck: 5. Player 0 plays 2. Player 0 ends his turn. Player 0's field: 7 2 (9) Player 1's field: 3 5 (8) ...... ......  • I haven't thought hard about loopholes, but one quick observation: I don't think you specify anywhere how many copies of each card are in the deck. – Peter Taylor Sep 20 '14 at 20:59 • See the detailed rules on github. But you're right, perhaps I should add a note. – blutorange Sep 20 '14 at 23:38 # Calculate an arbitrary linear recursive sequence in this question given a recursive definition for a sequence we need to output a formula for the given sequence. in this question, a linear recursive sequence is a sequence of the form: a_0 = c_0 a_1 = c_1 ... a_{m-1} = c_{m-1} for n >= m: a_n = x_1*a_{n-1} + x_2*a_{n-2} + ... + x_m*a_{n-m}  where m, c_1 ... c_{m-1}, x_1 ... x_m are all constants. for example, such a definition (the fibonacci numbers): a_0 = 0 // c_0 is 0 a_1 = 1 // c_1 is 1 for n >= 2: a_n = 1*a_{n-1} + 1*a_{n-2} // x_1 is 1 and x_2 is 1  the answer may be a function and get input as two lists, one containing a_0...a_{m-1} and one containing x_1 ... x_m, and return a string, or be a complete program and get the input as a space separated numbers. because polynomials of degree up to 5 can be solved but polynomials of degree 5 or higher can't, the solution may assume that m is smaller than 5. the output must be a formula that given n returns a_n. if two formulas are different but both return the same output for every index, both of them can be outputted. so, for the powers of 2, both (1+1)^n and 2*2^n - 2^n can be outputted. in the output √5 denotes the square root of 5, as does 2√5. 3√5 denotes the third root of 5. ### Example input and output: f ([0,1],[1,1]) (fibonacci numbers) can result in ((1+√5)^n-(1-√5)^n)/√5 f ([1],[2]) (the powers of 2) can result in 2^n f ([1,2],[1,2]) (the powers of 2 again)  bonus: if your solution uses no library function which solves equations, -80 bytes. this is code golf, so smallest byte count wins • This seems to hinge largely on solving the polynomial equation for the characteristic roots. For the Fibonacci one, would outputting floats in place of 1+√5 and 1-√5 be valid? – xnor Sep 25 '14 at 17:59 • @xnor what should I do? I guess allowing floats leads to an easier question, but outputting the exact formula is more mathematical. – proud haskeller Sep 25 '14 at 18:21 • @xnor I think floats won't be allowed – proud haskeller Sep 25 '14 at 18:22 • How then would one represent the roots of a fifth-degree polynomial? They're not generically algebraic. Maybe you can restrict to two-term recurrences to get quadratics. It would certainly make solving them and fitting to initial conditions easier, though perhaps that's less interesting. – xnor Sep 25 '14 at 18:39 • Could you please add some {} to your first code block and be consistent with the use of _ to indicate subscripts? At present, it seems to be more work than it should be to figure out how to read the equations. – Peter Taylor Sep 25 '14 at 22:37 • While it's true that cubics and quartics can be solved in radicals, the solutions are pretty ugly. I strongly advise you to write a reference solution so that you understand what you're asking for before you post the question. – Peter Taylor Sep 26 '14 at 10:42 • @PeterTaylor I was searching for the formulas and found this math.vanderbilt.edu/~schectex/courses/cubic . it is possible, but i guess the best solutions would just copy-paste the variables into the formulas, which isn't very interesting – proud haskeller Sep 26 '14 at 11:45 • @PeterTaylor Maybe restricting to qubic equations and requiring floats instead of √ would be more interesting because the solution will have to actually compute the solutions – proud haskeller Sep 26 '14 at 11:51 • @proudhaskeller I think that allowing floats is cleaner, but there's subtleties there too. Solution might use iterative rather than exact methods to find roots, so you'd need to specify a tolerance and bounds on the coefficients of your recursion. Also, the formula is different when you have a double-root, which solutions might fail to detect due to float precision issues. – xnor Sep 26 '14 at 21:01 • @xnor how is the formula different? I didn't get that – proud haskeller Sep 26 '14 at 21:04 • math.stackexchange.com/questions/129849/… – xnor Sep 26 '14 at 21:10 • @xnor I totally forgot that – proud haskeller Sep 26 '14 at 21:13 • @xnor Maybe the input should be restricted to not include these cases – proud haskeller Sep 26 '14 at 21:14 # Fake the forecast #2 Somewhat unfairly, your boss wasn't happy with your last attempt at forecast fakery. She's giving you one last chance, with extra stipulations. This time your task is to draw a map, as a grid of arrows, representing both wind speed and direction. • A grid is 8 tiles by 8 tiles. • A tile is an arrow representing a direction and a speed. • There are 8 potential wind directions, represented by the direction of the arrow: 1. N 2. NE 3. E 4. SE 5. S 6. SW 7. W 8. NW • There are 6 potential wind speeds, represented by the colour of the arrow (e.g. ): 1. # 00F (<20 mph) 2. # 0FF (21-30 mph) 3. # 0F0 (31-40 mph) 4. # FF0 (41-50 mph) 5. # F00 (51-60 mph) 6. # F0F (>60 mph) There are geographical restrictions: • Each tile has a terrain type, land (L) or sea (S). These are: S L L L L L S S S S S L L L L S S S S L L L L S S S S S L L L L S S L S S L L S S S S S L S L L S S S L L S S S S S S S S S S S  • Wind speed on land may only be between 1 and 4 • Wind speed at sea may only be between 3 and 6 Variation must be gradual, specifically: • If a feature (i.e. direction or speed) differs from one of its 4 adjoining tiles (or 3 for side tiles, 2 for corner tiles) it can only differ by one increment or decrement from that neighbour. e.g. a tile whose neighbour has wind speed 4 may have a wind speed of 3, 4 or 5 (assuming it accords with other neighbours). • Directions can loop around, i.e. N -> NW and NW -> N. However, speeds cannot. Because your boss is looking for believable maps, she has introduced four arbitrary restrictions: • There is always at least 1 tile with wind speed 6 • There is always at least 1 tile with wind speed 1 • A wind speed of 6 is always northeasterly • A wind speed of 1 is always southwesterly Maps must be unique, don't generate the same map for different inputs. • Input is a positive non-zero integer corresponding to the days between now and your forecast (e.g. 1 is tomorrow's forecast, 365 is a year's time). • Output can be any format (e.g. image or text) but must take the form of a grid of arrows • Output should be reproducible — the same input will always give the same output • Each output must be unique from those generated using a lower input. Because you really need to impress your boss this time, you should aim to give valid output for as many days in to the future as you can. Therefore, scoring is based on input limit: • Your submission's input limit is regarded as 1 less than the lowest input that gives non-unique or otherwise invalid output. • For instance, if valid and unique output is produced for an input of 1, 2 or 3 but not 4, your input limit is 3. The winner is the submission with the highest input limit - i.e. the submission which continues to give valid and unique output up to the largest input. There is a 768 byte limit on source code. If there is a draw the entry with the fewest bytes wins, so keep it short. Here's an example of valid output (terrain shown for illustrative purposes only): Some clarifications: • There needn't be a relation between forecasts, consecutive or otherwise (except that they must be unique). • Outside of a submission's 'input limit' there is no defined output. • There are no graphical restrictions except those specified. • You may supply the terrain definition grid as input - in which case it wont count towards your byte count • No other input or fetching of external data is permitted • The link to the previous question is purely in theme, no rules are carried across and previous solutions (clearly) wouldn't be valid here. • You don't have to draw the terrain type or any other embelishments - you can if you want but it isn't a popularity contest ## Sandbox Questions • Would this question be marked as a duplicate? • Is a 768 byte limit too restrictive? Too easy? • Have I left any loopholes? • 1. I think you need to come up with something more radical than your last question to stop it from being closed as a dup. 2. Why 768? It seems very specific.. – Beta Decay Sep 29 '14 at 15:49 ## Translator to Minimize the Number of Characters With code golf you are attempting to minimize the number of characters or bytes. The languages are, however, all just ASCII characters. While I do not want to see this in other code golf challenges, can you use more exotic characters to do the job? CJam, for example, only uses ASCII characters in its code but many other characters can be placed into the compiler as a strings. I wrote a simple translator to test this out which can be coverted to: ㉕ァײோ¸༘ݩײ౲ᖒⲫ㶚ቲ㑼ᇦ㰌⧑༘ઃ௉ⲫ௔ྭഞࠗ㒍⾺ While this is intentionally not an acceptable answer for various reasons, it shows the range of possible characters the interpreter can identify. Please note unusual things that happend as you attempt to highlight the text. ## The Challenge 1. Choose an online interpreter such as Ideone, CJam, or Golfscript and a language which can be run on that interpreter. This is so I know I am using pretty much the same resources as you are when I run your answer. 2. Create a translator in your stated language which accepts an "original" input code from the same language. It then outputs a string which can be pasted in your answer or in a comment on this site. 3. Create a second translator into which the previous output string can easily be incorporated. When this combined string and translator are run, it will run the original input code. Please note: • The original input code to score your answer will be the same for any answers of the same language. • This code for scoring will be subject to change and the translator must work for any code of that language the interpreter accepts. (exceptions listed below). • This code for scoring will only contain ASCII characters and I will attempt to take it from existing answers on this site. At request it can exclude line breaks or specific characters for an additional 5% to your score AT MY DISCRESION (for instance Java code needs to be able to have spaces in it, I can't avoid that). • The input code for scoring will be roughly 500 characters long. However, you transltors need to work regardless of the length of the input code so you can't take advantage of the fact that the code is even/odd. It does not need to work for null input. • Any errors or anything malicious will obviously be disqualified. • The compressed code must be copy/pastable to codegolf SE. • When running the code from its translated form, the code must be able to accept input. This input is not going to be part of the code to be translated. • Any null case which does not compact the original code in any way is disqualified. ## Scoring • Minimum score wins (surprise surprise) • Score is the number of characters you need to run the original code minus the number of characters in the original input code plus 500 (combined with any modifiers). • The length of the original translator does not matter. • 5% is added to your score for each character/symbol your language often makes use of but your translators cannot handle. I can disqualify for this if I believe that the missing character too severly cripples the programmer. • 5% is removed from your score if your two translators are the same piece of code (aka the translation is reversible). • 5% is removed from your score if all characters in the compressed output are visible (no invisible ASCII characters). White space (spaces, tabs, line breaks) are visible but ASCII character 19 (for instance) is not. • 3% is removed from your score if all characters are visually distinguishible (no two characters look the same but are read differently by the interpreter). The more obvious this is the better. • 10% if anyone provides an acceptable example input code where the score without modifiers would be longer than the original input code. This would mean the translator effectively did not compress the input code. • What's the use of the +500? Everyone's getting it, so the differences don't change at all. – Soham Chowdhury Oct 4 '14 at 9:30 • What happens if you remove/add 5% to a negative or zero score? – kaine Oct 4 '14 at 10:07 • A negative number becomes smaller and zero . . . remains zero. OK, I see your point now. – Soham Chowdhury Oct 4 '14 at 10:20 • 1. A map that is equal to its inverse is called involutive, not reversible. 2. The "input code" should be the same for all submissions. It won't be fair otherwise. 3. The first, third and fifth bonus seem rather subjective. 4. I don't understand the penultimate bullet point. 5. Am I right to assume that number of characters you need to run the original code is the number of characters of the encoded string plus the decoder? – Dennis Oct 12 '14 at 17:13 • THANK YOU FOR THE INPUT. I will try and adress concerns. 1. Ill include involutive if I post is but the map doesnt need to be involutive if the encoder can tell if the input is encoded. That was my intention. 2) the code would need to be in the same language as the language it is programmed in. Wont work for submissions in different languages to have the same input code. 3) ill try to find a way to clarify them. Only the first has a subjective component and would be available to anyone who asks for the point fee. I dont mean look simular, I mean print exactly identical symbols. – kaine Oct 12 '14 at 17:27 • 4) I will try and rewrite it. I meant there is a penalty if the encoder does not shorten some valid code of the appropriate length. 5) yes... These are my initial reactions. I am more than willing to remove bonuses if they complicate things too much. I think i need to include examples. I mean them there to make it easier to promote more answers. I dont want invisible characters but I would rather have answers with them than no answer. Again, thank you for the input. I like the idea and want to see it flushed out better than I probably could. Is there a good way to fix #2? – kaine Oct 12 '14 at 17:33 # Sudden Death Rummy with following rules: A 50 game match is played and the winner gets an average score per game. This average score is then multiplied by the bytecount of the program. The winner is the program with the lowest product of average score and bytecount. Rummy is a card game where the objective is to get rid of all cards in your hand by forming "melds". A meld is either a consecutive series of cards in the same suit, or 3/4 cards of different suits of the same value, which is, in ascending order A(ce), 2-10, V(alet), Q(ueen) or K(ing). A meld is always at least 3 cards, and 13 cards at the most. In my regional variant of discard rule Rummy, there are 7 rounds. the first 6 rounds require you to put down N+2 cards in 1 or more melds, then discard 1 card, then finish your turn, before you can start using existing melds or put down new melds. in the 7th round, you NEED to be able to place down your entire hand and discard the one card in 1 turn, before your opponent can do this. You start with 10 cards, and every turn you cannot empty your entire hand, you draw another card and give the turn to the opponent. The actual system involves buying cards and bidding wars, but to simplify, it's just round robbing cards until one of them finishes. Your task: Create a Rummy bot that plays against itself. Input: a number between 1 and 100 denoting how many games should be played. your program needs to generate 2 random legitimate hands as the first task. The deck starts with 104 cards: 2 full decks, 4 suits per deck, 13 cards per suit. 10 cards per hand from the deck. second task: one hand randomly starts. If the program cannot make a legitimate Sudden Death Rummy hand clear, it draws a random card and hands the turn to the other hand. If the program CAN make a legitimate hand clear, it displays 2 lines. The first line is a comma-separated list displaying the winning hand clear. The second line is the sum of the value of the cards of the other hand, with number cards being their respective value and A/V/Q/K being 10 points each. this task switches between players until one of them is the winner. If the game lasts long enough for the deck to be depleted, no victor is declared and both hands get scored according to the above rules. 3rd task: after a victor is chosen, the next game starts. task 1 and 2 are repeated until there have been as many games as the input indicates. At this point, the match ends. The victor is the side who has the lowest amount of points after the end of the last game. [Sandbox Note: I need to: Figure out a scoring method that doesn't require multiplying or averaging average score and bytecount without encouraging high bytecounts or average scores; decide whether to include a runtime limit; Decide whether the program should also display the hand and drawn cards.] # Build a Version Control System [WIP] code-golf Git, SVN, Mercurial and Bazaar are just too bloated for you. You want something simple. Something as short as possible. # Rules • Your program will be invoked every time an operation needs to be made to the repository. • Your program must take commands from command-line arguments. • The implementation of how the program stores its own data does not matter. Input and output format do. • Give your version control program a name and version numbering (so I can keep track of when you update it). # Repositories A "repository" is a directory with files and directories in it, as well as (a) special file(s) that store settings and information for the repository. These special files may not be included in version control. All other files in that directory should be included in version control. # Features • 'init' command - sets up a repository in the working directory • [BONUS 20pts] If a repository already exists in the working directory, erase or reset it first • 'destroy' command - removes all of your special version control files from the repository. If you are not in the root directory of a repository, keep moving up one level until you find VCS files. If you reach the top level of the filesystem without finding your VCS files, don't do anything. • [BONUS 15pts] Exit with status 1 if no VCS files are found # Scoring Your score is the length of your code in bytes, minus all bonuses. Lowest score wins. • What should "every time you change the program" say? I'm not sure whether it should be s/change/run/ or s/program/repository/. – Peter Taylor Oct 5 '14 at 22:07 • Do you need to generate diffs and resolve conflicts? That's a whole challenge on its own. – xnor Oct 6 '14 at 6:56 • @PeterTaylor I mean that your entry into the competition needs to have version numbering - so I can see that you've edited your post and added features. Probably not too important – user16402 Oct 6 '14 at 9:41 • @xnor Currently what I have in mind is a mechanism for committing changes, viewing a log of changes (diffs) and reverting to a particular commit - probably not much more (or if there is more, make it a bonus). By 'resolve conflicts' you mean when users A and B clone the same version, then both submit commits? – user16402 Oct 6 '14 at 9:43 • Yes, usually in version control systems, when two users make parallel changes to the same file, it tries to merge the changes. If they are consistent or to different parts of the file, the changes are merged. If not, a "conflict" is presented with options on how to resolve the inconsistency. See diff3 and en.wikipedia.org/wiki/Merge_(revision_control)#Three-way_merge. This is a tricky algorithmic problem on its own, so perhaps it should be outside of the scope of your challenge. – xnor Oct 6 '14 at 20:08 • @xnor You're right. I think I'll restrict this to a single-user system (i.e. no clone/pull/push). Should those features be available as bonuses though? Or a separate challenge? Maybe the bonus should just be "Implement a system for resolving conflicts, using an external, existing tool for conflict resolution" – user16402 Oct 6 '14 at 20:45 • @professorfish Sounds reasonable, though perhaps you should say exactly what features it needs and what types of tools are OK, lest golfers cut too many corners. For diffs, will changes the to system be provided like "XYZ" inserted after line 1? Or will it be just be given the new file and have to produce the diff from the old file? If the second, then algorithmic alignment is also a challenge. It needs a notion of quality to prevent cheap diffs that claim the user deleted the whole file and added a new one when actually a single line was changed. – xnor Oct 6 '14 at 21:33 Unbreakable Wall Maria In order to protect the last bastion of human civilisation against giant Titans, a large wall has been constructed around the perimeter of the city. It has been decided that another large wall, within the perimeter of the first one, will be erected to ensure the protection of the city. You have been assigned to design the wall to make sure it is strong and sturdy. A wall of height p and length q is built out of identical rectangular blocks of height m and length n. A wall is considered unsecure if there is a straight line that can divide the wall into two pieces without cutting through any of the individual blocks. To illustrate, consider a wall of height 5 and length 6, constructed of blocks of 1 height and 2 length placed in either orientation. This is the test case 5 6 1 2 (a 5x6 wall composed of 1x2 blocks). There are at least two different ways of building this wall: Diagram 1: Ways of building a wall The first wall is an insecure wall because there is a line that divides the wall into two pieces (into a 6x4 block and a 6x2 block). Because there is only one line that divides the wall, we can call this wall an insecure-1 wall. An insecure-1 wall is more secure than an insecure-2 wall, but not as secure as a secure wall. The second wall is a secure wall because there is no line that can divide the wall into two pieces without going through any of the blocks. You could also think of it as insecure-0 if you wanted to. A secure wall is essential to the integrity of the wall. If it is an insecure wall it will be easily breached by the Titans. Your task is to design the wall. To do this, you will write a program that takes in the height and length of the wall and the blocks as input, and output (a graphical representation / an ASCII art representation) of the most secure wall that can be created using the blocks given. ### Input Input consists of four space seperated integers p, q, m, and n, which represents the height of the wall, the length of the wall, the height of the blocks, and the length of the blocks. ### Output This is the part I'm not sure about. I've got two possibilities: either I can make the question graphical output (i.e. I would expect the program to output an actual image), or ASCII art. Possibility 1: Output a graphical image (not ASCII art) of the wall. The overall appearance of the wall (e.g. line thickness, colours used, size, etc.) is up to you, but the lines that form the individual blocks must be clearly visible, and differentiated from the rest of the wall. This means you can't pull something like "this draws a black wall with black lines", or "this draws an infinitesimally small scaled wall", etc. Possibility 2: Output text based art (not a graphical image) of the wall. It should be drawn using the box drawing characters. The wall must be drawn to scale, but apart from that, you have some freedom in what characters to use (so you can choose to use the double line ones if you wish), but they have to be part of the Box Drawing Unicode block. In addition, the wall must be visible, so you can't write a program that outputs nothing and say "this draws an infinitesimally small scaled wall", etc. Question to reader: Which output format do you think would make a more interesting challenge? • As is, this seems like a math problem rather than a coding challenge. There's probably a criterion one can derive without needing to test tilings in code. But I like the idea behind the challenge. May I suggest something like generating or testing for secure walls? – xnor Sep 25 '14 at 3:04 • ​​​​​​​​​​​​​​​@xnor I found that there was indeed a closed form solution for any case of the problem. Generating wall positions sounds like a good idea. I'll rewrite. – absinthe Sep 25 '14 at 3:20 # One digits or two digits Here’s the rule: They're 2 players. Each player has a pool of99.

The player that takes the first turn will choose to invest an amount of $taken (deducted)from your own pool. Then other player will do the same. Who invests more wins the round. Who wins the most round is the match winner. Unless it’s not that simple. They’re a few twist: Your opponent know how many points you use, well almost. After you invest, your opponent know if you invest one digit number or two digit number. They’re told instantly after you invest your points. Just one or two digits. Not precisely. WARNING: Player who moves first still get notified about your opponent who moves second. Your opponent know how many points you still have left in your pool, well almost. They’re only told if you have either$0 to $19,$20 to $39,$40 to $59 points,$60 to $79 points or$80 to $99. They’re told instantly after you invest your money. WARNING: Since the notification is instant, that means if I move second, I got to know your score level before I move. If I notice a level change when you move first, I will know the level change before I make my move second. So I can act according to it. It’s best of 9, and those$99 must survive those 9 rounds.

So you don't want to invest all $99 in round 1. Well, it doesn’t mean that you have to spread those$99 exactly in 9 rounds. You can use those $99 in any mean to get victory. If you have a sure-fire strategy that will give you a guaranteed win, but it needs you to use all your$99 in the first 5 round, by all mean, go. Just remember that invested point don’t return back to your point pool, win or lose.

In first round, the player who moves first decided randomly. In following round, the player who wins previous round moves first. If tie, the player who moves first last round, moves first again

SCORING METHOD

Each bot will be run double robin. The winner of the match results 1 point. Tie 1/2 point. Lose 0 point. After the match up, bot with most points declared as champion

COMMUNICATION PROTOCOL

During your turn, I will run your program and gives you lines of query from STDIO

Each line is a query of this following type:

START

YOU xx

This means that in that round, you played xx(exact number of dollar you invested)

ENEMY x y

This means enemy invest x digit int that round (x is 1 if enemy invested 1 digit, x is 2 if enemy invested 2 digit) and y is the money level after the player invests(y is 0 for $0 to$19, 2 for $20 to$39, 3 for $40 to$59, 4 for $60 to$79, 5 for $80 to$99)

FINISH

End of query. We expect you to give us output.

Your output must be to stdout and a single positive integer (0 is allowed)

EXAMPLE:

The match is between DEO vs WORLD. It was decided that DEO moves first.

ROUND 1

Deo will receive this query:

START
FINISH


Deo decides to invest $10. Now he only has$89.

WORLD receive this query:

START
ENEMY 2 5
FINISH


What WORLD deduces is that DEO played from $10 ~$19. WORLD knew that DEO played at least $10 because the query said that ENEMY 2.. and WORLD knew that DEO played at most$19, because if DEO played $20, the query will be ENEMY 2 4 WORLD decides to invest$20.

In round one, DEO invests $19 while WORLD invests$20. Since WORLD invests more, WORLD receive 1 point.

Enter to round 2: WORLD starts first, since winner starts first by the rule

WORLD receive this query:

START
ENEMY 2 5
YOU 20
FINISH


WORLD decides to invest $0. DEO receive this query: START YOU 19 ENEMY 2 4 ENEMY 1 4 FINISH  DEO realizes that in round 1, enemy played at least$20, due to level change. And he noticed that in round 2, enemy played 1 digit number. DEO taught that WORLD decides to save his money and invest $0. DEO decides to invest$1

WORLD invests $0 while DEO invests$1. Since DEO invests more money then WORLD, DEO win 1 point.

And so on

• what happens if both players invest the same number of points? Also, it seems you could guarantee a tie as player 1 by investing 0 in the first round (guaranteed loss/tie the round), then investing 99 the second round (guaranteed win/tie the round). – stokastic Oct 24 '14 at 20:38
• @stokastic None wins the round. You do realize that you need that it's best of 9. So if I follow your strategy, I will get 1 point by round 2, however, my opponent easily wins the next 5 and end the game (since I already use all of my 99 ). – Realdeo Oct 25 '14 at 8:15