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

# Geometry Dash Clone in a weird Way?

Try to make a functional clone of Geometry Dash in the shortest time.

## How GD Works.

• You have a cube. In the clone, it can be as small as you want, but no bigger than 2x2.
• You have to jump over spikes. The key to do this is (preferably) the up arrow key, but can be any option you want (simply tell me in your answer what key is it.
• If you touch the spikes, the screen says "Game Over." and exits in 3 seconds.
• There are blocks! You can jump on them, but touching them from the left side results in the same thing that happens if you touch the spikes.
• A song plays in the background. How you do this is up to you.

## Rules:

1. 3 Extra points for working forwards and backwards.
2. Must have the letter a 5-7 times and no q at all!
3. Allows ascii art type output and text input (standard input)!

## Sandbox Questions

How is this even going to work?

• Welcome to codegolf! I don’t really recommand to compare how fast submit time after question release, since there maybe someone out there already holding an answer, and it also really timezone dependent.
– okie
Dec 2, 2021 at 5:41
• But it could be one of the code-golf problem, and allowing ascii art type output and text input (standard input) could allow more language to compete.
– okie
Dec 2, 2021 at 5:42
• also the flawless limit is kinda weird, extra point for certain language is not suggested, if you still want to give extra point, you may want to say how much extra point is.
– okie
Dec 2, 2021 at 5:48

# Get Floor of N ^ (3 / 2)

Get The Floor of N ^ (3 / 2)

OEIS

This is Code Golf so the winner wins

## Test Cases

0 => 0
1 => 1
2 => 2
3 => 5
4 => 8
5 => 11
10 => 31
13 => 46
27 => 140
33 => 189
49 => 343
68 => 560
89 => 839
98 => 970
100 => 1000
136 => 1586
256 => 4096
500 => 11180
147385 => 56582212


# Meta

• Any feedback?

# Who Loses The number guessing game?

You are playing a number guessing game. You know everyone's guesses, and who won, and want to figure out who was in last place.

Your task is to take a dictionary of guesses as input, along with the name of the winner. You should then return the name of the player whose guess was the farthest from the winner's, or if there are multiple, the lowest.

A input:

[{"Joe": 800, "Mama": 1000, "Biden": 1200}, "Joe"]


Means that the aproxximate score winner is Joe, The next is Mama, Mama is greater than Joe and Mama is greater than Biden.

So the loser is Biden.

All guesses are guaranteed to be unique

## Test cases

[{"A": 100, "B": 200, "C": 300}, "A"] => "C"
[{"Hello": 200, "World": 201}, "World"] => "Hello"
[{"Blah": 210, "Bruh": 984, "Boo": 314}, "Boo"] => "Bruh"
[{"A": 6, "B": 7, "C": 666, "D": 1000}, "C"] => "A"
[{"AC": 100, "BE": 200, "CE": 300}, "B"] => "CE"


# Meta

• Any feedback?

• Dupe?

• What's the point of having this weird input format? Why not just take and return indices? Jan 23 at 10:36

# Convert decimal to unary in fewest regex codes code-challengeregular-expression

Your task is to Convert decimal to undary in fewest regex codes

Every regex code is substitution mode.

The regex code counts the regex code, without test string and Substitution code

A example

^2, |11
^3, |111
^4, |1111
...
\|, <empty>


This scores infinity, But don't try this.

## Rules

• Your score is always non-infinity

• Any flavor is allowed.

• Your score is the number of regex codes

• every length of regex code is non-infinite

# Meta

• Any feedback?
• Can you add an explanation of what exactly a "regex code" is? Jan 23 at 17:30

# Nth Eights Challenge

## Inputs:

There are 2 inputs: The amount of eights to be used in the calculation, and the number to solve for.

## What to solve:

The program needs to insert operators in between each eight, so when the newly created equation is calculated, the answer is the number that was trying to be solved for. When the equation is calculated, there is no operator priority.

## Rules:

The only operators allowed are:

+
-
*
/
(And parentheses)


You may insert multiple operators between each number. No extra numbers are allowed. There must be an operator inserted in between each 8. The answer must be displayed when the program finishes.

## Examples:

#User inputs
Amount of eights: 4
Solve for: 15

8+8-8/8

#User inputs
Amount of eights: 4
Solve for: 10

(8+8)/8+8


## Winning Criteria:

The winning criteria is for the program written in the least amount of characters.

• 0. What is winning criteria for this question? Code-golf or fastest code? 1. What operators are allowed? May I insert multiple operators between two 8s or may concatenation two 8s without any operator? 2. Is operator priority considered? 3. How fast should it be? Define by time usage on specified (batch of) testcases? Or defined by algorithm time complexity? 4. Language specified challenges are generally unwelcome on this site.
– tsh
Jan 27 at 8:56
• Jan 29 at 1:35
• Do you mean "characters" or "bytes"? Jan 31 at 12:46

# Get the Nth line

## Challenge

Let's have a file f and a number n. Your task is to get the nth line from the file.

## Constrains

• file f exists and has at least n lines
• you can index lines from 0 or 1, whichever you prefer

## Example

• input: n = 2 (indexing from 1) and content of file f is:
foo
bar
baz

• output: bar

## Rules

• this is code-golf challenge, so the shortest code wins
• standard rules apply for your answer with default I/O rules, so you are allowed to use stdin/stdout, functions/method with the proper parameters and return-type, full programs
• default Loopholes are forbidden.
• I thought the entire point of this sandbox was to get feedback. Down-votes without any comment is the complete opposite. Feb 18 at 15:28
• I think the downvotes here are just because it's not a very interesting challenge. There are no comments because there's nothing actually wrong with your post, so no feedback to really give, but people just don't think it's interesting for code-golf. You could post it and I don't think it would get closed or anything, but it wouldn't get many upvotes. Thank you for using the sandbox nonetheless. Feb 19 at 9:35

# Knight mover

Your task is to move a chess knight between the points B and E.

A chess knight moves in an L shaped pattern, like so:

.X.X.
X...X
..B..
X...X
.X.X.


The Xs mark where the knight in position B can move.

There may be other chess pieces on the board, blocking the knight's movement, but for clarity, you will only be notified of where you cannot go by # characters. You cannot land on these marked spaces, but you can go over them. You also cannot go outside of the board.

Your goal is to find how many turns N are needed to go from B to E, or return -1 if it can't be done.

## Input & Output

• You are given 2 integers W and H giving the width and height of the board
• For the next H lines, you are given a row of the board, containing the characters B, E, . and #
• You are allowed to take in the input as a WxH board as a list of strings or a character matrix

## Test case

3 2
..E
B..
->
1

5 5
B...E
..#..
.....
.....
.....
->
4

7 5
B..###.
####.##
...###E
..#.#.#
.#..#..
->
4

8 8
....#...
....##..
..E..#..
#...##..
.###....
........
........
.....B..
->
6


This is code-golf, so shortest code wins!

Credits to this puzzle

# Game of GO

Go is an abstract strategy board game for two players, in which the aim is to surround more territory than the opponent.

Given a board (where some stones are already added) and a list of moves to be executed next, check whether the moves are valid and (if they are valid) execute them.

After executing all moves in the list the expected output is either not valid if at least one of the moves is invalid, or the new state of the board after all moves were executed.

Rules of Go:

• Two players place stones of their color (by turns)
• If a stone is completely surrounded by stones of the other player (or by the edge of the field) this stone is beaten and is removed from the board
• If stones of the same color are placed next to each other they build a group
• If the group is completely surrounded by stones of the other player (or by the edge of the fields) this group is beaten and all of its stones are removed from the board
• A stone can be placed on every free field on the board except for:

A position in which it would be completely surrounded by the stones of the other player (no suicidal moves allowed). Except this move beats some other stones which leads to it not being surrounded anymore

A position that would create the same board that was there before the other player made his move (to prevent an infinite loop of killing stones) which is named KO-rule (see a test case for an example)

• Points (which are not important for this puzzle) are made by empty fields that are surrounded by the stones of a player or by enemy stones that are beaten

For a more detailed description please visit here

## Input & Output

• You are first given an integer S for the size of the field (the field is a square of S×S)
• You are then given an integer M for the number of moves that are to be made on the board
• You are then given a line of the board where . is an empty field, B is a field with a black stone and W is a field with a white stone on it (each line contains S characters) for the next S lines
• You are then given a move that is described by the player color, and the position (separated by a space character)
• Output the expected output, else output any character you want
• You are allowed to output the board as a matrix/list
• You may assume the initial board state in the input is always valid
• You are allowed to take in the input as a list/array of lines and moves

## Testcases

5
5
.....
.....
.....
.....
.....
B 2 2
W 2 3
B 3 2
W 3 4
B 4 3
->
.....
.....
..BW.
..B.W
...B.

5
7
BB...
B....
.....
...W.
.....
B 3 2
W 0 2
B 3 4
W 2 0
B 2 3
W 1 1
B 4 3
->
..W..
.W...
W..B.
..B.B
...B.

5
1
.....
.....
..B..
.....
.....
B 2 2
->
0

5
5
.BW..
BW...
.W...
.....
.....
B 3 4
W 4 4
B 3 3
W 2 0
B 0 0
->
0

5
3
..B..
.B.B.
.WBW.
.BW..
.....
B 3 3
W 1 2
B 2 2
->
0

5
7
.B...
BW...
WB..W
...W.
...BW
B 3 4
W 0 2
B 0 3
W 0 0
B 1 2
W 0 1
B 1 0
->
...B.
B.B..
WB..W
...WB
...B.


This is code-golf, so shortest code wins!

Credits to this puzzle

# Beaker drawing

Your task is to output the following beaker with the volume n:

_
%      %
%       %
%       %
%       %
%       %
%%%%%%%%%


You are the fill n spaces of the beaker above, so n=5 looks like this

_
%      %
%       %
%       %
%       %
%-----  %
%%%%%%%%%


Even though this defies the law of physics, you are to output the beaker with the liquid of n volume. The volume of the beaker is 35. The first 4 layers have a volume of 7 and the top has a layer of 6, and the _ represents an additional volume of 1 if the beaker overspills.

## Test cases

34
->
_
%------%
%-------%
%-------%
%-------%
%-------%
%%%%%%%%%

35
->
-
%------%
%-------%
%-------%
%-------%
%-------%
%%%%%%%%%
(Note the _ becomes a -)

15
->
_
%      %
%       %
%-      %
%-------%
%-------%
%%%%%%%%%


You may assume n is positive (can be 0)

You may assume the beaker can overspill

You may perform the "flood fill" from left to right bottom to top or right to left bottom to top.

This is code-golf, so shortest code wins!

# Challenge

Your challenge is simple: play an audio file at a given path. Your program will take the file path as input and will play it once and quit.

To make this harder, however, you are not allowed to use external libraries, but modules that are part of your language's standard library (such as ctypes below) are allowed.

# Rules

• Standard loopholes are forbidden.
• You may assume (a) specific operating system(s) and/or (a) specific file format(s).
• You may assume an absolute path.
• You do not have to hear the sound every time; you are not expected to unmute muted speakers, and you can play through whichever audio device is the most convenient. However, it must be possible to hear it every time you run it with certain settings. A window such as Control Panel -> Sound -> Playback on Windows must always be able to "show" the sound being played under at least one audio device. You are allowed to play the file under a different device each run.
• Your program must be able to play at least one of the audio file formats listed on Wikipedia. Other formats are allowed, as long as one of the formats listed there is supported.
• Outputting any content to any stream, file, etc. is allowed, but the sound must be played.
• Please explain your answer. This is not necessary, but it makes it easier for others to understand.
• Languages newer than the question are allowed. This means you could create your own language where it would be trivial to do this, but don't expect any upvotes.
• This is , so shortest code in bytes wins!

# Reference implementaion (ungolfed, Python 3, Windows only, .wav only)

# -*- coding: utf_8 -*-

from ctypes import windll

winmm = windll.winmm
audio_file = input('Audio file path: ').encode('utf_8')

winmm.PlaySound(audio_file, 0, 131072)


# Golfed reference implementation

import ctypes;ctypes.windll.winmm.PlaySoundW(input(),0,131072)

• "To make this harder, however, you are not allowed to use external libraries."...and then you use a library in the reference implementation? Feb 25 at 19:29
• Does "external libraries" mean libraries not coming with the standard library of the language of choice, or all libraries for that language? Feb 25 at 19:34
• I said external libraries, not libraries in general. ctypes is built-in, so it's not an external library. Feb 25 at 19:35
• @Makonede But winmm is not built-in. Feb 26 at 0:51
• @wizzwizz4 It is in Windows. Feb 26 at 1:20
• @Makonede “External libraries” is unclear, then. External to what? Can I make raw calls to the hardware interface, and say that those particular drivers are part of my operating system and so not external? etc, etc.. We already have rules and conventions about all of this; trying to forbid “external libraries” won't make it more fun. Feb 26 at 1:28

# Visualize tag progress

Task is pretty simple. Given non-negative positive integers 0 ≤ s ≤ 1000 and 0 ≤ a ≤ 200, your code should draw following progress bars.

## Examples

When s ≤ 100 or a ≤ 20:

Input:15 12
Output:
15/100 score
++++++------------------------------------
+++++++++++++++++++++++++-----------------

Input:3 1
Output:
3/100 score
+-----------------------------------------
------------------------------------------

Input:85 35
Output:
85/100 score
+++++++++++++++++++++++++++++++++++-------
++++++++++++++++++++++++++++++++++++++++++


When (s > 100 and a > 20) and (s ≤ 400 or a ≤ 80):

Input:156 43
Output:
156/400 score
++++++++++++++++--------------------------
++++++++++++++++++++++--------------------

Input:666 66
Output:
666/400 score
++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++--------


When (s > 400 and a > 80) and (s ≤ 1000 and a ≤ 200):

Input:999 85
Output:
999/1000 score
+++++++++++++++++++++++++++++++++++++++++-
+++++++++++++++++-------------------------

Input:666 194
Output:
666/1000 score
+++++++++++++++++++++++++++---------------
++++++++++++++++++++++++++++++++++++++++--


The number of +'s in each bar is equal to the value of a or s divided by its max value (max values for s are 100, 400, 1000 and for a are 20, 80, 100, the choice of max values ​​depends on the ranges in which the values ​​of a and s fall.), multiplied by 42 and rounded down. This number cannot be more than 42.
The number of -'s is equal to 42 minus the number of +'s.

End etc. Trailing spaces are allowed. Additional newlines are not allowed.

This is a code-golf challenge so the shortest solution wins.

## Meta

I realized that I myself got confused in my task :) ... so this task will be in completion until this text is deleted.

• "progress bars are built according to the same rules" - what are those rules? Please describe them, so that we don't need to infer them from examples. Mar 2 at 7:14
• Why should we have to "output nothing" when s>1000 and a>100? The challenge would, in my opinion, be much better if we were allowed to assume that s<=1000 and a<=100. Mar 2 at 9:12
• Please, describe the rules governing drawing the bars. Also, "s = 666 and a = 66" appears twice with two different outputs. Mar 3 at 7:32

Your task is to create an approximation for sin(x) in the fewest characters possible.

• Given the approximation s(x), it must satisfy 0.95 * sin(x) <= s(x) <= 1.05 * sin(x)

The entry with the fewest characters wins.

• Most languages already have a built-in for the sine function, so I think this would not be an interesting challenge at all. Also, FYI, code-golf challenges (if that is what you are going for) usually score submissions by byte count, not character count. Mar 15 at 23:01

## Draw the Swedish coat of arms

Or rather, assemble it. A coat of arms is specified not my its physical representation on Wikipedia or any other source, but by its blazon: a formal, pseudo-French listing of its components and their position. I'll explain the blazon, and it is your job to draw it out and display it.

Different from many questions on this site; accessing the internet is allowed. You can load files from websites under certain conditions, and only for charges. The reasoning is that, when the blazon specifies that this shield has a yellow lion, any yellow lion is in fact equally fine. That's how it worked historically, and that's how it will work for this challenge.

Blazon English
A shield azure You start with a shield, coloured fully in blue. My only requirements for "shield" is that it is a square or rectangle, with the top two corners being sharp, the bottom two corners being rounded, and in the middle of the bottom there's a marked point.
quartered by a cross Or with outbent arms, A cross divides this shield in four sections. The cross should be yellow or gold, and the arms should get wider as you get farther from the center. Those arms should reach the edges of the shield but not visibly exceed it.
an inescutcheon containing the dynastic arms of the Royal House. A smaller shield goes on top of it all. We'll get to that.
In the first and fourth fields three open crowns Or, placed two above one. The top-left and bottom-right quarters of the large shield contain three identical yellow/golden open crowns (a crown leaving the top of the head bare, with no hoops or cap); placed so that two of them are side by side above the third, which is horizontally centered between the two.
In the second and third fields In the top-right and bottom left quarters...
three sinisterbendwise streams argent, The background should contain three parallel wavy lines that go from top-right to bottom left; they should be white/silver/grey. The lines should be roughly evenly arranged, i.e. not on top of each other.
a lion crowned with an open crown Or armed gules. Atop that background goes a yellow/golden lion, wearing a yellow/golden open crown, and the lion should have red nails.
The inescutcheon Now we get to the smaller shield on top of it all...
is party per pale Divided horizontally in two
the arms for the House of Vasa In the left half you have:
(Bendwise azure, argent and gules A background diagonally (top-left to bottom-right) divided in three sections, top-to-bottom blue, white/silver/grey, red;
a vasa Or); atop that is a yellow/golden vasa which is a sheaf of bundled straw.
and the House of Bernadotte In the right half, you have:
(Azure, Blue background;
issuant from a wavy base a bridge with three arches and two towers embattled argent, The bottom part should be "wavy", e.g. resemble a water surface (with no specifications for colour). From the water (or from behind the water) there's a white/grey/silver bridge that must have three arches, two towers, and crenellations.
in honor point Above that bridge:
an eagle regardant with wings inverted resting on thunderbolts Or, A heraldic eagle looking to the objective left, to the eagle's right. The wings should be pointed down. Below its feet should be some depiction of thunderbolts. All of this in gold/yellow.
and in chief the Big Dipper constellation of the same). Above the eagle, the eight stars of Big Dipper constellation, also gold/yellow.

As said you can load up charges from external sources. Charges are objects that sit atop the background, like eagles, stars, crosses. Loading them follows some rules:

• You cannot load multiple charges at once; so the thunderbolts, eagle, and Big Dipper should all be separate objects (you can however load the eight stars of Big Dipper as one object; and you don't have to load up the lion's red nails separately from the lion).
• Any added images can be whatever format you want; jpg, svg, animated gifs...
• Charges having a transparent background is encouraged but not required; what is required is that every element be clearly identifiable, including background colours/patterns.
• Files can be loaded from any website not hosted by yourself (or by your friend for that matter).
• Using url shorteners is not allowed.

Of course drawing them yourself is also allowed. There's no requirement for using any specific exact colours either; as long as the colours you use are recognisable under the English names I gave. Finally, charges should not bleed out of their shields/quarters or overlap one another where not specified. As in the example, the small shield is allowed to overlap the background elements slightly.

Output should be at least 400 pixels wide.

### Sandbox

I am unsure what scoring criterion to use. is my go-to but I want to reward shields that look recognisable, specifically that are creative. Would work?

• Downvoters, I would really appreciate if you could give me some indication as to what is wrong with what I wrote. Apr 29 at 8:11
• If you make this into a challenge such as [code-golf], the coat of arms is far too complex to yield any interesting answers - most answers will simply be a very long list of instructions to draw it. You could make it a popularity contest, but "do this thing but creatively" generally don't produce good pop-cons, as the first person to just faithfully reproduce the coat of arms is likely to win Apr 30 at 15:35

# Longest Possible Pythagorean Triple Triangle

A Pythagorean triple is a set of 3 integers $$\\{a, b, c\}\$$ where $$\a^2 + b^2 = c^2\$$. Your task is to, given an integer $$\n\$$ where $$\3 ≤ n ≤ 15\$$, output a Pythagorean triple using these rules:

• If $$\n\$$ is odd, output $$\\{n, \frac{n^2-1}{2}, \frac{n^2+1}{2}\}\$$.
• If $$\n\$$ is even, output $$\\{n, \frac{n^2}{4}-1, \frac{n^2}{4}+1\}\$$.

With these rules, the difference between the lengths of the longest leg and the hypotenuse is minimized.

## Test cases

Input | Output
------+-------
3     | 3 4 5
4     | 4 3 5
5     | 5 12 13
6     | 6 8 10
7     | 7 24 25
8     | 8 15 17
9     | 9 40 41
10    | 10 24 26
11    | 11 60 61
12    | 12 35 37
13    | 13 84 85
14    | 14 48 50
15    | 15 112 113


See A055523 and A055524.

# Repeat Hello World according to another string's length

• I think arbitrarily overriding the scoring defaults is not very well received... Jul 25 at 18:14
• Which part? The "This is code-golf, so shortest answer wins!"? I've seen it in many questions, so I thought I would have to add it here. Is there a problem with it, or were you talking about something else in the question? Jul 26 at 5:37
• "Please write how many bytes it is in UTF-8". A lot of languages have ther own scoring systems Jul 26 at 14:57
• So what you are suggesting is to remove the UTF-8 option? Jul 29 at 9:53
• Alright then. I've added it. Jul 29 at 9:56

# Output the number of lines of your code

Your task is to write a program that counts the number of its lines of code and outputs them.

Specs:

• The number mustn't be hardcoded into the program, nor in any other external resource;

• Internet access is forbidden;

• Your program's output must be the number of lines only;

• Your program should not use any tool, macro, function, or similar device designed with the specific purpose of counting lines.

• I don't see much of a challenge here. wc -l \$0? Feb 23, 2014 at 17:15
• It can be a nice question, but needs some work. Just add something like "it should not use any tool, macro, function, or similar device designed with the specific purpose of counting lines". Feb 24, 2014 at 2:10
• @Victor Nice point, added. Thank you :) Feb 24, 2014 at 10:10
• As long as you can read the program file, it's no challenge. E.g. print len(l for l in sys.argv[0]). But if you forbid reading the source, and forbid hard-coding the length, what's left? Feb 24, 2014 at 14:00
• @ugoren I don't see where it says it can't read its source.
– user10766
Feb 27, 2014 at 22:13
• @user2509848, It doesn't. This is why the question is easy and uninteresting. Feb 28, 2014 at 5:56
• @ugoren If you can't though, how will you tell, hardcode it?
– user10766
Feb 28, 2014 at 5:57
• @user2509848, Either way, not a good question. Feb 28, 2014 at 6:25
• This is one byte in any golfing language with implicit output: 1
– Nic
May 9, 2016 at 20:11

Here is my first attempt at a cops and robbers post (which is why I'm using the sandbox).

# Cops - Golfed recursion

You must select a language that satisfies the following criteria:

• Functions - It must be possible to create a function with any number of integer input values and a single integer output (or return) value. The function may also be a complete program in itself. (Your language may not call it a function, but that is ok)
• Arithmetic operations - The integer operations +-*/% should all be possible, either in a simple or a complicated manner.
• Data - You should be able to store one-byte or two-byte long integers (either signed or unsigned will do). You may do this also in an indirect manner.
• Iteration - You must be able to create a loop that will keep running until a condition is satisfied. Therefore < > = <= >= ! & | should also be supported, either directly or indirectly.
• Recursion - You should be able to call a function from within the function itself with a set of input values calculated by the main function.
• Declaration - You should be able to declare new integer variables as needed from within the function.

You need to create a recursive function. Code will be scored by the number of characters in it, the shorter the better. A solved code cannot win the challenge. A post with less than 5 up-votes cannot win the challenge. There will be no overall winner, but a separate winner for each language.

# Robbers - Golfed recursion

Your objective is to pick up a cop's post, and write a function in the same language but it should not use any recursion (can use iteration). The function may create any number of variables, loops, etc. but should be able to achieve the exact same end result (atleast, in theory) as the cop's one.

Your score will be the same as the cop's post's score at the time it was solved. His/her post is now invalid, and you get his/her score

• I don't understand how a cop can write an answer that isn't going to be cracked, unless the language of choice can only loop via recursion (which I think you're trying to rule out by requiring that "iteration" must be possible). Also, requiring 5 votes to be a winner is only encouraging tactical voting. Answers that are actually invalid will likely get downvoted and deleted anyway. Feb 10, 2016 at 12:36
• @MartinBüttner Maybe in some languages it is possible by exploiting both closure and recursion, but I mainly agree with your point: recursion and iteration are two ways to do the same thing. Feb 10, 2016 at 12:41

Your task is to create a program that outputs a random pizza recipe following this one rule:

No random number choosers, you may have random text choosers. All standard code-golf rules apply. A sample output:

A simple PEPPARONI pizza sprinkled with fish and sausages. Your program must have the following items:

• Anchovies
• Fish
• An adjective for the pizza

The program written with the shortest code wins.

# Winner

The winner shall be picked on April 3rd, 12AM on the time zone GMT+3.

• I already had an answer to the question, albeit non-competing: Python3 print("Have a plain MARGHERITA without any",["fish.","anchovies."][len(input("What's your favourite pizza? "))%2]) Mar 31, 2016 at 12:41
• Uh, this has a lot of problems with clarity. First, all "random text choosers" are implemented with "random number choosers" which makes this restriction feel a bit bizarre. Second, what counts as an adjective for pizza? And since this is code golf, people will always pick the shortest available. And third, what should an output look like? It's not clear from the spec. Also, sort of unrelated, but usually putting a time limit is unnecessary, even extremely popular challenges stop getting responses with any frequency after a month or so. Mar 31, 2016 at 12:59
• Did you misspell it on purpose? Mar 31, 2016 at 13:55

What about one question on numeric solve?

Write one function that gets as one argument one function f(x), and one interval a..b and return the list of all element v such f(v)=0 in the interval a..b. In the interval a..b the f must be definite and can not be f(r) = +oo for r in a..b.

Win the one write the function with biggest set of right results. If two have the same set, win the one has less characters. You can not use solve() or nsolve() or fsolve() or one already written function that your sys offer that finds numerical x in f(x)=0

• Finding all zeros of an arbitrary function is impossible unless the domain is restricted.
– user45941
Nov 29, 2016 at 8:59
• Ok you are right
– user58988
Nov 30, 2016 at 10:04
• The edit doesn't do anything to fix the problem. Nov 30, 2016 at 14:48
• The bigger problem is that this post is incomprehensible.
– user45941
Dec 2, 2016 at 8:54

# Beep. Boop. Maggot? code-golf

1. Read input from STDIN until enter is pressed.
2. If the input is "Beep", continue.
3. Otherwise, print "Wrong!" and exit.
4. Repeat steps one to three with "Boop" instead.
5. Execute step one.
6. If the input is "Maggot", output "Done".
• Otherwise, output "Wrong.".

Remove punctuation (?.!'"), ignore capitalization (a-zA-Z only), and strip whitespace (\t and )

Notes: You must print the text word-for-word, character-for-character. Step 3 is Wrong!, while Step 6 is Wrong.

## Hints

• Notice how boop is just beep with the o's turned into e's.
• There is lots of repetition here, but with many caveats.
• Technically speaking, step 4 should repeat steps 1-3, shouldn't it? Anyway, apart from that, I don't see anything technically wrong with the challenge, but I'm not sure it's a very good challenge.
– user62131
Jan 1, 2017 at 0:07

I believe that each language has a score. The way you find the score of a language is shown in the ungolfed Python program below

def scorer(lang):

num = 0

for i in str(lang):
num += ord(i)

return num


Basically the score is the total of the unicode values of the language name.

Now this seemed like a fairly trivial challange, so I thought I'd make it a bit more difficult. You aren't allowed to use your language name (case-sensitive) in the code. So this code in C++ would be invalid as I've used C++ in the code.

#include <iostream>

int main() {

int total = 0;
std::string s("C++");

for (char & c : s) {
total = total + (int)c;
c = '*';
}

std::cout << total;

}


Although this does output the required number (153) it is still invalid.

# Rules

• You aren't allowed to use the language name but are allowed to use it in a different case. E.g. Java isn't allowed but java is.
• This is a code-golf so shortest answer in bytes wins
• You are allowed to use hex/octal codes in strings e.g \150 can be used instead of h
• Your program must take no input or function arguments
• You cannot simply output the score. Theoretically the program should work for any language name when changed.
• Languages where the only valid syntax is the name, such as Chicken are allowed to use said name.
• Version shouldn't be included so Python is always Python not Python 2 or 3
• The score is the value of the case-sensitive name

# Correct Scores

Language              Score

ArnoldC                675
brainfuck              949
C                       67
C++                    153
Java                   386
Lua                    290
Mornington Crescent   1922
Python                 642
TrumpScript           1165
Vim                    300


## Sandbox Questions

1) Why has this been downvoted?

2) I am thinking about putting a reputation limitation so that bosses like Dennis and Martin Büttner can't take answers from people who aren't as accomplished. Is this unfair? Should I not?

3) Is this a duplicate? I couldn't believe it wasn't already taken.

• Terms like "you cannot use your language name" and "it must be calculated by the program" are not only unclear but will likely not be able to be made rigorous.
– Wheat Wizard Mod
Feb 5, 2017 at 14:58
• Are you suggesting that I remove those rules?
– user63571
Feb 5, 2017 at 15:00
• I don't think that the challenge is very interesting without the rules, but I don't think it is clear with them. I would suggest reworking the rules in some manner but exactly how I do not know.
– Wheat Wizard Mod
Feb 5, 2017 at 15:01
• 1. I would guess that it's mainly because it fails some of the tests in Things to avoid when writing challenges (X without Y, asking for different things in different languages, unnecessary fluff, explicitly disadvantaging certain languages, arguably one or two more), although it might also in part be because some people oppose trivial "challenges", and in part because the problems WW mentioned can't be fixed. 2. Very bad idea. 3. It's a multi-dupe: it combines two trivial tasks, each of which independently would clearly be a duplicate. Feb 6, 2017 at 9:15

# Goal

Write a program or function in a language of your choice that takes input and outputs that exact input.

# Specifications

• Your program/function should output the exact input in any reasonable way.
• Your program does not have to end after printing the input. It may end up in an infinite loop if you wish, as long as that loop doesn't output any extraneous characters.

# Winner

The winning answer will be the one that has the highest score. Voters should look for answers that use an unique way to print the input, have a special source code or use neat language features.

• Plain "do X in a creative way" popularity contests have fallen out of favour and will likely immediately get closed as being too broad or not having an objective winning criterion. Apr 4, 2017 at 18:33
• @MartinEnder: Yeah, I noticed. How do you think I should change the challenge so that it won't be closed?
– Luke
Apr 4, 2017 at 18:35
• Can't really help you there. If I knew of a good way to make popularity contests work, I'd write some myself. ;) Apr 4, 2017 at 18:39
• Probably a duplicate of codegolf.stackexchange.com/q/62230/34718 Apr 4, 2017 at 18:43
• @mbomb007: No, this is not a code-golf challenge.
– Luke
Apr 4, 2017 at 18:54

This is Code-Golf, Shortest answer wins.

Standard loopholes are forbidden.

• you can't say that answer doing something "would be good" if the shortest answer wins Apr 18, 2017 at 7:05
• underhanded challenges are off-topic. Apr 18, 2017 at 8:36
• It's not underhanded. Apr 18, 2017 at 14:15
• I'm sure this might be a dupe of an obfuscation challenge Apr 18, 2017 at 23:36

Of numbers of letters

there is something special the number 4. When spelled in English the word 'four' uses exactly 4 letters. I wonder whether there are further such numbers Your task is to identify whether there exist further such numbers and output them in any human readable format. To make this more of a challenge you can do the task in any regional Language of your choice (Say Russian or Portuguese or Spanish or Mandarin or Hindi etc.).

The Best entry will be selected by the most number of such numbers regardless of language used

Best of Luck

## No strings code bowling

I created this challenege idea with @redwolfprograms. In the challenge, you would create the longest program possible (code-bowling) it can do anything, but it cannot:

• Contain any strings, or quotation marks/apostrophes/backticks
• Contain the same alphanumeric byte more than twice
• Conatin the same non alphanumeric byte more than three times
• What is the task we have to solve? Is it really alphanumeric character but non alphanumeric byte? Apr 17, 2018 at 13:50
• Why do you mix characters and bytes? Apr 17, 2018 at 14:01
• I feel like there are a lot of languages that would score the maximum (768) by not (strictly speaking) having alphanumeric characters, and then just wrapping everything in a string: "[3x each other byte value]"". Apr 17, 2018 at 14:08
• I think you got bytes and characters mixed up. Both should be bytes, and make sure you specify the program can do anything. Apr 17, 2018 at 14:26
• People, the point of the sandbox is to add suggestions. This question has been downvoted several times. Why? Apr 17, 2018 at 22:39
• @RedwolfPrograms downvotes are a way for people to say that this challenge in the current state shouldn't be posted to main. If the challenge gets changed enough to make it viable and interesting the downvotes will be reverted (or upvotes from other people will outweigh them).
– Leo
Apr 18, 2018 at 1:32
• Maybe this challenge should have a "No strings" rule? Apr 18, 2018 at 1:59
• Not being able to use e is not really that much of a big deal. Even in C you can get around it easily. (It would prevent you from returning values from functions, but you could just use pass by reference instead.) So that restriction wouldn't really add much to the challenge. Apr 18, 2018 at 8:35
• Now that strings are forbidden, one could just create a huge variable whose name is all the alphanumeric characters twice. This is the bane of any longes code that... challenge. Consider adding some more interesting restrictions. Apr 18, 2018 at 14:35

[Posted, but reference kept]

Given a function with boolean inputs a1, ..., an and a boolean output, output an array of numbers 0 to n satisfying:

For each item in the truth value, if (from the array you output, we repeatedly remove two adjacent numbers x and y satisfying that, for each integer n between x+0.5 and y+0.5, an=1), we can get an empty result array iff the given function's output is 1. You can assume the result exist.

Sample input:

a[1] a[2] result
0    0    0
0    1    0
1    0    0
1    1    1


Sample output: 0 2

Sample input:

a[1] a[2] result
0    0    0
0    1    1
1    0    1
1    1    1


Sample output: 0 1 2 0 1 2

Sample input:

a[1] a[2] result
0    0    1
0    1    1
1    0    1
1    1    1


Sample output: (empty)

shortest code win, but optimizing running time and result length is encouraged(I won't accept but I may upvote)

• The spec makes absolutely no sense to me. What does it mean to remove a number from a truth table? Apr 25, 2018 at 12:13
• Still makes no sense. Maybe if you give a detailed worked example I would be able to reverse engineer the spec and propose some changes to the wording. Apr 25, 2018 at 14:59

Write a function that takes compares each pair of adjacent items and swaps them if they are in the wrong order. The pass through the list is repeated until no swaps are needed, which indicates that the list is sorted.

Static visualization of bubble sort and a gif explanation.

The steps go from left to right. At each stage, an exchange is made. The darkest color has the most value and finds its final place (bottom) first.

## The rules

• The function must take a list of integers that shall be sorted (less than 20 elements)

• The function must print each step of the sort.

• Yes, built-in Bubble sort algorithms are permitted.

• No, you can not assume only positive integers or unique integers.

• It's so the shortest code wins!

## Test cases

input list
5 4 3 1 2
1 2 3 5 4
11 4 2 1 5


## Optional

Add an interpreter so the submission can be tested. It is allowed to write this interpreter yourself for a previously unimplemented language.

Note

It's my first code-golf idea I'm fully open to improving it with more experienced users if I missed something.

This is not a duplicate of Bubble sorting in progress.

Thanks to @Erik the Outgolfer for encouraging me to post my idea in the sandbox.

• Can you add one walked-through example? I.e. show each pass.
Jun 20, 2018 at 13:04
• You note it isn't a duplicate of the in-progress bubble sort, but what distinguishes it from Golf me a bubble sort, which was closed as a dupe of that? Jun 20, 2018 at 13:10
• @Geobits This was not a dup but unclear. Jun 20, 2018 at 13:12
• Here's my c# non-golfed solution : dotnetfiddle.net/ZFkl5y Jun 20, 2018 at 14:01
• You claim it's not a duplicate of codegolf.stackexchange.com/q/92753 but you don't adduce any argument to support that claim, and I can't see any significant difference. (The upper limit is a trivial difference IMO). Jun 21, 2018 at 6:14

Once, I thought of this. Rules:

1: You must make a fractal that looks like the specified thing.

2: One thing per round.

3: Algorithms are rated by two scores: Resemblance and Compactness. The one that gets the highest scores wins!

4: Only I can tell what thing must be made.

5: Only one entry per user. Do not plagiarize.

6: One may code in anything they wish.

7: Have fun!

• Erchh! OK OK Remove the PM stufs. didnt know Jul 31, 2018 at 0:12
• On this site, winning criteria has to be objectively defined. (by tradition, I have to admit... there is popularity-contest (read the tag info page for more details), but if you really want to make a pop-con, be careful) "Resemblance" is quite... subjective, unless you can define an objective formula. Also, what is a fractal exactly? Jul 31, 2018 at 4:05
• For example, how many points would I score if I just made the initial fractal look like the image and have it spiral inwards? What is the objective formula of Compactness/Resemblance
– Jo King Mod
Jul 31, 2018 at 6:04
• A fractal is a shape that recurses. It has copies of itself in it. Analyze the Mandelbrot set, you'll see mandelbrots in mandelbrots. What is a pop-con? Sounds like a soda convention. I'd love to go there! JK Jul 31, 2018 at 14:32
• @user202729, experts are unable to agree on the definition of a fractal. That aside, this looks more like a forum game than a good fit for this site. Jul 31, 2018 at 14:46
• Oh, popularity? No. No voting. I will work on my formula, with a new parameter: Mandelbrottiness, which is more or less Goldilocks. Jul 31, 2018 at 14:54
• I attempted doing this on Encyclopedia Spongebobia, then went here. Jul 31, 2018 at 14:55
• Then maybe a Stack Exchange for off-topic? Jul 31, 2018 at 14:57
• @Ikura There are no such SE site, because it would generate low-quality content. Try Quora or Reddit... Jul 31, 2018 at 15:15
• Ergo! Goin' to the Kongregate Off-topic forum! Jul 31, 2018 at 18:48

This question is a simplified description of the requirement described at Permutations to the nines

Given input integer (minimum) where the first digit is always 1 and the adjacent digits are increasing in value, e.g.,

12

123

1234

12345

with the ability to handle up to the integer

123456789

where the maximum integer is always the input integer in reverse order, e.g.,

21

321

4321

54321

987654321

Return a list (array) of each number between the input minimum and maximum integer which satisfies three conditions

1. the resulting integer list item includes only the individual numbers comprising the input number
2. the resulting integer list item does not contain any duplicate individual digits
3. the resulting integer list item is greater than the preceding integer list item and not greater than a following integer in the list

## Test cases

Valid list items

12 -> [21] // done

123 -> [132,213,231,213,312,321] // done

Invalid list items

12345 -> 12344 // contains duplicate digits in whole number

123456789 -> 13256789 // not the next integer by increasing numeric value order

123456789 -> 987654322 // greater than maximum integer and duplicate digits

## Winning criteria

The algorithm which uses the least amount of operations to compute the complete resulting list of items.

Examples

123 -> 123+5+4=132 // two mathematical computations

123 -> 123+9=132 // one mathematical computation (winning criteria)

(@JoKing suggested fastest-algorithm tag; math and code-challenge tags are also applicable)

• @PeterTaylor Pared down version of the original question. Oct 8, 2018 at 18:30
• Am not as yet well-versed in Big-O notation. If the phrase "the least amount of operations to compute the complete resulting list of items" can be translated into Big-O notation, kindly suggest and edit the language used in the question. We are not interested in code length (this is not a code-golf question), but rather, that the code produces the expected result in the fewest, or least amount of total computational operations. Oct 8, 2018 at 18:35
• Ok, so if I understand the challenge, you give me a number N. I need to generate a list of numbers between N and M, where M = reverse(N). Each number in the list cannot have duplicate digits, can only consist of digits in N, and must be in strictly increasing order. Is this correct? Oct 8, 2018 at 18:52
• Assuming my above comment is correct: 1. Why is 123456789 -> 13256789 invalid, as the maximum is 987654321, which is bigger than 13256789? 2. You need a list of all possible operations. 3. Use the word digit when referring to the individual parts of a number. Oct 8, 2018 at 18:57
• @NathanMerrill Yes. Originally included using only the number 9 within the prerequisite criteria, though that inclusion appears to be challenging in itself to explain how the single number 9 can be employed to derive all list items. You are correct about 123456789 -> 13256789 being invalid. Was attempting to include invalid examples and to indicate that 13256789 should not be the next integer in the list following 123456789; the list should be in order from least to greatest integers. Ok, will use the term digit. Oct 8, 2018 at 18:57
• Thinking about this more, there's a really simplified way to describe this: You want the all permutations of the digits of N in strictly increasing order. Permutation Oct 8, 2018 at 19:09
• @NathanMerrill Yes, that is one way to put it. From perspective here, we are trying to use a number - the indexes of the initial input as a whole number - to generate all lexicographic permutations by using only math and the initial number (the current number) to do so. No loops, swaps, recursion, etc. Which am able to achieve using the code at the linked question, though the approach used there adds 9 to the initial (current) number. The challenge is to reduce the mathematical operations necessary to achieve the result - is at all possible. Oct 8, 2018 at 19:12
• I think describing it that way will make this challenge much clearer. Also, to be a fastest-algorithm, you really need to list all possible operations. Oct 8, 2018 at 19:13
• @NathanMerrill "I think describing it that way will make this challenge much clearer." Well, did that exhaustively in the linked question - with links to OEIS and previous inquiries which lead to here PPCG for context - which was closed due to "unclear what you are asking" votes codegolf.stackexchange.com/q/173145/31257, codegolf.meta.stackexchange.com/questions/16959. Posted this version of the question as users appear to not gather the original, more detailed question. Is this question codegolf.meta.stackexchange.com/a/16961/31257 clear to you? Oct 8, 2018 at 19:15
• No. That question is much too long. I don't think it is the word "Permutation" killing you there, it's everything else. Oct 8, 2018 at 19:21
• @NathanMerrill Well, here we are back to square 1. "too long" is a subjective measurement, though have been advised that users actually do have some means to time the "read" of a question, which will more than likely never do, here. This question is the bare minimum, and yet you suggest including more details. Cannot glean every individual users' idea about what is "too long" or does not include enough details. Perhaps somewhere in the middle that am as yet unable to reach. If a user takes the time to read the original question without protesting the length thereof - the details are there. Oct 8, 2018 at 19:25
• @NathanMerrill What edits to the original question or this question do you suggest? Oct 8, 2018 at 19:26
• All of the close reasons are subjective: "Unclear" is subjective, "Off-topic" is subjective, etc. I can give a full analysis of the other post, but I'd rather focus on this one. My first suggestion is to get rid of most of the requirements in favor of all permutations of the digits of N in strictly increasing order. The second thing you need to do is define what "operation" means. Oct 8, 2018 at 19:28
• "The requirement is to add, subtract, divide, multiply, or use other mathematical procedure, the number 9 to the current number to generate the next number" is (a) not anywhere that I can see in the text of the requirements; and (b) an non-observable requirement, as described in the link I posted of things to avoid when asking questions. Oct 11, 2018 at 7:16
• A requirement is only observable if you can verify it given a black box implementation, so I don't see how any code snippet can demonstrate that it is observable unless it's a test framework which verifies it by black-box testing. Oct 11, 2018 at 7:30

## All numeric substrings

I like numbers. Really, really, like numbers. If you give me a string with numerals in it, I want to get all the numbers out of it that I can.

A string.

### Output:

Every numeric substring, in any order, but only one of each. Numeric here means anything with Unicode General Category Nd (because I'm no xenophobe).

### I/O

Any reasonable format. But languages that don't allow for multibyte-character I/O should use some numeric or other representation.

### Test cases

(input → one ordering of the correct output)

• 1212 → [1212, 121, 212, 12, 21, 1, 2]
• 123٤٥6 ‪→ [1, 2, 3, ٤,‪ ٥, 6, 12, 23, 3٤,‪ ٤٥,‪ ٥6,‪ 123, 23٤,‪ 3٤٥,‪ ٤٥6,‪ 123٤,‪ 23٤٥,‪ 3٤٥6,‪ 123٤٥,‪ 23٤٥6,‪ 123٤٥6]‪
• 12t45 → [1, 2, 4, 5, 12, 45]
• abc → []
• @JoKing, thanks, done. Feb 27, 2019 at 5:35
• I am not convinced by this challenge. To me, it essentially boils down to filtering a unicode string on a character-by-character level, followed by generating all substrings of non-split substrings of the original string. Is ‪٥6 supposed to have any semantic meaning or are those simply two unicode characters? Mar 2, 2019 at 4:36