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

# OEIS A049190

is separated by newline, is separated by space or separated by comma.

the first few numbers are:

1, 3, 5, 59, 245, 2491, 235253, 127756731, 330567489269, 258479716298484155, 36823182192123209878050549, 25576412117054296344209353299113896379, 10994511204169842163496446583221775727830456269734123253


## How to get numbers of this sequence:

this is look and say but in binary and convert to decimal

# Meta

• How to clarify this?

# Infinite ordinals from a well-ordering

• Are the score categories essentially arbitrary? If so, it's not clear to me whether this is a good idea: it seems like these constraints provide the only motivation for choosing a well-ordering different from the 'default' (1, 2, 3, ...). Poor constraint choices could derail the challenge (i.e. make it too trivial or too hard). On the subject of scoring, looking at the bytes category for example, do you mean that if the default ordering is chosen, the code must be exactly 1 byte? Nov 12, 2021 at 0:48
• Also, there's a typo under the second example: 2 < 101 is true. Nov 12, 2021 at 0:48
• @Dingus I tried to clarify the scoring part. So if you choose $\omega\cdot 2$ you just try to golf an implementation of it. In this case someone has (hypothetically) managed to do it in one byte. As for the difficulty of the ordinals, the first two are one-liners in most languages, $\omega^\omega$ can be implemented with a while loop and $\epsilon_0$ with a tree. The score categories are not totally arbitrary. $epsilon_0$ is an important ordinal, and the smaller ones follow a natural pattern. Another option is to have just one ordinal, making this a normal golf and not a challenge. Nov 12, 2021 at 7:41

# Baloney Sandwich KOTH

Tags: [king-of-the-hill], [python]

## Introduction

In this King Of The Hill Challenge, your bots will be playing Baloney Sandwich.

### How Baloney Sandwich is played

1. First, the entire deck is dealt equally to all players (EVERY BOT PLAYS; if there is more than 26 bots, it will be 2 decks mixed together).
2. Then, the player with the ace of spades goes first.
3. They play all of their aces
• However! They could opt to "cheat" and instead play cards that are not aces, or mix and match aces with other cards.
4. Every other player has their call_bs (bs = Baloney Sandwich) method called after this play, in turn until a player returns True; if a player returns True then the cards played are "revealed".
• Every player has their bs_call_outcome method to "reveal" the cards
• If no player returns True but the player was lying, the pb method is called (pb = Peanut Butter)
5. Play continues with twos, threes, etc.; after kings, start over at aces

## Creating A Player

Your player should be in this format:

class ExamplePlayer(AbstractBSPlayer):
def __init__(self, hand: list[int]):
super().__init__(hand)
# Any necessary initialization goes here

def call_bs(self, player_name: str, card_rank: int, number_of_cards: int) -> bool:
"""
player_name is the name of the bot who just played
The number of cards they played is number_of_cards
The claimed rank is card_rank (1 is Ace; 11-13 are face cards)
"""
# Magic decision maker
return False # never calls "Baloney Sandwich"
# return True would always call "Baloney Sandwich"

def bs_call_outcome(self, player_name: str, caller_name: str, card_rank: int, cards: list[int], cheated: bool):
"""
player_name is the name of the bot who just played
caller_name is the name of the bot who called "Baloney Sandwich"
The claimed rank is card_rank
The cards they played is cards
cheated is True if the player cheated
"""
pass  # Couldn't care less

def pb(self, player_name: str, card_rank: int, number_of_cards: int):
"""
player_name is the name of the bot who just played
The number of cards they played is number_of_cards
The claimed rank is card_rank (1 is Ace; 11-13 are face cards)
"""
pass # Couldn't care less

def play_cards(self, card_rank: int) -> list[int]:
"""
The rank you will claim to play is card_rank
"""
# Magic decision maker
return self.hand[0] # Always plays the first thing in hand


• self.store: A dictionary that is empty by default. The only instance variable allowed to be written to.
• self.hand: A list of ints, each representing a card (1 is Ace, 11-13 are face cards)

The controller can be found at https://github.com/sethpeace/bs-koth. I apologize in advance that it is janky beyond comprehension.

## Rules

### Runtime Disqualifications

• You must play at least one card every turn
• You can't play cards you dont have in your hand
• You can't take longer than one second to return from a function

### Pre-runtime Disqualifications

• No reading or writing to controller, runtime, or other submissions (bots can't read them; you can if you feel like it)
• Only write to self.store instance variable
• Other variables inside function scope are of course OK
• Don't design a bot to defend or support specific bots
• Bots can't use the same strategy as another bot
• Standard loopholes apply
• This seems too similar to codegolf.stackexchange.com/questions/48473/thats-bs-card-game Nov 27, 2021 at 16:45
• @RedwolfPrograms you are correct; thank you
– Seth
Nov 27, 2021 at 16:46
• It's cool to see some more KotHs being written though! If you have any ideas for ones that you're not sure are dupes, feel free to bring them up in chat to save the effort of having to write out a whole spec first. Nov 27, 2021 at 16:48
• @RedwolfPrograms alright thanks again :)
– Seth
Nov 27, 2021 at 16:49

# Implement xorshift128+

I don't have time to finish writing this draft at the moment.

Might also consider something like xoroshiro if it's more interesting to implement, but since xorshift128+ is so common it seems like a clearer choice.

(Possible idea: Given initial seed, determine number of iterations it'll take to get a certain random number with xorshift128+. It's not a CSPRNG, so there might be something more interesting than brute force.)

# Radiate a prime checker into a sum program

Write a program or function that takes a number n and returns/print truthy if it is prime, and falsy otherwise. Additionally, if you remove 1 character of the source code, the program must now take a list of one or more numbers and return/print the sum. This must work for at least one character, and your score is however many characters that this does /not/ work for. Lowest score wins.

# meta:

let me know if i need to clarify anything etc also: would it make sense to allow the programs to be the other way around (i.e. a sum checker where removing 1 character makes it a prime checker instead)? Just in case it could lead to a more interesting golf

• It says "remove or change 1 character". By change, do you mean simply changing an arbitrary character to another arbitrary character, e.g. abc -> axc? If so, a lot of golfing languages will likely be able to make a trivial 0-score program where they simply change a 1-byte prime checker to a 1-byte sum command. That might not be a bad thing, per se, but it's something to keep in mind. Dec 8, 2021 at 21:16
• @AaroneousMiller True, ill stick to just "remove". Wasn't sure of potential ramifications, thanks Dec 8, 2021 at 21:18

# Quickly pour liquid nitrogen

I have a container of liquid nitrogen, but nothing to measure it with. I do have some containers, whose volumes I know, and I know how much I start with. My goal is to fill any container with a given amount of liquid nitrogen, with the fewest possible pours.

Importantly, liquid nitrogen boils away as I pour it. Every time I pour liquid nitrogen into a container, a milliliter is lost.

Pouring mechanics:

If I have two containers, a and b, and I pour a into b:

• If both are empty, nothing changes
• If b's unused volume is greater than or equal to the volume of liquid nitrogen in a, a is emptied into b, and a milliliter boils away from b
• Otherwise, as much as possible is poured from a into b, and an additional milliliter is taken from a (so b will still be full)

If I have three containers, x, y, and z, they all have volumes of 25, and they contain 25, 10, and 18 milliliters of liquid nitrogen respectively, here are some example pours (one after another, not indiviudual):

1. x into y: y is filled, and x is left with 9 milliliters
2. y into z: z is filled, and y is left with 1 milliliter
3. z into x: x remains full, z is left with 24 milliliters
4. y into z: z remains at 24 milliliters, y is emptied

(Note that in your input, not all containers will have the same volume)

Given a list of container sizes, where the first container is initiallyfull and the amount of liquid nitrogen you must measure out, return the minimum number of pours that would be needed to leave that much in any container.

You may assume volumes are non-negative integers, and the initial amount of liquid nitrogen will never be less than the amount you should end with. The actual sequence of pours you use doesn't matter, as long as you output the minimum possible count.

Test cases:

Containers          Target      Output

7, 4                3           5
12, 3, 3            4           2
100, 10, 8          84          6
8, 8                5           3
10, 0               8           2
100, 20, 20, 17     73          7


Other:

I don't think this is a good challenge after doing the test cases

• Welcome to Code Golf, and nice first answer! Dec 10, 2021 at 3:31
• @emanresuA You too! Dec 10, 2021 at 3:31
• use fastest-code there are few questions with both tags. Dec 4, 2021 at 16:28
• time spent on what interpreter? can you say TIO? Dec 4, 2021 at 16:30
• @Fmbalbuena what if the interpreter is not on TIO? Dec 4, 2021 at 16:31
• You'd need many more test cases to get significant results with fastest-code. Also, using TIO for timing is a bad idea (I'm sure there's a post on meta about that, but I don't know exactly where). Dec 4, 2021 at 16:33
• @Arnauld here Dec 4, 2021 at 16:35
• @Arnauld added more test cases Dec 4, 2021 at 16:37

### Tinla Resqua (Latin Square of rotated words)!

Based on this (currently closed) question on Puzzling, your task is to take a single word generate a valid 'latin square', not by permuting the letters in a word, but by rotating the word.

E.g. if one row was CENTURY then ENTURYC is a valid row, but ENTCTURY is not.

Also unlike some Latin Squares, no diagonal may contain repeated letters either.

1 2 3 4 5 6 7
C E N T U R Y
R Y C E N T U
T U R Y C E N
E N T U R Y C
Y C E N T U R
U R Y C E N T
N T U R Y C E

Is a valid grid.

• For even-length words, I think it is impossible to create such square by only rotating the word. At least it is surely true for length 2 and 4. Dec 14, 2021 at 23:38
• @bubbler then they could error or return null or similar? Dec 15, 2021 at 0:02
• That could work. (I'd make it more lenient and say "output something that can be distinguished from a valid solution".) Determining absence of solution is actually harder than that, because it's also impossible for 3. It seems to depend on the existence of solution to "toroidal n-queens problem". Dec 15, 2021 at 0:19
• I found the solution here, which states that such a square is possible exactly when the smallest prime factor is 5, which is equivalent to n%6 being 1 or 5. Dec 15, 2021 at 0:44
• @bubbler very interesting Dec 15, 2021 at 2:16

This was heavily inspired by the donut.c program

# Challenge:

You have to come up with a program that prints (in console) a shape that looks exactly like the shape of your code.

For example, if your code's shape looks like this:

    2343
3kf5
3o*/f
3%kt^7


then the output's shape should look like this:

    9I8b
&yt^
)ph67
{}fgh]


(the byte don't need to match, just the shape)

# Rules

• Empty programs/whitespace-only programs are not allowed.

• Your program should have more than 2 lines/statements of code.

• Each line should not be identical to every other line.

• All whitespace characters (space, tab,...) don't have to be identical.

• Whitespaces characters don't count towards the minimum bytes count.

• Your program's source code and the output should not be identical. It should be at least has one different character.

• The output should have at least two different bytes on one line.

• You should not use comments.

# Scoring criteria

• Longest code (in bytes) wins!

• If two same programs have the same byte count, the one with the most unique characters in the output wins!

• If two same programs have the same unique characters, the one with the most different characters in output compared to source code wins!

# Meta

• Does this question have any duplicates?

• My wording is bad, can you improve it?

• Is this question interesting? Fit within the rules of the site?

• How will you tie-break solutions that change all characters from source to output, while having no duplicated characters in the output?
Dec 15, 2021 at 10:06
• Are programs without any whitespace allowed?
Dec 15, 2021 at 10:12
Dec 15, 2021 at 10:15
• Please avoid cumbersome I/O formats like requiring printing in a console, which also makes assumptions about language features and arbitrarily overrides the defaults. Instead, refer to the default for code golf output methods.
Dec 15, 2021 at 10:19
• I suggest changing "input" to "source code".
Dec 15, 2021 at 10:23
• Can you confirm that this is an optimal answer (minimum allowed byte count changing all its characters while having no duplicates in the output) and that if I post this answer, I win? Note also that the source has no duplicated characters either, so that it won't help to add a rule for tie-breaking on unique characters in the source. Furthermore, code and output have no characters in common at all, preventing that as a tie-break too.
Dec 15, 2021 at 10:25
• I think "longest code wins" is problematic. People can probably make it as long as they want.
– Ivo
Dec 15, 2021 at 11:54
• Oh, I completely missed the change to code-bowling. Have a look at the tag wiki for tips and warnings. Also, note that the maximum number of unique characters will be 1114112.
Dec 15, 2021 at 11:59
• Closely related, potentially a duplicate Dec 15, 2021 at 12:41

# Challenge

You should write a program that has one in (your code in bytes) chance to output a 4 (could be a function that returns a 4). So if your code has 10 bytes, your code should have 1 in an 10 chance to print out a 4. Otherwise, output "finding my dice".

# Rules

• You can use whitespaces, comments or any unnecessary code to get to the number of bytes that you want.
• You shouldn't use any loopholes.

# Winning criteria

This is , so shortest code in bytes wín!

• What should the solution do in the n−1 out of n cases?
Dec 15, 2021 at 13:42
• @Adám Do you mean when it doesn't print 4? Just trying to clarify. Dec 15, 2021 at 13:58
• Say my code is 10 bytes long and I run it 50 times. On average, 5 of those runs should print a 4. What should the remaining 45 runs do?
Dec 15, 2021 at 13:59
• You phrasing sounds a lot like a program that prints is required. Please clarify if a function (e.g. taking a dummy argument) that returns 4 is allowed.
Dec 15, 2021 at 14:00
• Are we allowed to embed unnecessary strings to reach a desired byte count?
Dec 15, 2021 at 14:01
• @Adám Wouldn't that just make your score worse though? Dec 15, 2021 at 16:58

# Find duplicates, quickly

In this challenge, you'll be given a list of positive integers or non-empty alphabetical strings (your choice), and must return a list containing all duplicates. You must do this with the minimum time complexity you can, and as few bytes as possible.

Given a list of either positive integers or non-empty alphabetical (lower or uppercase, your choice) strings, return a list containing all duplicates. You may contain a duplicate value any number of times, so for the input [a, b, b, c, d, d, d, d], any of [b, d], [b, d, d, d], [b, b, d, d, d, d], or even [b, b, b, b, d] would be fine.

Scoring:

Scoring is by both average time complexity and bytes. A better time complexity will always beat an answer with a lower one, and byte count is a tie breaker. E.g., if there are two $$\O(n^2)\$$ answers, at 10 and 20 bytes, and an $$\O(n\log{n})\$$ answer at 140 bytes, it would rank higher than either of the others (until either a shorter $$\n\log{n}\$$ answer or an answer faster than $$\n\log{n}\$$ showed up).

As in , this is per-language, so Vyxal and Vim, Charcoal and C, or Japt and Java are not competing.

• But what if I don't know the time complexity of some operations in my compiler / interpreter? Some languages only define the correct output for certain operator without specify the time complexity. This could happen when some language provide a Map<> without specify if the Map<> is TreeMap<> or HashMap<>.
– tsh
Dec 24, 2021 at 5:37

# Check if the string is reshaped.

• I don't understand this. Can you try to reword it? Dec 16, 2021 at 19:58
• @pxeger read examples carefully Dec 16, 2021 at 20:00
• @Fmbalbuena I did, but it's really not clear what you mean by "reshape" Dec 16, 2021 at 20:01
• @RedwolfPrograms ⍴ in APL. Dec 16, 2021 at 20:04
• @Fmbalbuena I don't know APL, and you can't expect people solving the challenge to either. You need to explain what you mean by "reshape", in a way that people will be able to understand without a background in any particular language. Dec 16, 2021 at 20:09

# Dumbo octopus flashing time code-challenge

Day 11 of this year's AoC was about a grid of bioluminescent dumbo octopi. I'll try to explain how this works, click on the link for a better explanation.

You have a 10x10 grid of octopi which slowly gain energy and flash when fully charged. Each octopus has an energy level from 0 to 9:

5483143223
2745854711
5264556173
6141336146
6357385478
4167524645
2176841721
6882881134
4846848554
5283751526


The flashes and energy amounts can be modelled with steps. At each step:

• All octopi have their energy level increase by 1
• Then, any octopus with an energy level greater than 9 flash. When an octopus flashes, it increments the energy levels of all octopi adjacent (orthogonally or diagonally) to it.
• The flashing repeats until no more octopi can flash. Then, all octopi that flashed during this step have their energy level reset to 0.

For example (stolen from AoC):


Before any steps:
11111
19991
19191
19991
11111

After step 1:
34543
40004
50005
40004
34543

After step 2:
45654
51115
61116
51115
45654


In step 1, the octopi with energy level 9 are all incremented to 10 and flash, all incrementing the octopus with energy level 1 (initially incremented to 2) in the center and causing it to flash as well.

The second part of the puzzle asks how long a configuration will take to have all octopi simultaneously flash in the same step. However, not all configurations will do this - some will fall into other cycles. Eventually, all of the configurations will repeat themselves, as there's only $$\10^{10 \cdot 10 } = 10^{100}\$$ possible configurations - still a huge amount, but finite.

Your challenge is to find a configuration that takes as many steps as possible to return to a configuration it's reached before, with more steps being better.

People on reddit have been investigating this, and the number to beat is 372886.

## Meta

Is the explanation good, and should I bother with it?

Better examples?

• Why is it not $10^{100}$ configurations? Also, it's not initially clear that an octopus increments for each adjacent flash.
– att
Dec 20, 2021 at 8:40
• @att Oops, made a mistake with #1 and I'll try clear up #2 Dec 20, 2021 at 8:42
• @att Better now? Dec 20, 2021 at 8:45
• Yeah, I think so
– att
Dec 20, 2021 at 8:51

# Kolmogorov-simple numbers

• Why not more flexible IO? Requiring a print seems pointless to me. Dec 15, 2021 at 8:50
• Seems like this would be better if the challenge was stated as "output the smallest number $l$ in $n$ bytes, such that $l < \log_{256}(n + 1)$". I agree with pxeger, it's a lot more simple to just use our standard I/O rules, and not worry about it Dec 15, 2021 at 12:58
• I've edited this down to a stub now that it's been posted to save space Dec 22, 2021 at 1:04

# Return all letter counts as an integer

• I've edited this down to a stub now that it's been posted to save space Dec 22, 2021 at 1:06

# Event scheduler

• Thanks for using the sandbox. The challenge type is called fastest-code here. It looks well-defined in general, but a few minor issues: 1) You don't really need restrictions in time complexity (the requirement 1) when submissions are competing for it. 2) Looks like the build instruction is linux only. If so, it should be clarified as such (along with dependencies like cmake). Dec 7, 2021 at 2:12
• FYI, language-specific challenges are discouraged here, and fastest-code without language restriction is usually done by measuring time on a single machine (often the challenge author's). (Not sure how to adapt this specific challenge to other languages, so I'd say it's fine in this case.) And unfortunately we're not like other competitive programming sites, and therefore have very few C++ users. Dec 7, 2021 at 2:15
• OK so would it be acceptable to submit a sample C++ code as guidance and open up to other languages?
– user108147
Dec 7, 2021 at 5:12
• @Bubbler Changed the terms of the challenge. Does it look better as it stands?
– user108147
Dec 7, 2021 at 5:28
• I mean, because of the nature of the task, it's near impossible to establish fair comparison across languages. Normally you'd feed input in a standardized format through STDIN and let the programs output through STDOUT, but 1e8 events would make I/O time way too significant. And not all languages have mt19937 implementation or seeding it like C++ does. So I was saying that limiting to C++ is fine here, though it won't get many answers on this site. Dec 7, 2021 at 5:36
• Hmm we could then open by classes like in boxing but per language here. Winner for C++, Java, Python, etc. And the IO is really not much - just generate a random sequence in memory and submit.
– user108147
Dec 7, 2021 at 5:38

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

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

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

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

one example of artificially constructed language is Toki Pona:

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

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

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

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

What basic language structures you would propose for new language ?

# Find out what type of adjective it is

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

## Notes

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

This is , so the shortest code wins!

Test cases:

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

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

# Is it a mathy-county-number

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

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

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

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

## Rules

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

## Examples

332222410
> True

33222241
> False

1
> False

33222
> False

1122233334444455555566666667777777788888888890
> True

112223333444445555556666666777777778888888889
> True

122334444456789
> False

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

# Wordle

The game Wordle is quickly becoming popular.

The way the game works is as follows:

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

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

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

## Sandbox

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

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

# Universal Command Sequence

Posted

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

# Generate Fmbalbuena Numbers

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

# Generate Matching Regexes

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

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

## Scoring

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

## Rules

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

# Help Bob split his apples

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

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

# Test Cases

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

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

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

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

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

The starting point is the top left corner

Example:

1234


Can do like this

>>>


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

But

124
435


Is impossible so the fewest fails are:

>>v<<


1 > 2 > 4 > 5 < 3 > 4

So this has 1 fail

## Test cases:

The output is not exact, there are multiple possible solutions

Input:

123
245
175


Output:

>>vv<<^>


Input:

123456789


Output:

>>>>>>>>


Input:

987654321


Output:

>>>>>>>>


Input:

123
456
789


Output:

>>vv<<^>


Input:

123456789
987654321
123456789


Output:

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


# Meta:

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