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


To post to the sandbox, scroll to the bottom of this page and click "Answer This Question". Click "OK" when it asks if you really want to add another answer.

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.


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
  • Comments addressing specific points mentioned in the proposal
  • 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 requires more feedback, but it's been ignored, you can ask for feedback in The Nineteenth Byte. It's not only allowed, but highly recommended! Be patient and try not to nag people though, you might have to ask multiple times.

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.


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".

  • \$\begingroup\$ What if I posted on the sandbox a long time ago and get no response? \$\endgroup\$
    – None1
    May 15 at 14:05

4686 Answers 4686

107 108
110 111


Wardialing was a very interesting way to try to hack people back in the '80s and '90s. When everyone used dial-up, people would dial huge amounts of numbers to search for BBS's, computers, or fax machines. If it was answered by a human or answering machine, it hung up and forgot the number. If it was answered by a modem or a fax machine, it would make note of the number.


Your job is to make a URL wardialer. Something that tests and checks if it's a valid website from one letter of the alphabet.


  • Program must take user input. This input has to be a letter of the alphabet, no numbers. Just one letter of the alphabet and form multiple URLs that start with the letter.
  • Standard loopholes apply.
  • You must make 8 URLs from 1 letter, and test to see if it is a valid site.
  • If you hit an error (not a response code), instead of leaving it blank, go ahead and return a 404
  • If you hit a redirect (3xx), return a 200 instead.
  • You may output the results in any reasonable format, as long as it includes the website name, status codes for all the websites and the redirects
  • This is Code Golf, so shortest amount of bytes wins.

What counts as a URL for this challenge?

http://{domain-name}.{com or net or org}

For this challenge, the domain name is should only be 4 letters long, no more, no less.

What should I test?

For each 4 letter domain name, test it against three top-level domains (.com, .net, .org). Record all the response codes from each URL, remember from the constraints that any (3xx) should return 200 and be recorded as a redirect in the output and any error getting to the website should result in a 404.




| Website | .com | .net | .org | Redirects? |
| ajoe    | 200  | 200  | 200  | .com, .net |
| aqiz    | 200  | 404  | 404  | no         |
| amnx    | 200  | 503  | 404  | .com       |
| abcd    | 200  | 404  | 200  | .com       |
| ajmx    | 200  | 503  | 404  | no         |
| aole    | 200  | 200  | 200  | .com       |
| apop    | 404  | 200  | 200  | .net       |
| akkk    | 200  | 200  | 200  | .com       |
  • 2
    \$\begingroup\$ I don't like the formatting aspect; it adds a whole unnecessary layer to the meat of challenge. I also don't like the fact that you have to go through .com, .net, and .org for the same reason. But I do like the concept, and I think if you stay closer to the actual challenge ("generate a few websites and check if they exist") it could be well-received on main. \$\endgroup\$ May 22, 2017 at 19:43
  • \$\begingroup\$ but the formatting looks sooooo good \$\endgroup\$
    – kuantum
    May 22, 2017 at 19:44
  • \$\begingroup\$ Well then, maybe you should post a challenge idea to format a table like that ;-) I think we may have already had that challenge though. \$\endgroup\$ May 22, 2017 at 19:45
  • \$\begingroup\$ ehhh, nah. what should i replace it with \$\endgroup\$
    – kuantum
    May 22, 2017 at 19:47
  • \$\begingroup\$ I'd allow users to output in any reasonable format they like: an array of arrays, a newline-separated string, etc. A table like that would still be allowed, though it probably wouldn't be the shortest. \$\endgroup\$ May 22, 2017 at 19:49
  • \$\begingroup\$ URLs for websites all start with the letter h. If you want to make an argument about relative URLs, I will concede that they can also start with the non-letter /. But abusing a clearly defined term like URL to the extent to which it's abused in this draft only serves to confuse people. The task is: given an input of one letter of the alphabet, generate 8 alphabetic labels, from each of those labels to generate three domain names, and for each of those names test the response code of the URL http://{name}/ \$\endgroup\$ May 22, 2017 at 21:46
  • \$\begingroup\$ Also, in "Something has more than 4 letters in it", more than is exclusive, so this is not consistent with the example. \$\endgroup\$ May 22, 2017 at 21:47
  • \$\begingroup\$ There. I think this edit helps @PeterTaylor \$\endgroup\$
    – kuantum
    May 22, 2017 at 22:17

Program Equilibrium Iterated Prisoner's Dilemma Tournament

This is an iterated prisoners dilemma tournament. You are to make a bot that plays the prisoners dilemma against the other contestants, but with a twist- you can perfectly simulate your opponent!

Iterated Prisoner's Dilemma

The prisoner's dilemma is a two-player game in which players can choose to either "Cooperate" or "Defect" against their opponent. The payoff matrix for the prisoner's dilemma looks like this:

                           Player 2
                       C              D

                |              |               |
            C   |    (3, 3)    |    (0, 5)     |
                |              |               |
Player 1        |------------------------------|
                |              |               |
            D   |    (5, 0)    |    (1, 1)     |
                |              |               |

In the iterated prisoner's dilemma, multiple rounds are played in succession, and players can use their knowledge of the previous rounds when making a decision.

The twist

Bots are also allowed to run their opponent and examine the output before making a move. This allows for significantly more complex strategies in which bots can simulate their opponents to determine if it is safe to cooperate with them, as well as attempt to exploit less sophisticated players.


There will be a program available in the path called simulate that you can use to simulate what your opponent would do against you

simulate [instruction to your own bot] [fake history to the opponent]
simulate cooperate 00 10 01 11 01 10

All arguments are optional, and you may also use underscore _ for no argument. If you do not explicitly state the history, the real history will be used.

Example output from the simulate program:


The first number is you, the second is your opponent. 0 means defect, 1 means cooperate.

The instruction

It wouldn't be much use to simulate what your opponent would do against you, because he'd probably simulate you right back, and then you'd be stuck in an infinite loop.
The instruction is your way to simulate what the opponent would do against another agent. You could for instance have a cooperate instruction that causes your bot to cooperate mindlessly, to see what the opponent would do if you were to cooperate.


Your program will be given the following input at the beginning of each round:

Instruction (if any)
Your score
Your opponents score
Current round number
Complete history of past interactions with this bot. Space separated: the first number is you, the second is your opponent


00 10


0 for defect or 1 for cooperate, with any number of leading characters. Trailing characters (including 0 or 1's) will be ignored.



The tournament

The tournament will be round-robin elimination: Each bot will play one match against all other bots, where a match consists of 100 rounds of the prisoner's dilemma. At the end of the round-robin round, the lower-scoring half of the tournament pool will be eliminated. This process will be repeated until only one bot remains, or there is a tie.


  • Your program has to run on Linux. Please provide a brief description of how to run your program if possible
  • Your program has to give an answer within 5 seconds. Failing to do so will be interpreted as defect.
  • Your program may not perform multiple simulations at the same time
  • You may only enter a single bot, this is to prevent people from entering multiple bots that cooperate
  • You may not read or write any files. If this is required by your language, please state so in your answer.
  • You may not in any way store state between rounds. This is to prevent bots from figuring out whether they are being simulated.
  • If you exploit another loophole to figure out whether you are being simulated, you will be disqualified. Guessing (or strategical testing) is obviously allowed

About the host computer

Arch Linux 4.10.13-1
Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz, 4 cores
I will disconnect from the internet while running the tournament


I got the idea as well as some of the text from this Github repository. I have not directly asked the author for permission to use the challenge, but he said that "if you want to run this tournament on your own, you are more than welcome to" in a blogpost.


I will update this periodically whenever new bots enter.


How do I best discourage/prevent players from intentionally using every bit of their time limit to sabotage other players trying to simulate them? I am thinking random time limits and/or penalties

  • 1
    \$\begingroup\$ Have you ever run a KotH? If not, I think you are about to learn how incredibly slow a round can be even if the programs have very simple logic. With the simulate instruction I anticipate taking hours to run a single round. \$\endgroup\$ May 22, 2017 at 21:50
  • \$\begingroup\$ @PeterTaylor That's good advice; I might not want to run this on my main computer \$\endgroup\$
    – BlackCap
    May 22, 2017 at 22:54

Identify the variable case

Your task is to write a function which determines which casing convention a provided variable name belongs to:

  • camelCase
  • kebab-case
  • Train-Case
  • snake_case
  • PascalCase
  • Ada_Case (not a real term, but apparently the standard casing used in Ada)

Your function should return one of the above strings, either exactly as above, or as spaced title-case: "Train case", "Screaming snake case".

Casings that include - or _ may include leading or trailing -s or _s (eg, __MY_SNAKE__ or -webkit-kebab).

Multiple consecutive upper case letters are allowed in mixed casings, as long as they follow a lower case letter (MyXMLDocument, This-CSS-Crap).

Where an input fits multiple schemes (eg, F or foo), you may return any valid classification.

If an input does not fit one of the above schemes (eg stu-pid_case), you must return something different. You may also throw an error.

The input string is guaranteed to be at least one character, and begin with a character matching /[a-zA-Z_-]/. Every other character will match /[a-zA-Z0-9$-]/

This is , so shortest length in bytes wins. Standard loopholes forbidden. Standard input and output methods.

Test cases

myFunkyVariable => camelCase
no-op => kebab-case
__c => snake_case
XML-Madness => Error
Get_Input => Ada_Case
i => camelCase (or snake_case)
char2int_factory => snake_case
  • \$\begingroup\$ You should specify exactly what each of the cases requires. (e.g. train case is separated by underscores with only the first character capital) Because this is a competition there should be no room for interpretation. \$\endgroup\$
    – Wheat Wizard Mod
    May 26, 2017 at 4:56
  • \$\begingroup\$ What ambiguity have I missed? \$\endgroup\$ May 26, 2017 at 5:19
  • \$\begingroup\$ You should define what each of the 7 cases entails. Currently you just list 7 examples, which is certainly helpful, but I don't think sufficient. \$\endgroup\$
    – Wheat Wizard Mod
    May 26, 2017 at 5:30
  • \$\begingroup\$ You really don't think they're sufficiently self-explanatory? I mean, I can add explanation, but I'm curious if you have an example of a variable name that you don't know how to classify? \$\endgroup\$ May 26, 2017 at 5:35
  • \$\begingroup\$ I think I get it based on the examples and I think any reasonable person would be able to jump to the correct conclusion, but we should strive to make questions as concrete as possible. Some people might not be aware of casing in the first place and definitions could help. It may seem like I'm making a fuss over nothing, and perhaps I am, but I think it could only benefit to add specific definitions of the terms, since the question is about identifying them. As far as examples go, I believe E_S_S is ambiguous between screaming snake and Ada. Definitions might help clear that up. \$\endgroup\$
    – Wheat Wizard Mod
    May 26, 2017 at 5:46
  • \$\begingroup\$ That one is ambiguous, which, as stated, means that either answer is ok. But I'll add an introductory paragraph about casing. \$\endgroup\$ May 26, 2017 at 5:58

21 = (1 + 3 + 5 + 7 + 9) - (1 + 3)

Sandbox question:
Is this different enough from the original challenge?


  • This is a sequel to my previous challenge, but this time with a slightly more interesting practical application (the factorization of the input).

  • It is based on 1) the fact that any odd integer n can be expressed as the difference of two squares a² - b² and 2) the well known formula:


The task

You're given a positive odd integer n. Your task is to determine how many iterations of the following algorithm need to be processed to reach n.

  • Initialization: find the highest integer k such that k² ≤ n. Build the list L = [ 1, 3, 5, ..., 2k-1 ].
  • Iteration:
    • Step #1: If the sum of the terms of L equals n, stop here.
    • Step #2: Increment k and append 2k-1 to L.
    • Step #3: While the sum of the terms of L is greater than n, remove the first term from the list. Go on with step #1.

All iterations (either full or partial) must be counted. In other words, you must return the number of times step #1 was executed.

Example #1

This is a trivial example for the perfect square n = 9:

  • Initialization: k = 3 because 3² ≤ 9 < 4², which leads to L = [ 1, 3, 5 ].
  • Step #1: 1 + 3 + 5 = 9. We're done.

We went through one iteration. So the expected result is 1.

Example #2

Here is what we get for n = 21:

  • Initialization: k = 4 because 4² ≤ 21 < 5², which leads to L = [ 1, 3, 5, 7 ].
  • Step #1: 1 + 3 + 5 + 7 = 16, which does not equal n.
  • Step #2: We increment k and we add 2k + 1 = 2 x 5 - 1 = 9 to the list: L = [ 1, 3, 5, 7, 9 ].
  • Step #3: We remove the first term from the list: L = [ 3, 5, 7, 9 ]. The sum of the terms is now 24, which is still greater than n. So we remove another term: L = [ 5, 7, 9 ].
  • Step #1 : 5 + 7 + 9 = 21. We're done.

We went through two iterations. So the expected result is 2.

Example #3

Below is a summary of all steps for a slightly more complex example with n = 145.

Initialization: k = 12 because 12² ≤ 145 < 13².

Iteration | Step | k  | L                                 | Sum
    1     |  1   | 12 | 1,3,5,7,9,11,13,15,17,19,21,23    | 144
          |  2   | 13 | 1,3,5,7,9,11,13,15,17,19,21,23,25 | 169
          |  3   | 13 | 11,13,15,17,19,21,23,25           | 144
    2     |  1   | 13 | 11,13,15,17,19,21,23,25           | 144
          |  2   | 14 | 11,13,15,17,19,21,23,25,27        | 171
          |  3   | 14 | 17,19,21,23,25,27                 | 132
    3     |  1   | 14 | 17,19,21,23,25,27                 | 132
          |  2   | 15 | 17,19,21,23,25,27,29              | 161
          |  3   | 15 | 19,21,23,25,27,29                 | 144
    4     |  1   | 15 | 19,21,23,25,27,29                 | 144
          |  2   | 16 | 19,21,23,25,27,29,31              | 175
          |  3   | 16 | 23,25,27,29,31                    | 135
    5     |  1   | 16 | 23,25,27,29,31                    | 135
          |  2   | 17 | 23,25,27,29,31,33                 | 168
          |  3   | 17 | 25,27,29,31,33                    | 145
    6     |  1   | 17 | 25,27,29,31,33                    | 145

We went through 6 iterations. So the expected result is 6.

Factorization of the input

This paragraph is for illustration purposes only. It describes how the factorization of the input can be deduced from the result of the algorithm.

Factorization of 21:

  • 21 = 5 + 7 + 9 = (1 + 3 + 5 + 7 + 9) - (1 + 3)
  • 21 = 5² - 2²
  • 21 = (5 + 2)(5 - 2)
  • 21 = 7 x 3

Rules and clarifications

  • The input is guaranteed to be a positive odd integer. It may be either a composite integer or a prime.
  • You're required to process any odd n in [ 1, ..., 65535 ] in less than one minute on mid-range hardware.
  • Given enough time, your program/function should theoretically work for any value of n that is natively supported by your language. If it doesn't, please explain why in your answer.
  • You may use any other method instead of the described one as long as it returns the correct result.
  • This is code golf, so the shortest answer in bytes wins!

Test cases

To be completed

  • \$\begingroup\$ Typo: you wrote "k²=n", which can't possibly be correct (and contradicts the rest of the post). \$\endgroup\$
    – user62131
    May 26, 2017 at 3:30
  • \$\begingroup\$ @ais523 Thanks for catching that out. (I believe all my "less than or equal to" signs where turned into equal signs when I copy/pasted through Notepad++.) \$\endgroup\$
    – Arnauld
    May 26, 2017 at 7:10
  • \$\begingroup\$ 1. There's also an extra = in the LaTeXified image. 2. You say it's a variant on an earlier question of yours, but it seems so similar that I don't see why it wouldn't be a dupe. If it isn't, I definitely think it's a dupe of codegolf.stackexchange.com/q/18349/194 : the two questions are essentially "Find the factorisation of n into two parts which are as close as possible to sqrt(n). \$\endgroup\$ May 26, 2017 at 8:12
  • \$\begingroup\$ @PeterTaylor Thanks for your feedback. Yes, I think it's a dupe indeed. \$\endgroup\$
    – Arnauld
    May 26, 2017 at 8:16

Dungeon of Botdom

Bots will play a variant of this game:


(Our version will be played by one bot versus another bot, and there will only be one character, which may or may not be in the actual game, and it will be repeated a bunch.)

Essentially, there is a deck of cards, with enemies on each card. players take turns either passing, or drawing a card and either a) placing it in the initially empty dungeon or b) removing a piece of gear and discarding the enemy. enemies have different hit points, which affects the damage done to a bot traversing the dungeon. When everyone but one player has passed, they enter the dungeon. when a bot is traversing the dungeon, they will encounter the enemies placed in the dungeon in LIFO order (the card on top is taken first) (if I take out some items this may be irrelevant). enemies are instantly defeated if the player has a corresponding item, otherwise the player takes damage equal to the enemies number. if a player makes it through the dungeon, they get one point. get two points to win the match. if they fall while traversing the dungeon, they lose one chance. fail twice, and the opponent wins the match.

What this means, is that you might want to do one of two things: make the dungeon too dangerous to survive without your opponent thinking it is, and passing, or making the opponent bot believe the dungeon is too dangerous, when it is not, and running through the dungeon and succeeding.

We'll have a good ol' round robin of a 1000 rounds each or some such. the nice thing about this game is that the rounds are short, because once you finish the deck, a player automatically enters the dungeon.

  • 2
    \$\begingroup\$ You may want to include a better description, not just the link. Describe the various cards, the game mechanics, the format of the bots, and include the code for testing bots. KOTH challenges tend to have lots of text. \$\endgroup\$
    – Gryphon
    May 26, 2017 at 13:29
  • \$\begingroup\$ @gryphon did I not do that? Also I haven't decided on the exact deck yet, and exact items, and exact round formats. I have described the basics of the game anyway \$\endgroup\$ May 27, 2017 at 0:43
  • \$\begingroup\$ @Gryphon also I haven't made the controller yet. we can't all get away with straight posting to main because of our incredible talent for Koths and making the controllers immediately \$\endgroup\$ May 27, 2017 at 0:54
  • \$\begingroup\$ OK, sorry. I would just make sure I have the controller before I actually posted the question. \$\endgroup\$
    – Gryphon
    May 29, 2017 at 17:27
  • \$\begingroup\$ I have the controller finished here \$\endgroup\$ May 30, 2017 at 8:24
  • \$\begingroup\$ Nice Poem, @DestructibleLemon! \$\endgroup\$
    – Gryphon
    May 30, 2017 at 10:28

Can my favourite team still become Football Champion?

As a fan of an at most moderately successful footballBE team, towards the end of the season I often wonder whether my favourite team still has any theoretical chance left of becoming champion. Your task in this challenge is to answer that question for me.


You will recieve three inputs: the current table, the list of remaining matches, and the current position of the team we are interested in.

Input 1: The current table, a sequence of numbers were the i-th number are the points gained by team i so far. For example, the input [93, 86, 78, 76, 75] encodes the following table (only the last column is of importance):

premier league table

Input 2: The remaining matches, a sequence of tuples where each tuple (i,j) stands for a remaining match between team i and j. In the above example, a second input of [(1,2), (4,3), (2,3), (3,2), (1,2)] would mean that the remaining matches are:

Chelsea vs Tottenham, Liverpool vs Man. City, Tottenham vs Man. City, Man. City vs Tottenham, Chelsea vs Tottenham

