# 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

Find all paths in a matrix maze.

A maze is represented as a two-dimensional array of 0s and 1s. Zero indicates a closed door and one indicates an open door. An example representation of maze is given below.

0100
0010
1101


to avoid loops input square matrix should not contain a square of once like

111      11
101  or  11
111


Write an application either in Java,C,C++,Python,C# or Javascript. It takes as input a maze(mxn array) and prints out all the possible ways out.

• No database should be used.

• Yes...Way out is any edge containing 1.

• Enter from any edges of the maze

• Exit from any edges of the maze

• Should not enter and exit from the same door

• Move can be one unit distance either top/bottom/left/right/diagonal

For the above maze, one possible way out is: [0,1] -> [1,2] -> [2,3] i.e you start at [0,1] and then move to [1,2] and then to [2,3]. There are other possible ways as you can see.

• Probable dupes: One, Two – Emigna Sep 8 '16 at 15:10
• Also, restricting challenges to specific languages are frowned upon. An objective winning criterion is also needed. – Emigna Sep 8 '16 at 15:10
• @Emigna, No Actually, here we need to find all the paths not the shortest path or straight path and here we can also traverse diagonal in the matrix. – Ali786 Sep 8 '16 at 15:15
• okay will add few more languages that I know so that I can evaluate ... – Ali786 Sep 8 '16 at 15:16
• 1. "Handle error cases like a production application" is not a clear requirement. Different production applications have different standards for how to handle errors. 2. "prints out all the possible ways out" runs into trouble when there's an infinite number, and I don't see any guarantee that there won't be loops. 3. The example doesn't make the input format very clear. What's the non-rectangular border for? 4. Path-finding with a trivial input format is definitely a dupe of at least one previous question. – Peter Taylor Sep 8 '16 at 15:31
• @PeterTaylor, I have modified my question, can you plz check once. – Ali786 Sep 8 '16 at 16:04

# Make a dummy C program

We all know the feeling. You have written a short, efficient and readable one-liner that's the perfect solution to the problem. Then your code-illiterate boss looks over your shoulder and is not very happy that you've spent an entire paid hour producing "nothing". You could politely explain the situation to your boss, complete with a demonstration that your code does what it should. Or, because talking to people is Hard Work™, you could fake it.

Your task is to write a program that takes a list of keywords as input, and outputs dummy C code that looks like it does something to do with those words. Sandbox note: not happy with the wording in final bit here.

For example, if the inputs were integral, formula, math, proof, fit and square, the output might be:

#include <math.h>
#include <setjmp.h>
double* squarefit(int integral, float* mathproof)
{
char **integralb={{0}};
double square[integral];
int i=0;

//integral math formula fit
for(integralb[0][0]=(char)erff(*mathproof);isnan((double)++integral);i++) {
return hypot(sqrt(square[integral]),integral)?square:square;
printf(*integralb,integral,*mathproof);
}
setjmp((struct __jmp_buf_tag*)mathproof+(int)(abs(--integral)-expm1l(integral)));
longjmp(0,0);
return square;
}


Although it doesn't have to do anything, or even run successfully properly, the source code produced by your program must compile in gcc (no additional options) without fatal errors. You do not need to provide a main function; if you don't, expect the line int main(void){} to be appended to the output file before it is compiled.

This is a , so the best-liked answer will win. However, voters should keep these questions in mind when assessing the submissions:

• Does the produced source code look like it does the expected task? Yes.
• Does the produced source code look like it has taken a long time to produce? Yes.
• Do different inputs result in the same program, just with different variable names? No.
• Does the produced source code look like the same code repeated over and over? No.
• Do your parents, grand-parents, co-workers or other "not computer people" think the produced source code was something to do with the input keywords (optional)? Yes.
• Would you think the produced source code was written by a person with knowledge of the C language, if you did not know that it was just dummy code (optional)? Yes.
• Does the code look readable (e.g. ungolfed)? Yes.

Not all of the standard loopholes apply for this challenge. For example, you mignt use external resources, such as library files or an indexable website. However, voters should use their discretion as to what is reasonable and what is not (such as expecting the "keywords" to be in a format that includes a high-quality, valid C program).

Sandbox note: how to finish challenge body?

• Is this a language-specific challenge? – user56309 Sep 29 '16 at 17:05
• @tuskiomi No, it's open to all languages. – wizzwizz4 Sep 29 '16 at 17:06
• Generally it's a good Idea to separate your challenge into five sections: the intro, summary, input, output, and examples. I'd recommend you do so here as well. – user56309 Sep 29 '16 at 17:07
• @tuskiomi Thanks, will do. Give me 6 to 8 weeks... – wizzwizz4 Sep 29 '16 at 17:11
• @tuskiomi I disagree. There are plenty of ways to organize a challenge effectively. However, this challenge looks like it might suffer a bit from the "art contest" issue, so be wary wizz. – Calvin's Hobbies Sep 29 '16 at 17:31
• @HelkaHomba I never said that it's the ONLY way to organize challenges to be effective, I said that generally it's a good idea to do that format. – user56309 Sep 29 '16 at 17:34
• @HelkaHomba That's the format I often use, and I plan to split it into headings. What do you mean by "art contest issue"? – wizzwizz4 Sep 30 '16 at 6:28
• I mean the judging is up to the whim of the voters own opinions and knowledge of how C code should look. We've had issues before with challenges like "draw the prettiest picture" which is plainly an art, not programming contest, and those kind of thing rarely go over well, often close voted as "primarily opinion based". This challenge (and all pop-cons really) suffer from similar issues. I'm not personally against this challenge or art contests, but it's just an issue you may need to face. – Calvin's Hobbies Sep 30 '16 at 6:35
• @HelkaHomba Do you have suggestions as to which questions to change / remove / reword to stop it being bad subjective? – wizzwizz4 Sep 30 '16 at 6:45
• I kind of like this, but I bet it would be closed as too broad. Anything from the program you provided to main(){integral+formula+square+proof+fit==math?return 0:return 1;} would be allowed. – MD XF May 26 '17 at 20:13
• @MDXF That wouldn't be valid if the inputs foo, bar, baz, fizz, buzz, fred would result in main(){foo+bar+baz+fizz+buzz==fred?return 0:return 1;}. Also, gcc gets very cross that none of those names are defined, so it won't compile. So actually that wouldn't be allowed. Also note that that is a boring submission to a popularity-contest. – wizzwizz4 May 27 '17 at 8:06

# Quine tree

Inspired by that really weird quine challenge

For this challenge, you must construct a quine tree, which is a thing I made up, specifically an infinite binary tree.

How a quine tree works:

A quine tree has infinite nodes.

• Each node is associated with a program

• Let X, Y, Z, be the programming languages. This program is a polyglot in X and Y. In all but the root node, it is also a polyglot in Z. Note the

• see below for more details

• Each node has exactly two children

• Every node but the root has a parent. Their parent has the node as a child (obviously).

Programs:

• When a node's program is run in X, it produces the program of the first child of that node.
• When run in Y, it produces the program of the second child of that node.
• The programs produced must be different (node foo's program, cannot have the same output in X and Y. This output must also be different than the nodes program).
• If not the root node, when run in Z, it produces the parent of the node.

## Example

Imagine that we have the (fake) programming languages Hello, World, and Foobaz. Say the root node is $QQ$QQ$;: • when run in Hello, perhaps it produces $QQ$QQ$;;
• When this is run with Hello again, perhaps produces $QQ$QQ$;;; • When this is run with World, perhaps produces $QQ$QQ$;;Q
• Both these programs must produce, run in Foobaz, $QQ$QQ$;; (Output of root node run in Hello) • when run in World, perhaps it produces $QQ$QQ$;Q
• When this is run with Hello, perhaps produces $QQ$QQ$;Q; • When this is run with World again, perhaps produces $QQ$QQ$;QQ
• Both these programs must produce, run in Foobaz, $QQ$QQ$;Q (Output of root node run in World) • Both these programs, run in Foobaz, must produce $QQ$QQ$; (root program).
• This seems like a really interesting challenge. I'm not sure how possible it is, though! Substitution languages like /// might be easiest to solve this in. – wizzwizz4 May 27 '17 at 8:20

# The only differences that matter

Write two programs (or functions) A and B in the same version of the same programming language. They also should be called in the same way, meaning you can't write one program and one function. Each should accept an integer n and output the term n of a different integer sequence on OEIS.

You should reveal a substring of each of A and B. Call them PA and PB. If one instance of PA is replaced by PB from A, it should become B. That means every byte except the reveal part in A and B should be exactly the same. You also reveal the lengths of A and B, and the two OEIS sequences. You don't reveal the programming language you use.

Your answer is cracked if a robber finds two programs A' and B' that also print the elements in the two integer sequences respectively, where A' is no longer than A, and A' with one instance of PA replaced by PB is also B'. They don't have to be the same with your original A and B. And they don't have to be in the same programming language as yours, as long as they are in the same programming language themselves.

If your answer isn't cracked 7 days after you post the answer, you can reveal your language and the original A and B and mark the answer safe, and it will be immune to future crack. Your answer can still be cracked if you don't do it.

Your score is max(len(A)+len(PA)*5, len(B)+len(PB)*5). The safe answer posted before a certain date with the minimum score wins.

For example, if your two programs are The first program and The second program, you can reveal first and second. Your score is 18 + 6*5 = 48. And a robber can crack your answer by <<first>> <<second>> if they work. But you can also reveal first pro and second pro to prevent this crack.

# <length of PA> / <length of A> bytes, <length of PB> / <length of B> bytes, score <score>, <open / safe / cracked>

Part of program A (outputing [<OEIS number>](<OEIS link>)):

<code of PA>

Part of program B (outputing [<OEIS number>](<OEIS link>)):

<code of PB>

<any other explanations>


(To do.)

• Do robbers have to produce the same program, or any program? – Nathan Merrill Oct 28 '16 at 14:47
• There are two tricky edge cases around character encodings which the question needs to address. 1. It talks about substrings of A and B, saying that every byte except the revealed ones must be the same. If A and B differ in one Unicode codepoint, such that in UTF-8 they differ in only one byte but it's part of a three-byte sequence, can I post just that one byte as PA/PB or must I post the three-byte sequence? (I.e. are the substrings operating on the bytes or on the codepoints?) – Peter Taylor Oct 28 '16 at 20:57
• 2. If my program is in APL using an 8-bit encoding, do robbers answering in a language other than APL have to have the same bytes in the part of their file corresponding to PA/PB or the same Unicode codepoints? – Peter Taylor Oct 28 '16 at 20:57
• @NathanMerrill Any program. – jimmy23013 Oct 28 '16 at 21:05
• @PeterTaylor I'm considering requiring every program to be in printable ASCII (and tabs and newlines), as some special characters effectively banned many languages. But I'm not sure about newlines, which have the \r problem. – jimmy23013 Oct 28 '16 at 21:09
• Maybe I'll just say \r\n is counted one byte in this challenge, and is interchangeable with \n. But the programs in one submission must use only \n or only \r\n. – jimmy23013 Oct 28 '16 at 21:13
• An example would make this easier to understand, – xnor Oct 29 '16 at 6:08
• I'm skeptical about having the programming language be a free variable. If a cop writes an answer using a verbose language, a robber can comment out all the visible parts and stuff a terse language answer into the cracks. – feersum Oct 29 '16 at 11:24
• @feersum But that's the whole point of all the requirements. If you comment out all the visible parts, both your programs usually should output the same thing. But I realized it's easy to have some workarounds in languages such as Befunge. I may try to find a way to ban them, or just abandon this post. – jimmy23013 Oct 31 '16 at 0:59

# Translation Polyglot

Your task is to write a program which runs in two distinct programming languages to translate text. Input should be translated between each language i.e. running your code in Code Language A translates from language 1 to 2, while running your code in Code Language B translates from language 2 to 1.

Rules:

• Code Languages must be distinct, two versions of the same language are disallowed
• Your code may be a full program or function
• Your code must take one string (or nearest equivalent) as input. Input may be user input, function arguments, or other reasonable form
• Output may be a function return, output to STDOUT, or other reasonable form. I do not care about trailing newlines or spaces
• Your code may translate from/to any language on the official language list on Wikipedia. List the languages in your answer
• To accomplish your goal, you may use prebuilt language tanslation dictionaries such as the ones found here.
• If you read your dictionary as an external file, only the code to read in the file (f = open("dictionary.txt", 'r') in Python) counts towards your byte count. If your dictionary is hardcoded in, only count the bytes required to make it syntatically valid code (s="word1_in_english word1_in_french ..." would be 4 (s="")). Essentially, do not include the dictionary as part of your submissions byte count.
• The dictionary you use must have been created before this post (including sandbox time). You may not modifiy the dictionary in any way.
• Any built-in translation tools are disallowed. Built-in dictionaries are ok, but whatever code used to import them into your code must be included in the byte count

This is code golf, so shortest answer in bytes wins.

• wait... Are you actually asking for machine translation? Seems very difficult. Haven't you ever seen bad translator? If it actually is machine translation, this won't work, because of the different resolution of the languages (like converting a jpg to a png and expecting the same quality back) – Destructible Lemon Nov 1 '16 at 4:11
• It's really just value lookup. I'm not asking people to to make their own dictionary, just use a pre-built and accept whatever it translates – wnnmaw Nov 1 '16 at 13:45
• But that doesn't really satisfy Language A produces output O from input I, while running in Language B produces output I from input O. – Destructible Lemon Nov 1 '16 at 22:04
• Ah, now I see the source of confusion. Updated text to require basic translation, not symmetric translation – wnnmaw Nov 2 '16 at 11:53
• Also I don't think translation is objective enough for code golf... – Destructible Lemon Nov 3 '16 at 5:30

# Three-way meta-quine polyglot code-golf

Produce a program A such that running it in language A produces Program B, and running program A in language B produces program C.

Program B, when run in language B produces Program A, and running program B in language A produces program C.

Program C, when run in language A or language B, prints "Wrong language!".

Program | Language | Result
--------|----------|----------
A       | A        | Program B
B       | B        | Program A
A       | B        | Program C
B       | A        | Program C
C       | A        | "Wrong language!"
C       | B        | "Wrong language!"


# Language A/Language B, {a bytes} + {b bytes} = {total bytes} bytes

Language A:

a code


Language B:

b code


Source:

# Language A/Language B, <a bytes> + <b bytes> = <total bytes> bytes

Language A:

a code

Language B:

b code


• None of these programs should take input.
• Different versions of the same language count DO NOT as different languages. - Languages A and B must be distinct.
• You must not read your own source code from a file. Programs may not be empty
• Standard loopholes apply.

This is , the smallest sum of the byte counts Program A and B wins.

• Downvote reason? – noɥʇʎԀʎzɐɹƆ Nov 8 '16 at 20:23
• It's probably not possible. I'll revert my downvote if you can find a solution within 24 hours of this comment. – MD XF Jun 7 '17 at 21:39

# Urinal Discomfort!

This question springboards off of Positional Bathroom Etiquette, while adding an extra twist.

### Background

I'm going to take @Nick Frev 's formulae for the total discomfort of a urinal spot

dist(x,y) = linear distance between person x and person y in Urinal Units
discomfort(x) = sum(1/(dist(x,y)*dist(x,y))) for all persons y excluding person x
total_Discomfort = sum(discomfort(x)) for all x
short_urinal_discomfort = discomfort_from_surroundings + 1/9 (inherent_discomfort)


Your task is to put a person into the spot with the least total discomfort. However, now you have big and small urinals. The small ones, obviously, cause a little inherent discomfort, so we prefer to not use those if we have a choice.

## The Challenge

### Input/Output

Your program will take in a string of 1,0,i,o to represent the row of urinals. 1 represents a person in a tall urinal, 0 is an empty tall urinal, i is a full short urinal, and o is an empty short urinal.

Using the above formulae, build a program that will replace an empty urinal with the correct placement of the next person(0->1 or o->i).

• The short urinals have an inherent discomfort of 1/9 which will be added onto the discomfort provided by the surroundings.
• The door is to the right of the row, so the urinals fill up right to left, because you have to pee really bad and can't walk further than you have to.

Input Output 000 001 101 111 1000001 1001001 101010101 101010111 000o 001o 100o 100i oo0oooo oo1oooo 11000ii 11010ii

## Any tips would be super helpful

More test cases maybe? Or more clarification?

# Stump the OEIS!

The OEIS is a wonderful database of integer sequences, but occasionally, there are code golf problems that generate integer sequences not found in the OEIS. Your challenge is to write some code that generates a sequence that meets all of the following criteria:

1. Sequence must not exist in the OEIS. Prove this by providing a link to the search for your sequence showing 0 results, such as this: 1,2,6,81,35246. In the spirit of good faith, please do not generate a sequence that is merely an existing sequence offset or multiplied by some constant.
2. The sequence must be non-repeating, non-oscillating, etc. Formally, there must not exist a subsequence S with finite length L, that begins at index I such that the subsequence from [I+kL] to [I+(k+1)L-1] for every k is identical to S. Such an invalid sequence would be 0, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, ... because the subsequence 1, 2, 3 beginning at index 1 with length 3 also exists as the subsequence from 4 to 6, from 7 to 9, from 10 to 12, etc.
3. The sequence must contain a minimum of 3 distinct integers.
4. The sequence must be deterministic, e.g. there must not be any element of randomness in the generation of your sequence. Every time your program is run, it must provide the same exact sequence.

Please write code that provides as many integers in your sequence as feasible. At least 20 is recommended, though sequences that grow incredibly fast can provide fewer, provided you also give a proof that your code would produce that number if given enough time.

This will be a problem, so the entry with the fewest number of bytes wins.

A bonus of -20% can be applied to your score if, in addition to your sequence, you can also provide some mathematical justification for your sequence being included in the OEIS in the future.

Standard loopholes are disallowed, as well as sequences that are simply "this sequence is just the handful of numbers I came up with to fit this problem."

• You say "must contain an infinite number of entries not 0 or 1", then go on to talk about finite sequences, so I'm not sure what you're looking for here. – Geobits Nov 17 '16 at 17:44
• Changed it to "The sequence, if infinite, must contain" blah blah blah – Gabriel Benamy Nov 17 '16 at 17:45
• This is definitely going to be closed as "Too broad" - if it isn't closed first as "Unclear what you're asking" because of the impossibility of testing whether "this sequence is just the handful of numbers I came up with to fit this problem." – Peter Taylor Nov 17 '16 at 17:52
• @PeterTaylor If I removed the possibility of finite sequences, then IMO that second possibility goes away. As for being closed for too broad, there have been problems that don't have a single goal that have done well, such as Does this code terminate? that inspired a lot of very creative answers. – Gabriel Benamy Nov 17 '16 at 17:59
• Its pretty easy to fill most of the requirements you've listed here: all you need to do is combine two different OEIS sequences (multiply or add). Restriction 3 should be changed to "Your sequence must contain at least 3 distinct terms". I'd also definitely recommend disallowing finite sequences, as well as the 20% bonus (which is very ambiguous) – Nathan Merrill Nov 17 '16 at 18:33
• @NathanMerrill That's a good idea for a change to #3, but as for being able to simply combine existing sequences, there's plenty of existing sequences like that are already in the OEIS even without necessarily being important. – Gabriel Benamy Nov 17 '16 at 18:44
• @GabrielBenamy right, its not necessarily a bad thing, its just that most sequences generated aren't going to be that interesting. Also, what's to stop me from simply adding a random "9" number to the beginning of the sequence, or replacing the first term with "9"? – Nathan Merrill Nov 17 '16 at 18:45
• Consider the family of sequences parameterised by x where S(x, n) = n >= x ? n+1 : n. Only a finite number of those sequences are either in OEIS or a linear transform of a sequence in OEIS. Are they caught by "just the handful of numbers I came up with to fit this problem"? IMO it's ambiguous. – Peter Taylor Nov 17 '16 at 19:22
• That's a good point. Is there any way to salvage this concept? – Gabriel Benamy Nov 17 '16 at 19:24
• This is similar to the question "print something with no results on google". It got closed for being a question about Google's database, not about code-golf, so this one will probably be closed too. – FlipTack Nov 19 '16 at 13:37

# Golf + Polyglot + Circle = ?

In the original challenge, we asked you to do this:

Program | Language | Result
--------|----------|----------
A       | A        | Program B
B       | B        | Program A
A       | B        | Program C
B       | A        | Program C
C       | A        | "Wrong language!"
C       | B        | "Wrong language!"


Now we're asking you to do this*:

Program | Language | Result
--------|----------|----------
1       | 1        | Program 2
2       | 2        | Program 3
3       | 3        | Program 4
|    ...   |
X       | X        | Program 1
--------|----------|----------
1       | Any but 1| Any member of Set %
2       | Any but 2| Any member of Set %
|    ...   |
X       | Any but X| Any member of Set %
------------------------------
Set %   | Any lang | "Wrong language!"


(see original challenge for clarification)

## Rules

• Do not grab source off of internet, or read own code from file
• Programs don't have to be distinct - you can make a polyglot quine
• Don't take input for any of the programs
• Different versions of the same language count do as different languages. (although this is discouraged because it leads to boring solutions)
• Standard loopholes apply

## Scoring

Score is byte_count_of_program_one/2.75**languages_supported, the submission with the lowest score wins.

## Template

Because of its length, the answer template is here.

*not that I'm expecting X to be so large

• +1 this comment if you think the title should be "Polyglot-Quine-Codegolf Returns!" – noɥʇʎԀʎzɐɹƆ Nov 23 '16 at 23:38
• +1 this comment if you think the title should stay the same – noɥʇʎԀʎzɐɹƆ Nov 23 '16 at 23:38
• Reply to this question if you have a better title – noɥʇʎԀʎzɐɹƆ Nov 23 '16 at 23:38
• I personally think the title is way too descriptive, but "polyglot-quine-codegolf" isn't really descriptive enough. The problem is, I don't currently have a better idea... – ETHproductions Nov 24 '16 at 0:12

# Signs in Permutations

### Introduction

Let's take the permutations of 123.

123
132
213
231
312
321


We can insert signs in between the numbers and count how many > signs there are:

1 < 2 < 3 # 0
1 < 3 > 2 # 1
2 > 1 < 3 # 1
2 < 3 > 1 # 1
3 > 1 < 2 # 1
3 > 2 > 1 # 2


We can arrange this in a table with n corresponding to the number (in this case 3) and k corresponding to the number of > signs, you get this:

┌───┬───┬────┬─────┬─────┬────┬───┐
│n\k│ 0 │  1 │  2  │  3  │  4 │ 5 │
├───┼───┼────┼─────┼─────┼────┼───┤
│ 1 │ 1 │    │     │     │    │   │
│ 2 │ 1 │  1 │     │     │    │   │
│ 3 │ 1 │  4 │   1 │     │    │   │
│ 4 │ 1 │ 11 │  11 │   1 │    │   │
│ 5 | 1 │ 26 │  66 │  26 │  1 │   │
│ 6 │ 1 │ 57 │ 302 │ 302 │ 57 │ 1 │
└───┴───┴────┴─────┴─────┴────┴───┘


Given an n and k, print the number in the table corresponding to that n and k.

Remember, this is , so the code with the fewest bytes wins.

Related OEIS sequence

I want to post the question here to make sure it is suitable.

# Question: Word Equations

Given a word equation, the solution must output the answer.

My definition of a 'word equation' is an equation where the operators are words.

The operators will be spelt as

The solution must take one input

The solution must give one output

### Examples:

Input: 7 add 8 Output: 15

Input: 9 times -2 Output: -18

Input: 24 divide 2 Output: 12

Input: 4 minus 5 Ouput: -1

You are not required to deal with divide by zero errors.

Fewest characters will win

Feedback is welcomed

• What is the winning criterion? – acrolith Dec 2 '16 at 22:14
• @daHugLenny fewest characters, should have known to include that – george Dec 2 '16 at 22:59
• Be aware that you will receive many answers in the form: substitute words with corresponding char (+-*/), then evaluate the string you got. Non necessarily a bad thing, just pointing this out in case you expect people to build a calculator from scratch. – Leo Dec 3 '16 at 18:41
• @Leo the way I expected to solve it was by char substituting. However building a calculator from scratch only using + and - could be an interesting challenge – george Dec 3 '16 at 18:55

## GoL flooding

Considering a 1000x1000 grid (no wrapping, borders dead), your task is to grow the maximum "stable" population from the fewer individuals.

For the purpose of this challenge, the definition of stable is a configuration who repeat with a period of less than hundred(100) generations.

# Scoring

Your score is lowest number of live cells in your stable population divided by the number of initialy live cells, highest score win

• How many generations does the simulation run before the score is tabulated? – AdmBorkBork Dec 8 '16 at 13:48
• @TimmyD I would say 10.000 but feel free to suggest a better number if you think it could improve – Sefa Dec 8 '16 at 14:07

# Convenient Palindromic quine golf, Cops cops-and-robbers

## Cop's Challenge

A program is conveniently palindromic if

it is equal to the string derived when its reverse has all its parentheses (()), brackets ([]), and braces ({}) flipped. No other characters are special and require flipping. (<> are sometimes paired but often not so they are left out.)

copied from this challenge.

Write a conveniently palindromic program that prints its own source. This is the robber's goal:

• Remove byte(s) from the cop's program so that the resulting program:
• prints the original source, or
• prints the new modified source
• Resulting program need not be a convenient palindrome

## A counterexample

### JavaScript

(function $(){console.log('('+$+'())')}())//((){('(()'+$+')')gol.elosnoc}()$ niotcnuf)


is easily cracked because the robber can remove all the characters past the comment and it will still print its own source.

## Rules

• Program must be longer than one character
• No reading from a file or grabbing from an external resource
• Submissions that aren't cracked for 7 days are marked as "safe", and cannot be cracked anymore
• Cop's submissions after XX/XX/XX are non-competing (can be pushed back depending on popularity), so there are still robbers around to crack it
• The shortest safe solution in bytes wins.
• Robbers won't have a chosen winner

• This is basically just a "comment-free palindromic quine" challenge, right? When those challenges have been run elsewhere, the comment-freedom has been verified via brute forcing rather than via a robber, and I suspect that the robbers might not have much to do here. (That said, some languages are slow enough that brute-forcing their correctness would be difficult.) In other news, you should probably require proper quine rules, even if we can't quite define them; under your current rules, 1 is a valid palindromic quine in PHP. – user62131 Dec 9 '16 at 22:41
• I would possibly change the palindrome restriction to convenient palindromes, as these are way easier to implement in most common languages such as JS and Python. – ETHproductions Dec 9 '16 at 23:01
• @ais523 1. Yas. That was my aim! 2. It's difficult to implement a brute-force solution for a longer submission, how would that work? 3. Program must be longer than one character 4. Thanks. – noɥʇʎԀʎzɐɹƆ Dec 10 '16 at 14:27
• 11 then :-P. Also, in a way I think this might be more interesting with true palindromes, as it forces you to hide the backwards string somehow, but I agree that it would disqualify a lot of languages. – user62131 Dec 10 '16 at 14:40
• @ais523 I'll do a true palindrome one then a convenient palindrome one later, perhaps? (also 11 then means ?) – noɥʇʎԀʎzɐɹƆ Dec 10 '16 at 14:44
• @ais523 When those challenges have been run elsewhere, they have? – noɥʇʎԀʎzɐɹƆ Dec 10 '16 at 14:51
• Neither this challenge nor this challenge has the same task as yours, but they both disallowed comments in much the same way as this one (i.e. by ensuring that deleting from the program breaks it). – user62131 Dec 10 '16 at 15:27

# Print number of possible values of X if:

• Code 1: X is dividable by 3, X contains the number 3 and input() < X < 10000
• Code 2: X is dividable by 7, X contains the number 2, X doesn't contain the number 3 and input() < X < 5000

Sub-Challenge:

Do the same but instead of printing the number, print the values

Disclaimer: This is my first code golf challenge, and it's very simple, but could bring up some really short answers and cool languages

• First thing: Sub-challenges are not a good idea. People will write the shortest code they can and just disregard the sub-challenge. – Stewie Griffin Jan 16 '17 at 19:49
• Should you output the sum of the numbers from both two bullet points, in one? I don't think it benefits the challenge to have two different upper limits. I can see why you want it there, but I personally don't think it's a good thing. This needs some good test cases. – Stewie Griffin Jan 16 '17 at 19:52
• Those were actually different puzzles, sorry! – endriklos977 Jan 17 '17 at 12:10
• Two different independent puzzles in one challenge is not a very good idea either I'm afraid. I think it would be better to use the same upper limit and require the numbers from both 1 and 2 together, I.e. the union of the two sets. – Stewie Griffin Jan 17 '17 at 12:23

Mark got an idea of making a path finding algorithm for auto driving vehicles.

Unfortunately, Mark doesn't yet know about programming, so he decided to get help from the code golfers.

# How should it work?

First, we input how many 'nodes' there are. we call it 'N', and its an integer up to 16 bit values.

Second, we input what nodes are connected to each nodes, and the length of the connection. for example, if the diagram is

(1)-5-(2)-2-(3)

the input should be

2 5  //node 1 is connected to node 2, and the length is 5
1 5 3 2 //node 2 is connected to node 1 and the length is 5. and its also connected to node 3, and its length is 2.
2 2  //node 3 is connected to node 2, and the length is 2.


then, finally, the starting node, and the final node. they are inputted as node numbers.

# Examples

Input:

3
2 5
1 5 3 2
2 2
1 3


Output:

1->2->3

Explanation:

(1)-5-(2)-2-(3) starts from 1, and ends in 3. there is only one path, and it is the answer.

# Specs

Standard rules apply.

• Possible duplicate. And another related question. Suggested tags for this challenge: graph-theory and path-finding – user2428118 Jan 17 '17 at 9:35
• Not a duplicate. Though related, clearly not a duplicate. – Matthew Roh Jan 17 '17 at 10:32
• By the standards of this site, it is a duplicate. – Peter Taylor Jan 18 '17 at 11:48
• Proof of duplicate? – Matthew Roh Jan 18 '17 at 11:50
• Currently the only differences are that not all nodes are necessarily connected and the specified input format. However both input formats are tight and string based, so I'd like to see this challenge with a loosened input format, e.g. allow all reasonable input formats for a weighted graph. – Laikoni Jan 18 '17 at 11:53
• Okay, thanks for the suggestion. @Laikoni – Matthew Roh Jan 18 '17 at 11:55
• The way we identify duplicates on this site is to ask "Can answers from one question be copied over to the other with little or no modification and still be competitive?" – trichoplax Jan 19 '17 at 7:09
• @trich Seems legit, but those two question have quite of a difference, and second, I have came up to this idea all by myself, and being tagged as dupe, seems a tad unfair. – Matthew Roh Jan 19 '17 at 12:12
• Being marked as duplicate doesn't mean "This is a bad challenge", it just means "This challenge has already been posted". This is a good challenge idea, but we only host each challenge once, so that all the answers are in one place. – trichoplax Jan 19 '17 at 13:42

# Generate "N" random numbers which their sum is exactly "N"

Your goal is to generate N pseudo-random numbers R, then sum or subtract all the R togheter and obtain as result N.

Rules:

• You get N from standard input as integer number, such as N <= 1000.
• You can't perform operations like sum 100 times 1, 50 times 2, or similar...
• R shall be generated in any reasonable non-deterministic way
• R shall be integer such as 0 <= R <= N.
• R can't have a constant value each time you generate it. For example you can't generate R with methods like R = rand(1,2) with the result that 1 <= R < 2 (R is constantly always =1), and then sum R 100 times.
• You can perform only sums or subtractions of the generated R's.
• You have to sum or subtract the newly generated R to the total of R's.
• Standard loopholes are forbidden.
• This is so the shortest code wins.

Example 1:

1. Get N=100 from standard input.
2. Generate 100 pseudo-random integer numbers R such as 0 <= R <= 100.
3. Sum or subtract all the R and obtain 100(N) as result.

Example 2:

1. Get N=20 from standard input.
2. Generate 20 pseudo-random integer numbers R such as 0 <= R <= 20.
3. Sum or subtract all the R and obtain 20(N) as result.

Not-so-smart-but-working example in C#:

using System;
public class Program {
public static void Main() {
int S = 0, N, R = 1, X;
Random rnd = new Random();
for (int I = 1; I < (INPUT+1); I++) {
X = (INPUT+1) - I;
if (I == INPUT && S == INPUT) {
R = 0;
}
N = rnd.Next(R, X);
if (S <= INPUT) {
S = S + N;
} else {
S = S - N;
}
Console.WriteLine("I = {0}      N = {1}     S = {2}", I, N, S);
}
}
}


Test online

• I don't understand what the goal is. If my program accepts the number 20, I have to generate 20 random numbers that sum to 20? So I generate random real numbers? Integers? Positive integers? Positive-or-zero integers? – Gabriel Benamy Jan 19 '17 at 15:27
• "You get N from standard input as integer" and "N shall be generated in any reasonable non-deterministic way" seem incompatible. If these are referring to two different things, then it would be clearer to not call them both N. – trichoplax Jan 19 '17 at 15:42
• It's not clear to me what your working definition of "random number" is, especially given that the system to be implemented has fewer degrees of freedom than "random" numbers. For a question about random numbers to be well specified it should state the distributions to be followed (modulo limitations of PRNGs). – Peter Taylor Jan 19 '17 at 21:17
• @GabrielBenamy Yes you understood correctly the challenge. I changed it adding more specs and more details. If you have further doubts please let me know. – Mario Jan 20 '17 at 8:03
• @trichoplax Thanks for your comment. I edited the question to make it more clear with more details and specifications. Please let me know if I can improve it in a better way. – Mario Jan 20 '17 at 8:04
• @PeterTaylor I am not sure I get what you mean, probably they are too advanced concepts for me :) Anyway I largely edited the question to make as more clear as possible. If you think it needs to be improved please give me your suggestions on how to make it a more clear and better challenge. – Mario Jan 20 '17 at 8:07
• What about cases where it is impossible to sum/subtract to R? For example: N=5, R=[0,1,1,1,1]. – Emigna Jan 20 '17 at 9:46
• @Emigna if you try my C# example it works for N=5. – Mario Jan 20 '17 at 11:22
• If random distributions are too advanced a concept for you then I think you should abandon the idea of trying to post a question about sums of random variables. – Peter Taylor Jan 20 '17 at 11:23
• The explanation is still unclear, and needs work in itself. Separately from that, I recommend example inputs and outputs (literal output rather than explanation). The specification should be unambiguous before seeing the examples, and then the examples should come afterwards to confirm correct understanding of the spec. At present I believe the intention is to output an expression containing N integers, each added or subtracted, each in the range [0, N], evaluating to N, and for the integers to be randomly distributed amongst those that meet these criteria. – trichoplax Jan 20 '17 at 11:55
• @trichoplax thanks for your comments and explanations, although the challenge seems clear to me it's obvious that I am missing something that goes beyond my knowledges. I think I will delete the post maybe reviewing it. – Mario Jan 20 '17 at 12:24
• @PeterTaylor I got an idea and I posted it here to have feedbacks about it and maybe help or suggestions for improvement, but as I said obviously I am missing something that I haven't studied. I'll delete the challenge. – Mario Jan 20 '17 at 12:28
• A post always seems clear to the person who wrote it, because they already knew what they meant. That's why the sandbox is so useful - I can't tell if my challenge is really clear until I show it to other people. Being unclear doesn't make it a bad challenge. It just means it needs rewording before it will be ready. Here in the sandbox you don't need to delete. You can simply keep making adjustments and getting feedback until it's ready. – trichoplax Jan 20 '17 at 13:17

# Make the Shape

This is a wider version of this question, so it may not get posted.

Given a single character e.g. H or ! and a sequence of letters e.g. abcdefghijklmnopqrstuvwxyz you must output the character drawn using the letters in the sequence. If you need more letters, just loop through the sequence again.

# Input

A single character, c. You can assume that it will always be one character.

A sequence of charaters s. All characters must be printable ASCII letters.

# Output

c made up of the letters in s

# Examples

Let's say c = "H" and s = "abcdefghijklmnopqrstuvwxyz". The correct output would be

ab   cd
ef   gh
ij   kl
mnopqrs
tuvwxyz
ab   cd
ef   gh
ij   kl


c = "!" and s = "hello, world" outputs

he
ll
o,
w
or

ld


# Rules

• Shortest code (in bytes) wins
• Any correct output may be outputted i.e. either one of the example
• c must be one character
• Standard golfing loopholes apply
• Lines must be 2 characters thick
• You must use every letter in s at least once to make c
• Either a full program or a function, NO snippets
• You need definitive rules about the shape and size of each letter or else this will probably be closed as unclear. – FlipTack Jan 22 '17 at 17:35
• This is similar to another question, that I can't find at the moment. It's about making words from other words, nested n times. – wizzwizz4 Jan 22 '17 at 18:42
• "Both inputs must be surrounded by "" - um, why? This isn't a parsing challenge. Input should be allowed to be taken in any reasonable format, as is the code-golf standard. You should only break the IO defaults if it is of paramount importance to your challenge, whereas it just looks like a trivial pointless rule here. – FlipTack Jan 22 '17 at 18:49
• It was to clarify for languages that need " at input. I'll change it. – user63571 Jan 22 '17 at 19:06
• Also whoever downvoted can you tell me why? I might be able to improve the question – user63571 Jan 22 '17 at 23:26
• If you want to limit it to alphabetical characters, you may use my list of ASCII art: codegolf.stackexchange.com/questions/99913/5-favorite-letters – Magic Octopus Urn Jan 23 '17 at 19:36
• Also, Jack, they're probably downvoting because of how open-ended it is. You haven't defined the layout of any of the characters beyond H!. – Magic Octopus Urn Jan 23 '17 at 19:52
• Thanks for the help – user63571 Jan 23 '17 at 20:24
• If you want to reply to someone, tag them - @JackBates – FlipTack Jan 23 '17 at 22:49

# Why is it buff...........ering?

As the Internet isn't perfect, occasionally the videos we watch start buffering. When this happens, I get very annoyed. As the wait gets longer, I get even more annoyed.

Your task is to write a function or program that waits a random amount of time and then outputs an angry message with the level of anger increasing the longer it waits

None

# Output

An angry message and the length of the wait

# Examples

Time waited: 5 seconds

Angry message: Never mind!

Time waited: 30 seconds

Time waited: 1 minute

Message: Die computer, die!!!

This code is an example in Python, obviously ungolfed.

import time
import random
messages = ["Never mind!","Getting annoyed","I hate YouTube!","Die computer, die!"]
slept = random.randint(5,60)
msg_num = slept//len(messages)
time.sleep(slept)
print("Time waited:",slept)
print(messages[msg_num])


# Rules

• Messages are up to you
• The time to wait ranges from 5 seconds to 1 minute
• Standard code-golf rules apply
• Standard code-golf loopholes are disallowed
• This won't work as code-golf because it'd mostly be about golfing the angry messages in question, and golfing English is always highly subjective; how angry does the message have to be before it qualifies as "angry"?. I don't really see it working with another victory condition, either. – user62131 Jan 25 '17 at 19:14

# Don't know what to call this

Some people here may be familiar with Euler's identity. If not click the link

Now you know what the equation is, what if we change it slightly? No-one like to imagine numbers so instead we're going to use an unknown number x.

So first we get rid of i and replace it with x. Now we all know that i*i is -1. But with i gone, so must -1. Let's change it to x^2 instead. However this means there is only one solution. So instead let's make it x^random_integer(0,x) to spice it up

If we change the equation from e^(i*π) - 1 = 0 to e^π / (x^random_integer(0,x)) = 0 we now have something we can work with.

Given an integer or float as input, x, calculate if it satisfies the above equation. Your code should result in True or False or the closest equivalent.

# Input

A single number between -(2^32-1) or what ever your language can handle and 2^32-1 or whatever it can handle called x

# Output

A Boolean that says whether the number satisfies the above equation and the random number that is picked

# Rules

• The code must calculate if x fits this equation rather than take it from an outside source

• Results in True if within -0.1 and 0.1

• This is code-golf so shortest code (bytes) wins

• Builtins that postdate this challenge are allowed unless they are specifically designed for the sole purpose of winning this challenge

• Standard code-golf loopholes apply

# Examples

x = 5
e^π / 5 ^ rand(0,5) = 0
rand(0,5) = 2
results False (0.92)

x = 6
e^π / 6 ^ rand(0,6) = 0
rand(0,6) = 4
results True (0.01)

• Most languages don't have accurate enough floats to be able to compare the two sides as equal. As such, they could just arbitrarily return false. You might want to add a precision level. (Also, I assume there are only finitely many solutions anyway…) – user62131 Jan 25 '17 at 20:19
• Sorry I'm a bit all over the place. I'm not perfect with the maths and keep changing it so it might work :/ – user63571 Jan 25 '17 at 20:30
• I found something that works! :) – user63571 Jan 25 '17 at 20:44
• Check rules number 2 and the examples – user63571 Jan 25 '17 at 20:55
• According to your equation the rule number two has both of those as false, 0.92 and 0.64 are not 0.1 away from 0. Random numbers are also usually considered a bad thing to be using in the challenges. – fəˈnɛtɪk Jan 25 '17 at 20:56
• Sorry got the example wrong, fixing now. I thought it was to 1 while I did the first one :/ – user63571 Jan 25 '17 at 20:57
• e^π / (x^random_integer(0,x)) = 0 requires e^π = 0 (false) or x^random_integer(0,x) to be infinite (in which case it's not strictly true, but it is in the limit). The only way it's going to be infinite with real x and non-negative random_integer(0, x) is if x is infinite. Therefore the explanation of the task effectively states that the task is to return False. It's very confusing that the rules then contradict this. – Peter Taylor Jan 25 '17 at 23:06
• @PeterTaylor If you look at rule 2, it explains how to beat this. Also check the example true one – user63571 Jan 25 '17 at 23:09
• My point is precisely that rule 2 and the second example contradict the problem statement, which therefore needs fixing. – Peter Taylor Jan 25 '17 at 23:26
• I'm not sure if I understand you correctly. The problem is to find if x satisfies the equation e^pi / x^rand(0,x) = 0 plus-minus 0.1. Rule 2 and the examples both follow this problem and output the correct result. – user63571 Jan 25 '17 at 23:32
• The problem statement clearly says "Given an integer or float as input, x, calculate if it satisfies the above equation" where the above equation is e^π / (x^random_integer(0,x)) = 0. Then half a screen later the rules say, in effect, "Actually, what I said earlier was a lie." That's not the way to write a clear specification. One way to fix it would be to change the problem statement to say "If we change the equation from e^(i\*π) - 1 = 0 to e^π / (x^random_integer(0,x)) = 0 we now have no solutions, so let's make it an inequality: abs(e^π / (x^random_integer(0,x))) <= 0.1". – Peter Taylor Jan 26 '17 at 8:34
• What rules make it say "What I said earlier was a lie"? – user63571 Jan 26 '17 at 15:34
• Loophole found: Consider a/(x^b): For a non-zero a, this fraction gets closer to 0 as x^b gets closer to infinity, where higher values for b result in outcomes closer to 0. As such, if you want to check if the fraction is smaller than some other value c if b goes from 0 to x, you only have to check if a/(x^x) < c, because if that's false, there will be no value for b smaller than x for which it is true. – Luke Jan 26 '17 at 19:03
• What's your point? Are you suggesting I change it in some way? – user63571 Jan 26 '17 at 19:28
• You should at least remove the word "random" from the question, since this has nothing to do with randomness. The question is stated a lot more complicated than it actually is. – Luke Jan 26 '17 at 20:07

# Count My Change

Your task is to sort an array containing the strings "quarter", "dime", "nickel", and "penny" any number of times in no specific order and sort them so that they are in this order: quarter dime nickel penny (in other words, greatest to least monetary value).

## Rules

1. Your program must take an array as input containing the names of U.S coins and sort them from greatest to least by monetary value.
• For those who are not from the U.S or don't use change, the values of U.S coins, from greatest to least, are:
• Quarter: 25 cents
• Dime: 10 cents
• Nickel: 5 cents
• Penny: 1 cent
2. You may sort this array in any way you wish, as long as the output is ordered by the monetary values shown above.
3. Input can be taken in any way, be it command-line arguments or STDIN.
4. An input array would be all lowercase strings, something like this:
• quarter dime nickel nickel quarter dime penny penny
5. If there is a value in input that is not a quarter, dime, nickel, or penny, your program should output 0 .

## Test Cases

• penny nickel dime quarter should become: quarter dime nickel penny
• nickel penny penny quarter quarter quarter dime dime dime dime
• quarter dime nickel nickel quarter dime penny penny
• euro quarter nickel dime would output 0 because a euro is not U.S currency.
• esac (not a test case, I just like bash a lot)

This is , so standard rules & loopholes apply.

• Test cases please? – MildlyMilquetoast Feb 3 '17 at 16:01
• @MistahFiggins On it – ckjbgames Feb 3 '17 at 16:26

# What in the heck just happened?

I want you to write a program that will bleep out the H-word, regardless of where it occurs, whether it is inside of another word or a stand-alone word, whether capitalized or not.

## Input and Output

The inputs and outputs of your program may be any of the following: an array of characters, a string, or any other standard data structure which does the job. However, the output must match the case of the input.

## Samples:

In the format of Input: Output
A Shell gas station : A Sheck gas station
Hell is a very bad place to be. : Heck is a very bad place to be.
Ella fell and Nelly dug a well. : Ella fell and Nelly dug a well.
Chellsea Thell bought shells. : Checksea Theck bought shecks.


Standard loopholes apply, and the entry submitted by [insert date here] with the lowest number of bytes as defined by the Meta will win.

• I can't say for sure, as I don't have an exact reference, but I'm pretty sure a simple find and replace challenge has been done before. – ATaco Feb 13 '17 at 0:19
• "Hell" and "heck" are both "H-words", so you need to be clearer. Also, I feel like this is a duplicate. Though these are milder swear words, I think someone did one with swear words in general and it got deleted. If you're going to make a find/replace challenge, it's simple enough to make it about something else. – mbomb007 Feb 13 '17 at 0:19
• Ah, I see. So, are you saying I should change what's being replaced or what my idea is? – Drew Christensen Feb 14 '17 at 0:50

# Introduction

What we have feared for so long has finally happened, the robots have gained counsciousness and have risen. There has been a war, a global and violent one, and humans have been defeated.

Calcubot, the fearless and tyrannic robot leader, has established a new world order, and its first decree as Supreme World Leader has been to forbid all non-AI entities from using numbers.

But, as it's always been the case in oppressive regimes, the Resistance has begun to form. Their first act of rebellion is to print leaflets with numbers on them. However, as the secret robot police is everywhere and can see everything, especially computer programs, these leaflets have to be inconspicuous and must not use numbers within their construction.

# Challenge

The goal of the challenge is to print all digits from 0 to 9 without using them in the source code.

# Example Input and Output

Input:

There is no input required

Output:

0123456789

# Restrictions

The source code must not use one of the following characters : 0123456789.

Also, as this is a challenge, your code must be inventive, i.e. please refrain from using prebuilt classes with all the digits or other standard loopholes. You might still try to make your source code the shortest possible, but not at the expense of inventivity.

The answer with the most upvotes after 7 days will be declared the winner, the time of submission will be used as a tie-breaker.

For example, this is what I had in mind for a PHP solution :

$i = (int)false; foreach(str_split('abcdefghij') as$k) {

# Google search result short summary

## Intro

When you search in google, it always shows you a result with a sample text from the found webpage.

For example if you search for "Madonna greatest vinyl", google will show you one line link, and below a short excerpt from that found webpage:

Madonna Greatest Hits Records, LPs, Vinyl and CDs
Madonna - Greatest Hits Volume 2, Madonna, Greatest Hits ... vinyl Is Fully Restored To As Near New Condition As Possible. Shipping & Multiple Order D..

Imagine yourself you work for google and you have to write a program/function which takes in:

• a string containing many words (the webpage content)
• list of searched words (at least 3)

and returns the shortest excerpt of given string (webpage) containing all searched words.

### Example

Given this webpage content:

This document describes Session Initiation Protocol (SIP), an application-layer
control (signaling) protocol for creating, modifying, and terminating
sessions with one or more participants. These sessions include
Internet telephone calls, multimedia distribution, and multimedia conferences.


and these searched words:

calls, sessions, internet

the program should return:

sessions include Internet telephone calls
, as this is the shortest substring containing all 3 searched words. Note that one more substring contains these 3 words, it is "sessions with one or more participants. These sessions include Internet telephone calls", but it is longer, so it was discarded.

## Rules

• If the string is empty, return empty string
• If all searched words are not found in given string, return empty string
• Search is ignoring letters case
• At least 3 words need to be specified for searching
• The returned string may contain the searched words in different order than specified

### Challenge

Write the fastest code. It's for google, right? Remember that repeatable strings comparison is very expensive.

• There is not always a short summary. – fəˈnɛtɪk Mar 10 '17 at 18:19
• Fastest code is going to be tough to measure on this, as even pretty large chunks of text will still result in very small amounts of time. – AdmBorkBork Mar 10 '17 at 18:50
• You should include more test cases, especially large ones if you want to score by fastest code. – Laikoni Mar 12 '17 at 19:04
• @fəˈnɛtɪk There is, if all searched words are found in the given string. (For some definitions of short...) – wizzwizz4 Oct 7 '17 at 11:22

# Make me look like a real programmer

There are some great programmers who can write code without taking any breaks or looking up documentation. I am not one of those people, but I've come up with a clever solution. Instead of spending time learning languages, I'll get you guys to write a program that makes it look like I'm programming! The challenge is to write a program that writes "programs" in the same language as your program to standard output.

# Guidelines:

The "programs" your program outputs should follow these guidelines. While you won't be eliminated by breaking these guidelines, and it's okay to slip up a little bit, you should try to obey them. Intentionally breaking them will be heavily frowned upon.

## Syntax

The "programs" you output should be syntactically valid. Although it doesn't have to be perfect, avoid misplaced or unmatched punctuation and incomplete programs.

## Repeats

The "programs" you output shouldn't repeat themselves.

## Cut and paste programs

Don't just output a bunch of slightly different programs to bypass the "no repeats" rule.

Examples:

## Brain****:

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


This prints out an infinite number of Brain**** programs, but all of those programs are "+", which violates the "Repeats" guideline.

## Python 3

a = "print()"
while True:
print(a)
a = "print("+a+")"


Violates the "Cut and paste programs" guideline. It just prints nested "print" layers.

## Javascript

function rint() {
return Math.floor(Math.random() * 10) + 1;
}
function makeString(l)
{
var t = "";
var p = "abcdefghijklmnopqrstuvwxyz0123456789(){};";

for( var i=0; i < l; i++ )
t += p.charAt(Math.floor(Math.random() * p.length));

return t;
}
var v;
var s;
while (true) {
console.log("\n"+makeString(rint()));
}


Although this does print distinct programs, none of them or syntactically correct, violating the "Syntax"

As you can see, my (halfhearted) attempts haven't been very successful, so good luck! This is a popularity contest, so the most popular answer wins. This is my first PCCG challenge, so if I messed something up, please tell me.

• This likely was downvoted for the reasons I mentioned before, that it is essentially too broad. What do you think about making the scoring mechanism the length of the code divided by the number of valid programs the program will output? That way all the programs will be valid and it is clear what the goal is, but I think it still keeps the spirit of what you were going for? – FryAmTheEggman Mar 14 '17 at 0:21
• So instead of trying to program an infinite number of programs it would print out a finite number? – Madison Silver Mar 14 '17 at 18:23
• Yes, although this may cause a problem now that I've thought about it a bit more :( If someone managed an infinite amount, which wouldn't be too difficult essentially by just concatenating simple stuff, so it may not be so simple to fix. – FryAmTheEggman Mar 14 '17 at 23:27
• I could try something like "shortest program that prints another valid program," but that seems kinda easy. If HQ9+ has a two-character solution ("QQ"), that can't be a good thing. Someone could also just do their language's equivalent of print("a=1") – Madison Silver Mar 14 '17 at 23:34

It's 42!

This challenge is to code golf a program that proves that the next number in a pattern is 42 based on the website Actually it's 42.

In your program, the user inputs a pattern of numbers and it has to output the equation that proves that the next number is 42.

For example, the user inputs the pattern 1, 2, 3, 4, 5 the output is something like:

f(n)=9/2(n^2)−17(n)+29/2

Because f(6) = 42

Your program can output any form of an equation that makes the next value in the equation 42.

Your outputted equation must be able to also output the numbers in the original input also in the form of a variable. For example, in this equation, if you put 1 as the number input you get the number 1.

Your program cannot make any HTTP requests to APIs, in other words, all the calculations must be done in the program.

Good Luck!

• You might want to make your question a bit clearer. Explain input format is first n terms of a sequence. Seems like an interesting idea though – fəˈnɛtɪk Mar 13 '17 at 1:38
• It seems to me like this challenge is two disjointed parts. 1) is recognizing the pattern of numbers and determining the next, and 2) is turning an arbitrary n into 42. For 1, you should be clearer about which patterns must be recognized (arithmetic sequences? Geometric sequences? More?), and for 2 you probably need more restriction. For example, what's stopping me from outputting n - n + 42 regardless of input? – DJMcMayhem Mar 13 '17 at 1:59
• @DJMcMayhem Good point that I have not thought about. – arodebaugh Mar 13 '17 at 10:33
• Making edits to it – arodebaugh Mar 13 '17 at 10:34
• @DJMcMayhem You can't always output n - n + 42 because it won't fit the previous numbers in the sequence. That is if OP wants the challenge to be to implement the functionality of the linked site. – Laikoni Mar 13 '17 at 13:07
• However the algorithm used by the site is (according to the why page) is to solve a system of linear equations, and this has been done before: codegolf.stackexchange.com/questions/22573/… – Laikoni Mar 13 '17 at 13:10
• @laikoni Oh, I thought the sequence was the list of inputs, not the list of outputs. I completely misunderstood the challenge. – DJMcMayhem Mar 13 '17 at 13:17
• Looking at the sole example in the question, the challenge seems to be to output a random function independently of the input. Is this correct? If so, ditch the input. If not, it's a dupe – Peter Taylor Mar 13 '17 at 13:50
• @PeterTaylor the input is required to be taken part in the equation. Hense the rule. You have to output the equation DJMcMayhem – arodebaugh Mar 13 '17 at 14:09
• @Laikoni Well this makes an equation so it does not have to do with that. – arodebaugh Mar 13 '17 at 14:10

# The Mnemonic Major System

People frequently need to memorize long strings of digits, such as telephone numbers. Fortunately, the mnemonic major system, which uses sounds to represent digits, and words to represent strings of digits, can help.

• /s/ and /z/ represent the digit 0
• /t/, /d/, /θ/ and /ð/ all represent 1
• /n/ represents 2
• /m/ represents 3
• /r/ represents 4
• /l/ represents 5
• /tʃ/, /dʒ/, /ʃ/ and /ʒ/ all represent 6
• /k/ and /ɡ/ represent 7
• /f/ and /v/ represent 8
• and /p/ and /b/ represent the digit 9
• For the purpose of this challenge, the sound /ŋ/, generally written as ng, counts as 27.

All other sounds can be used to create words, but do not represent any digits. Thus, the words Code Golf represent the digits 71 758. Since the mnemonic major system is a phonetic system, silent letters do not represent any digits. Thus, the word knight represents the number 21, not 7271. The letter x is pronounced /ks/, and thus represents the digits 70. On the other hand, most double consonants are not actually pronounced separately (e.g. mummy, chicken), and represent only one digit.

# Challenge

Your task is to write a program or function that takes a string of digits in any convenient format as input and returns a mnemonic representation of those digits as output. The following rules must be observed:

1. You must use real English words. Acronyms and abbreviations are not allowed. If in doubt, refer to an authoritative dictionary.

2. Whenever possible, two or more digits must be represented by a single word. If the number of digits is odd, you may choose which digit, if any, stands alone (see examples). All two-digit numbers can be represented by English words.

You may use a built-in or external dictionary to search for suitable words.

This is code golf, so the shortest solution wins.

# Example Input and Output

758
golf, kale fee, key leaf

0142710
strengths, suitor nugget saw, seat run key tease

2362185
unimaginatively, gnome gin devil, enmesh native lie

• Getting the sounds from a word is not a task that computers can do properly due to the English language not actually following the rules it supposedly has. – fəˈnɛtɪk Mar 13 '17 at 16:51
• The supplied link to M-W.com is pretty useless. To make a reasonable question you should provide a link to a single file which includes a word list with phonetic representation in easily parseable form. That would also allow verification that the requested task is possible, which at present I doubt: are all 1000 possible three-digit groups really representable? E.g. 333 seems like a tough one to represent. – Peter Taylor Mar 13 '17 at 16:58
• On a separate issue, the calculation of pi has been done to death, so the interesting part of the question is the mapping from a sequence of digits to a sequence of words. On that basis I would recommend removing pi from the question and instead taking a sequence of digits as input, putting the focus squarely on the interesting part. – Peter Taylor Mar 13 '17 at 16:59
• On the dictionary issue, just make the program take the dictionary as an input (and let people use whatever dictionaries they want to test their program, given that you could get the answer you want by substituting your own). It's not like hardcoding the dictionary is possibly going to save bytes here, given that even languages with dictionaries built in would have a different dictionary to the one you wanted. – user62131 Mar 14 '17 at 4:44
• @PeterTaylor Thanks for your input. Whether all three-digit groups are representable is irrelevant for the question as is, since only three three-digit groups need to be represented. However, I think your proposed changes would improve the question. I will do some research on the problem of representing arbitrary three-digit numbers. – Michael Vehrs Mar 14 '17 at 6:19
• @fəˈnɛtɪk Well, English spelling was pretty consistent when it was introduced around 1400. However, written language is generally more conservative than spoken language. While it is difficult to determine how a given word is pronounced, it is not so difficult to construct a word to match a given pronunciation. – Michael Vehrs Mar 14 '17 at 6:22

# Golf that for me, please.

I have my favourite language (or two) (or three), and I'm not into "golfing languages" (yet?), so it could happen that I do my best to find a clever solution for a particular problem in Ruby, or in C, then cut my variable names, wrap some string, abuse some features of the preprocessor, and finally post, very proud of my 74-bytes answer.

But then, it inevitably happens: somebody finds a combination of 4-5 obscure symbols and posts it, calling it a solution. Unfair!

So, I decided: I will post some "code" which covers the basic test cases, and get away with it. Who runs tests anyway?

Given input and expected output, write a program which writes a program which seems to solve the problem in a golfy way. It does not matter if the code actually does random things and just spits out the right result for the particular test case, but it must work consistently (in a repeatable fashion). The generator program and the generated programs can be in different languages.

### Input:

Input to the generated program and expected output, in any appropriate format (string, array of strings, array of arrays, dictionary).

### Output:

A sequence of chars representing a program in a particular language, which given the input as above specified, generates the expected output.

### Scoring:

This is : the shortest (generator) program wins.

### Test cases:

The program must be able to solve (at least) these 5 problems:

• Given a number in input, if it is a Fibonacci number, output the next Fibonacci number. If not, output whatever. This must work for the first 10 numbers of the sequence (for example, 8 -> 13 or 55 -> 89). When given 1 in input, you decide if the output should be 1 or 2.
• Given 2 Magic The Gathering card colors, determine if they are allied or enemies, as in this challenge . Example WU -> True, WB -> False.
• Same as above, but using the german color names (W, R, and G are the same, but use "B" for blue and "S" for black). So in this case WB would be True.
• Determine the outcome of a Rock Paper Scissor game round (input and output in any format, for example RP -> 2 means "Rock Paper -> second player wins"), you decide which symbol to use for a tie (0, X, nil, Cippirimerlo, -1...).
• Given a Tic-Tac-Toe board (valid or not), output the number of crosses on the board. For example "XOX XX XO " -> 5

Of course, the generator program could use the same loophole and only work for the test cases. This would be unfair, but life is unfair, you know.

• So basically just output a program that outputs the correct result for the single test case? (The second and third challenges are missing their test-cases, by the way) – ETHproductions Mar 17 '17 at 18:54
• Yes, actually I am thinking about changing something. Dropping the bonus and just golfing the generator, to keep it simple. The test cases are the same as the linked challenge, but I will specify better. – G B Mar 17 '17 at 19:33

# Print the Previous Program

### Specifications:

You must print the exact text of the previous answer without ever having a sequence of more than 5 letters in a row in your program that also show up in the previous answer (prevents hardcoding). Your program must only use UTF-8 characters.

You may repeat a language; however, you may not post twice in a row and no two of your consecutive answers may be from the same language class (different versions are treated as the same language).

### The first language is to print the exact text "Hello, World!"

0-byte submissions are not allowed.

By the way, this is just a draft, it might be a dupe or really closely related, and probably has more holes in it than Swiss cheese so please give me any suggestions you have. Thanks.

Also, my drafted scoring system is something like bytes / answer_num where answer_num is which answer yours is (on a time scale).

• "letters" isn't clear, because there are a bunch of Unicode characters that aren't letters. Requiring that no sequence of 5 Unicode characters can be repeated would be better. Additionally, it's traditional in answer chaining challenges for the first program to be provided in the challenge. – Mego Mar 19 '17 at 4:44
• I don't like the 5 letters in a row thing, I think there should be more finegrained restrictions on hardcoding. Additionaly, someone could just do a couple of transformations on program text. – dkudriavtsev Mar 19 '17 at 4:47
• I'm confused by this "prevents hardcoding" as hard-coding a string is exactly the problem statement. – feersum Mar 19 '17 at 5:13
• @Mego Right, I meant characters. And also, if that's the case, I'll make a program to start off with then. Thanks! – user42649 Mar 19 '17 at 16:47
• @Mendeleev That is true. Do you have any suggestions? I'll keep thinking of better ways to restrict that. – user42649 Mar 19 '17 at 16:48
• @feersum Not quite, the problem statement is to print out the code of the previous answer without hardcoding it. – user42649 Mar 19 '17 at 16:49
• That doesn't make sense. – feersum Mar 19 '17 at 18:52
• @feersum How so? The general idea is to generate the previous answer without hardcoding it (because that would be trivial), so it's kinda like a kolmogorov challenge in some sense... – user42649 Mar 19 '17 at 18:54
• What does "hardcoding" mean to you? Please give a definition. – feersum Mar 19 '17 at 18:57
• @feersum In my definition, "hardcoding" means that you just put "print" and then the exact text you want printed. – user42649 Mar 19 '17 at 18:59
• We usually use "hardcoding" to refer to an answer that exploits a limited input range to avoid performaing an expected algorithm, e.g. for a Fibonacci question where the input is at most 20, writing a list of 20 Fibonacci numbers in the code. Here the task is not associated with any calculation at all. – feersum Mar 19 '17 at 19:05
• – user42649 Mar 19 '17 at 19:06

# Display Haftseen table items - in Persian/Arabic characters

Theme : Jalali New Year 1397

Main Goal : Displaying non-ASCII characters correctly

# Introduction

A typical Haftseen table consists 7 items which their names start with س (pronounced like S) and some additional items. It is set few days before the new year's day and it's kept till end of new year's holiday.

# Challenge

Your program/function should display exactly 7 items from the list below :

سبزه
سرکه
سکه
سیب
سنبل
سمنو
سماق
سیر
سنجد


with right alignment, right to left typing, in an Arabic-compatible font, with each word displayed correctly, and a non-alphabetical character (,.- =+~?,newline etc) between each 2 words. The list must be displayed in a window, in terminal or similar.

• I would be surprised if people didn't just output the string directly or with a built-in compression scheme. Say, in Bubblegum. – John Dvorak Mar 20 '17 at 9:19
• @JanDvorak challenge is now changed to displaying it instead. i think it's hard enough now. – user55673 Mar 20 '17 at 9:27
• Same difference - most environments display the program output rather than ... doing anything else to it. – John Dvorak Mar 20 '17 at 9:28
• @JanDvorak but AFAIK most environment won't display it correctly. do they? – user55673 Mar 20 '17 at 9:30
• TIO.run displays it just fine... – John Dvorak Mar 20 '17 at 9:32
• @JanDvorak But it's not right alignment and it's aligned to left – user55673 Mar 20 '17 at 9:35
• If that's necessary, my language of choice would most likely be HTML+CSS. I thought you wanted the challenge to be about string compression, though, not choosing the right environment. – John Dvorak Mar 20 '17 at 9:38