557
\$\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".

Get the Sandbox Viewer to view the sandbox more easily!

\$\endgroup\$
0

3992 Answers 3992

1
36 37
38
39 40
134
2
\$\begingroup\$

Disassemble tables

Posted here.

\$\endgroup\$
3
  • \$\begingroup\$ awesome puzzle ophact! at the moment, i do not have any feedback other than well done! \$\endgroup\$
    – DialFrost
    Feb 16 at 10:40
  • \$\begingroup\$ #4 seems to have an extra pair of legs \$\endgroup\$
    – emanresu A
    Feb 19 at 0:47
  • \$\begingroup\$ @emanresuA thanks, will edit now \$\endgroup\$
    – ophact
    Feb 19 at 7:51
2
\$\begingroup\$

Lexicographical sum

\$\endgroup\$
6
  • \$\begingroup\$ Bigger test cases would be helpful. \$\endgroup\$
    – ophact
    Mar 2 at 8:39
  • \$\begingroup\$ how big @ophact? \$\endgroup\$
    – DialFrost
    Mar 2 at 23:47
  • 1
    \$\begingroup\$ Something like 386 would be great \$\endgroup\$
    – ophact
    Mar 3 at 12:45
  • 1
    \$\begingroup\$ Isn't it called Lexicographical instead of Lexical? Either way, not sure why it got so many downvotes, unless it was for a previous versions that were already corrected, or it could use a short explanation of Lexicographical order in general. You may also want to write out the n=9 example a bit more perhaps. E.g. "For sum n=9 the following strictly decreasing arrays are possible: [[9],[8,1],[7,2],[6,3],[5,4],[6,2,1],[5,3,1],[4,3,2]]. Putting these in lexicographical order: [[4,3,2],[5,3,1],[5,4],[6,2,1],[6,3],[7,2],[8,1],[9]], the first [4,3,2] will be the final output." \$\endgroup\$ Mar 3 at 13:17
  • \$\begingroup\$ I think you should clarify more explicitly that the array is strictly decreasing and therefore cannot contain duplicate elements. At first it wasn't obvious to me why the output isn't always just [1, 1, 1, 1, ...] \$\endgroup\$
    – pxeger
    Mar 3 at 14:54
  • \$\begingroup\$ sry @KevinCruijssen and pxeger i did not have time to check ur msgs yet as i was sleeping thx for the feedback! i will change the challenge accordingly \$\endgroup\$
    – DialFrost
    Mar 3 at 23:27
2
\$\begingroup\$

Random Point from a 2D Donut Distribution

Posted here.

\$\endgroup\$
5
  • \$\begingroup\$ I don't think the current definition of the distribution is unambiguous? Is this intentional? Is this open-ended-function or did you mean to specify an exact distribution? \$\endgroup\$
    – Wheat Wizard Mod
    Feb 17 at 10:39
  • \$\begingroup\$ @Jitse Different distributions can have the same standard deviation. Perhaps you forgot to specify that the radius of the points should have a normal distribution? \$\endgroup\$
    – AnttiP
    Feb 17 at 20:52
  • \$\begingroup\$ @AnttiP You're absolutely right, can't believe I missed that! \$\endgroup\$
    – Jitse
    Feb 18 at 10:37
  • 3
    \$\begingroup\$ So what we need is just generate \$ R \sim {\mathcal {N}}(r ,s^2) \$, \$ \theta \sim U[0, 2\pi]\$. And convert to Cartesian coordinate system \$(R\cos \theta, R\sin \theta)\$? \$\endgroup\$
    – tsh
    Feb 19 at 6:03
  • \$\begingroup\$ @tsh $$ R \sim {\mathcal {N}}(r ,s) $$, but yes \$\endgroup\$
    – Jitse
    Feb 19 at 22:35
2
\$\begingroup\$

String table

Posted here

\$\endgroup\$
2
  • \$\begingroup\$ Related, related \$\endgroup\$
    – sinvec
    Mar 10 at 13:48
  • 3
    \$\begingroup\$ please leave stuff in the sandbox for more than two hours. \$\endgroup\$
    – emanresu A
    Mar 10 at 18:26
2
\$\begingroup\$

Implement a very simple ALU using only NAND gates

\$\endgroup\$
2
  • 1
    \$\begingroup\$ O0-O7? Isn't it O0-O3? \$\endgroup\$
    – ophact
    Mar 13 at 16:58
  • \$\begingroup\$ Oh, yes. My mistake: a previous revision of the challenge had a data width of 8 bits. I will correct that. \$\endgroup\$
    – Tuxysta
    Mar 13 at 17:10
2
\$\begingroup\$

Is it a base-\$\infty\$ prime?

To explain how base-\$\infty\$ numbers work, let's look at how base 10 arithmetic works. We can view a base 10 number as a list of digits (numbers). So 123 is [1,2,3] and so on. When we add numbers, we use the standard long addition, meaning we add digit by digit, carrying if necessary. For example, 123+798:

  ₁₁ 
  123
+ 798
-----
  921

Similarly, multiplication can be done using long multiplication. For example, 123*798:

    123
*   798
-------
    984
  1107
+ 861
-------
  98154

Now, like the name suggest, base-\$\infty\$ numbers have infinitely many possible digits. Therefore we can represent a base-\$\infty\$ number as a list of integers. For lists consisting of only non-negative numbers, addition and multiplication are straightforward. For example, [19,53,1]+[8,4]=[19,53,1]+[0,8,4]=[19,61,5] and [1,2]*[3,4]=[1,2]*[3,0]+[1,2]*[4]=[3,6,0]+[4,8]=[3,10,8]. When restricted to non-negative numbers, carrying doesn't occur.

Negative numbers however spice things up. Let's look first how [-1] works. Let's see what happens when we add [1] to it:

[-1]+[1]=[1,0]

We get [1,0]. Before explaining how this works, it may be helpful to look at a related example in base-10:

9 + 1 = 10

Do you see the similarities? Nine is just ten minus one. Anyways, what is happening is that when you cross the boundary from the negatives to the positives, you carry one, so you end up with [1,0] where the one is carried.

Let's see what happens when we add [-1] to [-1]. We can reason in this way:

[-1]+[-1]=[-1]+[1]+[-2]=[1,0]+[-2]=[1,-2]

Here is the related base-10 example:

9 + 9 = 18

Ok, here is a more complicated example

[1,3,-2,-3,6]+[1,5,-1]=[1,4,0,3,5]

And the base-10 equivalent

13876+159=14035

For singular non-negative integers, multiplication works as you'd expect:

[3]*[1,-2,3]=[1,-2,3]+[1,-2,3]+[1,-2,3]=[5,-6,9]

For singular negative integers, we can use the following trick:

[-3]*[1,-2,3]=([1,0] - [3])*[1,-2,3]=[1,0]*[1,-2,3]-[3]*[1,-2,3]=[1,-2,3,0]-[5,-6,9]=[1,-8,9,-9]

where a-b=c iff b+c=a (subtraction is well defined as long as a>=b).

Here is a base-10 example:

[-1]*[-1]=[-2,1] 9*9=81

For multiplying with longer numbers, we just distribute the addition:

[a,b,c]*[d,e,f]=[a,0,0]*[d,e,f]+[b,0]*[d,e,f]+[c]*[d,e,f]=[a]*[d,e,f,0,0]+[b]*[d,e,f,0]+[c]*[d,e,f]

Basically just doing long multiplication.

Primes

A prime number is a number which cannot be expressed as a non-trivial product. A non-trivial product is a product which doesn't contain the multiplicative identity ([1]). By convention, the multiplicative identity is not a prime.

Your task is to take a base-\$\infty\$ number as input and decide if it's a prime.

Rules

Standard rules apply. You may assume that the input doesn't contain leading zeros. You may choose whether the additive identity (zero) is represented as [] or [0].

Mathematical definition of addition and multiplication

Addition:

[] + b = b
a + [] = a
[...ia,la] + [...ib,lb] = [...(ia + ib + carry(la, lb)), la+lb]

where

