# 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

# 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

# Code - Decode

## Cops:

Your task is to write a program or functon wich otuputs encrypted alphabetic input. The same program or function has to be used to encrypt and decrypt messages as the case of ROT13

1. Languaje and length of your program
2. The encrypted output of the input "CODE GOLF"
3. Two more examples of crypted - unencrypted strings

Example:

## Bash, 30 chars

1. "CODE GOLF" <=> "PBQR TBYS"
2. "SHA" <=> "FUN"
3. "Why did the chicken cross the road? Gb trg gb gur bgure fvqr!" <=> "Jul qvq gur puvpxra pebff gur ebnq? To get to the other side!"

You may post your program code an decpription of your crypting algorithm once is considered safe. Shortest uncracked answer wins.

Example:

tr '[A-Za-z]' '[N-ZA-Mn-za-m]'

This bash command crypts and decrypts messages shifting each letter 13 positions in the alphabet.

## Robbers:

Your task is to write a program or function wich otuputs encrypted alphabetic input. The same program or function has to be used to encrypt and decrypt messages as the case of ROT13

Your code has to pass test cases posted on one of the COPS post. The user who cracks most wins.

• First cops and robbers challenge, pleas help me writing it nice. – marcosm Apr 4 '17 at 14:58
• Just to be clear, is the goal of the robbers to crack the encryption algorithm that the cops create? – AdmBorkBork Apr 4 '17 at 15:02
• Folowing the example if one cop posts an answer wich uses ROT13 and a robber implements ROT13 the answer is cracked. – marcosm Apr 4 '17 at 15:05
• You might want to read this, which specifically mentions certain types of encryption/decryption – fəˈnɛtɪk Apr 4 '17 at 15:18
• Certanly I'm not an cryptography expert, wouldn't the constrait of being the same function that crypts-decrypts avoid such cases of random crypt? How can I change robber thread to avoud brute force? – marcosm Apr 4 '17 at 15:25
• The problem with this is that real encryption is really hard to crack. All they need to do is add a random salt, and the robbers have to blindly guess what the salt is. – Nathan Merrill Apr 4 '17 at 17:27
• I'm not sure what the proposed constraint is. An encryption function takes two arguments (plaintext and key) and produces one output (ciphertext). Are you saying that for any plaintext and key, encrypt(encrypt(plaintext, key), key) == plaintext? If so, I think that's essentially a restriction to stream ciphers, and you might as well ditch the whole plaintext processing and ask for a function which takes the key and the length of the plaintext and generates a deterministic output of that length. – Peter Taylor Apr 5 '17 at 11:22
• And it has the same cryptographic flaw that many cops-and-robbers do. It's not even really necessary to use good crypto: something like for(i='secret';n--;putch(i[0]))i=md5(i); would require heavy-duty cracking even if you hinted that that's the structure. – Peter Taylor Apr 5 '17 at 11:25
• ok, i've learned something, thanks for your comments. – marcosm Apr 5 '17 at 13:24

# Shortest “Hello World” for common journaled file systems.

Create a valid file system image as small as possible containing a file or a folder labeled “Hello World” with the following constraint:

• If the hello world is a regular file, it needs to not be empty.
• The file system needs to one of the following: ntfs3.1 ext3/ext4 zfs btrfs hfsplus

Please note you won’t be able to create the smallest file system with normal fomatting tool.
I mean they don’t allows to create the smallest theoriticall size.

## Winner

The answer with the smallest file system

• Hmm, why not xfs/zfs? Also, I don't really think this is a programming problem – ASCII-only Apr 4 '17 at 23:04
• @ASCII-only the challenge seems to easy with xfs. Otherwise I didn’t got an answer to this question chat.stackexchange.com/transcript/message/36478963#36478963 . Though if it can be made on topic for a code challenge, please explain how. Although it is not a code problem, the special case of journaled filesystem require create a program behind the hood due to the huge number of data structure, so I think it’s still a programming problem, even it’s for being able to only write a unique file. – user2284570 Apr 4 '17 at 23:10
• You can make it a code problem by changing it to verifying that a byte sequence is a valid ext3 image. – Peter Taylor Apr 5 '17 at 10:15
• @PeterTaylor hemmm, by turning it in a code challenge, I still want something that can lead to create very small journaled filesystems. But does programming cahllenges needs also to be code challenges in order to be on topic? – user2284570 Apr 5 '17 at 12:32
• How are you drawing a distinction between programming challenges and code challenges? To me they're the same thing. – Peter Taylor Apr 5 '17 at 15:54
• @PeterTaylor I mean by handling or creating algorithms you don’t necessarily write code. But anyway this challenge need to be converted into a code challenge while still generating small filesystems. Any ideas? – user2284570 Apr 5 '17 at 20:39

# Real Programmers Don't Comment Their Code code-golf

(Disclaimer: I do think programmers should comment their code.)
Your task is to write code in one language that removes comments from code in another language. Both single-line and multi-line comments should be removed from your program. You may write code in one language to remove comments from the same language. Input and output may be in any format. Finally, before answering, read the rules, please.

## Rules

1. Your program in language X must take a program in language Y as input and output the code with all comments removed. Language X may be the same as Language Y.
2. You may not use language Y if:
• Language Y has no comments whatsoever.
• Language Y does not have 2 or more types of comment.
3. Language Y should preferably have unusual comment behavior. (Ex.: older programming languages or Haskell)
4. You may not ignore line continuations (usually \ at the end of the line).
5. Your code may not remove anything inside a string literal.
6. Standard loopholes are disallowed.
7. I strongly encourage you, ironically, to provide an explanation if it is unclear how your code works.

This is , so may the best programmer with the shortest code win...

