# Sandbox for Proposed Challenges

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

Sandbox FAQ

## Posting

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

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

## Discussion

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

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

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

If you think one of your posts requires more feedback, but it's been ignored, you can ask for feedback in The Nineteenth Byte. It's not only allowed, but highly recommended! Be patient and try not to nag people though, you might have to ask multiple times.

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

## Other

Search the sandbox / Browse your pending proposals

The sandbox works best if you sort posts by active.

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

Get the Sandbox Viewer to view the sandbox more easily!

## Play RPS with 3 bits of memory

This is a rough draft for now, the specifics, presentation and title will probably be adjusted

In this game you will be building bots to play rock paper scissors against each other. Of course rock paper scissors is not a very interesting game, just pick one of the three randomly. Can't get better than that?

The first thing here is that, we will play a slight variation on the game which introduces a small amount of strategy.

But more importantly in this version we will be designing very simple bots. Your bot will not be able to pick things randomly, nor will it be able to simulate complex strategies, because your bots will have 3 bits of working memory.

## The game

Before we get into exactly how the bots will be made and what exactly it means to have only 3 bits of memory lets cover the game.

For each pair of bots we will play 48 rounds of RPS. In each round both bots will select a choice of Rock, Paper or Scissors. Rock beats scissors, paper beats rock and Scissors beats paper, if the two chose the same move they tie.

When you win you will receive points based on your play. If you win with scissors you get 1 point, if you win with paper you get 3 points, and if you win with rock you get 6 points. If you tie or lose you get 0 points.

Each bot will play every other bot and the bots will be scored on the number of points gained in total.

## The bots

Your bot will have 3 bits of working memory, that means at any given time it will have stored a number between 0 and 7. To decide what to play it will know two things

1. What it has in memory
2. The last move it's opponent made

Given those it should spit out

1. What move it wants to make
2. 3-bits to write into memory

This is so simple you don't actually need to write "code" to represent your bot. Your bot is really just a $$\8\times 3\$$ lookup table, plus a single move which it will make as it's first move. (We can assume that the starting memory is 0 without loss of generality)

And in fact you will submit your bots in this format as it makes it easy to verify your bot works and doesn't cheat.

## Sandbox

I like this challenge because it is

1. Completely deterministic who wins, to the point where you can, for small bot pool work out with pen and paper the scores.
2. It is basically language agnostic. No need to bother with JS.
3. There's basically no way to cheat. It's going to be really hard to exploit a vulnerability in the handler when you can't run arbitrary code.

I am a little concerned though that there might not be a whole lot to do? I'm not sure how much better one bot really can be than others. Obviously you can always take 1 bot and design a bot which plays perfectly against it. But I'm not totally sure how much a carefully arranged bot is going to do better than ones that are just a pile of random connections.

Turning the memory size up could improve this but the larger you make it the more complex each bot gets, and I think the fun is really in being able to hand tune your bot.

However I don't know what I can do to find out other than just post this.

• Seems bruteforceable Oct 17, 2021 at 18:40
• This is a unique challenge, and I think you could post it. If it doesn't work out, then we'll all know not to do it again (or an improved version could be posted later). If it does work, CGCC'll have a new kind of challenge, which would be great.
– user
Oct 17, 2021 at 18:57
• @pxeger There are 1333735776850284124449081472843776 machines possible. Brute forcing that would probably mean playing every machine against every other machine. It may be solvable, but I don't think it is feasible to brute force it.
– Wheat Wizard Mod
Oct 17, 2021 at 21:15
• I'd prefer to have rigid I/O (fixed I/O method and format) for KotH purposes. Or you could just say "write down the 8x3+1 possible outputs in a specific format". The barrier to post some bot looks pretty low, so I'd expect a large number of answers in the worst(?) case which would require some kind of automated controller. Oct 18, 2021 at 1:13
• @WheatWitch ah, I misread the challenge Oct 18, 2021 at 6:59
• @bubbler oh I absolutely will write a controller once the rules are nailed down a bit. Just because you can score this by hand does not mean it would not be very tedious
– Wheat Wizard Mod
Oct 18, 2021 at 7:40

So I am simplying to ^/a*b*/b*a*/[ab]*$. # Problem Given a slashes program that matches ^/a*b*/b*a*/[ab]*$ in POSIX BRE (i.e. below), determine whether the program halts or not.