carry(a,b) = [(a < 0 and b < 0) or (a + b >= 0 and min(a,b) != 0]

Multiplication:

[] * b = []
[..ia, 0] * b = [...(ia*b),0]
[..ia,-a] * b = [...(ia + [1]), 0]*b - [a]*b
[..ia, a + 1] * b = [..ia, a]*b + b

Where a-b is the unique solution to b+x=a (guaranteed to be well defined when using the above definitions)

Test cases:

[0] -> False
[1] -> False
[2] -> True
[3] -> True
[4] -> False
[5] -> True
[6] -> False
[7] -> True
[8] -> False
[9] -> False
[10] -> False
[11] -> True
[12] -> False
[-12] -> True
[-11] -> True
[-10] -> True
[-9] -> True
[-8] -> True
[-7] -> True
[-6] -> True
[-5] -> True
[-4] -> True
[-3] -> True
[-2] -> True
[-1] -> True
[1,0] -> True
[1,1] -> True
[1,2] -> True
[1,3] -> True
[1,4] -> True
[1,-4] -> False
[1,-3] -> True
[1,-2] -> False
[1,-1] -> True
todo add more test cases
\$\endgroup\$
3
  • 1
    \$\begingroup\$ Isn't this just the set of integer polynomials with nonnegative leading coefficient in disguise? \$\endgroup\$
    – Nitrodon
    Mar 20 at 16:34
  • 1
    \$\begingroup\$ @Nitrodon Yes, it is \$\endgroup\$
    – AnttiP
    Mar 20 at 17:46
  • \$\begingroup\$ how are your challenges so good? +1 for nice challenge! \$\endgroup\$
    – DialFrost
    Mar 21 at 0:36
2
\$\begingroup\$

Spaceship shooter

\$\endgroup\$
2
  • 1
    \$\begingroup\$ This looks good as it is; it doesn't need to be made harder. However, you can always make it harder. So, if you want to make it harder, go ahead! The more challenging the challenge, the more enjoyable it is (at least, until it becomes impossible)! \$\endgroup\$ Mar 22 at 19:24
  • 1
    \$\begingroup\$ Ah ok thx @SylvesterKruin ig ill leave it as it is, i dont want to overcomplicate \$\endgroup\$
    – DialFrost
    Mar 22 at 23:19
2
\$\begingroup\$

Flipping Burnt Pancakes, but Optimally!

This is based on the Burnt Pancake problem.

In the burnt pancake problem, each “pancake” has a burnt side. You must sort these pancakes in order with the burnt side down. You may only use one tool, your spatula, which can flip the pancakes from the top of the pancake stack to where you inserted the spatula.

Flipping pancakes that have the burnt side down results in those pancakes being in reverse order and having the burnt side up, and vice versa.

For a given pancake stack, return the minimal number of flips needed to be made burnt pancake sorting.

The output must show every step of the optimal flipping process, with the position of the spatula being represented by a pipe character, and u or b after every number representing whether or not a pancake is burnt or unburnt.

Note that this is an NP-HARD problem. You may not make an approximation algorithm.

Testcases

1b2b3b4u returns the following:
 1b|2b3b4u
 1u2b|3b4u
 2u|1b3b4u
 2b1b|3b4u
 1u2u3b|4u
 3u|2b1b4u
 3b2b1b|4u
 1u2u3u4u
4b3b2b1b returns the following:
 4b3b2b1b|
 1u2u3u4u

This is fastest-algorithm, so the minimal time complexity wins.

\$\endgroup\$
6
  • \$\begingroup\$ 32145 3'2145 1'2'345 21345 2'1345 1'2345 12345 Is [3,2,1,4,5] at most 6? \$\endgroup\$
    – l4m2
    Feb 26 at 18:28
  • \$\begingroup\$ Is this a good explanation? \$\endgroup\$
    – awi
    Feb 28 at 15:50
  • 1
    \$\begingroup\$ @awi Nice, much better! Some images might make it even better. \$\endgroup\$
    – emanresu A
    Mar 1 at 8:51
  • \$\begingroup\$ I found a visualization of the problem at one point, might link that. Could someone confirm what the solutions for the examples are? \$\endgroup\$
    – awi
    Mar 1 at 15:48
  • \$\begingroup\$ Found some solutions by brute force. Is this good? \$\endgroup\$
    – awi
    Mar 23 at 15:13
  • \$\begingroup\$ Very similar. \$\endgroup\$
    – Wheat Wizard Mod
    Apr 7 at 11:38
2
\$\begingroup\$

Convert from Two's Complement to Decimal

\$\endgroup\$
4
  • \$\begingroup\$ May we assume at most one leading zero? If not, please add a test-case covering this. \$\endgroup\$
    – pajonk
    Mar 17 at 19:56
  • \$\begingroup\$ I was assuming not, so I will add a test case. \$\endgroup\$
    – Romanp
    Mar 17 at 20:42
  • \$\begingroup\$ Are we allowed to copy the example answer XD \$\endgroup\$
    – DialFrost
    Mar 19 at 1:21
  • \$\begingroup\$ Well, if there are no better solutions in Mathematica, it could become a community wiki solution, and the approach could certainly be adapted to another language. \$\endgroup\$
    – Romanp
    Mar 21 at 18:20
2
\$\begingroup\$

Draw an ASCII envelope

\$\endgroup\$
3
  • \$\begingroup\$ Wow your're a good challenge poster. nice challenge! \$\endgroup\$
    – DialFrost
    Mar 22 at 23:31
  • \$\begingroup\$ But i think you can remove the last 2 points under rules as they are sort of standard code golf rules and ascii art rules, and u might wanna include "trailing spaces are allowed" \$\endgroup\$
    – DialFrost
    Mar 22 at 23:32
  • \$\begingroup\$ @DialFrost Thanks for the feedback! I'll edit it according to your suggestions! \$\endgroup\$ Mar 22 at 23:46
2
\$\begingroup\$

Order of an algebraic number

\$\endgroup\$
11
  • \$\begingroup\$ i find it fascinating although its a bit beyond my knowledge of how to solve it \$\endgroup\$
    – don bright
    Dec 21, 2021 at 7:41
  • \$\begingroup\$ Of course this is your challenge, and you can configure it as you wish. But I'd like to note that, by separating out any answers that employ Built-Ins into a Community Answer, you're effectively reducing this to a "Do X without Y" challenge, where "Y", in this case, is Built-Ins. That takes away the fun of being able to find just the right Built-In (or combination of two or three Built-Ins) to do the job... \$\endgroup\$
    – theorist
    Dec 24, 2021 at 4:11
  • \$\begingroup\$ ...fun that you were happy to avail yourself of when you answered each of these two questions with a pair of Built-Ins: codegolf.stackexchange.com/questions/224125/… and codegolf.stackexchange.com/questions/229414/… \$\endgroup\$
    – theorist
    Dec 24, 2021 at 4:12
  • \$\begingroup\$ Sorry I did not spot this problem when the challenge was still in sandbox: Surd in Mathematica only gives real roots. \$\endgroup\$
    – alephalpha
    Dec 24, 2021 at 4:44
  • \$\begingroup\$ Deleted main post \$\endgroup\$ Dec 24, 2021 at 16:25
  • 1
    \$\begingroup\$ @alephalpha I've edited the challenge to include the test cases suggested by you and tsh on the main post. I've also specified that the input will always be real \$\endgroup\$ Dec 24, 2021 at 16:26
  • \$\begingroup\$ @theorist I already know that Mathematica essentially has a builtin for this - it wouldn't surprise me if other math-oriented langs (e.g. Pari/GP) also did. I'm not interested in solutions that off-hand all the work onto a builtin, but banning them isn't something I like doing. Therefore, I go by this suggestion to combine trivial builtin answers into a single CW answer. I'm well aware that I've posted builtin-only answers before, but only if the challenge doesn't combine trivial answers into a single CW answer (like I prefer to do) \$\endgroup\$ Dec 24, 2021 at 16:31
  • \$\begingroup\$ There's three problems: (1) For all intents and purposes, the suggestion you are folowing does effectively ban builtins. By requiring any who answer to put builtin solutions into an anonymous community wiki, you are banning them from including builtins in their answers. The practice you've adoped just seems like a way to ban builtins in practice, while saying they're not "technically" banned. It's a "distinction without a difference." Thus I think those who adopt this practice shouldn't say "I'm not banning builtins".... \$\endgroup\$
    – theorist
    Dec 24, 2021 at 22:08
  • \$\begingroup\$ Instead, I think it's more accurate to say: "I am banning builtins. But for those who want to post builtins anyways, you can put them into the Community Wiki." (2) Calling builtin answers "trivial", IMO, unfairly, well, trivializes the knowledge and understanding of a program needed to identify the right builtin for the job. Sure some can be trivial, but I don't think think they should be blanket-labeled as suchl. E.g., while you may have a different view, I don't think this was trivial: codegolf.stackexchange.com/questions/230836/leave-the-times-out/… ... \$\endgroup\$
    – theorist
    Dec 24, 2021 at 22:10
  • \$\begingroup\$ The point of the linked example is that Defer wasn't designed to accomplish the goal set by the OP, but it nevertheless had that effect anyways. And you needed some understanding of how the language worked to realize it would do that. But it's still a simple one-word builtin. (3) Unless you're programming in machine code, all answers consist of a sequence of builtins. So it really comes down to an arbitrary cutoff of what's the minimum amount of builtins an answer needs to contain. \$\endgroup\$
    – theorist
    Dec 25, 2021 at 0:03
  • \$\begingroup\$ To my understanding, the most complex thing here is not find out a minimal polynomial, but instead of how to simplify the input. Especially for testcases like \$\sqrt{\sqrt{5}+1}\cdot \sqrt{\sqrt{5}-1}\$, or \$\frac{5\sqrt{5}-1}{\sqrt{5}-1}\$. \$\endgroup\$
    – tsh
    Dec 27, 2021 at 6:23
2
\$\begingroup\$

Batt to the Basics

\$\endgroup\$
2
\$\begingroup\$

What's the Missing Code?

Cops' thread Robbers' thread

\$\endgroup\$
5
  • 1
    \$\begingroup\$ Now this sounds like fun! Just one question: wouldn't it add more to the challenge if you didn't tell the robbers where each letter was removed? I feel like knowing where the missing characters are would make it too easy, especially since the cops are trying to create as short code as possible (so that they win). Do you think it would make it too easy? \$\endgroup\$ Mar 27 at 18:13
  • \$\begingroup\$ I thought about this, but I came to the conclusion that it would make it easier for the robbers to simply go to the start of the program, and write print(...); end program. However, on thinking about it again, this would make it easier for the cops to reduce the characters removed while keeping the answer non-obvious, which would prevent the robbers from doing this. I will consider this and perhaps change the question. \$\endgroup\$
    – Lecdi
    Mar 27 at 18:19
  • \$\begingroup\$ Ohh.... I see what you mean. But that could be part of the cops' challenge: making the code complicated enough, with few enough characters removed, so that the robbers couldn't do that. But yes, your reasoning makes sense now. In that case, either way would be fine. I'm looking forward to when this is posted on the main site! \$\endgroup\$ Mar 27 at 18:28
  • 1
    \$\begingroup\$ I think it is too easy for the robbers in its current state, so I will edit it to include your suggestion: I think that as long as the cops remove few enough characters, it will be impossible for the robbers to do this. \$\endgroup\$
    – Lecdi
    Mar 27 at 19:17
  • 1
    \$\begingroup\$ If your int("5") example is run in the Python shell (as opposed to in a program), the output is 5. Just FYI. \$\endgroup\$ Mar 27 at 19:46
2
\$\begingroup\$

Wash clothes as quickly as possible

\$\endgroup\$
1
  • \$\begingroup\$ Can you add test cases? \$\endgroup\$
    – Seggan
    Mar 29 at 15:50
2
\$\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
    Apr 10 at 20:03
  • \$\begingroup\$ @pajonk i added this line You must fill each shell to it's limited capacity. \$\endgroup\$
    – PyGamer0
    Apr 11 at 3:23
  • \$\begingroup\$ 29 should return [2,8,18,1], not [2,8,18,2] \$\endgroup\$
    – Steffan
    Apr 11 at 4:12
  • \$\begingroup\$ BTW, it's more accurate to call it the electronic shell structure, not the electronic configuration \$\endgroup\$
    – Steffan
    Apr 11 at 4:13
  • \$\begingroup\$ @Steffan that's how we learnt it \$\endgroup\$
    – PyGamer0
    Apr 11 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
    Apr 11 at 11:14
  • \$\begingroup\$ @pajonk ok, edited. \$\endgroup\$
    – PyGamer0
    Apr 11 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\$
    – Steffan
    Apr 11 at 16:07
  • \$\begingroup\$ I just noticed this is a duplicate of codegolf.stackexchange.com/questions/37657/… \$\endgroup\$
    – Steffan
    Apr 19 at 18:36
2
\$\begingroup\$

Translate Text into Matoran

The Matoran Alphabet is the alphabet used by many of the characters in the Bionicle universe.

Matoran Alphabet

Your challenge is to create a program or function that takes a string as input and creates an image of the input written in the Matoran alphabet.

The input will only consist of uppercase letters (A-Z), numbers (0-9), and spaces. You may instead take input in lowercase.

Glyphs

As you can probably notice, the alphabet comprises glyphs made up of circles and straight lines.

For the sake of this challenge, let's define each glyph as a circle of radius 4 units (8 x 8), with some internal designs. The internal designs of letters can be any of:

  • Vertical Line at position 2, 4, or 6 (either full length or half)
  • Horizontal Line equivalent to above
  • Circle of radius 1, centered at [2, 2], [2, 6], [6, 2], or [6, 6]
  • Any of the above rotated by 45 degrees about the centre

Number glyphs work slightly differently; they always have a circle of radius 1 in the centre. For numbers 0 - 5, the glyph has evenly spaced spokes between the circles, starting from the top. For numbers greater than 5, the glyph has an additional circle of radius 2 in the centre, and the number of spokes is 6 less than the number.

Here is a diagram of the glyphs in spec, any glyphs with 45 degree rotations have an orange grid.

Matoran Alphabet

For drawing the glyphs, any line stroke in the range (0, 1) can be used. Glyphs can be kerned (space between adjacent glyphs) any amount from 0 - 4 units. Spaces should be 8 units wide (in addition to kerning).

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

\$\endgroup\$
4
  • \$\begingroup\$ This does seem like pretty interesting challenge, although I would recommend a clearer image of the characters of the Matoran alphabet, and probably a more rigorous definition of the shapes of each of the characters (eg. defining the positions/lengths/radii/etc of the inner circles/lines in terms of the radius of the exterior circle) \$\endgroup\$
    – des54321
    Apr 11 at 4:14
  • \$\begingroup\$ @des54321 Thank you! I added some specification around the characters. Do you think this is sufficient, or should I include a written definition of each glyph? \$\endgroup\$ Apr 11 at 22:31
  • \$\begingroup\$ That looks pretty good! I'd suggest leaving this challenge up on the sandbox for a bit longer to see if anyone else has suggestions, but as things stand now this seems a very well specified and fairly interesting challenge \$\endgroup\$
    – des54321
    Apr 11 at 23:06
  • 1
    \$\begingroup\$ Thanks for your help, I'll leave it a couple of days then post it. \$\endgroup\$ Apr 11 at 23:13
2
\$\begingroup\$

Is this propositional formula an instance of an axiom?

\$\endgroup\$
2
\$\begingroup\$

Get the trends of an array

\$\endgroup\$
2
  • 1
    \$\begingroup\$ Is there any specifications prevent the program from outputting [[1,1], [1,2], [2,3]] for [1,1,2,3]? Maybe you should add some texts about "you should generate fewest possible trends" or something like it. \$\endgroup\$
    – tsh
    Apr 18 at 8:43
  • \$\begingroup\$ @tsh Good idea. Added. \$\endgroup\$
    – chunes
    Apr 18 at 9:17
2
\$\begingroup\$

Will this makina program halt?

makina is a cell-based esolang composed of automata which move around a grid. These automata follow paths of instructions that direct their movement. Your task is to, given a makina program using only the below instructions (so a subset of normal makina) as input, output two distinct values depending on whether or not it is a loop. (If program flow comes to an arrow character that it has already visited then the program is a loop.)

Instructions

  • ^>v< These instructions (arrows) set the direction of the automaton to the direction they point in.
  • I This instruction halts automata going up or down, but does nothing to ones going left or right.
  • H This instruction halts automata going left or right, but does nothing to ones going up or down.
  • O This instruction does nothing to the automaton, acting like a sort of 4-way intersection.

All other characters halt the automaton, as does exiting the bounds of the program. The automaton starts in the top-left corner going right.

Testcases

Truthy

>>>v
v<<<
OOOv
H<<<
v

Falsey

>>>v
^<<<
>v
^O<
>^
>>>v
v<I<
H>^
>^
>>>>v
v <<<
OOOv
H<<<
v
\$\endgroup\$
2
  • \$\begingroup\$ "All other characters halt the automaton" So arbitrary characters different from >v<^HIO can be part of the input? If so, this should be reflected in the test cases. (Personally, I'd only allow valid characters in the input.) \$\endgroup\$
    – Laikoni
    Apr 24 at 19:39
  • \$\begingroup\$ Also the current last two Falsy test cases actually halt and are probably a cop-paste error from the Truthy cases. \$\endgroup\$
    – Laikoni
    Apr 24 at 19:43
2
\$\begingroup\$

Sequence of integers not the sum of powers of earlier terms

\$\endgroup\$
2
\$\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\$ May 6 at 17:31
  • \$\begingroup\$ Try it online! Other than that problem, this sounds like a good challenge! +1 \$\endgroup\$ May 6 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\$
    – Steffan
    May 6 at 17:54
  • \$\begingroup\$ Here is your code fixed: Try it online! \$\endgroup\$
    – Steffan
    May 6 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\$ May 6 at 18:07
2
\$\begingroup\$

Derivative of a product

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

Convert to Shorthand (Part 1, Part 2)

\$\endgroup\$
5
  • \$\begingroup\$ Conjunction points of O P X Y may be ambiguous. \$\endgroup\$
    – tsh
    Apr 26 at 12:08
  • \$\begingroup\$ @tsh I am thinking of allowing multiple correct answers for the same input. To make it slightly more precise I have added more rules and improved the examples. \$\endgroup\$
    – Saphereye
    Apr 26 at 12:14
  • 3
    \$\begingroup\$ I feel like this are actually two challenges in one: 1. transcribe to the weird alphabet 2. make this "interconnected". I suggest splitting to two challenges. \$\endgroup\$
    – pajonk
    Apr 26 at 17:57
  • \$\begingroup\$ I see you posted the first part, please edit this post or post a new one so that we can discuss the details of the second part (if you like). \$\endgroup\$
    – pajonk
    Apr 27 at 5:12
  • \$\begingroup\$ @pajonk Thank you for the interest. I am thinking of putting all details in the same question to avoid clashing of data. This question is still the umbrella goal I am trying to achieve with it. I will be editing details once I get more suggestion from the posted questions \$\endgroup\$
    – Saphereye
    Apr 27 at 8:00
2
\$\begingroup\$

Modular tetration

Tetration is the operation of repeated exponentiation. That is \$ ^{n}a = a ^ {. ^ {. ^ {.^a}}} \$, with \$ a \$ appearing \$ n \$ times.

Tetration grows extremely fast - \$ ^6 2 \$ would take significantly more digits to write then there are atoms in the known universe.

However, to work with big numbers, we can operate on them modulo some number \$ m \$.

Your task is to calculate \$ ^n a \mod m \$, with integer \$ 1 < a,n < m \$.

Rules

  • You may use any consistent reasonable I/O method.
  • The complexity of your answer must be \$ O(m) \$, where \$ m \$ is the modulus. In particular, you can't calculate \$ ^{n}a \$ with arbitrary precision and then modulo by \$ m \$.
  • Standard loopholes are disallowed.
  • Your algorithm must work for all values, but it's allowed for your program to fail due to integer overflow.

Test cases

The format for the test cases is a n m -> answer (however, you can take your input in any order) [Sandbox note: TODO - there's an error in my program]

This is , so the shortest answer in bytes wins.

\$\endgroup\$
2
  • \$\begingroup\$ I don't really know how to compute \$O\$ here, but would this algorithm satisfy the requirement on \$O(m)\$? \$\endgroup\$
    – pajonk
    May 13 at 11:03
  • \$\begingroup\$ @pajonk it depends on the implementation. If you calculate euler's totient by going over all numbers from 1 to m and calculating the gcd it wouldn't, since calculating the gcd is logarithmic time, so it'll be \$ \Theta(m \log m) \$. If you calculate it by factoring \$ m \$ in \$ o(m) \$ time then it's fine. \$\endgroup\$ May 13 at 11:49
2
\$\begingroup\$

Write a (simplified) BitCycle Interpreter

\$\endgroup\$
2
\$\begingroup\$

Convert Alpha-2 to Alpha-3

\$\endgroup\$
1
  • \$\begingroup\$ I liked the back story, personally. \$\endgroup\$
    – Tuxysta
    May 13 at 16:49
2
\$\begingroup\$

There's more than one way to skin a set

\$\endgroup\$
5
  • \$\begingroup\$ You may want to clarify that when summing the subset, one may take a number only once and that the order doesn't matter. Also subjective suggestion: allow only inputs of length >1 (or even >2). \$\endgroup\$
    – pajonk
    Apr 9 at 19:35
  • \$\begingroup\$ Description could be clearer, possibly something like "given a set S of integers, output all the integers that are the sum of multiple subsets of S" would be less wordy and clearer, also outputting a "set" is probably not necessary, as I feel that whitespace delimited strings or simple lists would work, especially since not all langs have a specific concept of a set \$\endgroup\$
    – des54321
    Apr 11 at 16:48
  • \$\begingroup\$ also possibly add a few comments onto the test cases to explain them a bit more, eg. on test case 3 adding a comment like "21 can be 10+11 or 9+12" \$\endgroup\$
    – des54321
    Apr 11 at 16:51
  • \$\begingroup\$ @des54321 It's pretty standard that "outputting a set" doesn't literally mean a builtin set type, it just means some kind of list-y thing \$\endgroup\$
    – pxeger
    Apr 11 at 16:55
  • \$\begingroup\$ @pxeger, fair enough, although you may want to explicitly specify strings with just whitespace separators if you want to allow that as output, as especially with the current format of your testcases that does feel slightly like its not allowed \$\endgroup\$
    – des54321
    Apr 11 at 16:57
2
\$\begingroup\$

I want 8 bits for every character!

\$\endgroup\$
2
\$\begingroup\$

Convert Klingon romanization to pIqaD


Context

Klingon is a constructed language from Star Trek. It has two writing systems: a not-very-good Latin alphabet (with case distinctions, I being different from l, ...) and its own script, called pIqaD.

Task

Convert the bad[disputed - discuss] Klingon romanization into pIqaD. Here's a CSV (the pIqaD [or, if you don't have a font for it, boxes or nothing] is in the second column and the Unicode hexadecimal codes are in the third):

a,,f8d0
b,,f8d1
ch,,f8d2
D,,f8d3
e,,f8d4
gh,,f8d5
H,,f8d6
I,,f8d7
j,,f8d8
l,,f8d9
m,,f8da
n,,f8db
ng,,f8dc
o,,f8dd
p,,f8de
q,,f8df
Q,,f8e0
r,,f8e1
S,,f8e2
t,,f8e3
tlh,,f8e4
u,,f8e5
v,,f8e6
w,,f8e7
y,,f8e8
',,f8e9

Be careful not to mix up q and Q, they are different letters in Klingon!

Input and output

Strings! or your language's equivalent. You can assume that the input contains no characters not in Klingon (incl. miscapitalized dhis) or numbers or punctuation.

Scoring

Lowest byte count wins, as always.


suggestions? :)

\$\endgroup\$
3
  • \$\begingroup\$ I like it! It seems ready for publication. \$\endgroup\$
    – Tuxysta
    May 25 at 21:34
  • 1
    \$\begingroup\$ My browser shows only in the second column of the csv. Maybe add a link to TIO or other external page, which will render it correctly. If possible, you may also add UTF codes for those characters. \$\endgroup\$
    – pajonk
    May 26 at 10:02
  • \$\begingroup\$ @pajonk i added the unicode codes :) \$\endgroup\$
    – matt
    May 29 at 14:28
2
\$\begingroup\$

Generate Fibonacci Primes Quickly

Unsurprisingly, fibonacci primes are primes that are also Fibonacci numbers. There are currently 34 known Fibonacci primes and an additional 15 probable Fibonacci primes. For the purpose of this challenge, the Fibonacci numbers are the sequence \$F_n\$ defined as \$F_1 = 1\$, \$F_2 = 1\$, and \$F_n = F_{n-1} + F_{n-2}\$, and a number is considered prime if it passes a probabilistic prime test with a probability of being incorrect of less than \$2^{-32}\$. For example, since a \$k\$ round Miller-Rabin test has an error probability of \$4^{-k}\$, a 16 round Miller-Rabin test is sufficient to prove primality for the purpose of this challenge.

Submissions:

The goal of this challenge is to write a full program that calculates every Fibonacci prime and its index in the Fibonacci series as fast as possible.

Submissions shall be a full program, complete with instructions for building and running it. Submissions must be in a language freely available for noncommercial use and capable of running on Windows 10, and users must be prepared to provide installation instructions for that language. External libraries are permitted, with the same caveats that apply to languages.

Primes will be output by writing to stdout with a simple binary format, that has a little-endian byte order:

[8 bytes- index into the Fibonacci series]
[8 bytes- length of the Fibonacci prime, in bytes]
[? bytes- the Fibonacci prime, as a byte array]

Scoring

The programs will be run on an Intel(R) Core(TM) i5-8365U CPU with 8 threads, avx-2 support, and 24 Gigabytes of ram. The largest prime that can be correctly reached in one minute wins. Tiebreaker is the time taken to reach the largest value. Programs that tamper with my computer or the testing program will be disqualified. Programs that error or otherwise fail to produce the correct output will be judged based on the furthest Fibonacci prime reached before they failed.

see also: A005478, A001605

The test program can be found here. Additionally, there is an example program here.

Meta

The test program is now completed and posted, but I still have a little documentation to write. I chose the output format to be simple, and so that answers wouldn't have to worry about formatting integers quickly. Is there anything I need to improve clarity-wise?

tags:

\$\endgroup\$
4
  • \$\begingroup\$ Since there are only 34 (?+15) of them, how will you stop a program from hard-coding these, and then starting looking for larger ones from the last of them onwards? \$\endgroup\$ May 22 at 10:02
  • \$\begingroup\$ @DominicvanEssen tweaked the question to use "calculate" instead of "list", which has worked for other challenges in the past. I also posted the controller. \$\endgroup\$
    – Aiden4
    May 30 at 5:30
  • \$\begingroup\$ How is the "error bound" of a "probable prime" defined? \$\endgroup\$
    – pxeger
    May 30 at 15:07
  • \$\begingroup\$ @pxeger I hopefully clarified what I meant, by error bound I meant error probability. \$\endgroup\$
    – Aiden4
    May 30 at 17:01
1
36 37
38
39 40
134

You must log in to answer this question.

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