# What is the Sandbox?

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

See the Sandbox FAQ for more information on how to use the Sandbox.

## Get the Sandbox Viewer to view the sandbox more easily

To add an inline tag to a proposal use shortcut link syntax with a prefix: [tag:king-of-the-hill]

# Plan and Chain a route through OEIS

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

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

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

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

# PHP, 171 bytes

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

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

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

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

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

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

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

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

# Print a Variable's Memory Address suggestions-needed

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

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

Examples:

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



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

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

# Challenge

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

# Criteria

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

### Migrating to the Sandbox

The script should...

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

### Migrating from the Sandbox

The script should...

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

# Scoring

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

# Sandbox

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

Grep for math in a pdf document

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

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

What should the code do?

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

Scoring

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

Requests for help

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

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

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

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

The algorithm is described as follows: Infinitely alternate between

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

and

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

starting with (1).

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

### Example

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

Then the program would first print "abcdefg".

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

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

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

Then the output would be the newline-separated

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


### Specifications

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

### I/O

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

### Test cases

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

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


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

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

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

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

# The challenge:

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

# The tournament rules:

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

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

None: Play regular RPS.

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

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

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

• You cannot bring two of the same variant.

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

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

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

• There can be only one winner.

# The coding rules:

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

• No standard loopholes.

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

# Sample Input/Output:

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

n = the amount of players you intend to enter.

Example Input:

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


Make a func() that:

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

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

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

Output (uses table from input):

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

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

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

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

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


# Misc. requirements (some optional):

A {!} means it is required.

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

• {!} Print the tournament winner.

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

• Print the table for each round.

# Scenarios:

None:

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


RPSLV (will make this one quick):

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


Best out of Three:

Scenario 1: (a tie occurs at match 2)

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

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

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


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

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

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


Double RPS:

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


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

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

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

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

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

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

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

# Is it cat-urday?

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

## The catch:

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

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

Don't forget leap years!

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

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

# Lennyface parser and selector

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

## Rules

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

## Example

Given this input list :

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

1


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

## Test cases

Test 1

(⌐■_■)
3


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

Test 2

ʢ◉ᴥ◉ʡ


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

Test 3

0
\(ᗝ)/


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

Test 4

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

0


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

Test 5

1

( ͡° ͜ʖ ͡°)


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

Test 6

42

-1
( ͡° ͜ʖ ͡°)



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

@Sandbox : should I add test cases?

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

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

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

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

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

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

n=1 => 1
*

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

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

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


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

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

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

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

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

## Rules

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

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

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

# Complicating Simple Maths code-golf

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

## Goal:

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

## Examples:

Input: 5 - 1
Output: 5 + 2i

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


## Rules:

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

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

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

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

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

• This is , so shortest answer wins.

## Sandbox use only:

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

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

# The Self-Referential Algorithm

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

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

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

# The Compressor

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

[list to come]

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

## Rules

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

## Examples

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

### Alternative: code-golf

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

7160708104901559695507628057638725214364226867212714872539720713967912042100814603497742352846014272

Write the shortest possible program that outputs this number.

Related: No strings (or numbers) attached

Questions? Clarifications?

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

# Ulam spiral 2

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

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

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

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

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

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

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

Proposal:

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

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

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

## Rules

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

.

func dummy() {
}
print_first_native_instruction_byte(dummy)


would print :

0x90


which is a nop instruction on x86.

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

## Winner

The one with the shortest code… Import statements included.

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

# Preposition, not possession

## Enthralling background

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

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

What will be censored? Any overt references to ownership.

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

## Let's get specific

### Example

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

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


### Algorithmically

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

Here are some more examples:

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

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

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

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

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


# Output the first digit of Graham's number

Code golf

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

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

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

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

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

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

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

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

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

# Sandbox questions

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

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

# Golf an interpreter

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

Input to path finder:

A list of edges in a graph e.g.

AC
CD
DB


Output from path finder:

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

Feel free to somewhat adjust the input/output format.

Scoring:

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

Note:

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

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


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

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

## Brainf*** Polygot

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

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

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

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

# Gatherer Golf: The 61 Dwarves

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

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

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

Rules

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

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

# xkcd-esque Reverse Code Golf

## Introduction

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

So I set out on making this challenge!

## Challenge

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

## Rules

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

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

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

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

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

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

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

Scoring criteria:

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

# Examples

Valid:

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

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


Invalid:

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


Hope this meets PPCG puzzle criteria :D

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

# Bees?

Inspired by SCP-3045

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

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

The program should then output these modifications.

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

Move a window around the screen

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

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

# Output a Random Bit

Your task is simple: print either 1 or 0.

Chosen uniformly randomly every time.

No, not your silly pseudorandom nonsense. No system calls. No reading /dev/urandom. The randomness has to be unpredictable (i.e. reliant on chaotic, impossible-to-reasonably-model natural phenomena, and not on some configuration of bits in your computer).

## Specifications

• It is OK to query a site such as random.org for your bit.
• Your program only needs to be runnable once per day (i.e. you can assume there is a 24 hour gap between executions). This is to work around the fact that sites like random.org often have rate-limits.
• If it only has to be run once a day, wouldn't millis() % 2 be truly random? – geokavel Apr 2 '18 at 3:22
• @geokavel No, because you can't assume that the calling actions will be random (e.g. I could always invoke the program at 25-hour intervals, meaning that millis() % 2 would always be a consistent value. – Esolanging Fruit Apr 2 '18 at 4:11
• Is a time cost of maybe read a file in nanoseconds allowed? – l4m2 Apr 2 '18 at 4:42
• In its current form, it appears to be impossible to define the validity criteria objectively. Temporary -1. – user202729 Apr 2 '18 at 6:39
• @user202729 If it were up to you, how would you define them? – Esolanging Fruit Apr 2 '18 at 6:45
• /dev/random seems to be really random. Is it allowed? – the default. Apr 2 '18 at 7:30
• @someone Wikipedia says it's a PRNG, and I've heard that system randomness tends to draw entropy from sources like startup times and user actions, so that wouldn't count. – Esolanging Fruit Apr 2 '18 at 7:42
• Would a HRNG such as RdRand work? – the default. Apr 2 '18 at 8:24
• ... I admit that my downvote/comment is not constructive, but I found absolutely no way to objectively define the challenge. – user202729 Apr 2 '18 at 14:02
• Maybe define "real random" as "not only based on xxx"(currently last state, calling current) – l4m2 Apr 2 '18 at 15:38
• @l4m2 That was what I was trying to imply by saying it shouldn't be pseudorandom. – Esolanging Fruit Apr 2 '18 at 18:47
• @EsolangingFruit but you need to define what's pseudo – l4m2 Apr 2 '18 at 18:52

# Let's play the too high too - low game!

TL:DR : write a code that plays the too high - too low game

Given this pseudo code function for the too high - too low game, write it in your language of choice. This is just to make the challenge work better across all languages. This code won't count in the final score. You may also change the function's name and any of its variable's name too.

function isRight(number, guess):  # where the number is the correct answer and the guess is your code's guess

if guess < number:            # if the guess is too low
return 0                  # return 0

else if guess > number:       # if the guess is too high
return 2                  # return 2

else if guess == number:      # if the guess is right
return 1                  # return 1

else:                         # if there is an error
return -1                 # return -1


# The challenge

Write a code, function, script, etc. that guesses the right number. The range of the "random" number will be between 0 inclusively and 100 exclusively. For the sake of this challenge, the "random" numbers will be the test cases. Note that hard-coding the test cases is banned.

# Scoring

This is how the score will be counted:

bytes = number of bytes in your code
tries = the sum of all the tries used to guess all the test cases

score = bytes + tries


# Rules

• Hard-coding the test cases if forbidden.

# Test cases

[0,2,4,13,19,21,26,33,38,42,48,50,51,56,66,69,74,75,80,89,98,99]

• For one, i'd say the randomness is unfair. If you manipulate the seed python is given, you can just have it output a known sequence. Alongside that, can't you just hardcode the testcase? EDIT: Hardcoding the test case is the only way to get a good score. – moonheart08 Mar 29 '18 at 16:38
• @moonheart08 would banning hardcoding the test cases help? – Dat Mar 29 '18 at 17:57
• "the sum of all the tries used to guess all the test cases" Won't this be the same for all answers (with the only difference being floor vs ceil when taking halve the previous guess (as in 75 & higher could result in a next guess of either 87 or 88).First guess will always be 50. Is it lower, guess 25; is it higher, guess 75. etc. etc. Btw, there are already a few Guess the number challenges: Here is one; and here is another one. – Kevin Cruijssen Apr 3 '18 at 12:54

# ♫ I see a window and I want it painted black ♫

Yes, I know this is a popular mishearing of the lyrics. But instead of a red door, I really do want an (application) window painted black.

Your standalone program should launch an application window at least 400x400 and fill it entirely with black. It doesn't need to be borderless, and it doesn't need to exit gracefully.

Running in a browser is insufficient because there are still elements of the window such as the address-bar and tab-bar that aren't painted black. You must paint the whole window black except for borders added by your window manager.

This is code golf. Standard loopholes apply. Additional challenge is to listen to The Rolling Stones while making your submission.

Here is an un-golfed Java solution:

#compile: javac BlackWindow.java
#run: java BlackWindow
import java.awt.Color;
import java.awt.Frame;

public class BlackWindow{
public static void main(String[] args){
Frame frame = new Frame("no colors anymore");
frame.setsize(400, 400);
frame.setLocationRelativeTo(null);
frame.setBackground(Color.Black);
frame.setvisible(true);
}
}

• What if my platform doesn't support windows that large? – Nissa Apr 20 '18 at 23:17
• What is the 400x400 measured in? Pixels? Does it qualify if I somehow emulate a screen with larger resolution? – user202729 Apr 21 '18 at 9:23
• Does making the whole screen black count? – user202729 Apr 21 '18 at 9:24
• Stephen then make the whole screen black? What kind of system doesn't support that? – Jared K Apr 22 '18 at 0:16
• user202729 i was thinking pixels – Jared K Apr 22 '18 at 0:16
• What if I am listening to The Feelies cover of the song? Do I get the bonus point? +1 from me for an unusual challenge. – JayCe Jun 11 '18 at 3:34

# Shorter coding in non-golfing language

Copper write a requirement, a sample program in a golfing language, and a required non-golfing language. Rob hack it with the required language, with fewer bytes of code.

I guess it'd be cuz it's sometimes hard to define which is "golfing language". Also is it a duplicate?

• If it's a cops-and-robbers, then it can't be a popularity-contest. I personally don't think this challenge would work out; first of all, it's virtually impossible to outgolf a golfing language using a non-golfing languages because most golfing languages can complete most reasonable tasks in fewer bytes than it takes a non-golfing language to even print Hello World. Also like you said, golfing/non-golfing is extremely difficult to define. I also don't think this challenge would be particularly interesting because you'd likely end up with a bunch of miscellaneous cops posts with all – HyperNeutrino May 2 '18 at 13:09
• sorts of random requirements, which is basically just going to be a bunch of questions that either exist on PPCG already or could be posted to PPCG main as its own challenge, without any robber posts because it would be basically impossible. – HyperNeutrino May 2 '18 at 13:09
• IMO this is well past the threshold of "Too Broad", so I would vote to close for that reason. – Peter Taylor May 2 '18 at 15:23

(Now I don't know what the name should be)

# Intention

I want to create a challenge based on dependent typing, feature that exists in Idris, Coq, Agda and the similiar.

# Text

You should create a function in dependently typed language (Idris, Coq, Agda, etc) so that:

1. The function will receive a string that denotes format.
2. The format string will have s or n, s means it will receive a string, n means it will receive a number. You can assume that there is no other thing in the string
3. Arguments is received in order. If there is type mismatch, the error must be reported on compile-time.
4. After all arguments is received, the function will return a string, that is list of all passed argument

For example

formatf "sn" "goods" 25
> "goods 25"
> Type error in compile time
formatf "ak" "Akangka" 25
> You can do anything.
formatf "nnn" 24 25
> Either type error or return a function expecting a number and return string (currying is almost universal in these languages)
formatf "ss" "Akangka" "Martin Ender" "Adám"
> Type error on compile time


This challenge is similiar to printf-style string formatting, the difference that the function in this challenge has to be type safe.

Note that you cannot use build-in function or macro to do this

# Discussion

1. What should be the name of this challenge?
• Any reason why full programs are not allowed? – user202729 May 2 '18 at 9:29
• What happens if the language is not compiled? – user202729 May 2 '18 at 9:32
• (if you didn't realize, it's not just some languages can't solve it, but in some languages your requirements don't make any sense. There are languages without functions, language with only monadic functions, languages without integers, language without macros, language where macros have different meaning than C #define, language without string (C), etc.) – user202729 May 2 '18 at 9:59
• If the string is possibly not known at compile time, how can it produce a type error at compile time? – Angs May 2 '18 at 10:04
• Personally I think it's a bit too similar to the challenge you linked.. The only difference is validating the input-type with the format.. In which case it would be better to have a challenge dedicated to that, as in: Given this format and a variable amount of other objects, check if the format and types of these objects match. In which case "%s: %i%%", "Percentage", 25 would be truthy, and "%s: %i%%", 123.45, 25 would be falsey. In addition, most languages are type independent, which can change during run-time based on their use.. 10.0 could be all three types in some languages.. – Kevin Cruijssen May 2 '18 at 10:07
• Suggested re-working of the problem: Given a pattern using only %s and %n (for number), slot in the given list of strings and numbers in the given order, but return a distinct value or throw an error if the given list doesn't fit right. – Adám May 2 '18 at 10:08
• @Angs dependent typing. In fact, this challenge is about dependent typing. – Xwtek May 2 '18 at 10:17
• @user202729 well, by compile-time, I mean about typechecking time. I specifically disallow dynamic typing, as one of the point of the challenge is to make the program fail to typecheck if %s format is supplied by integer, etc. – Xwtek May 2 '18 at 10:21
• @KevinCruijssen Indeed, not all language can do this challenge. After all the intention is on the dependent typing, which most programming language (but not Idris, Coq, etc) lack. – Xwtek May 2 '18 at 10:26
• @Adám nice suggestion. But the type-safe feature (i.e. all error is on type-checking time) is integral part of the challenge – Xwtek May 2 '18 at 10:28
• @Akangka I don't understand why my suggestion doesn't satisfy that. You get a list of strings and numbers and need to check against each tag in the format that you've been given the right tag. – Adám May 2 '18 at 12:12
• I think you should limit to some languages (perhaps extend the language list if needed), as the challenge does not make sense in other languages anyway. – user202729 May 3 '18 at 1:26
• @Adám I actually implement your suggestion, except the throw an error part. I make the challenge require the result is type error – Xwtek May 3 '18 at 2:03
• @Akangka I don't understand why you insist on language specific features like "type errors" and "compile time". Your examples do not show how to format ss, ns, and nn. You mention float dots, but floats are not part of the examples any more. – Adám May 3 '18 at 5:46
• @Adám thanks about float dots. About language specific features, I just want to create a challenge about dependent typing. – Xwtek May 3 '18 at 6:50