## Format of program, if you are not familiar with POSIX BRE

program = "/" first "/" second "/" third
first = "" | first "a" | first first.b
first.b = "" | first.b "b"
second = "" | second "b" | second second.a
second.a = "" | second.a "a"
third = "" | third "a" | third "b"


# Constrains

In this problem every program's length is up to 153.

# Detailed rules

• Can be either a full program or a function.
• Standard i/o apply.
• Examples of input format
• a string of program
• three strings p,q,r when the program is /p/q/r
• integers p,q,r,s and a string t when the program is /a\{p\}b\{q\}/b\{r\}a\{s\}/t
• entirely as an integer (think of it by yourself)
• Examples of output format
• Standard loopholes apply.
• This is ; shortest code wins.

# Examples

Testcase generator 1

My noncompetive solution

///: no
/a//: yes
/ab/bba/aab: yes
/ab/bba/aaab: yes
/ab/bba/aabb: no


# Meta

• Were similar things ever done before?
• I am not even sure if this problem is solvable.
• Just thought there are answers if I clarify maximum length of input.
• Should I change the problem's genre to ? Would making a maximum length of the program be boring?
• /// is turing-complete, so this is not possible Apr 25, 2021 at 12:33
• Should we simplify it more?
– user100411
Apr 25, 2021 at 20:23

# Implement a BrainFlump interpreter

BrainFlump is the latest alternate memory model brainfuck-esque turing tarpit.

It operates on a memory model we call a "Dump", which is simply an un-ordered collection of integers, with a pointer indicating the current item to operate on. As it is "unordered", when moving to the next item, one is simply chosen at random (chosen uniformly between the items that are not the currently selected item) and the operation pointer is moved to that item.

## Commands

+   #Increment the item at the pointer
-   #Decrement the item at the pointer
:   #Add a 0 to the dump, and move the pointer to it
;   #Move the pointer to a random item that is not the pointer's current position
(   #Skip to the matching ) if the item at the pointer is 0
)   #Skip to the matching ( if the item at the pointer is not 0
,   #Read a single character from STDIN and push its ascii value to the dump
#This also moves the pointer to the new item
.   #Print the current item at the pointer modulo 127 as an ASCII character


## Other notes

• When the ; command is used if the dump contains only 1 item, a new 0 is pushed to the dump, and the pointer is moved to it
• The . command does not pop the item from the dump
• When the , command is used if STDIN has been exhausted, a new 0 is pushed to the dump, and the pointer is moved to it
• Any item in the dump who's value is 0 is not considered to exist, unless it is the item at the pointer, therefore to "pop" an item from the dump, you simply set its value to 0
• Nested loops are supported
• The random number generator used for the interpreter does not have to be cryptographically secure, but must chose with uniformity.
• BrainFlump does not support floating point numbers or negative integers. Attempting to decrement a number below 0 has no effect.
• The maximum value of an item in the dump is 255

## Examples/Testcases

### brainf**k emulation

++++++(;++++++++;-);.


This should output 0

### Explanation

++++++        #Increment the first item to 6
(             #While the item under the pointer is not 0
;         #Move to another item in the dump
#    Note the first time this loop runs,
#    this will insert a new item
++++++++  #Increment the new item by 8
;         #Switch to another item in the dump
#    Note there are only 2 items currently,
#    So this will switch to the only other
#    item, the one we initially incremented to 6
-         #Decrement the item
)             #Repeat the loop if the item is not 0
;             #Switch to the other item
#    Note this switches the pointer back to
#    The item we have been incrementing by
#    8 each loop
.             #Output as ASCII character


This is effectively a 6*8 operation, followed by an output, and is nearly identical to brainf**k's ++++++[>++++++++<-]>. program, which also outputs 0.

Note, however, that brainf**k-esque dump manipulation is only deterministically possible if there are never more than 2 items in the dump.

### Random output

+:++:+++:++++:+++++:;.


This will actually always output an unprintable character, however which character is output will be random each time, selected from: SOH, STX, EST, EOT, ENQ, ie ASCII characters 1-5. In a correctly implemented interpreter, this output should be uniformly random between the 5 possibilities.

### Explanation

+      #Increment first item to 1
:      #Add new item and move to it
++     #Increment new item to 2
:      #Add new item and move to it
+++    #Increment new item to 3
:      #Add new item and move to it
++++   #Increment new item to 4
:      #Add new item and move to it
+++++  #Increment new item to 5
:      #Add new item and move to it
#    Note this last item is added because ; will
#    always switch to an item that is *not* the
#    currently selected item
;      #Switch randomly to an item in the dump
.      #Output as ASCII character


To give a little more info on this, by the time the ; command is reached, the dump should look like this:

1 2 3 4 5 0
^


As ; always switches to a different item, the result will be the pointer at one of the non-zero items.

### cat

,(.,)


Nice and simple, and identical to brainf**k's cat program.

For scoring purposes, you should use this gist as input when testing.

### When will it end?

++++(,:+++++;++(;++++++;--):++++;---)


This program doesn't output anything, but runs for a non-deterministic amount of time.

### Explanation

++++             #Increment first item to 4
(                #Start loop
,            #Read char from STDIN to new item in dump
:+++++       #Push 5 to dump
;++          #Switch to random item in dump and add 2
(            #Start loop
;++++++  #Switch to random item in dump and add 6
;--      #Switch to random item in dump and subtract 2
)            #End loop
:++++        #Push 4 to dump
;---         #Switch to random item in dump and subtract 3
)


This one is a little tricky, as ; will never switch to a 0 (Remember items with a value of 0 are considered to not exist)

The inner loop will only exit if ;-- switches to a number <= 2

The outer loop will only exit if ;--- switches to a number <= 3

Due to the inherent randomness of the language, this should always terminate... eventually.

For scoring purposes, you should use the exact string Hello, World! as input when testing.

## Scoring

This is meaning the interpreter that on average runs the fastest, wins!

Scoring will be determined by running each of the 4 test-cases above 100 times, and determining an average runtime (due to the inherent randomness of the language, a high number of runs should be made to minimise anomalous results).

Then once you have an average for each testcase, sum the 4 times, and that is your final score. Lower is better

• I feel like a lot of time will come from the RNG, so better solutions might sacrifice some "randomness" for speed - You might want to standardise "randomness" Dec 22, 2021 at 3:42

# Schrödinger's cat program

• This is probably good to post now, and it looks like a good challenge! Dec 27, 2021 at 5:59

# Incrementally Increment Identical Integers

• Total rewording suggestion for everything up until before "To demonstrate": Given a non-empty non-descending list of any integers, increment each number by how many identical elements occur to its left.
Jan 1 at 18:16
• @Adám For what it's worth, I find that less understandable than the current description. It's probably a difference of APL mindset vs. Python mindset. Jan 1 at 18:18

# Remove odd indices and double the even indices

• The test cases are now consistent with the example explanation, but not with the "remove odd, double even" description. You could fix this by either changing this to "remove even, double odd", or switching to 0-indexing Jan 17 at 12:40
• It'd be nice to link the ITTM paper. Also, showing an example ITTM and explaining its halting time (like your ⍵×⍵ 2-state ITTM) would be helpful. May 7, 2021 at 12:39
• @user41805 I'm currently working on an explanation for my 2-state ITTM champion. But the animations are a bit time consuming. I meant to link some ITTM papers, so I will add those links when I finish the edit I am working on. Thanks.
– Wheat Wizard Mod
May 7, 2021 at 12:42
• Related: codegolf.stackexchange.com/q/36747/45613 and codegolf.stackexchange.com/questions/18028/… (This doesn't seem to be a duplicate) May 18, 2021 at 16:25

# Score a Scrabble Play

• I think removing the letter points mapping from the challenge as you suggest is a good idea. Otherwise a lot of the byte count will be taken up just in storing the map, with less of the answer being the interesting part, which is the scoring algorithm. Honestly it might even be worth assuming all letters score 1, because the interesting computational problem is really just detecting what the words formed in the grid are. Jan 24 at 20:53
• @pxeger I think I would like to keep the specific point values, so that the challenge still involves the words themselves somehow. Otherwise it would suffice just to find the distances between relevant tiles and certain empty squares as well as losing some (important, in my opinion) flavor. Jan 24 at 21:01
• That's a good point; I hadn't considered that the letters themselves would no longer matter in that case. I'd still recommend going for the version with points mapping as input. Jan 24 at 21:03
• Where do we get the word dictionary? Jan 24 at 21:08
• @GingerIndustries There is no need for a word dictionary. As I wrote in my post, answers do not need to consider the legality of the play. Jan 24 at 21:11
• please check if i have explained properly as some may not understand Feb 2 at 9:20

# Print 2^n graph in ASCII

Your challenge is to output this infinite graph:


o
o
oo
oo
oo
oo
ooo
ooo
ooo
ooo
ooo
ooo
ooo
ooo
oooo
oooo
oooo
oooo
oooo
oooo
oooo
oooo
oooo
oooo
oooo
oooo
oooo
oooo
oooo
oooo
ooooo
ooooo
ooooo
ooooo
ooooo
ooooo
...


with the xth line having floor(log_2(x)) os (or other characters). Tag: code-golf, ascii-art, kolmogorov-complexity.

• wow this looks interesting tbh, is there supposed to be a \n at the start of the sequence? Feb 12 at 13:48
• @DialFrost Yeah, because floor(log_2(1)) = 0. Feb 12 at 15:05
• nice, but is there a reason you chose o? Feb 20 at 10:55

# Is it a tower permutation?

• @pxeger I'll add a comment once I post this Feb 20 at 14:07

# Gambling with an Alien

Find the challenge here!

• Welcome to code golf and thanks for using Sandbox! Are wee allowed to implement less restrictive output requirement, i.e. using our default decision-problem rules (tag wiki)? - I suggest it over using two fixed strings (that not all languages can handle). Feb 28 at 19:43
• @pajonk That seems like a good change! I'll implement it. Feb 28 at 19:45
• Is trailing whitespace allowed? Mar 2 at 7:11
• This one is much better than the Stack Em one. Mar 2 at 8:40
• @pajonk do you think its better to allow or not allow? Mar 3 at 2:57
• I think I usually see allowing trailing whitespace in such challenges. Also, I'm always on the side of loosening I/O requirements. Mar 3 at 7:28

# Sorted strings filter

Input a list of strings a and a string s for search keyword. Find out all strings in a which contains s as subsequence. And sort them in the following order:

1. Exact equals to s
2. Starts with s
3. Contains s as substring (continuous subsequence)
4. Contains s as subsequence

## Detail

• When two strings belongs to the same group, you may sort them in any order you prefer.
• String matching is case sensitive. "A" and "a" are different characters.
• All strings will only contain printable ASCII (#32~#126).
• All strings will not have leading or trailing whitespaces.
• All strings will be non-empty.
• List a does not contain duplicate strings.

## Example

When the list is ["center","encounter","enter","enterprise","event"], and the search target is "enter", output should be ["enter","enterprise","center","encounter"]. "event" is not included in the output as it doesn't contain "enter" as subsequence.

## Test cases

["center","encounter","enter","enterprise","event"]
"enter"
-> ["enter","enterprise","center","encounter"]

["celebration","cooperation","generation","operation","ratio"]
"ratio"
-> ["ratio","celebration","cooperation","generation","operation"]

["combination","explanation","international","nation","national","nomination"]
"nation"
-> ["nation","national","combination","explanation","international","nomination"]

["ever","every","here","very","where"]
"everywhere"
-> []

"train"

["condition","confusion","construction","contribution","information","organization","recommendation","transportation"]
"onion"
-> ["condition","confusion","construction","contribution","organization","recommendation"]

["...","---",".-.-.-","..--","-..-"]
"--"
-> ["---","..--",".-.-.-","-..-"]

["#","##","###","####","#####"]
"####"
-> ["####","#####"]


Output from your program may be different from above test cases, as the order of words in same group is not required.

## Input / Output

Input / Output are flexible. For example, you may use any reasonable ways including but not limited to:

• You may I/O string as
• Your languages built-in string in ASCII or any ASCII compatible encoding (e.g. UTF-8);
• Your languages built-in string in any codepage that supports all printable ASCII characters (e.g. UTF-16);
• NUL terminated array of characters;
• array of integers, each integer is the ASCII value of character
• 0 terminated integer array;
• You may I/O the array of string as
• A collection (OrderedSet, LinkedList, Array, ...; or HashSet only for input) of strings
• A character (or ASCII value) matrix with 0 padding at the ending to each short ones;
• Output matrix may have unnecessarily extra 0 padding;
• Line break (CR / LF / CRLF) separated single string;
• JSON encoded array of string

Meta: Is this clear enough? Any duplicate? Will it be interesting enough to post?

• IMHO this would benefit from explicitly allowing or disallowing I/O as a list of char codes. Mar 9 at 13:10
• @pajonk Included. Will it be helpful?
– tsh
Mar 10 at 2:36
• this challenge is quite interesting imo, but the bolding of words in the description might be abit hard to see (idk if you want to change it or leave it uty) but otherwise gd job on the challenge details! Mar 10 at 2:44
• @DialFrost Do you mean the example section? IMO, the bolding may be ignored and readers may still understand the question without them. So I think leave it as is should be enough.
– tsh
Mar 10 at 2:55
• ah ok @tsh sry my bad Mar 10 at 2:59
• @tsh Yes, thank you. Mar 10 at 5:27

# Repeat List Until Longer

• I think the output for the last example should be [2,3,5,2,3,5,2,3,5]? Mar 9 at 0:26
• Ah yes, that was my muscle memory being a little off. Thanks. Mar 9 at 0:27
• Suggestion: instead of second list as input take only its length. Mar 9 at 13:13
• This problem is component of a solution for another problem. I prefer it like this. Mar 9 at 15:26

# The Missing Match

• The task becomes clear by the end but I think some reorganisation of the text would help. In the second sentence you say 'The braces are all balanced', but further down we find out that this isn't actually true: 'inside the string there is a single unbalanced brace'. I'd suggest these two bits of information should be closer together. Mar 13 at 2:26
• @Dingus thanks for the feedback. I updated the answer; would you care to take a look?
– code
Mar 13 at 3:25
• Looks good to me, but one other thing - I'd suggest brackets is a more appropriate word than braces here. Mar 13 at 6:29
• @Dingus sure, thanks! Do you suggest I post it anytime soon or wait another day or so?
– code
Mar 13 at 6:54
• The general recommendation is to leave it in the Sandbox a few days at least, just to maximise the number of eyes that see it before it goes on main. Mar 13 at 9:25

# Can you decrypt me?

## Cops

Cops, post obfuscated code that hides a number $$\n\$$ inside its code. If $$\n\$$ condchars are changed, the program outputs $$\n\$$. Otherwise, it outputs a different number. Both programs may not error.

# Robbers

Find the chars to change and what they should change into.

### Example

print(2)


N is 1.

Robbers' post:

print(1)


# Scoring

Cops, the user with the most uncracked posts wins. Robbers, the user with the most cracks wins.

• How could you stop robbers writes a code that try to apply cops code on every possible inputs until find out one matching output?
– tsh
Mar 16 at 11:22
• @tsh uh, can you clarify? Mar 16 at 11:51
• Does this mean robber just need to write a program that for (i in AllPossibleInputs) if (CopsCode(i) == CopsOutput) return i?
– tsh
Mar 16 at 12:28
• @tsh, is it possible to enforce "don't do that?" Mar 16 at 13:11
• This is a good format for a CnR, but you need to specify scoring criteria. For the cops, "shortest code" (code-golf) is probably good enough. For robbers, something like "most cracked answer". You should probably add a rule to allow uncracked cops' answers to become "safe" after a certain amount of time (probably around 1-2 weeks) Apr 12 at 9:01
• @pxeger does it need more clarifying and details? (other then scoring criteria) Apr 12 at 14:10
• No, if you add those things, it will be ok Apr 12 at 14:47

# What does the text talk about?

note that the machine-learning tag will be new

META: this is far from being done. I also understand that this challenge depends heavily on manual opinion about the "type" of a piece of text. Hence, if you take issue with that, I would appreciate your giving a comment that suggests ways to fix that issue, rather than an unjustified downvote related to that issue.

Additionally, this might be a duplicate. I would appreciate your pointing this out before I compile the list of texts, if possible. However, if you identify a duplicate after I start compiling the list of texts, that is also fine.

Some parts use the future tense to talk about what I will do. Obviously I will have done them by the time I post the challenge.

The sections in italic could be taken as being ambiguous.

The links to the training, validation and test sets are not available yet. And of course, I don't yet have labels on my side.

This is a project that I once attempted to do, having learned machine learning. I run a forum app, and I was thinking of incorporating my new machine learning knowledge into that app by creating a model that could detect topics related to a given topic. After having worked on it for a few days, I hadn't made much progress, so I abandoned it. I hereby challenge you to make a similar model, ideally with machine learning, but that is not required. Your model will classify the topic of a piece of text. Such a model could then be used to find text related to a given piece of text by finding texts with a similar topic. You can choose to write your model without machine learning.

This is thus essentially a machine learning challenge. (or ideally, it will be. You may choose to write your solution without machine learning, but I am mainly looking forward to seeing machine learning solutions.) I will provide a large set of "articles", divided into a training set, a validation set, and a test set, with a 60-30-10 split. I expect there to be about 500 articles in all.

The articles in the training and validation sets are labeled with their topics: for instance, history, geography, mathematics, programming, etc. The test set, importantly, does not have public-facing labels, but I have labels on my side.

The training set is available here.

The validation set is available here.

The test set is available here.

## Challenge

Write a classifier that attempts to classify the topic of a piece of text. The possible topics are:

(coming soon)

You can choose any of (coming soon) distinct values to represent the topic.

It should be able to produce an output that is one, and only one, of the chosen distinct values given any input string.

You have access to the train set to teach your classifier to recognize the topics (if you are using machine learning). The validation set can be used to compare different approaches.

Your submission will be scored based on how well it does on the test set. I will write the test set articles in such a way that they are not ambiguous (500 years ago, a mathematician discovered a method to calculate integrals is ambiguous as the sentence could be about mathematics or history, but Learn about the way people lived 1000 years ago is only about history). Your score is the number of articles it can correctly classify out of the test set. The higher the number of articles your submission can correctly classify, the better the score is. Thus the winner of this challenge is the submission that classifies the most articles correctly.

Importantly, this is not . I expect this to be a challenge that demands significant time and effort to produce a solution that scores highly, so you may post a link to a GitHub repository hosting the solution if required.

You are encouraged to either provide a way to easily run your solution, or provide the list of outputs that your code produces when given the test set articles. Even better, you could post a Jupyter notebook (if you are answering with a supported language) containing your solution, complete with test set outputs.

Important: please do not post a solution that is optimized only for the test set. It should work reasonably well in general.

Just so that you can get an idea of the topics:

Article: The dinosaurs went extinct 66 million years ago due to an asteroid impact.
Topic: history

Article: Time complexity is a measure of the complexity of an algorithm. For instance, the operation of adding two integers is usually taken to have a complexity of O(1). The operation of summing a list given as input has a complexity of O(n) where n is the size of the input.
Topic: programming

Article: Partial derivatives are derivatives taken with respect to one variable.
Topic: mathematics

Article: Planes are for going on holiday, especially island getaways.
Topic: holiday

Article: Carrot Cake Potato Mushroom
Topic: food

• [joke] mathematica probably has a builtin for this May 2 at 18:54

# Matrix Meets ASCII Art

• Is the input guaranteed to contain at least one 1? How should we handle all-0 rows? (will it ever be a case?) Are the 1s going to be always neighbours? I suggest adding some more examples/test-cases. May 9 at 11:05

# Haplololololololology!

• Suggested test case: aaaabaaaab -> aaaab, as a simple example of matching the longest sequences not producing the shortest result (which would be abab) May 4 at 1:22
• Thanks, added... May 4 at 1:27
• What about something like filed edit? May 4 at 5:45
• It would yield filedit - or were you suggesting I add it to the test cases? May 4 at 5:51
• Isn't mississippi -> missippi? May 4 at 12:55
• Awesome, thank you! May 5 at 1:40
• Edited down to a stub now that it's been posted to save space. May 13 at 4:04

# Straighten my corners... diagonally

• This is OEIS A060736. Sample Python copied from OEIS. May 22 at 23:14
• Cheesy title suggestion: straighten my corners... diagonally May 24 at 14:42
• @chunes That sounds great, thanks! May 24 at 19:33
• Also, you probably realize this, but the question doesn't currently have a score criterion. May 25 at 13:39
• @chunes Nice catch, thanks :) May 25 at 19:20

# The Magic Money Machine

This KOTH is based on a game of Tom Scott's series Money, so make sure to check out his video

# Challenge

There are three rounds per game. Each bot will get 100$. They'll have to decide how much money they'll keep for themselves, and how much they're going to put in the Magic Money Machine. The money in the Machine will get a 20% boost in the first round, a 50% boost in the second round, and a 100% boost in the third round. Each bot will equally get the money left in the Machine. ### Example: • Bot A decides to put 60$ in the Money Machine and keep 40$ for themselves • Bot B decides to put 30$ in the Money Machine and keep 70$ for themselves • In total there are 90$ in the Money Machine, so with a boost of eg. 20% that's 108$, so each bot will get an additional 54$
• Bot A has 94$ in the end • Bot B has 124$ in the end

You have to try to get as much money as possible.

## Rules:

• Standard Loopholes apply
• No interaction with the controller other than by returning values.
• No interaction with other bots

## API Template

def plan(round_num, others_money):
# Tell the other bots how much money you're going to put in the Machine
# You are allowed to lie
return money_insert_pub

def main(round_num, others_money, others_plan):
# Do stuff here
return money_insert

• round_num: an integer ranging from 1 to 3, it depicts the current round
• others_money: a list of 0, 1, or 2 tuples. Each tuple will contain the money_kept var of the other bots of the last rounds (yours incl.).
• money_insert_pub: the money_insert value you're telling others
• money_insert: an integer between 0 to 100, the amount of money you put in the Magic Money Machine
• others_plan: the money_insert_pub value of the other bots (yours incl.)

Controller code is on Github

## Example bots

### Beep Boopy Random

import random
def plan(round_num, others_money):
global money_insert
money_insert = random.randint(0, 100)
return money_insert

def main(round_num, others_money, others_plans):
return money_insert


### Random copycat

import random
def plan(round_num, others_money):
return 100

def main(round_num, others_money, others_plan):
if round_num == 1:
money_insert = random.randint(0, 100)
else:
money_insert = (
random.choice(others_money[-1]) if others_money else random.randint(0, 100)
)
return money_insert


# Meta

• This is my first (well sort of) KOTH, is there anything I've missed?
• Is the controller function written yet? You might want to link to it on Github. Jun 9 at 22:15
• @Steffan not yet :P Jun 10 at 8:19
• but now I'm done Jun 10 at 12:42
• It looks like the bot that never donates will always win because "Each bot will equally get the money left in the Machine?" Am I missing something? Jun 10 at 15:28
• @WezloOvOo damn maybe one sec Jun 10 at 15:34

# Give f and g that sometimes commute

• @WheatWizard, how's this? Jun 11 at 19:15
• Seems good. A little odd that when anonymous functions are only allowed for the separate submissions, but understandable.
– Wheat Wizard Mod
Jun 11 at 19:36
• What restrictions are there on the codomains of the functions? E.g. are $f(x)=\frac32 x$, $f(x)=i^x$, $f(x)=\frac1{x^2}$ valid?
– att
Jun 11 at 22:05
• @att by "over the integers", i mean that the domain and codomain are integers. i'll clarify. Jun 12 at 5:57
• You've specified these functions to act on all integers, but it may be annoying for answers to handle negative numbers and/or zero. Is there a reason you don't restrict the input to positive integers, or allow answers to decide which of $\{ \mathbb Z, \mathbb Z^+, \mathbb Z^* \}$ they handle? Jun 12 at 9:30
• @pxeger no reason! i think the extra flexibility is okay. i'll edit the question so that people can choose, but i think it's still reasonable to require the domain and codomain to be equal (because these functions should be composed). Jun 12 at 17:56
• Can I use builtins without explicitly declaring them? for instance, using $f(x)=\text{abs}(x)$, 0 bytes? Plus, why do I have to enter \\$ here...? Jun 13 at 0:42
• @NobodyNeedsNames at minimum you need to submit abs (like how other builtin submissions are) Jun 13 at 4:37

# Iteratively delete a list

• How does this have to do with polyglot? Jun 11 at 20:09
• @Steffan It's a program which runs on different versions of a library. So it's a sort of library polyglot.
– Wheat Wizard Mod
Jun 11 at 20:10
• If the Unicode handling library has an interface to determine which version of the Unicode database it uses, are we allowed to use that? Jun 12 at 15:21
• @pxeger I'm not sure if there is really any point in disallowing it since it seems unlikely that it would get you many votes.
– Wheat Wizard Mod
Jun 12 at 17:20