Input 3: The current position of the team we are interested in. For example, an input of 2 for the above example would mean that we'd like to know whether Tottenham can still become champion.


For each remaining match of the form (i,j), there are three possible outcomes:

  • Team i wins: Team i gets 3 points, team j gets 0 points
  • Team j wins: Team i gets 0 points, team j gets 3 points
  • Draw: Team i and j both get 1 point

You must output a truthy value if there is some outcome for all remaining games such that at the end, no other team has more points than the team specified in the 3rd input. Otherwise, output a falsy value.

Example: Consider the exemplary input from the above section:

Input 1 = [93, 86, 78, 76, 75], Input 2 = [(1,2), (4,3), (2,3), (3,2), (1,2)], Input 3 = 2

If team 2 wins all its remaining matches (i.e. (1,2), (2,3), (3,2), (1,2)), it gets 4*3 = 12 additional points; none of the other teams gets any points from these matches. Let's say the other remaining match (i.e. (4,3)) is a draw. Then the final scores would be:

 Team 1: 93, Team 2: 86 + 12 = 98, Team 3: 78 + 1 = 79, Team 4: 76 + 1 = 77, Team 5: 75

This means that we have already found some outcome for the remaining matches such that no other team has more points than team 2, so the output for this input must be truthy.


  • You may assume the first input to be an ordered sequence, i.e. for i < j, the i-th entry is equal to or greater than the j-th entry. The first input may be taken as a list, a string or the like.
  • You may take the second input as a string, a list of tuples or the like. Alternatively, you may take it as a two-dimensional array a where a[i][j] is the number of entries of the form (i,j) in the list of remaining matches. For example, a[1][2] = 2, a[2][3] = 1, a[3][2] = 1, a[4][3] = 1 corresponds to [(1,2), (4,3), (2,3), (3,2), (1,2)].
  • For the second and third input, you may assume 0-indexing instead of 1-indexing.
  • You may take the three inputs in any order.

Please specify the exact input format you chose in your answer.

Side node: The problem underlying this challenge was shown to be NP-complete in "Football Elimination is Hard to Decide Under the 3-Point-Rule". Interestingly, if only two points are awarded for a win, the problem becomes solvable in polynomial time.

Test Cases

All test cases are in the format Input1, Input2, Input3.


  • [93, 86, 78, 76, 75], [(1,2), (4,3), (2,3), (3,2), (1,2)], 2
  • [50], [], 1
  • [10, 10, 10], [], 3
  • [15, 10, 8], [(2,3), (1,3), (1,3), (3,1), (2,1)], 2


  • [10, 9, 8], [], 2
  • [10, 9, 9], [(2,3), (3,2)], 1
  • [21, 12, 11], [(2,1), (1,2), (2,3), (1,3), (1,3), (3,1), (3,1)], 2


This is , so the shortest correct answer (in bytes) wins. The winner will be chosen one week after the first correct answer is posted.


Closely related to Words from periodic table of elements (but that one is closed due to unclear specification?).

Closely related to Find the Chemistry of a name (probably a dupe, slightly different requirements though).

Closely related to [Br]eaking Code Golf [Ba]d (allows strings to be not expressible as solely a sequence of element abbreviations).

May I get a community consensus, whether this is better specified and/or sufficiently different to not be immediately closed as a dupe?

Elementize a string

Convert an input string to a concatenation of chemical element abbreviations.

Write a program/function/procedure etc. which will take as input a string/array of characters/pointer to a string etc. and return/print/display the same string expressed as a concatenation of chemical element abbreviations.

For example, takagi can be expressed as TaKAgI (i.e. the abbreviations for Tantalum(Ta), Potassium(K), Silver(Ag), Iodine(I)).

For this challenge you must use the following element name abbreviations:

{"H", "He", "Li", "Be", "B", "C", "N", "O", "F", "Ne", "Na", "Mg",
"Al", "Si", "P", "S", "Cl", "Ar", "K", "Ca", "Sc", "Ti", "V", "Cr",
"Mn", "Fe", "Co", "Ni", "Cu", "Zn", "Ga", "Ge", "As", "Se", "Br",
"Kr", "Rb", "Sr", "Y", "Zr", "Nb", "Mo", "Tc", "Ru", "Rh", "Pd",
"Ag", "Cd", "In", "Sn", "Sb", "Te", "I", "Xe", "Cs", "Ba", "La",
"Ce", "Pr", "Nd", "Pm", "Sm", "Eu", "Gd", "Tb", "Dy", "Ho", "Er",
"Tm", "Yb", "Lu", "Hf", "Ta", "W", "Re", "Os", "Ir", "Pt", "Au",
"Hg", "Tl", "Pb", "Bi", "Po", "At", "Rn", "Fr", "Ra", "Ac", "Th",
"Pa", "U", "Np", "Pu", "Am", "Cm", "Bk", "Cf", "Es", "Fm", "Md",
"No", "Lr", "Rf", "Db", "Sg", "Bh", "Hs", "Mt", "Ds", "Rg", "Cn"}

These are the elements with numbers 1 through 112. You may optionally also use the abbreviations for elements 113 through 118:

{"Nh", "Fl", "Mc", "Lv", "Ts", "Og"}

You may not, however, use the placeholder three-letter abbreviations for not yet named elements, such as "Uuo" (Ununoctium).

If the input string cannot be expressed by the above abbreviations, you shall return one of the following:

  • a falsey value (clearly distinct from element names, in other words A would not be valid, even though there is no element "A"; something like 0, null, false, newline is fine)
  • an empty string
  • exit without output
  • exit with an error
  • something similarly unambiguous signifying failure and not returning some incorrect output that could be accidentally misinterpreted as an answer (suggestions to make this specification clearer?)

Possible output, using example input takagi:

  • an appropriately capitalized string: TaKAgI.
  • a flat array of characters {"T", "a", "K", "A", "g", "I"} with appropriate capitalization.
  • a list of strings (capitalized or not) separated by newlines or as separate members of an array, etc., e.g. ta \n k \n ag \n i.

The rule of thumb is that the division into separate elements must be clear. Please comment if additional clarification is needed!

You may assume the input to be a single word consisting only of letters.

Compression is not the intent of this challenge! Boiler-plate code that fetches the list of elements from somewhere, hard-coding the lists of abbreviations, assuming the list of abbreviations to be stored in a variable or passed as a second argument to your function is OK and should not be included in the byte count.

Sample input -> sample output
no -> No             // as in Nobelium, alternatively see next line
no -> NO             // Nitrogen-Oxygen, either one is valid
helium -> falsey output
heliam -> HeLiAm
fog -> FOg           // If using 118 elements, falsey otherwise.
ppcg -> falsey       // I'm really, really sorry

Suggestions of further test cases are appreciated.

This is code-golf, shortest code wins.

  • \$\begingroup\$ Potassium is K, not P. \$\endgroup\$ Jun 1, 2017 at 2:44
  • \$\begingroup\$ @calculator brain-fart, fixed, thanks. \$\endgroup\$
    – LLlAMnYP
    Jun 1, 2017 at 4:35
  • \$\begingroup\$ I think it makes more sense to work on improving the existing closed question than to post a duplicate. \$\endgroup\$ Jun 1, 2017 at 6:30
  • \$\begingroup\$ @Peter I should have realized sooner, that a [chemistry] tag exists here. I'm not sure I'm at ease with modifying someone else' challenge (distorting their intent?) and potentially invalidating others' answers... \$\endgroup\$
    – LLlAMnYP
    Jun 1, 2017 at 6:37

How many substitutions till palindromization?

Given a string, find the minimum number of character substitutions needed so that the string is a palindrome.

E.g. the string abchefa needs 2 substitutions, so it can take any of the following paths:

abchefa -> afchefa -> afehefa
                   -> afchcfa
        -> abehefa -> afehefa
                   -> abeheba
        -> abchcfa -> afchcfa
                   -> abchcba
        -> abcheba -> abeheba
                   -> abchcba

You must return a minimal number, e.g. abc can use 3 substitutions (abc -> dbc -> ddc -> ddd) but it really only needs 1 (abc -> aba) so you must return 1.

The string will only contain printable ASCII, no newlines.

Additional testcases:










  • You can take the string as a string or as a list of chars, but not as a list of strings
  • You must return a minimal value in a generally accepted output format.
  • \$\begingroup\$ I thought there was a near-dupe somewhere, but I'm pretty sure this is the one I was thinking of... \$\endgroup\$ Jun 1, 2017 at 23:38
  • \$\begingroup\$ Actually this might be a dupe of this: perform any answer for all indexes in the string, sum, divide by two. \$\endgroup\$ Jun 1, 2017 at 23:41
  • \$\begingroup\$ @ETHproductions You spoiled the hidden way to do it... \$\endgroup\$ Jun 2, 2017 at 5:39
  • \$\begingroup\$ I'm pretty sure I've seen an exact dupe, although it might still be in the sandbox; codegolf.stackexchange.com/q/95343/194 is a generalisation. \$\endgroup\$ Jun 2, 2017 at 9:00

Write machine code that also works when left rotated one byte

Write machine code for a CPU that runs and does something. The twist is that your code should run and do something else, without errors, if it is left rotated one byte.

Suggestions? Ideas? Thoughts? Let me know.

  • 4
    \$\begingroup\$ So is this "any code that doesn't crash if rotated"? Generally it's best to give a specific task, not just "do something", or else it's quite broad. \$\endgroup\$
    – Geobits
    Oct 26, 2016 at 0:15
  • 2
    \$\begingroup\$ This is completely uninteresting in any instruction set which has one-byte instructions. E.g. in x86 the byte that's rotated away can be INC, and then the "something else" is just the same function with an offset to one of the arguments. \$\endgroup\$ Oct 26, 2016 at 7:53
  • 1
    \$\begingroup\$ Far too broad, IMO. Also very, very easy in machine code dialects which have single-byte jump instructions, or any instruction that has a single-byte opcode plus X bytes of data, where X is no shorter than the length of the jump instruction; this describes almost every machine code dialect in existence. \$\endgroup\$
    – user62131
    Jun 2, 2017 at 15:03
  • \$\begingroup\$ What about reversing it? \$\endgroup\$
    – anna328p
    Jun 2, 2017 at 16:49

Reverse divmod


The divmod function is one that is included in many standard libraries and is defined as follows:

enter image description here

Or, in other words, divmod(a,b) returns a list containing the integer quotient of a/b (i.e. floor(a/b)) and mod(a,b) (i.e. the remainder in the division of a/b).

Your challenge is not to implement the divmodfunction, but rather reverse it.


You will take two integers x and y as input, in any reasonable input format (two integers, list, etc.). Both x and y are guaranteed to be in the range -2^31 to 2^31-1, inclusive.


The output of your code shall be two integers, in any reasonable output format (two integers, list, etc.). Note that you must output the two integers in such a way that a human is able to distinguish one from another. These two integers should be an a and b such that divmod(a,b)==(x,y) (i.e. floor(a/b)==x && mod(a,b)==y). Please specify in your answer how these two integers are outputted if it is not immediately clear (for example, if you output b before a).

Remember that this is , so shortest solution in bytes wins!

  • \$\begingroup\$ Note to self: add I/O examples \$\endgroup\$
    – GamrCorps
    Jun 3, 2017 at 2:10
  • 1
    \$\begingroup\$ So: given x and y output x*b+y, b for any b > y if y is positive or b < y if y is negative? Or have I missed something? \$\endgroup\$ Jun 3, 2017 at 12:59
  • \$\begingroup\$ @PeterTaylor No you haven't, I realized that the challenge is much simpler than I originally thought (because of the method you mentioned). I am going to try and increase the difficulty later. \$\endgroup\$
    – GamrCorps
    Jun 3, 2017 at 13:05

Help me golf my numbers! (Part 2)

Thanks for all your help in Part 1! I recently just found out that my language also supports expressions, and we can use those to make our numbers even shorter!


Write a full program that takes in a list of integers less than 2^53-1. For each integer, rewrite it in the shortest way possible using expressions, and output the result.

Allowed operators

The operators below are given in order of precedence from highest to lowest, with groups separated by empty lines. (These precedence levels are the same as Python.) All binary operators are left-associative, except exponentiation, which is right-associative. Note that some operators are two bytes in length.

**: Exponentiation

* : Multiplication
/ : Integer Division
% : Modulus

+ : Addition
- : Subtraction
~ : Bitwise NOT

<<: Left shift
>>: Right shift

& : Bitwise AND

^ : Bitwise XOR

| : Bitwise OR

You may use decimal, hexadecimal, or scientific notation to represent integers in your output (the answers to Part 1 will help you choose the shortest representation for each integer). You may also use parentheses to group subexpressions.


I will post a list of 1000 integers to be used as the test battery. A program's score will be the size of the output for the provided test, where the lowest score wins. A solutions is invalid if any of the expressions do not evaluate to the given integer. There will also be an execution time limit of 20 minutes for all 1000 inputs (roughly 1 second per input) in order to discourage brute-force solutions.

Numbers for the test battery will be chosen according to the following algorithm:

def choose():
    msb = randint(0, 52)
    return randint(0, 1 << msb)

with duplicates filtered out.


  • Is there anything here that can be clarified?
  • Anything else that can make this challenge more fun?
  • \$\begingroup\$ Sandbox #2 - I don't think bitwise operators will make it too broad. #3 The community has generally agreed that penalties do not make the challenge any more interesting. General advice- make some more rules. Clarify what you mean by "shorten them as much as possible", I had to read that three times to understand. And what do you mean by takes a list of integers? How does one shorten a list using arithmetic? \$\endgroup\$
    – MD XF
    Jun 2, 2017 at 22:32
  • \$\begingroup\$ You should specify how your expressions handle precedence and associativity. I assume expressions can use any number literals? \$\endgroup\$
    – xnor
    Jun 2, 2017 at 22:38
  • \$\begingroup\$ I think it would be good to say something about you're choosing numbers for the test battery. If they are random, heuristic solutions will be effective (or maybe just hardcoding?). Or, if you intentionally choose inputs that benefit from rarely-useful operations like `%, that would be useful to optimize for. \$\endgroup\$
    – xnor
    Jun 2, 2017 at 22:41
  • \$\begingroup\$ @xnor Yes, they may. I'll add information about precedence and associativity as well. \$\endgroup\$ Jun 2, 2017 at 22:41
  • \$\begingroup\$ @xnor Good point. My plan was to choose randomly, do you think this is a good idea? \$\endgroup\$ Jun 2, 2017 at 22:42
  • \$\begingroup\$ I think random would be good. Maybe with some bias towards shorter numbers so they're not all 50-ish bits. It might hard though to beat hardcoding, though the bitwise operations might help. Perhaps you could try to hand-optimizing some random numbers and see how well you do. I think you also need something to rule out brute-force solutions, like a run-time bound. \$\endgroup\$
    – xnor
    Jun 2, 2017 at 22:46
  • \$\begingroup\$ I feel like this might be a dupe. \$\endgroup\$
    – Shaggy
    Jun 3, 2017 at 10:54
  • \$\begingroup\$ @Shaggy could you link to the duplicate please? \$\endgroup\$ Jun 3, 2017 at 12:12
  • \$\begingroup\$ I haven't figured out the right search terms to get me there yet. \$\endgroup\$
    – Shaggy
    Jun 3, 2017 at 12:29
  • \$\begingroup\$ @xnor I added a possible algorithm for choosing numbers as well as a time bound. Do you think this is ready for posting? \$\endgroup\$ Jun 3, 2017 at 18:39
  • \$\begingroup\$ @musicman523 Having thought about it a bit more, I worry hardcoding the number is too effective. It seems really unlikely a random number allows a shorter arithmetic expression than its digit length. I'm not even sure such a number would appear in 1000 samples. \$\endgroup\$
    – xnor
    Jun 3, 2017 at 19:14
  • \$\begingroup\$ I agree. I previously entered 'there can be only one' ( codegolf.stackexchange.com/questions/92962/there-can-be-only-1 ), which was simliar but only allowed using '1'. I don't believe the operators will be useful for almost all numbers, and if you require an operator is used people will just use '+1' most of the time. While a break from your original plan, you could (for example) require using scientific notation, with one number before and after the 'e', so things like '2e5' and '3e7'. That would make operators required and useful. \$\endgroup\$ Jun 4, 2017 at 21:12
  • \$\begingroup\$ Maybe make operators cost less than digits. e.g each operator is 2 and each digit is 5 in order to discourage hardcoding \$\endgroup\$
    – H.PWiz
    Jul 9, 2017 at 15:53
  • \$\begingroup\$ Not a bad idea. I'll probably revive this at some point. Thanks guys! \$\endgroup\$ Jul 9, 2017 at 18:43

Insert a simulated Ken Thompson virus into a program

A Ken Thompson virus is a virus that infects your compiler and other programs. Since it infects all your tools, you can not detect it without using tools from before the virus was introduced.

Your will create a prototype for inserting the Ken Thompson virus into code. The goal of this virus will be to allow you to (fake) destroy any computer running a program infected with it.

Inserting a Ken Thompson virus is defined as follows. Start with an input program P. Your program will output a modified program Q that works as follows:

  • If the input to Q is aNouIQ5xKvUfdZVzo0Xs, it will output BOOM (in a real Ken Thompson virus, this would actually do something bad, but since it this is a fake virus, outputing BOOM is done instead).
  • For any other input to Q, run program P with that input
    • If the output of P is valid source code in the language you are using, insert the Ken Thompson virus into it and then Q will output the resulting infected program.
    • Otherwise, the output of Q is just the output of P.

You will write a program that takes P's code as input and produces Q's code as output.

You can use either a currently (at the time of this post) existing programming language, or a subset of one, for this challenge. (The idea is that language you are using would be the target language of some self-compiling compiler, but this is not required.) Since you want to be as subtle as possible, the shortest code (in bytes) wins!


Find the Harmonic Mean

The harmonic mean of a sequence of numbers is the reciprocal of the arithmetic mean of the reciprocal of each number. For example, the harmonic mean of [1, 2, 3] is 1/((1/1+1/2+1/3)/3) = 3/(1/1+1/2+1/3).


A list/array/tuple/string with some delimeter/etc. of positive integers which fit within the standard integer/float type of your language of choice.


The harmonic mean of those integers, accurate to at least 6 (?) decimal places.

Test Cases

input => output

1 4 4 => 2.0

1 2 3 => 1.63636

527 => 527.0

52 33 400 => 52.6548

7 20 333 45 1 => 4.10481
  • \$\begingroup\$ Sub-challenge of this. \$\endgroup\$ Jun 6, 2017 at 1:28
  • \$\begingroup\$ If you're going to specify the output accuracy in decimal places you need to restrict the input such that it's possible. A 64-bit floating point number (double) can represent about 16 significant decimal figures, but it can represent numbers up to a bit more than 10^300. \$\endgroup\$ Jun 6, 2017 at 7:30
  • \$\begingroup\$ @PeterTaylor not really sure how to handle this... I want people to be able to use the most natural method without allowing silly abuses such as "I can only handle one decimal place" or something. \$\endgroup\$
    – Cyoce
    Jun 6, 2017 at 7:40
  • \$\begingroup\$ If you guarantee that there will be at most 20 numbers, all in the range 1E-8 to 1E8 then I think that should easily be sufficient. \$\endgroup\$ Jun 6, 2017 at 8:46

The problem

