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

# Identifying a Sonnet

This challenge is about determining if a given file (read-in from stdin) meets the criteria to be a sonnet. You may use any language for this challenge. If your language supports an API to use an online dictionary you may use that API, if your language doesn't then too bad.

Additionally, it is preferred if your language is one that can be ran directly from the command line and is a language that has a compiler or interpreter available directly from my distro's repos(Fedora), as I would rather just use a bash script to test the various programs, then test each program manually.

# Definition of a Sonnet

• Has 14 Lines (lines are denoted as the standard newline on your operating system).
• Has a definite rhyme scheme, it will have one of the following rhyme schemes
• ABBA ABBA CD CD CD
• ABBA ABBA CDE CDE
• ABAB ABBA EFEF GG
• Iambic Pentameter - consists of alternating stressed, unstressed syllables. This doesn't have to be perfect 100% of the time, just at least 50% of the time.

In order for your program to declare a given string a sonnet, it must meet all of the above criteria.

You do not have to identify the following:

• Thought Structure - too intense for a code golf challenge, and too subjective.
• Topic - computer lacks context to determine this

# Input

Input will be read from stdin. This is the string that you will be declaring to be or not to be a sonnet.

# Output

Your program will output either yes or no for the question:

Does this string meet the given requirements to be a sonnet?

As this is code golf yes or no can be abbreviated to Y/N.

# Winner

The solution with fewest number of bytes win that has the highest accuracy ratio for the correct identification of a sonnet. The preference is for higher accuracy rather than brevity of the program.

# Test Data and Resources

## What is not a sonnet

The following are examples that you program should return false on:

• Beowulf
• Haiku
• Input that doesn't have exactly 14 Lines in it
• The text of this question.
• The text of just about any other question on StackExchange.
• Things that don't have a rhyme scheme. See Below

# Not A Sonnet

A man got on a boat
The boat was leaky
For it was made by a one-eyed blind man
and his dumb intern
As soon as he got out of port
at the fort
it started to sink
eventually, it tanked.
And it capsized
If only that shipwright
wasn't so blind deaf and dumb
as microsoft tech support
That's not much support at all.

• I think without dictionaries for rhymes and stresses this is probably not a good idea. Of course you can use some sort of accuracy ratio, but then you also need false positives, and you need a lot more examples than the few on the pages you've linked. But if you do this there's no requirement to actually recognise the sonnets by their rhymes and stresses - instead, I'm pretty sure, people will just regex golf the test sets. – Martin Ender Mar 24 '15 at 19:36
• @MartinBüttner I updated the requirements with an accuracy percentage, and added the option to use an API to look up terms from a dictionary. – HSchmale Mar 24 '15 at 19:57
• 1. Test data which only covers one possible output isn't test data. I can write a program which always outputs Y in as little as one byte and it will pass all of the linked "test data", but it comes nowhere near to meeting spec. 2. Unless you specify which rhyme/stress dictionary to use, you can't guarantee that the test data is "correct". – Peter Taylor Mar 24 '15 at 20:20
• @PeterTaylor I added examples of what is not a Sonnet. – HSchmale Mar 24 '15 at 20:32
• I'm not sure how to say this, but it feels as though this task has a lot of individual parts, each of which could be quite tricky. Especiallly detecting rhymes/syllables/stresses, since words can be pronounced/stressed differently based on context. Also if you're using Shakespeare's sonnets I have no idea where to get rhyming and stress dictionaries for Elizabethan English... – Sp3000 Mar 25 '15 at 14:18
• To make this interesting, you'll need some interesting near-misses: non-sonnets that can't be detected by something simple like counting lines or words per line. – xnor Mar 25 '15 at 20:59
• @xnor You mean a file with a that looks like a sonnet but has no rhyme. – HSchmale Mar 25 '15 at 21:04
• Yes, for example. Or, one with rhyme by wrong rhythm. Or, one with nonsense characters that seem to "rhyme". – xnor Mar 25 '15 at 21:06
• @Sp3000 You can just use modern english, or just base it on words that have similar endings. – HSchmale Mar 25 '15 at 21:11

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 # 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. – clismique 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? – clismique 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 ## 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? – Fund Monica's Lawsuit 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

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

# 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

## 99 selttob fo reeb no eht llaw popularity-conteststring

I teb ev'uoy lla draeh tuoba eht doog 'lo 99 selttob fo reeb no eht llaw. Llew ti os sneppah taht I emoc morf na evitanretla esrevinu - eht esrevinu erehw ew etirw gnihtyreve ni esrever! Ew peek eht snoitisop fo lanigiro hguoht. Siht osla snaem reporp noitazilatipac fo tsrif (ekil rettel ni siht txet). Ruoy egnellahc si ot etirw a margorp taht stuptuo eht lausu 99 selttob fo reeb no eht llaw, tub ni esrever (ni ruo egaugnal uoy dluow llac ti 99 bottles of beer on the wall). Siht si a ytiralupop tsetnoc, os teg evitaerc dna yrt ot sserpmi eht dworc. Doog kcul!

I bet you've all heard about the good ol' 99 bottles of beer on the wall. Well it so happens that I come from an alternative universe - the universe where we write everything in reverse! We keep the positions of original though. This also means proper capitalization of first letter(like in this text). Your challenge is to write a program that outputs the usual 99 bottles of beer on the wall, but in reverse (in our language you would call it 99 selttob fo reeb no eht llaw). This is a popularity contest, so get creative and try to impress the crowd. Good luck!

Elpmas fo derised tuptuo:

Sample of desired output:

99 selttob fo reeb no eht llaw, 99 selttob fo reeb. Ekat eno nwod dna ssap ti dnuora, 89 selttob fo reeb no eht llaw.

89 selttob fo reeb no eht llaw, 89 selttob fo reeb. Ekat eno nwod dna ssap ti dnuora, 79 selttob fo reeb no eht llaw.

...

1 elttob fo reeb no eht llaw, 1 elttob fo reeb. Ekat eno nwod dna ssap ti dnuora, on erom selttob fo reeb no eht llaw.

On erom selttob fo reeb no eht llaw, on erom selttob fo reeb. Og ot eht erots dna yub emos erom, 99 selttob fo reeb no eht llaw.

• There's no need for the reversed text in the description - it distracts the viewer from the challenge at hand. – clismique Oct 21 '16 at 12:06
• @Qwerp-Derp I wanted to make this a bit more "unique" and "immersing", so I thought about giving the reversed description(I like it). I also included original text(although in spoilers), but I was also wondering about distracting readers. Do you have some other idea on how to keep both versions without making it look obscure? – MatthewRock Oct 21 '16 at 12:10
• 1. This should not be a popularity-contest. 2. It's fundamentally a duplicate of codegolf.stackexchange.com/q/64198/194 . 3. If you're going to muck around with the question text, write a program that mucks it around correctly. "elpmaS" doesn't follow the specified transformation rule. – Peter Taylor Oct 21 '16 at 12:34
• @PeterTaylor 1. why not? 2. It's not. You can't simply reverse, and counting is a bit different. – MatthewRock Oct 21 '16 at 13:24
• Do X creatively popularity contests have fallen out of scope. This will get closed if posted on main. – Dennis Oct 21 '16 at 13:46
• @Dennis Damn, too bad. I guess I won't be posting it then, it's boring "shortest code". – MatthewRock Oct 21 '16 at 14:16
• What does this add to the original '99 bottles of beer on the wall'? – 0WJYxW9FMN Oct 21 '16 at 20:54
• 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:08

# Best n out of 2n - 1

### Challenge:

This one should be relatively simple. Output this exact text:

Best [n] out of [2n - 1].


given n as an input.

### Input:

Just the integer n, can be from stdin or as an argument. n will always be greater than 0.

### Output:

The exact text above. Trailing spaces/newlines are allowed.

### Rules:

This is , so shortest code in bytes wins. Standard loopholes are forbidden.

### Meta:

Is this too simple? What other tags should be included, ?

• Seems like a dupe of 2spooky4me, just with a different operator. – Geobits Nov 1 '16 at 17:52
• Your wording specifies "this exact text" while I think your intent is "Best 5 out of 9." or the like. – AdmBorkBork Nov 1 '16 at 17:53
• @Geobits Aha, I knew I remembered a similar challenge. Just forgot the exact name, so I thought maybe I was just imagining things after I tried to find it. My bad. – Yodle Nov 1 '16 at 17:55

# Google Home / Amazon Echo - Turing complete?

Your challenge is to try to make a turing machine based on Google Home and Amazon Echo, see this video.

You must describe how to set up the machine, and how to give it input.

You must also describe a program for integer addition. It should compute 1+1 to be 2, 200+55 = 255, 200+56 = 0, and so on for all other combinations of 2 8-bit integers.

• It's basically not possible... – TuxCrafting Dec 2 '16 at 19:52
• VTC as unclear and too broad. What are you even expecting as an answer? – Rɪᴋᴇʀ Dec 2 '16 at 19:52
• @EasterlyIrk A set of commands that send the 2 computers into infinite loop, reading commands endlessly from a list of commands for the other to run, eventually processing a computer program and finally calculating the answer to the universe. – SoniEx2 Dec 2 '16 at 20:14
• @TùxCräftîñg Why not? I mean other than that we have yet to prove their turing-completeness. – SoniEx2 Dec 2 '16 at 20:14
• @SoniEx2 so only 1 of each computer? And what defines a command? – Rɪᴋᴇʀ Dec 2 '16 at 20:16
• @EasterlyIrk A command is anything that starts with "Hey google" or "Alexa" and triggers a successful response on either of the computers. – SoniEx2 Dec 2 '16 at 20:19
• Are we allowed to program the Echo and Google device? If so this is trivial. If we're supposed to construct a sentence that winds up having the devices compute using existing services like the calendar in the video, there are plenty of web sites that can process a variety of languages and read back the solution. Echo has basic math built in. – wyldstallyns Dec 2 '16 at 21:09
• I really hope this can be tweaked into a challenge because the youtubes would be awesome. – wyldstallyns Dec 2 '16 at 21:12
• @wyldstallyns tbh I have no idea what I'm doing... But yes, you're allowed to program both of them. – SoniEx2 Dec 2 '16 at 22:51
• A question should ideally be self-contained. In this case the APIs for Google Home (whatever that is) and Amazon Echo (whatever that is) probably won't fit in the question, but an overview and links to the APIs would. – Peter Taylor Dec 2 '16 at 23:03
• @PeterTaylor This isn't a matter of APIs. This is a matter of voice commands. – SoniEx2 Dec 3 '16 at 0:19

# Prelude:

Joke languages are allowed.
Submissions' scores will vary depending on whether they'll be made in a joke language, golfing language or a Turing complete language, don't worry if your score is high just because you chose a TC language.
That being said, let's get right into the challenge...

# Challenge:

Make a program as close as possible to the language name and document what it does in the description.

# Scoring/rules:

(will assume a simple language I made up, called Printr that has only a print() command that can take a argument to print but doesn't have to)

• Submissions that contain more than a 1/2 of whole language name in a string (ex. print("Printr")) are banned.
• Submissions must not throw any errors/exceptions/warnings (writing to an error stream is okay though).
• +1 for every char away from language's name (ex. print("r") is 4 chars away, (""), +4 points)
• Submissions need to contain (at least once) the language name "in a row" excluding nonalphanumeric characters and ignoring case (ex. print(" *@)!R") is okay, print("lolz R") is not okay)
• Duplicates of the name will be counted as other characters (ex. print("r") print("r") is still 4+1 [space]+10=15).

By looking as close as the language I mean having the least score (since scoring is based on other characters than the language name itself.

# Example:

## Printr, score 4:

print("r")

This program prints "r" then quits.

• is it allowed to throw an error? – FlipTack Dec 18 '16 at 14:00
• @Flp.Tkc, good question, errors shouldn't be allowed (syntax error be like). – n4melyh4xor Dec 18 '16 at 14:07
• What about a warning to STDERR? Stray error output is allowed by default on meta... – FlipTack Dec 18 '16 at 14:19
• @Flp.Tkc, should be okay. – n4melyh4xor Dec 18 '16 at 14:24
• ><>, in ><>, score 0, infinite loops. – redstarcoder Dec 18 '16 at 15:56
• or actually if we're excluding non-alphanumeric characters, this could also be golfed down to > or empty depending on if outputting "something smells fishy..." is a valid program. – redstarcoder Dec 18 '16 at 16:00
• in brainfuck you can just write brainfuck and it won't do anything... – FlipTack Dec 19 '16 at 17:31

A simple challenge: Shortest program that takes the longest to compile.

• What's the scoring requirement (i.e. how will programs be scored)? Who's machine will this be run on? – clismique Feb 11 '17 at 1:43
• It's too broad of a challenge; are infinite loops allowed? To reiterate what Qwerp-Derp said, how will it be scored? Longest to compile -- what if it's an interpreted language? – user42649 Feb 11 '17 at 1:47
• @AlexL.: languages without a compiler would be excluded. – jmoreno Feb 11 '17 at 1:57
• I still believe this is not a good challenge because it is unclear what you are asking and it is too broad. – user42649 Feb 11 '17 at 2:01

# Make a Simple GUI application

I have made a simple glade layout. The chalenge is to remake it in as few bytes as possible.

<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.20.0 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<object class="GtkApplicationWindow">
<property name="can_focus">False</property>
<property name="title" translatable="yes">Remake me!</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkButton">
<property name="label" translatable="yes">hello</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">world</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
<child>
<placeholder/>
</child>
</object>
</interface>

• This probably doesn't break any rules, but it also doesn't seem that fun. It would be preferable if it was a more substantial task than simply golfing the code you already wrote. – Wheat Wizard Feb 18 '17 at 2:09

### Rock Paper Scissors Lizard Spock

This game is from The Big Bang Theory, an extended version of the classic Rock Paper Scissors game.

Objective

To create a full program that I can run to play Rock Paper Scissors Lizard Spock against an "AI". The opponent ("AI") will pseudo-randomly choose their option after receiving user input.

The program must be run with user input of the following;

| Input     | Meaning   |
|-------    |---------- |
| R         | Rock      |
| P         | Paper     |
| S         | Scissors  |
| L         | Lizard    |
| SP        | Spock     |


The game is played with the following rules that Sheldon tells us;

Scissors cuts Paper

Paper covers Rock

Rock crushes Lizard

Lizard poisons Spock

Spock smashes Scissors

Scissors decapitates Lizard

Lizard eats Paper

Paper disproves Spock

Spock vaporises Rock

Rock crushes Scissors

Once you've taken user input, psuedo-randomly chosen the AIs option, you must output either "Player wins (<<user_input>> vs <<ai_input>>)" or "AI wins (<<user_input>> vs <<ai_input>>)". In the event of a tie (both the user and AI choose the same options), you must output "It's a tie"

Sample Runs

//Player chooses Scissors (S)
//AI chooses Paper (P)
$php -f rpslsp.php S Player wins (S vs P) //Player chooses Spock (SP) //AI chooses (R)$ php -f rsplsp.php SP
Player wins (SP vs R)

//Player chooses Lizard (L)
//AI chooses Scissors (S)
$php -f rsplsp.php L AI wins (L vs S) //Player chooses Lizard (L) //AI chooses Lizard (L)$ php -f rsplsp.php L
It's a tie


Rules

• Standard loopholes apply.
• The computer must choose an input at random (pseudo random) so that on each program run, the AI chooses (in a perfect world) a different input and that each input has the same percentage of being chosen.

This is code-golf so the shortest code in bytes wins.

• "A full program" means that we're not allowed to return the result from a function? Must it be a full program?? – Mr. Xcoder Mar 13 '17 at 12:55
• @Mr.Xcoder What I mean is we are able to run it in environments like TIO or REPL.it – ʰᵈˑ Mar 13 '17 at 13:01
• 1. It's not true that the game is from BBT. BBT made a cultural reference to a preexisting game. 2. The output spec is incomplete because it doesn't say what to do in the case of ties. – Peter Taylor Mar 13 '17 at 14:32
• @PeterTaylor Ah, I've only known the game exists because of TBBT, though the origin of the game doesn't really affect anything except maybe tread on the toes of some serious competitive RSPLSP players. Thanks for reminding me about it being a tie. – ʰᵈˑ Mar 13 '17 at 14:36
• – DLosc Mar 17 '17 at 19:42

# Fastest Compiling Fibonacci Sequence compilerfibonaccifastest-compiling

Your task is to create a program which takes one numerical input and outputs all numbers in the Fibonacci sequence up to that point. However, you will not be scored on its bytecount or how many upvotes it gets. You will be scored on how quickly the compiler can compile it.

## Rules

• Of course, compiled languages are the only languages allowed.
• All answers are tested on an Amazon EC2 instance with an Intel Xeon at 2.4GHz, about 1 GB of ram, and Amazon Linux installed. You can time your program on an equivalent machine, but I will compare results.
• Your program is allowed to produce warnings when compiled, but it should work properly when run.
• Compile time is tested with the time command, and "real" time is used for the final score.
• If I need to comment the amount of time you took, you should add it to your answer.
• Of course, standard loopholes are strictly disallowed.

This is , so may the cleverest optimization win and the best programmer prosper...

• For a trivial challenge like this the compilation time is going to be dominated by noise: whether the compiler is in the disk cache is going to be more important than the code submitted. – Peter Taylor Aug 14 '17 at 8:05
• To make compile times longer, you could require for the compiled program to work in O(1), or constant time. Then, the compiler will have to hardcode the entire sequence (up to a point specified by you, e.g. the largest 32- or 64-bit Fibonnaci number), which could make for interesting template-based programming optimization. – Sanchises Aug 14 '17 at 10:41
• @Sanchises, not true. Binet's formula will do the job in O(1). – Peter Taylor Aug 14 '17 at 11:08
• @PeterTaylor of course. So, another sequence which is proven not to have a direct formula could make this challenge possibly salveagable. – Sanchises Aug 14 '17 at 11:11

# Pascal's Particulars

Pascal is feeling very particular today. He wants to get an element from his famous triangle without going through the work of generating all the prior elements. He'll provide you with a row number and an entry number and you'll provide him with the element at that location.

Example:
Input row = 1, entry = 1, output 1. (row 1 is 1)
Input row = 3, entry = 2, output 2. (row 3 is 1-2-1)
Input row = 6, entry = 3, output 10. (row 6 is 1-5-10-10-5-1)

## Rules

• You will only be provided valid inputs (i.e. x will never be higher than n).
• Your code should either print or return the output value, either works.
• Standard golfing rules apply (lowest byte-count wins, etc.).

Happy golfing!

• you know that you are just asking for binomial(n,k), don't you? this is trivial – J42161217 Aug 17 '17 at 17:33
• Duplicate – Peter Taylor Aug 17 '17 at 17:39

# Break this block

Your challenge is to break this block.

But of course that would be a pretty easy challenge, that's why this is a challenge.
The robber's challenge: Break the block. As breaking qualifies everything that has the result that no diamond block is at the coordinates 0 128 0 (even pushing it with a piston) and that follows the rules (see below).
The cop's challenge: Prevent the robbers from breaking the block. As preventing the breaking counts everything that guarantees that there is a diamond block at 0 128 0 in every future game tick despite the robber attempting his solution (and also if he doesn't). You are not in the world while the robber makes his attempt, so you have to prepare the world for him.

## Rules

• You may not use modded Minecraft or external tools that change the save file. Reading it with external tools is allowed.
• You have to show a reproducible way to break/secure the block. Just uploading a world save without saying what you changed is invalid. You should offer a detailed explanation and preferably more (video, screenshots, structure file, etc.), if necessary.
• This challenge starts with a normal world (default generation, Creative+cheats, random seed), where one diamond block was placed using the command
/setblock 0 128 0 diamond_block
The spawn chunks can include 0 0, but they don't have to. Since both sides have access to commands, that shouldn't matter anyway.

## Sandbox questions

• How should I restrict the version? Should it be "latest release", "any stable release", "only 1.12.1", "any snapshot, release or historical version" or something else? People could come up with interesting solutions using past versions (maybe even past snapshots that aren't selectable in the launcher anymore), but I have to somewhat restrict it. If a certain downgrade automatically breaks the block, it's of course boring, especially since they instantly win. And if they load the world in any of the 9 oldest versions in the launcher (called "Classic" and "pre-Classic), there isn't even a diamond block in the game, so it would be deleted.
• Should I discourage people from instantly preventing every single breaking method with their first "cops" post? To have an interesting challenge, it should slowly become more difficult. If I should discourage it, how to "enforce" it?
• What other rules do I need?
• I'm planning to be very active myself on the "cops" side (I already have some nice ideas), possibly creating the majority of posts there. Is there a problem with that? If no, would it be considered unfair or boring to ask the others to wait up to a day with their solutions? Of course they don't have to do it, I just originally planned this to create programming challenges for myself.
• If every answer on one side can have multiple answers on the other side, which itself could have answers on the first side and so on, that could lead to a tree-like structure. But such a structure would lead to many unanswered questions (if it doesn't keep growing exponentially, what I highly doubt). Is there a way to prevent that or should I even try it?
• Apparently this is the first Minecraft-only programming challenge here. Should a tag be created for it?
• This doesn't make sense. What are the submissions? Minecraft commands? A set of instructions? A program that reads a save file and outputs a new one? – James Aug 22 '17 at 20:02
• Submissions would mostly be Minecraft commands, but maybe in the first few rounds instructions. – Fabian Röling Aug 23 '17 at 5:39

# Be typically flexible efficiently

Write a short function that returns outputs of different types in a non-boring way. If L is the length of your code and T is the number of different types returned, your score is (T−1)/L. The highest score wins.

• The function must take exactly one argument and be deterministic, i.e., the output depends only on the input.

• Obviously your programming language must have an official notion of type, by which each object has a unique, clearly identified type. Typically this would manifest in a type or typeof function returning an object’s type. Also, it must obviously allow functions to have differently typed returns.
If there are many separate typing systems in your language, you have to pick one (conforming with the above) and stick to it.

• The function must not employ any conditional constructs or other language features whose primary purpose is to handle logic, such as if statements, loops, or logical conjunctions. (Obviously, employed predefined functions need not adhere to this.)

• All inputs needed to produce the outputs used for scoring as well as any elements of container structures must adhere to the following:

• They are all of the same type.
• If they are functions or otherwise callable (and actually called in your program), they must consistently return objects of the same type.
• They must not be classes, type identifiers, or similar.
• If they are strings, they are treated (with respect to these rules) as any obvious interpretation of them as code, class names, or similar.
• If they are containers themselves, their elements must adhere to these rules when taken together.

So, e.g., in Python the following are invalid:

a = lambda i: [ 0, 0., [], {}, (0), {0} ][i]
b = lambda i: [ int, float, list, dict, tuple, set ][i]()
c = lambda i: [ [0], [0.], [[]], [{}], [(0)], [{0}] ][i][0]
d = eval   # using "0", "0.", "[]", "{}", … as input
e = lambda i: eval( ["0","0.","[]","{}","(0)","{0}"][i] )


This also applies to containers generated during by the function during its execution. (Obviously, this does not apply to such objects if used internally by employed predefined functions.)

# Valid (ungolfed) example

Python:

def f(i):
return sum([2.][0:i])


For this we have:

f(0) == 0
type(f(0)) == int
f(1) == 2.0
type(f(1)) == float


This makes use of the fact that the sum of an empty iterable (like [2.][0:0]) is 0.

# Sandbox questions

• I am pondering whether I should replace a portion of the rules with a catch-all like:

If whatever trick you use to acquire n types of output can be used to obtain n+1 types of output, it is invalid. (If n+1 just doesn’t work because n is the total number of types in your language, this doesn’t count either.)

Obviously, this would lessen the chance of any boring loopholes, but it would also be more likely to be subject to interpretation. Do you think this is a good idea?

• Did I miss any obvious loopholes that would make this challenge boring?

• This challenge was mainly done with Python in mind, but I seen no reason why it should not extend to other programming languages (with a suitable typing system). Are there any obvious pitfalls with other languages that I should consider?

• Are there any other appropriate tags for the question?

• This seems like an interesting challenge at its core, but there are a lot of gotchas. Is indexing into a tuple considered a logical construct? For example, in PowerShell, you can put a Boolean into the index and it will automatically cast to 0 or 1 to get a pseudo-ternary operation. Are languages like Java allowed to use reflection? Etc. – AdmBorkBork Oct 13 '17 at 20:34
• Also in a language like R (my most familiar language), there are really only 7 types as given by typeof() but there are numerous classes which can be found by class(). That being said, every instance of an R class is really list when typeof() is called on it. see this, for example. Basically, you'll have to make a decision for every language submitted on "a suitable typing system" – Giuseppe Oct 13 '17 at 20:44
• @AdmBorkBork: Is indexing into a tuple considered a logical construct? – No, handling logic is not the primary purpose of this feature. I also do not see this as a problem since a tuple is an iterable and thus its elements would have to be of the same type. (Such pseudo-choosing operations are exactly the reason why I imposed that rule.) — Are languages like Java allowed to use reflection? – I only briefly looked into this, but I don’t see a how this could pose a loophole. – Wrzlprmft Oct 13 '17 at 21:24
• @Giuseppe: (T-1)/L rather than (T-1)/C – corrected, thanks. — Basically, you'll have to make a decision for every language submitted on "a suitable typing system" – I added a note that you can pick one and stick to it in that case. Would this pose any problems with your example (R)? – Wrzlprmft Oct 13 '17 at 21:34
• 1. A PowerShell tuple is not an iterable. 2. Plenty of languages have duck typing. That's a clear notion of type, but it has the potential to trivialise this question in the same way that reflection does. E.g. in JavaScript function f(s){var o={};o[s]=f;return o} 3. The Java method you should be looking at is Class.forName. – Peter Taylor Oct 13 '17 at 22:59
• @PeterTaylor: 1. Okay, let me generalise this to containers. 2. I am familiar with duck typing from Python but I don’t see how this provides a loophole. Your JavaScript example always returns something of type object IIUC. 3. From what I just learnt, that seems to be a special case of interpreting strings as code. – Wrzlprmft Oct 13 '17 at 23:28
• 2. "If there are many separate typing systems in your language, you have to pick one and stick to it." I'm using duck typing: your objection is using prototype-based typing. 3. No, it takes a string which is the name of a type and instantiates an object of that type using its public 0-ary constructor. – Peter Taylor Oct 14 '17 at 6:27
• Given that so many approaches are disallowed, can you add a simple example or two of a valid approach? – user2390246 Oct 14 '17 at 8:14
• @PeterTaylor: 2. I get what you are going at now, but I would not consider duck typing a clear typing system in the sense that every object has a unique type (I edited to clarify) – if you so wish, it is the absence of such a system. 3. I gathered that, but how is that not interpreting a string as code? Anyway, I edited that criterion to be more inclusive. – Wrzlprmft Oct 14 '17 at 9:47
• @user2390246: I added an example. – Wrzlprmft Oct 14 '17 at 9:48
• I don't think the edits unambiguously resolve the issues. 2. I can write a typeof function in JavaScript which produces an array of the properties of an object. 3. It's more like a defaultdict lookup than eval. And I don't see how "these strings are subject to all rules" unambiguously prohibits reflection.The contents of the string are characters: the string is not a valid statement or expression, and its contents can't really be said to have a type. – Peter Taylor Oct 14 '17 at 10:53
• @PeterTaylor: 2. I can write a typeof function in JavaScript which produces an array of the properties of an object. – Words fail me. Let’s stick to official type systems (I edited). — 3. unambiguously prohibits reflection – My goal isn’t to prohibit reflection (which is probably fuzzy anyway), but only exploits thereof that make this challenge boring. I restructured the rules and extended them in a way that I hope will clearly cover Class.forName and any other boring exploits. – Wrzlprmft Oct 15 '17 at 9:48

Puzzle:

• Make a program that draws the following figure line by line.

• Your program should wait for one-second(it can be longer, just has to be a noticable difference) after drawing each line.

• Your program can only draw line by line (you cannot jump to another point or re-draw over a line)

• Given a positive integer n, produce an art image of the below drawing

• The angle measures should always be the same (regardless of n's value)

• However, each line's length should be 150*n pixels

• You only need to account for when n = 1, n = 2, n = 3

Specifications:

if n=1:

• length = 150 pixels

if n=2:

• length = 300 pixels

if n=3

• length = 450 pixels

.

.

Answering - Name the language you used followed by its bytes

Example:

Java (swing), 500 bytes

.

Scoring

Good luck!

• You haven't solved the obvious issue "You can't have an equilateral triangle with angles of 45-45-90." (comment from deleted challenge) The sandbox is only helpful if you listen to people who suggest changes, really. – user202729 Oct 22 '17 at 8:00
• I'm not sure what we're being asked to draw. Just the black figure? The black figure and the annotations? – Peter Taylor Oct 23 '17 at 7:07

I have seen many a trivial answer in jelly, so i wish to propose:

• Input two strings
• If the two strings are integers and are equal, output a truthy value.
• Otherwise, output a falsy value.

Clarifications

• You may receive non-integer inputs.
• You will never receive an integer that is outside the bounds [-2³¹, 2³¹). Rules

• Standard loopholes are disallowed.

Scoring:

• This is not your standard code-golf
• the winner person who posts the longest program.
• an entry is invalidated if someone posts a shorter program in the same language.
• Note: i don't believe that this is code-bowling, as only the shortest program in any language is eligible; this is more about finding an obscure language in which the task is actually hard to do, rather than obscure languages where the task is too easy. – Andrew Hill Nov 2 '17 at 22:19
• Easy win for Unary. – Dennis Nov 2 '17 at 22:26
• what a horrible way of representing a program, yeah... any type of 'longest sensible program' task is not so helpful. – Andrew Hill Nov 3 '17 at 3:20
• @Dennis do you think that restricting to languages that have won a standard code-golf challenge in 2017 would help? It does seem that if we have to start putting in language or other implementation restrictions, then this isn't worth posting. Oh well. guess this stays on the proposal board. – Andrew Hill Nov 3 '17 at 3:22

Golf This Question

Your program should output to STDOUT the full text of this question as it appears on your screen, so no HTML. This includes the title and the body. Please do not edit this question whatsoever so-as to keep it the same for all programs.

No reading the text from a file or the internet

This is , so the shortest code wins!

Sandbox Is this a good question? Is there anything I should clarify?

• similar but obviously different since it requires the markdown. – Giuseppe Nov 8 '17 at 16:17
• You should add some rules and winning criteria (which would increase the length of the question, but oh well) – HyperNeutrino Nov 8 '17 at 17:28
• I'm not sure what much this adds beyond the typical KC challenges, and thus it's likely to be closed as a dupe. – AdmBorkBork Nov 8 '17 at 17:36
• @AdmBorkBork I guess OP means to allow access to the internet, in which case it's very different, but I'm not sure... If so, it's basically a challenge about parsing html, or get the result directly from the API (if that's possible). – Stewie Griffin Nov 8 '17 at 18:40
• Include tag about Kolmogorov complexity. – Heimdall Nov 11 '17 at 8:43
• Why the downvotes? – FantaC Nov 21 '17 at 23:24

# Find the min swaps for order one powerset for a List

The question it is write one powerset function and one sort function tha minimize the swaps for doing one order with this compare function on powerset of the List A

cmp(a,b) -- a and b are subset of the list A
if sizeof a > sizeof b then (swap a and b; return)
if sizeof a < sizeof b than return
for i in 1..(sizeof a) repeat
for j in 1..(sizeof A) repeat
if a[i]==A[j] then return
if b[i]==A[j] then (swap a and b; return)


the result of this compare function on the sets wuold be the follow:

(15) -> powSet([1,2,3])
(15)  [[],[1],[2],[3],[1,2],[1,3],[2,3],[1,2,3]]
Type: List List Any
(16) -> powSet([3,2,1])
(16)  [[],[3],[2],[1],[3,2],[3,1],[2,1],[3,2,1]]
Type: List List Any


note that order depend not from the number element, but on the position on the start List A=[1,2,3]

(17) -> powSet([1,2,3,4,5,6])
(17)
[[], [1], [2], [3], [4], [5], [6], [1,2], [1,3], [1,4], [1,5], [1,6], [2,3],
[2,4], [2,5], [2,6], [3,4], [3,5], [3,6], [4,5], [4,6], [5,6], [1,2,3],
[1,2,4], [1,2,5], [1,2,6], [1,3,4], [1,3,5], [1,3,6], [1,4,5], [1,4,6],
[1,5,6], [2,3,4], [2,3,5], [2,3,6], [2,4,5], [2,4,6], [2,5,6], [3,4,5],
[3,4,6], [3,5,6], [4,5,6], [1,2,3,4], [1,2,3,5], [1,2,3,6], [1,2,4,5],
[1,2,4,6], [1,2,5,6], [1,3,4,5], [1,3,4,6], [1,3,5,6], [1,4,5,6],
[2,3,4,5], [2,3,4,6], [2,3,5,6], [2,4,5,6], [3,4,5,6], [1,2,3,4,5],
[1,2,3,4,6], [1,2,3,5,6], [1,2,4,5,6], [1,3,4,5,6], [2,3,4,5,6],
[1,2,3,4,5,6]]
Type: List List Any


Win the one that minimize the swaps for order the powerset of the follow list

[1],[1,2],[1,2,3],[1,2,3,4],[1,2,3,4,5],[1,2,3,4,5,6]


# Patterns match for composed expression

If we have one math expression B(x) [that mean in B appear x] [math expression is one expression where appear only symbols for function and operator of mathematics that are ok for type and compose ] Find the max lengt subexpression g(x) of B contain x such that

B(x)=f(g(x))


And f(y) and g(x) are both math expression.

# Find Max for a function in one interval

R is the set of real numbers. Is given a function f:A->R from set A (⊆ R) to the R, continue and derivable in one close interval

 [a, b]⊆A


Write the shortest program for find

 max{f(x): x in [a,b]}


knowing the function f(x) derivable in the interval [a,b]. The solution has to be correct at last until the V digit after the float point, and for all functions f that has 10 value max in which f'(x)= 0 in [a, b]. codegolf tag

# On Riemann Zeta function domain

If Zeta:C->C is the Riemann Zeta function, we give the set:

 W={b: 0<b<100 and Re(Zeta(0.5+i*b))=-Im(Zeta(0.5+i*b))}


Where Re() return the real part of its argument, and Im() return the imaginary part of its argument.

It is requested to calculate one approximation of each element of W; this means here all b in float numbers with b in 0..100 such way

  abs(Re(Zeta(0.5+i*b))+Im(Zeta(0.5+i*b)))<0.0001


at last, to put all together in a array or list or set of float.

One can note that the below set of zeros for the Riemann function is a subset of above W set.

 {b: 0<b<100 and Zeta(0.5+i*b)=0}


Some test

Some numbers b approssimation to solution of equation

Re(Zeta(0.5+i*x))+Im(Zeta(0.5+i*x))=0


the ones that are approssimation to solution of equation Zeta(0.5+i*x)=0 too

[14.134725, 21.022039, 30.424876, 32.935061, 37.58617815, 40.918719, 43.327073, 48.00515, 49.773832]


the ones not approssimation to solution of equation Zeta(0.5+i*x)=0 too

[12.458493623791109003, 24.351346882420215577, 28.716611773969890307]


The code more short in bytes that find all these approssimations of element of the set W wins...

Code golf tag

• You're going to need to phrase this better and be more precise about what you're asking for. Currently, this sounds a little bit like a homework question. – numbermaniac Apr 22 '17 at 13:25
• This is also formatted improperly. – Erik the Outgolfer Apr 22 '17 at 13:27
• This appears to permit hard-coding the output, which is generally a sign of a bad question. Why not parameterise it? – Peter Taylor Apr 22 '17 at 15:09
• I think now I ' m clear... What is not clear or ambiguous? – user58988 Apr 22 '17 at 15:40
• possibly a little too much difficult... there are numbers that seems solutions but if i increase digits they are just wrong.... – user58988 Apr 23 '17 at 17:55
• Also, it's "approximation". – Steve Bennett May 22 '17 at 6:40
• Being (continuous and) differentiable is quite a weak constraint. There are e.g. nasty functions which are differentiable but whose derivative is not integrable. – Peter Taylor May 22 '17 at 11:47
• One continue function in one close interval [a, b] has max and min – user58988 May 22 '17 at 13:48
• So for the order a PowerSet of one list is all clear... – user58988 Nov 16 '17 at 13:30

# Shortest code to draw a png from stdin

## Rules :

• You’re free to use any image library you want as long as the image library is designed in the same language as your answer.
• The image should be displayed in an Xorg or wayland window or a console framebuffer.
If you’re displaying to a window, you don’t need to create any windows control (in that case the programs ends with CTRL+C).
• The stdin stream doesn’t eof. so the only way to get the image size is to parse png data. Once the image had been displayed, /dev/stdin should be closed.

The answer using the fewest bytes wins !

• Way too easy for some languages and way too hard for others. And how would I do it if my language can't produce graphical output? What if I have neither STDIN nor STDOUT? – Nissa Nov 29 '17 at 16:21
• @StephenLeppik : the point of my question is to suggest that language choice is restricted to languages that can run on Unix systems supportting screening. I don’t know too easy answers, but libpng16 along Xorg libraries should make it possible in a few line of code. – user2284570 Nov 29 '17 at 16:45
• Restricting it to such a small list of languages is a good way of alienating half the site. – Nissa Nov 29 '17 at 16:52
• @StephenLeppik : It just basically, restrict to all languages which can write a hello word. Writing to a framebuffer is just as easy as to write a raw image in device file which opens like a normal file so this doesn’t matter. I’d rather say the list of language that can print a Hello world on Linux or ʙꜱᴅ is huge but not small. – user2284570 Nov 30 '17 at 17:34
• Believe it or not, displaying an image is not a capability that directly follows from being able to print text… – Unrelated String Mar 22 '19 at 2:40
• @UnrelatedString that’s because it’s not possible to do it from text I’m asking this. But this is defintely like writing to a file. – user2284570 Mar 22 '19 at 19:31

# Hack Stack!

Your challenge is to create a code snippet in javascript that will upvote your answer when run. This should not be possible, but maybe it is. We'll see!

## Rules

Standard Loopholes are not allowed.

You should not auto-downvote other answers.

Do not manually upvote any ansewer, please!

The first one to write code that also accepts the answer when it is run by me will remain accepted.

## For discussion:

Is this even a valid challenge?

• I'm a newbie here but I think this is exactly the most dangerous place to ask for code to run on your PC. Too many clever obfuscators, golfers and underhanded practitioners to trust. – workoverflow Dec 10 '17 at 21:27
• Maybe, instead of requesting submissions do something that is (1) possibly impossible, (2) illegal, and (3) unsafe to run on your browser, have the submission try to upvote the answer (even though this might not work) – Esolanging Fruit Dec 10 '17 at 21:43
• I think this counts as asking for malicious code, which is against the site rules. – Laikoni Dec 10 '17 at 22:31
• Thanks for telling me this is illegal and against the rules. I wasn't thinking of it that way. Not a good challenge, then. Should I delete it, or keep it there so that other people with similar ideas can see it? – Reinis Mazeiks Dec 10 '17 at 22:40