• All answers from here apply to this challenge. I'd say this would be a duplicate. – user42649 Apr 9 '17 at 21:23
• If this isn't a duplicate, it's mostly about selecting a language Y which makes the question as easy as possible. (There are comment markers that are terser to parse than //…\n and /*…*/, so good answers won't be exactly the same, but they'll still be pretty similar.) – user62131 Apr 9 '17 at 22:05
• @ais523 How can I add variation and distinguish my challenge? – ckjbgames Apr 9 '17 at 23:14
• Try requiring a specific Y whose comment behaviour is unusual. A good start would be to pick a language where comments nest, for example, although that might not be enough by itself. – user62131 Apr 9 '17 at 23:17
• But Pascal as given in the example only have 1 comment type (start with (* or {, and end with *) or }, not in string, and not (*)) – tsh Apr 10 '17 at 1:54
• I should make the requirements less strict. – ckjbgames Apr 10 '17 at 12:58
• Done! Requirements less strict. – ckjbgames Apr 10 '17 at 12:59
• "3. Language Y should preferably have unusual comment behavior" very subjective thing, isn't it? – officialaimm Apr 10 '17 at 13:36
• @officialaimm How to make it less subjective? – ckjbgames Apr 10 '17 at 14:44
• This sandbox post has had little activity in a while and little positive reception from the community. Please improve / edit it or delete it to help us clean up the sandbox. – programmer5000 Jun 9 '17 at 14:12

# Background

A "fun" drinking game is based on the classical hard rock song by AC/CD: Thunderstruck. The Thunderstruck drinking game starts when the song starts. When the word "thunder" is heard, the first person starts drinking, not stopping until the word "thunder" is said again. At that point, the next person begins to drink. This continues around the circle until the song ends.

The "twist" is that in the middle of the song, there is an entire verse where thunder is not uttered once. The person who gets this part -- and thus has to drink for the longest period of time -- is said to have been thunderstruck.

# Challenge

Input: An Integer number of players.

Output: Which player got thunderstruck

# Example

Input:  1
Output: 1

Input:  2
Output: 1

Input:  3
Output: 3


# Rules

Here are the rules:

• Assume that the number of players always is a positive integer.
• Output should always give a positive integer.
• You are not allowed to hardcode the number of times before the "solo" / long verse. Meaning your code has to find the longest part without the word thunderstruck, on its own.
• Use the following lyrics for thunderstruck
• Shortest code wins.
• Forbidding hardcoding is not considered an observable requirement. – Wheat Wizard Apr 16 '17 at 17:47
• You should also state exactly which verse is the one without the thunder (it seems like it is the one after the 16th thunder) – Wheat Wizard Apr 16 '17 at 17:48
• And I think your 3rd test case is wrong here is a solution I made in python you can compare it to. – Wheat Wizard Apr 16 '17 at 17:54
• I think this challenge could be made more fun if you also take a song as input and have to find the longest part without a thunder. This would solve your hardcoding problem and make the challenge a little more fun. – Wheat Wizard Apr 16 '17 at 17:56
• Just seconding this; this challenge badly needs to take the song as input. If it doesn't, then the problem is that (even banning hardcoding) it becomes mostly about kolmogorov-complexity of the song (with the actual finding of the long gap becoming almost irrelevant by comparison), which is both a chameleon challenge and a duplicate; and because it's about kolmogorov complexity, thus compression, it'd be quite easy to choose a compressed representation in which the challenge was easier than you think. (Note that even taking input, the challenge is very easy anyway.) – user62131 Apr 17 '17 at 9:34

# Description

Find the number of '1's in a binary number of any length. (Variable name up to you)

# Output

You should output or print an integer/number/string which reflects the number of '1's that were counted.

# Example

10101100 should return 4

# Sandbox

I'm new here, so I don't know if this has been asked before. I searched but I could only find one other similar question, however that required the answer to be in binary, and was somewhat different in terms of the inputs.

My question seems very short and lacking details, but I don't know how to expand further on such a simple challenge.

Any other ways I could improve on my first post in this Stack Exchange?

• codegolf.stackexchange.com/q/47870/194 – Peter Taylor Apr 27 '17 at 10:19
• @PeterTaylor but that involves decimal input. This question is for binary input. – Joel Damien Apr 27 '17 at 11:09
• I'm not sure what you mean. Are you saying that the input will be a string, and the answer has to count the number of times the character '1' appears in it? – Peter Taylor Apr 27 '17 at 11:20
• Easy solution: add up all the numbers in the input. Many answers will have one-character answers. – Comrade SparklePony Apr 27 '17 at 13:48
• O - 05AB1E and 2SABLE polygot 1 byte. – Magic Octopus Urn Apr 28 '17 at 15:38
• @MagicOctopusUrn c'mon 05AB1E and 2sable are practically the same thing I wouldn't call that polyglot :I – HyperNeutrino Sep 10 '17 at 1:45

# Add numbers without math functions.

In this challenge, you must take an input that can take at least 10 numbers separated by commas and add them together without addition, subtraction, multiplication, and division symbols. Least bytes win. Normal code golf rules apply.

## Examples:

Input:

1,2,3,4,5,6,7,8,9,10


Output:

55


Input:

1,1


Output:

2

• You have to define what a math function is. Are we allowed bitwise operations? – Beta Decay May 14 '17 at 22:54
• @BetaDecay Fixed it. – arodebaugh May 15 '17 at 0:50
• I'm assuming summation counts as addition because that's just common sense. Does string or list repetition count as multiplication? – user42649 May 15 '17 at 3:43
• "Do X without math" has no chance of not being closed, just so you know. – feersum May 15 '17 at 4:04
• Probable dup – Digital Trauma May 16 '17 at 23:20

# Bike saddle drawn through a fractal

Based on the Mandelbrot image in every language, and on the observation the 3rd layer (0 indexed) always looks like a bike saddle, I had a little bit different challenge:

• Language must be capable of graphical output or drawing charts (saving files disallowed)
• Render a window or control that is resizable by mouse action. As example, it can be a typical GUI Window with the typical frame that allows resizing
• After resizing the GUI element, the fractal should be updated according to the new pixel space
• The fractal coordinates range from approximately -2-2i to 2+2i
• The pixels outside of the 3rd layer (0 indexed) of Mandelbrot set should have one color; the ones inside 3rd and inner layers should have another. The only two colors used should be clearly distinguishable
• At least 99 iterations
• ASCII art not allowed

Winning conditions:
Shortest version (size in bytes) for each language will get a mention in this post, ordered by size.
No answer will ever be 'accepted' with the button.

• @Mark Jeronimus: credits to you. – sergiol May 27 '17 at 8:48

# Google Logo in Conway's Game of Life

Conway's Game of Life base challenges are always fun so here is a new one.

This is Google's Logo (if you have not somehow seen it):

The font is called Product Sans. Your job is to replicate this logo (no color of course) in 800x439px just like the image (just the letters).

Have fun! This is a popularity contest so the most votes wins. :D Good luck. Of course, this may not be possible but, you never know until you try.

Usual rules apply.

Inspired by this.

• "looks like" isn't a tight enough specification for a challenge. – Mego May 29 '17 at 21:20
• Also consider some method besides first-past-the-post, that winning criteria doesn't really work well with this site. – FryAmTheEggman May 30 '17 at 0:22
• So the answer could replicate it at the 0th generation? – Peter Taylor May 30 '17 at 10:48
• @PeterTaylor Good point – arodebaugh May 30 '17 at 13:14
• @FryAmTheEggman Popularity contest? – arodebaugh May 30 '17 at 13:14
• @Mego Also good point – arodebaugh May 30 '17 at 13:15
• OK I updated stuff maybe it will make this challenge better – arodebaugh May 30 '17 at 13:16
• 1. I don't see how the change you've made addresses my previous point. 2. Pop-con is barely any better than fastest-gun-in-the-west. 3. It's possible to test whether this is possible or not (I highly doubt it) by running the CA backwards. – Peter Taylor May 30 '17 at 16:09

Here's a thing: Let's do the bignum bakeoff again.

Because why not.

### What to do

Write a program in less than 256 characters that outputs the biggest number you can.
Yep, that's it. Biggest return value wins.

We'll run the program on a VM with infinite memory. (How do we do this?)

### Rules

• 256 chars max, excluding whitespace
• Different leagues for each language
• Output however you want
• No explicitly printing numbers until your loop runs out. Print the number you generate directly. {1}
• Program must terminate
• No implementation-dependent shenanigans.
• Implementation-independent shenanigans is encouraged.
• ints are infinite.
• Program must return the same number every time
• Submission must include the approximate return value in any suitable googological notation.
• Whitespace is space, tab, newline, formfeed, and return
• BrainF***: Whitespace is all non-[]+-<> characters

{1} Allowed ways to return: printf("%d", num); return num;, etc.
Banned ways to return: for(;num>0;num--)printf("99999");, etc.

### This is not a dupe of...

This because you can put any characters you want, not just non-digits; because we're hard-limiting the characters.

### Suggested rules

• No floats: float double long double, etc
• No strings or chars
• No bitfeilds
• No looking at Command-line args

Next year's contest will be named after this year's winner, for no particular reason.

http://djm.cc/bignum-rules-posted.txt

### Sandbox

• How do you even test these programs?
• What other rules should we have?
• You don't actually explain the rules of the challenge, we would have to go to that link to find out what we are supposed to do. Aside from that, I think this has a lot of problems with your typing restrictions if these are not limited to C, but limiting it to C wouldn't really fit the spirit of the site. I think you may want to rethink how you want to approach this question. – FryAmTheEggman May 29 '17 at 16:43
• @FryAmTheEggman "Typing restrictions"? (Added proper instructions) – SIGSTACKFAULT May 29 '17 at 16:45
• Your post doesn't describe how people win. Is it by the largest possible number? Anyway, the problems are things like not counting whitespace, which can easily result in degenerate answers, as well as things like I/O streams and whatnot. All of your extra rules seem entirely based around C with no regard for other languages, which will not go well. – FryAmTheEggman May 29 '17 at 16:48
• In answer to "Because why not": because it will be closed as a dupe. – Peter Taylor May 29 '17 at 17:59
• Here's a couple of rules I would consider. 1. Program must generate the same result every time (e.g. not based on timer, probability, or the like). 2. Submissions should include, if not the exact resulting number, at least a best estimate, in scientific notation if need be. – Computronium May 30 '17 at 18:32
• Scientific notation? People will post answers that far, far exceed that. In fact, Mathematica, 22: Fold[Power,2~Range~9999] It's 2^3^4^...^9999. That's not being represented anytime soon. – CalculatorFeline May 31 '17 at 3:31
• This is a duplicate, and is also going to come down a lot to whether or not you allow programs that exceed the computational capacity of any existing computer. (If you require programs to work on a physical computer, the best they can possibly do is to use the entirety of memory as a counter and print out 9s over and over again. If you don't, the answers can easily be large enough that you need to use notation invented specifically for describing the number, because all other notations are not enough.) – user62131 May 31 '17 at 22:40
• If your code can simulate a Turing machine, it becomes hard to judge who the winner is, and whether an answer is valid at all. – anatolyg Jun 1 '17 at 20:35
• Re your latest edit: you're wrong. The question it's a dupe of also has a hard limit to the number of characters; in fact it's a harder one, but the best answers could be copied with slight tweaking to take advantage of the extra space. And the digit restriction turned out not to be a serious problem: the winning answer would gain extremely little from being able to use digits. – Peter Taylor Jun 2 '17 at 9:07

# Buzzfeed's Ultimate Coder Challenge code-golfcode-generation

Buzzfeed recently published a coding test which the guys over in TNB have determined is the world's hardest coding test [citation-needed].

In the language of your choice, given no input, output 8 separate snippets of code in your language. The snippets should do the following, in order:

1 - Print "Hello, world!"
2 - Print 200
3 - Read input from STDIN then print "Hello "[input]
4 - Print 10
5 - Print 25
6 - Terminate silently (do nothing)
7 - Print "a is 1", "a is 2"... all the way to "a is 10"
8 - Print "a is 5", "a is 6", "a is 7", "a is 8"


For challenges 7 and 8, the outputted source should output each output newline separated

### Scoring

This is so fewest bytes in each language wins!

## Meta

• What needs clarifying?
• What other tags could this use?
• Would this perform better as a ?
• Is it even worth posting this challenge at all?
• citation – Adám Jun 7 '17 at 12:10
• Generally, bunching a lot of unrelated tasks is frowned upon. – Adám Jun 7 '17 at 12:11
• Also, several of these tasks will have almost identical answers (2, 4, and 5 being the worst offenders I think). I don't feel this fits very well for any tag on this site. – FryAmTheEggman Jun 7 '17 at 18:26
• 2, 4, and 5 are actually radically different in golfing languages (a builtin for 200 would be very unusual, and it's just large enough to make for an interesting competition between compressed representations, whereas most have a builtin for 10 and some have a builtin for 25). However, that doesn't change the facts that a) they're nonetheless far too easy, and b) asking people to solve a number of unrelated tasks is inferior to splitting them all up into separate questions (which in this case, is inferior to posting them at all). – user62131 Jun 8 '17 at 0:11

# Do nothing

Write a program which terminates normally (not in an error), producing no output on the standard output stream (or the language's closest equivalent), nor on the standard error stream, regardless of what content is present on the standard input stream. (Note that this is intentionally overriding the normal I/O defaults; this is a challenge entirely about input/output handling.)

Additionally, your program may not have any other side effects (e.g. writing files, changing persistent state), unless they're an unavoidable consequence of running a program on the operating system you're using (e.g. on Linux, it's OK to change the "next process ID number to be assigned" value inside the kernel, because that happens whenever you run a program).

Finally, to avoid numerous uninteresting 0-byte (or boilerplate-plus-0-byte) solutions, you may not use a language in which the shortest program that does nothing (i.e. complies with the above specification) is also the shortest (or tied for the shortest) program which runs without error (but possibly reacts to input or produces output). In other words, you can't use a language unless doing nothing is more verbose than doing something.

## Clarifications

• Intentionally exiting the program early is permitted. If you do exit the program manually, on a system that uses exit codes, you may do so with any exit code.
• Crashing the program is not permitted, even if it (for some reason) exits with a "success" code after the crash.
• "No output" means 0 bytes of output, not even a trailing newline.
• Likewise, your program must be able to handle any finite sequence of bytes on the standard input stream, even if it isn't, say, made of characters in the current encoding (but rather of arbitrary octets). You do not need to handle infinite input, though (e.g. your program won't be connected to /dev/zero or the like).

## Victory condition

As a challenge, shorter is better, measured in bytes. (Remember that if you need to run the program in an unusual way, that incurs a byte penalty, under standard PPCG rules.)

Because languages which are particularly suited for this task (such as Perl and Python) are excluded by the rules, there's not much point in talking about the best answer cross-language; rather, the aim is to find the best answer you can in the language which you submit in. (Historically, on this sort of challenge, answers that are more unusual, interesting, or better-explained have tended to get more votes.)

## Sandbox questions

Is this too trivial? We were discussing it in chat as a joke, and realised that it's actually possibly more interesting than it sounds. I'm fairly sure the spec's correct (although would definitely appreciate knowing if something's wrong here!), but would appreciate feedback on how much people would hate me if I posted it to main.

• you can't use a language unless doing nothing is more verbose than doing something.you can't use a program unless your program is more verbose than any other program which does something. You must provide a shorter program which does something to prove your solutions validity. – Adám Jun 8 '17 at 1:03
• @Adám: If you did that, people would just add a comment byte or two to create a program of the shortest possible length that was longer than a program that did something. That isn't particularly interesting. – user62131 Jun 8 '17 at 1:21

# Plan and Chain a route through OEIS

Your Task is to reach so many OEIS sequences you could make with chaining your last sequence with a operation to a new sequence.

You must avoid last sequence minus last sequence plus first sequence or something similar that your new sequence is based on the first sequence except to make the second sequence.

Your starting OEIS sequence is in every case https://oeis.org/A001477

Given as Input an positive Integer and a Letter that matches [A-Z] or [a-Z]

# PHP, 171 bytes

for($a=0;$a<=$argv[1];$a++)$r[]=[$a,$b=$a&1,$c=$a+!$b,$d=(($c-!$b)/2^0)+$b,$A[$b]=$e=$d*$c,$f=$e+$A[!$b],$g=$a?$g*sqrt($f):1,$h=$g%2];echo$r[$argv[1]][ord($argv[2])%32-1];  Try it online! The example gives back the n value of a OEIS sequence for the following letters. A letter greater h is for this example a invalid input • a https://oeis.org/A001477 numbers $a Valid first sequence

• b https://oeis.org/A000035 mod 2
$b=$a&1 Valid use the variable in the sequence before

• c https://oeis.org/A109613 odd numbers
$c=$a+!$b Valid Can use sequences before • d https://oeis.org/A110654 a(n) = floor(n/2) + n mod 2 $d=(($c-!$b)/2^0)+$b Valid an invalid example is $d=(($a/2)^0)+$b cause it not use the sequence before

• e https://oeis.org/A000217 triangular
$A[$b]=$e=$d*$c Valid you can create help variables • f https://oeis.org/A000290 square $f=$e+$A[!$b] Valid use a help variabale and the variable of the sequence before. $f=$A[!$b]+$A[!$b] Invalid causes it makes the same value but use indirectly the variable of the sequence before

• g https://oeis.org/A000142 factorial $g=$a?$g*sqrt($f):1 Valid cause your condition is not always the case that it have no relationship to the sequence before.

• h https://oeis.org/A019590 Fermat's Last Theorem $h=$g%2 Valid but now we have the problem to find the next sequence

Could You make a full alphabet? My alphabet ends with the letter h

• I'm rather confused as to what is being asked here. It might be helpful to state how one can get from one sequence to another. – Wheat Wizard Jun 10 '17 at 20:47
• @WheatWizard I could understand you. The problem is at the moment to make rules that avoid that a trivial solution exits. There are too many sequences in OEIS. The way from every sequence to the next should not end in a simple addition or multiplication. But evrything else should be allowed to get more creative solutions – Jörg Hülsermann Jun 10 '17 at 20:56
• (1) The first sentence says that the aim is to build the longest chain possible, but the scoring mechanism rewards average code length per element in the chain rather than number of chains. I would think it most likely as it stands that the winner would be a chain of length 1 or at most 2. (2) If you delete everything from the header Example to the end, do you think that the question still makes sense? If not (and I don't think it does), it needs a lot of work. (3) What do the two values in the input mean? Why is the second one a letter rather than a number? – Peter Taylor Jun 10 '17 at 21:10
• (4) I'm not sure how feasible it is to write objective rules which forbid "trivial" expressions. (5) It is not clear how to interpret the rule about the 32nd term where either it is not known or the sequence is finite and shorter than 32 terms. – Peter Taylor Jun 10 '17 at 21:12
• @PeterTaylor (1) Think you that popularity Contest is a better winning criteria? (2+3) to limit the chaining length to 26. The goal is to show relationsships between two or more sequences. (4+5) Yes it is not easy and I can drop it if I switch to popularity Contest – Jörg Hülsermann Jun 10 '17 at 21:26
• @WheatWizard I allow now trivial solutions – Jörg Hülsermann Jun 10 '17 at 21:53
• I'm not clear on the purpose of the inputs if we're just supposed to hard code our way from one sequence to the next​. Replacing your PHP example with more generic, more verbose pseudo-code might help. – Shaggy Jun 11 '17 at 0:16
• (too many tags) – programmer5000 Jun 11 '17 at 1:38
• @programmer5000 exists a limit of correct tags? – Jörg Hülsermann Jun 11 '17 at 11:39
• @Shaggy See it as restriction for ways to code. You must have a chaining to the sequence before. So far I know any working code is a pseudocode – Jörg Hülsermann Jun 11 '17 at 11:48
• @JörgHülsermann 5. – programmer5000 Jun 11 '17 at 20:09

# Print a Variable's Memory Address suggestions-needed

Similar to this puzzle I posted earlier, with a difference that should make this challenge easier.

Create a function (not a full program) that prints or returns the memory address of the parameter passed in. Literal values should return a falsey value.

Examples:

var foo = 4901
var bar = "foobarbaz"
var baz = true



Note that you probably won't get the same exact result as show above.

• Example(s) please. – Shaggy Jun 15 '17 at 15:15
• @Shaggy Updated. – Caleb Kleveter Jun 15 '17 at 15:38

# Challenge

Write user scripts that will migrate challenges to and from the Sandbox.

# Criteria

These are my suggestions for criteria that will create the most beautiful user scripts. Feel free to suggest your own!

### Migrating to the Sandbox

The script should...

• only act on a question that has been closed for "unclear what you're asking"
• answer the Sandbox as the original author of the question
• make the title and tags the first line of the answer as a H1-sized header
• link the original question to the Sandbox post, and then delete it

### Migrating from the Sandbox

The script should...

• use the first line to determine the title and tags for the post, and eliminate it from the post body
• error handling here would be a good idea
• create the question as the author of the Sandbox answer
• comment on the question with a link to the Sandbox answer
• replace the Sandbox answer with just the title and link to the question, then delete the Sandbox answer

# Scoring

This is a , so the answer with the highest net of votes will win.

# Sandbox

• Is what I'm asking for even possible? I've never written a user script before. Maybe it should be a question?
• Should this be a Community effort rather than a challenge? Does it even belong on main?
• This is not within the capabilities of a userscript. Also, automating this wouldn't really help at all, since the sandbox only does anything if the poster wants to use it. Anyway, if you disagree with me and still want to pursue this, it should be a question on meta, asking if people want a sandbox migration bot. – FryAmTheEggman Jun 20 '17 at 4:15
• @FryAmTheEggman Thanks for your feedback! I've asked on meta as you suggested. – musicman523 Jun 20 '17 at 4:45

Grep for math in a pdf document

This challenge is likely to need the use of libraries. You may use any free library of your choice as well as any library.

The challenge is simply to write a tool that can grep for "2^n" in a pdf document. That is the math that represents 2 to the power n. You may assume that the pdf was produced from LaTeX which contains $2^n$ and that the pdfr was made using the command line tool pdflatex.

What should the code do?

The code should take a pdf file as input either by reading a file or from standard in. It should output if the file contains "2^n" or not.

Scoring

I will provide a number of pdf files as test examples. Your score will just be how many your code gets right.

Requests for help

I could provide sample pdf documents that do or do not contain 2^n in them.

Does it always appear as an image in the pdf as Mego suggests? If so, this image will depend on the font and font size and this is an image processing task.

• 1. How are you going to score this? Code golf? Popularity contest? 2. PDFs can vary wildly in how something is displayed. If you're specifying that it's produced from a specific program in a specific way, then it's likely just a search for a static string of bytes, which is IMO a boring challenge. 3. What exactly is the output? Is it a simple yes/no, or is it supposed to be location within the file? – Shelvacu Jul 1 '17 at 19:37
• @Shelvacu I was going to score by how often the code gives the right answer. I would ideally like the code to output the first page number it finds 2^n on but I don't know if that is too hard. If it is then the output is just yes/no. – user9206 Jul 2 '17 at 17:38
• So test-battery. – user202729 Mar 23 '18 at 14:35

Your program or function must, given a string in any standard input format, output an infinite stream of delimiter-separated strings where each string is determined from the previous by a braiding algorithm. The program starts with printing the input string.

The algorithm is described as follows: Infinitely alternate between

(1) splitting the string into three substrings then swapping the first two substrings and flattening.

and

(2) splitting the string into three substrings then swapping the last two substrings and flattening.

starting with (1).

The three substrings should be of non-increasing length with the maximum length no more than 1 greater than the minimum length of the three substrings. (This means that when the length of the given string is a multiple of three, the three substrings should be the same length. When the length of the given string is one more than a multiple of three, the first substring should be one character longer than each of the last two substrings. When the length of the given string is two more than a multiple of three, the first and second substrings should each be one character longer than the last substring.)

### Example

Let the input be "abcdefg". Let the delimiter be a newline.

Then the program would first print "abcdefg".

It applies (1) which splits the string into ["abc","de","fg"] and swaps the first two elements, reaching ["de","abc","fg"]. It flattens to get "deabcfg" which it prints and uses for the next step.

The program applies (2) to "deabcfg" to split into ["dea","bc","fg"] and swaps into ["dea","fg","bc"], flattening to reach "deafgbc".

The program applies (1) to "deafgbc" and the process repeats ad infinitum.

Then the output would be the newline-separated

abcdefg
deabcfg
deafgbc
fgdeabc
fgdbcea
bcfgdea
bcfeagd
eabcfgd
eabgdcf
gdeabcf
gdecfab
cfgdeab
cfgabde
abcfgde
abcdefg
deabcfg
deafgbc
fgdeabc
fgdbcea
bcfgdea
bcfeagd
eabcfgd
eabgdcf
gdeabcf
gdecfab
cfgdeab
cfgabde
abcfgde
abcdefg
[...]


### Specifications

• Note that the string should not be split at the beginning and then only swapped later. The string should be split on each and every iteration
• The delimiter between lines could be whichever character is convenient. You may assume it does not appear in the input string.
• The string input shall be at least three characters
• The input consists solely of printable characters (0x20-0x7F)
• Of course, standard loopholes are forbidden.

### I/O

• The input and output should be taken in standard I/O methods.
• The input and output should be taken as string, list of characters, or equivalent.
• The output should be output continuously, which means you may assume infinite memory.

### Test cases

For the test cases, we will assume that the delimiter is a newline. Just the portion before the endless stream is repeats is shown.

input
--
output
-----
abcdefg
--
abcdefg
deabcfg
deafgbc
fgdeabc
fgdbcea
bcfgdea
bcfeagd
eabcfgd
eabgdcf
gdeabcf
gdecfab
cfgdeab
cfgabde
abcfgde
-----
abc
--
abc
bac
bca
cba
cab
acb
-----
abcdefgh
--
abcdefgh
defabcgh
defghabc
ghabcdef
bcdghaef
bcdefgha
efgbcdha
efghabcd
habefgcd
habcdefg
cdehabfg
cdefghab
fghcdeab
fghabcde
abcfghde
abcdefgh
-----
Braid
--
Braid
aiBrd
aidBr
dBair
dBrai
raidB
idraB
idBra
Brida
-----
Cycle
--
Cycle
clCye
cleCy
eCcly
eCycl
yceCl
ycleC
leycC
leCyc
Cylec
-----
--
anaO Cda!
da!anaO C
da!O Cana
O Cda!ana
-----
A man, a plan, a canal - panama!
--
A man, a plan, a canal - panama!
an, a canalA man, a pl - panama!
an, a canal - panama!A man, a pl
- panama!Aan, a canal man, a pl
- panama!A man, a plan, a canal
man, a pla - panama!An, a canal
man, a plan, a canal - panama!A
n, a canal  man, a pla- panama!A
n, a canal - panama!A man, a pla
- panama!A n, a canal man, a pla
- panama!A man, a plan, a canal
man, a plan- panama!A , a canal
man, a plan, a canal - panama!A
, a canal -man, a plan panama!A
, a canal - panama!A man, a plan
panama!A m, a canal -an, a plan
panama!A man, a plan, a canal -
an, a plan, panama!A m a canal -
an, a plan, a canal - panama!A m
a canal - an, a plan,panama!A m
a canal - panama!A man, a plan,
panama!A ma a canal - n, a plan,
panama!A man, a plan, a canal -
n, a plan, panama!A maa canal -
n, a plan, a canal - panama!A ma
a canal - pn, a plan, anama!A ma
a canal - panama!A man, a plan,
anama!A mana canal - p, a plan,
anama!A man, a plan, a canal - p
, a plan, aanama!A man canal - p
, a plan, a canal - panama!A man
canal - pa, a plan, anama!A man
canal - panama!A man, a plan, a
nama!A man, canal - pa a plan, a
nama!A man, a plan, a canal - pa
a plan, a nama!A man,canal - pa
a plan, a canal - panama!A man,
canal - pan a plan, a ama!A man,
canal - panama!A man, a plan, a
ama!A man, canal - pana plan, a
ama!A man, a plan, a canal - pan
a plan, a cama!A man, anal - pan
a plan, a canal - panama!A man,
anal - panaa plan, a cma!A man,
anal - panama!A man, a plan, a c
ma!A man, aanal - pana plan, a c
ma!A man, a plan, a canal - pana
plan, a cama!A man, anal - pana
plan, a canal - panama!A man, a
nal - panam plan, a caa!A man, a
nal - panama!A man, a plan, a ca
a!A man, a nal - panamplan, a ca
a!A man, a plan, a canal - panam
plan, a cana!A man, a al - panam
plan, a canal - panama!A man, a
al - panamaplan, a can!A man, a
al - panama!A man, a plan, a can
!A man, a pal - panamalan, a can
!A man, a plan, a canal - panama
lan, a cana!A man, a pl - panama
lan, a canal - panama!A man, a p
l - panama!lan, a canaA man, a p
l - panama!A man, a plan, a cana
A man, a pll - panama!an, a cana


# Rock Paper Scissors, but it's a big, custom tournament

We all know "Rock, Paper, Scissors", and it's pretty variated.

A world tournament is held every year, and it's dang popular.

However, the contestants are able to bring their own ways of play to the plate, and they play with them.

# The challenge:

Create a program that, by process of elimination through RPS, determines the winner of the tournament.

# The tournament rules:

• No slackers. (Let the amount of players be an integer equally divisible by 2. [In other words, an even number.])

• You can bring 2 of either of the 4 variants:

None: Play regular RPS.

RPSLV: Play "Rock, Paper, Scissors, Lizard, Spock" (play diagram shown here).

Best out of three: Play 3 rounds; if by round 2, a player wins the round and has two points, they auto win. Else, winner of the next round wins.

Double RPS: Play with four hands (two hands used by each player).

• You cannot bring two of the same variant.

• In order to use a variant, the two players must have the same type of variant. If there are no matching variants, the gameplay is automatically None.

• However, if there are more than one variant matches, a game of mode None will be played. The winner of the game mentioned decides what mode they play for the match they will play to see who goes to the next round.

• In the case of a tie, replay until a win occurs (for all modes)

• There can be only one winner.

# The coding rules:

• All choices must be randomized (no strategies, to make this simple.).

• No standard loopholes.

• Give an explanation as much as you can. (If possible, include a "Try it out online" sample.)

# Sample Input/Output:

You must make a table variable with all the player numbers, from 1 to n, with two variants for each player.

n = the amount of players you intend to enter.

Example Input:

Player # | Var 1 | Var 2
1        | RSPLV | None
2        | None  | x2 RPS
3        | x2 RPS| Boo3
4        | Boo3  | x2 RPS
...      |...    | ...


Make a func() that:

1: Checks the variants of the next two availible players on the list, starting at player 1, then does the second to third last rules depending on what happens.

2: Makes the pair engage in battle, gameplay depending on the chosen variant.

3: Finally, boot the loser off the game and add the winner to the next list (round). (The "boot the loser" part isn't that required, but I recommend so as to not make the program add a player to the next table.)

Output (uses table from input):

 Round 1:
1 vs. 2 // None, since the None variant matches both of them
["Rock"/*1*/,"Scissors"/*2*/]
1 wins

3 vs. 4 // They have more than one match, so they fight for who decides
["P"/*3*/,"S"/*4*/]
4 wins, and chooses Best out of 3
Match 1:
["P"/*3*/,"R"/*4*/] // 1(3) - 0(4)

Match 2:
["P"/*3*/,"S"/*4*/] // 1(3) - 1(4)

Match 3:
["P"/*3*/,"R"/*4*/] // 2(3) - 1(4)
3 wins

Round 2:
1 vs. 4 //No matches, defaults to None
["R"/*1*/,"R"/*4*/] // No-one wins
["R"/*1*/,"S"/*4*/]
1 wins the tournament


# Misc. requirements (some optional):

A {!} means it is required.

• {!} Print each match, and who wins.

• {!} Print the tournament winner.

• {!} The number of players must be flexible.

• Print the table for each round.

# Scenarios:

None:

a vs. b //Either they have no matches, or they have both None matches
["R"/*a*/,"S"/*b*/]
a wins


RPSLV (will make this one quick):

a vs. b //RPSLV chosen
["V"/*a*/,"L"/*b*/]
b wins


Best out of Three:

Scenario 1: (a tie occurs at match 2)

a vs. b //Boo3 chosen
Match 1:
["P"/*a*/,"S"/*b*/] // 0(a) - 1(b)

Match 2:
["P"/*a*/,"P"/*b*/] // tie
["P"/*a*/,"S"/*b*/] // 1(a) - 1(b)

Match 3:
["R"/*a*/,"S"/*4*/] // 2(a) - 1(b)
a wins


Scenario 2: (a player has two points by the end of match 2)

a vs. b //Boo3 chosen
Match 1:
["P"/*a*/,"S"/*b*/] // 0(a) - 1(b)

Match 2:
["S"/*a*/,"P"/*b*/] // 0(a) - 2(b)
b automatically wins


Double RPS:

a vs. b //x2 RPS chosen
[("R", "P")/*a*/, ("S", "S")/*b*/] // lock
[("P", "P")/*a*/, ("S", "S")/*b*/]
b wins


# For sandbox use only (won't be included in real question)

I don't know if this kind of problem is suitable for code golf, it could be a programming puzzle, I'm not sure. Go ahead in the comments and tell me what mode it should be, and if I should improve it. (Also, sorry for the mix of Python lists and C++ comments, if it confuses you.) A ** means the choice is random.

• Hi and welcome to PPCG, and thanks for using the sandbox! I had a hard time following what you intended from this challenge. The rules are rather disorganised with many points early on not making sense until later. For example, you say: "No slackers. (Let p be a number equally divisible by 2.)" before it is clear that you intend for us to implement a single elimination tournament. I had no idea what "p" was supposed to mean, or why this should matter. I'd recommend trying to explain this to someone verbally, perhaps, to try to organise your thoughts better. Good luck! – FryAmTheEggman Jul 15 '17 at 21:50
• Ah, thanks. I will edit the problem. – S.G. Harmonia Jul 15 '17 at 22:03
• I'm not quite sure what we're supposed to implement. The controller for the tournament and what else? Do we also implement the players, so that we're simulating the entire thing? Or do we have to provide some kind of API for the players? In the first case, how does "The winner decides what mode they play" work? – Peter Taylor Jul 16 '17 at 7:14
• Again, any multi-choice is random. – S.G. Harmonia Jul 16 '17 at 19:29

# Quick! Tell me all the numbers from 1 to 100,000! fastest-codenumbers

Your task is to write a program or function that, when run, output all the numbers from 1 to 100 thousand as quickly as possible to STDOUT. It's that simple. All answers are tested on an HP Compaq nx9420 with an Intel Core Duo @ 1.83 GHz and 3 gigs of RAM using the time command.

Of course, standard loopholes are strictly forbidden.
This is , so may the fastest code win and the best programmer prosper...

• Have you tried running an example to see if the times are variable enough to be meaningful? As-is, this is going to be strongly dependent upon how fast the code can do I/O, which makes the challenge pretty uninteresting, IMO. – AdmBorkBork Jul 19 '17 at 18:16
• @AdmBorkBork Might be interesting – ckjbgames Jul 19 '17 at 21:12
• As far as I can tell, this takes less than a tenth of a second, which means submissions will probably be differentiated solely by noise on your computer. – FryAmTheEggman Jul 20 '17 at 2:37
• upvoted, though I think the differenciation is really difficult, unless you test it on a raspberry PI (for example) having ONLY the program and its compiler installed. – V. Courtois Jul 20 '17 at 13:36
• @FryAmTheEggman How could I improve on that? – ckjbgames Jul 20 '17 at 23:38
• @V.Courtois I do have a Pi, and I think I will use that (it has Raspbian installed). – ckjbgames Jul 20 '17 at 23:39
• The time is still so small even a basic operating system will have to much noise in process creation, etc, for this to work out. You need to make what we are computing substantially more complicated for this to be reasonable. – FryAmTheEggman Jul 21 '17 at 0:10
• @FryAmTheEggman K – ckjbgames Jul 21 '17 at 1:20
• @ckjbgames good then :) – V. Courtois Jul 21 '17 at 5:26

# Is it cat-urday?

Caturday is one of the oldest memes out there. For this challenge you need to write a program that outputs the input, but only on Saturday.

## The catch:

You can acquire the date via UNIX timestamp, or as a formatted date string (local or UTC). However, you can not:

• use day of the week information in a date string
• directly acquire the day of the week of a date by some other means
• use Date or Calendar functions, beyond one to simply give you the current date
• use any external resources (files, Internet)

Don't forget leap years!

Does this question work as is? Should I make anything clearer?

• This is a "do X without Y" challenges, and those have been done to death. – caird coinheringaahing Jul 22 '17 at 20:28

# Lennyface parser and selector

Create, in the language of your choice, a program that outputs a randomly selected lennyface (artistic minifigures, see this) from an input - a string composed of numbers and lennyfaces. You will have to : first, parse this input; second, extract a probability mass function f from the parsed input; third, select and output a lennyface respecting f. Read the rules for more details.

## Rules

• Input : A string with lennyfaces and numbers (positive AND negative integers), separated by newlines. You may take input by STDIN or function parameter for example.
• Output (STDOUT for example) : the randomly-selected lennyface, as a string.
• The input creates a probability mass function f. If l is a lennyface, then f(l)=(sum of all numbers since the previous lennyface)/x where x is obtained afterwards by summing each of those numerators. @Sandbox : is it clear enough?
• If (sum of all numbers since the previous lennyface) is equal to zero or negative, you must do as if the numerator is equal to 1 in f's definition.
• A line with a number contains only this number ; same for a line with a lennyface. So you can assume there will never be a number in a lennyface.
• If there is nothing on a line (two newlines in a row), you must consider it as a lennyface.
• You must consider that the last line of the string is directly before its first line. See Test 1 for an example.
• You can assume there will be at least 1 lennyface in the list; it cannot be composed just by numbers (don't forget that an empty line is a lennyface too).

## Example

Given this input list :

( ͡° ͜ʖ ͡°)
2
¯\_ツ_/¯
34
-4
8
└[⸟‿⸟]┘

1


You must have 1/42 chances of outputting ( ͡° ͜ʖ ͡°), 2/42 chances of outputting ¯\_ツ_/¯, 38/42 chances of outputting └[⸟‿⸟]┘ and 1/42 chances of outputting nothing (line 7).

## Test cases

Test 1

(⌐■_■)
3


Must output (⌐■_■) with 3/3 chances.

Test 2

ʢ◉ᴥ◉ʡ


Must output ʢ◉ᴥ◉ʡ with 1/1 chance.

Test 3

0
\(ᗝ)/


Must output \(ᗝ)/ with 1/1 chance.

Test 4

( ͡° ͜ʖ ͡°)
2
¯\_ツ_/¯
34
4
☞   ͜ʖ  ☞

0


Must output ( ͡° ͜ʖ ͡°) with 1/42 chance, ¯\_ツ_/¯ with 1/21 chance, ☞  ͜ʖ  ☞ with 19/21 chances and nothing with 1/42 chance.

Test 5

1

( ͡° ͜ʖ ͡°)


Must output ( ͡° ͜ʖ ͡°) with 1/4 chance and nothing with 3/4 chance, since there are 3 empty lines.

Test 6

42

-1
( ͡° ͜ʖ ͡°)



Must output nothing with 43/44 chance and ( ͡° ͜ʖ ͡°) with 1/44 chance.

@Sandbox : should I add test cases?

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

Note : Please do not be discouraged if the parsing is difficult to handle in your language, or if testing is hard because of randomness. Your solution might be very interesting algorithmically, not obviously in terms of golfing. Just please explain in your answer why it works.

Moreover, this is the first code-golf I create, so please let me know if something is not appropriate or if I should give more details on a point. And overall, if you downvote, explain me why so I can improve it.

• Yours tests seems a bit contraditory. The number is the chance of the next face (line), so what's the point of the empty line in the example / test 4? By the same logic, the test1 should have a 3/4 of outputting nothing? What is the point of the 0 in the test 4? – Rod Jul 3 '17 at 14:03
• Why is the chance of outputting ( ͡° ͜ʖ ͡°) 1/42 and not 0 ? (since there are no numbers above it) – Dada Jul 3 '17 at 14:04
• Sorry ! I forgot to copy paste the fact that the minimal chance is 1! – V. Courtois Jul 3 '17 at 14:05
• Also, a common thing to do on challenges involving randomness, and therefore, hard to test, is to ask people to provide a mandatory explanation, or at least ask them to show why it works. – Dada Jul 3 '17 at 14:05
• @Dada thanks. I note this. – V. Courtois Jul 3 '17 at 14:06
• @Rod the empty line is a lennyface, as said here : If there is nothing on a line, you must consider it as a lennyface. – V. Courtois Jul 3 '17 at 14:08
• @V.Courtois I meant and empty line without a preceding number – Rod Jul 3 '17 at 14:09
• As I said, the minimum is one (sorry again for forgetting it). – V. Courtois Jul 3 '17 at 14:10
• If only positive integers are to be expected, you should write it. Otherwise, give some details and examples about what you consider "numbers". – Dada Jul 3 '17 at 14:12
• @Dada editing. In fact I said the minimum is 1, but you can have things like 2,-1,-3,17 and then your lennyface ; that means the probability is 15/ total. – V. Courtois Jul 3 '17 at 14:14
• @V.Courtois just a small suggestion, to make the "list as circle" more explicit you could change the value to something else than 0 or 1, this way it would not overlap the "missing number" rule – Rod Jul 3 '17 at 14:15
• @Rod does it? Sorry if I'm not getting what you are saying, but the list is always a circle, meaning if your list is 2,3,( ͡° ͜ʖ ͡°),4,5,☞  ͜ʖ  ☞,6, you have 6+2+3 chance of getting ( ͡° ͜ʖ ͡°) and 4+5 chance of getting ☞  ͜ʖ  ☞. – V. Courtois Jul 3 '17 at 14:18
• thanks for editing @musicman523 – V. Courtois Jul 4 '17 at 7:21
• KISS. This is far more complicated than common sense would require. Deliberately overcomplicating things to make it "more difficult" is a guaranteed method to make a bad question. – Peter Taylor Jul 4 '17 at 7:32
• The challenge has two parts as far as I can tell. a) Create a probability mass function from an input by parsing b) sample from the probability mass function. Part a) needs to be rewritten as it is at best ambiguous and at worst just incorrect. – user9206 Jul 5 '17 at 7:50