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

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!

What's the Missing Code?

• Now this sounds like fun! Just one question: wouldn't it add more to the challenge if you didn't tell the robbers where each letter was removed? I feel like knowing where the missing characters are would make it too easy, especially since the cops are trying to create as short code as possible (so that they win). Do you think it would make it too easy? Mar 27 at 18:13
• I thought about this, but I came to the conclusion that it would make it easier for the robbers to simply go to the start of the program, and write print(...); end program. However, on thinking about it again, this would make it easier for the cops to reduce the characters removed while keeping the answer non-obvious, which would prevent the robbers from doing this. I will consider this and perhaps change the question. Mar 27 at 18:19
• Ohh.... I see what you mean. But that could be part of the cops' challenge: making the code complicated enough, with few enough characters removed, so that the robbers couldn't do that. But yes, your reasoning makes sense now. In that case, either way would be fine. I'm looking forward to when this is posted on the main site! Mar 27 at 18:28
• I think it is too easy for the robbers in its current state, so I will edit it to include your suggestion: I think that as long as the cops remove few enough characters, it will be impossible for the robbers to do this. Mar 27 at 19:17
• If your int("5") example is run in the Python shell (as opposed to in a program), the output is 5. Just FYI. Mar 27 at 19:46

Wash clothes as quickly as possible

• Can you add test cases? Mar 29 at 15:50

Give me the electronic configuration.

As simple as the title.

Input will be a number denoting the atomic number.

The output will be the electronic configuration of the element of the given atomic number.

There are 2 rules for electronic configuration:

• The maximum number of electrons each shell can hold is given by $$\2n^2\$$ where n is the shell number starting from 1.
• The number each shell is allowed to hold from the last shell is given by $$\2n^2\$$ where n is the number starting from 2, in reverse.

You must fill each shell to it's limited capacity from left to right, with the remaining electrons on the last shell.

Test cases

12 -> [2,8,2]
13 -> [2,8,3]
20 -> [2,8,8,2]
86 -> [2,8,18,32,18,8]
29 -> [2,8,18,1]

• You may specify this a little more, as according to current spec any of [2,2,8], [2,8,1,1],[1,1,1,1,1,1,1,1,1,1,1,1] is a valid answer for 12. Apr 10 at 20:03
• @pajonk i added this line You must fill each shell to it's limited capacity. Apr 11 at 3:23
• 29 should return [2,8,18,1], not [2,8,18,2] Apr 11 at 4:12
• BTW, it's more accurate to call it the electronic shell structure, not the electronic configuration Apr 11 at 4:13
• @Steffan that's how we learnt it Apr 11 at 5:09
• @PyGamer0 You must fill each shell to it's limited capacity from left to right, with the remaining electrons on the last shell, maybe? Remember, you're dealing with programmers here ;-) Apr 11 at 11:14
• @pajonk ok, edited. Apr 11 at 11:29
• If you look up the electronic configuration of atomic number 12, for example, you'll see things like 1s^2 2s^2 2p^6 3s^2 at the top. If you look up electron shells of atomic number 12, it will tell you 2,8,2. Apr 11 at 16:07
• I just noticed this is a duplicate of codegolf.stackexchange.com/questions/37657/… Apr 19 at 18:36

Translate Text into Matoran

The Matoran Alphabet is the alphabet used by many of the characters in the Bionicle universe.

Your challenge is to create a program or function that takes a string as input and creates an image of the input written in the Matoran alphabet.

The input will only consist of uppercase letters (A-Z), numbers (0-9), and spaces. You may instead take input in lowercase.

Glyphs

As you can probably notice, the alphabet comprises glyphs made up of circles and straight lines.

For the sake of this challenge, let's define each glyph as a circle of radius 4 units (8 x 8), with some internal designs. The internal designs of letters can be any of:

• Vertical Line at position 2, 4, or 6 (either full length or half)
• Horizontal Line equivalent to above
• Circle of radius 1, centered at [2, 2], [2, 6], [6, 2], or [6, 6]
• Any of the above rotated by 45 degrees about the centre

