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

# Runs of Ones (What Fun!)

• Not sure if only on my browser: Width of ✓ and number are different. So last ✓ is under ] instead of 9.
– tsh
Jul 26, 2022 at 5:55
• Apparently, the monospace font doesn't include Unicode characters, oh well Jul 26, 2022 at 14:47

# Remove redundant parenthesis

• Tags: balanced-string, string Jul 25, 2022 at 23:36
• If there never will be an empty pair, you probably shouldn't give (abc((123))()) as an example. Aug 1, 2022 at 14:19

# A better Hexagony template

• 4000th answer to this question, hooray Aug 10, 2022 at 12:58
• "For convenience, define $a(0)=0$ (for zero-sized grid)." $a(0)=3\times0(0−1)+1=1$ though. Does the $n=1$ output have to be *, or are we allowed to output . instead as well? In terms of output it doesn't really make sense, but for the formula it does (and it would save me 2 bytes in my prepared solution 😅). Aug 11, 2022 at 11:40
• @Kevin I meant size 0 grid has zero spots and size 1 has one, but now that I think of it, I don't know if Hexagony interpreter special-cases empty code or it just treats it as size 1. Something to think about... Aug 11, 2022 at 14:02
• @KevinCruijssen I decided to allow both :) Aug 11, 2022 at 22:56

# CGCC Rocket Biking

• Suggestion: Split it to two challenges (validating and generating instructions). Mar 27, 2022 at 18:00
• Good challenge! Just one question: what does may not save the input while reading mean? Does "save" just mean saving to a file, or does it include variables too? In some languages, it would be impossible to do anything with input without saving it somewhere, even if not in an explicitly named variable. Mar 27, 2022 at 18:02
• @pajonk That's a good idea, thanks! Mar 28, 2022 at 12:22
• @SylvesterKruin I think the idea behind that could also be written as "The program may not work on more than one character of the input at any time.", i.e. reading the entire input bit-by-bit into a var and doing transformations on that isn't allowed. I used the wording from the file directly, which wasn't a good idea as it is rather lacking in other places too. Mar 28, 2022 at 12:23
• this does seem like an interesting challenge! I do think the while thing about only reading the input once is A) confusing and mostly unnecessary, and B) kinda against the meta consensus against unobservable requirements. The code obviously takes a single text string in somehow, but what it does with that is not controllable. Also seconding the suggestion to split this into two challenges/get rid of one of them, as determining whether it is possible is a different matter from determining how to precisely stop at the end Apr 3, 2022 at 1:08
• Not a comment on the challenge itself, but I like the four-state CnR system! Aug 8, 2022 at 11:21
• Does the cop reveal which of the 4 programs satisfy which of the criteria 1-4? Aug 8, 2022 at 11:39
• @pajonk Yes they should. I'll edit it to make it clear.
– Wheat Wizard Mod
Aug 8, 2022 at 11:39
• @UnrelatedString I have a feeling this is equivalent to "standard" CnR, where to become safe you need to reveal your language (or other features the challenge is about) - or are there some differences I missed? Aug 8, 2022 at 11:42
• @pajonk In a normal CnR if a robber ever gets your answer you cannot score. However here your answer is cracked after 10 days you still get to score your answer. On a lot of CnR's people will delay the reveal to give robbers an extra chance, this ruleset allows you to do that without having to sacrifice your score.
– Wheat Wizard Mod
Aug 8, 2022 at 11:45
• @WheatWizard I get it now, thanks! This indeed makes more sense. Aug 8, 2022 at 12:16
• Requiring that languages can run on FreeBSD seems unnecessarily restrictive to me, it being a pretty niche OS in the grand scheme of things. Aug 15, 2022 at 16:15
• @pxeger The idea is that if it is Free, and runs on both linux and freeBSD it is very likely to run everywhere. And users should be able to sandbox either linux or freeBSD. It also doesn't seem like a very high bar to cross actually. If you can find a language that can't be run on freeBSD but has otherwise wide support that would make a compelling case.
– Wheat Wizard Mod
Aug 15, 2022 at 17:52

# Quantise a list code-golfarray

In music production, quantisation is the process of "aligning" recorded notes to the beat, to remove the variability caused by imprecise human playing.

In this challenge, we will implement an abstract and approximate version of quantisation, representing notes as runs of positive integers, and using zeroes to represent gaps. The "beat" will be defined as every second note, starting with the first (even indices, 0-based).

Given a list of non-negative integers, insert or remove zeroes such that every run of non-zeroes begins on an even index (using 0-based indexing).

Runs of non-zeroes may not be split or joined together if they weren't already in the input. In other words, a zero cannot be inserted or removed if it only has non-zeroes next to it.

The minimal number of insertion/removal operations must be performed. If a removal is possible, it should be preferred over an insertion.

## Test cases

todo

blah blah code golf rules

• Removal of double negatives: "No runs of non-zeroes may be split..." -> "Runs of non-zeroes may not be split...", maybe also "...zero cannot be inserted or removed if it only has non-zeroes..." -> "...zero can only be inserted or removed if it has at least one zero..." Aug 30, 2022 at 17:24
• The latter conversion is incorrect, because [0, 3, 4] can become [3, 4] because the zero has an end-of-the-list next to it rather than a zero. I agree this could be clearer though Aug 30, 2022 at 19:28
• that's not supported by the current phrasing either: "a zero cannot be inserted or removed if it only has non-zeroes next to it". If that zero can be removed, you're saying it has something other than non-zeros next to it, which means you're saying that either "end-of-the-list"s or 3s are zero. Addendum: my head hurts Aug 30, 2022 at 19:34
• @thejonymyster My head hurts too and now you see why lol. The way I drafted this in my head is slightly different from how I wrote it down, which doesn't help Aug 30, 2022 at 19:38
• Maybe instead of splitting / joining runs, just say the number of runs of nonzeros cant change between input and output. That handles the 0s on the ends situations too and is probably simpler Aug 30, 2022 at 19:41
• I mean, the first sentence (before "in other words") explains it pretty well already. Maybe I should just remove the second rephrasing. Aug 30, 2022 at 19:45

# Use "e" or a suffix?

## Background

In Māori (the indigenous language of New Zealand), to make a verb a command the verb is either preceded by "e" for example, "oma" (to run) -> "e oma", or, it's given a passive ending to make it a passive verb for example "kōrero" (to speak, talk, say, etc) -> "kōrerotia".

Besides some edge cases with intransitive verbs and different dialects, the rule is that if the verb has exactly two short vowels or one long vowel (which have macrons over the top of them like "ā") then the verb is preceded with "e" otherwise it is given a suffix.

## Challenge

Your challenge is to determine whether which case a verb fits in to. If it should be preceded by "e" output a truthy value, otherwise output a falsey value.

## Rules

• You can assume that all the input will be lower case.
• You may not take input with combining diacritics.
• Because there are very few, if any verbs in Māori with only one short vowel, and the fact that what happens in that case depends on dialect, you don't need to handle those cases.
• This is so the shortest answer wins.

## Test cases

ako -> true
kai -> true
haere -> false
tū -> true
āwhina -> false
kōrero -> false
huri -> true


## Meta

• Thoughts on the combining diacritics rule?
• Are there any other rules that should be added?
• Maybe add a test case with a single short vowel? (Or if there are no actual mono-moraic verbs, consider including in the spec that such an input doesn't have to be considered.) Jul 25, 2022 at 7:27
• @UnrelatedString I was thinking about that, I haven't been able to find any verbs with one short vowel, but I just can't be sure that there are none so I'm not really sure what to do about it. Jul 25, 2022 at 7:40
• Fix your link! (It's the second one.) Aug 30, 2022 at 23:26
• @Laurel Ah, thanks. I'll replace it with a new one. Aug 30, 2022 at 23:29
• Tag: decision-problem Aug 31, 2022 at 1:26
• You should also probably specify that it has to be exactly two short/one long, and the cases are mutually exclusive -- e.g. say "...the verb has exactly two short vowels or two long vowels, but not both" Aug 31, 2022 at 15:02
• @Adam true, done. Aug 31, 2022 at 20:51

# Compute the Fabius function

• $$\f(x)\$$ always takes on rational values at dyadic rationals (i.e. $$\\frac m{2^n}\$$ with $$\m,n\in\mathbb Z\$$). It could also be interesting to restrict input to such values, and ask for a rational output.
• Forgive my ignorance, but is it even possible to exactly determine the value of the function for any given input $x$? Sep 5, 2022 at 23:03
• @97.100.97.109 What do you mean by "exactly"? There do exist algorithms which can approximate the value of $f$ to arbitrary precision for any given input. For example, from math se
– att
Sep 5, 2022 at 23:22
• I suppose the answer to my question is "no" (when the input is not a dyadic rational). In that case, how do solvers decide the level of precision with which to calculate the answer? I think that limiting to dyadic rationals is a good idea because then there is an explicit formula to calculate the values. Sep 5, 2022 at 23:38
• @97.100.97.109 I don't think the absence of an explicit, non-limiting formula should be a factor in that decision. How would you "exactly" calculate $\sin$ for arbitrary inputs?
– att
Sep 5, 2022 at 23:44
• I think it can make two challenges actually: first with f on dyadic rationals asking for rational output (no floating point errors); second with f at any input with stated required precision (maybe limited to interval 0-1). Sep 7, 2022 at 19:51
• I'd prefer keeping the function to [0,1] where it is defined by the cumulative distribution.
– xnor
Sep 10, 2022 at 22:08

# Convert integer to IEEE 754 float

The task is simple, given a 32 bit integer, convert it to its floating point value as defined by the IEEE 754 (32-bit) standard.

## IEEE 754

Here is a converter for your reference.

Here is how the format looks:

The standard is similar to scientific notation.

The sign bit determines whether the output is negative or positive. If the bit is set, the number is negative otherwise it is positive.

The exponent bit determines the exponent (base 2), it's value is offset by 127. Therefore the exponent is $$\2^{n-127}\$$ where n is the integer representation of the exponent bits.

The mantissa defines a floating point number in the range $$\[1,2)\$$. The way it represents the number is like binary, the most significant bit is $$\\frac 1 2\$$, the one to the right is $$\\frac 1 4\$$, the next one is $$\\frac 1 8\$$ and so on... A one by default is added to the value.

Now the final number is: $$\text{sign}\cdot 2^{\text{exponent}-127}\cdot \text{mantissa}$$

## Test cases

1078523331 ->   3.1400001049041748046875
1076719780 ->   2.71000003814697265625
1036831949 ->   0.100000001490116119384765625
3264511895 -> -74.24919891357421875
1056964608 ->   0.5
3205496832 ->  -0.5625


For this challenge assume that cases like NaN and inf are not going to be the inputs, and subnormals need not be handled, and you may output 0 for the case where the number represented is -0.

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

• Closely related. Kinda opposite task, but I think there are certainly overlapping techniques around reinterpreting a bit pattern from one type to another. Sep 22, 2022 at 0:22
• I don't quite understand what this challenge is asking for. Are we supposed to reinterpret the integer as a float? Oct 2, 2022 at 21:51
• @pigrammer yes. Oct 3, 2022 at 3:42
• @solid.py shouldn't all the digits be accurate, because there is no floating point conversion error when you are reinterpreting an integer as a float Oct 9, 2022 at 10:33
• @solid.py 1/2 + 1/4 + 1/8 + ... should be accurately stored, because, well it can be accurately represented by IEEE754, which is supported by most languages... Oct 10, 2022 at 15:51

• Is 10000001 actually 81? A simple web search shows 81 is 1010001 Sep 30, 2022 at 9:38
• -1 because of that Sep 30, 2022 at 9:39
• @py3programmer Since hexadecimal is in base sixteen, hexadecimal 81 is 10000001. Sep 30, 2022 at 14:27
• @py3programmer no. Hexadecimal is base 16. I've edited the post so you can remove your downvote. Sep 30, 2022 at 14:30
• There's a different way to calculate binary numbers in base 16? I didn't know that. Oct 1, 2022 at 2:46
• @py3programmer 81 in base 16 isn't the same as 81 in base 10, the same way that, e.g. 10 in binary is not equal to 10 in decimal. 81 in base 16 is 8*16+1 = 129 in decimal, which is indeed 10000001 in binary. Oct 2, 2022 at 18:59
• Since 16 is a power of 2, you can also convert each character individually into binary then concatenate -- 8 -> 1000, 1 -> 0001, 81 -> 10000001. Oct 2, 2022 at 19:18
• Yeah, I get you. I was think more in Python terms, bin(81) instead of bin(0x81) Oct 3, 2022 at 3:58

# Find a word in the dictionary of all possible words

• Can input use strings? (e.g. 123 and 231 for your example) Oct 2, 2022 at 21:47
• @pigrammer that's a default input method and thus should be fune Oct 2, 2022 at 22:00
• @solid.py that should be fine so long as tuples of arbitrary length can be handled Oct 4, 2022 at 19:19

# Generate QR code from string

I'm surprised to have not seen anyone doing this particular challenge yet.

The challenge is simple: Take input as a string, your task is to turn it into a QR code.

This challenege originally requires outputting to an image (or any graphical output), but to relax the restrictions down, you only need to output the result as a matrix (or a 2D array). A binary string (with splits between) is also acceptable.

And for sake of simplicity, you will only need to output a 25x25 QR code image (which is the most popular QR code size, I believe). For the input Version 2, the image should look like this:

You may not need to handle empty strings.

Standard loopholes are forbidden.

## More resources

• Can we output as a binary string Oct 9, 2022 at 9:28
• @py3programmer No, the output string must be full, correct image data. If you are using a binary string to later be used with metadata to output to a, say bitmap file, then yes, you can.
– oeuf
Oct 9, 2022 at 10:06
• You may consider turning this into a binary-matrix challenge instead. It would be easier to test on TIO and the like. Oct 9, 2022 at 21:02
• Also, it would need to be significantly more specified. Which version of QR code? Which kind of data? With which error correction level? (Challenges are supposed to be self-contained. So, ideally, the full algorithm should be explained.) Oct 9, 2022 at 21:05
• @oeuf I meant a binary string that describes whether each pixel is lighted up or not. The binary string would describe the pixels from left to right. Is that valid? Oct 10, 2022 at 3:50
– oeuf
Oct 10, 2022 at 5:32
• @Arnauld I have edited to relax the output restrictions down and specify more about the output. Thanks for suggestion! I am currently deciding on the error correction level
– oeuf
Oct 10, 2022 at 6:08
• Don't we need 2 inputs? One for the version, and one for the string we need to encode the qr code with? Oct 10, 2022 at 7:01
• @py3programmer No, we only need one input for the string.
– oeuf
Oct 10, 2022 at 7:14
• So you mean that using version 2, you'll encode the input as a QR code? Oct 10, 2022 at 7:17
• @py3programmer Yes.
– oeuf
Oct 10, 2022 at 7:18
• Can one use built-in libraries that generate QR codes? I think that the real would be to compute the image/matrix Oct 17, 2022 at 14:50
• @matteo_c Builtins are allowed, but builtins that solves the entire problem are generally disencouraged.
– oeuf
Oct 18, 2022 at 4:50

# Integer Bluffing (Still a draft)

It's an exciting night at the IGS casino, as a brand new table game is being revealed - Integer Bluffing. Bots from all over the network have come to have a chance at playing the inaugral game, and luckily for you, you just happen to have a seat at the table.

## The Rules of Integer Bluffing

At the beginning of a game of Integer Bluffing, each player starts with 20 tokens. A round of Integer Bluffing consists of 4 phases: (i) the deal, (ii) declaring, (iii) reacting, (iv) the showdown

### The Deal

Each round, 1 player is chosen to pay an ante, which increases during the game, into the pot. A random integer in the range [1, 8] is then "dealt" to each player. Players only know the true value of their own integer, and once an integer is given to a player, it can't be dealt to anyone else.

### Declaring

Starting with the player after the player who paid the ante, each player has the choice to either: a) decline to play the round (fold) or b) put 1 token into the pot and declare what their integer is (play).

Here's the twist - if choosing to play, the player doesn't have to tell the truth about the value of their integer - they can lie and declare they have an integer they don't have. The player also sets a flag whether they say they are bluffing or not - this can also be lied about.

Consider the following game with players A, B, C and D:

Player Integer
A 4
B 2
C 7
D 3

Assuming Player A paid the ante for the round, player B goes first in the declaring round. Player B sees that they have a 2, which is highly unlikely to win against other integers, so they fold.

Player C sees that they have a 7, so they choose to play the round. Wanting to trick Players D and A into putting a token into the pot, C declares that they have 2, and states they are not bluffing.

Player D sees that Player C allegedly has 2 and that they aren't bluffing. Player D knows that 3 is higher than 2, but knows that Player A might have a higher integer. Therefore, Player D decides to declare 6, not bluffing, in the hopes that Player A folds.

TODO: Continue writing

• "new table game"? Pfff, I've played this before :3 Oct 14, 2022 at 13:28
• You should state the number of players at the table (always exactly 4?), probably in the "The Rules of Integer Bluffing". I also think this sentence: "The player also sets a flag whether they say they are bluffing or not" should be reworded. I think "The player may also set a flag to say they are bluffing" works. Oct 14, 2022 at 19:58

# Tic, Tac, stub your Toe

• Welcome to Code Golf, and thanks for using the Sandbox! Currently, this is missing a winning criterion. If it's code-golf, you should probably specify. Oct 26, 2022 at 4:12
• I'd also recommend allowing looser I/O formats - see here. It's your challenge though, so if you really want to keep the strict formats, that's okay. Oct 26, 2022 at 4:17
• Don't know how to add tags to specify which type so right now it's just fastest possible solution wins. Also will update to remove number of testcases and commas from input. Oct 26, 2022 at 14:14

# Is this series of quotes valid python? code-golfdecision-problem

Python string parsing has quite a few edge cases. This is a string:

"a"


Putting 2 strings immediately after each other implicitly concatenates them, so this is also a string:

"a""a"


However, if you put 3 quotes in a row, it will create a "triple quoted string" which can only be ended by another triple quoted string. A triple quoted string can contain other quotes. These quotes will not end the string unless there are 3 of them. Thus this is valid:

"""a"a"""


Of course, you can combine these together, so this is a valid string:

"""a""""a"


And this:

"""""aaa"""""""""


A string is not valid if:

1. Any a appears outside of a string literal (would get SyntaxError: invalid syntax in python) OR
2. The end of the sequence is inside a string literal (would get SyntaxError: unterminated string literal (detected at line 1) in python)

Given a string containing 2 distinct characters, one representing a double quote and another representing any alphanumeric character, determine if it would be a valid python string, or invalid syntax.

You do not need to consider single quotes or how double and single quotes normally interact.

A array of booleans or a array of bytes would also be a valid input method.

This is , shortest answer wins.

## Test Cases

Truthy Falsy
"a" (1-1) "a (1)
"a""a" (1-2-1) "a"a" (1-1-1)
"""a"a""" (3-1-3) ""a"a""" (2-1-3)
"""a""""a" (3-4-1) """a"""a" (3-3-1)
"""""aaa""""""""" (5-9) """""aaa"""""""" (5-8)
"""""""""""" (12) """"""aaa""""""""" (6-8)
"a""a""a""a" (1-2-2-2-1) """" (4)
"a""" (1-3)

eval or exec or ast.literal_eval would be valid answers, though I hope to see more creative python answers as well.

• Well, well, well... exec can be used, so I'm claiming that. Ha! Oct 26, 2022 at 12:02
• Ok go for it. Not sure if I would count that as creative though Oct 26, 2022 at 12:03
• But the problem with this is, lambdas are not going to work in Python, and neither can normal functions. LHS = SyntaxError = RHS -> hence proved that eval and exec 4 byters are not valid. Oct 26, 2022 at 12:06
• And neither will normal inputs. Therefore, python would not work at all for this program, as input cannot only be provided. Oct 26, 2022 at 12:07
• Of course python works? You can take input as a string containing quotes Oct 26, 2022 at 12:08
• Though I assume it could be made to work in online interpreters like TIO and ATO, but not in IDLE style. Oct 26, 2022 at 12:08
• "string containing quotes": won't the string itself contain quotes? Like "a"a" when passed to an argument would be '"a"a"' Oct 26, 2022 at 12:09
• Notice the '? Oct 26, 2022 at 12:10
• The string will contain only double quotes. Oct 26, 2022 at 12:11
• Nod nod so when are you posting this? Oct 26, 2022 at 12:15
• When I get 3-4 votes Oct 26, 2022 at 12:17
• +1. You're 2 votes away :P Oct 26, 2022 at 12:19
• Hey why'd you claim exec? Oct 27, 2022 at 6:42
• Because it's boring. Note that duplicate answers are technically allowed but don't expect any votes Oct 27, 2022 at 6:52
• But it wasn't your idea to use it... I had to rack my brain for a minute to figure out an alternative approach :( Oct 27, 2022 at 11:10

# Does the sequence shut the box?

• small nitpicks: "roles" should be "rolls", "d6 dice" is redundant and should probably just be "six sided dice", and [] input is an edge case, and i think we should probably be able to assume input wont be empty. Oct 10, 2022 at 21:58
• actual feedback: cool challenge idea :-) a worked out example of how a specific sequence could be used to shut the box would be very helpful in allowing everyone to understand the challenge more Oct 10, 2022 at 21:58
• Thanks for the feedback. I cleaned those things up and added the example. Personally I like the inclusion of the [] input as it adds more thinking to the golfing (can one save bytes by formulating the general case to include the edge case). But I admit it may be weird to say "not playing the game is not a winning sequence". Oct 10, 2022 at 23:29
• ultimately up to you :-) thanks for humoring me :P Oct 11, 2022 at 2:03

# 50 digits of π in HQ0-9+-INCOMPUTABLE?

• Sorry few questions: are those the only commands avaiable? How would I append to the buffer then if I didn't want to use q/Q? Nov 11, 2022 at 0:18
• @DialFrost 1) Yes. 2) It's your job to figure it out. Nov 11, 2022 at 0:19

# Base Neutral Numbering System code-golfprimes

• Can we output as a nested list? Like <<1> * <<1>>> = [[[1],[[1]]]] Nov 22, 2022 at 20:40
• Also, can we omit the *? Most of the test cases omit it, only the last two use it. Nov 22, 2022 at 20:41
• Omitting the * from the test cases was a mistake. I think [[[1],[[1]]]] already qualifies by my rules since I allow replacing <> with [] and * with , . Nov 22, 2022 at 21:08

# Turn two dice into one die

• Is it guaranteed that target is divisible by die1 * die2? Seems all your test cases assume so Dec 8, 2022 at 10:42
• What if there are multiple possibilities? Or will the input configuration guarantee an unique solution? Dec 8, 2022 at 11:16
• @mousetail that issue is already addressed in the assumptions: "assume N is a divisor of A*B"
– Noah
Dec 8, 2022 at 20:25
• @pajonk if there are multiple solutions (such as making a one-sided), you only need to return one of them. I will clarify that in the post. I have not proven mathematically if there are unique solutions for the examples in the post, but I will postulate that they are (up to permutation)
– Noah
Dec 8, 2022 at 20:27

# KotH: Build an Organism

A while back, I made a thing that simulates a world, with a bunch of organisms with randomly chosen genes:

These would code for things like how the organism would manage resources (such as sugar, water, and starch), whether it could photosynthesize, hunt, run away from enemies, or defend itself using tough materials like wood or stone spikes.

In this challenge, you'll design an organism which can effectively survive. This could be through strategies including:

• Being an effective hunter, chasing down and killing prey
• Being difficult to attack, such as by having tough armor and fleeing from stronger organisms
• Growing and dividing too quickly for it to be possible that all organisms of your species are killed at the same time

I will update this post with a spec listing all available resources, materials, genetic traits, and actions later.

• this seems fun. Dec 23, 2022 at 20:18

# Rotate an Image code-golfimage-processing

This challenge is simple: Take a path to an png image file as input and overwrite that file with a copy of itself rotated 90 degrees clockwise. You may assume that the file has dimensions of 128x128 pixels.

## Examples

Input:

Output:

This is , so shortest answer wins.

# Change the subject code-golfstringarraysorting

## Posted here

• Nice challenge! Is it guaranteed that there will be an order in which each sentence connects to the next? Jan 15 at 19:02
• @TheThonnu Yes, I'll add that to the challenge rules Jan 15 at 19:19
• How are words defined in a sentence? Space separated or any non-letter/punctuation separated? Jan 16 at 4:31
• @lyxal, to not make things too complicated, they will just be space separated. But the first and last words of the sentence can be compared with the others as well, and the first word starts with a capital letter while the last word ends with a period. I'll clarify this in the challenge. Jan 16 at 13:58

# Simplify a Cycle

• A worked out example would be great. I don't get why aren't all vertices from the input in the output. Aug 19, 2022 at 8:16
• Is this really "given a path that may include cycles, remove the cycles"? Aug 19, 2022 at 8:42
• @UnrelatedString no, it's "given a cycle between two vertices, return the shortest cycle" Aug 19, 2022 at 8:43
• The last test case seems to contradict that, since the shortest cycle between 1 and 7 seems like it should just be [1,2,7]. I guess what I'm getting at is there needs to be a clearer spec and/or worked through example :P Aug 19, 2022 at 8:47
• So is this a 1-D graph or what? Are you only giving us the X coordinates or what? Or am I just not understanding a thing? If we have the coordinates (both X and Y) is this basically removing adjacent coordinates that are colinear? Aug 19, 2022 at 15:50
• @Steffan these numbers arent coordinates; they're just the labels on the nodes of the graph. the input is a path that exists on the graph, meaning you can get from each node in the list to the next node in the list by following a single edge Aug 22, 2022 at 2:35
• Maybe an example program will help. Aug 26, 2022 at 14:29
• Questions for @lyxal . Aug 26, 2022 at 14:39
• Suppose his answers are what I expect, this should work. Aug 26, 2022 at 14:40
• It was at 4 char left. Sorry for another post. Why must [1,2,7,2,7,2,3,7] be [1,2,3,7] ([1,2,...,3,7]) and not [1,2,7] ([1,2,7,...])? Aug 26, 2022 at 14:42
• The mathematical definition deems that both are correct. You might want to clarify or add that to the test case. Aug 26, 2022 at 14:42
• E Aug 26, 2022 at 14:44
• ...dited to match the test cases. The last post was too long. Aug 26, 2022 at 14:44

# Change the Temperature of Swatchlings

## Summary

Your challenge today is to determine the minimum number of turns needed to change the temperatures of an arbitrary amount of Swatchlings to all be the same.

## Context

In the second chapter of Deltarune, there are enemies you encounter that are called Swatchlings (suit-wearing butler-like characters that serve the main antagonist of the chapter). These enemies always appear in battle in groups with at least one outlier in terms of suit colorsource. Swatchlings are defeated by making all Swatchlings in the group have the same suit colour.

Each Swatchling's color can be changed in stages, either becoming warmer (redder) or colder (bluer). While there are only five colours in the actual game, for this challenge, there will be an infinite amount, represented by positive integers.

During each turn of a battle, there are 3 ways to change the temperature of a Swatchling: increasing/decreasing the temperature by 2 stages, increasing the temperature by 1 stage or decreasing the temperature by 1 stage. You may perform up to 3 of these actions per turn, and no action twice in a turn.

Given a list of Swatchling temperatures, determine the minimal number of turns needed to change the temperatures of all Swatchlings to be the same. Note that

For example, given the following temperatures:

[1, 5, 5]


The optimal solution would be:

Turn 1:
Increase Swatchling #1 by 2 stages: [3, 5, 5]

Turn 2:
Increase Swatchling #1 by 2 stages: [5, 5, 5]


Meaning a minimum of 2 turns are needed to change the temperatures of all Swatchlings to be the same.

Another example is:

[1, 5, 3, 4, 4, 2, 1]


One optimal solution might be:

Turn 1:
Increase Swatchling #1 by 2 stages: [3, 5, 3, 4, 4, 2, 1]
Decrease Swatchling #4 by 1 stage: [3, 5, 3, 3, 4, 2, 1]
Increase Swatchling #6 by 1 stage: [3, 5, 3, 3, 4, 3, 1]

Turn 2:
Decrease Swatchling #2 by 2 stages: [3, 3, 3, 3, 4, 3, 1]
Decrease Swatchling #5 by 1 stage: [3, 3, 3, 3, 3, 3, 1]

Turn 3:
Increase Swatchling #7 by 2 stages: [3, 3, 3, 3, 3, 3, 3]


Meaning a minimum of 2 turns are needed to change the temperatures of all Swatchlings to be the same.

## Rules

• Input will be a list of positive integers representing the temperatures of each Swatchling. The list will contain at least one Swatchling.
• Output will be an integer representing the minimum number of turns needed to change the temperatures of all Swatchlings to be the same.

## Test Cases

[1, 5, 5] => 2
[1, 2, 5] => 1
[1, 5, 3, 4, 4, 2, 1] => 3
[1, 7] => 2
[1, 10, 3] => 4


As this is , the aim of the game is to get y'all's byte count as low as possible, just like the turn count to make all the Swatchlings the same temperature.

## Sandbox Meta

• Is the explanation clear enough?
• For your first case, can't you decrease #3 by 2, decrease it by 1 again, and increase #1 by 1? Jul 2, 2022 at 0:09
• @emanresuA huh, so you can. Just tested it in deltarune lol Jul 12, 2022 at 13:43
• I'm assuming the line after the solution for [1, 5, 3, 4, 4, 2, 1] should say "Meaning a minimum of 3 turns are needed..." Jul 15, 2022 at 19:01
• Is [2,5,5] 1 or 2, or say is multiple operating on one item allowed in one turn?
– l4m2
Jan 22 at 7:44
• [1, 10, 3] should be 3 if I understand it correctly. [1, 10, 3] => [3, 8, 4] => [5, 6, 4] => [5, 5, 5] Jan 22 at 16:46

# Yakko's New World Order

• I don't think allowing outputting the indices into the list should be allowed Jan 24 at 21:11
• @RydwolfPrograms Why not? Jan 24 at 21:17
• Everybody's just going to do that, and that rules out some interesting approaches involving the text itself (such as using some sort of custom digest as a sorting key). Jan 24 at 21:18
• Given a list of countries in alphabetical order -> are we always given the full list, or could it be a subset of this list? Jan 29 at 20:23
• @Arnauld You are always given the full list. (If you want, you can ignore the input completely.) Jan 29 at 21:12

# Reverse the polyglot, change the language.

Write a polyglot in two languages that when run, outputs the language it is run in. Additionally, this program must also output the other language's name if the source code is reversed

# Example:

Program ABC in language foo outputs foo. ABC in language bar outputs bar. CBA in language foo outputs bar, and CBA in language bar outputs foo.

This is code-golf, so the shortest code wins

# Huffman Decoding

Write a programm which takes two strings as input and prints a text.

The first argument is a Huffman Tree, serialized in the following format:

• every ascii character except ~ is always a leaf, if ~ is the first characater it is also a leaf.
• <tree0><tree1>~ is a tree where <tree0> is the left subtree and <tree1> is the right subtree.

Example: ab~cde~~~ generates this tree:

 ┌─┴─┐
┌┴┐ ┌┴─┐
a b c ┌┴┐
d e


where a would have the key 00, b 01, c 10, d 110 and e the key 111.

The second argument is a text that has been compressed with with the Huffman code that is defined by the first parameter. This bit-string can contain any bit sequence (also null-bytes and non-printable characters) and is not byte aligned, therefore it has been encoded with a variation of the standard Base64 encoding:

• the characters used for the encoding are the standard base64 characters: ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/
• the bitstring is broken up into 6-bit chunks and mapped to this characters
• if the last chunk is smaller than 6 bits, a character with this prefix is used, and padding characters are added to the string:
• - : the last chunk was five bits long
• = : the last chunk was four bits long
• =- : the last chunk was three bits long
• == : the last chunk was two bits long
• ==- : the last chunk was one bit long

Example:

bits:       1 1 1 1 0 1 1 0 1 0 0 1 1 1 0 1 0 1 0 0 0 1 1 0 1
chunks:    |1 1 1 1 0 1|1 0 1 0 0 1|1 1 0 1 0 1|0 0 0 1 1 0|1[0 0 0 0 0]|
characters:       9           p           1           G           g
base64:     9p1Gg==-


Your programm has to decode the text encoded in the second parameter and print it to stdout.

You have to provide your source code encoded in the way described above. The length of your encoded source code + the length of your serialized huffman tree will be the winning criterion.

TODO: example input

• It would be helpful to explicitly state the 64 characters used in the encoding. I presume they're A-Za-z0-9+/ but (especially if you're expecting people to implement that part explicitly) it's best to make the problem self-contained. Oct 8, 2012 at 16:23
• Hello! This looks like a good but abandoned meta post, would you be willing to offer it for adoption? (If you want to, you can still post to main.)
– user58826
Jun 9, 2017 at 15:30