As I sometimes build bots, I often came across real time image reading. The goal in this problem is to be able to identify a character given pixel representation with the minimal amount of tests. For that, you will have to generate a tree that can identify any char.


  • A list of frequency
  • A png file containing each char in a 1 wide red box. Its exact color is #ed1c24 and it is not present in any of the chars.


A series of specific test that can identify any char. A test is defined by the pixel coordinates, the exact colour to check, the list of chars to have this pixel and the list of chars that donot.


Let's have a look at only four chars (number 1-4) of equal frequency.


Here we could say that we check for the for pixel in 0,0 (upper left corner). If it is white, it means it's a 1, otherwise we check for the pixel 1,0 (to the right of the upper left corner). If this one is white, it's a 4, otherwise we check for the pixel in 2,2 (the blanck beetween the 3 and the box). If it is white, it's a 3, otherwise it's a 2.

That way we can identify any number in 3 tests at most. If we calculate our score with this layout, it would be 0.25x1 + 0.25x3 + 0.25x3 + 0.25x2 = 2.25 so on average our tree needs 2.25 pixel reading to identify a number.

The solution that lead to that is written like this:

[0,0], [255,255,255], [1], [2,3,4]
[1,0], [255,255,255], [4], [2,3]
[2,2], [255,255,255], [3], [2]

However the best solution for this example has a score of 2. One of the trees that lead to that is

[0,1], [255,255,255], [1,4], [2,3]
[0,0], [255,255,255], [1], [4]
[2,2], [255,255,255], [3], [2]


  • Count each time you read a pixel.
  • Use the number frequency to average your score
  • Your score is the sum of the char frequency times the number of pixels read to identify this number.
  • \$\begingroup\$ What do you mean by 'any number'? If it is more than 1,2,3,4, you should demonstrate what these additional numbers look like. \$\endgroup\$ Jun 7, 2017 at 13:26
  • \$\begingroup\$ Good point. I meant any chars, I extended the problem while writting it. I will fix this \$\endgroup\$
    – Philippe
    Jun 7, 2017 at 13:48

Sources and Strings

The challenge: Output a string with the same length as the source code.

The requirements:

  • Standard loopholes apply, etc., etc.
  • Input may not be taken
  • The output must be deterministic (for scoring purposes)
  • Output must be a string
  • Functions and full programs are allowed, no snippets though

The scoring: This is , so the shortest code in bytes wins. However, for each individual character in the source that has a match in the outputted string, your byte score is increased by 2 bytes.

Examples of scoring (of course, most of these aren't working programs):

Program            Output            Score
nn                 ng                2+(1*2)=4
print('h'*14);     hhhhhhhhhhhhhh    14+(1*2)=16
print('prnt'*4);   prntprntprntprnt  16+(8*2)=32
q                  q                 1+(1*2)=3
qwertyuiop         mmmmmmmmmm        10+(0*2)=10
System.out.println("lol");           Invalid=Infinity points

Prime Factors Zip

Take an integer strictly greater than 2, for example 66. Its prime factors are [2,3,11], when ordered from smallest to biggest. If we zip the digits of those factors, we get [231,1]. Multiplying them yields the integer 231.

If we apply this process back on 231, we get 371. If we apply this multiple times, we get the following sequence:


At this point, we stop because 0 cannot be factored. We say that 0 is the prime factors zip of 66.

If we start with 19, we get the following sequence:


Here, we can see that once we reach 3, we will always get 3. Therefore, 3 is the prime factors zip of 19.

If we start with 22, we get the following sequence:


Here, we can see that once we reach 21, we will always get the loop [21,37]. Therefore, [21,37] is the prime factors zip of 22.

Note that it is possible for an integer to be its own prime factors zip (e.g. 5) or that it is contained in its prime factors zip (e.g. 23 which has prime factors zip [23,6]).


Given an integer strictly greater than 1, output its prime factors zip.

This is , so the shortest answer in bytes wins.

Test Cases

Input        Prime factors zip
7            7
46           0
48           [22103,72463]
100          0
113          3
1337         [337,63]    


I have no idea (nor have I checked extensively) if it is possible than this procedure never loops for some integers.

  • 2
    \$\begingroup\$ I'd suggest explaining "zip" more precisely. I think it is more commonly called "transpose" and you could try to visualise it by drawing out a matrix? For the never looping thing, I think you can just say the programs don't have to handle that. \$\endgroup\$ Jun 9, 2017 at 14:22

Color the Grayscale

Given an image containing only grayscale colors (for RGB, R==G==B), and a RGB value (that is not grayscale), color the image with your given color.

//Is there a formula that does this? If so this can definitely have objective input and output.

Should this be like a lot of the other challenges?


This question is up for adoption! If you would like to finish and post it, please include a little mention for @gryphon :)

Battle of the Bots

Your Task

Program a bot to compete in a battle with other bots. Each robot has fifteen flags situated around their exterior. Your goal is to have at least one flag left on your robot for as long as possible. Each turn you will move diagonally (or not at all) on a square grid with a width/length equal to the number of bots competing squared (attempting to move off the edge of the grid will result in either you moving adjacent to your previous position, or no movement at all if attempting to move from a corner), and use two or less of the four weapons/shields that are situated facing along the horizontal and vertical rows of the grid. You will choose which weapon you would prefer to have in each of your four slots at the beginning of the game. After 2,500 turns, each bot with flags remaining will receive a 500 point bonus, and the game will end. If all flags have been destroyed before this time, the game will end then. The winner will be the person with the most points at the end of 1,000 matches.

Your Code

Each bot will begin in a randomly chosen location on the playing field (bots may be on top of each other). Your code will take the form of two python 2.7 functions, one named (name of your submission) start, which will take no input and return 4 values, one for each weapon/shield slot. The first value will be the top of the bot, and they will continue in clockwise order. The integer values to be returned and weapons/shields they represent are shown below:

1: Firestarter, a weapon that will start a fire adjacent to the bot. Fires start at class 1 and increment upward every turn. If, at the start of a bot's turn they are on top of a fire they lose flags equal to the level of the fire. If a fire is at level 3, it spreads fires of level 1 to all directly (not diagonally) adjacent squares that are not already on fire. When a fire reaches level 8, rather than becoming a level 8 fire, it dies, turning back to an "O" on the map, having used up all available burning material. It may then be lit on fire again in the future.

2: Laser, a weapon that destroys one flag on any bot in a straight line from its firing point outwards from the bot.

3: Buzzsaw, a weapon that destroys five flags on any bot adjacent to the bot using it on the side it is used on.

4: Shield, a defensive mechanism that protects flags from lasers and buzzsaws, and is unaffected by our next weapon.

5: Acid Sprayer, a weapon that destroys the weapon facing it on any bot within three spaces of the bot using it in a straight line (not an arc) from its mounting point

Your second function will receive, first the turn number, second a map of the battlefield in a string, with "R" representing robots (including itself), "O" representing empty space, and the level a fire is at representing any fires. The end of a row will be shown with a semicolon ";". For example, if the battlefield looks like this:


Each bot will receive this:


Next, the bot will receive its X coordinate, and then its Y coordinate, 0 indexed and with the top left corner being 0,0. Finally, the bot will receive how many flags it has remaining.

If multiple bots are in the same square, only a single "R" will be shown. If a bot is standing on the same square as a fire, only the fire will be shown. A bot can tell if it is standing on a fire if its own X and Y coordinates show an integer rather than a "R".

Sample Bots

Will show sample bots here when they are completed


Will show controller here when it is completed

Additional Rules

  • No copying other bots, or copying with only minor changes.

  • No messing around with the judging process, other bots, or writing programs to acquire information that does not come from the inputs given to them, randomizers, or other legitimate sources of information.

  • No writing bots specifically designed to prop up other bots.

  • Maximum of three submissions per user.


Is the explanation clear enough?

Are there any loopholes for programs to exploit?

Any tags other than ?

  • \$\begingroup\$ There are a few points which I think could be clearer. 1. The description of the goal ("on average ... one or more flags left on it for the longest period of time") doesn't seem to match the actual scoring mechanism. 2. Must the weapon selection be deterministic? 3. Does a fire spread to adjacent cells on the turn that it becomes level 3 or on the next turn? 4. How do multiple fires interact? 5. Having burnt to level 8, can a cell be set on fire again in the future? 6. Does the acid sprayer work along the same axis-aligned line as the laser, or does it hit in a semicircle? \$\endgroup\$ Jun 5, 2017 at 11:00
  • \$\begingroup\$ 7. How does a bot know whether the cell it is currently standing in is on fire? 8. I assume that movement is blocked at the edges, but this could be more explicit. \$\endgroup\$ Jun 5, 2017 at 11:01
  • \$\begingroup\$ Edited to fix concerns. \$\endgroup\$
    – Gryphon
    Jun 6, 2017 at 17:15
  • \$\begingroup\$ you should probably use classes rather than two functions, since the ability to remember how opponents behave is useful. \$\endgroup\$ Jun 7, 2017 at 23:23
  • \$\begingroup\$ @DestructibleLemon, I've actually moved on from this challenge now, so consider it abandoned. If you want, you can take it over. \$\endgroup\$
    – Gryphon
    Jun 7, 2017 at 23:25
  • \$\begingroup\$ But... if I did that I would have three koths on the waiting list! \$\endgroup\$ Jun 7, 2017 at 23:29
  • \$\begingroup\$ Wow, that is a lot. I dropped it because I'm working on a new language, but I may readopt it if no one else does after I'm finished. \$\endgroup\$
    – Gryphon
    Jun 7, 2017 at 23:36

Print all video urls of YouTube channel

Inspired by Count the videos in a Youtube Playlist, the input will be the "VIDEOS" view from a channel like this one:


The output will be a complete, newline-delimited list of all video urls the respective channel has to offer. It would look something like