Number glyphs work slightly differently; they always have a circle of radius 1 in the centre. For numbers 0 - 5, the glyph has evenly spaced spokes between the circles, starting from the top. For numbers greater than 5, the glyph has an additional circle of radius 2 in the centre, and the number of spokes is 6 less than the number.

Here is a diagram of the glyphs in spec, any glyphs with 45 degree rotations have an orange grid.

For drawing the glyphs, any line stroke in the range (0, 1) can be used. Glyphs can be kerned (space between adjacent glyphs) any amount from 0 - 4 units. Spaces should be 8 units wide (in addition to kerning).

This is a code-golf challenge, so the shortest code in bytes in each language wins.

• This does seem like pretty interesting challenge, although I would recommend a clearer image of the characters of the Matoran alphabet, and probably a more rigorous definition of the shapes of each of the characters (eg. defining the positions/lengths/radii/etc of the inner circles/lines in terms of the radius of the exterior circle) Apr 11 at 4:14
• @des54321 Thank you! I added some specification around the characters. Do you think this is sufficient, or should I include a written definition of each glyph? Apr 11 at 22:31
• That looks pretty good! I'd suggest leaving this challenge up on the sandbox for a bit longer to see if anyone else has suggestions, but as things stand now this seems a very well specified and fairly interesting challenge Apr 11 at 23:06
• Thanks for your help, I'll leave it a couple of days then post it. Apr 11 at 23:13

Get the trends of an array

• Is there any specifications prevent the program from outputting [[1,1], [1,2], [2,3]] for [1,1,2,3]? Maybe you should add some texts about "you should generate fewest possible trends" or something like it.
– tsh
Apr 18 at 8:43
• @tsh Good idea. Added. Apr 18 at 9:17

Will this makina program halt?

makina is a cell-based esolang composed of automata which move around a grid. These automata follow paths of instructions that direct their movement. Your task is to, given a makina program using only the below instructions (so a subset of normal makina) as input, output two distinct values depending on whether or not it is a loop. (If program flow comes to an arrow character that it has already visited then the program is a loop.)

Instructions

• ^>v< These instructions (arrows) set the direction of the automaton to the direction they point in.
• I This instruction halts automata going up or down, but does nothing to ones going left or right.
• H This instruction halts automata going left or right, but does nothing to ones going up or down.
• O This instruction does nothing to the automaton, acting like a sort of 4-way intersection.

All other characters halt the automaton, as does exiting the bounds of the program. The automaton starts in the top-left corner going right.

Truthy

>>>v
v<<<

OOOv
H<<<
v


Falsey

>>>v
^<<<

>v
^O<
>^

>>>v
v<I<
H>^
>^

>>>>v
v <<<

OOOv
H<<<
v

• "All other characters halt the automaton" So arbitrary characters different from >v<^HIO can be part of the input? If so, this should be reflected in the test cases. (Personally, I'd only allow valid characters in the input.) Apr 24 at 19:39
• Also the current last two Falsy test cases actually halt and are probably a cop-paste error from the Truthy cases. Apr 24 at 19:43

Who needs 8 bits for one character?

• I'm a little confused by the test cases in this challenge. Based on your description of how to get the solution, I wrote an (ungolfed) Python program that does that (as far as I know). However, my results differ greatly from yours, specifically in using "the fox" as input. For that string, you get [170, 76, 19, ...], but my code gets [172, 239, 134, ...]. I'll put a TIO link in another comment, if you want to try it out. I do note that your first index (the index for a under "How, though?") starts at one, not zero. Could you help me understand this difference in results? Thanks! May 6 at 17:31
• Try it online! Other than that problem, this sounds like a good challenge! +1 May 6 at 17:31
• @SylvesterKruin It is one indexed because otherwise, 000 may get lost in leading zeros. Your Python code has a couple problems. One is that it does not pad leading zeros to the binary of each character. Another is that your code has a bug where it does not output the last byte (because of Python exclusive ranges). Also, the last byte should pad zeros at the end, which it does not do. May 6 at 17:54
• Here is your code fixed: Try it online! May 6 at 17:54
• Ah, it didn't pad leading zeroes... that's what it was. I intentionally left out the last <8 bytes for reasons of simplicity. Thanks for the feedback! I'm looking forward to when this challenge is posted on the main site! May 6 at 18:07

Derivative of a product

• Is the input always at least 2 characters long? May 2 at 13:31
• @pxeger Yes. (filler) May 4 at 9:42

Convert to Shorthand (Part 1, Part 2)

• Conjunction points of O P X Y may be ambiguous.
– tsh
Apr 26 at 12:08
• @tsh I am thinking of allowing multiple correct answers for the same input. To make it slightly more precise I have added more rules and improved the examples. Apr 26 at 12:14
• I feel like this are actually two challenges in one: 1. transcribe to the weird alphabet 2. make this "interconnected". I suggest splitting to two challenges. Apr 26 at 17:57
• I see you posted the first part, please edit this post or post a new one so that we can discuss the details of the second part (if you like). Apr 27 at 5:12
• @pajonk Thank you for the interest. I am thinking of putting all details in the same question to avoid clashing of data. This question is still the umbrella goal I am trying to achieve with it. I will be editing details once I get more suggestion from the posted questions Apr 27 at 8:00

Modular tetration

Tetration is the operation of repeated exponentiation. That is $$\ ^{n}a = a ^ {. ^ {. ^ {.^a}}} \$$, with $$\ a \$$ appearing $$\ n \$$ times.

Tetration grows extremely fast - $$\ ^6 2 \$$ would take significantly more digits to write then there are atoms in the known universe.

However, to work with big numbers, we can operate on them modulo some number $$\ m \$$.

Your task is to calculate $$\ ^n a \mod m \$$, with integer $$\ 1 < a,n < m \$$.

Rules

• You may use any consistent reasonable I/O method.
• The complexity of your answer must be $$\ O(m) \$$, where $$\ m \$$ is the modulus. In particular, you can't calculate $$\ ^{n}a \$$ with arbitrary precision and then modulo by $$\ m \$$.
• Standard loopholes are disallowed.
• Your algorithm must work for all values, but it's allowed for your program to fail due to integer overflow.

Test cases

The format for the test cases is a n m -> answer (however, you can take your input in any order) [Sandbox note: TODO - there's an error in my program]

This is , so the shortest answer in bytes wins.

• I don't really know how to compute $O$ here, but would this algorithm satisfy the requirement on $O(m)$? May 13 at 11:03
• @pajonk it depends on the implementation. If you calculate euler's totient by going over all numbers from 1 to m and calculating the gcd it wouldn't, since calculating the gcd is logarithmic time, so it'll be $\Theta(m \log m)$. If you calculate it by factoring $m$ in $o(m)$ time then it's fine. May 13 at 11:49

Convert Alpha-2 to Alpha-3

• I liked the back story, personally. May 13 at 16:49

There's more than one way to skin a setcode-golfnumberset-partitionsinteger-partitions

• You may want to clarify that when summing the subset, one may take a number only once and that the order doesn't matter. Also subjective suggestion: allow only inputs of length >1 (or even >2). Apr 9 at 19:35
• Description could be clearer, possibly something like "given a set S of integers, output all the integers that are the sum of multiple subsets of S" would be less wordy and clearer, also outputting a "set" is probably not necessary, as I feel that whitespace delimited strings or simple lists would work, especially since not all langs have a specific concept of a set Apr 11 at 16:48
• also possibly add a few comments onto the test cases to explain them a bit more, eg. on test case 3 adding a comment like "21 can be 10+11 or 9+12" Apr 11 at 16:51
• @des54321 It's pretty standard that "outputting a set" doesn't literally mean a builtin set type, it just means some kind of list-y thing Apr 11 at 16:55
• @pxeger, fair enough, although you may want to explicitly specify strings with just whitespace separators if you want to allow that as output, as especially with the current format of your testcases that does feel slightly like its not allowed Apr 11 at 16:57

Convert Klingon romanization to pIqaDcode-golf

Context

Klingon is a constructed language from Star Trek. It has two writing systems: a not-very-good Latin alphabet (with case distinctions, I being different from l, ...) and its own script, called pIqaD.

Convert the bad[disputed - discuss] Klingon romanization into pIqaD. Here's a CSV (the pIqaD [or, if you don't have a font for it, boxes or nothing] is in the second column and the Unicode hexadecimal codes are in the third):

a,,f8d0
b,,f8d1
ch,,f8d2
D,,f8d3
e,,f8d4
gh,,f8d5
H,,f8d6
I,,f8d7
j,,f8d8
l,,f8d9
m,,f8da
n,,f8db
ng,,f8dc
o,,f8dd
p,,f8de
q,,f8df
Q,,f8e0
r,,f8e1
S,,f8e2
t,,f8e3
tlh,,f8e4
u,,f8e5
v,,f8e6
w,,f8e7
y,,f8e8
',,f8e9


Be careful not to mix up q and Q, they are different letters in Klingon!

Input and output

Strings! or your language's equivalent. You can assume that the input contains no characters not in Klingon (incl. miscapitalized dhis) or numbers or punctuation.

Scoring

Lowest byte count wins, as always.

suggestions? :)

• I like it! It seems ready for publication. May 25 at 21:34
• My browser shows only ⍰ in the second column of the csv. Maybe add a link to TIO or other external page, which will render it correctly. If possible, you may also add UTF codes for those characters. May 26 at 10:02
• @pajonk i added the unicode codes :)
– matt
May 29 at 14:28

Generate Fibonacci Primes Quickly

Unsurprisingly, fibonacci primes are primes that are also Fibonacci numbers. There are currently 34 known Fibonacci primes and an additional 15 probable Fibonacci primes. For the purpose of this challenge, the Fibonacci numbers are the sequence $$\F_n\$$ defined as $$\F_1 = 1\$$, $$\F_2 = 1\$$, and $$\F_n = F_{n-1} + F_{n-2}\$$, and a number is considered prime if it passes a probabilistic prime test with a probability of being incorrect of less than $$\2^{-32}\$$. For example, since a $$\k\$$ round Miller-Rabin test has an error probability of $$\4^{-k}\$$, a 16 round Miller-Rabin test is sufficient to prove primality for the purpose of this challenge.

Submissions:

The goal of this challenge is to write a full program that calculates every Fibonacci prime and its index in the Fibonacci series as fast as possible.

Submissions shall be a full program, complete with instructions for building and running it. Submissions must be in a language freely available for noncommercial use and capable of running on Windows 10, and users must be prepared to provide installation instructions for that language. External libraries are permitted, with the same caveats that apply to languages.

Primes will be output by writing to stdout with a simple binary format, that has a little-endian byte order:

[8 bytes- index into the Fibonacci series]
[8 bytes- length of the Fibonacci prime, in bytes]
[? bytes- the Fibonacci prime, as a byte array]


Scoring

The programs will be run on an Intel(R) Core(TM) i5-8365U CPU with 8 threads, avx-2 support, and 24 Gigabytes of ram. The largest prime that can be correctly reached in one minute wins. Tiebreaker is the time taken to reach the largest value. Programs that tamper with my computer or the testing program will be disqualified. Programs that error or otherwise fail to produce the correct output will be judged based on the furthest Fibonacci prime reached before they failed.

The test program can be found here. Additionally, there is an example program here.

Meta

The test program is now completed and posted, but I still have a little documentation to write. I chose the output format to be simple, and so that answers wouldn't have to worry about formatting integers quickly. Is there anything I need to improve clarity-wise?

• Since there are only 34 (?+15) of them, how will you stop a program from hard-coding these, and then starting looking for larger ones from the last of them onwards? May 22 at 10:02
• @DominicvanEssen tweaked the question to use "calculate" instead of "list", which has worked for other challenges in the past. I also posted the controller. May 30 at 5:30
• How is the "error bound" of a "probable prime" defined? May 30 at 15:07
• @pxeger I hopefully clarified what I meant, by error bound I meant error probability. May 30 at 17:01

Play a Dumb Coin-flip Game

Write an interactive program (or function?) which allows the user to play The Coin-flip Game! The object of the game is to flip a coin and get the same result n times in a row.

Specific behavior of the program/function is as follows:

• At the start of the game, the user inputs a positive integer n>1
• The program should then "flip a coin", and show the result to the user. Results can be any two distinct outputs, e.g. 1 or 0, and must be chosen non deterministically such that each result has a nonzero chance of appearing.
• Next, the following loop occurs
1. Prompt the user to input whether they wish to continue trying or quit. If they choose to quit, exit the program and take no further input.
2. If they choose to continue, flip another coin.
3. If the coin-flip's result is the same as the previous n-1 flips and the total number of flips is >=n, print a congratulatory message (i.e. any message that is not one of the coinflip values) and exit, taking no more input.
4. If the result is different, return to step 1 of the loop.

This is , so shortest implementation in bytes wins.

Meta

Commenter noted that I should be more strict with output values / messages, but I wonder if it's more fun to give more freedom to be golfy, like with truthy/falsy values. Maybe letting the coinflip be anything is freedom enough, and the continue prompt / congratulatory message should be specific?

Leave your opinions in the below!

• You say "If the coinflip's result is the same as the previous n-1 flips..." What if this is the first flip? There wouldn't be any previous flips. I assume this would not print the congratulatory message, correct? May 31 at 16:34
• I suggest showing a sample output of the program and expecting everyone to match its structure precisely. Allowing people to choose any congratulatory message and prompt will lead to chaos. May 31 at 18:15
• @chunes and what is wrong with chaos? i'll consider your suggestion though :) May 31 at 18:20
• @thejonymyster I think it still has a problem. If n = 20 for example, there will still be undefined flips. I think you could fix it like this: 3. If the coin-flip's result is the same as the previous n-1 flips and total flips >= n, print a congratulatory message (i.e. any message that is not one of the coinflip values) and exit, taking no more input. May 31 at 21:44
• @00Her0 ah, in my mind that wasn't a contradiction, as a valid coinflip can not equal a nonexistent coinflip, so that didn't occur to me. It would be much clearer your way, so I'll make the change. thank you May 31 at 21:48
• @thejonymyster define "at random". is always "1" "at random"? Is 1% getting a "1" "at random"? Or does it have to be "uniformly random"? Jun 4 at 2:09
• @Nobody I've clarified in the post now, it only needs to be a nonzero chance of getting each result. Thank you Jun 4 at 2:14

lol is an ambigram, dad isn't

• I think you mean "rotated", not "reversed". Related, Related, but not a dupe of either. May 30 at 5:20
• I think using the word "palindrome" is misleading here. Palindrome is specifically for reversing right-to-left, not rotating. Also, please specify what kind of rotation is required (180 deg around the center of the word, isn't it?) and add some longer test-cases with various length. Please also specify what to do with empty string. Suggestion: make this decision-problem, not a "filter a list", because now it requires some needless boring boilerplate code. May 30 at 10:08
• I've edited this down to a stub now that it's been posted to save space Jun 4 at 2:50

How much more to a repdigit?

• These are more commonly referred to as repdigits Jun 4 at 17:55

Seeing the queen's lasers

In chess, the queen piece can see arbitrarily far in each cardinal and intercardinal direction. What does this mean? Well, I'll show you with an ASCII drawing:

\..|../
.\.|./.
..\|/..
---Q---
../|\..
./.|.\.
/..|..\


It means the queen (notated as Q) can see along these lines (notated as \, |, /, and -), and cannot see the other spaces (notated as .).

However, I've quickly lost interest in chess and am more fixated on the diagram itself;

How many different symbols can be seen in the 3x3 region around any symbol? I'll show you again:

2232322
2233322
3356533
2365632
3356533
2233322
2232322


Challenge:

Given the queen's position on an MxN board, output the number of unique symbols each square of the board can see in the 3x3 region around them. , so shortest wins :)

meta

test cases / slightly better spec to come :P is this at all interesting of a challenge?

• I'm confused by "8x8". Do you mean to say 3x3? because an 8x8 square grid doesn't have a central square so the 8x8 region around a square is not clear. Jun 14 at 17:51
• @WezloOvOo indeed i did mean to say 3x3, i was conflating "8 surrounding cells" with it. Thank you for catching that! fixed :) Jun 14 at 18:24

Enumerate all pure sets

• sequence IO? Jun 12 at 9:05
• @pxeger Good idea :P Jun 12 at 9:13

Interpret BigTalk

Talk is a language which takes a single bit of input and has four commands:

• 00 If the accumulator is 0, set the accumulator to 0.
• 01 If the accumulator is 0, set the accumulator to 1.
• 10 If the accumulator is 1, set the accumulator to 0.
• 11 If the accumulator is 1, set the accumulator to 1.

These can be interpreted as replacement commands. We're going to extend that concept to positive integers, and make the language more complicated.

The language we're going to be defining is called BigTalk. It has an accumulator, which is a list of positive integers, initially set to only the input.

Programs are a series of commands. Each command is a pair of lists of integers, like ([24, 2], [32, 1]), and means to replace the first as a sequence with the second, as many times as it occurs.

The program runs repeatedly until the accumulator does not change. Finally, the accumulator is output.

For example, with the input [5, 5, 5, 5] and the program ([5, 5], [3, 2, 1]), ([3], [5]), ([2, 1, 5], [5, 1, 2]), the list goes:

[5, 5, 5, 5]
[3, 2, 1, 3, 2, 1]
[5, 2, 1, 5, 2, 1]
[5, 5, 1, 2, 2, 1]
[3, 2, 1, 1, 2, 2, 1]
[5, 2, 1, 1, 2, 2, 1]


Your challenge is to interpret this language. You may take input and program in any reasonable format.

This is , shortest wins!

Testcases

In the format of input, commands.

[5, 5, 5, 5], ([5, 5], [3, 2, 1]), ([3], [5]), ([2, 1, 5], [5, 1, 2]) -> [5, 2, 1, 1, 2, 2, 1]
[4], ([4], [4, 4]) -> Infinite loop
[2, 19, 13], ([13, 19], [2]) -> [2, 19, 13]
[39, 1, 23], ([1], [39, 23]), ([39, 39], [1, 1]), ([23, 23], [1]) -> [39, 23, 39, 23, 39, 23]


This language may be Turing-complete, and I have a +50 bounty for someone who proves it either way.

How far from binary?

• Your description doesn't quite match your test cases. It should probably say that the absolute value of n-m is composed only of 1s and 0s. Since negative numbers have -.
– Wheat Wizard Mod
Jun 15 at 8:40
• @WheatWizard Why is it necessary? -101 is a signed binary. Jun 15 at 8:46
• -101 is not a binary string. It might be reasonable to interpret the intended way, but I certainly think it's more reasonable to interpret it another way. I don't see any harm in being explicit.
– Wheat Wizard Mod
Jun 15 at 8:48

Iterative Smallest Complement

• You forgot to include the input in the output of test case #2. Jun 21 at 10:51
• @chunes good eye, should be fixed. added some more test cases aswell Jun 21 at 11:51
• The last two test cases don't make sense to me. I thought the complement was supposed to include integers between the minimum and maximum of the input sequence. But there is a minimum of 1 that shows up out of nowhere for some reason. Jun 21 at 12:10
• @chunes oh, you're right. Misunderstood my own challenge :P fixed. Thank you for being observant Jun 21 at 12:31