577
\$\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\$
2
  • \$\begingroup\$ What if I posted on the sandbox a long time ago and get no response? \$\endgroup\$
    – None1
    Commented May 15 at 14:05
  • \$\begingroup\$ @None1 If you don't get feedback for a while you can ask in the nineteenth byte \$\endgroup\$ Commented May 29 at 13:27

4831 Answers 4831

1
22 23
24
25 26
162
3
\$\begingroup\$

Draw an ASCII Volume

Posted here

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

Posted here

\$\endgroup\$
3
  • 2
    \$\begingroup\$ What is the order each rules applied? For example, for rules "11=12", "12=21", "22=3". If input is "1112", should it be "1112 -> 1212 -> 2121" or "1112 -> 1221 -> 131" or "1122 -> 1222 -> 123"? \$\endgroup\$
    – tsh
    Commented Feb 22, 2022 at 7:58
  • \$\begingroup\$ All of them. See the original specification for Shue in the linked challenge, or the interpreter. \$\endgroup\$
    – Seggan
    Commented Feb 22, 2022 at 15:11
  • \$\begingroup\$ As challenges should be self-contained, I suggest you add the mathematical definition from my post (and maybe an informal explanation of how the rules are applied non-deterministically) \$\endgroup\$
    – AnttiP
    Commented Feb 22, 2022 at 16:46
3
\$\begingroup\$

Draw a Signal strength indicator

Posted here

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

Convert to UTF-∞

\$\endgroup\$
1
  • \$\begingroup\$ I believe if Unicode code points are used up. They are most probability caused by CJK characters. Until then, there are already >50% used code points represent CJK characters. And characters used by Chinese dialect other than Cantonese (HK source) are still missing in Unicode. \$\endgroup\$
    – tsh
    Commented Feb 22, 2022 at 8:23
3
\$\begingroup\$

Ragged slice

Your task is to slice a ragged list. Your input is a ragged list and two lists of integers, corresponding to the beginning index and end index of the slice, where the beginning index is inclusive and the end index is exclusive.

Explanation

Let's start from the very basics. How does regular slicing work? Let's say we have the list [a,b,c,d,e,f] and we want the slice [1,4]. How does this work? Here is an illustration:

[a,b,c,d,e,f]
^ ^ ^ ^ ^ ^ ^
0 1 2 3 4 5 6
  v v v v
  [b,c,d]

This means that [a,b,c,d,e,f][1,4]==[b,c,d]. Ragged slicing is a bit tricky, so please make sure that the previous diagram is mostly clear. Ok, now ragged lists.

Let's first just draw the indices like previously for the list [a,[b,c],[d,[e]],f]:

[a, [b,c] , [d, [e] ] ,f]
^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
0 1 1 1 1 2 2 2 2 2 2 3 4
    0 1 2   0 1 1 1 2
                0 1

Now, let's see what a slice of [1 1, 2 1 0] would look like:

[a, [b,c] , [d, [e] ] ,f]
^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
0 1 1 1 1 2 2 2 2 2 2 3 4
    0 1 2   0 1 1 1 2
                0 1
      v v v v v v       
      ,c] , [d, [
       c] , [d
     [[c] , [d]]

The last steps are probably the most confusing. But basically we want to do two things, in the following order:

  1. Trim the left side until an element, or an opening bracket is encountered. Do the same on the right side, except with a closing bracket.
  2. Balance the remaining brackets and keep the depth of every array element the same as in the input, by wrapping the output in brackets.

Now, let's look at what happens when we have empty arrays. In fact, let's replace every letter in our previous example with an empty array:

[[] , [[] ,[] ] , [[] , [[] ] ] ,[] ]
^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
0 0 1 1 1 1 1 1 2 2 2 2 2 2 2 2 3 3 4
  0   0 0 1 1 2   0 0 1 1 1 1 2   0
        0   0       0   0 0 1
                          0
          v v v v v v v v
          ,[] ] , [[] , [
           [] ] , [[]
         [[[] ] , [[]]]

Notice that for the empty array, the starting bracket doesn't have an index. This is because for an empty array, an index of 0 is already "one past the end" in an empty array, so there is no smaller index for the beginning.

If we would have used index 2 1 0 0 as the ending index, then this would have happened:

[[] , [[] ,[] ] , [[] , [[] ] ] ,[] ]
^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
0 0 1 1 1 1 1 1 2 2 2 2 2 2 2 2 3 3 4
  0   0 0 1 1 2   0 0 1 1 1 1 2   0
        0   0       0   0 0 1
                          0
          v v v v v v v v v
          ,[] ] , [[] , [[]
           [] ] , [[] , [[]
         [[[] ] , [[] , [[]]]]

Lastly, let's see what happens if the slice is empty. We'll use [1 1 0, 2]:

[[] , [[] ,[] ] , [[] , [[] ] ] ,[] ]
^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
0 0 1 1 1 1 1 1 2 2 2 2 2 2 2 2 3 3 4
  0   0 0 1 1 2   0 0 1 1 1 1 2   0
        0   0       0   0 0 1
                          0
            v v v
            ] ] ,

Here after step 1, the input just disappeared. We'll just return the empty list [].

Rules

Your input will contain only lists (no numbers, letters, etc.), and the starting and ending index. Indices can in bounds or one past the last in some array. Indices are non-empty lists of non-negative integers. The starting index is not greater than then ending index.

You can choose the order of the indices and also if they are 0 or 1 based (but they must be inclusive-exclusive).

This is so shortest code wins.

Meta

This is a bit tricky to explain. If there were parts that were unclear, or poorly written, etc. then please comment. If you think there is a better explanation, please also let me know.

\$\endgroup\$
4
  • \$\begingroup\$ I don't get why sometimes the opening bracket is indexed, and sometimes not. Could you explain? \$\endgroup\$
    – pajonk
    Commented Feb 27, 2022 at 16:41
  • \$\begingroup\$ @pajonk I've added a paragraph explaining that. Basically it only happens for empty lists (that the starting bracket doesn't have an index). \$\endgroup\$
    – AnttiP
    Commented Feb 27, 2022 at 16:57
  • \$\begingroup\$ Ok, that was a little confusing. Suggestion: replace empty lists with elements (like numbers) and disallow empty lists - wouldn't this be +/- equivalent and easier to explain? \$\endgroup\$
    – pajonk
    Commented Feb 27, 2022 at 17:06
  • \$\begingroup\$ I would suggest simply index any elements and the ending of an array. So for example, Array [1, 2, 3] is indexed as [ 0=>1 1=>, 2 2=>, 3 3=> ]. And a slicing simply exclude the ending element. \$\endgroup\$
    – tsh
    Commented Mar 1, 2022 at 7:56
3
\$\begingroup\$

Hello Shue! (Cops)

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

Circular chained compound

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

Draw the Ukrainian Flag

Draw the Ukrainian Flag

\$\endgroup\$
3
  • 1
    \$\begingroup\$ "horizontally down the middle" -> "horizontally across the middle" \$\endgroup\$
    – att
    Commented Mar 18, 2022 at 21:54
  • \$\begingroup\$ @att oops, fixed \$\endgroup\$
    – Ginger
    Commented Mar 18, 2022 at 21:57
  • \$\begingroup\$ Ginger u stole my challange idea :D (i thought it was too easy so i didnt post it) \$\endgroup\$
    – DialFrost
    Commented Mar 19, 2022 at 0:23
3
\$\begingroup\$

Resolve a Super Auto Pets Round

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

Remove unmatched brackets

\$\endgroup\$
8
  • \$\begingroup\$ "containing of brackets"->"containing brackets"? Also, what characters to expect apart from brackets? You may also want to specify that we want to match the closest brackets together (inferred from example). And I think you lost first 543 in your example. \$\endgroup\$
    – pajonk
    Commented Mar 17, 2022 at 19:51
  • \$\begingroup\$ @pajonk Fixed those. \$\endgroup\$
    – emanresu A
    Commented Mar 17, 2022 at 20:19
  • \$\begingroup\$ What's with the 1 in the third testcase? \$\endgroup\$
    – ophact
    Commented Mar 18, 2022 at 6:30
  • \$\begingroup\$ @ophact A typo. \$\endgroup\$
    – emanresu A
    Commented Mar 18, 2022 at 7:44
  • \$\begingroup\$ "the input will only contain those and lowercase letters" - but the example string contains digits too! Could you remove them? \$\endgroup\$
    – pxeger
    Commented Mar 23, 2022 at 6:39
  • \$\begingroup\$ @pxeger Oops... \$\endgroup\$
    – emanresu A
    Commented Mar 23, 2022 at 8:28
  • 2
    \$\begingroup\$ I think it would be good to add a definition of "matched." It may not be immediately obvious to everyone who reads the challenge why [abc]def] should result in [abc]def and not [abcdef], since you could view either close bracket as being matched with the open bracket. \$\endgroup\$
    – DLosc
    Commented Mar 23, 2022 at 14:06
  • \$\begingroup\$ @DLosc Done. (filler) \$\endgroup\$
    – emanresu A
    Commented Mar 24, 2022 at 3:26
3
\$\begingroup\$

Interpret +-=

\$\endgroup\$
9
  • \$\begingroup\$ I would say this is a fairly simple challenge, but it could still produce some interesting answers. However, it definitely needs some more clarification on input specifications. Should code read from a file? Prompt for input once and interpret that program? Prompt for an input, interpret that, and then repeat? \$\endgroup\$
    – des54321
    Commented Mar 23, 2022 at 21:36
  • \$\begingroup\$ @des54321 prompt, interpret, repeat, as i think that has more golfing potential \$\endgroup\$ Commented Mar 23, 2022 at 22:07
  • 1
    \$\begingroup\$ However I do realize that it won't exactly work on TIO... so idrk \$\endgroup\$ Commented Mar 23, 2022 at 22:10
  • \$\begingroup\$ A few things I think you should specify : Is this code-golf or something else ? Can we assume input is always valid? Usually we do the task just once, it can be a full program or a function tacking arguments. \$\endgroup\$
    – AZTECCO
    Commented Mar 24, 2022 at 12:17
  • \$\begingroup\$ @AZTECCO 1. this... is code-golf... are you ok? 2. Yes you can. \$\endgroup\$ Commented Mar 24, 2022 at 21:13
  • \$\begingroup\$ Instead of explaining my suggestions in a comment I edited adding comments, feel free to reject anything you don't like. Hope it helps a bit.. Nice challenge btw! \$\endgroup\$
    – AZTECCO
    Commented Mar 24, 2022 at 21:41
  • \$\begingroup\$ I would perhaps add a test case that results in negative output(s) (e.g. +=----= resulting in 1 -3) and perhaps one with multiple adjacent == (e.g. --== resulting in -2 -2). Apart from that I'd say it's good enough to be posted. And it may be simple, but it's good to have some simple challenges every now and then. :) In fact, I'd say it becomes harder and harder to come up with easy challenges suitable for beginners that aren't duplicates yet, so +1 from me. (I've already prepared a solution for when it goes to main.) \$\endgroup\$ Commented Mar 28, 2022 at 15:31
  • \$\begingroup\$ @KevinCruijssen how about some of these? \$\endgroup\$ Commented Mar 28, 2022 at 19:42
  • \$\begingroup\$ @BowlingPizzaBall Looks good. 👍 \$\endgroup\$ Commented Mar 28, 2022 at 20:35
3
\$\begingroup\$

Give me the electronic configuration.

As simple as the title.

Input will be a number denoting the atomic number.

The output will be the electronic configuration of the element of the given atomic number.

There are 2 rules for electronic configuration:

  • The maximum number of electrons each shell can hold is given by \$2n^2\$ where n is the shell number starting from 1.
  • The number each shell is allowed to hold from the last shell is given by \$2n^2\$ where n is the number starting from 2, in reverse.

You must fill each shell to it's limited capacity from left to right, with the remaining electrons on the last shell.

Test cases

12 -> [2,8,2]
13 -> [2,8,3]
20 -> [2,8,8,2]
86 -> [2,8,18,32,18,8]
29 -> [2,8,18,1]
\$\endgroup\$
9
  • \$\begingroup\$ You may specify this a little more, as according to current spec any of [2,2,8], [2,8,1,1],[1,1,1,1,1,1,1,1,1,1,1,1] is a valid answer for 12. \$\endgroup\$
    – pajonk
    Commented Apr 10, 2022 at 20:03
  • 1
    \$\begingroup\$ @pajonk i added this line You must fill each shell to it's limited capacity. \$\endgroup\$
    – zoomlogo
    Commented Apr 11, 2022 at 3:23
  • \$\begingroup\$ 29 should return [2,8,18,1], not [2,8,18,2] \$\endgroup\$
    – naffetS
    Commented Apr 11, 2022 at 4:12
  • 1
    \$\begingroup\$ BTW, it's more accurate to call it the electronic shell structure, not the electronic configuration \$\endgroup\$
    – naffetS
    Commented Apr 11, 2022 at 4:13
  • 1
    \$\begingroup\$ @Steffan that's how we learnt it \$\endgroup\$
    – zoomlogo
    Commented Apr 11, 2022 at 5:09
  • \$\begingroup\$ @PyGamer0 You must fill each shell to it's limited capacity from left to right, with the remaining electrons on the last shell, maybe? Remember, you're dealing with programmers here ;-) \$\endgroup\$
    – pajonk
    Commented Apr 11, 2022 at 11:14
  • \$\begingroup\$ @pajonk ok, edited. \$\endgroup\$
    – zoomlogo
    Commented Apr 11, 2022 at 11:29
  • \$\begingroup\$ If you look up the electronic configuration of atomic number 12, for example, you'll see things like 1s^2 2s^2 2p^6 3s^2 at the top. If you look up electron shells of atomic number 12, it will tell you 2,8,2. \$\endgroup\$
    – naffetS
    Commented Apr 11, 2022 at 16:07
  • 1
    \$\begingroup\$ I just noticed this is a duplicate of codegolf.stackexchange.com/questions/37657/… \$\endgroup\$
    – naffetS
    Commented Apr 19, 2022 at 18:36
3
\$\begingroup\$

Convert angle to clock time

\$\endgroup\$
5
  • \$\begingroup\$ I strongly discourage strict output format restriction. Also, you may want to specify that only integer angles will be inputted (if that's the case). \$\endgroup\$
    – pajonk
    Commented Apr 14, 2022 at 12:18
  • \$\begingroup\$ @pajonk Is it okay now? \$\endgroup\$
    – Yousername
    Commented Apr 14, 2022 at 12:30
  • \$\begingroup\$ As long as identifiable as clock times by humans is also a list of hours and minutes and other reasonable formats - I'm fine with that :-) \$\endgroup\$
    – pajonk
    Commented Apr 14, 2022 at 12:38
  • \$\begingroup\$ Outputting 0:00 instead of 12:00 is invalid, right? \$\endgroup\$
    – naffetS
    Commented Apr 17, 2022 at 23:34
  • \$\begingroup\$ @Steffan Yes. The 12-hour time convention should be used. \$\endgroup\$
    – Yousername
    Commented Apr 18, 2022 at 0:01
3
\$\begingroup\$

How normal is this group?

Let \$(G, *)\$ be some group. That is, for all \$x, y, z \in G\$, the following axioms hold:

  • \$x * y \in G\$
  • \$x * (y * z) = (x * y) * z\$
  • There exists some \$e \in G\$ such that \$x * e = e * x = x\$
  • There exists some \$x^{-1} \in G\$ such that \$x * x^{-1} = x^{-1} * x = e\$

For some group \$(G, *)\$, we define a subgroup of this as a group \$(H, *)\$ for some subset \$H \subseteq G\$. The trivial subgroups of a group \$(G, *)\$ are when \$H = \{e\}\$ (the identity element of \$G\$) and when \$H = G\$.

For the sake of convenience, we will denote \$x * y\$ as \$xy\$. Let \$N\$ be a subgroup of \$G\$. We say that \$N\$ is normal if, for all \$g \in G\$ and \$x \in N\$, \$gxg^{-1} \in N\$. For any group, the trivial subgroups are normal, and so any group has at least 2 normal subgroups.

For example, let \$G = \{0,1,2,3\}\$ and \$x * y = x + y \bmod 4\$. The subgroups of \$G\$ are \$\{0\}\$, \$\{0, 2\}\$ and \$\{0,1,2,3\}\$, all of which are normal. Therefore, \$(G, *)\$ has 3 normal subgroups.


Given a finite group, output a positive integer \$n \ge 2\$ counting the number of normal subgroups of the input. You may take a group as input in any reasonable manner, including but not limited to:

  • The set \$G\$ (as a set, list, etc.) along with a black-box function \$* : G \times G \to G\$
  • A square matrix representing the Cayley table of the group. You may choose whether to take \$G\$ as a separate input
  • A collection of triples \$(a, b, c)\$ where \$a, b, c \in G\$ and \$c = a * b\$ (the order of such a triple is irrelevant, but must be consistent for all triples)
  • etc.

This is a challenge, so the shortest code in bytes in each language wins.


Test cases

G
∗ : G×G → G
output

{0,1,2,3}
a*b = a+b mod 4
3
\$\endgroup\$
0
3
\$\begingroup\$

Who needs 8 bits for one character?

\$\endgroup\$
5
  • \$\begingroup\$ I'm a little confused by the test cases in this challenge. Based on your description of how to get the solution, I wrote an (ungolfed) Python program that does that (as far as I know). However, my results differ greatly from yours, specifically in using "the fox" as input. For that string, you get [170, 76, 19, ...], but my code gets [172, 239, 134, ...]. I'll put a TIO link in another comment, if you want to try it out. I do note that your first index (the index for a under "How, though?") starts at one, not zero. Could you help me understand this difference in results? Thanks! \$\endgroup\$ Commented May 6, 2022 at 17:31
  • \$\begingroup\$ Try it online! Other than that problem, this sounds like a good challenge! +1 \$\endgroup\$ Commented May 6, 2022 at 17:31
  • \$\begingroup\$ @SylvesterKruin It is one indexed because otherwise, 000 may get lost in leading zeros. Your Python code has a couple problems. One is that it does not pad leading zeros to the binary of each character. Another is that your code has a bug where it does not output the last byte (because of Python exclusive ranges). Also, the last byte should pad zeros at the end, which it does not do. \$\endgroup\$
    – naffetS
    Commented May 6, 2022 at 17:54
  • \$\begingroup\$ Here is your code fixed: Try it online! \$\endgroup\$
    – naffetS
    Commented May 6, 2022 at 17:54
  • \$\begingroup\$ Ah, it didn't pad leading zeroes... that's what it was. I intentionally left out the last <8 bytes for reasons of simplicity. Thanks for the feedback! I'm looking forward to when this challenge is posted on the main site! \$\endgroup\$ Commented May 6, 2022 at 18:07
3
\$\begingroup\$

Derivative of a product

\$\endgroup\$
2
  • 1
    \$\begingroup\$ Is the input always at least 2 characters long? \$\endgroup\$
    – pxeger
    Commented May 2, 2022 at 13:31
  • \$\begingroup\$ @pxeger Yes. (filler) \$\endgroup\$
    – emanresu A
    Commented May 4, 2022 at 9:42
3
\$\begingroup\$

King of the Cards

\$\endgroup\$
1
  • \$\begingroup\$ This seems like it won't be particularly strategic \$\endgroup\$
    – rydwolf
    Commented May 9, 2022 at 18:01
3
\$\begingroup\$
\$\endgroup\$
0
3
\$\begingroup\$

Whyte Notation Translator

\$\endgroup\$
7
  • 1
    \$\begingroup\$ I think the scoring is sufficiently punishing to answers missing any cases that none will be able to make use of that in interesting ways. \$\endgroup\$
    – rydwolf
    Commented May 16, 2022 at 19:25
  • \$\begingroup\$ @RadvylfPrograms That's true, i guess i could change that to a multiplication instead. How about S = codesizefunc1 * (1+u) + codesizefunc2 * (1+v) ? Or maybe using the square root on u and v ? \$\endgroup\$ Commented May 16, 2022 at 19:27
  • \$\begingroup\$ Those might work too, but then you run into the risk of people optimizing the combination of code size and cases handled, and getting something boring like x=>"AA20". I think it'd be better to just use the sum of the code sizes as the score. Since it seems like parsing the os into indices into a list is probably going to be how most solutions work, and that's the interesting part of the challenge (since the outputs can't really be compressed), you might even consider allowing a third program that provides the list of names, that's weighted to count for less. \$\endgroup\$
    – rydwolf
    Commented May 16, 2022 at 19:39
  • \$\begingroup\$ @RadvylfPrograms What would be the purpose of the third program and the reduced weight of it ? \$\endgroup\$ Commented May 18, 2022 at 10:27
  • \$\begingroup\$ Since there's no interesting way to compress the list of names \$\endgroup\$
    – rydwolf
    Commented May 18, 2022 at 13:28
  • 1
    \$\begingroup\$ Prairie and Adriatic are both mapped to oOOOo. \$\endgroup\$
    – Arnauld
    Commented May 28, 2022 at 20:34
  • \$\begingroup\$ @Arnauld You're right, it's corrected and posted \$\endgroup\$ Commented May 29, 2022 at 17:13
3
\$\begingroup\$

Tell me how many there are, in Polish

Today, you're going to be writing Polish. No, not Polish notation—Polish, the actual language spoken in Poland.

Given a number and a noun, output a Polish sentence telling me that there are that many of that thing, using the appropriate template below.

The input consists of an integer in the range from 0 to 200, and a string of 1 to 10 lowercase ASCII letters (called the "noun"). You may accept these inputs in any reasonable format.

The output must consist of one of the below output templates, where the number in the template (if any) has been replaced with the input integer, and the word kot in the template has been replaced with the input noun.

Output templates

If the input number is 0, then use the output template

Nie ma żadnych kotów.

If the input number is 1, then use the output template

Jest 1 kot.

If the input number ends with 2, 3, or 4, but does not end with 12, 13, or 14, then use the output template

Są 4 koty.

In any other case, use the output template

Jest 8 kotów.

Note that the special characters used in these templates are:

  • ż (in "żadnych") – U+017C Latin small letter Z with dot above
  • ó (in the suffix "-ów") – U+00F3 Latin small letter O with acute
  • ą (in "Są") – U+0105 Latin small letter A with ogonek

You may output these characters in any reasonably common character encoding (including HTML entities), and you may use combining characters instead of precomposed characters (or even a mixture of the two).

Test cases

0 pomidor -> Nie ma żadnych pomidorów.
1 kwiat -> Jest 1 kwiat.
2 dom -> Są 2 domy.
5 wilk -> Jest 5 wilków.
13 komputer -> Jest 13 komputerów.
24 but -> Są 24 buty.
101 kurczak -> Jest 101 kurczaków.

Do plurals in Polish really work that way?

No, the way it actually works is much more complicated.

This is , so the shortest program in each language wins.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Suggested test-cases with 3-digit numbers ending with 02-04, 12-14, x2-x4 (with x>1) and outside those ranges (>101). \$\endgroup\$
    – pajonk
    Commented Jun 3, 2022 at 8:11
3
\$\begingroup\$

Find the winning Mormon Bridge card

Mormon Bridge (also called Oh Heck, similar to Oh H***) is a card game played (at least by me) with a standard Rook deck. A standard Rook deck includes cards 1-14 in 4 suits, which are black, red, green, and yellow, and a Rook card. Each round, a card is taken from the deck. It's suit is chosen as "trump." Then, players take turns playing cards. We'll call the suit of the first players card "sub-trump". If the Rook card is played, it wins. If trump was played, the highest trump card wins. Otherwise, the highest sub-trump card wins.

Your Goal

Your goal is to take input for:

  • Trump
  • Sub-trump
  • Cards played

and output the winning card. You may take input in any reasonable manner, swapping suit colors for numbers is fine, as is taking input for all cards played in order instead of separating the first card. , so shortest answer in bytes wins.

Test cases

(note that input can be taken in any reasonable format, these are written in a human-readable format.)

Trump: Red
Cards played: Red 4, Rook, Black 14, Yellow 7
Output: Rook

Trump: Green
Cards played: Red 14, Red 8, Green 2, Yellow 6
Output: Green 2

Trump: Yellow
Cards played: Red 5, Green 7, Red 12, Black 6
Output: Red 12

Meta

What tags should be on this? Are the rules clear enough?

\$\endgroup\$
2
  • 1
    \$\begingroup\$ I think the rules are pretty clear. It would be great if you could add some examples of input => expected output \$\endgroup\$ Commented Jun 7, 2022 at 21:14
  • 1
    \$\begingroup\$ @mathjunkie added test cases \$\endgroup\$
    – 00Her0
    Commented Jun 8, 2022 at 1:05
3
\$\begingroup\$

Is it a valid list?

\$\endgroup\$
6
  • 1
    \$\begingroup\$ Suggestion: allow input also with {} or (), maybe even allow separators to be spaces or semicolons. \$\endgroup\$
    – pajonk
    Commented Jun 12, 2022 at 5:28
  • 1
    \$\begingroup\$ "Outputting by erroring/not erroring is not allowed" - I presume this is to prevent people from submitting solutions which are just eval. This tends not be a good approach, and I think solutions like eval are still interesting. Maybe instead you could ask that people post solutions which don't directly do any parsing into one Community Wiki answer, like is sometimes done for builtin answers to catalogue-style questions. [contd...] \$\endgroup\$
    – pxeger
    Commented Jun 12, 2022 at 9:18
  • 1
    \$\begingroup\$ @pxeger Good idea :P \$\endgroup\$
    – emanresu A
    Commented Jun 12, 2022 at 9:19
  • 1
    \$\begingroup\$ [...contd] But I think disallowing error output is not the right way to go about it, because (1) people will still post them, but wrapped in a try-catch or whatever, which is a no more interesting answer; and (2) people can write interesting answers which don't use eval, but which can be shorter using error output as a kind of "short-circuiting" output mechanism. \$\endgroup\$
    – pxeger
    Commented Jun 12, 2022 at 9:20
  • \$\begingroup\$ Suggested falsey test-case: [[]][[]], which may erroneously be accepted by eval-like solutions \$\endgroup\$
    – pxeger
    Commented Jun 12, 2022 at 12:22
  • \$\begingroup\$ @pxeger Added.. \$\endgroup\$
    – emanresu A
    Commented Jun 12, 2022 at 19:46
3
\$\begingroup\$

backwardS_hybriD-snakE_kebaB-cameL_case

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

Fix my FizzBuzz

\$\endgroup\$
2
  • \$\begingroup\$ You need some more test cases, to cover: inputs that are already valid and don't need shuffling, inputs with only numbers, inputs with no numbers, inputs with FizzBuzz in them. \$\endgroup\$
    – pxeger
    Commented Jun 26, 2022 at 16:40
  • \$\begingroup\$ @pxeger Done. (filler) \$\endgroup\$
    – emanresu A
    Commented Jun 26, 2022 at 19:47
3
\$\begingroup\$

Simplify Rubik's Cube Moves

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

Infinite quote escaping sequence

Posted

\$\endgroup\$
15
  • \$\begingroup\$ "one of these sequences" - does this include the infinite string aa'a'a'...? Or do we have to output one of the numeric sequences? \$\endgroup\$
    – pxeger
    Commented Jul 14, 2022 at 12:31
  • \$\begingroup\$ @pxeger one of the numeric sequences \$\endgroup\$ Commented Jul 14, 2022 at 12:32
  • \$\begingroup\$ What does "connect the original string" mean? \$\endgroup\$ Commented Jul 14, 2022 at 12:32
  • \$\begingroup\$ @mousetail I edited it - it should be concatenate \$\endgroup\$ Commented Jul 14, 2022 at 12:33
  • \$\begingroup\$ I feel like the sentence is still confusing. I'm confused by the exact order. First the original string, then a "a", then the string surrounded by quotes right? \$\endgroup\$ Commented Jul 14, 2022 at 12:35
  • \$\begingroup\$ @mousetail Yes. How should I phrase this? Is this better? \$\endgroup\$ Commented Jul 14, 2022 at 12:36
  • \$\begingroup\$ Maybe include a example what it would look like after 1 or 2 iterations \$\endgroup\$ Commented Jul 14, 2022 at 12:39
  • \$\begingroup\$ I don't understand the first step of the process. From the examples it just looks like you are doing the second step over and over. If I try to do it with the first step I just get an infinite sequence of 's. \$\endgroup\$
    – Wheat Wizard Mod
    Commented Jul 14, 2022 at 12:47
  • \$\begingroup\$ I rewrote the process as an algorithm in pseudocode. Is it clearer now? \$\endgroup\$ Commented Jul 14, 2022 at 12:50
  • \$\begingroup\$ A worked out example of generating one of the iterations would be helpful. aa'a'a'aa''a''' is right about where you lose me, I'd like to see that one step-by-step \$\endgroup\$ Commented Jul 14, 2022 at 12:55
  • \$\begingroup\$ It is now clearer, but I, at least, would prefer if you just described it in a normal way rather than using pseudocode. \$\endgroup\$
    – Wheat Wizard Mod
    Commented Jul 14, 2022 at 13:00
  • \$\begingroup\$ @WheatWizard I tried rewriting it. Is this clear? \$\endgroup\$ Commented Jul 14, 2022 at 13:38
  • \$\begingroup\$ The commas helped a lot. I get it now :-) I still think a worked out example would be nice, but this is definitely easier to parse with the commas \$\endgroup\$ Commented Jul 14, 2022 at 14:18
  • \$\begingroup\$ May I swap 0/1 for sequence 1? (Use 1 for non-quote, 0 for quote) \$\endgroup\$
    – tsh
    Commented Jul 15, 2022 at 9:51
  • \$\begingroup\$ @tsh yes, I edited that in \$\endgroup\$ Commented Jul 15, 2022 at 9:52
3
\$\begingroup\$

Shifted auto-sum

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

Runs of Ones (What Fun!)

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

Remove redundant parenthesis

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

A better Hexagony template

\$\endgroup\$
4
  • \$\begingroup\$ 4000th answer to this question, hooray \$\endgroup\$ Commented Aug 10, 2022 at 12:58
  • \$\begingroup\$ "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 😅). \$\endgroup\$ Commented Aug 11, 2022 at 11:40
  • \$\begingroup\$ @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... \$\endgroup\$
    – Bubbler
    Commented Aug 11, 2022 at 14:02
  • 1
    \$\begingroup\$ @KevinCruijssen I decided to allow both :) \$\endgroup\$
    – Bubbler
    Commented Aug 11, 2022 at 22:56
1
22 23
24
25 26
162

You must log in to answer this question.

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