# Sandbox for Proposed Challenges

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

Sandbox FAQ

## Posting

Write your challenge just as you would when actually posting it, though you can optionally add a title at the top. You may also add some notes about specific things you would like to clarify before posting it. Other users will help you improve your challenge by rating and discussing it.

When you think your challenge is ready for the public, go ahead and post it, and replace the post here with a link to the challenge and delete the sandbox post.

## Discussion

The purpose of the sandbox is to give and receive feedback on posts. If you want to, feel free to give feedback to any posts you see here. Important things to comment about can include:

• Parts of the challenge you found unclear
• Problems that could make the challenge uninteresting or unfit for the site

You don't need any qualifications to review sandbox posts. The target audience of most of these challenges is code golfers like you, so anything you find unclear will probably be unclear to others.

If you think one of your posts needs more feedback, but it's been ignored, you can ask for feedback in The Nineteenth Byte. It's not only allowed, but highly recommended!

It is recommended to leave your posts in the sandbox for at least several days, and until it receives upvotes and any feedback has been addressed.

## Other

Search the sandbox / Browse your pending proposals

The sandbox works best if you sort posts by active.

To add an inline tag to a proposal use shortcut link syntax with a prefix: [tag:king-of-the-hill]. To search for posts with a certain tag, include the name in quotes: "king-of-the-hill".

Get the Sandbox Viewer to view the sandbox more easily!

# 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.
– user45941
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. Mar 19 '17 at 4:47
• I'm confused by this "prevents hardcoding" as hard-coding a string is exactly the problem statement. 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. 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. 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. 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. 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. 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... 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. 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. 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? 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. Apr 4 '17 at 15:05
• You might want to read this, which specifically mentions certain types of encryption/decryption 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? 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. 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. 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. Apr 5 '17 at 11:25
• ok, i've learned something, thanks for your comments. 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 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. 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. 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? 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. 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? 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? 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. Apr 10 '17 at 12:58
• Done! Requirements less strict. Apr 10 '17 at 12:59
• "3. Language Y should preferably have unusual comment behavior" very subjective thing, isn't it? Apr 10 '17 at 13:36
• @officialaimm How to make it less subjective? 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.
– user58826
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.
– Grain Ghost Mod
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)
– Grain Ghost Mod
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.
– Grain Ghost Mod
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.
– Grain Ghost Mod
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 Apr 27 '17 at 10:19
• @PeterTaylor but that involves decimal input. This question is for binary input. 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? Apr 27 '17 at 11:20
• Easy solution: add up all the numbers in the input. Many answers will have one-character answers. Apr 27 '17 at 13:48
• O - 05AB1E and 2SABLE polygot 1 byte. Apr 28 '17 at 15:38
• @MagicOctopusUrn c'mon 05AB1E and 2sable are practically the same thing I wouldn't call that polyglot :I
– hyper-neutrino Mod
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? May 14 '17 at 22:54
• @BetaDecay Fixed it. 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. May 15 '17 at 4:04
• Probable dup May 16 '17 at 23:20

# 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.
– user45941
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. May 30 '17 at 0:22
• So the answer could replicate it at the 0th generation? May 30 '17 at 10:48
• @PeterTaylor Good point May 30 '17 at 13:14
• @FryAmTheEggman Popularity contest? May 30 '17 at 13:14
• @Mego Also good point May 30 '17 at 13:15
• OK I updated stuff maybe it will make this challenge better 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. May 30 '17 at 16: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. Jun 15 '17 at 15:15
• @Shaggy Updated. 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. Jun 20 '17 at 4:15
• @FryAmTheEggman Thanks for your feedback! I've asked on meta as you suggested. 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? 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. Mar 23 '18 at 14:35

# Output the infinite sequence of middle positions of odd square numbers code-golf

As everyone knows, every odd square number has an element at its central position — I represent those central elements as an *:

n=1 => 1
*

n=9 => 5
###
#*#
###

n=25 => 13
#####
#####
##*##
#####
#####

n=49 => 25
#######
#######
#######
###*###
#######
#######
#######


The challenge consists on output the sequence 1, 5, 13, 25, ... uninterruptedly. The separator does not need to be a comma, but use the same separator always.

There will not be any accepted answer, except if I see some very creative answer. There will be a winner for each language (I will steal Leader board code somewhere)

• Is this equivalent to "output (N+1)/2 for every odd square number N"? Aug 3 '17 at 17:15
• @trichoplax: Yes. Aug 3 '17 at 17:40
• There will not be any accepted answer, except if I see some very creative answer The whole point of code-golf is the shortest answer wins. Why output constantly and not return the Nth or first N terms? Aug 4 '17 at 10:08
• Also surely this boils down to for(i=1;;i+=2)Output((i**2+1)/2+",") which isn't that exciting. Aug 4 '17 at 10:09

# Hello, Quine! code-golfquinehello-worldrestricted-source

Your task is to write a program which, if given an input of "Hello," will output "Hello, world!", if given any other input, it will output its source code.

## Rules

• Input does not have to be case-sensitive.
• Your program may not contain the string "Hello, world!" or any variation with different cases of letters (i.e "hELLO, WORLD!", "HeLlO, WoRlD!", and "hello, world!").
• No "cheating quines."
• Standard loopholes are strictly forbidden.

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

• This is combining two different challenges into one, and I don't see a good reason to do so. (Output your source, and output Hello, World! without it in your source). Also, restricted-source. Aug 3 '17 at 17:36
• @StepHen How could I distinguish it somewhat? Aug 3 '17 at 17:40
• Distinguish it from what? It's just combing two already used challenges - Hello, World! without important characters, and quining, into one. Aug 3 '17 at 17:43
• @StepHen Definitely true. Aug 3 '17 at 17:46

# Complicating Simple Maths code-golf

We do know what 1 + 1 is, or 2 - 1. How about we turn those and other really simple operations into complex numbers?

## Goal:

As stated in the intro, taking an operation that can be done within the range of the following operators ( +, -, /, *, ^ and () ), print out a complex number operation that is pretty much a transformed version, and when done using the order of operations, results in the same answer as the inputted operation.

## Examples:

Input: 5 - 1
Output: 5 + 2i

Input: 4 * (7 ^ 2)
Output: (4 * 4i) * (7 ^ 2)


## Rules:

• It is recommended you print out the sector(s) that holds your complex number(s) as a + bi, e.g. (a + bi) - (ci * (di ^ f)). (NOTE: If you are doing non-communicative operations, such as ^, /, or -, the recommendation doesn't apply to the sub-operation).

• If you want to, feel free to use operations/functions other than the set mentioned in the Goal, but your input operation must have at least one of them.

• You can format your operators in any way, e.g. x or • instead of *, ÷ instead of /, etc.

• Input and output is allowed in any format as long as it fits within the standard I/O rules.

• Input must also be flexible (as in to return any input from a simple operation to a complex number operation.

• This is , so shortest answer wins.

## Sandbox use only:

Is there any way I can improve this challenge? Are there any other loopholes to be covered in the rules?

• Can you relax output to standard IO too? At the moment it seems you can only print the result. Also isn't this essentially calculate the result of the inputted expression then work out a complex expression that gives the same answer seeing as you don't need to keep anything in the input the same. Aug 7 '17 at 10:32
• And if that is the case isn't this challenge just return input + (1 + i^2)? Aug 7 '17 at 10:33
• No, the challenge is to transform parts of the input into complex numbers and output that. Aug 7 '17 at 13:13
• But 5 - 1 becomes 5 + 2i You are removing two stages - and 1 and adding 2 + and 2i. It's not entirely clear how much you can remove and how much you can add. Aug 7 '17 at 13:15
• At least one sub-operation should be transformed from simple to complex (which could take two steps). Aug 7 '17 at 13:16

# The Self-Referential Algorithm

Most people are familiar with Tupper's self-referential formula. When the formula is graphed on a calculator it magically graphs itself. Wouldn't it be interesting if we could do something similar with a programming language?

Write a small program that will be able to output exactly itself when ran.

This is a question so answers will be scored in bytes, with the fewest bytes winning.

# 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 Aug 17 '17 at 17:33
• Duplicate 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? Aug 22 '17 at 20:02
• Submissions would mostly be Minecraft commands, but maybe in the first few rounds instructions. Aug 23 '17 at 5:39

# The Compressor

You are given this list of 100 positive integers that are at between 7 and 18 digits long:

[list to come]

You need to generate 100 snippets that will produce these numbers in some language (either as a numeric or string). Your score is the total length of the snippets. Lowest score overall wins, but you should also try to get the lowest score in whichever language your snippets are in. Please include both your snippets and any code you used to generate them in your submission. Note: the generating code isn't actually scored.

## Rules

• The snippets must all be in one language, however it does not need to be the same language as the generating program(s).
• You may assume that any pre-existing libraries you use are already imported.
• You don't need to include the line terminator (i.e ';' in Java and others) for snippets that fit on one line. For multi-line snippets, you don't need to put a terminator on the last line.

## Examples

• 1357000 => 1357e3 (many languages)
• 1234567 => 1234567 (most languages)
• 307422089600 => S6*99b (CJam, returns value of [32,32,32,32,32,32] in base 99)
• 12582912 => 12<<20 (JS + others)

### Alternative: code-golf

I generated this 100 digit random number with random.org:

7160708104901559695507628057638725214364226867212714872539720713967912042100814603497742352846014272

Write the shortest possible program that outputs this number.

Related: No strings (or numbers) attached

Questions? Clarifications?

• I would say that rather than having the input be a list of 100 numbers, have the input be a single number and just have score be the sum of output lengths when applied to each of the 100 numbers. I think that this will avoid confusion over valid output formats, without altering the interesting part of the problem. Sep 7 '17 at 21:14
• I would also say that this could be dangerously close to a duplicate, since answers to that challenge seem likely to score well in this one with relatively minor modifications. Sep 7 '17 at 21:15
• @KamilDrakari I'm trying to understand your suggestion. Currently the score is lowest sum of output lengths. Sep 7 '17 at 22:15
• currently the challenge is for a program which takes a list of numbers and outputs 100 snippets. I think the challenge would be better if the program takes 1 number and outputs 1 snippet, and gets run 100 times to score it. Sep 8 '17 at 13:04
• @KamilDrakari You're allowed to make a program that takes 1 snippet at a time, because you are score on the snippets, not the program. The program is a meta-program. Sep 8 '17 at 14:46
• I think having both options should be more clearly stated then. One other suggestion: you mention "Lowest score in a particular language", which I think should be explicitly clarified whether answers compete based on the language of their snippets or their generating program. Sep 8 '17 at 14:59

# Ulam spiral 2

Like Ulam, I had a boring moment and began drawing a spiral like him's. But his version is utterly incorrect, as the \ diagonal distorts the equation n^2.

The following picture illustrates an wrong Ulam spiral at left and a correct at right:

I challenge you to output a numbered Ulam spiral, the right version, where it is mandatory to highlight the primes. The input is n, meaning the point where the spiral ends. For the image example I gave n was 100. It will always begin at 1

I don't care what highlight style you use (different color, font weight, circle around number, etc), given it makes the primes easily distinguishable form the rest.

There will be no accepted answer; just did it for fun.

• This isn't [arithmetic]. Sep 19 '17 at 19:06
• Also, can you provide an actual explanation of how you got the second one? Sep 19 '17 at 19:07
• You can only have a maximum of 5 tags per question. Sep 19 '17 at 19:36
• @Riker there is a pattern. Interpreting it is part of the challenge. Sep 19 '17 at 19:50
• @sergiol -1, that's no fun at all. The first person can figure it out, and the rest can and will copy the pattern. PPCG doesn't work well with the "find the pattern and decode it" style. Sep 19 '17 at 21:40
• wrong Ulam spiral at left; I thought the spiral on the left was the Ulam spiral? Sep 20 '17 at 2:20
• @JonathanFrech: Yes. Sep 20 '17 at 9:21

Looking for some help to make this code golf/question better.

Proposal:

Now that twitter has increased it's character limit from 140 to 280, there's a joke of almost enough to write Hello World! in Java. But what actual programs could you write in 280 characters, fizz buzz? Sure you could write many in 140 or less, but maximum points if you get a good program in the full 280.

• Hello! Your programming challenge needs an actual task... Think of an idea first, then come here again!
– hyper-neutrino Mod
Sep 27 '17 at 14:01
• So "do something in exactly 280 bytes"? Yeah, you're going to need a much better spec than that. As well as a winning criterion. Sep 27 '17 at 14:25
• There is some precedent for a similar challenge, but that was more narrow, more clearly defined, and it was still closed for being "too broad" (though it did have some interesting answers). I don't think this would really offer any improvements over that existing challenge. Sep 27 '17 at 14:40
• codegolf.stackexchange.com/questions/35569/… is basically what you're describing except the limit is 280 rather than 140 characters Sep 28 '17 at 21:40

# Shortest golang code to println the first byte of a function’s code

## Rules

• The code must be a function which takes another function as parameter and will print the first cpu instruction byte of parameter such as :

.

func dummy() {
}
print_first_native_instruction_byte(dummy)


would print :

0x90


which is a nop instruction on x86.

• You don’t need to perform disassembling : if the first instruction is longer than one byte, just print it’s first byte anyway without caring about instruction meaning or instruction length. Please note this is harder than just printing the value pointed by &dummy in the case of my example though.
• The function parameter must be a go function, not a cgo or assembly function.
• You can include as many golang packages as you want.
• The code need to be written in Go. A well known language developped at Google and part of the four Google’s app engines supported languages and answers should be able to run on the official go playground.

## Winner

The one with the shortest code… Import statements included.

• Please note this is a little harder than just getting the value of &dummy in my example code, and requires internal knowlwedge of the official go implementation. but it doesn’t requires architecture specific code beside handling big endian or little endian. Oct 1 '17 at 20:37

# Preposition, not possession

## Enthralling background

Back in 1960s Soviet Russia, communism was the thing, and –– as we all know –– in a completely socialist society, there is ideally no personal property.

Our dear client is an author who is moving to the Soviet Union. However, as is Bolshevik custom, our client is afraid his works will be censored. That is why we are going to help this industrious author by revising his writings so that they will not be censored.

What will be censored? Any overt references to ownership.

How will we do this? Quite simply: we will replace all possession with preposition.

## Let's get specific

### Example

Text in parenthesis is added; text in curly-brackets is removed.

[Input]   All the author's works will be censored!
[Output]  All (the works of )the author{'s works} will be censored!


### Algorithmically

1. For each word with a 's attached to it:
2. Call the word with an 's attached to it _word_
3. Call the following word _object_
4. Remove all 'ss and _object_
5. Insert The _object_ of two words before _word_
6. If there are not two words before _word_, place _object_ right before _word_.

Here are some more examples:

Then the red horse stopped and took the orangutang's oranges. What a fuss ensued!
Then the red horse stopped and took the oranges of the orangutang. What a fuss ensued!

It is the people's right to not own anything!
It is the right of the people to not own anything!

The world's tallest building was once the Empire State Building.
The tallest of the world building was once the Empire State Building.

Bill likes Fred's shoes, and Jill likes Beth's dress.
Bill likes the shoes of Fred, and Jill likes the dress of Beth.

Ryan's fear was a stack overflow.
The fear of Ryan was a stack overflow.


# Output the first digit of Graham's number

Code golf

Write a program that will output the first digit of Graham's number (and nothing else), terminate and produce no error.

I'll be lenient about loopholes. But if your submission is something like print("4"), the burden of proof will be on you.* Also, if you submit 9 answers like that, each printing one digit, then yes, one will definitely be correct, but I will need to know which one, and, you guessed it, the burden of proof is on you.*

* Catch: at the moment, no one has yet worked out what the first digit of Graham's number is.

But I want a "practical" solution. Yes, the algorithm is simple, but I'm sure your computer doesn't have unlimited storage. Nor do language implementations have arbitrarily large int. (OK, some do, but there is memory constraint.)

However, you will have a tape device attached to your computer. The library which is automatically loaded into the interpreter or compiler controls the tape device. Here things do become theoretical: the tape has a beginning, but no end, or you can imagine the device will manufacture more tape to extend it if more is needed. The tape has discrete positions. On each position a sector is stored. The device has access to one sector at the time but it can move the tape. All sectors have the same size.

The library provides you with the following functions (subroutines, whatever):
- detect if the tape is at the beginning
- move the tape left by n positions (stops at the beginning if sent beyond)
- move the tape right by n positions (n has to be one of atomic integer types of your chosen language)
- read the whole sector at current position
- read a part of the sector (zero indexed location within the sector and number of bytes to be read are arguments of an atomic integer type)
- overwrite the whole sector
- overwrite a part of the sector

The names of functions are your choice, as is the size of a sector. Reading loads the contents into a variable / into the memory area starting with a pointer given as an argument. Similar about writing.

Because the tape is effectively infinite, you have no function to tell you the actual position on the tape, as you'd have no way to store the result on a "real" computer.

So the real parts are: computer, possibly tape device.
Theoretical parts are:
- infinite storage tape or availability of material to manufacture as much tape as needed, which may well exceed the total amount of matter in our universe
- the computer, device, tape, ... not deteriorating, getting tangled up nor power falling or anything else going wrong for the time it takes the program to complete the task, which may well exceed total lifetime of our universe.

# Sandbox questions

Ideas how to improve the question... or should I abandon the idea?

• As you say this is code-golf, I think you should better define your library functions (are they well-written and only require one-byte functions or is there considerable cost to using specific library features). Nov 11 '17 at 22:26
• @JonathanFrech I thought I made clear about each of the 7 functions what they do. As for functions' names, some esoteric languages use funny identifiers so I thought I would leave naming to contestants. (I guess everyone will use single character names.) I'm open to suggestions if anyone has a better idea. Nov 12 '17 at 12:19
• Some languages doesn't even have definition of "function" (BF, ///). Some other languages doesn't have definition of "extension/library" (Jelly). Practical is subjective. Sector size is not specified. Atomic integer type is not defined. The amount of memory the program takes depends on several things, not just the program. Nov 12 '17 at 12:42
• @user202729 Maybe I should just name the functions and languages that can't handle named functions are out. Although brainfuck should be fine because its built-in commands will, using the library, manipulate the tape device (which enables it to be infinite, not possible otherwise); a sector would then probably only contain 8 or 16 bits. The solution in infinite brainfuck does indeed exist (because it's Turing complete) but how long is it? Nov 12 '17 at 15:13
• Language specific things are heavily discouraged. I would expect some downvotes if you say that. / Some languages may already had that name as builtin (Mathematica E, N). / The issue of unclear-ness of other specifications still remains. Nov 12 '17 at 16:47
• @user202729 What other specifications? Anyway, I'm trying to be as language-open as possible, but apart from very few I don't know of any other languages that actually have access to something infinite. So for other languages some kind of extension to get new actions is necessary. Is that too language specific? Maybe I should give up on this question, considering the popularity vote... Nov 13 '17 at 10:23

# Golf an interpreter

The challenge is to find a path from A to B, but you must also provide an interpreter for your program. The shortest interpreter wins.

Input to path finder:

A list of edges in a graph e.g.

AC
CD
DB


Output from path finder:

A list of vertices e.g. A C D B

Feel free to somewhat adjust the input/output format.

Scoring:

Your score is the number of bytes of your interpreter/compiler. The lowest score wins.

Note:

It's possible to work around the question and interpret a language that is too similar to an existing one by doing something like:

eval(input_file.replace("this never happens", ""))


I don't have a good rule to prevent this other than to ask that you don't.

• Not interesting, so downvote. Yes, you can't restrict that. Jan 7 '18 at 4:25

## Brainf*** Polygot

Write a brainf*** interpreter in as many languages as possible.

You will take the brainf*** code on standard input, and then execute it.

Your score is bytes / (n * sqrt n) (where n is the number of languages in which your program works), which you will seek to minimize.

• I don't think the generic "preform <simple task> in as many languages as possible" [polyglot] task is gonna cut it anymore. Maybe add some new BF-related task. Jan 24 '18 at 5:04
• @EsolangingFruit This isn't "preform some simple task". This is "be Turing complete". No other polygot challenge can be used a universal turing machine. In particular, it requires you to use the turing complete facilities of all the languages involved. Jan 24 '18 at 5:06
• If your goal is "prove turing completeness", then maybe "write a polyglot interpreter for a Turing-complete language". Allow different languages to interpret different TC languages. Jan 24 '18 at 5:10
• @EsolangingFruit I guess that would make it more interesting. I kind of like the idea of them all doing the same thing though, so you can just "feed in" an algorithm and get an instant polygot. Jan 24 '18 at 5:19
• @EsolangingFruit What about a caveat that the you must feed in the currently executing language as a parameter (for example, when run with python, it executes the code with "python" as its first input). Jan 24 '18 at 5:20
• In my opinion, polyglot challenges are better when you're solving different problems in each language. That has the advantage of being more interesting to solve, as well as not needing to ban multiple similar versions of the same language (since making polyglots would be trivial in those). Jan 24 '18 at 5:25
• Alternatively, a more difficult version: a polyglot in some set of languages languages that acts a compiler from BF to a new polyglot in each of those languages. In that case you probably want to score by no. of languages Jan 24 '18 at 5:27
• @EsolangingFruit OW, that sounds even cooler! Jan 24 '18 at 5:39

# Gatherer Golf: The 61 Dwarves

Gatherer is the official tool for searching for Magic: The Gathering cards. Its advanced mode allows searching by most of the criteria you could hope for, as well as simple boolean combinations within a single kind of criterion (for example, you can do "name contains X or Y and not Z").

I've been using it a lot recently, and have been trying to get better at more quickly finding the exact set of cards I need. For example, if I want creatures that can generate mana, searching for "dd {" seems to be the minimal exact string match on their rules text.

For this inaugural Gatherer Golf, your challenge is to create a query that lists, exactly, the 61 Dwarf cards (not counting creatures that are all creature types), without using the key "subtype". The result generated the normal way can be found here.

Rules

• Your score is the length of the full URL in Gatherer. For example, searching for "name contains Dw or Resp and type contains Creature" generates the URL gatherer.wizards.com/Pages/Search/Default.aspx?action=advanced&name=|[Dw]|[Resp]&type=+[%22Creature%22] for a score of 104.

• Lowest score wins.
• Your URL can be manually generated; it doesn't have to be possible to create it via the advanced search form.
• Cards added to Gatherer after this challenge was posted (in this case, after Rivals of Ixalan) do not invalidate existing answers. Your answer may include or exclude any card published after that date, regardless of whether it's a dwarf, and answers that no longer give correct results (for example, because the Oracle text of a card changed) do not need to be deleted.
• Other than as described above, all cards in Gatherer are relevant to this challenge, regardless of whether they're legal for tournament play.
• The cards may be listed in any order. This may be relevant if your search contains more than just dwarves, but concentrates all the dwarves into one page of the search results.
• I'm not sure that this requires code to solve. Also, I'd ban the word "subtype" in the query, as that's more solid than "without querying on subtype" Jan 31 '18 at 20:26
• Thanks, edited. I was thinking of the query itself as code--it's declarative and certainly doesn't meet our definition of a programming language, but I'd've expected an HTML or SQL golfing challenge to be on-topic here and this seems the same in principle. Jan 31 '18 at 21:02
• I wouldn't expect HTML golfing to be on-topic; and SQL meets the definition of a programming language. IMO the way to make this on-topic is to somehow supply a database (maybe abusing imgur with steganography?) and then ask for a program which takes input as a list of card names to match and outputs a minimal query. Feb 2 '18 at 12:28

# xkcd-esque Reverse Code Golf

## Introduction

A new xkcd comic came out recently, seemed to be a fun challenge and a change from the usual code golfing.

So I set out on making this challenge!

## Challenge

Make a short snippet of code in any language which, when read out, sounds like 1 sentence of normal English literature (for example, Moby Dick in the comic).

## Rules

• The snippet doesn't have to run, so you are free to add statements which would not execute (for example: undeclared variables, functions, etc.). However, it must be syntactically correct.

• A word in this challenge is any sequence of letters considered as valid English as in a dictionary. Articles (a, an, the) are counted as words.

• To prevent too long answers, the maximum number of words will be fixed at 200 individual words. This includes operator expansion.

• The maximum length of any function or variable name will be 10 words.

• The expansion used for an operator must be specified in the answer.

• Imported and built-in functions are not considered as operators.

• Since this is reverse code golf, the answer with the most points wins.

Scoring criteria:

• Characters used to structure code (0): All kinds of brackets, statement terminators, whitespace, etc.
• Comments and String literals (0): To avoid making large comments/literals with actual literature
• Names of functions or variables (1 per character):
• Keywords (2 per letter): Using keywords in the story as valid syntax.
• Operators (2 per letter of expansion): For example, > is worth 2x13 (isGreaterThan).

# Examples

Valid:

try { throw IngTheBallAnd; } catch (Ing it) {}
// Worth 3x2 + 5x2 + 13 + 5x2 + 3 + 5 = 37 points

let myLife = "a quote";
// Worth 3x2 + 6 + 2x2 = 16 points ("=" used as "be")


Invalid:

// One does not simply write everything in a comment
// Worth 0


Hope this meets PPCG puzzle criteria :D

• Define "short" Otherwise answers could just go on and on to approach infinite score.
Feb 28 '18 at 10:05
• How long may function/variable names be?
Feb 28 '18 at 10:07
• How do we determine the exact expansion of operators? E.g. is * "times" or "multipliedBy"?
Feb 28 '18 at 10:09
• So the APL function ×× would count as 28: (signOfTheTimes)? Indeed APL functions often read nicely as plain English. E.g. (?∘≢⊃⊢)¨(⊂⍳3)/⍨¨1+⊢ reads as "a random number up to (?) the length (≢) selects from (⊃) the value of (⊢) each of (¨) the entire (⊂) indices until (⍳) three (3) replicated (/) by (⍨) each of (¨) one (1) added to (+) the value of the argument (⊢).
Feb 28 '18 at 10:26
• @Adám I'll edit my answer to answer these. As for APL, I guess my puzzle is no match for it :P Feb 28 '18 at 10:46
• @Adám I'd actually aim for english literature rather than procedure sentences Feb 28 '18 at 10:50
• What is a "determiner"? Some programming languages do not use white space. What is a word?
Feb 28 '18 at 11:05
• "Context" determination of expansion is not an exact science. As long as your challenge has that feature, I predict it will be closed as "unclear what you are asking".
Feb 28 '18 at 11:07
• Are built-in functions "keywords"? What about imported functions?
Feb 28 '18 at 11:08
• @Adám Edited to answer. Determiners were meant to be Articles (a, an, the). Lack of whitespace is not a concern as long as it is readable. I mentioned the need for specifying the intended meaning of operators before, but it was a partial change. Feb 28 '18 at 12:13
• built-in functions are not considered as operators? Uh, what exactly is an operator then? Some languages use single letters as operators. I'm afraid this question makes far too many assumptions about the features of programming languages. A common mistake, but often hard to fix. Compare to the problems with atomic code-golf.
Feb 28 '18 at 12:53
• There have been a few questions about reading code as sentences, e.g. 1, 2, 3. Because answers can't be objectively scored, those are popularity-contests. However those types of challenge have mostly fallen out of scope on the site and are very hard to get right, see the tag wiki for more infos. Feb 28 '18 at 12:56
• Hmm.... alrighty. I shall disband this puzzle. I hope someone can make a better puzzle with the comic, it ought to get its own challenge ;) Feb 28 '18 at 13:17
• No one have said that? Welcome to PPCG! Mar 1 '18 at 0:05
• Note that this is called code-bowling on PPCG. Typically code bowling questions have strict scoring rules to avoid arbitrary score inflation which usually prevents large variable/function names.
– Jo King Mod
Mar 1 '18 at 2:19

# Bees?

Inspired by SCP-3045

Write a program that takes the input, extracts all of the words, and looks for the word bee; then:

• If bee is not detected, pick sections of the text at random and delete them.
• If bee is detected, add instances of the word bee to the input such that it has significantly more bytes than the original input.

The program should then output these modifications.

• How much is significantly more? Why is it popularity-contest? Mar 18 '18 at 14:00
• Do X creatively pop cons have fallen out of scope. This will get closed instantly if posted on main. Mar 19 '18 at 12:51

Move a window around the screen

Your code should open a new window that is at least 100 by 100 pixels in size. Once the window is open you should be able to move the window around the screen using the keyboard. The window should move smoothly but it doesn't matter how fast it moves.

• Is there anything else that could make this challenge a bit more interesting? Maybe a scoring method? Mar 26 '18 at 14:01
• @RamenChef I suppose the scoring method was meant to be by the code-golf rules. I could make the challenge more interesting maybe by insisting that you can type into the window?
– user9206
Mar 26 '18 at 14:05
• What counts as a "window"? I think this might be quite hard to define objectively in a way which is OS-agnostic. Mar 26 '18 at 15:38