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

# Minimally destroy CGCC in Game of Life

• Just to clarify, you get an integer $n$ as input and must kill all but $n$ cells from the initial state to produce the shortest lived automata? Mar 22, 2021 at 17:44
• Are there performance requirements? This problem is in EXPTIME. Mar 22, 2021 at 17:45
• @Beefster No time requirements. And no, you decide how many cells you want to make alive (call that $n$) and which cells they are. You then run the game with those cells and the initial CGCC being alive until it reaches a point where all cells on the board are dead. Lowest $n$ wins. Mar 22, 2021 at 17:47
• Oh, I get it. You're supposed to add live cells around the initial CGCC so that the board eventually anihillates. The way you framed the challenge is a little confusing. You make it seem like you're supposed to remove cells from the initial configuration. Mar 22, 2021 at 18:02
• @Beefster I've edited the wording slightly, does it make more sense? Mar 22, 2021 at 18:05
• The wording is clearer now, but the issue is that "However, if we change the initial state to the following, by changing 13 cells, then, after 31 iterations, the board is empty" is sort of misleading because it prepares the reader to remove cells when you then say "And this is your task." I think it would be less confusing if you gave an example where adding cells to an initial state causes the pattern to eventually annihilate. Mar 22, 2021 at 19:20
• @Beefster The issue with that is that I don't actually have an example that fits the current rules :/ Mar 22, 2021 at 19:38
• You don't necessarily need to create an example that fits the rules. You could instead give an example of a simpler pattern that, when a few additional cells are made live, leads to eventual annihilation. So the overall flow of the challenge description would be something like this: simple pattern, simple pattern + live cells --> annihilation, CGCC pattern creates still life + oscillators, description of the task and scoring. Mar 22, 2021 at 20:02

# Posted

• Instead of saying that "Output is undefined if n<1, or if A is shorter than n" just specify that this won't be the case.
Mar 24, 2021 at 13:54

# Two Diehards Make a Glider

POSTED

• Is the WIP for the title or the challenge? The challenge looks mostly ok, but I'd be worried about having many solutions with the form: as simple as possible for the gliders with a well-known diehard placed far away. For the title, something like "gliders as emergent properties" or something could also be catchy. Mar 24, 2021 at 22:01

# Decode Polybus Square/Tap Code/Prison Code

• Nice challenge :) You need to add a scoring criterion (code-golf most likely), and you should provide a few input->output examples to help checking answers
– Leo
Mar 22, 2021 at 23:03
• Suggested testcases: 23 15 31 31 34 => HELLO, 24 25 31 32 => IJLM, 11 22 33 44 55 => AGNTZ. Add tags code-golf, decode and string. Mar 23, 2021 at 8:11
• Thanks for the feedback :) Mar 23, 2021 at 12:51
• I've edited this down to a stub now that it's been posted Mar 30, 2021 at 15:15

# Plz Halp I Need $Again Bob’s startup is running out of money and desperately needs investors to keep it afloat. Although you have helped Bob find the maximum number of investors, Bob has quickly realized that more investors does not lead to more funds because different investors give different amounts of money. Each investor interested in Bob’s company wishes to schedule a meeting with a certain start and end time, and promises to invest a certain amount of money. However, some of the meetings times may conflict. What is the maximum amount of money he can get from his investors? ## Input Format Input is given as an array of tuples of integers (or the equivalent in your chosen language). Each tuple p represents one investor, where p[0] is the start time of the investor’s meeting, p[1] is the end time, and p[2] is the amount of money promised. For example, in the test case [(0, 10, 30), (10, 20, 50)], there are two investors: one who wants to meet from time 0 to time 10 and offers$30, and one who wants to meet from time 10 to time 20 and offers \$50.

Meetings will always have a positive duration, meeting times are always non-negative, and a meeting that ends at time k does not conflict with a meeting that starts at time k. You may assume that the input is nonempty, and you may use any reasonable I/O method for input.

Within reason, you may also take input in different formats (for example, as three lists, one which contains the start times, one with the end times, and one with the money offered).

## Output

Your program should output an integer, the maximum quantity of money that Bob can make.

## Test Cases

[(1, 100, 10), (1, 5, 3), (5, 10, 3), (10, 15, 3)] => 10
[(0, 30, 40), (20, 45, 30)] => 40
[(10, 40, 40), (60, 85, 60)] => 100
[(65, 100, 70), (10, 45, 80)] => 150
[(10, 15, 50), (50, 85, 10), (95, 110, 60)] => 120
[(100, 135, 80), (50, 70, 80), (80, 110, 30), (95, 100, 40)] => 200
[(65, 95, 70), (50, 75, 30), (35, 60, 80), (85, 115, 100)] => 180
[(30, 35, 80), (35, 65, 10), (75, 110, 40), (40, 45, 20)] => 140
[(80, 110, 50), (0, 5, 30), (95, 125, 50), (80, 85, 70)] => 150
[(25, 40, 10), (100, 115, 60), (15, 50, 90), (60, 95, 50)] => 200
[(100, 125, 50), (75, 80, 100), (30, 60, 20), (50, 65, 90)] => 240
[(15, 35, 80), (55, 70, 40), (30, 65, 90), (30, 55, 60)] => 120
[(15, 40, 50), (60, 95, 30), (35, 40, 70), (55, 60, 90)] => 190
[(40, 65, 80), (40, 75, 10), (5, 15, 80), (100, 115, 80), (15, 35, 100), (60, 95, 40)] => 340
[(5, 30, 60), (85, 105, 90), (35, 65, 80), (90, 115, 40), (85, 90, 80), (30, 60, 90)] => 270
[(55, 65, 30), (5, 15, 90), (50, 85, 100), (0, 15, 90), (65, 70, 70), (60, 70, 80), (35, 55, 20), (80, 105, 80)] => 290
[(0, 10, 90), (70, 85, 80), (45, 55, 20), (90, 105, 90), (55, 90, 50), (0, 25, 20), (85, 105, 30), (85, 90, 100)] => 380
[(10, 45, 40), (85, 115, 80), (85, 105, 30), (30, 50, 50), (20, 40, 80), (100, 115, 60), (100, 135, 70), (30, 35, 70), (35, 50, 30)] => 180
[(80, 105, 70), (60, 65, 50), (95, 105, 80), (55, 65, 100), (40, 75, 80), (95, 110, 70), (60, 70, 90), (65, 70, 50), (55, 85, 100)] => 230
[(80, 85, 70), (35, 40, 60), (60, 80, 80), (5, 20, 100), (30, 60, 100), (45, 50, 60), (45, 80, 60), (10, 20, 50), (50, 65, 60), (60, 85, 70)] => 370
[(50, 75, 100), (90, 115, 20), (50, 65, 10), (35, 50, 30), (90, 120, 90), (65, 90, 30), (20, 55, 40), (50, 75, 50), (75, 105, 10), (15, 35, 70)] => 290


## Rules

• Standard loopholes are prohibited.
• Though not required, polynomial-time solutions are encouraged so that Bob does not have to wait forever for the result.
• This is , so the shortest solution in each language wins.

## Meta

• Are there any errors with the computer-generated test cases? I've manually verified some of them but I may have overlooked something.
• Is there any ambiguity in the problem statement?
• Are there any other issues?
• Test cases seems be ordered by end times. I'd suggest mixing them up (so no answer accidentally uses the order) or specifying the order. Also, in the example in the input format, it's (10, 20, 50) but you say they want to meet 5 - 10. (And I prefer the Output section before the test cases, so people know what they need to do earlier.)
– xash
Apr 28, 2021 at 12:51
• Thanks, I have edited the challenge accordingly Apr 28, 2021 at 12:55
• Is it possible to take input as three lists, for start times, end times, and prices? Apr 28, 2021 at 13:13
• Sure - should I add test cases in that format? Apr 28, 2021 at 13:16
• You don't need to add testcases in different formats, simply state in your post that different formats are acceptable (and perhaps mention some different formats like the $3$ lists @rak1507 mentions). Apr 28, 2021 at 13:41
• Link to the deleted main post, so that it's easy to find and edit when this challenge is good to go :) Apr 28, 2021 at 15:21
• I think I saw l4m2's proposal which is essentially the same thing, but this one is arguably much better and clearly worded. Btw, the first example is just a special case of Chaitin's constant with power-of-0.5 weights. May 12, 2021 at 14:16
• I don't see how it's possible, if $f(n)$ is computable, isn't the limit of $f(n)$ computable by the definition of limit? May 12, 2021 at 17:31
• @CommandMaster Actually no! This is just one of a million ways in which limits can be counter intuitive. For an example, imagine an $f$ where $f(n)$ just takes the first $n$ Turing machines and runs them for $n$ steps, if machine $m$ halts in the test run then you add $2^{-m}$ to a total (think about what this means in binary). This is obviously computable, we can simulate Turing machines for $n$ steps and add rational numbers. But the limit encodes the exact solution to the halting problem. This is actually the first example number there.
– Wheat Wizard Mod
May 12, 2021 at 17:48
• Does $f(n)$ have to be an exact rational (i.e. a pair (numerator, denominator)), or can it be represented as a floating point number? In other words, can we output $f(n)$ as a floating point number which will, necessarily, be inexact for large values of $n$, as long as the algorithm theoretically works if given arbitrary precision? May 12, 2021 at 20:30
• @Delfad0r I'm not entitled to answer your question, but I don't think float or double are applicable here. Arbitrary-precision floating-point numbers are certainly applicable tho. May 12, 2021 at 20:44
• @WheatWizard Thanks for the clarification! Does the first option include, say, a pair [numerator,denominator] (even though it's not a built-in rational type)? In this case, is the pair required to be reduced (i.e. gcd=1)? May 13, 2021 at 10:09
• @Delfad0r I will add that as another form, and the second format shows a non-reduced fraction as an example so it would be all right for this format as well.
– Wheat Wizard Mod
May 13, 2021 at 10:11

# Drop some boxes

• Assuming you live in a world with gravity Jun 20, 2021 at 10:07

# Ouput Input... Forever

## Problem

Given input chars, output them repeatedly forever.

## Examples

abc       -> abcabcabcabcabcabcabcabcabc...
[1, 2, 3] -> [1, 2, 3][1, 2, 3][1, 2, 3]...
lo        -> lololololololololololololol...


Dedication: This is for all the tarpits out there!

## Questions

• Should a delimiter be allowed?
• I was imagining that the input would be cycled through infinitely in order, like in the examples. Should we enforce that as a rule, though?
• Or should the rules just be: Each char of input should eventually occur infinitely many times in output. (Informally stated, but can easily be made mathematically precise.)
• Other thoughts!
• If you go with "Each char of input should eventually occur infinitely many times in output", then you'd need to specify that no other characters should be outputted because otherwise you could just output all bytes in order, or output random bytes infinitely Aug 6, 2021 at 7:24
• I think that vast majority of languages here will just use some version of x = input(); while(true) {print(x);}, so I doubt this will be especially interesting except for in a handful of languages Aug 6, 2021 at 13:49
• Are you going to post this? :) Aug 13, 2021 at 22:30
• Are you going to post this? It's been a month.... Sep 6, 2021 at 3:31

Create the shortest code snippet of the power functions 1 through 10 which can be compiled to assembly code and which contains the minimum number of imul assembly operations. For better comparison use https://godbolt.org/ and either GCC or LLVM.

## Introduction

Did you know the fastest way to calculate x⁴ is not x*x*x*x, but y = x*x; y*y which saves one multiplication and is therefore faster. In mathematics and computer science this is called addition-chain exponentiation.

The minimum number of multiplications for powers of 1 through 10 are

x^1  -> 0
x^2  -> 1
x^3  -> 2
x^4  -> 2
x^5  -> 3
x^6  -> 3
x^7  -> 4
x^8  -> 3
x^9  -> 4
x^10 -> 4


## Example

The assembly code looks as follows (C++ code below):

pow_1(int):
mov     eax, edi
ret
pow_2(int):
mov     eax, edi
imul    eax, edi
ret
pow_3(int):
mov     eax, edi
imul    eax, edi
imul    eax, edi
ret
pow_4(int):
imul    edi, edi
mov     eax, edi
imul    eax, edi
ret
pow_5(int):
mov     eax, edi
imul    eax, edi
imul    eax, eax
imul    eax, edi
ret
pow_6(int):
mov     eax, edi
imul    eax, edi
imul    eax, edi
imul    eax, eax
ret
pow_7(int):
mov     eax, edi
imul    eax, edi
imul    eax, edi
imul    eax, eax
imul    eax, edi
ret
pow_8(int):
mov     eax, edi
imul    eax, edi
imul    eax, eax
imul    eax, eax
ret
pow_9(int):
mov     eax, edi
imul    eax, edi
imul    eax, eax
imul    eax, eax
imul    eax, edi
ret
pow_10(int):
mov     eax, edi
imul    eax, edi
imul    eax, eax
imul    eax, edi
imul    eax, eax
ret


One naive solution written in C/C++ and compiled with X86-64 gcc 11.2 and -O3 optimization on https://godbolt.org/ could be (Notice that I didn't need to optimize the code myself, but the compiler picked it up automatically. Aren't compilers awesome?):


int pow_1(int num) {
return num;
}

int pow_2(int num) {
return num * num;
}

int pow_3(int num) {
return num * num * num;
}

int pow_4(int num) {
return num * num * num * num;
}

int pow_5(int num) {
return num * num * num * num * num;
}

int pow_6(int num) {
return num * num * num * num * num * num;
}

int pow_7(int num) {
return num * num * num * num * num * num * num;
}

int pow_8(int num) {
return num * num * num * num * num * num * num * num;
}

int pow_9(int num) {
return num * num * num * num * num * num * num * num * num;
}

int pow_10(int num) {
return num * num * num * num * num * num * num * num * num * num;
}


Of course you can also use other language like Rust to create the same assembly code:

pub fn pow_9(num: i32) -> i32 {
num * num * num * num * num * num * num * num * num
}


(Note Rust has an additional mov, but the challenge only focuses on the amount of imul assembly instructions.)

example::pow_9:
mov     eax, edi
mov     ecx, edi
imul    ecx, edi
imul    ecx, ecx
imul    eax, ecx
imul    eax, ecx
ret


## Scoring

• The string must be compilable to assembly instruction with a compiler like GCC or LLVM (Note they have backends for many languages). You are not allowed to create the assembly instructions directly. Please also provide compiler version and flags.
• The whole string must be written in the same language (no writing C with another language)
• Out of bounds issues must not be considered, the code should work for integers 0 through 3.
• The generated assembly code can only contain the minimum number of imul needed for that power and mov and ret instructions
• The 10 functions in the assembly instructions should be named as I named them (order does not matter)
• Shortest string wins!

Good luck!

## Discussion

I've mistakenly posted this as a question to the meta site, but wanted this was my intended destination. After a few migrations the current location is here. I've now reposted here trying to keep the style the same as I couldn't edit the post anymore.

Grain ghost has made two comments on how to improve the challenge:

• "Creating the assembly instructions not via a compiler is not allowed" and "The generated assembly must be similar to the provided assembly" strike me as not particularly clear, objective or enforceable
• Since we are dealing with assembly I would expect some discussion about precision and out of bounds issues

Thank you!

This is not a typical code golf challenge, but I'm very excited what kinds of meta programming techniques will show up.

• @grain-ghost do I ping you this way? What I want to prohibit with the use of a compiler is that people simple create a program creating the assembly instruction string. The string must be compilable with GCC or LLVM. Similarity is hard, because compilers are weird (see my Rust example). May be say: The binary must contain the right number of imul instructions, at most two additional mov instruction and one ret instruction. Precision is no important with integer numbers as far I can think. Overflow is an issue, but I would simply neglect that case or restrict to numbers below or equal to 3. Nov 16, 2021 at 20:54
• If nobody's said it so far, welcome to Code Golf! This looks like a great challenge. For out of bounds issues, there's usually one of two approaches challenges will take, either having a minimum input size that must be supported, or just ignoring out of bounds issues within reason. Those would probably both work here, so it's entirely up to you. I agree with the two bullet points Grain Ghost brought up, those could probably use some clarification. Nov 16, 2021 at 21:06
• Thanks for welcoming me! :) I've updated the challenge. By restricting the amount of assembly instructions the submission must use imul (another feedback brought up to use for loops with addition) and guarantees similarity, because there is no other way to solve it. Another idea I had would be to only allow mov, ret and imul instructions. Nov 16, 2021 at 21:24
• Oh, so you're aiming to restrict what instructions can be used? That makes sense, I hadn't understood the wording right. You can definitely just choose a specific list of instructions to allow, which I'd recommend doing instead of the current requirements which are a little bit vague. There's actually a tag for that sort of thing, atomic-code-golf. Nov 16, 2021 at 21:27
• (Comment migrated from the original question.) In addition to what was already pointed out on the main site, another potential issue with this challenge is that it's entirely possible to do it without any imul, for instance with inefficient addition loops. Nov 16, 2021 at 21:32
• I've updated the challenge accordingly I think limiting to imul (minimum number), mov and ret ensures similarity. I would like to encourage entries from many languages. Can I pick a winner per language? Nov 16, 2021 at 22:04
• We have a challenge on a similar topic Shortest Addtion Chain. This challenge looks different enough though.
– xnor
Nov 17, 2021 at 2:00
• I might not be the target audience as someone not into compiled languages, but the needing to go through a compiler strikes me as convoluted. What if we could just output the assembly, or some other representation of the sequence of operations? Needing to consider how a compiler would translate and optimize the operations seems finicky, but I guess maybe that's the whole point.
– xnor
Nov 17, 2021 at 2:06
• @xnor exactly the best solution will probably involve some kind of metaprogramming massaging the code so the compiler will optimize it. I've updated the challenge again with info about naming the functions. Can the challenge be posted now? :) Nov 17, 2021 at 7:00
• @JulianWgs It's your decision, but the general recommendation is to leave posts in the Sandbox at least 72 hours to gather feedback. I'd err on the side of waiting for this challenge because it might benefit from being seen by more people with knowledge in this specific domain and many people don't look at the Sandbox that often. I'd also suggest confirming with existing commenters that your edits have addressed their comments.
– xnor
Nov 17, 2021 at 7:06

# Open or close?

Posted here.

• The calculator would be more useful if ) were followed by ) assuming another unbalanced ( remains. Example: "1*(2+(3*4)" -> ? Nov 15, 2021 at 23:24
• @aschepler Good thing the calculator dev thought this through more than I did, because that's exactly what it does. I'll update the question, thanks! Nov 16, 2021 at 8:11

# Convert prefix to infix

• Dupe? Nov 18, 2021 at 23:09
• @Dingus Yes, I'll just do prefix to infix instead :P Nov 19, 2021 at 3:31

## Summary

Given a chess knight K that is only allowed to step on permitted tiles X, output the minimum number of . tiles that must be changed to an X tile in order to permit a passage to the destination D.

## Specification

• The chessboard is guaranteed to be larger than 3x3.
• The chessboard is guaranteed to have one and only one D and K in it.
• Sometimes, not using the existing X tiles can lead to a more minimal solution, so please take this in mind while solving this challenge. (e.g. the 2nd testcase)

## Test cases

..D.
XXXX
....
...K


Output = 1 (sequence = (-2,+1), (+1,+2))

.D..
....
..XK
....


Output = 2: (sequence = (-2,+1), (-1,-2), (+2, +1), (-1, +2))

D.X
...
...
...
..K


Output = 1: (sequence: (-1, +2), (-1, +2))

DX.
...
...
...
..K


Output = 1: (sequence: (-1, +2), (-1, +2))

D.X.
....
.X.X
.K..


Output = 0: (sequence: (+2, +1), (-1, +2), (-1, -2), (-1, +2))

DXXX
XKXX
XXXX
XXXX


Output = 0: (sequence: (+1, -2), (+1, +2), (-2, +1), (-1, -2), (+2, +1), (-2, +1))

• where is the D on the board and what is the W doing on the board Jan 26 at 7:08
• @DialFrost That's a typo. Fixed
– user110579
Jan 26 at 7:10
• i like this challenge otherwise! Jan 26 at 7:15
• @DialFrost Thank you! :)
– user110579
Jan 26 at 7:22
• May we assume that using existing X tiles leads to minimal solution or may there be "traps"? Jan 26 at 8:08
• May you give an example of not using the X tiles leading to the minimal solution?
– user110579
Jan 26 at 8:12
• I mean e.g. DX./.../.../.../..K, where putting X in the middle is sufficient and you don't need to reach the existing X. Jan 26 at 8:12
• @pajonk In this case, I think I'm trying to define a challenge that allows "traps" in the input. I'll clarify that in the challenge.
– user110579
Jan 26 at 8:14
• I've edited my example in the meantime to highlight its "trappy" nature. You may also want to add more test-cases (like with more Xs or where the ouput is 0). Jan 26 at 8:18
– user110579
Jan 26 at 8:27
• your first test case is wrong, you can do it in 1: (-2,+1), (+1,+2) Jan 26 at 14:06
• @thejonymyster Fixed
– user110579
Jan 27 at 4:57
• suggested testcase: one where the straight path to the goal takes more X tile placements than following a longer route to the goal which already has many X tiles. Either way though, this is pretty much ready to post Jan 28 at 14:13
• May I assume the board is less than (or equals to) 8x8?
– tsh
Jan 29 at 8:15

# Is it a fibonacci-like sequence?

• input will be increasing... meaning first number>=next number?. Else i like the idea! Feb 16 at 8:51
• @DialFrost I suggest you look in the dictionary Feb 16 at 8:52

# Fibonacci triangle

• this is more of a curve due to the incrementing length of numbers :P looks alright tho Mar 2 at 3:47
• @DialFrost Close enough, and I wasn't sure what else to call it :P Mar 2 at 3:48
• i think the test case for 20 is wrong, the first 1+1=2 and 1+2=3 dont align Mar 2 at 3:48
• @DialFrost Fixed, that's an error with my programming Mar 2 at 3:51
• suggestion for title qns: Fibonacci curve (cuz triangle has no application to this qns lol) Mar 2 at 4:17
• Is infinite output allowed, taking no input? (part of standard sequence rules) Mar 2 at 10:17
• @pxeger Sure :P - no outputting the nth term though, as I feel that makes the challenge too easy. Mar 2 at 19:03
• @emanresuA Yes, I was thinking that as well. (although calculating the increasing string lengths might be complicated?) Mar 2 at 20:09

# Convert between graph representations.

• Awesome challenge! It seems ready to me and juding by the upvotes (might wanna wait 1 or 2 more days) Mar 21 at 11:00
• @DialFrost already posted .... Mar 21 at 12:21

# Satisfy as many people as possible

Posted here.

• im confused but nice challenge! :D Mar 14 at 2:50
• Wow, good challenge! They should use this for making servant robots; they'd make everyone as happy as possible :-)! The only part I didn't understand was the math formula; but, since I don't even know what the giant E means, that's not surprising. And as for title suggestions, something a little more catchy would be nice. Maybe something along the lines of "How many people can you satisfy?" (that's just a suggestion; I'm not very good at creative writing) Mar 22 at 19:37

# Storing a band matrix

• Can you clarify in the definition that a band is symmetric (in terms of shape) about the main diagonal? Something like "the main diagonal and an equal number of adjacent diagonals on either side of it"
– att
May 9 at 23:02
• Wait never mind, somehow I missed the "in this challenge" further down
– att
May 9 at 23:04

# BitCycle Metagolf

• Since undefined behavior can have an effect on how small you can make a BitCycle program, I'd say you should either pick a specific implementation and say all answers must work on that implementation, or say that answers are allowed to work on any existing implementation. May 14 at 17:47
• @DLosc Okay, I will put in that it has to work on TIO. May 14 at 18:13

# Spend maximal money

• For 10.00; [5,5,10] is [5,5] an ok output? What should be the output for 10.00; [1,2,5,5,7] (and why)? Suggestion: keep the challenge within positive integers. May 9 at 11:15
• @pajonk I prioritized choosing items from left to right. May 9 at 22:22
• You may want to alter the new examples to comply with your spec ("without equaling"). Also, does the order of the output matter ([12.99, 0.99] vs [0.99, 12.99])? I also suggest explicitly stating that $l$ is an ordered list. May 10 at 9:06
• @pajonk YOU were the one how made me thought those were the correct answers, but ok. May 10 at 11:26
• and no, it will not be an ordered list. the output also doesn't matter. May 10 at 19:03
• If the input is not ordered, hot do we determine left-to-right? May 10 at 19:31
• aw damn you have a valid point lemme fix that May 10 at 22:16
• Your last example has an incorrect output. The answer should be [2.00, 7.00] May 12 at 23:31
• @jezza_99 fixed. May 13 at 0:03
• You say that you want to prioritize choosing items from left to right. For the examples you have given, this only results in an ordered output, which you've said is not important. The actual possible solutions do not change. I recommend either adding an example to test this criteria or dropping it. A suitable example would be budget=10.00, prices=[1.00, 2.00, 3.00, 4.00, 8.00]. This should output [1.00, 8.00] even though [2.00, 3.00, 4.00] is also a potential solution May 13 at 1:03
• @jezza_99 i'm sorry but you've broken my brain. I'll just leave this here to rot May 13 at 19:06
• @BowlingPizzaBall what is the point of the rule "Prioritize choosing items from left to right"? May 13 at 22:59
• @jezza_99 Guess you could say there is no point. I'll remove that rule May 13 at 23:11
• @jezza_99 I thought this rule was to make the solution unique. Now (as in your example above) there may be multiple solutions. May 14 at 15:31
• @jezza_99, yeah, prioritizing left to right means there is only 1 valid solution. May 14 at 16:47

# Generate a Baudot punched tape segment

## What is Baudot?

From Wikipedia

The Baudot code [boˈdo] is an early character encoding for telegraphy invented by Émile Baudot in the 1870s. It was the predecessor to the International Telegraph Alphabet No. 2 (ITA2), the most common teleprinter code in use until the advent of ASCII. Each character in the alphabet is represented by a series of five bits, sent over a communication channel such as a telegraph wire or a radio signal. The symbol rate measurement is known as baud, and is derived from the same name.

For this challenge, your task is to write a program or a function that takes a string as its input and generates ASCII art that looks like a roll of punched tape. For the purposes of this challenge, you should specifically use the following variant, as it just happened to be the first image I found :P

For example where input is "HELLO WORLD\r\n" (note that carriage return is optional)

 *    *
**  * **  *
.............
*    *  *
*  *   *
* ***  *  *
hello worldcl
rf


## Program Description:

• The program/function takes the input and turns it into a sequence of Baudot words (sequences of five bits)
• For each word, it makes a column of the first two bits, then a . then the remaining three bits
• Optional trailing space / newline

## Criteria:

• Output may not be output as an array unless there is no other valid option in the language. Trailing spaces and newlines allowed.
• Any acceptable input
• Assume all input characters are valid Baudot characters
• No need to specify standard loopholes and I/O, they apply by default. You also override standard I/O with your third rule, so not much of a point to linking to it. Jun 7 at 21:12
• The Baudot code comes with the ability to switch between two modes (one for letters and one for figures). You'll have to clarify if we need to support that and how. Jun 12 at 20:41

# All$$\^{\dagger}\$$ 3-character expressions

$$\^{\dagger}\$$with some exceptions

In your golfing language of choice, given no input, output all valid 3-character expressions in that language, with the conditions described below.

An expression, for the purposes of this challenge, is a string of characters that can be evaluated to some result. An example of an expression in many languages is 1+2, which evaluates to 3. If evaluation causes an error/exception/crash (e.g. 1/0 in Python), then it should not be printed.

Expressions can also have side effects (modify the state of the program), e.g. y=2 in Ruby. These are allowed to be output but are not required. (In other words, you only need to print out referentially transparent expressions.) Similarly, any expressions that rely on the evaluation of previous expressions, e.g. a+2 (which requires that the value of a be set), are optional, unless they cause an error/crash, in which case they should not be output.

• White space and comments do not count as part of an expression - e.g. 2  or 2#a in Python are one-character expressions, so they shouldn't be printed.

Any language that does not have the concept of expressions, or has no expressions that are 3 characters long meeting the above requirements, cannot be used for this challenge.

As per usual code golf, the shortest program (in bytes) wins.

## Sandbox Questions

(This is my first challenge, so I don't really know what I'm doing, and feedback is greatly appreciated.)

I'm not sure how to deal with expressions that change the results of other expressions or change what counts as a valid expression, particularly in the case of side effects. For example, if in the language, evaluating any expressions causes an "answer" variable to be set, then all expressions have side effects and the challenge is moot.

I was considering having the condition for passing be "Your program satisfies the challenge if, after running, there are no other expressions you can evaluate.", but I'm unsure if that's a good requirement.

• Nice challenge! However, bonus challenges are generally discouraged when writing challenges, so either remove the bonus, or make it another challenge. Jul 12 at 20:34
• Jul 12 at 21:38
• Might it be possible to generate programs instead of expressions for languages that don't have expressions? Also I think, that you can use code-generation tag.
– Jiří
Jul 12 at 21:43
• @Jiří I think that is a meaningfully different request from generating all expressions -- it could probably be a separate challenge. Jul 12 at 22:15
• @thejonymyster It doesn't lead to any footnote -- it's just indicating that there are some exceptions to the word "all" (the same way that "with an asterisk" means "some exceptions apply"). It's probably unnecessarily confusing though -- I'll change it. Jul 12 at 22:18
• I'm still concerned about how exactly to define "having side effects" -- does anyone have a better idea of how to deal with that? Jul 12 at 22:21
• Does having side effects also include printing or reading input? Also I have found following Wikipedia page which talks about expressions. Which led me to Wikipedia page about Referential transparency which had following sentence which might be the thing you are looking for: An expression is called referentially transparent if it can be replaced with its corresponding value (and vice-versa) without changing the program's behavior.
– Jiří
Jul 12 at 23:00
• The thing is, some languages don't have something called an "expression", like golfing languages (and others). In that case, do we just output valid programs? Jul 13 at 2:04
• @Steffan I mentioned that in the description: "Any language that does not have the concept of expressions, or has no expressions that are 3 characters long meeting the above requirements, cannot be used for this challenge." Jul 15 at 18:30
• What is the definition of "expression" in regards of comments? Is it allowed to output strings that include comments? (e.g. 3#2 in python) Jul 15 at 18:39
• @Steffan Hm, I'd say that's a 1-character expression with a comment, so by the rules above it shouldn't be printed. But that's not a strong conviction on my part. Jul 15 at 18:58
• Also, is it allowed to print things with whitespace, e.g. " " or " 2"? Jul 15 at 19:08
• Also, can random warnings be spouted to stderr? Jul 15 at 19:11
• @Steffan Thank you for asking these questions :) I'd also say that white space isn't part of the expression, except in obvious cases - e.g. the expression representing the empty string " " -- so it shouldn't be allowed. For the second point: I think I'll say that expressions generating errors that don't stop execution of the program are allowed, so yes. Those expressions probably shouldn't be required to output though (?) Jul 15 at 19:25
• For the warnings, I can actually disable them with a flag (like -W0 in ruby), so it's fine either way. So as far as spaces, " 2" isn't allowed, I guess. And - 2 isn't allowed either, I guess? Welp, this is going to add some bytes lol Jul 15 at 19:47

# Divisor of a string

• May we assume the input string has positive length? Aug 10 at 8:31
• @pajonk yes, you can Aug 10 at 9:31
• You may also want to specify what to expect within the string (letters, whitespace, special characters?) - I suggest only lowercase letters. Aug 10 at 11:25
• Can the output have duplicates? Can it be in any order? Aug 10 at 21:30