This is codegolf, so shortest answer wins.


  • I am unsure whether the permitted use of Google's YouTube API might be a good idea. It requires an API_KEY and can only retrieve 50 results per request.

Thanks for the feedback.


Patch Tuesdays Calendar


Patch Tuesday happens every second Tuesday of the month, Microsoft and other companies release their monthly security patch on that Tuesday.


The challenge is to write a program that writes 24 consecutive Patch Tuesdays dates separated by newline to the console. The Tuesdays must be the ones of the current year and the next year (not a parameter). Date format must be mm/dd/yyyy.


Code with the fewest bytes wins, there are no bonuses.


Is there a good write up with conventions for golf questions?



My challenge, is for you to generate a Menger Sponge based on the level/iteration given. You need to draw it in 3d, see the Specifications below!

3D Specifications

  • You can use existing 3D libraries


Inputs: 0, 1, 2, 3



Background Information

What is a Menger Sponge

In mathematics, the Menger sponge (also known as the Menger universal curve) is a fractal curve. It is a three-dimensional generalization of the Cantor set and Sierpinski carpet


See https://en.wikipedia.org/wiki/Menger_sponge#Properties (too long to copy and paste)

How do I construct the sponge?


  1. Begin with a cube (first image).

  2. Divide every face of the cube into 9 squares, like a Rubik's Cube. This will sub-divide the cube into 27 smaller cubes.

  3. Remove the smaller cube in the middle of each face, and remove the smaller cube in the very center of the larger cube, leaving 20 smaller cubes (second image). This is a level-1 Menger sponge (resembling a Void Cube).

  4. Repeat steps 2 and 3 for each of the remaining smaller cubes, and continue to iterate ad infinitum.

The second iteration gives a level-2 sponge (third image), the third iteration gives a level-3 sponge (fourth image), and so on. The Menger sponge itself is the limit of this process after an infinite number of iterations.


Background info taken from this wikipedia page on Menger Sponges.

Good Luck!

Remember this is the shortest program wins!


I need help with specifications for the 3d output:

Since 3D is now required (invalidating existing answers), I think the question is now unclear. There is a lot you need to specify for 3D including but not limited to viewing angle, projection, lighting, shading.

  • \$\begingroup\$ This may be a bit too much for the usual golfing techniques. 3D graphics isn't easy to golf. \$\endgroup\$
    – Daffy
    Jun 13, 2017 at 21:32
  • \$\begingroup\$ @Daffy Then, should I try making it a coding challenge? \$\endgroup\$ Jun 13, 2017 at 21:33
  • 7
    \$\begingroup\$ @downvoters - Noah has listened to advice and posted this in sandbox. If you downvote, please give some specific indication of what you think could be improved \$\endgroup\$ Jun 13, 2017 at 21:33
  • \$\begingroup\$ @NoahCristino Personally, I think it would make a better coding challenge, yes. \$\endgroup\$
    – Daffy
    Jun 13, 2017 at 21:35
  • 1
    \$\begingroup\$ @Daffy If the question is about implementing a 3D rendering engine (I don't think it is) then you are probably right. However, if the OP chooses to allow the use of existing 3D libraries (which would not be untypical for this site), then I don't see a problem with it being code-golf \$\endgroup\$ Jun 13, 2017 at 21:35
  • \$\begingroup\$ @Daffy Ok, well I still need to specify the 3d specifications better. \$\endgroup\$ Jun 13, 2017 at 21:35
  • \$\begingroup\$ @DigitalTrauma I would like to keep it code golf, since people have already coded it like this guy: youtube.com/watch?v=LG8ZK-rRkXo \$\endgroup\$ Jun 13, 2017 at 21:36
  • 1
    \$\begingroup\$ I'll edit and say that you can use existing 3d libraries. \$\endgroup\$ Jun 13, 2017 at 21:37
  • 3
    \$\begingroup\$ @Daffy who said challenges need to be easy? There's a question with 250+ upvotes asking for Tetris inside of Conway's game of life... \$\endgroup\$
    – steenbergh
    Jun 14, 2017 at 14:33
  • \$\begingroup\$ @steenbergh Hah! Very very good point. \$\endgroup\$
    – Daffy
    Jun 14, 2017 at 19:56
  • \$\begingroup\$ Could output be as a list of vertices, with you providing a default renderer? This would eliminate the need for a 3d-render on the part of the answerer, might simplify things a bit... \$\endgroup\$
    – steenbergh
    Jun 16, 2017 at 11:03
  • \$\begingroup\$ @steenbergh What if it was the x, y, z coordinates of each block? \$\endgroup\$ Jun 16, 2017 at 18:16
  • \$\begingroup\$ @NoahCristino That would come too far off of your 3d-idea, I believe. Unless you'd make this about voxels, perhaps?. \$\endgroup\$
    – steenbergh
    Jun 16, 2017 at 19:14
  • \$\begingroup\$ @steenbergh but, you still technically outputting a representation of a Menger Sponge \$\endgroup\$ Jun 16, 2017 at 19:49

I Got All Night


  • Is this interesting?
  • Has this already been submitted?
  • Issues/loopholes in the rules?
  • Suitable tags?

The goal

Make a program that takes as much time as possible to complete. That's it.


  • It must not be infinite. while(1){} will not be accepted.
  • You must be able to show how long it will take. Either through calculating it or by measuring it.
  • It must be doing something non-trivial. for(var x=0; x<1000000000000; x++){y++;} will not be accepted.


Your score is the time it takes to complete in milliseconds divided by the size of the program in bytes. Round to the nearest point if needed.

For example, if your program is 95 bytes long and takes 3 hours to complete, your score is (3*60*60*1000)/95 = 113,684 (rounded)

  • \$\begingroup\$ busy beaver tag? \$\endgroup\$ Jun 15, 2017 at 2:29
  • \$\begingroup\$ also nontrivial is a bad requirement \$\endgroup\$ Jun 15, 2017 at 2:29
  • 1
    \$\begingroup\$ The main issue here is that time taken isn't objectively measurable on regular computers. Further, "trivial" is also not objective. Any computable task is largely equivalent to the for loop you have, besides some "minor" details. \$\endgroup\$ Jun 15, 2017 at 2:29
  • \$\begingroup\$ also be prepared for answers that would go past the heat death of the universe \$\endgroup\$ Jun 15, 2017 at 2:29
  • 2
    \$\begingroup\$ @DestructibleLemon Please don't post so many short comments, this isn't a chat room. Take time to think through what you want to say, and say it all at once. You can edit your comments for a couple minutes to add more details you realised that you omitted. \$\endgroup\$ Jun 15, 2017 at 2:32
  • \$\begingroup\$ @FryAmTheEggman The wording I was going to use was "useful" instead of "non-trivial", but I figured that was even less descript. Do you have any suggestions for that? Also, what if I write a python script that measures computer speed (i.e. spinning around in a loop for 10 seconds, incrementing a variable) to normalize for different computer speeds? \$\endgroup\$
    – Daffy
    Jun 15, 2017 at 2:37
  • \$\begingroup\$ @DestructibleLemon That's what I meant by Either through calculating it or by measuring it. If you can calculate that your program will take 15 billion years, then it's completely usable. Converting 15 billion years to milliseconds might be a hassle though ;) \$\endgroup\$
    – Daffy
    Jun 15, 2017 at 2:38
  • 2
    \$\begingroup\$ You would have to run all the submissions yourself then, however the problem will then be answers that take too long to verify. Calculations would be very difficult to say, for example, what if my program will only run on some ancient computer, will I be able to use that clock time? Also what about context switches/interrupts/etc? Generally I don't think this kind of challenge works, it's sort of like why world records for "shortest concert" don't exist anymore: programs that take forever are not really programs. \$\endgroup\$ Jun 15, 2017 at 2:46
  • \$\begingroup\$ I think this ground has been well-covered by existing challenges to make large numbers and this would add anything new. \$\endgroup\$
    – xnor
    Jun 15, 2017 at 3:29

Help me play Battleship!

Battleship is a two-player guessing game in which each player guesses the placement of the opponent's ships, placed on a grid.

Each column is labeled with a letter, and each row with a number. The label starts from top left (A and 1), and descends as you move right/down.

Each player is given two grids, one for placing ships, and one for guessing the enemy's ship placement. Each player places 5 ships -- one ship of length 5, one ship of length 4, two ships of length 3, and one ship of length 2 -- on her grid, either horizontally or vertically. The players should not share their ship placements.

After placing all ships, each player takes turn guessing the opponent's ship placements. The guessing player guesses one position, and the defending player must announce "hit" or "miss," depending on whether she (the defending player) had a ship there. When all positions of a ship is hit, it is "sunk."

The player who sinks all of the opponent's ships win.

This is an example of a battleship board (taken from Wikipedia):

enter image description here


Given the list of guesses a player has made, construct a 10x10 array that represents the board.


  • The input can take any reasonable format, as long as it is explained. Some examples are [[position, result], [position, result], ...] and [[hit positions], [miss positions]].
  • The output array can have any characters, as long as empty, "hit," and "miss" squares are distinguishable from one another. (e.g. unknown = 0, hit = 1, miss = 2)
  • You may not take the list of unknown grid positions in the input.

Test Cases

