560
\$\begingroup\$

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

To post to the sandbox, scroll to the bottom of this page and click "Answer This Question". Click "OK" when it asks if you really want to add another answer.

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
  • Comments addressing specific points mentioned in the proposal
  • 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".

\$\endgroup\$
0

4331 Answers 4331

1
19 20
21
22 23
145
3
\$\begingroup\$

Distance between vowels

Objective

Given two vowels represented in single IPA characters, calculate the distance between them.

Vowels

Vowels are characterized by three factors: Height, backness, and roundedness. Here, all vowels have the three characteristics as integers.

Unrounded vowels (z = 0)

    x=0       x=1       x=2       x=3       x=4
y=6 i(U+0069)           ɨ(U+0268)           ɯ(U+026F)
y=5           ɪ(U+026A)           ʊ(U+028A)
y=4 e(U+0065)           ɘ(U+0258)           ɤ(U+0264)
y=3                     ə(U+0259)
y=2 ɛ(U+025B)           ɜ(U+025C)           ʌ(U+028C) 
y=1 æ(U+00E6)           ɐ(U+0250)
y=0 a(U+0061)                               ɑ(U+0251)

(I know, Wikipedia states ʊ as rounded, but official IPA doesn't specify the roundedness of ʊ. It will be considered unrounded for this challenge.)

Rounded vowels (z = 1)

    x=0       x=1       x=2       x=3       x=4
y=6 y(U+0079)           ʉ(U+0289)           u(U+0075)
y=5           ʏ(U+028F)
y=4 ø(U+00F8)           ɵ(U+0275)           o(U+006F)
y=3
y=2 œ(U+0153)           ɞ(U+025E)           ɔ(U+0254) 
y=1
y=0 ɶ(U+0276)                               ɒ(U+0252)

Metric

Your metric \$d\$ shall fit the usual definition of metric:

  • \$d(v,w)=0\$ if and only if \$v=w\$

  • For all \$v\$ and \$w\$, \$d(v,w)=d(w,v)\$

  • For all \$v\$, \$w\$ and \$x\$, \$d(v,x)≤d(v,w)+d(w,x)\$

As an additional constraint, the norm \$\Vert\cdot\Vert\$ induced by \$d\$ shall satisfy:

  • For all \$x≠0\$, \$y\$ and \$z\$, \$\Vert(0,y,z)\Vert<\Vert(x,y,z)\Vert\$

  • For all \$x≠0\$, \$y\$, \$z\$ and \$k>1\$, \$\Vert(x,y,z)\Vert<\Vert(kx,y,z)\Vert\$

  • Analogous rules for the y-axis and z-axis

All of these apply only to the vowels above. All other inputs fall in don't care situation.

Rules

  • Input format is flexible. It may be two chararacters, or a single string containing two charcters. In any case, every input that doesn't fit in your format falls in don't care situation.

  • Output format is also flexible.

\$\endgroup\$
3
\$\begingroup\$

Memory KoTH

Memory is a game where a bunch of pairs of identical cards are laid upside down, and you try to find pairs while only looking at two at a time.

In this KoTH, the way it will work is:

The game will be played on a 4096-item array, and the "cards" will be integers 0-2047.

Each bot takes its turn in order. It has access to the results of previous moves (Up to its previous turn), but their only storage is a single integer.

Spec

The controller will be written in Javascript.

The bot has a move function, which must return two integers: The positions of both its guesses, in the form [g1, g2], where both are integers between 0 and 4095, and must not be gone already (see below).

The bot has access to:

The most recent move of every bot, including itself, in the form of an array of [g1,g2,r1,r2], where r1 and r2 are the first and second values revealed. The first item of this will be your bot's most recent guess, and the rest will be the other bots. This will be the global variable prev, and is readonly.

A picture of the entire grid, as a 4096-item array, left to right and top to bottom, where 0 means gone and 1 means still there. This will be the global variable grid, and is readonly.

An array of values that are gone. This will be the global variable gone, and is readonly.

A single ArrayBuffer(50), a 50-bit set of raw binary data. See the docs for help on how to access this. This will be the property this.storage, and can be used to store data.

Writing to globals is banned.

Game

The bots will take their turn in a predetermined randomised order.

If a bot's moves are two tiles with the same value, those tiles are removed from the game area, and that bot gets a point.

The game ends when all tiles are gone, and the bot with the most points wins. In case of a tie, the bot that is last in the randomised order wins.

Bots should be a Javascript object like:

{
  name: "A bot",
  move(){
    // insert code here
  }
}

Meta

Should I change storage limit or grid size?

\$\endgroup\$
18
  • \$\begingroup\$ Shouldn't the bot be able to see the values of gone items? \$\endgroup\$ May 15, 2021 at 9:03
  • \$\begingroup\$ @CommandMaster True, will add. \$\endgroup\$
    – emanresu A
    May 15, 2021 at 21:02
  • \$\begingroup\$ This doesn't really matter too much but if it were up to me, personally, I would change the storage limit from \$[1,2^{50}]\$ to \$[0,2^{50}-1]\$ so it's a bitstring of length 50 \$\endgroup\$
    – hyper-neutrino Mod
    May 18, 2021 at 6:10
  • \$\begingroup\$ @hyper-neutrino Oh yes, that's what I intended. \$\endgroup\$
    – emanresu A
    May 18, 2021 at 6:11
  • \$\begingroup\$ What if two bots tie? \$\endgroup\$ May 18, 2021 at 8:18
  • \$\begingroup\$ @StackMeter The one that is last in the randomised order wins. I'll add that. \$\endgroup\$
    – emanresu A
    May 18, 2021 at 8:41
  • \$\begingroup\$ Wouldn't it be easier to use a Uint8Array rather than a Bigint? Purely for ease of use. \$\endgroup\$ May 20, 2021 at 12:51
  • \$\begingroup\$ Also need to make it clear that writing to globals is banned, since that's a legal play right now \$\endgroup\$ May 20, 2021 at 12:52
  • \$\begingroup\$ @EnderShadow8 Yes, writing to globals is banned. \$\endgroup\$
    – emanresu A
    May 20, 2021 at 20:07
  • \$\begingroup\$ @EnderShadow8 How would I format this Uint8Array? Like how many items would it need to be restricted to? \$\endgroup\$
    – emanresu A
    May 20, 2021 at 20:07
  • \$\begingroup\$ Up to you. It's just a more convenient method of storing data that's a certain size. \$\endgroup\$ May 20, 2021 at 23:32
  • \$\begingroup\$ @EnderShadow8 Actually, I think a BigInt would be better for this challenge, as remembering a single tile is 23 bits, which would be confusing to fit into a Uint8Array. \$\endgroup\$
    – emanresu A
    May 21, 2021 at 4:22
  • \$\begingroup\$ Just make it a plain ArrayBuffer and DataView. That's easier. I don't like using bit operations to extract data from integers. \$\endgroup\$ May 21, 2021 at 4:42
  • \$\begingroup\$ @EnderShadow8 Ok. \$\endgroup\$
    – emanresu A
    May 21, 2021 at 4:43
  • \$\begingroup\$ Are you considering giving the bot the result of its first guess before asking for its second? That would introduce a new layer to the strategy. Eg. explore on the first move and defend or attack on the second \$\endgroup\$ May 21, 2021 at 5:04
3
\$\begingroup\$

Generate a UK number plate

\$\endgroup\$
5
  • \$\begingroup\$ I'd suggest saying AANNXXX or something like that instead of AA12XXX so it's clear the age identifier isn't always 12 (that's clarified later, but still). \$\endgroup\$
    – user
    Apr 28, 2021 at 18:12
  • \$\begingroup\$ Just a note: the last 3 characters can't be either Q or I \$\endgroup\$ May 1, 2021 at 18:13
  • \$\begingroup\$ @cairdcoinheringaahing I thought that too, but I found no mention of it in the government document so I kept it as the whole alphabet. shrug \$\endgroup\$
    – pxeger
    May 1, 2021 at 19:37
  • \$\begingroup\$ There's a Q in the alphabet for the first letter, but then you say the alphabet, minus IJQTUXZ. \$\endgroup\$
    – Arnauld
    May 5, 2021 at 18:13
  • 1
    \$\begingroup\$ @Arnauld yep, that shouldn't be there. Too much muscle memory from typing the alphabet correctly I guess :þ \$\endgroup\$
    – pxeger
    May 5, 2021 at 19:15
3
\$\begingroup\$

I'm Lazy: Close my Parens

\$\endgroup\$
10
  • 1
    \$\begingroup\$ It's clear what to do with ], but what does [ represent? Is it the same as just (? \$\endgroup\$
    – DJMcMayhem
    Jun 1, 2021 at 22:00
  • \$\begingroup\$ Why is ([(] invalid but [(] is not? Will there ever be multiple ] in a row? \$\endgroup\$
    – DJMcMayhem
    Jun 1, 2021 at 22:05
  • \$\begingroup\$ @DJMcMayhem ([(] is invalid because it is the same as [(] but with an unmatched ( at the beginning since the ] only closes the [. There may be multiple ] in a row. \$\endgroup\$
    – Wezl'
    Jun 1, 2021 at 22:08
  • 3
    \$\begingroup\$ So basically ] matches as many open parens as possible until it hits a [ at which point it has to stop? \$\endgroup\$
    – DJMcMayhem
    Jun 1, 2021 at 22:10
  • \$\begingroup\$ @DJMcMayhem yes. Should I add that to the question for clarity? \$\endgroup\$
    – Wezl'
    Jun 1, 2021 at 22:12
  • \$\begingroup\$ Yes, I think that would help. \$\endgroup\$
    – DJMcMayhem
    Jun 1, 2021 at 22:17
  • 1
    \$\begingroup\$ Not sure if lisp tag is appropriate, because the challenge itself doesn't have to do with lisp. \$\endgroup\$
    – qwr
    Jun 2, 2021 at 14:43
  • 2
    \$\begingroup\$ Tag: balanced-string? \$\endgroup\$
    – pxeger
    Jun 3, 2021 at 10:47
  • \$\begingroup\$ @pxeger nice tag-finding skills :) I'll add that. \$\endgroup\$
    – Wezl'
    Jun 3, 2021 at 13:04
  • \$\begingroup\$ @qwr How else do I get the tag badge :P \$\endgroup\$
    – Wezl'
    Jun 3, 2021 at 13:07
3
\$\begingroup\$

But, Is It Art?

\$\endgroup\$
1
  • \$\begingroup\$ I think it is clear, but the second example of "is not equivalent to" is a little unnecessary in my opinion. \$\endgroup\$
    – Alex bries
    Jun 2, 2021 at 10:03
3
\$\begingroup\$

Generalised multi-dimensional chess knight's moves

Posted

\$\endgroup\$
2
  • \$\begingroup\$ You know that the necessary conclusion is we do all the pieces - take my +1 and start the chain. \$\endgroup\$ Jun 14, 2021 at 6:26
  • 1
    \$\begingroup\$ @StackMeter I don't think most of the pieces would be very interesting. Pawns in combination with details of what pieces are already on the board, maybe. Otherwise, it's just this challenge with some slightly simpler vectors \$\endgroup\$
    – pxeger
    Jun 14, 2021 at 6:48
3
\$\begingroup\$

Write a C++ demangler

\$\endgroup\$
6
  • \$\begingroup\$ Is _ZN3foo3barE3baz -> foo(bar)::baz valid? \$\endgroup\$
    – tsh
    Jun 7, 2021 at 8:39
  • \$\begingroup\$ That would be foo::bar::baz. The base identifier is baz, and it is prefixed with the namespace foo::bar. \$\endgroup\$
    – EasyasPi
    Jun 7, 2021 at 14:27
  • \$\begingroup\$ Won't foo::bar::baz be _ZN3fooEN3barE3baz or _ZNN3fooE3barEbaz? \$\endgroup\$
    – tsh
    Jun 8, 2021 at 6:14
  • \$\begingroup\$ No, nested namespaces are placed together without a separator. \$\endgroup\$
    – EasyasPi
    Jun 8, 2021 at 12:39
  • \$\begingroup\$ Decided to remove the "if it doesn't start with _Z, then it is to be printed as-is" as that adds unnecessary complexity. \$\endgroup\$
    – EasyasPi
    Jun 13, 2021 at 23:55
  • 3
    \$\begingroup\$ I've edited this down to a stub now that it's been posted to save space \$\endgroup\$ Jun 17, 2021 at 20:30
3
\$\begingroup\$

Create word lightning

Posted

\$\endgroup\$
2
  • \$\begingroup\$ Trees can be taken in different formats, right? \$\endgroup\$
    – Wezl'
    May 14, 2021 at 13:35
  • \$\begingroup\$ yes, they can be taken in any suitable format. \$\endgroup\$
    – Razetime
    May 14, 2021 at 13:47
3
\$\begingroup\$

Jump trajectory

\$\endgroup\$
3
\$\begingroup\$

Reconstruct a recursively prime-encoded integer

\$\endgroup\$
1
  • \$\begingroup\$ Looks great! At first glance seems easy but it's actually a little more difficult. I think it's ready to post, although you might want to wait a day or so. \$\endgroup\$
    – user100690
    Jun 20, 2021 at 12:14
3
\$\begingroup\$

Splinter metagolf

\$\endgroup\$
2
  • \$\begingroup\$ An example for a short repetitive string would be nice \$\endgroup\$
    – pxeger
    Jul 12, 2021 at 9:42
  • \$\begingroup\$ @pxeger Ok, I'll have a look. \$\endgroup\$
    – emanresu A
    Jul 12, 2021 at 9:43
3
\$\begingroup\$

Posted! - How many Sets are there?

\$\endgroup\$
2
  • \$\begingroup\$ Minor suggestion: Move the expected outputs to the start, because you have to scroll all the way to the end to see them. \$\endgroup\$
    – user
    Jul 19, 2021 at 23:59
  • \$\begingroup\$ @user Done, thanks. \$\endgroup\$ Jul 21, 2021 at 4:36
3
\$\begingroup\$

Visual Encoding

I want to create a program to randomize certain words, however, I would like all the swapped letters to have the same form factor as the previous one.

Challenge

Given a string of only lowercase letters (and no spaces), randomize its letters according to the following groups:

1: acemnorsuvwxz
2: bdfhiklt
3: gpqy

Each letter cannot be transformed into the same letter as it started as. Additionally, choosing the new character must be uniformly random (within codegolf guidelines).

One final thing is that for the letter j, it must be transformed into either group 2 or group 3, and this can be done by either:

Uniformly choosing between each group and then uniformly choosing a letter or Uniformly choosing between any of the letters in both groups

Note that nothing can turn into j itself.

Examples

helloworld -> kadfrszmhl
jamaica -> genokac
jamaica -> penokac
abpj -> odyt

This is so the goal is to create the shortest answer in bytes.

\$\endgroup\$
3
\$\begingroup\$

Find the necessary Files

Let's assume you have program that needs some of the files in a given folder to run. But not all the files in this folder are actually necessary. You can only find out which are necessary be removing/adding files from/to that folder, running the program and then observing whether it runs or throws or fails. The goal is finding exactly the necessary set of files with the minimial number of calls to the program.

Let's formalize it a little bit:

You are given a black-box-function \$ f: \{0,1\}^n \to \{0,1\} \$ that is of the form \$f(x_1, \dots, x_n) = \prod_{i \in I} x_i\$ where \$I\subseteq \{1,2,3,\ldots,n\}\$.

Your goal is finding \$I\$.

Your program may only interact with \$f\$ by evaluating it at various \$x \in \{0,1\}^n\$.

Your score is \$ S= \prod_{m=1}^M (1+s_k)\$ where \$s_k\$ is the number of evaluations of \$f\$ you needed for the example \$k\$ in the test battery. The least score wins.

Test Battery

META: Not sure yet if I should explicitly define a test battery or just let participants iterate through all possible functions up to some \$n\$.

In the following list, the first column represents \$n\$ (the number of arguments) followed by the set \$I\$:

n  | I
3  | 1
3  | 1 3
3  | 1 2 3
4  | 2 3 4
10 | 1 3 5 6 7 9

The last entry for instance represents the function \$ f(x_1, x_2, \ldots x_{10}) = x_1 \cdot x_3 \cdot x_5 \cdot x_6 \cdot x_7 \cdot x_9\$

\$\endgroup\$
1
  • \$\begingroup\$ Could the title have the "files" removed to be more abstract (or use another analogy)? On the surface this might look like a filesystem question \$\endgroup\$
    – pxeger
    Aug 10, 2021 at 11:05
3
\$\begingroup\$

Parse some Husk (WIP)

Husk is a "functional golfing language inspired by Haskell." Its syntax is prefix, albeit with a twist: Husk's functions can be curried: so uses its static typing to determine how many arguments a function should take at a time. For example, Husk can tell that m+2:2;3 should be parsed as m(+2)(:2(;3)) and not, say, m(+2(:2(;3))) or m(+)(2:2;3), which are meaningless.

Task

This challenge involves validating a subset of Husk that has 5 functions and two types: integers 0-9 or lists of those integers. It also does not have parentheses or overloading. Your submission will take a string consisting only of the characters mo;:+0123456789 and determine whether it is a valid program according to the rules below.

In the following descriptions, "unary integer function" refers to a function that takes an integer and outputs another. It's a made-up term, let me know if there's a better one. "list" refers to a list of integers, and "integer" refers to an integer 0-9. You don't need to understand the purposes of each function, just the types of their inputs and outputs.

  • 0-9 are values/integers.
  • ; is the unary function singleton. Its argument is an integer x, and it returns a list ([x]).
  • : is the binary function prepend. Its first argument is an integer x and the second is a list l. It returns x prepended to l ([x, ...l]).
  • m is the binary function map. Its first argument is a unary integer function f and the second a list of integers l. It returns [f(l[0]), f(l[1]), ..., f(l[-1])].
  • o is the trinary function compose. Its first argument is a unary integer function f and the second a unary integer function g. The third is an integer x. It returns f(g(x)).

Here is what their types might look like in Haskell:

(;) :: Int -> [Int
(:) :: Int -> [Int] -> [Int]
m :: (Int -> Int) -> [Int] -> [Int]
o :: (Int -> Int) -> (Int -> Int) -> Int -> Int

Here is pseudo-pseudo-pseudo-not-even-BNF-anymore:

<int> ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | + <int> <int>
<list> ::= ; <int> | : <int> <list> | m <unary-int-int> <list>
<unary-int-int> ::= o <unary-int-int> <unary-int-int>
<valid-husk-program> ::= <int> | <list>

Questions for Meta:

  • Is this collection of functions okay? Should I add more or replace/remove some?
  • Is this challenge interesting?
  • Is this a dupe?
  • Is the explanation good enough? How can I make it clearer?
  • This currently doesn't have a lot of variety in the currying. Should the functions given to map/compose also be allowed to input/output lists? (and if so, would lists be allowed to be nested?)
  • Can Perl regex do this? I'm making this challenge hoping that it can't.
\$\endgroup\$
2
  • 2
    \$\begingroup\$ You haven't really specified what the output is. The closest is saying the task is to "validate", but what do we actually need to do? \$\endgroup\$
    – pxeger
    Aug 20, 2021 at 16:10
  • \$\begingroup\$ are we validating or executing(akin to the gelatin challenge)? \$\endgroup\$
    – Razetime
    Sep 3, 2021 at 7:52
3
\$\begingroup\$

Volume of a 3d model

In this challenge, you'll take a shape as input, consisting of a number of triangles forming an outer shell. Your task will be to find the volume of the resulting shape.

You can assume the triangles all connect to exactly one other triangle per side, and the surface does not cross over itself. You will not get an input where two separate solids touch only at points or edges.

Test cases and sample implementation coming soon

\$\endgroup\$
7
  • \$\begingroup\$ I like this one. I think that its got some tricky bits to it, like getting the normals for the triangles and ensuring that they are facing the right way. As far as input format goes, an Ascii stl file may be a good option, as it breaks down the meshes into faces and provides the normals as well. \$\endgroup\$
    – JPeroutek
    Oct 15, 2021 at 19:36
  • \$\begingroup\$ is the winding of the input going to be consistent or could it be random? also what is the error bound for the output? \$\endgroup\$
    – don bright
    Oct 18, 2021 at 3:15
  • \$\begingroup\$ @donbright Random, I'm thinking. For the output, floating point errors are fine, as long as the calculations would theoretically return the correct result. \$\endgroup\$ Oct 18, 2021 at 13:27
  • \$\begingroup\$ sounds like a good bit of fun but i kind of predict people will ask for some kind of precise bounding on the error like +/- 1 percent or something. \$\endgroup\$
    – don bright
    Oct 19, 2021 at 2:07
  • \$\begingroup\$ @donbright The answer could be off by a thousand percent, if I reimplemented the language with arbitrary precision floats and it worked, I'm fine with it. That's way easier for everyone. Answerers don't need to worry about weird floating point tricks, and I don't need to tell them their answer's invalid :) \$\endgroup\$ Oct 19, 2021 at 4:15
  • \$\begingroup\$ i mean the question is how do you know the algorithm works without running it and comparing the result to the known correct value? \$\endgroup\$
    – don bright
    Oct 20, 2021 at 2:31
  • \$\begingroup\$ @donbright Probably a mix of trust, and it most likely being close enough to the correct answer that anything other than floating point errors is unlikely \$\endgroup\$ Oct 20, 2021 at 2:34
3
\$\begingroup\$

Pythagorean triples given the hypotenuse.

\$\endgroup\$
3
\$\begingroup\$

Is This Scrabble Board Valid?

\$\endgroup\$
3
\$\begingroup\$

Leave ABACABA on the tape

Note that will be removed post sandboxing: This challenge is Brainfuck-specific, but I hope that its contents make the reason why sufficiently clear.

Write a brainfuck program which leaves the following sequence on the tape:

0 1 0 2 0 1 0 3 0 1 0 2 0 1 0 4 0 1 0 2 0 1 0 3 0 1 0 2 0 1 0 ...

This sequence may be familiar to some as ABACABADABACABA... or A007814.

Assume an implementation of BF with an endless tape and arbitrarily large (but not arbitrarily small) integers.

You should link to a visualizer to prove that your program works as you say it does, but if this isn't fast enough to witness the first few (say 4) numbers in ABACABA you'll have to explain it yourself.

This is code-golf, so the shortest program operating within these rules wins. Have fun!

\$\endgroup\$
1
  • \$\begingroup\$ Because a BF program would likely do destructive edits to the previous terms or add scratch data to the end while advancing the sequence, I'd propose a more rigorous definition: "Write a BF program where, given any prefix of the ABACABA sequence, running the program for some finite number of steps will give the pattern at the start of the tape." \$\endgroup\$
    – Bubbler
    Nov 18, 2021 at 1:32
3
\$\begingroup\$

Light-Cycle KotH

\$\endgroup\$
9
  • \$\begingroup\$ I'd recommend removing all bots that crash in the same turn. Basing it off of external factors like submission dates is a bit unfair. \$\endgroup\$ Sep 13, 2021 at 17:04
  • \$\begingroup\$ My justification for removing only 1 per turn is that it simplifies the logic of generating a leaderboard and removes some edge cases, otherwise things like 3-way ties for first place might be possible if all the bots crash at the same time. \$\endgroup\$
    – thesilican
    Sep 13, 2021 at 20:51
  • \$\begingroup\$ I feel like biasing the rules against newer submissions is fair. After all, new submissions inherently have the advantage that they're able to see the older submissions and can strategize around these existing submissions. \$\endgroup\$
    – thesilican
    Sep 13, 2021 at 20:55
  • \$\begingroup\$ The issue is that the oldest submissions functionally move first, meaning that being the first bot posted is a significant advantage. What about edits? If a bot is changed, does it drop to the bottom? I agree that removing all bots which crash is the right call. \$\endgroup\$ Sep 14, 2021 at 18:36
  • \$\begingroup\$ Hmm... I was going to disallow edits, so that anyone who wanted to update their bot must instead post it as a new bot. @Spitemaster Are edits typically allowed for KotH submission? \$\endgroup\$
    – thesilican
    Sep 14, 2021 at 20:27
  • \$\begingroup\$ Frequently; not always. But you've still got the problem of earlier entries effectively moving first. If you really want to do it this way, it doesn't make sense to have simultaneous movement (because it's not really simultaneous). \$\endgroup\$ Sep 14, 2021 at 20:34
  • \$\begingroup\$ Ok, that seems fair, I will update post to allow for simultaneous movement \$\endgroup\$
    – thesilican
    Sep 14, 2021 at 20:49
  • \$\begingroup\$ If I were you, I'd consider sizing the arena based on number of bots. \$\endgroup\$
    – emanresu A
    Sep 14, 2021 at 20:56
  • \$\begingroup\$ That seems like a reasonable suggestion, what kind of scaling do you think would be good? I'm thinking maybe something like a square with side-length 2n+6, for n players. \$\endgroup\$
    – thesilican
    Sep 14, 2021 at 21:02
3
\$\begingroup\$

Randomly capitalize half of a string

\$\endgroup\$
3
  • \$\begingroup\$ Will a string of length 0 ever be an input? \$\endgroup\$
    – dzaima
    Jun 15, 2017 at 12:26
  • \$\begingroup\$ @dzaima no, clarified by saying length will always be positive \$\endgroup\$
    – Mayube
    Jun 15, 2017 at 13:57
  • 2
    \$\begingroup\$ Change "positive" to "non-zero"? You can't have a negative-length string, last time I checked... \$\endgroup\$
    – pxeger
    Dec 1, 2021 at 18:15
3
\$\begingroup\$

Write a number in overflowed binary

\$\endgroup\$
1
  • \$\begingroup\$ Maybe define a overflowed binary number a binary number where one or more of it's digits goes over 1? \$\endgroup\$
    – Alan Bagel
    Dec 3, 2021 at 17:21
3
\$\begingroup\$

Sum powers to n

Posted to main

\$\endgroup\$
3
\$\begingroup\$

Solve an Inglenook Sidings Puzzle

Tags:

Posted! After about 2 weeks in Sandbox

\$\endgroup\$
3
  • \$\begingroup\$ "Model railroading", not "railroad modeling?" \$\endgroup\$
    – Bubbler
    Nov 25, 2021 at 2:17
  • \$\begingroup\$ @Bubbler specifically model railroading. The puzzle was made to create operational interest on small layouts, since it only needs 2 switches and 4 pieces of relatively short track \$\endgroup\$
    – bigyihsuan
    Nov 25, 2021 at 4:05
  • \$\begingroup\$ So this challenge proposal has been in here for just about a week now; are there any flaws in this? I don't want to post this to the main site and get feedback that should've been caught in meta \$\endgroup\$
    – bigyihsuan
    Dec 1, 2021 at 16:11
3
\$\begingroup\$

Worst time complexity in under 100 bytes

Time complexity, typically represented in Big O notation, represents how long a program will typically take to run given some input(s), ignoring constants.

Your task is to do one of the following things, with the worst time complexity possible:

  • Sort an array of integers
  • Find duplicates in an array
  • Find longest strictly increasing slice of an array of integers

Tasks:

All of the tasks involve taking one input, an array of items, in any reasonable format, and returning an array. If your language supports mutable array data types, this is an allowed output format. Assume all items in the arrays will be (not necessarily positive) integers.

If you choose sorting: You may choose to sort the array by minimum or maximum.

If you choose listing duplicates: You may include a duplicate item any number of times in the output; [1, 2, 2, 3, 4] could result in [2, 4], [2, 2, 4], or even [2, 4, 4, 4].

If you choose longest strictly increasing slice: Duplicate items do not count as increasing, so [1, 2, 2, 4] is not strictly increasing. The items do not have to increase by a steady amount; [-1, 4, 14, 16, 17] is strictly increasing.

Rules:

Your program must be 100 bytes or less. Your program should terminate in a finite amount of time. You can assume your program will never run out of memory, and it does not have to terminate before the heat death of the universe.

This is a . The winner will be based on the average time complexity, with slower being better, followed by the best case and then worst case for ties.

\$\endgroup\$
5
  • \$\begingroup\$ Unfortunately, this answer broke all "irreducible" challenges. You can execute (almost) arbitrary code unrelated to the task without breaking the "irreducible" requirement. \$\endgroup\$
    – Bubbler
    Apr 22, 2021 at 0:16
  • \$\begingroup\$ @Bubbler Hmm, and I don't think irreducible is a sensible requirement for this either. It definitely makes more sense with bytes than time, along with pristine. I'll have to think about some creative limitations. Maybe unique bytes only? \$\endgroup\$ Apr 22, 2021 at 0:22
  • \$\begingroup\$ Now this is somewhat too close to bignum computation challenge, since all the biggest numbers are actually a fast-growing function applied to some number. They can be trivially converted to take the length of the input, and then used in the algorithm in some way (or just discarded). \$\endgroup\$
    – Bubbler
    Dec 16, 2021 at 8:32
  • \$\begingroup\$ How about this: Choose a decision problem, and write code that solves it, within 100 bytes (or use a partially ordered score instead of a byte limit). Answers are compared based on the minimal time complexity of the problem, not the implementation. So if someone solves an EXPTIME-hard problem, they beat whoever solves a problem in P. This solves the problem of people doing useless calculations, since it doesn't help them. Writing a sorting function that takes exponential time is not in any way better than just doing a sort in O(nlogn) time. \$\endgroup\$
    – AnttiP
    Dec 16, 2021 at 11:25
  • \$\begingroup\$ @AnttiP That could be cool, but it sort of goes against what I was going for (ridiculously slow sorting algorithms). Maybe a separate challenge idea? \$\endgroup\$ Dec 16, 2021 at 14:27
3
\$\begingroup\$

Nth FizzBuzz Number

\$\endgroup\$
1
  • \$\begingroup\$ Maybe allow any different 4 distinct inputs for Fizz, Buzz, FizzBuzz and Number? \$\endgroup\$
    – pajonk
    Dec 16, 2021 at 11:48
3
\$\begingroup\$

Light it up

\$\endgroup\$
4
  • \$\begingroup\$ Maybe you can fill empty cells by some characters like . in your examples and testcases. Or it could be confusing: L.#. is falsy but L.# is truthy, but it is hard to see the difference. \$\endgroup\$
    – tsh
    Nov 2, 2021 at 1:53
  • \$\begingroup\$ @tsh Ok, thanks! \$\endgroup\$
    – emanresu A
    Nov 2, 2021 at 2:02
  • \$\begingroup\$ "some squares are walls, some are empty, and some are lights". Since there are testcases where only empty cell is there, will there be any testcases like ####? \$\endgroup\$
    – tsh
    Nov 2, 2021 at 5:23
  • \$\begingroup\$ @tsh Yes, see the fourth truthy one. I'll be more explicit that some may not occur at all. \$\endgroup\$
    – emanresu A
    Nov 2, 2021 at 6:13
3
\$\begingroup\$

Print □□Square□□ Numbers

Your task is to write a program or function that accepts an integer as input/argument and prints/returns all square numbers from 0 up to but not including n².

But the numbers should not just be perfect squares in the mathematical sense. They should be square in every sense. That is, the digits should

  • • occupy a square space, 5 lines by 5 columns (including separating space)
  • • form right angles at their joints
  • • be formed entirely from □ and space characters

Actually, the digits must be shaped exactly like these:

   □ □□□□ □□□□ □  □ □□□□ □□□□ □□□□ □□□□ □□□□ □□□□ 
   □    □    □ □  □ □    □       □ □  □ □  □ □  □ 
   □ □□□□ □□□□ □□□□ □□□□ □□□□    □ □□□□ □□□□ □  □ 
   □ □       □    □    □ □  □    □ □  □    □ □  □ 
   □ □□□□ □□□□    □ □□□□ □□□□    □ □□□□ □□□□ □□□□ 

Note the single column of space between each digit. Spaces at the end of each line are optional. (The three empty columns of spaces on the left side of the digit 1 are not optional.)

Each square number shall be printed on exactly 5 lines using these digits, and between each of these numbers shall be a single line containing no non-whitespace characters. You may optionally include extra blank lines at the beginning or end of the output.

Standard loopholes etc. Shortest solution in bytes is the coolest of beans.

Example Output (given the input 5):

□□□□
□  □
□  □
□  □
□□□□

   □
   □
   □
   □
   □

□  □
□  □
□□□□
   □
   □

□□□□
□  □
□□□□
   □
□□□□

   □ □□□□
   □ □
   □ □□□□
   □ □  □
   □ □□□□

(Note for sandbox: I know this is a good challenge because I had fun solving it myself. But I am worried there is another challenge I haven't seen that is too similar. Please let me know. I'll abandon it if so.)

\$\endgroup\$
3
  • \$\begingroup\$ Can't find any dupes on this search so it is probably clear. \$\endgroup\$
    – Razetime
    Jan 7, 2022 at 4:45
  • 1
    \$\begingroup\$ Closely related \$\endgroup\$
    – pxeger
    Jan 7, 2022 at 7:58
  • \$\begingroup\$ @pxeger yeah that's probably similar enough not to post this \$\endgroup\$
    – quintopia
    Jan 7, 2022 at 17:37
3
\$\begingroup\$

Expand a Rubik's Cube Commutator

Tags:

Posted: Expand a Rubik's Cube Commutator

\$\endgroup\$
5
  • \$\begingroup\$ What do you mean by "expand" the commutator? Also, 3x3x3*, a 3x3 would be a rubik's square :) \$\endgroup\$ Jan 11, 2022 at 15:12
  • \$\begingroup\$ @thejonymyster The common names for Rubik's cubes are by the size of a face since they're usually cubes, so we just call them "3x3" for a 3x3x3 cube, etc. Only in cuboids like the 3x3x4 cuboid actually have the 3rd dimension "Expanding" the commutator == Listing out all the moves performed in the commutator \$\endgroup\$
    – bigyihsuan
    Jan 11, 2022 at 19:59
  • \$\begingroup\$ ahh, that makes sense, for both parts. +1 \$\endgroup\$ Jan 11, 2022 at 20:03
  • 1
    \$\begingroup\$ "Each part of the commutator can be a separate value" - I see this is to make IO more flexible than flat string to flat string, which is good, but I would go further and allow the moves themselves be separate values in each part, and allow a list of moves as the output in order to focus on the challenge itself. This would allow, for example, [["F'", "U2", "R"], ["D", "B2"]] -> ["F'", "U2", "R", "D", "B2", "R'", "U2", "F", "B2", "D'"]. \$\endgroup\$ Jan 11, 2022 at 23:07
  • \$\begingroup\$ I couldn't resist and just gave it a go in Jelly and got a 15 byte solution (assuming IO is further relaxed as I suggested, which I believe you will do given your current relaxation). This is a good challenge IMO. \$\endgroup\$ Jan 11, 2022 at 23:20
3
\$\begingroup\$

Will the tower balance?

You are given as input a tower made of bars of unit height, and your task is to decide if the tower is stable. Here is an ascii art drawing of a tower:

 #
####
# ####
#####

For extra clarity here is the same tower but with the different bars in different characters:

 A
BBBB
C DDDD
EEEEE

The bars are rigid, but they are not connected to each other. Even though the bars are not connected, they stay still under the influence of gravity. Here however is a tower that is not stable:

      B
CCCCCCCC
   D
  EEE
FFFFFFFF

In this tower, under the influence of gravity, the top bar will fall to the right.

The following tower is metastable:

AA
B

The center of mass of the A-bar lies on top of the edge of the B-bar. In this kind of situation the tower is considered unstable, since even a small perturbation will cause it to fall eventually.

Input/output format

The input format is an ascii drawing of the tower like so:

 ###
  #
### #

In this picture there are 4 bars. It is guranteed that all bars are on top of another bar or on top of the ground and that every row has at least one bar. You can use a different printable ascii character instead of #. You can also take a 2d array instead of a string and use two distinct values for # and . In that case please use simple values, that don't encode extra information (standard loopholes prohibited).

Output two distinct values for STABLE and UNSTABLE.

Test cases

#

STABLE

###
 #
 ##
  #

UNSTABLE

  ###
 ###
###

UNSTABLE (metastable)

#
#     ######
####    ##
 #      ##

STABLE

###
 #
#####
 #

STABLE

 #
#####
 #

UNSTABLE

######  #
 #  #   #
### #####
 #   #
 #####
   #

STABLE

\$\endgroup\$
2
  • 1
    \$\begingroup\$ The rules do not actually specify what makes a tower stable. The stable test cases use balancing methods not stated anywhere, and the rules themselves just seem to be more examples. As a non physicist, "use gravity" isn't enough information IMO. This is a cool idea though and +1 once that's fixed \$\endgroup\$ Jan 17, 2022 at 13:49
  • \$\begingroup\$ Just highlighting the bars on their own would be interesting IMO \$\endgroup\$
    – emanresu A
    Jan 17, 2022 at 18:36
1
19 20
21
22 23
145

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .