# 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]

• Suggestion: instead of having a notice on the top answer ("note: if you are..."), you'd better just put a moderator notice below the question – nicael Mar 19 '18 at 19:35
• @nicael We can only choose from three post notices: citation needed, current event, and insufficient explanation. – Dennis Apr 7 '18 at 14:43
• If you remove a post but didn't post it you can replace the text body with [](lots of text here to reach the min chars) to make it much smaller when removed – Christopher Apr 13 '18 at 17:54
• @Christopher Please don't do that for old proposals. It clutters the first page with an answer nobody cares about anymore, instead of staying hidden on page 10 where it will bother nobody. – Dennis Apr 13 '18 at 18:17
• @Dennis ? what are you talking about. As if if you didn't post it like you just removed you own sandbox because dupe or something – Christopher Apr 13 '18 at 18:18
• @Christopher If your proposal is still on the first few pages, you can replace the proposal with a stub to save vertical space on these pages. However, if your proposal is already on page 10, editing your proposal will bump it to page 1, where space is more precious than on page 10. – Dennis Apr 13 '18 at 18:21
• @Dennis ohh that makes sense – Christopher Apr 13 '18 at 18:25
• codegolf.meta.stackexchange.com/questions/12599/… – Redwolf Programs Apr 17 '18 at 17:38
• Maybe it's time to consider cleaning some of this up a bit. There's just too much to go through and some of these proposals are years old and obviously not going anywhere (even some of the good ones). Perhaps cull anything that is two years old and has likewise been inactive for as long? – ouflak Aug 6 '18 at 9:07
• @ouflak You can sort posts by "active". That seems to resolve all of the problems you describe. – FryAmTheEggman Sep 27 '18 at 19:04
• I already posted this, but codegolf.stackexchange.com/questions/176599/… – 2br-2b Nov 27 '18 at 2:38
• How are tags added to questions? – guest271314 Jan 9 at 7:51
• It seems like there is a rollback war with moderators and the Community user to add and remove the featured tag. – smileycreations15 Mar 21 at 21:13
• @smileycreations15 That's unfortunately unavoidable. Community is an automatic script, and, since most featured questions are only temporarily so, it assumes that we don't want this question to be featured forever. However, we do, so a mod has to edit the tag in every now and then. – Erik the Outgolfer Mar 24 at 15:22
• @EriktheOutgolfer Yeah. Maybe they can create a special [featured-pin] tag which will both feature it and pin it from removal by the Community user. – smileycreations15 Mar 24 at 17:20

# HTML-tac-toe

Build a one-player tic-tac-toe game with only HTML and CSS.

# Introduction

You can do just about anything with a fully-featured programming language, but how much can you accomplish on a Neopets petpage? Inspired by http://www.neopets.com/~vuh

# Challenge

Build a one-player tic-tac-toe game with only HTML and CSS.

• Use no more than one file.
• GIFs (including animations), PNGs, and JPEGs are allowed.
• Flash, embedded scripts, iframes, and JavaScript are not allowed.
• It must work in the at least two standard browsers (FF, Chrome, Safari, Opera, IE)

Inputs: The player will click on a space when it's their turn to move there.

Outputs: The page will show the current board state at all times. The page will play an optimal move whenever the player moves, unless the game is over.

You're free to decide who starts and who has X or O.

# Scores

• -10 per image
• -1 per opening bracket or brace (< / { )

Brownie points for design, flair, and new tricks!

# Example Input and Output

Input:

Click on the top left of an empty grid

Output:

Grid shows my mark where I clicked and the opposite mark in the left middle or top middle.

• I'd recommend against restricting languages, and against score bonuses too – ASCII-only Jan 22 at 4:15
• @ASCII-only I can drop the bonuses without much consequence, but it's not a new challenge without a language or host restriction. Any suggestions? – Qaz Jan 22 at 4:45
• True, but... language restrictions are pretty frowned upon – ASCII-only Jan 22 at 4:47
• Welcome to PPCG! You may want to check this post out, it certainly helped me when starting with writing my own challenges. Also, your post does not have a well-defined objective winning criterion. It seems like it is atomic code-golf or code-challenge [1/2] – ბიმო Jan 22 at 19:32
• , but you will need to define how answers are scored (in this case lower is worse) and how ties are treated. Also why do you disallow GIFs but JPGs not? I know most will know, but maybe explain or at the very least link to somewhere where the rules for tic-tac-toe are explained. What counts as an X, what as an O? There are a lot of open question atm. [2/2] – ბიმო Jan 22 at 19:36
• JPGs are allowed. (That's the same format as JPEG, just a different extension.) I can change it to 'images', but I'm worried about some image format I don't know of that makes the challenge trivial. More points, more better! That seems clear enough, but I can certainly spell it out. Are ties forbidden? Two entries with the same number of points seem equally good to me, but the first posted could be the winner. If I link to tic-tac-toe rules, does that answer "What counts as an X, what as an O?" or are you asking something else? – Qaz Jan 23 at 0:13
• "Standard exceptions are allowed IF they work on Neopets.com." How do we know what works on Neopets.com? If we have to create accounts on a random third party site to test answers and know whether they're valid or not, the question should and probably will end up closed with a lot of downvotes. – Peter Taylor Jan 24 at 15:34
• This isn't very interesting in general. It essentially amounts to creating every possible layout of a tic-tac-toe board and linking them together with clever CSS and HTML hacks so it fits in 25 pages. I think it could be made a bit more interesting by making it atomic code golf scoring on the total number of html files used, lowest scores win rather than limiting the total number of pages. – Beefster Jan 25 at 20:36
• @PeterTaylor very well, dropped that altogether – Qaz Jan 25 at 22:53
• @Beefster The page I link to as the inspiration (neopets.com/~vuh) uses only one html file, and the source isn't too hard to understand, so perhaps I should link to the creator of the page instead, limit the solutions to one page, or both. – Qaz Jan 25 at 22:53
• I highly suggest looking through current codegolf questions to see which are well-received by the community. This question seems highly arbitrary and leaves too much under-specified. – qwr Jan 27 at 20:28

# Introduction

The original creator of this meme has gone blind, lost his internet and accidentally deleted all his memes. Except this one. He has this one last meme on his desktop, and since he can't see, he wants to know what this meme is.

By hearing it.

# Challenge

Your challenge is to write the shortest program that will produce a playable audio file that the meme creator will play to hear the text in this meme.

• The input is the meme below
• The output will be a audio file that reads the output text in English and has a slight pause after a colon or a new line. But don't read out 'colon'

• You can use any programming language
• You can use any existing library
• Output audio must be playable by vlc
• Networking is not allowed, you cannot connect to any internet services

# Input and Output

Input:

Output:

Me: spends 8 hours per day on the internet

Eyesight: gets worse

me:

• The output would always be hardcoded, so there's no point in the input – Jo King Mar 8 at 9:43
• This challenge would be nice with different memes as test cases. Otherwise it would be hardcoded as said previously. – Belhenix Mar 20 at 19:35

# Compress briefly

Compress and decompress the first chapter of Worm, beginning with the opening words "Class ended" and ending with the closing words "my best friend." (including the period). You do not need to include any of the formatting (copy and paste as plain text).

## Rules

• You may not use any built-in or imported compression functions or procedures. You must implement the compression yourself.

• You may either write one program to compress and another to decompress, or one program that does both. If you wish, the second option can be a polyglot, where compiling as one language compresses and compiling as the other decompresses.

• Your program must be no more than 2000 bytes long. You may, at your option, compress your program with bzip2 or gzip before measuring its size for the purpose of meeting this limit.

• Your program does not need to work for any other text.

• Standard loopholes apply.

• Standard I/O rules apply.

## Scoring

• The score is the sum of the total number of bytes of your program(s) and the total number of bytes in the compressed text.

• If you use a single program to compress and decompress, then you may have to pay a penalty. Specifically, you must pay a number of bytes equal to the Levenshtein distance between the shell command needed to (compile and) run your compression program and the one needed to run your decompression program. You can calculate this online. A special exception: if you choose to write a polyglot, then you can leave out the paths to the compilers/interpreters when you calculate the penalty.

Tags: code-challenge, compression

• Related – Beefster Mar 19 at 22:31
• @Beefster, a bit, but I think there are enough differences to make competitive answers largely incompatible. – dfeuer Mar 19 at 22:36
• I don't think any answers are going to outperform gzip/bzip/whatever. There's no obvious patterns to exploit in the text. – Beefster Mar 19 at 22:37
• Also: how is this different from kolmogorov-complexity? – Beefster Mar 19 at 22:38
• @Beefster, it's different because I don't allow the code to be big enough to have much chance of encoding the text in it. It doesn't have to outperform industrial-strength algorithms. That mention had to do with the source code size limit, intended to give extremely verbose languages the opportunity to participate. – dfeuer Mar 20 at 0:28
• Every answer will be some variant of import gzip; gzip.compress(story) – Beefster Mar 20 at 16:21
• @Beefster, is my explicit prohibition of that insufficient? My first rule is that you can't use a built-in or imported compression function. – dfeuer Mar 20 at 16:42
• That sounds a lot more interesting than it actually is. There's a reason "do X without Y" questions have fallen out of favor. Compression challenges are hard to write. At the very least, you need some exploitable pattern common to a class of strings. This simply isn't the case in the linked text. – Beefster Mar 20 at 19:29
• Even without using built-ins the best answer will use some variant of Huffman coding that fits in 2000 bytes. LZ77 is also pretty easy to implement and works well on text. – Beefster Mar 20 at 19:44

# Bit flipper

Given a string s and a positive number n, return the string s with n random bits flipped. (A random number can be generated in any way, including pseudo-random number generators)

Example:

Before:

Hello World


After (n = 2, 2 bits flipped):

Hello wOrld

• How exact are the bytes being 'flipped'? Are we changing the bits? Is the output deterministic? It doesn't look like you're modifying any specific bit of the byte, or reversing it, or doing bitwise negation. – Rɪᴋᴇʀ Mar 21 at 1:55
• @Riker well changing from uppercase to lowercase is just xor 32. But they'rem saying byte flipper not bit flipper which is a bit confusing – ASCII-only Mar 21 at 6:09
• @Riker The bits are flipped – smileycreations15 Mar 21 at 9:42
• @JoKing No, that was an example because I didn’t wanted binary non-unicode characters in the post. – smileycreations15 Mar 21 at 9:44
• What is n? On the basis of what little is specified in the question, I would be tempted to write an implementation for n=0 which consists of the empty program in GolfScript... – Peter Taylor Mar 21 at 16:44
• @PeterTaylor A user defined count of how many bytes will be flipped – smileycreations15 Mar 21 at 18:12
• I think the confusion here is that "bytes" doesn't mean what you think it means. From the lone test case I think what you're trying to ask us is: given a string s and a number n, change the case of n random letters in s - would that be correct? – Shaggy Mar 22 at 0:41
• I assume case was just an example of bit 5 flipping. I'd recommend writing it like Given a string s and a positive number n, return the string s with n random bits flipped. Though from there you run into problems about invalid unicode sequences in the output – Jo King Mar 22 at 3:45
• @JoKing I replaced with your example. – smileycreations15 Mar 22 at 7:47
• What do you mean by Default n = 3? Also, how should programs handle invalid unicode sequences? – Jo King Mar 22 at 9:14
• @JoKing By default, n should be 3. And invalid unicode sequences should not be handled, and the data should be directly printed out to stdout or any output file. – smileycreations15 Mar 22 at 12:35
• When you say random, do you mean of our choice? pseudo-random? fetched from random.org? – Artemis Fowl Mar 26 at 23:16
• @ArtemisFowl It is selected by the program. – smileycreations15 Mar 27 at 10:45
• @smileycreations15 It's gonna be hard to make that 100% random – Artemis Fowl Mar 27 at 15:46
• @smileycreations15 Maybe you should add that to the question. – Artemis Fowl Mar 27 at 20:35

# Output an alphabet suite

A successor to the ŋarâþ crîþ alphabet challenge.

Outputting the alphabet song with as few letters as possible was too easy, but what about outputting many of them?

Your challenge is to write as many programs as you can, with no two programs sharing any Unicode codepoints, and each program outputting the names of the letters of the alphabet (or the glyphs of some other kind of phonetic script) used by a different language. For instance, one program can output

a bee cee dee e eff gee aitch i jay kay el em en o pee cue ar ess tee u vee double-u ex wye zed


and another program can output

a be ce de e efe ge hache i jota ka ele eme ene eñe o pe cu erre ese te u uve uve doble equis ye zeta


Notes:

• For a given language, there will probably be some leeway in what you can output.
• Unlike in the previous challenge, you don't need to worry about any particular punctuation. You should at least separate each letter name with whitespace.
• You must output the names of the letters, not the letters themselves (so A B C... is invalid), unless the letters are literally pronounced so in the language in question.
• If a language uses both capital and lowercase letters, then you may output the letter names in either case. If it uses only one of them, then you must output the alphabet in that case.
• You must use a different language's alphabet for each program, but you are allowed to use the same script in the context of different languages.
• Constructed languages are allowed, as long as they predate the challenge.
• You may use different programming languages for each program. Or the same.
• Standard loopholes are forbidden.

TODO:

• is the requirement against sharing any codepoints too strict?
• I haven't downvoted you, but suspect that the major reason that you're getting downvoted is that it's totally unclear what outputs are valid or not, and skimming the edges of that is where most of the byte savings are going to come from in a code-golf. That said, I don't think this is code golf, despite having the tag. You'll probably find that, when any golfing aspect is removed, the strings to print are more or less irrelevant, so you might as well use a fixed, objective set of strings instead of the ones you have. – ais523's temporary account May 13 at 16:24

# Count the Trees

## Challenge

Given an input consisting of ASCII art of trees such as

  0            <
|      >       @
|   @          |    0
|   |    #     |    |
|   |    |     |    |
==========================


count the number of trees present (5 in this case).

## Rules

### Input

• The input might not have all lines at the same length.
• You can take your input from stdin or take it as a string argument.
• There will be a ground as the last line, consisting of = characters.
• All trees have a straight trunk of | characters.
• The crown of the tree can be one of 0@#.
• Each tree will have at least one trunk character.
• You may assume that there is at least one tree.
• Unfortunately, there might be birds (< and >) photobombing the ASCII art. They should be ignored.
• If you find a bird on the ground, then it is dead and another tree will grow in its place tomorrow (carcasses make great fertiliser). In the ASCII art below, there will be two trees tomorrow:
   #
|   <
=========


### Output

• Output the number of trees that are present today and those that will be present tomorrow.

### Test cases

  0            <
|      >       @
|   @          |    0
|   |    #     |    |
|   |    |     |    |
==========================


(5, 5)

   #
|   <
=========


(1, 2)

 0#@
|||
|||
=====


(3, 3)

• What about languages that can't handle input over multiple lines? Can the input be taken as a list of strings? Or a single string with \n as separators? Also, the task is basically just counting all non-space characters on the second line from the bottom. The birds in the air, different crowns etc. won't affect the answers in any way. MATLAB: @(s)nnz(s(2,:)-32). – Stewie Griffin May 23 at 10:16
• A single string should be fine; a list is not acceptable. And thanks for pointing out the shortcut. Maybe it would be better to require validation? – bb94 May 24 at 15:50

The heights of Natural Numbers

Every number can be expressed as the product of itself and/or smaller numbers. This is a fundamental feature of our world.

For example 10 can be expressed as the product of 5 and 2, or as the product of 1 and 10.

9 can be expressed as the product of 3 and 3, or 1 and 9.

12 can be expressed as the product of 2 and 6. 6, in turn, can be expressed as the product of 2 and 3. It could also be the product of 3 and 4, and in turn 4 is the product of 2 and 2. Lastly there is 1 and 12.

7 can only be expressed as the product 1 and itself.

The numbers in the products are called factors. Every number has at least 2 factors, itself and 1. Numbers with only those two factors are called prime. Numbers with more than 2 are called composite.

These factors can be written as trees. The root begins with the number itself, and factors are written below, by adding branches to the root.

7 has 1 and 7. This is a short tree. It has one prime.

9 has 3 and 3. This is also a short tree, but it has two branches. It has two primes, but they are both at depth of 1 down the tree.

10 has 5 and 2. Again, short. Again, primes are at depth 1.

12 has 6 and 2, 6 has 3 and 2. This tree has two levels of height. Note that at the second level, every factor is prime, but at the first level, some factors are composite. 12 has also 3 and 4, and 4 becomes 2 and 2 - the tree looks similar to when using 6 and 2, this is called Isomorphic, which comes from the Greek language words for same shape.

In other words, every number has several trees of factors, and each tree has leaves that are prime factors. And every tree has a height, the number of branches one must travel between the root and the furthest leaf.

For example, every number has a tree of height 1. Itself and 1. So.

7 has height 1, because 1x7=7

9 also is height 1, because 3x3=9, and 1x9=9, are both of height 1.

12 is height 2. 3x2x2 becomes 3x4, which becomes 12. There are two branches between 12 and either leaf of 2.

But 12 is also height 1 because it has a different tree of height 1: 1x12=12.

16 is height 3, because 16 becomes 2*8 becomes 2*2*4, becomes 2*2*2*2. But 16 is also depth 1 because 1x16=16. However 16 is not depth 2, because no tree of it's factors has primes up two branches from the root.

Write a program that given an integer n, returns a sequence of the first 100 numbers that have prime factor trees of height n.

• The prologue about factors and primes is unnecessary-- we know what they are. A diagram would be nice. You didn't explicitly mention the rules for creating trees-- why can't 16 = 4x4 = (2x2)x(2x2), or 16 = 8x2 = (8x1)x2? Are depth and height the same? – lirtosiast Jun 29 at 7:12

## Code-challenge: Guess my number

### The challenge

You have a number from 1 to 10 in mind, and your program should ask questions to find out which number. These questions can be any questions, the program only has to find out the number as fast as possible.

Your program should ask a question, such as "Is the number a prime?", and the user must answer either y or n (yes or no). Ask questions until you know the number.

### The scoring

To calculate the score, you need to take the sum of the question count for each number. For example, if you need 1 question to find the number 1, 2 questions to find the number 2, and so on, the score is 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10, so the score is 55.

Important note: the question count for a specific number must always be the same. For example, if you need 4 questions to find out the number 10, then you have to ask always 4 questions to find out the number 10, otherwise it is impossible to calculate the score.

• boooring. The Huffman tree for a uniform set is any perfectly balanced tree. The question asks us to perform a binary search on the usr device. Is the number greater than 5? Is the number greater than 2? Is the number greater than 1? Hey' I think it's 1. – John Dvorak Jan 2 '14 at 11:49
• Maybe if this were a pop-contest and the goal was to make the most original set of questions while still keeping the score at its theoretical minimum. – John Dvorak Jan 3 '14 at 5:28

Bovine Ignorance

I'm curious about code which still works after being mangled by figlet, toilet, cowsay et al, but I'm not sure whether this in any way sane.

What I'm toying with is a challenge in which a participant may submit any program in any language. It should be possible to use this program's source code as input to cowsay or whatever, and the result should be another valid program in any language, which still does a similar thing. For instance, the following bf program prints Hello world! with no newline:

+++++ +++++
[
> +++++ ++
> +++++ +++++
> +++
> +
<<<< -
]
> ++ .
> + .
+++++ ++ .
.
+++ .
> ++ .
<< +++++ +++++ +++++ .
> .
+++ .
----- - .
----- --- .
> + .
+++++++++++++++++++++++++++++++++++++++++


Running cat ./prog.bf | cowsay -e .. -T $'>.' yields the following output:  _________________________________________ / +++++ +++++ [ > +++++ ++ > +++++ +++++ \ | > +++ > + <<<< - ] > ++ . > + . +++++ | | ++ . . +++ . > ++ . << +++++ +++++ | | +++++ . > . +++ . ----- - . ----- --- . | | > + . | | +++++++++++++++++++++++++++++++++++++++ | \ ++ / ----------------------------------------- \ ^__^ \ (..)\_______ (__)\ )\/\ >. ||----w | || ||  Which is itself a valid bf program which prints Hello world!!!, followed by a newline. The problem with using bf here is that it ignores most of the cow, making this a bit too easy. The problem with using any other language is that it doesn't ignore most of the cow, making this far too difficult. Is there a sensible middle ground I could pick for this? I don't think it's impossible, I'm fairly sure you can exploit cowsay's behavior on one-liners to produce valid svgs, but I'm not sure how best to pose this challenge. Any ideas? • I could not think of any language that falls in the middle ground. Even brainfuck is affected by the -----------------------------------------..>.---- inserted by cowsay. Most languages have strong parsing rules that would not cope with being post-processed by cowsay. The few exceptions for this will be either completely unaffected or badly affected, making the challenge uninteresting. – Victor Stafusa Feb 19 '14 at 12:32 • Actually, you can't transform just any brainfuck program to cowsay-brainfuck. Namely those that can output fewer than three characters cannot be transformed at all. – John Dvorak Feb 19 '14 at 14:52 • @JanDvorak, I was intending to allow competitors to choose the parameters of their calls to cowsay. For the uninitiated, -e controls the string used for eyes and defaults to oo, and -T controls the string used for the tongue, defaulting to  U. This is all yak-shaving, though, and having written this up and read the comments, I suspect that this idea has neither legs, horns nor udders. – ymbirtt Feb 19 '14 at 23:19 • If I could propose a variant that is more feasible, you could do a challenge like "Write a program in your language of choice that draws ASCII art of a cow saying something (does not have to be identical or even similar to the cowsay art). The entire drawing must itself be valid source code that does something other than no-op. Post results of both programs." That gives people more leeway to work around the specific restrictions of their compiler. – Jonathan Van Matre Feb 21 '14 at 23:22 • Ok, I found a language that falls within the middle ground: whitespace. Anyway, this question has a too narrow scope to develop an interesting challenge. – Victor Stafusa Feb 22 '14 at 18:31 • @JonathanVanMatre That would be a subjective validity criterion, and would probably be closed as too broad. – wastl Jul 2 '18 at 13:55 # Output the number of lines of your code Your task is to write a program that counts the number of its lines of code and outputs them. Specs: • The number mustn't be hardcoded into the program, nor in any other external resource; • Internet access is forbidden; • Your program's output must be the number of lines only; • Your program should not use any tool, macro, function, or similar device designed with the specific purpose of counting lines. • I don't see much of a challenge here. wc -l$0? – ugoren Feb 23 '14 at 17:15
• It can be a nice question, but needs some work. Just add something like "it should not use any tool, macro, function, or similar device designed with the specific purpose of counting lines". – Victor Stafusa Feb 24 '14 at 2:10
• @Victor Nice point, added. Thank you :) – Vereos Feb 24 '14 at 10:10
• As long as you can read the program file, it's no challenge. E.g. print len(l for l in sys.argv[0]). But if you forbid reading the source, and forbid hard-coding the length, what's left? – ugoren Feb 24 '14 at 14:00
• @ugoren I don't see where it says it can't read its source. – Hosch250 Feb 27 '14 at 22:13
• @user2509848, It doesn't. This is why the question is easy and uninteresting. – ugoren Feb 28 '14 at 5:56
• @ugoren If you can't though, how will you tell, hardcode it? – Hosch250 Feb 28 '14 at 5:57
• @user2509848, Either way, not a good question. – ugoren Feb 28 '14 at 6:25
• This is one byte in any golfing language with implicit output: 1 – Nic Hartley May 9 '16 at 20:11

# Create an Identicon Generator

The challenge is to create an identicon generator. The identicons must be randomly generated, so we get a new identicon for each key the program receives. You can input a key using std-in or you can use your language's random number generator for the key.

In order to make your identicon look reasonably nice, it must generate a picture, then rotate that picture around the bottom right corner, the way this mockup shows:

The output must be to a PNG file. Shortest code wins.

• Far too broad. As this stands I can create a 1-pixel image whose colour is just the key. I don't think this question will be ready to go until you've found a way to prevent me from making the images differ only in their palette (and to pre-empt, I think that adding a rule "Images may not differ only in their palette" isn't a real fix). – Peter Taylor Mar 28 '14 at 14:50
• If you just ask for "random" images, you'll get images that are either hardly random at all (a solitary pixel in a random location), or completely random (noise). To get something "reasonably nice", you'll have to provide very clear instructions on how to produce these images. I suggest you try creating a few of these yourself, and find a minimal set of rules that produces results that look OK. Include requirements on dimensions (100x100px?), selection of colours (at least 2, not too similar), and drawing method (e.g., "five triangles with random vertices and a minimum area of 20 px²"). – squeamish ossifrage Mar 28 '14 at 15:25
• How important is the PNG file output? This will be a challenge in itself for many languages. Would you accept an uncompressed non-interlaced format like PPM? – trichoplax Apr 16 '14 at 9:45

## Underhand Bejewled

Help me to write a game of bejewled, which cannot be lost!

## Bejewled game rules

If you ever played bejewled, you can skip this, but for those who did not see it ever:

• Playing field of 8*8 grid is filled in with gems of 7 different types randomly
• By swapping two adjective stones, your goal is to create a line of at least three same type of stones in the either vertical or horizontal line
• If did so, the gems will dissappear, points are added (say 20 points for a matching) and new gems are provided randomly from the top
• image related:

Provide me a game which cannot be lost. In other words, the gems falling from the top are not random at all, but are falling in order that there is always at least one possibility to match three gems

But, from looking at the code at level of newbie programmer, it should look like that game acts as if it was random

## Output

Playable game. As long as it is the grid of 8*8 filled in with 7 different types of "gems" the game is ok. It does not to have killer graphics, neither it does not need to be playable by mouse. (But in that case please make sure you show which "gem" is hovered and then selected)

## Winning criteria

This is popularity contest. So highest rated game wins

• I think this is too big a task to work well for an underhanded contest. The programs will be way too large for anyone to actually read the source and try to find what's underhanded about it. – Martin Ender Nov 11 '14 at 8:32
• Thats what I was also afraid of. I will either take it as lesson to progress on my programming skill, or abandon the idea completly – Pavel Janicek Nov 11 '14 at 8:38

This and this gave me an idea, but I'm not quite sure if this can be done at all, or if it is trivial. If it is, maybe point out how it could be changed to be interesting.

# Anti golfing - Write the longest program not repeating any character

Well, it's just what the title says. Finally you're allowed to use as much bytes as possible.

## Conditions

• The code of the program or function should not use any character that is used in the code before.

• Your program should print some sort of result to stdout, or into a file or return a value. You're not allowed to output or return the empty string or only a newline.

• Other than that your program might do anything. Read input, print lots of output, or what you can think of, but you have to explain what it does, of course.

• Only characters in the ASCII range [32 .. 126] and newlines are allowed, which limits the maximal code length to 96 bytes.

• Variable names are only allowed to consist of a single character

• String literals or the like are forbidden. They could be used to hold the unused characters (though they would need two " in most languages anyway).

• The same rule applies for similar literal constructs like blocks or what else is there in some languages.

• Even if the length of a string literal would be used to generate a number, it is forbidden.

• Variables can not just be declared and never be used. They have to be reflected in the output somehow.

• If you've read and understood the above rules and still found a loophole and used it, you should go and stand in the corner for a while, thinking about what you've done.

So all in all, only use characters for actual code that does something generating the output, might it be calculating a value or formatting. And don't put unused characters somewhere in your code as a literal. Numbers are an exception, but I guess it's no problem to use them anyway.

I guess you should have a pretty good idea of what would be considered cheating here.

Example in awk

BEGIN{gsub(a,9);print $j-13+d^c/4*5678%20}  It prints 15.5, score is 42. It replaces the empty string a with 9 in $0, which is the empty string in the beginning. So $0 becomes 9. Then it prints the result of 9-13+1/4*5678%20. ($j is $0 (==9), because j is not defined d^c ist 1, because c and d are not defined) Please don't invent languages for this ;) The longest code in bytes wins. • Are you sure you want to allow ASCII 127? That's the unprintable<DEL> character. The main problem with this challenge is "only use characters for actual code that does something". This is essentially unenforceable, because there may be arbitrarily complicated no-ops in the code. It's also why most code-bowling challenges fail to be popular/interesting. – Martin Ender Sep 14 '15 at 7:32 • Well, I thought about making it a "most votes win" challenge, but I guess that would be unfair for less known users. I don't know what could be done with what you are pointing out. – Cabbie407 Sep 14 '15 at 7:51 • I don't think this is a good candidate for a popularity contest. Popularity contests shouldn't be used as a cop out if the actual spec is a bit vague. They work best for challenges where the actual scoring criterion can be well specified but is more easily judged by humans than machines (e.g. "visually approximate a given image with these constraints..."). – Martin Ender Sep 14 '15 at 7:54 • Yeah, it's hard to formulate the rules for this. But I think it's not always about finding a winner anyway. Thought this might be fun. Resolved the character 127 situation btw.. – Cabbie407 Sep 14 '15 at 7:57 • How could I change that rule? I'm thinking about "only use code that contributes to the generation of the output" – Cabbie407 Sep 14 '15 at 8:02 • How do you define "contribute"? E.g. this GolfScript program prints the length of the block in {...} which is a convenient way to stuff all characters except in '"# in there. Do all those random characters actually contribute? In Slashes everything which isn't an unescaped slash is printed to STDOUT, so as long as I put \/ together, I can put any characters I want there and they'll all contribute. – Martin Ender Sep 14 '15 at 8:07 • Hmm, I thought this would be covered by forbidding string literals.. might think about extending that rule to blocks. Well, I'm not that fluent at esolangs. – Cabbie407 Sep 14 '15 at 8:10 • It's trivial to use all possible 96 bytes. Trust me. If you really want to see the program I'm thinking of, I suppose I could write it, but I'm pretty sure it can be done. – mbomb007 Sep 16 '15 at 18:34 • Yeah, I guess you're right. i have no idea how it would be done, but alright. – Cabbie407 Sep 16 '15 at 20:10 • Not to mention this is pretty much a duplicate of codegolf.stackexchange.com/questions/30159/… – pppery Aug 6 '17 at 12:52 Here is my first attempt at a cops and robbers post (which is why I'm using the sandbox). # Cops - Golfed recursion You must select a language that satisfies the following criteria: • Functions - It must be possible to create a function with any number of integer input values and a single integer output (or return) value. The function may also be a complete program in itself. (Your language may not call it a function, but that is ok) • Arithmetic operations - The integer operations +-*/% should all be possible, either in a simple or a complicated manner. • Data - You should be able to store one-byte or two-byte long integers (either signed or unsigned will do). You may do this also in an indirect manner. • Iteration - You must be able to create a loop that will keep running until a condition is satisfied. Therefore < > = <= >= ! & | should also be supported, either directly or indirectly. • Recursion - You should be able to call a function from within the function itself with a set of input values calculated by the main function. • Declaration - You should be able to declare new integer variables as needed from within the function. ## Task You need to create a recursive function. Code will be scored by the number of characters in it, the shorter the better. A solved code cannot win the challenge. A post with less than 5 up-votes cannot win the challenge. There will be no overall winner, but a separate winner for each language. # Robbers - Golfed recursion Your objective is to pick up a cop's post, and write a function in the same language but it should not use any recursion (can use iteration). The function may create any number of variables, loops, etc. but should be able to achieve the exact same end result (atleast, in theory) as the cop's one. Your score will be the same as the cop's post's score at the time it was solved. His/her post is now invalid, and you get his/her score • I don't understand how a cop can write an answer that isn't going to be cracked, unless the language of choice can only loop via recursion (which I think you're trying to rule out by requiring that "iteration" must be possible). Also, requiring 5 votes to be a winner is only encouraging tactical voting. Answers that are actually invalid will likely get downvoted and deleted anyway. – Martin Ender Feb 10 '16 at 12:36 • @MartinBüttner Maybe in some languages it is possible by exploiting both closure and recursion, but I mainly agree with your point: recursion and iteration are two ways to do the same thing. – Katenkyo Feb 10 '16 at 12:41 # Stop the dance! Your sister was at the hospital, but now she's fine, awfully, you lost a day of work, one of your most important days. You work at your local television, and they have a contest, called "Stop the dance!", what is it about?: People is dancing, they have a big screen in the wall, while it says "Dance!", they have to dance, if it says "Stop!", they must stop, if you move, you lose. You don't have internet at the studio, so you use some strange offline data sharing method. The day you weren't there, another programmer came, such a silly programmer! He made a "Reciever" program, basically, gets data, processes data and prints data in the Big Screen Wall. The programmer was bored, so he made a way to get data, well, you don't know what way he choose! (Author comment: Let's assume he made all the possible ways. Cya.) Now you have to make a sender program, in any language, that sends data to that program using the protocol specified under this section. You are an expert code golfer, so you decide that you must make the shortest code possible. (Another author comment: Any lang is allowed. Cya.) # How did I came out with this idea? Having a shower, my friend... # Your task You must make the shortest (and winner) code possible, that sends data to the reciever, using this protocol: The reciever must recieve: $displaytext:"<text here>";$instnm:<integer here>;$displaytext corresponds to what it is going to be displayed on the Big Screen Wall.

$instnm corresponds to the number of the instruction, the count of things displayed, starts from 1. Your program may take an input, and send the data, in any way (except the ones in Rules) to the Reciever. Remember there's no internet. The winner will be the user with shortest bytes of code. # Rules ## As a good code golfer, you may not: • You can't use program arguments to send the data. • It must be an application. • If you apply for the bonus, mind you have to make both programs, if not, just the sender. • The string you have to send it has to be STRICT, no different ones, if not, unvalid answer. (I decided to call that "Strict JASON Protocol", get the joke?) # Bonus You can make the reciever program, and you get -1 byte. Not much, but k. (In bytes, you must not decrement your byte result, you must do: "n Bytes + Bonus") # Example Input and Output ## Input: From Sender program: Dance! or Stop! ## Protocol: Inbetween both commands $displaytext:"Dance!";$instnm:5 ## Output: In Reciever program: Dance! (9) or Stop! (187) # Overall objective: Send data between two programs, without internet connection. Edit: i can't post an example answer, because then i can give ideas of how to do this codegolf/puzzle, while the ideas are limited, i'm finding for the creativity of the user. • I have no idea what you're asking me to do. – Peter Taylor Feb 3 '16 at 21:26 • It is pretty clear what is asking you to, is defined in Task (You must make the shortest (and winner) code possible, that sends data to the reciever, using this protocol), all the story and background is defined on Introduction. I dont see any hole on the post. – TheCrimulo Feb 3 '16 at 22:11 • @TheCrimulo Example answer? – Akangka Feb 7 '16 at 7:06 • There is no Example, because you are just sending the same info you wrote in. If you type ´Dance!´, the output will be Dance! (n), n being the number of the sequence. The idea isn't to read input, and append (n) to it. You have to make it, in anyway (except command args/internet), dropping out the enoded data (input in the protocol), and, if necessary, make a reciever program, the reciever program its a bonus that discounts 1 byte, also, it can help you making your sender smaller. I can, i.e., make a file with the info on it. As explained, the reciever will read it. – TheCrimulo Feb 7 '16 at 15:54 # Biggest single character This challenge is simple, its like the challenges we've had before where the goal is to produce the biggest output one can. But in this one, you can only use one character in your code. You get no input, your code has to be a single character (not byte), and the person with the largest output in byte wins, ties broken by posting time. • Doesn't this boil down to which language has the biggest output stored in a predefined variable? – Denker Apr 3 '16 at 20:50 • @DenkerAffe true. maybe i should make it 2 byte src code. that might allow some interesting stuff – Maltysen Apr 3 '16 at 20:52 • I think I would raise the char amount a bit more to allow for some competition between the same language. Also you should keep in mind that this rules out every non-golfing language. While this should be allowed per meta consensus, I am not sure how much the community likes this. – Denker Apr 3 '16 at 20:58 • G for pyth wins :D :D – Leaky Nun Apr 4 '16 at 4:45 • Befunge & co. would probably win via infinite output. If output has to be finite though, I wouldn't consider this a very interesting challenge since it would just be one big language hunt. – Sp3000 Apr 4 '16 at 10:27 • Actually, N in Seriously wins. 11752 bytes output. – Mego Apr 6 '16 at 4:06 • @Mego Vitsy wins. 0 bytes, 11752 bytes of output. – Addison Crump Apr 7 '16 at 17:07 # Linear Time Sorting It was another slow day at Initech Inc. when a feature request came in: New Feature: Ability to sort by cash value in the transaction form. But make it a fast one!  Well it looks simple.. but what do the requester mean by fast one? Let's call Jim, from sales he probably knows what's going on. Jim: Well you know , our Business Inc. contact is very passionate about programming and computer science! In fact he had this idea that we should do sorting in how that was called.. linear time? You: Well you know that's impossible? Jim: But it was already approved by their cto and all! You need to do something  You and Jim came up with a plan.. nobody will notice if that big of a list isn't sorted enough, right? # Your task Your task is to write a linear time sorting program. It will be scored on accuracy of the sort as compared to list sorted by regular sorting algorithm but it must work on O(N) time in the worst case, where N is length of the input. Input will be in the form of list of string-double tuples, e.g: [("aaaa",2.0) , ("aaba",1.0)]  The program should sort on the number value of the tuple, i.e. in the above case the order should be reversed. There may be multiple inputs with the same double values, but no string value is repeated. In the event that two inputs have the same integer value the perfect solution is to keep the order as it is. The double value may be any floating-point value that fits in 8 byte double precision variable. NaNs should be placed at the end of the list. The score is calculated as number of "bubble sort operations" (switch an element with the next/previous element) needed to achieve perfect output from the output of your algorithm. # Sandbox Worries Well I don't know how clear my explanation of challenge was and if it is interesting to the PPCG crowd. Obviously there is a need for testing program and test cases. • How big will the test cases be? If you pick a fixed size, the response will be "n passes of bubble sort where n is the size of the largest test". Bam, linear with perfect score. – John Dvorak Apr 11 '16 at 10:12 • @JanDvorak I rephrased the scoring sentence to more reflect what I meant. In that case the score wouldn't be perfect as after just n switches the list wouldn't be the most ordered. EDIT: I think I understood it now. Well I think you can somehow exclude answers like that with some caveats in the rules, like "Your algorithm cannot make any assumtions about length of the input" – Lause Apr 11 '16 at 10:17 • I don't make any assumptions. It sorts every array up until the largest test case correctly and all other arrays partially. – John Dvorak Apr 11 '16 at 10:28 • An algorithm that fares better than n-pass bubble sort is to do a level-n mergesort. If the length exceeds 2^n, sort each [k::len/2^n] subarray separately. – John Dvorak Apr 11 '16 at 10:32 • But then you're making assumptions based on the size of the test cases - if somehow the test cases were changed (but still fitting the rules) to test cases which are much longer (for example you prepared for max 10 element list and you get 100000 element list) your program isn't linear. – Lause Apr 11 '16 at 10:41 • The problem with a spec is that it cannot change once you've posted the challenge, and you can't define "making assumptions based on the size of the test cases". You can't even ban all magic numbers - I can simply use functions merge1 .. merge20 – John Dvorak Apr 11 '16 at 10:47 • It isn't the spec - the way the test cases used to grade the result are constructed is described but do I have to post the test cases (but those used to score) themselves? – Lause Apr 11 '16 at 10:50 • You need to define the test cases, and you can't change them based on the answers (if only because updating the score of every answer would be a nuisance). Maybe you could ask for asymptotic behavior, but that can be surprisingly hard to measure. – John Dvorak Apr 11 '16 at 10:53 • Hidden test cases are a problem as well, because then we can't test the submissions after you're gone. – John Dvorak Apr 11 '16 at 10:55 • The idea was to pregenerate some test cases (undisclosed) and some test cases that are disclosed (for testing purposes during the coding) and then do a cutoff time for the challenge where all the solutions are tested against the undisclosed challenges. Also obviously after the cutoff time the test cases would be disclosed. – Lause Apr 11 '16 at 10:56 • 1. Most real-life data types can be sorted in linear time, so the premise of the question seems badly flawed. 2. "Input will be in the form of list of string-double tuples ... There may be multiple inputs with the same integer values" Huh? Where do the integer values come from? 3. "The double value may be any floating-point value" Where do NaNs sort? – Peter Taylor Apr 11 '16 at 16:00 • 1. The idea is that the data may be the worst case for any algorithm that can achieve linear sorting time 2. It was a typo 3. At the end - I will put it into the question – Lause Apr 11 '16 at 18:36 • Why does the input being worst case make any difference? The solution will still be perfect, so you'll need a tie-breaker to separate every single answer. – Peter Taylor Apr 11 '16 at 21:27 # Alphabetization 101 (popularity contest) Your task is to use all 52 letters of both the uppercase and lowercase alphabet, ONCE and ONCE only, and make a program. You are free to use any other ASCII character more than once, or use a letter of the alphabet more than once if it's required for the language to function. ## Meta: • Not sure if this has been done before. • Any questions regarding the task? • Not really meta: Is there any place I can go to (like a chat or something) to post a question about BF? StackOverflow probably isn't suitable. – Qwerp-Derp Apr 17 '16 at 6:48 • Come to our chatroom! :) – Leaky Nun Apr 17 '16 at 6:50 • I would vote to close this as too broad. It's not a particularly interesting restriction per se, and it certainly doesn't make a good question without some restriction on the task to be performed. – Peter Taylor Apr 17 '16 at 14:07 • @PeterTaylor That's why it's a popularity contest, though - it lets the people decide whether the program made is good or not. What WOULD be a good restriction on the task? – Qwerp-Derp Apr 18 '16 at 1:40 • The popularity-contest tag is not an excuse for a broad challenge. "Write a program that does anything..." is pretty much the definition of "too broad", regardless of any source code restriction put on the program. So at least you should choose a specific task. Could be anything really, but if it relates to the restriction it might be more interesting (e.g. a pangram checker). Even so, I agree with Peter that the restriction isn't particularly interesting. There are tons of languages where it's trivial to avoid unwanted letters and then include the remaining ones in a string or comment. – Martin Ender Apr 21 '16 at 7:04 # Why did I come to Sandbox? I have a very specific challenge, and I wanted to see if it was too specific. The challenge is to output "Valdosta ACM" using the shortest number of characters with the BrainF**k programming language. I've noticed it isn't the norm to specify a programming language on this domain, so I've come here to get feedback on whether or not this is acceptable. # Introduction As a challenge to the members of my local Association for Computing Machinery(ACM) chapter, I asked them to produce the shortest Brainf**k code that would output "Valdosta ACM". This was a very fun challenge for all of our members, and we got very competitive! I was impressed with the solutions turned in, but I wondered if it was possible to beat our best solution. Surely it's possible, but who could do it? # Challenge Output the string "Valdosta ACM". Stipulations: • Use only the Brainf**k programming language (you can test your code here) • No input can be accepted by your program • Your program must halt • The space in the string must be ASCII character #032. These are the ASCII values of each character, as they appear in the string, for convenience:  086 097 108 100 111 115 116 097 032 065 067 077  The winner is determined by the shortest code, by character count. # Example Input and Output ### Input: NO input is allowed ### Output: Valdosta ACM • Welcome to Programming Puzzles & Code Golf! Thanks for using the Sandbox. :) A few things to note: 1.) Generally we discourage language-specific challenges, 2.) typically code golf is scored by bytes rather than characters, and 3.) printing a fixed string like this would be insufficiently different from the Hello, World! challenge to avoid it being closed as a duplicate. – Alex A. Apr 25 '16 at 3:38 • Thanks Alex! Since I want to compare the results of my local competition with the results of the challenge here, is there anything I could change about the challenge to make it acceptable? I don't see a way to do this, but I was so excited about seeing if anyone here could do better than our coders. And thanks for the warm welcome! :) – Matt C Apr 25 '16 at 3:48 • You could look at Brainf**k solutions to other challenges (like this one), and see if the techniques used there can help you improve your solution. – ugoren Apr 25 '16 at 7:09 • We also have a tips question that may be of interest. – trichoplax Apr 26 '16 at 6:30 • Although this particular challenge is probably too similar to "Hello, World!" (as Alex pointed out), if you had a different challenge that you wanted to see solutions for in a specific language, you can still post it but just allow all languages to compete. If you don't see solutions in your specific language you can post a bounty for that language to encourage it. – trichoplax Apr 26 '16 at 6:33 # The FitnessGram™ Code Golf Test Same concept and rules to the well-known Rick Astley post a while back, only instead of using samples of various sizes, sample length is limited to what number sample it is. And different text for the program to write. It's code golf, so standard loopholes apply, and fewest bytes wins. • Closed as a dupe. And/or unclear. – Rɪᴋᴇʀ May 19 '16 at 20:04 • Paragraphs of text are boring for compression. Unless there's some particular structure in the text, the same techniques apply to all of them. – xnor May 19 '16 at 20:07 • First off, thank you for using the Sandbox before posting on main. That said, I don't understand what your challenge is supposed to be: what is the sample length? What is a sample? In addition to that, if this challenge winds up being "print some fixed string" then it is a duplicate of the rick astley post, as the techniques used for compression will be identical. – FryAmTheEggman May 19 '16 at 20:09 • we want to give them a challenge, not a flashback.... – user56309 Aug 4 '16 at 19:42 • This sandbox post has had little activity in a while and little positive reception from the community. Please improve / edit it or delete it to help us clean up the sandbox. – programmer5000 Jun 9 '17 at 14:12 ## Cops and robbers : Programmers/Hackers • This challenge is quite different from my previous challenges. This challenge is an endless competition between robbers and cops, which are respectively hackers and programmers. One of them will ever win!!! • This will evolve to code de/obfuscating when it gets to the higher stages: a skillful programmer who is struggling to save his program from a sourcecode-mangling attempted by a cunning "robber" who tries to impose his existence by patching his name instead of the name of the "programmer" in the output console without changing anything else in the code. The story begins this way: • Programmer is at the point of executing his recently made C code, so he included this trivial line to show off: C (1)  printf("[Programmer's username]")  After executing this program programmer saw this on the screen: [Robber's username]  which indicates the presence of some evil code at the compiler level that compromises his code, which follows: Matlab (2)/parser  a=findstr(code,'printf(''[Programmer's username]'')'); if a code(a:20)='printf(''[Robber's username]'')';end  The programmer cannot modify the counter-program in the compiler, so he must rather change the program content to escape the twiddling: PHP (3) $a='[programmer's username]';echo $a;  The score is now 3, which is the number of steps from the beginning. The current user would win only if the hacker did not figure out something like: PHP/Regex(pcre flavor) (4) $code=ereg_replace("(\$\w)\='programmer';(.*?);echo\s\1","\1\='robber';\2;echo\s\1",$code)


Since the solution above does not satisfy the rules (see the bottom of this question), the score stays unchanged, and the programmer can make a counter example, and take out the score from last submitter with a penalty on his score equivalent of how much he earned in the earlier level, where the counter example can be something as:

PHP (4)

      $a='programmer';$b=$a;$a='unrelated';echo $a;  Or he can adjust his program in higher scale to escape all the regex-trapping in a superior range, So the cycle goes on until no post can be added and the last submitter before the end of June is declared a potential winner meanwhile. The hacker can also fix his regex and regain his score, so the recent scoring will be abrogated from programmer. Perl/dynamic-regex (4) local @a=(''); sub check{ if (grep {$_ eq @_[1]} @a)
{push @a,@_[0]; }
elsif  (grep {$_ eq @_[0]} @a) { my @del_indexes = grep { @a[$_] eq @_[0] } 0..$#a; foreach$item (@del_indexes) {
splice (@a,$item,1); } } return 1; } sub actor{ if (grep {$_ eq @_[0]} @a)
{return "print robber";}
else
{return "print ".@_[0];}
}

sub initiate{
push(@a,@_[0]);
return 1;
}

$code =~ s/(((\w+)\="programmer"(??{initiate($3);}))|(print\s(\w+))|((\w+)\=(\w+)(?{check(($7),($8));})(?1)))/print($2);actor($5)/pegmx;


As you can see this Perl program prints b in the first case because the variable b is compromised after the first assignment, but in the second case the regex modifies the output because d receives the target-string transitively. Let's just stop here and not mess the fun (of course, if there will be some).

## Scoring and rules

How is the score counted ?

• Any hacker/programmer is scored for his code as the actual level L the game is on.
• A partial dynamic regex within the core of the program is scored L + (2^L)/log(length of program + length of characters which do not belong to the regex)), where the log is base 2. For the second example of level (4) the length of the compacted program is 480, and the length of regex is 136, so the score is 4+2^4/log2(480+480-136) ~= 4+16/9.6
• A fully functional regex as in the first example level (4) is scored L + (2^L)/log(length of regex), where the log is base 2, in that case S = 4 + 2^4 / log(91) ~= 4+16/6.5
• Scores are added progressively to submitters, and when a level is surpassed with no regex, it is still open for scores, while the actual winner remains unchanged.
• A penalty on a certain-leveled score when the regex/parser is revealed out of rules and the game is regressed to this stage until the issue is fixed, rules are cited below:

Rules:

• The main rule: the hacker-program must compromise an output to the console, which is the username of the programmer. Any other behavior is unaccepted simply because a string variable of [programmer's username] can be used in other order rather than printing, a counter-example is easy, converting the string to integer then use it for arithmetic calculations that harms the main program once intentionally modified.
• Also one of the following factors declared by any counter-example bans the targeted flawed regex/parser as non rule-complying:
• The regex/parser prints anything other than a chosen string preferably set as the username of the robber.
• The regex/parser generates a program which does not compile.
• The regex/parser does not print anything, or compromises a segment of code that is needed for tasks other than printing .
• The variable which stores the program is named code by default, also you may assume that is one-liner, and any non-significant spaces are omitted, and that it is fully working by default.
• The regex/parser deals with one variant of one code proportion in a comprehensive way, i.e. if a print function is used, that encompasses all printing functions in all languages puts,disp,..etc. Also, code separators can be unified to one characterL either , or ; or a significant space needlessly of enumerating all keywords/syntaxes, this is not a contest about a working code in a specific programming language.
• To prevent endless program/regex loops let's just not making a jokey sequence as a='programmer';print a / /(\w)\='programmer';print\s\1/ / a='programmer';b=a;print b / /(\w)\='programmer';(\w)\=\1;print\s\2/ because the first person who makes a regex/parser which palliates to a same replicated idea will take out all attributed scores to this idea from their owners, so any anaphoric sequences like this in addition that they are set to same level, they are unneeded.
• Any language that uses pointers/addresses/classes like C++ are welcome, as long as they help to evade the hacker.
• Please, for the love of god, spell things correctly. In the first bit alone I spotted a ton of spelling mistakes without even looking for them. Also, that whole first list is... basically impossible to understand, at least for me. Maybe use full sentences? – Nic Hartley May 10 '16 at 21:29
• Have you seen our cops-and-robbers challenges? It sounds like that is what you are trying to do here. That said, there are a couple of problems with the spec: Defining what parts of the language counts as a "partial regex" or "full regex" is really tough, especially when we get into esoteric languages. – Nathan Merrill May 10 '16 at 21:36
• Could you add a short summary to the post? I don't understand what the actual task here is. Is this a cops-and-robbers or answer-chaining challenge, or something entirely different? – Zgarb May 10 '16 at 21:36
• i will see what cops and robbers is – Abr001am May 10 '16 at 21:39
• @NathanMerrill this is not a code golf so i dont see the point of introducing esolangs here – Abr001am May 10 '16 at 22:28
• @Agawa001 Esoteric languages are still useful outside of golfing. You can use them to make it tough for regexes to match. – Nathan Merrill May 10 '16 at 23:06
• The introduction is very long and after reading it I have no idea what the task is. I would have to vote to close this as "Unclear what you're asking" in its current state. – Peter Taylor May 11 '16 at 7:45
• So what's the core mechanic? Is this an answer-chaining question where answers must alternate programmer and hacker? But if the programmer can change language at will, how can the hacker hope to win? – Peter Taylor May 12 '16 at 12:06
• @PeterTaylor yes it is answer chaining but the last submitter can post two consecutive answers and be the robber and cop themselves, the programmer change his code, hacker changes his regex taken consideration of all last regex/parsers. – Abr001am May 12 '16 at 16:13
• I have no idea what this challenge is supposed to be. The very little explanation of the concept is muddled by spelling and grammar issues. Please, learn English spelling and grammar before trying to write a challenge. – Mego May 13 '16 at 5:18
• @PeterTaylor refer at the 4th rule, procedures which accomplishes a specific task in different languages are dealt as one thing, this is not a challenge about checking language-syntaxes, when a programmer changes language, consider all previous regex/parsers changed to trap same functionnalities of previous code on the new language. – Abr001am May 28 '16 at 11:37

In this challenge, you must create a program which does something but you need to obfuscate it so that it becomes hard to understand (so don't explain it in your post).

It can accept anything as input and output anything.

Score

The shorter program (in bytes) which hasn't been understood wins.

Example

Can you guess what does this code calculate?

var t=1e5,s=t/1e4,n=s*0.1,i=n*s*7.5,r=!true,b=1,t='01'.split('').map(c=>parseInt(c)).concat(Array(i).join('.').split('.').map(m=>{a=r+b;(r=b)&&(b=a);return a})),t=t.join('').length,b=s,t=r,s=4+NaN;


Rules

• You should say what language you used
• You must not use any obfuscation tool
• At a minimum, you should state an actual objective: "obfuscate a program that does x". Otherwise it's just too broad and will likely be closed as such. You'll also need something else to explain the scoring, since "shortest that isn't understood" seems odd to me. Understood when? How do you show that it hasn't been understood? Do you mean something like Cops and Robbers?. – Geobits Jun 4 '16 at 19:06
• This sandbox post has had little activity in a while and little positive reception from the community. Please improve / edit it or delete it to help us clean up the sandbox. – programmer5000 Jun 9 '17 at 14:12

## Challenge

Write a program that takes an numerical input n and outputs the nth number that is not a perfect square.

## Rules

This is , so least bytes wins.

• What's the maximum expected input? Does it expect 0? How do we handle 0? Is there a requirement on the efficiency for large inputs? Also give some example inputs and outputs. – Patrick Roberts Jun 17 '16 at 20:19
• Here's some test cases I just generated: 1->2,2->3,3->5,4->6,5->7,6->8,7->10,8->11,9->12,10->13,11->14,12->15,13->17,14->18,15->19,16->20,17->21,18->22,19->23,20->24,21->26,22->27,23->28,24->29,25->30,26->31,27->32,28->33,29->34,30->35,31->37,32->38,33->39,34->40,35->41,36->42,37->43,38->44,39->45,40->46,41->47,42->48,43->50,44->51,45->52,46->53,47->54,48->55,49->56,50->57,51->58,52->59,53->60,54->61,55->62,56->63,57->65,58->66,59->67,60->68,61->69,62->70,63->71,64->72,65->73,66->74,67->75,68->76,69->77,70->78,71->79,72->80 Is this the function you expect? – Patrick Roberts Jun 17 '16 at 20:41
• Yes, yes it is. – weatherman115 Jun 17 '16 at 20:42
• Can you address my other questions please? Namely, the largest expected input and how to handle input of 0. – Patrick Roberts Jun 17 '16 at 20:43

## "01_firstHole" Challenge for Performance Golf

First there was code golf. Now, there is Performance Golf. FORE!

## Motivations

This is a crowd-sourced approach to easier and better performance troubleshooting. Performance problems are everywhere, so java technicians need access to easy-to-use diagnostic tools at every step of the SDLC.

## How to play?

1. Start by installing the live demonstrations of Java Performance Problems in this repo.

2. Pick one of the six holes of golf to play. You can do this by picking one of the six numbered folders in the repo. This particular codegolf.stackexchange.com challenge is for the 01_firstHole.

3. One at a time, run the 'a' load test and the 'b' load test for the hole you selected. The a & b tests are two different implementations of the same REST/SOA service. See the 'installing' link, above, for how to run the tests.

4. Compare the performance of the two tests, a & b. Which has better response time / throughput?

5. Using the least amount of tooling/instrumentation, identify the performance problem of the slower test. Hook it up your self and run the tests.

6. At codegolf.stackexchange.com, there is one "Stack Exchange Challenge" for each hole of golf. Post the following two things for your solution to that challenge:

• Post a description of the tools/techniques you used to detect the performance problem. Must be detailed enough so that others can reproduce your work. Performance golf always compares two different loads -- a & b. The solution must identify the inefficient code in the slower of the two examples. It must also show the absence of that inefficient processing in the faster of the two examples.
• Tally the number of strokes for your approach, using the "Scorecard" below. All solutions must specify the # of strokes incurred, and it must be specified in the answer heading/title.
7. Upvote the solutions that best identify the performance problem and have the fewest strokes (see Scorecard, below). Similar solutions on different platforms (Mac/Linux/MS-Win) deserve roughly the same number of upvotes.

## Scorecard

This scorecard determines the approach with the least amount of tooling/instrumentation. Lowest score wins!

• 1 stroke if JVM restart is required to hook up your monitoring tool of choice.
• 1 stroke for any tool with any  licensing cost.
• 1 stroke for every separate install process. No strokes for JVM and pre-installed OS tools.
• 1 stroke for tools/techniques specific to a particular Database vendor. Ex: Oracle AWR report. Even ‘EXPLAIN PLAN’ solutions are proprietary.

## Example One -- zero strokes :-D

This example does not use this github repo, but it will give you the general idea.

This solution to solving a high CPU problem would get lowest=best instrumentatin score: zero strokes. Only JVM and OS tools are used (thread dump and top -H). There are no tool license costs and a JVM restart was not required for the thread dump.

## Example Two -- 3 strokes :-(

This example also does not use this github repo, but it will give you the general idea of what we mean by the best troubleshooting with the least tooling/instrumentation.

A modern, commercial profiler (YourKit, JProfiler, etc...) would easily solve the high CPU problem in example 1. But look how many strokes (1+1+1=4!) are taken off with this approach: * 1 stroke because a JVM restart is required to hook up the tool * 1 stroke because there are licensing costs. * 1 stroke to install profiling the tool

• Answers in this site normally involve writing code, so this doesn't really appear to be on topic. – feersum Jun 16 '16 at 7:43
• Thanks for using the sandbox! I do however, see some problems with this challenge. For one, I think you would need to clarify a lot of the stroke criteria, as something like "rarely used" is pretty subjective. In addition, there doesn't seem to be a way to enforce a person to not use a high level tool, and then after figuring out the problem finding it again with a more basic tool. Even further, why couldn't someone look at another answer and then reuse their data to get a better score? cont... – FryAmTheEggman Jun 16 '16 at 13:22
• After all that, there doesn't seem to be an objective winning criterion, unless it is number of strokes. If number of strokes determines the winner, then won't there be many ties? I think you would need something more granular. – FryAmTheEggman Jun 16 '16 at 13:24
• Sounds like I need to work on the "rarely used" part mentioned by @FryAmTheEggMan. Regarding the same commenter's comments about the high-level tool and the basic tool. That is part of the natural progression of monitoring. We learn to do it one way, then we learn a better, less intrusive, less expensive way. As long as the user of the basic tool is "detailed enough so that others can reproduce your work", who cares how much refinement was involved? – Erik Ostermueller Jun 16 '16 at 22:45
• Regarding @FryAmTheEggman's question of "many ties". I look at auction sites like eBay as reasonable crowd-sourced arbiters of value of a given object for sale. I was hoping the voters would provide that kind of assessment, but I see where lack of objectivity could cause cronyism and perhaps other problems. Could someone point me to codegolf tolerance/lack of for ties? I'll try to work on that. – Erik Ostermueller Jun 16 '16 at 22:48
• @FryAmTheEggman, you mentioned that my "rarely used" criteria was pretty subjective. That's a good call, so just edited / removed that. – Erik Ostermueller Jun 18 '16 at 21:36
• @FryAmTheEggman, the "many ties" concern could also looked at from a different perspective -- that Performance Golf will provide a very useful "catalog" of answers. This "catalog" concept got 18 upvotes here. – Erik Ostermueller Jun 18 '16 at 21:43
• The catalogue concept is a failed experiment, and your mention of it is one of the reason why. "It's a catalogue question" should not be used to justify why a question should be closed even though it's off-topic and wouldn't have an effective scoring mechanism even if it were on-topic. – Peter Taylor Jun 19 '16 at 13:31

# Generate all variations of a string with every combination of upper and lower case for each vowel but leaving consonants and order of letters unchanged.

This is a simplified analog of a problem I've thought about a few times over the years based around variant spellings in different spoken languages.

Input is a text string. Output is an array of all variations of the text string.

A "variation" means the same letters in the same order but for each vowel letter in the string we generate a version of that string with the vowel in uppercase and the vowel in lowercase.

No variation should be included more than once. No legal variation may be omitted.

# Example

## Input

codegolf

## Output

• codegolf
• codegOlf
• codEgolf
• codEgOlf
• cOdegolf
• cOdegOlf
• cOdEgolf
• cOdEgOlf

The winner shall be the most elegant as voted by the community.

"Elegant" includes that the algorithm should be optimal in terms of Big O notation, should be concise, should be idiomatic making good use of available features of the implementation language.

Length of code characters or bytes is not relevant.

Programming language is open.

• "most elegant as voted by the community." I doubt many answers to such a challenge will be deemed elegant. – Fatalize Jun 23 '16 at 13:01
• Really? Anything to suggest instead? Just "best" is usually no good for Stack Exchange... – hippietrail Jun 23 '16 at 13:22
• Code golf version of this challenge: codegolf.stackexchange.com/q/80995/8478. That said, I don't think "most elegant" makes a good popularity contest and is very likely to be downvoted and closed almost instantly. If you're looking for elegant solutions, this might not be the right community in the first place though. You could write your own solution and post it on Code Revew to ask for improvements. We generally require objective winning criteria for our challenges, and popularity contests are in a weird place where you need to come up with something really good for it to be accepted. – Martin Ender Jun 23 '16 at 13:30
• Hmm well OK whatever. – hippietrail Jun 24 '16 at 11:55

# Make a Fork Bomb code-golf

under construction, please constructively (no pun intended) criticize

Create a program which forks itself at twice and exits, or forks itself once and idles. Whether it continues forever or exits is your choice. Forks can be OS forks or simply a command to relaunch the program.

## Rules

• No spoon bombs allowed, please.
• Don't make any assumptions about the location of the program.

# Bash, 10 chars

./$0|./$0&


Acts as a standard punching bag for other solutions.

# Microsoft Windows Batch file, 5 chars

 %0|%0


Anybody who beats this one gets a million internet points. (and maybe a bounty)

• I assume that the downvote is because someone considers that this violates our policy on malicious code. I think it's borderline, but if it's on the right side of the border then the question has other issues. 1. Why fork itself at least twice? Surely forking once is enough for a fork bomb? 2. Define "OS forks" in a way which doesn't rely on the OS being POSIX. Or, better, remove that requirement: it seems to me to limit the languages permitted more than necessary for no benefit. 3. What's a spoon bomb? Google is not being helpful. – Peter Taylor Jul 14 '16 at 13:49
• @PeterTaylor 1. the chat said it was fine 2. If you only fork once and exit, you have a constant amount of processes 3. Good idea. Any tips for windows forks? 4. it's a joke – noɥʇʎԀʎzɐɹƆ Jul 14 '16 at 16:38
• I'm downvoting because I think it's close enough to malicious. A fork bomb can hang a computer. – mbomb007 Jul 22 '16 at 19:27

# 2 Pass Hello world

You've heard about this fancy new programming language, but you're not sure you understand it perfectly. So you want to go over a new "Hello world" tutorial again.

How boring!

Instead you have a good idea, using your knowledge of the first programming language to create a "Hello world" program in the second programming language.

Exemple:

console.log('print "Hello world"');


Evaluated in javascript output:

print "Hello world"


Which, evaluated in python 2.X output:

"Hello world"


Nice, but, can it be shorter?

• We have a tag for multi-language challenges, polyglot. – Rɪᴋᴇʀ May 4 '16 at 14:06
• Pyth: \H (Guess what the second language is) – Leaky Nun May 4 '16 at 14:08
• Maybe add a scoring mechanism by how many languages it works in? e.g. console.log('print("puts\'Hello, World!\'")') would score len(submission)/num_languages_it_works_in? – Rɪᴋᴇʀ May 4 '16 at 14:09
• Then the submission above would score 0. – Leaky Nun May 4 '16 at 14:09
• (To OP) Maybe you would need to add some more rules – Leaky Nun May 4 '16 at 14:11
• @KennyLau no? 2/2 = 1 – Rɪᴋᴇʀ May 4 '16 at 14:11
• @EᴀsᴛᴇʀʟʏIʀᴋ It can be fed into itself for one more pass... – Leaky Nun May 4 '16 at 14:12
• I didn't want to add any recursive mechanism, because the end goal should be to display "Hello world" but a more than 2 language is a great idea. – nobe4 May 4 '16 at 14:15
• I don't see how you will be able to come up with a good scoring system for this. Using two esolangs / two times the same esolang will result in 1/2 bytes answers right away. – Fatalize May 4 '16 at 14:16
• @KennyLau, what rules do you generally add to a incomplete challenge? we thought adding a time/memory limit for the execution, but seems irrelevant... – nobe4 May 4 '16 at 14:17
• This is really closely related to several other challenges we've had on the site, such as this one and this one. You'll need to be very careful to not make it a duplicate. – AdmBorkBork May 4 '16 at 14:22
• Also this one, which is practically a duplicate, just with numbers instead of "Hello, world." – AdmBorkBork May 4 '16 at 14:26
• Yeah, I haven't seen all this, I guess I'll start searching for another idea instead ;) – nobe4 May 4 '16 at 14:29
• Also, welcome to PPCG! (I forgot to mention that earlier). Hope you enjoy yourself here! – AdmBorkBork May 4 '16 at 14:36

# Return True to Win - Counter javascriptcode-golf

Original credit goes to this site, which you should all check out

Write the shortest javascript code to pass as parameter f to function counter such that it returns true:

function counter(f) {
var a = f(), b = f();
return a() == 1 && a() == 2 && a() == 3
&& b() == 1 && b() == 2;
}


I'm considering also making this a series with all the rest of the challenges on the site, where each one gets harder

• Given the lack of a terms of use page on the site, the code on that site is copyrighted, with no provisions for reproduction. This is copyright violation. – Mego Aug 9 '16 at 6:00
• In addition to Mego's note regarding copyright, language-specific challenges are not typically well-received by the community. – Alex A. Aug 9 '16 at 18:18

# Stump The Golfing Languages

This is the seed of an idea. I'm unclear on the details that might make it work.

I want people to submit answers in the form of a program in a "normal" language (defined how?), such that reproducing its functionality in a golfing language isn't much smaller. That is, I want to find the algorithms that Jelly and Pyth and Matl and such are not optimized for.

I would appreciate suggestions on how to make this work. Maybe cops and robbers? Maybe each entry just contains two programs, and comments are given to help golf the smaller one?

• The only language that could possibly win is mathematica – Destructible Lemon Aug 23 '16 at 1:52
• – Dennis Aug 23 '16 at 1:53
• It's very easy to come up with boring examples e.g. print this exact trace, reproduce the output of this random number generator, etc. I don't see any way to get interesting answers. – feersum Aug 23 '16 at 6:31
• @feersum I'd probably disqualify errors and crashes and stacktrace outputs and such, and maybe all built-in non-trivial algorithms. Thanks for pointing those out. – Sparr Aug 24 '16 at 7:26
• @DestructibleWatermelon you don't have to beat the golfing language to win. The winning entry will probably still have a shorter Jelly solution than Python (or whatever). – Sparr Aug 24 '16 at 7:27
• I don't know of any golfing languages where creating a simple webserver is possible. All this would be is finding a task that isn't normally required for when doing code-golf – Blue Aug 24 '16 at 14:16
• I'm thinking of restricting it to algorithms and output, not stuff like network and file access. – Sparr Aug 24 '16 at 22:11

# Draw "Stack Exchange"

Stack Exchange has many site (159) and It has a logotype too. Anyway, In this challenge you'll need to draw Stack Exchange in the most shortest way.

This is a code-golf. challenge.

## Rules

1. Have fun!
2. You've to draw Stack Exchange, you can't use Paint or something like that, you can't use libraries.
• Challenges that start with "Most creative" are almost certainly guaranteed to not generate creative answers (or any answers for that matter) – Fatalize Sep 8 '16 at 13:47
• @Fatalize I changed the challenge. – Rizze Sep 8 '16 at 13:54
• Now there is basically no interesting solution possible to the challenge, because there is no patterns in Stack Exchange. So all shortest solutions will to print that string directly or a compressed version of it. – Fatalize Sep 8 '16 at 13:58