Pastebin link


  • Is this challenge interesting?
  • Are there any dupes? (I couldn't find one)
  • Did I include too much detail in the introduction? (If so, what should I remove?)
  • Are my test cases sufficient?

Star Trekkin'

Just an idea at this stage; wanted to get it down lest I forget it. I'll come back to it in a few days to work out the details.


Generate an ASCII art representation of the USS Enterprise with an animated, randomised ASCII starfield behind it.


Programming Challenge: Winning criterion is the shortest byte program which can tell me (x, y) which number "x" was doubled in the list, and which number "y" was removed from the list of 1000 numbers from 1 to 1000.

Given a list of 1000 positive integers in random order, find the integer that is repeated more than once, the integers that are not present in the range [1,1000] and output the count of the repeated integer present in the list.

The format of the list is a space deliminated text file such as this:

779 990 5 814 353
627 173 797 714 619
802 719 895 966 325
275 158 322 215 271
631 232 175 10 397
892 124 26 287 878
757 754 508 871 255
363 159 482 400 247
223 857 862 18 434
919 335 586 65 579
828 943 366 874 999
238 289 362 600 321
193 863 613 930 143
107 879 530 284 110
437 426 981 546 924
701 441 941 43 614
542 727 694 351 643
794 563 476 834 624
804 634 776 672 57
597 338 748 908 156
297 234 444 598 891
925 163 229 791 326
944 182 262 987 734
582 910 567 132 28
645 962 994 6 917
617 64 106 304 404
88 93 849 882 677
749 254 12 399 897
329 988 31 379 654
25 646 134 445 327
577 848 673 551 408
405 806 244 40 601
497 177 972 526 545
796 755 630 663 423
428 562 610 1 686
548 281 101 154 747
763 32 236 368 956
639 522 507 792 771
693 147 728 203 845
615 889 931 440 299
348 707 235 320 295
803 513 703 940 717
205 150 702 189 183
296 875 575 454 492
194 425 126 657 976
570 809 945 825 168
890 217 656 29 550
684 188 78 221 446
523 952 676 900 583
484 933 268 608 708
665 17 963 212 253
432 964 858 909 316
155 120 114 210 477
319 647 822 409 388
818 308 77 102 373
929 113 402 841 213
470 877 648 968 135
309 824 690 844 463
323 240 706 391 653
372 985 346 788 510
991 554 494 44 915
758 756 989 759 659
534 142 939 675 378
974 345 462 54 942
681 1000 7 716 415
42 264 996 438 464
386 350 197 141 84
123 127 811 853 516
60 49 277 70 986
98 733 905 978 103
390 230 501 449 731
34 370 541 958 466
251 71 108 846 260
576 830 100 140 529
869 333 303 664 589
856 777 427 187 184
305 766 829 136 456
786 401 737 961 475
412 887 178 91 698
448 433 62 519 832
314 957 861 898 683
983 515 893 220 817
979 149 267 3 63
458 473 139 970 835
666 119 967 695 343
242 947 41 47 623
973 53 354 74 816
121 471 151 246 369
499 45 593 691 376
111 46 226 83 431
274 606 506 265 753
79 387 451 883 525
479 744 162 949 8
292 95 97 324 823
315 152 394 671 718
347 836 50 195 360
812 566 725 612 923
537 911 620 51 328
243 19 556 592 288
334 298 873 655 443
705 66 767 604 285
760 896 474 406 73
918 688 667 914 730
729 826 959 774 543
594 192 27 948 912
491 419 341 518 55
146 787 495 904 172
469 761 840 626 637
144 616 465 712 660
785 365 250 636 384
208 2 174 864 839
741 410 621 342 442
245 568 998 485 216
960 224 239 782 855
291 355 860 807 936
920 56 669 561 697
112 270 715 913 938
364 851 467 751 468
450 995 609 490 72
674 713 640 185 801
361 742 38 784 167
225 743 692 790 907
859 762 569 115 521
116 200 580 632 997
85 82 249 207 486
218 196 14 932 867
429 258 125 793 69
865 385 902 222 531
611 658 318 935 980
808 23 105 722 300
520 30 420 286 662
227 581 745 585 928
330 638 358 587 16
452 635 736 489 252
89 951 137 591 721
880 555 204 535 769
9 820 605 854 148
128 934 396 480 307
161 711 750 704 651
696 133 813 789 517
263 775 553 75 992
293 190 916 273 602
461 11 977 202 764
483 76 52 773 723
870 872 498 359 868
67 544 504 279 833
599 48 171 687 80
547 336 417 642 181
558 906 256 219 81
866 810 709 186 668
572 145 209 739 682
847 752 720 332 393
770 965 574 629 176
746 306 138 798 15
528 778 392 457 726
337 39 86 380 160
493 211 436 180 241
795 94 955 837 214
584 954 117 549 59
340 805 367 927 633
946 738 819 487 557
768 4 37 827 596
511 628 381 68 679
838 179 603 680 13
231 650 35 700 735
975 595 502 301 424
527 678 950 280 532
649 685 710 539 903
248 276 571 500 435
560 109 926 588 278
414 509 237 169 740
885 118 430 382 689
481 311 199 993 821
261 447 540 357 92
129 131 953 375 377
852 61 191 228 937
122 418 439 573 198
331 302 505 644 283
421 416 36 894 884
831 22 24 104 876
371 272 622 312 578
459 395 455 536 374
969 403 565 269 389
552 90 164 922 781
503 460 524 206 356
130 259 533 294 157
901 422 290 514 982
641 661 478 559 496
282 512 266 257 538
765 564 96 783 724
843 317 411 799 652
488 310 349 313 413
453 886 58 971 20
921 618 815 850 99
339 87 21 472 699
33 607 800 352 899
233 166 780 407 625
670 201 170 383 772
344 376 881 984 590
165 732 153 398 842  

For example in this list 376 is repeated twice, and 888 is removed once. In this challenge a number "x" can only be repeated "once", so the number "888" can only be removed once, so an acceptable output for a programmed answer is this "(x, y)" where "x" is the number repeated twice, and "y" is the number removed.

I attempted to make this programming question, but because I included a bonus for web-scraping, and the format of the output for an answer was not clear it didn't receive positive reviews.

So I would like suggestions I how I can make this challenge clearer. Thank you.

Here is my challenge and the comments I received.

Programming Challenge: Tell me which number I repeated, how many times, and which one I skipped?

  • 1
    \$\begingroup\$ I have gone through and made the challenge clearer here: hastebin.com/ucesohawok.md Feel free to use or disregard this. However, one of my suggestions is to loosen the I/O formats (meaning stating input and output can be in any reasonable format). This would mean that the list could be taken as a list/array instead of a string. Same thing for output. This is ultimately up to you, but note that it is discouraged to restrict I/O formats as you have done. \$\endgroup\$
    – GamrCorps
    Jun 15, 2017 at 20:26
  • \$\begingroup\$ Thank you very much. \$\endgroup\$
    – xyz123
    Jun 15, 2017 at 20:47
  • \$\begingroup\$ My first reaction was that this is too straightforward to golf, but thinking more led to some interesting tricks. I think this is a nice challenge. \$\endgroup\$
    – xnor
    Jun 16, 2017 at 0:14
  • \$\begingroup\$ I suggest relaxing the input format and also allow a list or array of numbers. \$\endgroup\$
    – Laikoni
    Jun 17, 2017 at 7:00

Working For The Weekend

Option 1

Taking no input, output true if today is Saturday or Sunday or false otherwise.

Option 2

Taking no input, output how many days, from today, until the weekend.

Sunday:    0
Monday:    5
Tuesday:   4
Wednesday: 3
Thursday:  2
Friday:    1
Saturday:  0


  • Which option do you prefer?
  • Too trivial?
  • Dupe?
  • Allow local times to be used or require UTC? (I wanna say UTC)
  • true & false or truthy & falsey? (if option 1)
  • Working or Livin' For The Weekend?
  • 1
    \$\begingroup\$ 1) option 2 is less trivial and so Peter Taylor may not downvote / 2) Local times, not UTC / 3) truthy & falsey if you choose option 1 / 4) Working For The Weekend \$\endgroup\$ Jun 16, 2017 at 14:28
  • 2
    \$\begingroup\$ In my opinion this is far too trivial to be interesting. I feel in general time based questions are pretty boring. I don't feel it provides anything that hasn't been covered extensively by other date/time questions. \$\endgroup\$
    – Wheat Wizard Mod
    Jun 16, 2017 at 14:32

What could I add to improve this post? I have some questions that are inside of brackets.


A farmer needs help calculating the least time it will take him to pick his fruit each day.


  • This farmer has X orchards.
  • Each orchard has Y [is Y the correct variable to use here? does it matter?] fruits in it. If the orchard has no fruits, then it will contain the string "none".
  • The farmer has a list, this list contains the fruit he must pick.
  • The farmer will only go down the list in order
  • You must calculate how long it will take the farmer to pick his fruit on each day.

More on the orchards

  • All of the orchards are in a line.
  • Each orchard is exactly 1 unit [should I say unit or kilometer?] away from the next and previous one.
  • The farmer can go up and down the line, but may not jump from one orchard to another

Input and Output

You will receive an input in the following format:

*string* *string* *string* *string*
*string* *string*
*string* *string*
*string* *string*
*string* *string*

X is the number of orchards

  • Everything after X and before Y is an orchard containing a/some string(s), each string is a different fruit in that orchard.

Y is the number of days that the farmer must gather fruit.

  • Each day consists of two strings that are different fruits.
  • You must find what orchard these strings are in and calculate the difference.

Input Rules:

  1. Each fruit name string will be one word with no spaces
  2. [Should I add more here? if so, what should I add?]

Real Example

Still confused? Maybe this will clear it up:





orange pear pear


orange lemon pumpkin

pumpkin lettuce flowers peas


peas lettuce 

apple orange 

apple pumpkin 

flowers orange 

output: [ 0, 1, 3, 1 ]



  • 6 the number of orchards
  • A set of 6 orchards containing fruit, each orchard on a new line.
  • 4 the number of days on the farmers list.
  • A set of 4 fruits to compare, each pair of fruits is on a new line.


  • Output an array of the differences between each set of fruits.
  • The difference between peas and lettuce is 0, because they are in the same orchard.
  • The difference between apples and oranges is 1 because they are one orchard apart.
  • The difference between apples and pumpkins is 3 Because they are three orchards apart.
  • The difference between flowers and oranges is 1 because they are one orchard apart.

Annotated input/output

6 orchards 

a none

b apple

c orange pear pear

d none

e orange lemon pumpkin

f pumpkin lettuce flowers peas


4 fruits

peas lettuce 0

apple orange 1

apple pumpkin 3

flower orange 1


output: [ 0, 1, 3, 1 ]
  • \$\begingroup\$ I would only use the name y one time, as using it for two different things makes this a little confusing. \$\endgroup\$
    – Gryphon
    Jun 21, 2017 at 20:07

Studio 54

Studio 54 was a famous nightclub in Manhattan. The club is referenced in the Futurama episode Rebirth in which the crew visits a nightclub called Studio 122133. The mathematical expression 122133 evaluates to (1 x 1) x (2) x (3 x 3 x 3) = 1 x 2 x 27 = 54.


Determine whether a positive integer is a "studio number." We define a studio number to be a number n that can be expressed as the product of a set of distinct positive integers that does not include n, each of which is raised to the power of one of the numbers in the set. Or, more mathematically:

Studio Numbers

You should have a consistent output value for "is a studio number" and "is not a studio number," and nothing else.

Test cases

These are inexhaustive lists and are just meant for basic ad-hoc testing.

Studio numbers:


Not studio numbers:


Computed by this script.


I'm going off of this for the two consistent outputs, but I'm not really sold either way. I could also change the requirements to be to output the "studio" representation of the number.

Does the math-y bit help? Could I make the studio number definition clearer?

I've been unable to find any "nice" properties of these numbers that allow for methods besides brute force. Would this still be interesting enough to golf? I could also add a "reasonable time" limit that would enforce some non-naive code to reject bad attempts, but I'm not sure that's much better.

The studio numbers do not appear to be a sequence recorded on the OEIS.

  • \$\begingroup\$ You say "does include n", but I think you mean, "does not include n". \$\endgroup\$ Jun 17, 2017 at 22:32
  • \$\begingroup\$ @Challenger5 Uhhh, whooops... Thanks :) \$\endgroup\$ Jun 17, 2017 at 22:37

Only HeLlO WoRLd is allowed.

We are all familiar that "Hello World" is the 1st introductory program that most people learn when they first start to program. Then programmers go on to greater and better programs. But who says they have to go on to greater and better programs? What if all other programs were censored?

Your Task:

Write a computer program that takes in standard input. If the standard input is any case-insensitive version of HeLlO WoRLd, do nothing. If the Standard input is anything other than a case insensitive HeLlO WoRLd, print an infinite loop of a HELLO WORLD matrix to the standard output.

To print an infinite HELLO-WORLD-Matrix, randomly sort the letters of "HELLO" and the letters of "WORLD", join the two words with a space as if you were saying HELLO WORLD, although you are probably saying "HELLO DWROL", " OELLH LWODR" gibberish with an occasional "HELLO WORLD". Then just keep printing all this gibberish to the standard output.
























There is actually only one "HELLO WORLD" amid all this gibberish

Winning criterion: shortest program in bytes.

  • \$\begingroup\$ What is an infinite loop of a HELLO WORLD matrix? \$\endgroup\$
    – user42649
    Jun 18, 2017 at 16:08
  • \$\begingroup\$ Actually, I think I would like to up the challenge and request that HELLO WORLDS be printed to the standard output in a tab deliminated string with the letters randomly sorted, so occassionally the standard output would get HELLO WORLD HELLO WORLD ... But it would mostly get "EHLLO DWORL HEOW LLROD ... etc. \$\endgroup\$
    – xyz123
    Jun 18, 2017 at 16:11
  • \$\begingroup\$ I updated my HELLO WORLD INFINITE matrix problem and made it more difficult. You should check it out. Is there anyway that I can have the tab separation show up on the problem the same way it shows up on the edit tab? \$\endgroup\$
    – xyz123
    Jun 18, 2017 at 17:01
  • \$\begingroup\$ You may want to say "anagram of..." instead of "randomly sort the letters of..." \$\endgroup\$
    – Mr. Xcoder
    Jun 18, 2017 at 17:29
  • \$\begingroup\$ Are there rules about the horizontal and vertical spacing of your matrix, and the number of helloworldoids per line? This needs to be explicitly specified or else explicitly left flexible. \$\endgroup\$
    – user62131
    Jun 19, 2017 at 18:54
  • \$\begingroup\$ What do you think would make the challenge the most fun? \$\endgroup\$
    – xyz123
    Jun 20, 2017 at 3:54

Golfing a Busy Turing Machine

For the sandbox

This question is really hard, and the solution is restricted to one "language" – a 1-tape, 2-symbol Turing Machine. So I'm not sure if it belongs on PPCG. I've written up a basic description below, but can go into more detail if anyone is interested.


I recently came across a paper that explicitly presents a 7910-state 1-tape, 2-symbol Turing machine that cannot be proven to run forever in ZFC, assuming ZFC is consistent. It also cites codegolf.stackexchange.com!

The existence of this Turing machine proves that calculating BB(7910) is independent of ZFC.

So, we know that we can calculate up to at least BB(4), and definitely can't calculate BB(7910) and above.

Can you create a Turing Machine with under 7910 states that cannot be proven to run forever in ZFC?

The author designed two custom-purpose programming languages (Laconic and TMD) to create this Turing Machine. In order to improve upon his work, I imagine you could go one of three ways:

  1. Optimize his algorithm in Laconic such that it encodes the interpreter or Friedman's mathematical statement (section 3.1) more tersely.

  2. Optimize TMD so individual instructions are translated to fewer states.

  3. Find a simpler statement whose truth implies the consistency of ZFC, and encode that instead of Friedman's statement.

  4. Go another direction entirely!

Winning criteria

The Turing Machine with the fewest number of states that cannot be proven to run forever in ZFC, wins. The length of the code you used to generate this Turing Machine is irrelevant.

You don't win if you compute BB(5), but you do get eternal fame.

  • \$\begingroup\$ There's currently a huge loophole in the question: you can just present a Turing machine that trivially halts, without violating any of the rules. Defining this unambiguously is going to be hard; the problem is that the submitter has to prove that the Turing machine always halts, but also prove that the Turing machine can't be proven to always halt, which is almost a contradiction (and only works because the first "prove" is subjective but the last objective; but how do you enforce a subjective criterion?). That said, I like the question and it'd be nice if it could be made to work. \$\endgroup\$
    – user62131
    Jun 19, 2017 at 19:24
  • \$\begingroup\$ It's also worth noting that the vast majority of PPCG users won't understand the question no matter how precisely you try to word it. That probably isn't a problem for the people who are interested in or are willing to learn computability theory, but expect a large number of wrong answers that misunderstand the question and have to be deleted. \$\endgroup\$
    – user62131
    Jun 19, 2017 at 19:25
  • \$\begingroup\$ @ais523 "Cannot be proven to run forever" is a subtle point – it's not that it doesn't run forever but that it's impossible to prove whether or not it does. If the submitter can prove that the Turing machine always halts, then it would not be a valid submission. Or if it were, would solve the halting problem. I should clarify to say "cannot be proven either to halt or to run forever." My big concern is your second comment, though. In any case, this post explains the main points in the paper, and is very accessible and worth reading independent of PPCG! scottaaronson.com/blog/?p=2725 \$\endgroup\$ Jun 19, 2017 at 19:33
  • \$\begingroup\$ Right, I think the correct framing of this problem is "produce a Turing machine that cannot be proven to halt and cannot be proven not to halt". (Of course, we know it won't halt in practice, because if it did, you could prove it halts by running it, but that should be left out of the framing of the question.) That makes it clearer what's going on to people who haven't seen the problem in question beforehand. I wonder if opening this up to other languages might not be interesting too: brainfuck, for example, is a good fit for this challenge. Things like Jelly probably aren't though. \$\endgroup\$
    – user62131
    Jun 19, 2017 at 19:36
  • \$\begingroup\$ @ais523 The way to construct a program like this is usually to say "this machine halts iff conjecture A is true" where conjecture A's truth implies the consistency of ZFC. \$\endgroup\$ Jun 19, 2017 at 19:37
  • \$\begingroup\$ Opening up to other languages seems reasonable enough, especially as I imagine it wouldn't be too hard to write a brainfuck to 1-tape turing machine transpiler \$\endgroup\$ Jun 19, 2017 at 19:38
  • \$\begingroup\$ I can tell you haven't read the discussion about this in the comments of two blog posts in Aaronson's blog, because Stefan O'Rear one-upped with a search for a contradiction in ZFC in about 1900 states. See github.com/sorear/metamath-turing-machines . NB codegolf.stackexchange.com/q/79620/194 was also inspired by that discussion, although in a slightly different direction. See cheddarmonk.org/papers/laver.pdf for a 64-state machine which is not known to halt in ZFC, but is proven to halt assuming a rank-into-rank cardinal. \$\endgroup\$ Jun 19, 2017 at 22:17
  • \$\begingroup\$ @PeterTaylor very cool, thanks! I generally try to steer clear of comment-reading on blogs, but I should probably make an exception for academic ones. \$\endgroup\$ Jun 19, 2017 at 22:20
  • \$\begingroup\$ @PeterTaylor I just noticed that the Laver paper is yours. Super impressive. I'd love to know if/when you ever end up publishing it \$\endgroup\$ Jun 19, 2017 at 22:31
  • \$\begingroup\$ Any answer to this is also an answer to Write a program whose nontermination is independent of Peano arithmetic. Turing machine answers are welcome. (Though I’m not sure how we score those in bytes… perhaps the entropy measure (2n lg (4n + 1))/8?) Also (conjecturally) related: Laver table computations and an algorithm that is not known to terminate in ZFC. \$\endgroup\$ Jun 23, 2017 at 20:44
107 108
110 111

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .