# Sandbox for Proposed Challenges

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

Sandbox FAQ

## Posting

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

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

## Discussion

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

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

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

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

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

## Other

Search the sandbox / Browse your pending proposals

The sandbox works best if you sort posts by active.

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

Get the Sandbox Viewer to view the sandbox more easily!

# Recursive Pi

Given an integer $$\n\$$ with $$\0 \leq n \leq 9\$$, return all the digit $$\d's\$$ as the program goes through this process:

• Find the digit $$\d\$$ in the decimals of $$\\pi\$$ with the index $$\n\$$, $$\0\$$-indexed
• Run the same process with $$\n\$$ being the digit $$\d\$$

After at least $$\10\$$ steps, the program will always get stuck in a loop. That is when the program should terminate and output all the $$\d's\$$ / stop outputting $$\d's\$$.

# All Cases

$$0 \to [1, 4, 9, 5, 2] \\ 1 \to [4, 9, 5, 2, 1] \\ 2 \to [1, 4, 9, 5, 2] \\ 3 \to [5, 2, 1, 4, 9] \\ 4 \to [9, 5, 2, 1, 4] \\ 5 \to [2, 1, 4, 9, 5] \\ 6 \to [6, 6] \\ 7 \to [5, 2, 1, 4, 9, 5] \\ 8 \to [3, 5, 2, 1, 4, 9] \\ 9 \to [5, 2, 1, 4, 9] \\$$

• I'm not sure this is very interesting since it's basically just 10 lists you need to encode. Have you tried the challenge? Were there any interesting approaches you could come up with?
– Wheat Wizard Mod
2 days ago
• @WheatWizard Yes, but now I think it's shorter to encode the lists than to implement a recursive function. 2 days ago

### Identify basic building blocks for new natural and programming language

(Based on Invent new programming language and write Hello world in it, but re-phrased to gain more focus on answers).

There exists variety of different programming languages, also variety of natural languages.

If we could create new programming language, which in a turn would possess structure of natural language - what basic structures you would choose ?

one example of artificially constructed language is Toki Pona:

It can be used as natural language, but not as a programming language.

One example of programming language is for loop - for example in C#:

for(int i = 0; i < 10; i++) { ... }

If you want to express this kind of sentence in natural language - then you can use 'equals' for '=', 'less than' for '<' - but scope begins ('{') and scope ends ('}') is relatively long and difficult to express / pronounce.

What basic language structures you would propose for new language ?

# Find out what type of adjective it is

There are 3 types of adjectives: absolute, comparative, and superlative adjectives. Your program should print what type of adjective it is. The program is supposed to work on finite lost of words.

## Notes

• Input will be a string, (not always 1 word), it'll be an adjective (the number of words will be finite)
• Output must be anything that represents absolute, comparative and superlative.
• The 15 adjectives below should be used as test cases and your program should be at least 90% accurate.

This is , so the shortest code wins!

Test cases:

pushiest => superlative
homeliest => superlative
most miserly => superlative
outgoing => absolute
most feline => superlative
roasted => absolute
frightening => absolute
fairer => comparative
more uncomfortable => comparative
more classic => comparative
smarter => comparative
muffled => absolute
scratchier => comparative
meager => absolute
tartest => superlative

• So it only needs to correctly identify 14 of the below 15? Jun 30 '21 at 14:00
• @rak1507 at least. I'll add more test cases if necessary Jun 30 '21 at 14:02
• @rak1507 but checking everyone of these won't work, as it's code golf Jun 30 '21 at 14:04
• It should be made very clear whether the program is supposed to work on a finite list of words (as currently suggested) or on any input in theory. The approaches are going to be very different. Jun 30 '21 at 22:34
• "tartest" is a superlative. Jul 17 '21 at 2:04
• @DjinTonic okay done Jul 25 '21 at 7:58

# Is it a mathy-county-number

So I recently reinvented some boring type of number. Reinvented because I'm sure somebody else invented it before, but 'till figure out who invented it, let's call these numbers mathy-county-numbers.

## So what is a mathy-county-number?

A mathy-county-number number is a number whose count of each digit also appears in the number.
It's a number like 332222410.
The number 3 occurs 2 times, so there must be a 2. The number 2 occurs 4 times, so there must be a 4. 4 occurs once, and some other numbers occur 0 times.

The task is simple: Write a program to check if a number (received by the input) is a mathy-county-number.

## Rules

• Default loopholes apply
• Default I/O rules apply
• Output must be a truthy or falsy value
• No digit will appear more than 9 times

## Examples

332222410
> True

33222241
> False

1
> False

33222
> False

1122233334444455555566666667777777788888888890
> True

112223333444445555556666666777777778888888889
> True

122334444456789
> False

• "The number 3 occurs 2 times, so there must be a 2." Does this means "3312" is valid as there is a 2 (although not followed by 3).
– tsh
Jul 26 '21 at 9:48
• Why "1" is falsy?
– tsh
Jul 26 '21 at 9:49
• @tsh 1: no, because in 3312 there's no 0. but eg. 03312 would be valid Jul 26 '21 at 10:44
• @tsh 2: 0 is not there, 9, 8, 7, ... occur 0 times Jul 26 '21 at 10:54
• "If any digit occurs more than 9 times, count it as a 9." is needlessly complicated, I'd suggest just saying that no digit will appear more than 9 times. The output for the last 2 test cases in unclear - what is sdcvbhnjmk supposed to represent? Just use something like true/false. Additionally, why is 33222 true? By the same logic as the example, it contains "some other numbers zero times", so should include a 0 to be true, right? Aug 6 '21 at 14:02
• @cairdcoinheringaahing thanks, don't know why I'm addressing the changes now Jan 7 at 13:06
• If 0 does not occur in a number, does that mean that some number appears 0 times? Jan 7 at 14:03
• 0 has to occur in a mathy-county-number if some number appears 0 times. Example 112 would be invalid because eg. 3 appears 0 times. 1120 would be valid though. Jan 7 at 14:20
• @thejonymyster ^ Jan 7 at 14:30
• in the number 123456789, 0 appears 0 times. However, there is no 0 in the number to account for the fact that there is 0 of that number. Should this output truthy or falsy? (Note: this is a paradox) Jan 7 at 14:33
• Also, you should clearly define what makes a number mathy-county, rather than having the user rely on an example. (Not that it isn't easy to figure out, but it's good practice and leads to no assumptions being made, especially ones you weren't prepared for) Jan 7 at 14:34
• @thejonymyster I'd say the number itself should be falsy because there is no 0. However even if you add a 0 it'll stay falsy. Jan 7 at 14:40
• Thanks, I'll add that in Jan 7 at 14:41
• @mathcat so any number without a 0 in it should return falsy. Also, numbers with leading 0s being counted differently is strange. How is 01 different from 1, numerically? Jan 7 at 15:09

# Wordle

The game Wordle is quickly becoming popular.

The way the game works is as follows:

1. Players are trying to guess a 5 letter word
2. Players have six attempts to guess the word
3. After each attempt, the player is told:
a. which letters are in the right place (index)
b. which letters are in the word, but in the wrong place
c. which letters are not in the word at all

The aim of this challenge is to create a Wordle application, as follows:

1. On startup, the application reads from a dictionary of 5-letter words and selects one at random
2. The application then prompts for user input
3. On input:
a. The application checks the input to ensure it is also a 5-letter word and in the dictionary. If it is not, the application returns any failure message and exits
b. If the input matches the chosen word, the application returns any success message and exits
c. Otherwise, the application checks the letters of the input against the letters of the word, and returns to the user an indicator for each letter of whether it is correct, misplaced, or incorrect. If a letter is repeated in the input, only the first occurrence is marked as correct/misplaced; the remaining occurrences are marked as incorrect [sandbox qn: what happens if the actual word has repeated letters?]
4. Steps 2 and 3 are repeated until the application aborts in step 3a or 3b; or the user has failed to guess the word a total of 6 times; at which point the application exits

## Sandbox

I am thinking of this as a code-golf challenge, but I wonder if there's another approach where people create the bot that's trying to solve the challenge, as well as the bot that's providing the challenge? Or something else? I'm not familiar with the other types of challenges to suggest something.

• The hints wordle gives back are a little more complicated when a letter appears multiple times in the guess. I still think there's a lot left to clear up here otherwise but that sort of edge case behavior is one thing that should be made clear.
– Wheat Wizard Mod
Jan 11 at 15:04
• @WheatWizard Thanks, yes, that's why I put it in the sandbox! Jan 11 at 15:04
• Somone has played around and found out the repeated letter rules over on Reddit. Jan 11 at 23:29
• IMHO in its current form it contains too many tasks in one challenge. Maybe limit the challenge just to step 3 or even just step 3c? Jan 12 at 11:10
• @JonathanAllan thanks, that's helpful. Jan 13 at 15:24
• @pajonk I agree it's probably too complicated as-is for a [code-golf] challenge. I don't want to reduce it to just a simple "which letters are in the correct place" challenge though - I feel that's not interesting enough. What about a different scoring system - perhaps a variant of [king-of-the-hill], where you're either trying to create a bot that can solve Wordle quickly; or a bot that picks words to avoid being solved easily - and they're pitted against each other. Would that be more interesting? Jan 13 at 15:27

# Universal Command Sequence

Posted

• Very related: Shortest universal maze exit string
– xnor
Jan 6 at 8:59
• I feel like answers to this will be very hard to test. Probably the golfiest way to do this, if it's valid, would be not to code anything with mazes, but just to produce some massive random-looking sequence of directions. If the length is a fast-enough growing function of n, with overwhelmingly high probability works on every maze for every n. Like, "output 3^3^3^n in base 4".
– xnor
Jan 6 at 9:06
• @xnor This question is actually from a Russian math olympics problem :D that problem is to prove the existence of the sequence. The proof states that the sequence can be generated by following a certain rule (a certain rule of concatenating sequences, to be exact). And I think I do have written a testing code for it; see section "Test Code" (sorry but English isn't my mother tongue, but now I know it is called a "validator", isn't it?) Jan 6 at 15:42
• Ah yes I rembered, it's 1998 All-Russian Math Olympiad, Grade level 9, Day 1, Problem 4. Original problem is 8x8 grid, but the proof can be generalized to nxn. Jan 6 at 16:02

# Generate Fmbalbuena Numbers

• so both the second step and last step need to be true? Jan 6 at 11:35
• @Razetime 2nd and last step need to be true. Jan 6 at 11:36
• combine step 1 and step 2 into "Check if the number of digits is a multiple of 3", and change "N/3 digits" to something like "Length / 3 digits" (to me "N/3" reads like the original number divided by 3). Jan 6 at 14:22
• "equals the last digits" → "equals the last digits modulus 10"
Jan 7 at 0:01
• You should state clearly that having a digit count that isn't divisible by 3 is enough to make a number not be a Fmbalbuena number.
Jan 7 at 0:02
• What is the goal of the challenge? decision-problem for a single given number (I recommend that) or generating the sequence up until a limit, or maybe the first n number, or "infinitely" spitting out more?
Jan 7 at 0:04

# Generate Matching Regexes

Write a program that takes two lists of strings and generates a javascript regex that fully matches all the strings in the first list and matches none of the strings in the second list.

To be specific when for all stings in the first list str.match(\[your-output]\) must produce a match for the full string and for all strings in the second list str.match(\[your-output]\) must produce no matches.

## Scoring

Your score is the average length of the regexes you produce not the length of your program. Your regexes should be tested against this file: https://pastebin.com/9iNZvGJC. Take the file in blocks of 20 lines and run your program with the first ten lines to match and the second ten to not match. Average the lengths of your program's output for all of the blocks in the file. This is your score.

## Rules

• Do not output the \ for the regex
• I'm guessing this is a Sandbox for this closed challenge, and that you're aiming to improve the existing one? I'd suggest clarifying the scoring system, I'm not fully sure how exactly it works? Jan 15 at 22:46
• Yes it is. Could you clarify what you find confusing about the scoring system? Jan 15 at 23:06
• "Take the file in blocks of 20 lines and run your program with the first ten lines to match and the second ten to not match." Seems like it would be simpler to just provide the lines to match and the lines to not match, rather than doing the line splitting bit Jan 15 at 23:10
• You would have to split it into blocks anyway so that doesn't really seem easier? Jan 15 at 23:17

# Help Bob split his apples

Bob has a lot of apples, and he wants to split his apples with his friends evenly. (Including Bob.) However, every $$\k\$$th friend already has a lot of apples and does not need apples. Bob, however, is kind so he gives each $$\k\$$th friend the number of apples the friend already gives floor divided by three.

Given the input format below, a number $$\k\$$, and a number $$\a\$$ for the number of apples, output the number of apples that each person receives.

# Test Cases

[0, 0, 80, 0, 0, 45, 0, 0, 12] 3 100 => [10, 9, 26, 9, 9, 15, 9, 9, 4]

• Could you try to clarify a bit more? Jan 19 at 13:46

# Move the next greater number, with fewest fails to take everything

Your task is to move the next greater number, with fewest fails to take everything

A fail counts if a step is the lower number (not counting equal)

The starting point is the top left corner

Example:

1234


Can do like this

>>>


Because moves to right, the next number is greater than previous

But

124
435


Is impossible so the fewest fails are:

>>v<<


1 > 2 > 4 > 5 < 3 > 4

So this has 1 fail

## Test cases:

The output is not exact, there are multiple possible solutions

Input:

123
245
175


Output:

>>vv<<^>


Input:

123456789


Output:

>>>>>>>>


Input:

987654321


Output:

>>>>>>>>


Input:

123
456
789


Output:

>>vv<<^>


Input:

123456789
987654321
123456789


Output:

>>>>>>>>v<<<<<<<<v>>>>>>>>


# Meta:

• Any feedback?
• I like the idea but I think the explanation could include the definition of a "fail". Jan 19 at 16:28
• @Wezl-yizl Added Jan 19 at 16:31

# Euler Irregular Primes

Your challenge is to find all Euler Irregular Primes (A prime p is Euler-irregular if it divides an Euler number E(2n) with 0<2n<p−1) under n.

## Scoring

Your goal is to use the least amount of bytes.

• welcome to this website ! challenges should be self contained, so while the link is good, you should Also include a definition of euler irregular primes Jan 20 at 1:49
• Could you provide some test cases and define "storage" clearly? Jan 21 at 10:45

# Deterministic oozes

This challenge is similar to the above linked challenge except the task is to output the next state of the input.

### Input

Input can be taken as:

• A list of characters of states of cells
• A string
• A list of code points of characters

Output the next generation of the input.

These conversions happen if there is food . or : next to them:

"o" → "O"
"O" → "8"
"8" → "oo"


### Scoring

Number of bytes, shortest code wins!

### Test Cases

"o. o" → "O o"    # Look the food is consumed
"oooo.8" → "oooO8"  # Left eats first
"8:8" → "oooo"   # Both eat
":8" → "Oo"  # Notice, 2 generations happen, ":8" to ".oo" to "Oo"


## Meta:

• Tags?
• Clear?
• There's a lot still missing here. It seems like most the challenge has to be guessed from a handful of test cases.
– Wheat Wizard Mod
Jan 24 at 14:54
• @WheatWizard ok ill add more test cases tomorrow. Jan 24 at 14:55
• No that is the opposite of what I am saying. You need to specify the challenge not just add more test cases.
– Wheat Wizard Mod
Jan 24 at 14:56
• The challenge should be completely understandable with the test cases removed.
– Wheat Wizard Mod
Jan 24 at 14:56
• @WheatWizard ok i see, will do that tomorrow Jan 24 at 14:59
• Having multiple generations happen at a time seems contrary to "output the next generation" 2 days ago
• Suggested testcase: "o:o.o"
– tsh
2 days ago

# Approximate Euler's Number

Euler's number (e) is one of the most well-known mathematical constants, with a simple way to approximate it. All you have to do is repeatedly generate a random number between 0 and 1, and add it to an accumulator. Record how many times you have to do this for the accumulator to exceed 1. If you do this over and over again, the average of all the times it takes will approximate Euler's number.

Write a program that, given a number of iterations as input, approximates Euler's number using the above method and prints the result.

## Scoring

This is code-golf, so shortest answer wins. However, if the language you are using does not include a random number builtin, you may exclude from your byte count the code required to import it. For example, if you're writing a Python program to do this, you may assume the random module is already imported.

## Example implementation (ungolfed)

import random
acc = 0
res = []
for x in range(int(input())):
while acc < 1:
acc += random.random()
res.append(acc)
acc = 0
total = 0
for x in res:
total += x
print(total / len(res))

• This looks like it's probably unobservable. You also need to specify how "random" is defined: can programs use a biased RNG (which will inevitably produce an inaccurate approximation)? Jan 24 at 17:55
• @pxeger Good point. How should I go about fixing this? Jan 24 at 17:56
• IMO the interesting part of this is never going to be the random number generation, but the calculation based on them. You could just have challenges accept an input of a list of numbers, presuming them to be random, and give the approximation calculated if that list were the source of random numbers. So an input of [random.random() for _ in range(10000)] will produce about 2.72, but an input of [0] * 10000 will produce some completely wrong output Jan 24 at 18:00
• Also, your code is missing a parenthesis on line 4, and outputs $e / 2$, not $e$. Jan 24 at 18:00
• @pxeger I know the RNG is boring, whcih is why it's excluded from the byte count. Sorry about the bugs, I'm fixing them. Jan 24 at 18:02

# Count the ways to transform (3)

Your input is an infinite matrix (2d array) of nonneagtive integers where a finite area of the matrix contains nonzero integers. For example:

$$\begin{matrix} \ddots & \vdots & \vdots & \vdots & \vdots & \vdots & \vdots & \cdot^{\cdot^\cdot} \\ \cdots & 0 & 0 & 0 & 0 & 0 & 0 & \cdots \\ \cdots & 0 & 1 & 0 & 0 & 6 & 0 & \cdots \\ \cdots & 0 & 3 & 5 & 4 & 3 & 0 & \cdots \\ \cdots & 0 & 2 & 0 & 0 & 0 & 0 & \cdots \\ \cdots & 0 & 0 & 0 & 0 & 0 & 0 & \cdots \\ \cdot^{\cdot^\cdot} & \vdots & \vdots & \vdots & \vdots & \vdots & \vdots & \ddots \end{matrix}$$

A semi-continuous transformation of this matrix is a rearranging of elements that preserves immediate neighbors. For example, we can swap the $$\2\$$ in the bottom left, and the $$\1\$$ in the top left corner.

$$\begin{matrix} \ddots & \vdots & \vdots & \vdots & \vdots & \vdots & \vdots & \cdot^{\cdot^\cdot} \\ \cdots & 0 & 0 & 0 & 0 & 0 & 0 & \cdots \\ \cdots & 0 & 2 & 0 & 0 & 6 & 0 & \cdots \\ \cdots & 0 & 3 & 5 & 4 & 3 & 0 & \cdots \\ \cdots & 0 & 1 & 0 & 0 & 0 & 0 & \cdots \\ \cdots & 0 & 0 & 0 & 0 & 0 & 0 & \cdots \\ \cdot^{\cdot^\cdot} & \vdots & \vdots & \vdots & \vdots & \vdots & \vdots & \ddots \end{matrix}$$

This is fine, because every number has the same neighborhood counts. That is, we can make a sorted list of numbers and their neighbors, and verify the they are the same:

$$\begin{matrix} \text{Number} & \text{Neighbors} \\ 0 & 0,0,0,1 \\ 0 & 0,0,0,1 \\ 0 & 0,0,0,2 \\ 0 & 0,0,0,2 \\ 0 & 0,0,0,3 \\ 0 & 0,0,0,3 \\ 0 & 0,0,0,3 \\ 0 & 0,0,0,4 \\ 0 & 0,0,0,6 \\ 0 & 0,0,0,6 \\ 0 & 0,0,1,4 \\ 0 & 0,0,2,5 \\ 0 & 0,0,4,6 \\ 1 & 0,0,0,3 \\ 2 & 0,0,0,3 \\ 3 & 0,0,3,6 \\ 3 & 0,1,2,5 \\ 4 & 0,0,3,5 \\ 5 & 0,0,3,4 \\ 6 & 0,0,0,3 \\ \end{matrix}$$

(we ignore zeros that have 4 zeros next them, since there are always infinitely many)

# TODO: Add example where non-semi-continuous transformation changes the neighborhood counts.

To clarify, semi-continuity is a property of a transformation on some specific matrix.

Your code will take an infinite matrix as input and output the number of (unique) semi-continuous transformations. Two transformations are different if the output is different. So for example swapping two identical numbers is the same as the identity transform (doing nothing). Also, since it's an infinite grid, simply translating the pattern is the same as doing nothing. You can assume the output number will always be finite.

Or in other words: Your code will take an infinite matrix and return the number of matrices with those dimensions that have the same neighbor-list.

Input can be in any reasonable format. You can decide if your input has to have some amount zero-padding or if you always take a square matrix, etc.

# Meta

Is this more interesting than version 2?

• not sure what being infinite adds to the challenge since all that changes is that translations do nothing 2 days ago
• If the non-zero portions form multiple disconnected segments with more than one $0$ separating them the result can be infinite. For example if the finite portion is entirely within $1,0,0,2$ then you can just move the two non-zero values as far apart as you wish.
– Wheat Wizard Mod
2 days ago
• @WheatWizard Yes, that's what I meant with "You can assume the output number will always be finite" 2 days ago

(To do.)

# Test Cases

[[1, 2, 3], [4, 5, 6]] => [[1, 4], [[1, 2, 3], [4, 5, 6], [3, 2, 1], [6, 5, 4]]
[[1, 1, 1]] => [[1, 1, 1], [1, 1, 1]]
[[]] => [[]]


# Ragged Matrix

A ragged matrix, is a matrix that has a different number of elements in each row. Your challenge is to write a program in any favorable language to find the indices of all occurrences of target in the ragged matrix.

# Input:

A list of ragged lists (can be empty) of positive integers and a target range e.g. 56-26. The target range, given 2 positive integers. For languages that do not support this type of list, you can input it as a string representation

You may assume that a<=b

# Output:

If a number in the ragged list is within the range or equal to a or equal to b, output the index of the ragged list then the index of the number in that ragged list e.g. 0 4 - The 0 is the first ragged list in the input and the 4 is the index of the number in the first ragged list

# Test cases:

[[[1,3,2,32,19],[19,2,48,19],[],[9,35,4],[3,19]],19-53]
->
[[0,3],[0,4],[1,0],[1,2],[1,3],[3,1],[4,1]]

[[[1,2,3,2],[],[7,9,2,1,4]],2-2]
->
[[0,1],[0,3],[2,2]]


You can choose to follow the output format above or output it in the following as well:

[[[1,3,2,32,19],[19,2,48,19],[],[9,35,4],[3,19]],19-53]
->
0 3 0 4 1 0 1 2 1 3 3 1 4 1


0-based and 1-based indexing is allowed

You can output your answers in any way as long as it is distinguishable what the indexes of the number and matrix are

# Tags:

code-golf

matrix

ragged-list

• Please consider adding tags below the title (refer to the template). Please also consider loosening the input criteria (e.g. allowing also inputting a and b as integers with assumption that a<=b). You may also explicitly state that both 1- and 0- indexing is ok. yesterday
• are my edits ok now pajonk? i have changed it accordingly yesterday

# Truncatable Primes

A left-truncatable prime is a prime number and when the first digit is removed continuously, the result is always prime.

A right-truncatable prime is a prime number and when the last digit is removed continuously, the result is always prime.

If the integer is only a left-truncatable prime, return left

If the integer is only a right-truncatable prime, return right

Otherwise, return False

# Test cases

9137 -> left
9137, 137, 37 and 7 are all prime

5939 -> right
5939, 593, 59 and 5 are all prime

139 -> False
1 and 9 are non-prime, so 139 cannot be truncatable from either way

103 -> False
It contains a 0 digit, which is not prime(even though 103 and 3 are primes)


You may assume that the input will never be both left and right truncatable, so an integer such as 5 will not appear in the input (it is prime and single digit so it is counted as both)

You are allowed to print False as 0 and left as 2 and right as 1

OR

left as 1 and right as 2

Otherwise, you are allowed to use any 3 distinct 3 values/string representation of left, right and False

# Tags:

primes

classification

• Rather than those specific strings, I would recommend letting people choose their own four distinct values
– user
yesterday
• Also, I think there’s a tag for classification challenges
– user
yesterday

# Intro

Given a number of sides $$\a\$$ and a side length $$\b\$$, generate an $$\a\$$-sided polygon with side length $$\b\$$. The fill value will be the alphabet going clockwise. If there are not enough letters, wrap around.

# Test cases

3 4

A
H B
I   C
G F E D

4 4

ABCD
L  E
K  F
JIHG
$$$$

• This seems like it'd immediately run into problems with, say, a pentagon. But I digress, this is intriguing 2 days ago
• Good idea, it's just that I'm unsure as to how one might handle a heptagon, or dodecagon, for instance. And do we have to loop back to the beginning of the alphabet once we have exhausted the entirety of the alphabet? For instance, a square with a side length of 10? 2 days ago

# Understanding slicing

Remember, slices are zero-indexed. Take this slice: [2:]. If the list is [1, 2, 3, 4, 5], the result is [3, 4, 5] because the slice basiclly means "get all elements with a index greater than 2." Let's try [1:3]. If there is a end slice, the end slice is not included. (excluded) Therefore, the result is [2, 3]. What about [::2]? [::2] means "take every second element", so the result is [1, 3, 5].

Note: This is not the complete features of slicing. For more info, see here.

Cops, your job is to write to a program, that when sliced, will input a string and reverse it. The slice could be something like [::-1][2::6] which means "reverse the code, then get each sixth char starting from index 2."

The unsliced program must be valid code, and it does not need to do anything. It may not take any input.

You must specify the number of slices.

# Example

Take this code: iimmppoorrtt ssyymmppyy;;pprriinntt((ssyymmppyy..iisspprriimmee((iinnppuutt(())))))

The slice here is [::2], so the robber's post could look like this:

Cracked <somebody>'s answer
The slice is [::2].


# Robbers

Robbers, your job is to find the slices of the corresponding cop's code.

• Try to clarify the robbers challenge and add a example 14 hours ago
• Challenges should be self contained: i.e. copy the relevant info from the link onto the question 14 hours ago

# The only differences that matter

Write two programs (or functions) A and B in the same version of the same programming language. They also should be called in the same way, meaning you can't write one program and one function. Each should accept an integer n and output the term n of a different integer sequence on OEIS.

You should reveal a substring of each of A and B. Call them PA and PB. If one instance of PA is replaced by PB from A, it should become B. That means every byte except the reveal part in A and B should be exactly the same. You also reveal the lengths of A and B, and the two OEIS sequences. You don't reveal the programming language you use.

Your answer is cracked if a robber finds two programs A' and B' that also print the elements in the two integer sequences respectively, where A' is no longer than A, and A' with one instance of PA replaced by PB is also B'. They don't have to be the same with your original A and B. And they don't have to be in the same programming language as yours, as long as they are in the same programming language themselves.

If your answer isn't cracked 7 days after you post the answer, you can reveal your language and the original A and B and mark the answer safe, and it will be immune to future crack. Your answer can still be cracked if you don't do it.

Your score is max(len(A)+len(PA)*5, len(B)+len(PB)*5). The safe answer posted before a certain date with the minimum score wins.

For example, if your two programs are The first program and The second program, you can reveal first and second. Your score is 18 + 6*5 = 48. And a robber can crack your answer by <<first>> <<second>> if they work. But you can also reveal first pro and second pro to prevent this crack.

# <length of PA> / <length of A> bytes, <length of PB> / <length of B> bytes, score <score>, <open / safe / cracked>

Part of program A (outputing [<OEIS number>](<OEIS link>)):

<code of PA>

Part of program B (outputing [<OEIS number>](<OEIS link>)):

<code of PB>

<any other explanations>


(To do.)

• Do robbers have to produce the same program, or any program? Oct 28 '16 at 14:47
• There are two tricky edge cases around character encodings which the question needs to address. 1. It talks about substrings of A and B, saying that every byte except the revealed ones must be the same. If A and B differ in one Unicode codepoint, such that in UTF-8 they differ in only one byte but it's part of a three-byte sequence, can I post just that one byte as PA/PB or must I post the three-byte sequence? (I.e. are the substrings operating on the bytes or on the codepoints?) Oct 28 '16 at 20:57
• 2. If my program is in APL using an 8-bit encoding, do robbers answering in a language other than APL have to have the same bytes in the part of their file corresponding to PA/PB or the same Unicode codepoints? Oct 28 '16 at 20:57
• @NathanMerrill Any program. Oct 28 '16 at 21:05
• @PeterTaylor I'm considering requiring every program to be in printable ASCII (and tabs and newlines), as some special characters effectively banned many languages. But I'm not sure about newlines, which have the \r problem. Oct 28 '16 at 21:09
• Maybe I'll just say \r\n is counted one byte in this challenge, and is interchangeable with \n. But the programs in one submission must use only \n or only \r\n. Oct 28 '16 at 21:13
• An example would make this easier to understand,
– xnor
Oct 29 '16 at 6:08
• I'm skeptical about having the programming language be a free variable. If a cop writes an answer using a verbose language, a robber can comment out all the visible parts and stuff a terse language answer into the cracks. Oct 29 '16 at 11:24
• @feersum But that's the whole point of all the requirements. If you comment out all the visible parts, both your programs usually should output the same thing. But I realized it's easy to have some workarounds in languages such as Befunge. I may try to find a way to ban them, or just abandon this post. Oct 31 '16 at 0:59

# Translation Polyglot

Your task is to write a program which runs in two distinct programming languages to translate text. Input should be translated between each language i.e. running your code in Code Language A translates from language 1 to 2, while running your code in Code Language B translates from language 2 to 1.

Rules:

• Code Languages must be distinct, two versions of the same language are disallowed
• Your code may be a full program or function
• Your code must take one string (or nearest equivalent) as input. Input may be user input, function arguments, or other reasonable form
• Output may be a function return, output to STDOUT, or other reasonable form. I do not care about trailing newlines or spaces
• Your code may translate from/to any language on the official language list on Wikipedia. List the languages in your answer
• To accomplish your goal, you may use prebuilt language tanslation dictionaries such as the ones found here.
• If you read your dictionary as an external file, only the code to read in the file (f = open("dictionary.txt", 'r') in Python) counts towards your byte count. If your dictionary is hardcoded in, only count the bytes required to make it syntatically valid code (s="word1_in_english word1_in_french ..." would be 4 (s="")). Essentially, do not include the dictionary as part of your submissions byte count.
• The dictionary you use must have been created before this post (including sandbox time). You may not modifiy the dictionary in any way.
• Any built-in translation tools are disallowed. Built-in dictionaries are ok, but whatever code used to import them into your code must be included in the byte count

This is code golf, so shortest answer in bytes wins.

• wait... Are you actually asking for machine translation? Seems very difficult. Haven't you ever seen bad translator? If it actually is machine translation, this won't work, because of the different resolution of the languages (like converting a jpg to a png and expecting the same quality back) Nov 1 '16 at 4:11
• It's really just value lookup. I'm not asking people to to make their own dictionary, just use a pre-built and accept whatever it translates Nov 1 '16 at 13:45
• But that doesn't really satisfy Language A produces output O from input I, while running in Language B produces output I from input O. Nov 1 '16 at 22:04
• Ah, now I see the source of confusion. Updated text to require basic translation, not symmetric translation Nov 2 '16 at 11:53
• Also I don't think translation is objective enough for code golf... Nov 3 '16 at 5:30

# What in the heck just happened?

I want you to write a program that will bleep out the H-word, regardless of where it occurs, whether it is inside of another word or a stand-alone word, whether capitalized or not.

## Input and Output

The inputs and outputs of your program may be any of the following: an array of characters, a string, or any other standard data structure which does the job. However, the output must match the case of the input.

## Samples:

In the format of Input: Output
A Shell gas station : A Sheck gas station
Hell is a very bad place to be. : Heck is a very bad place to be.
Ella fell and Nelly dug a well. : Ella fell and Nelly dug a well.
Chellsea Thell bought shells. : Checksea Theck bought shecks.


Standard loopholes apply, and the entry submitted by [insert date here] with the lowest number of bytes as defined by the Meta will win.

• I can't say for sure, as I don't have an exact reference, but I'm pretty sure a simple find and replace challenge has been done before. Feb 13 '17 at 0:19
• "Hell" and "heck" are both "H-words", so you need to be clearer. Also, I feel like this is a duplicate. Though these are milder swear words, I think someone did one with swear words in general and it got deleted. If you're going to make a find/replace challenge, it's simple enough to make it about something else. Feb 13 '17 at 0:19
• Ah, I see. So, are you saying I should change what's being replaced or what my idea is? Feb 14 '17 at 0:50

# Prove the Undecideability of the Halting Problem

Either:

Create a program that, when given an input, no single program (which receives your source and your input) can determine if your program terminates, or

Create a function that, when given an input, no single program (which receives your source and your input) can determine if your function returns.

Your score is the byte count of your program plus the byte count of your input (or of the shortest input in the set of input that solves this problem).

Lowest score wins.

//I would love some input on my wording.

• Can I make a request to an external URL until I get a 404?
– user58826
May 17 '17 at 18:21
• @programmer5000 can an external program determine whether your program will halt? For example, by pinging that URL themselves? May 17 '17 at 18:24
• Oh. Could I make a program that stops when it finds 5 points that prove the Happy Ending Problem wrong?
– user58826
May 17 '17 at 18:29
• @programmer5000 if your program stops with a given input, and another program can predict that it will stop with that input, your program does not match specs. No input is accepted input, but it is very unlikely that an undecidable program can come from no input AFAIK. May 17 '17 at 18:32
• @programmer5000 from the Wikipedia page it seems like that problem is already solved, so that program will terminate, so another program could predict that. Could be wrong though. May 17 '17 at 18:33
• Um. eval. It's one byte long in GolfScript. May 17 '17 at 21:35
• @PeterTaylor you need to provide an input that is undecidable, and that counts towards your score. May 17 '17 at 21:38
• I don't think this is how the halting problem works... May 17 '17 at 23:50
• @DestructibleLemon You may be right; Wikipedia says a general algorithm to solve the halting problem for all possible program-input pairs cannot exist. Do I need to require two inputs? This answer seems to contradict Wikipedia though. May 18 '17 at 0:10
• hmmm, you definitely could do this (make it an interpreter) but I'm not sure how much you have to do to make this work... as in what the simplest program would be May 18 '17 at 0:17
• @StephenS It doesn't require 2 inputs, it requires a pair (program, input). May 18 '17 at 1:07
• It's the problem which is undecidable, not the instances. If you want to ask for a program which cannot be proven to halt or not halt, you have to specify the axiom system which can be used for the proof. See e.g. codegolf.stackexchange.com/q/79470/194 , codegolf.stackexchange.com/q/79620/194 May 18 '17 at 6:19

# Bike saddle drawn through a fractal

Based on the Mandelbrot image in every language, and on the observation the 3rd layer (0 indexed) always looks like a bike saddle, I had a little bit different challenge:

• Language must be capable of graphical output or drawing charts (saving files disallowed)
• Render a window or control that is resizable by mouse action. As example, it can be a typical GUI Window with the typical frame that allows resizing
• After resizing the GUI element, the fractal should be updated according to the new pixel space
• The fractal coordinates range from approximately -2-2i to 2+2i
• The pixels outside of the 3rd layer (0 indexed) of Mandelbrot set should have one color; the ones inside 3rd and inner layers should have another. The only two colors used should be clearly distinguishable
• At least 99 iterations
• ASCII art not allowed

Winning conditions:
Shortest version (size in bytes) for each language will get a mention in this post, ordered by size.
No answer will ever be 'accepted' with the button.

• @Mark Jeronimus: credits to you. May 27 '17 at 8:48

Here's a thing: Let's do the bignum bakeoff again.

Because why not.

### What to do

Write a program in less than 256 characters that outputs the biggest number you can.
Yep, that's it. Biggest return value wins.

We'll run the program on a VM with infinite memory. (How do we do this?)

### Rules

• 256 chars max, excluding whitespace
• Different leagues for each language
• Output however you want
• No explicitly printing numbers until your loop runs out. Print the number you generate directly. {1}
• Program must terminate
• No implementation-dependent shenanigans.
• Implementation-independent shenanigans is encouraged.
• ints are infinite.
• Program must return the same number every time
• Submission must include the approximate return value in any suitable googological notation.
• Whitespace is space, tab, newline, formfeed, and return
• BrainF***: Whitespace is all non-[]+-<> characters

{1} Allowed ways to return: printf("%d", num); return num;, etc.
Banned ways to return: for(;num>0;num--)printf("99999");, etc.

### This is not a dupe of...

This because you can put any characters you want, not just non-digits; because we're hard-limiting the characters.

### Suggested rules

• No floats: float double long double, etc
• No strings or chars
• No bitfeilds
• No looking at Command-line args

Next year's contest will be named after this year's winner, for no particular reason.

http://djm.cc/bignum-rules-posted.txt

### Sandbox

• How do you even test these programs?
• What other rules should we have?
• You don't actually explain the rules of the challenge, we would have to go to that link to find out what we are supposed to do. Aside from that, I think this has a lot of problems with your typing restrictions if these are not limited to C, but limiting it to C wouldn't really fit the spirit of the site. I think you may want to rethink how you want to approach this question. May 29 '17 at 16:43
• @FryAmTheEggman "Typing restrictions"? (Added proper instructions) May 29 '17 at 16:45
• Your post doesn't describe how people win. Is it by the largest possible number? Anyway, the problems are things like not counting whitespace, which can easily result in degenerate answers, as well as things like I/O streams and whatnot. All of your extra rules seem entirely based around C with no regard for other languages, which will not go well. May 29 '17 at 16:48
• In answer to "Because why not": because it will be closed as a dupe. May 29 '17 at 17:59
• Here's a couple of rules I would consider. 1. Program must generate the same result every time (e.g. not based on timer, probability, or the like). 2. Submissions should include, if not the exact resulting number, at least a best estimate, in scientific notation if need be. May 30 '17 at 18:32
• Scientific notation? People will post answers that far, far exceed that. In fact, Mathematica, 22: Fold[Power,2~Range~9999] It's 2^3^4^...^9999. That's not being represented anytime soon. May 31 '17 at 3:31
• This is a duplicate, and is also going to come down a lot to whether or not you allow programs that exceed the computational capacity of any existing computer. (If you require programs to work on a physical computer, the best they can possibly do is to use the entirety of memory as a counter and print out 9s over and over again. If you don't, the answers can easily be large enough that you need to use notation invented specifically for describing the number, because all other notations are not enough.)
– user62131
May 31 '17 at 22:40
• If your code can simulate a Turing machine, it becomes hard to judge who the winner is, and whether an answer is valid at all. Jun 1 '17 at 20:35
• Re your latest edit: you're wrong. The question it's a dupe of also has a hard limit to the number of characters; in fact it's a harder one, but the best answers could be copied with slight tweaking to take advantage of the extra space. And the digit restriction turned out not to be a serious problem: the winning answer would gain extremely little from being able to use digits. Jun 2 '17 at 9:07

# Do nothing

Write a program which terminates normally (not in an error), producing no output on the standard output stream (or the language's closest equivalent), nor on the standard error stream, regardless of what content is present on the standard input stream. (Note that this is intentionally overriding the normal I/O defaults; this is a challenge entirely about input/output handling.)

Additionally, your program may not have any other side effects (e.g. writing files, changing persistent state), unless they're an unavoidable consequence of running a program on the operating system you're using (e.g. on Linux, it's OK to change the "next process ID number to be assigned" value inside the kernel, because that happens whenever you run a program).

Finally, to avoid numerous uninteresting 0-byte (or boilerplate-plus-0-byte) solutions, you may not use a language in which the shortest program that does nothing (i.e. complies with the above specification) is also the shortest (or tied for the shortest) program which runs without error (but possibly reacts to input or produces output). In other words, you can't use a language unless doing nothing is more verbose than doing something.

## Clarifications

• Intentionally exiting the program early is permitted. If you do exit the program manually, on a system that uses exit codes, you may do so with any exit code.
• Crashing the program is not permitted, even if it (for some reason) exits with a "success" code after the crash.
• "No output" means 0 bytes of output, not even a trailing newline.
• Likewise, your program must be able to handle any finite sequence of bytes on the standard input stream, even if it isn't, say, made of characters in the current encoding (but rather of arbitrary octets). You do not need to handle infinite input, though (e.g. your program won't be connected to /dev/zero or the like).

## Victory condition

As a challenge, shorter is better, measured in bytes. (Remember that if you need to run the program in an unusual way, that incurs a byte penalty, under standard PPCG rules.)

Because languages which are particularly suited for this task (such as Perl and Python) are excluded by the rules, there's not much point in talking about the best answer cross-language; rather, the aim is to find the best answer you can in the language which you submit in. (Historically, on this sort of challenge, answers that are more unusual, interesting, or better-explained have tended to get more votes.)

## Sandbox questions

Is this too trivial? We were discussing it in chat as a joke, and realised that it's actually possibly more interesting than it sounds. I'm fairly sure the spec's correct (although would definitely appreciate knowing if something's wrong here!), but would appreciate feedback on how much people would hate me if I posted it to main.

• you can't use a language unless doing nothing is more verbose than doing something.you can't use a program unless your program is more verbose than any other program which does something. You must provide a shorter program which does something to prove your solutions validity.
Jun 8 '17 at 1:03
• @Adám: If you did that, people would just add a comment byte or two to create a program of the shortest possible length that was longer than a program that did something. That isn't particularly interesting.
– user62131
Jun 8 '17 at 1:21

# Draw an XBox

Here's an X:

\  /
\/
/\
/  \


And here's a Box:

+----+
|    |
|    |
|    |
|    |
+----+


So, for an XBox, just draw an X in a Box:

+----+
|\  /|
| \/ |
| /\ |
|/  \|
+----+


Your input will be a number (in any standard way) that will represent the size of the box. To output the above box, this could be the number of -/|\s (4), or the number of lines/columns (6), or even the intercept of the second diagonal (5) would be acceptable. (Don't ask me to accept the base256 encoding of the output though, as that's one of the many banned standard loopholes.)

Your program or function should then output (in any standard way) the XBox of the given size. If the \/s cross in the same character, place an X (as per Draw a big slash X). For example, here's an XBox three sizes larger than the one above:

+-------+
|\     /|
| \   / |
|  \ /  |
|   X   |
|  / \  |
| /   \ |
|/     \|
+-------+


This is , so the shortest program wins!

• in some obvious way unclear/subjective Jun 9 '17 at 16:35
• @MDXF 4 examples weren't sufficient?
– Neil
Jun 9 '17 at 17:04
• I'm just warning you that it could get closed for being too broad due to that statement. Jun 9 '17 at 17:05
• I agree with @MDXF Jun 9 '17 at 18:03
• @BetaDecay That's all very well, but I'm unclear as to what you want.
– Neil
Jun 9 '17 at 19:15
• Just a basic explanation of how scaling works. Some examples would suffice Jun 9 '17 at 21:32
– Neil
Jun 10 '17 at 0:42
• @MDXF Here's my problem. I just tried implementing this in Charcoal, and came up with Try it online!. As it turns out, to produce those example XBoxes I actually need sizes of 7 and 10, but I didn't want to penalise that choice of input just because I hadn't predicted that particular scaling.
– Neil
Jun 10 '17 at 13:42
• @BetaDecay If you still have any further input it would be appreciated.
– Neil
Jun 12 '17 at 12:06
• Related Jun 15 '17 at 11:57
• @KevinCruijssen Ugh, I even have an answer on that question... I guess the use of specific characters doesn't really sufficiently distinguish this one.
– Neil
Jun 15 '17 at 12:42
• @Neil Well, using /+x\ instead of just * does make it a bit trickier, but it's indeed a bit too similar imho. Jun 15 '17 at 13:11

# 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 Mod
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 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? 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. 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 Jun 10 '17 at 21:26
• @WheatWizard I allow now trivial solutions 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. Jun 11 '17 at 0:16
• @programmer5000 exists a limit of correct tags? 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 Jun 11 '17 at 11:48