578
\$\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\$
3
  • 1
    \$\begingroup\$ What if I posted on the sandbox a long time ago and get no response? \$\endgroup\$ Commented May 15, 2024 at 14:05
  • 2
    \$\begingroup\$ @None1 If you don't get feedback for a while you can ask in the nineteenth byte \$\endgroup\$ Commented May 29, 2024 at 13:27
  • \$\begingroup\$ I have been once submitted a question to sandbox and downvoted to -1, but after submitting it anyway it has 8-9 score right now. \$\endgroup\$ Commented Dec 5, 2025 at 18:13

5038 Answers 5038

1
2 3 4 5
168
1
\$\begingroup\$

Generate an HSV color picker square

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

Translate Few Volapük Verbs to Esperanto

Given one of the nine Volapük verbs as either (1) infinitive or (2) in present tense with personal pronounce, output corresponding Esperando words. For (2)nd input, output pronounce and verb in any order you prefer.

Nine Volapük verbs to translate to Esperanto

Taken from Volapük Vifik: Lärnod Balid.

Formatted as follows:

Volapük => Esperanto (English)

Here they are, both as in infinitive:

binön => esti (to be)
lärnön => lerni (to learn)
lödön => loĝi (to live, reside)
reidön => legi (to read)
studön => studi (to study)
tidön => loĝitgi (to teach)
topön => situi (to be situated)
vilön => voli (to want to)
vobön => labori (to work)

Volapük grammar

To form an infinitive verb, use -ön suffix.

To form a present tense with pronounce, append pronounce; unlike English but like Arabic the verb itself has personal pronounce. Volapük has following pronounces:

  1. ob(s) for first pronounce
  2. ol(s) for second pronounce
  3. om(s) for third masculine pronounce
  4. of(s) for third feminine pronounce
  5. on(s) for third neuter or mixed gender pronounce

Append -s for plural; don't for singular.

E.g. binom: he is; binobs: we are; binons: they (neuter or mixed) are.

Esperanto grammar

To form an infinitive verb, use -i suffix.

To form a present tense, use -as suffix.

Esperanto has following personal pronounces:

  1. mi for first singular pronounce
  2. vi for second pronounce
  3. li for third masculine singular pronounce
  4. ŝi for third feminine singular pronounce
  5. ĝi for third neuter singular pronounce
  6. ni for first plural pronounce
  7. ili for third plural pronounce

E.g. mi estas: I am, ili laboras: we work

Test case generator in ksh, 282 bytes

awk '$0 = $1 FS $3' | awk '{ print $1, "=>", $2; vstem = substr($1, 1, length($1)-2) ; estem = substr($2, 1, length($2)-1); N = split("ob mi ol vi om li of ŝi on ĝi obs ni ols vi oms ili ofs ili ons ili", a); for (i = 1; i <= N; i+=2) print vstem a[i], "=>", a[i+1], estem "as" }'

Try it online!

Some test cases

lödoms => ili loĝas
vobof => ŝi laboras
topön => situi
lärnofs => ili lernas
topofs => ili situas
binon => ĝi estas
vobons => ili laboras
vobol => vi laboras
studoms => ili studas
vilons => ili volas
tidom => li loĝitgas
binobs => ni estas
topols => vi situas
topob => mi situas
studon => ĝi studas
vilofs => ili volas
vilols => vi volas
binön => esti
topol => vi situas
lödons => ili loĝas

Meta

Followed Esperanto grammar of that you may put words in any order. Good idea?

\$\endgroup\$
1
  • 1
    \$\begingroup\$ I think you meant binons instead of another binobs \$\endgroup\$ Commented Apr 27 at 21:09
0
\$\begingroup\$

Elemental Partition

Given a string of letters, output the letters partitioned into the symbols of elements on the periodic table. If one does not exist, your program should do something that is clearly distinct from outputting a partition.

\$\endgroup\$
3
  • \$\begingroup\$ so a typical input might be "pushthreeupafternine"? \$\endgroup\$ Commented Apr 27 at 23:01
  • \$\begingroup\$ @Neil I suppose… \$\endgroup\$ Commented Apr 28 at 5:32
  • \$\begingroup\$ spoiler \$\endgroup\$ Commented 2 days ago
0
\$\begingroup\$

Infinitely straight line

The object of this challenge is simple: draw a straight line* from any point on a canvas that goes infinitely in any direction. If "true" infinity is impossible, it must go to the end of said canvas, and the code must allow it to go on for a theoretically infinite amount after that.

* While yes, I'm aware that technically lines go infinitely in both directions, I am using the term "line" regardless. Your line may go infinitely in both directions as well.

This is , so the lowest byte count wins!

META:

Please let me know if this is a boring challenge or it already exists, I looked around and couldn't find anything like it, but if it does exist please let me know. Additionally, if there are any clarifications I could make, please let me know of them as well.

\$\endgroup\$
2
  • \$\begingroup\$ line or ray? your question wording seems to suggest the latter \$\endgroup\$ Commented Apr 25 at 7:43
  • \$\begingroup\$ Either would work, I'll change the wording of the question \$\endgroup\$ Commented Apr 26 at 0:07
1
\$\begingroup\$

Implement Lichess's time control classification system

\$\endgroup\$
2
  • \$\begingroup\$ didn't know lichess accounted for increment when classifying time formats! i think this is a viable challenge as-is. just to be sure, 179.5 isn't still bullet??? seems imo that <180 makes sense than <=179, but i'm not too familiar with lichess internals \$\endgroup\$ Commented Apr 16 at 1:19
  • \$\begingroup\$ <180 does make sense, but since I'm accepting arbitrary floating-point increments I have to strictly abide by the classification rules. And since <=179 is officially specified, I added that test case to warn posters not to use <180 \$\endgroup\$ Commented Apr 16 at 3:42
0
\$\begingroup\$

Concentration of binary list

You have some gas (non-air) particles, and some air particles, and want to know the risk of an explosion.


You shall be given a list, with 0 representing an air particle, and 1 representing a gas particle. You must output the proportion of particles that are gas particles


TL;DR output the proportion of the ones in the binary list of the total numbers.


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

Golf Numerical Representations in Compressed Barbrack

\$\endgroup\$
8
  • \$\begingroup\$ i think you should include a score calculator where one may paste the output (or its length, i guess) as well as their program's byte count and it outputs the calculated score. \$\endgroup\$ Commented Apr 15 at 9:34
  • \$\begingroup\$ Not sure how easy it'd be to input a list of 142857 numbers. \$\endgroup\$ Commented Apr 15 at 12:19
  • \$\begingroup\$ the clipboard on modern OSes does not have a size restriction, but yeah that's fair. still, users could input the byte count of their output into the calculator \$\endgroup\$ Commented Apr 15 at 12:21
  • \$\begingroup\$ alr i'll write down some lua pseudocode or smth in the question \$\endgroup\$ Commented Apr 15 at 12:27
  • \$\begingroup\$ ok that should be good \$\endgroup\$ Commented Apr 15 at 12:39
  • \$\begingroup\$ ah i see now why it's a bit of a mess. i was thinking one could just input 2 values into a program but it's more involved. in that case then yes, your example is probably the best we can do. \$\endgroup\$ Commented Apr 15 at 14:21
  • \$\begingroup\$ is it viable as-is? \$\endgroup\$ Commented Apr 16 at 1:16
  • \$\begingroup\$ sure, i guess. it's very hard (to do well, the brute-force case is trivial) but that's never stopped anyone \$\endgroup\$ Commented Apr 16 at 7:52
0
\$\begingroup\$

Interpret Grass

\$\endgroup\$
2
  • 1
    \$\begingroup\$ Hello. I found out your challenge is very hard to read when you use machine translation without proofreading. In the sandbox I suggest you keep a version written in your native language (Japanese, I guess?) So that people can compare it (to verify the translation). \$\endgroup\$ Commented Apr 10 at 8:05
  • \$\begingroup\$ @Explorer09 didn't use machine translation; trying to describe what I mean in clear language \$\endgroup\$ Commented Apr 10 at 11:45
0
\$\begingroup\$

Given a Prüfer Code generate a tree

\$\endgroup\$
1
\$\begingroup\$

(Insert title)

Task

Given a list of two or more positive integers, do the following procedure:

function procedure(a) {
   let seq1 = [], seq2 = [], seq3 = [];
   let N = 0;
   for (const n of a) if (n > N) N = n;
   for (let itr = 0, i_N = 0, accum = 0; ; itr++) {
      for (let idx = 0; idx < a.length; idx++) {
         const a_N = a[idx];
         for (let i_a = 0; i_a < a_N; i_a++, accum++, i_N=(i_N+1)%N) {
            if (i_a == 0) seq1.push(i_N == 0)
            if (i_a == 0 && i_N == 0) seq2.push([itr, idx])
            if (i_a == 0 && i_N != 0) seq3.push([itr, idx])
         }
      }
   }
}

Try it online!

Then do problem for, at your choice, what one of seq1, seq2 or seq3 would store.

Example

You have three counters (3, 3, 4). The maximum counter counts up to 4.

With #0 3,
1, 1
2, 2
3, 3
Syncs!

With #1 3,
1, 4
2, 1
3, 2

With #2 4,
1, 3
2, 4
3, 1
4, 2

Second.

With #0 3,
1, 3
2, 4
3, 1

With #1 3,
1, 2
2, 3
3, 4

With #2 4
1, 1
2, 2
3, 3
4, 4
Syncs!

Third.

With #0 3,
1, 1
2, 2
3, 3
Syncs!

...

Meta

\$\endgroup\$
2
  • \$\begingroup\$ I'm a bit unsure exactly what this question is asking of me: for the first example, would I just output every 27th date? \$\endgroup\$ Commented Apr 8 at 19:46
  • 1
    \$\begingroup\$ Is the idea about telling in which year-and-month combination will yield the same day of month as the 31-day-only mechanical watch? \$\endgroup\$ Commented Apr 9 at 10:51
0
\$\begingroup\$

Golf every byte in Dis

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

Extract Source from TIO Link

\$\endgroup\$
1
  • 1
    \$\begingroup\$ If anyone needs it, tio.run/static/3fd328d8f41877a6df086a6037ae8f35-frontend.js has the source code that includes all the encoding and decoding the page does. The relevant function is hashToState, I think. (saveState is the inverse) \$\endgroup\$ Commented Apr 6 at 22:40
0
\$\begingroup\$

Select and Delete Fields: Unicage Edition

\$\endgroup\$
-1
\$\begingroup\$

Is it fsed and/or fsed?

Meta

ok fsed s/foo/bar/
ok fsed s/foo/bar/ file
ok fsed s/foo/bar/ s/foo/bar/
ok fsed s/foo/bar/ -
no fsed s/foo/bar/ -i
no fsed s/foo/bar/ -j
ok fsed s/foo/bar/ -e s/foo/bar/
ok fsed s/foo/bar/ -e s/foo/bar/ s/foo/bar/
ok fsed s/foo/bar/ -e s/foo/bar/ s/foo/bar/ file
\$\endgroup\$
1
  • 1
    \$\begingroup\$ No idea what this is asking. \$\endgroup\$ Commented Apr 12 at 12:10
0
\$\begingroup\$

Big Numbers with =+× and def


Write a program in this atomic language, with the symbols =, ==, +, ×, def (define a function), return, variables with any name, parentheses, curly brackets, if, and min() Scoring is heavily punished using \$\frac{\text{num}}{\text{biggest operator defined in code}(\text{bytes}, 2)}\$, so be careful! The biggest number in your program is the result!
The variable x0 is automatically set to 1.
Example program (10^10):

t=x0+x0+x0+x0+x0+x0+x0+x0+x0+x0
y=t*t
t=y*y
k=y*t*t
\$\endgroup\$
8
  • \$\begingroup\$ Should we optimize for maximum or minimum score? \$\endgroup\$ Commented Apr 8 at 18:55
  • \$\begingroup\$ So would this work as a functional 10^10? \$\endgroup\$ Commented Apr 8 at 19:40
  • \$\begingroup\$ @Rhaixer Maximum score. \$\endgroup\$ Commented Apr 8 at 23:19
  • \$\begingroup\$ @MijiGamin1 I calculated by hand and it's 100,000,000 or 10⁸ if not retroactive, or if retroactive 10²⁰. It's not retroactive though. \$\endgroup\$ Commented Apr 8 at 23:22
  • \$\begingroup\$ What do you mean by "retroactive"? And my apologies, this is the one I meant to send \$\endgroup\$ Commented Apr 9 at 14:52
  • \$\begingroup\$ @MijiGamin like, retroactive is definitions change with what they are defined with. Like a retroactive prog x=(((x0+x0)*(x0+x0))+x0)*(x0) y=xx, x=yy, y would update... also yup! 10⁴*10⁴*10²=10¹⁰!. Also my retroactive estimate is wrong, the program would be infinity because it causes an infinite loop. But no retroactivity here! \$\endgroup\$ Commented Apr 9 at 20:12
  • \$\begingroup\$ What is the syntax? Is it like Python? \$\endgroup\$ Commented Apr 27 at 21:20
  • \$\begingroup\$ This can easily be cheesed by returning 1 if the second argument is 2, and some big number otherwise \$\endgroup\$ Commented Apr 27 at 21:22
0
\$\begingroup\$

Word problem for \$A_\infty\$

Objective

Given an element in the infinitieth alternating group \$A_\infty\$, decide whether it's equal to the identity element.

The group \$A_\infty\$

For consider the collection of bijections between \$\mathbb N\$ (including zero) and \$\mathbb N\$, endowed with function composition as a binary operator. This results in a group, and this group is denoted \$S_\omega\$. Its identity element is the identity function over \$\mathbb N\$.

The infinitieth symmetric group, denoted by \$S_\infty\$, is a subgroup of \$S_\omega\$ consisting of bijections that fixes all elements of \$\mathbb N\$ except some finitely many elements. The infinitieth alternating group \$A_\infty\$ is a subgroup of \$S_\infty\$ consisting of bijections represent-able by composition of an even number of transpositions (that is, a bijection that sends one element to another element and vice versa).

I/O format

It is known that \$A_\infty\$ is generated by elements in the form of \$(n \enspace n+1 \enspace n+2)\$ (that is, the bijection that sends \$n\$ to \$n+1\$, \$n+1\$ to \$n+2\$, and \$n+2\$ to \$n\$) for some \$n \in \mathbb N\$. As such, the input shall be given as a list of the \$n\$s involved, interpreted as the composition of the bijections they represent, from the right to the left.

The output format is flexible. Standard loopholes apply.

Examples

Truthy

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

Falsy

[0]
[1]
[0,0]
[0,1]
[0,2]
[2,1,0]
[0,0,1,1]
\$\endgroup\$
1
  • \$\begingroup\$ This seems to be written in a needlessly intimidating and verbose way that asks for more math knowledge than is needed. I'd replace the whole text with something like the following and add a worked example. "Imagine the numbers 0, 1, 2, ... are written in order. You're given a list of instructions, where 'i' means to rotate the three numbers in positions i, i+1, and i+2. After following the instructions, are all numbers back to where they started?" \$\endgroup\$ Commented Mar 31 at 4:41
0
\$\begingroup\$

Writing the rounding and truncating functions for float point numbers

A float point number could be expressed like this:

FloatPointNumber = BaseFloatPoint x 2^ExponentFloatPoint

By "bits of the float point type," I mean the bits that BaseFloatPoint has in the float type under consideration. These bits are used to store the digits of the float number. Both BaseFloatPoint and ExponentFloatPoint should be binary numbers type in the end.

The question here requires that the float point type be 64 bits, that is BaseFloatPoint is 64 bits, and here when I say "float point number" or "float point type" or "float," I mean a 64-bit float point type, a 64-bit float, that has a 64-bit BaseFloatPoint.

Let's define a function that returns decimal digits must have a float point number w.

lenfld(w)= floor((63-floor(log(2,max(w,1))))/3.322)

which in APL would be written

lenfld←{⌊(63-⌊2⍟⍵⌈1)÷3.322}

Or better, considering the external ⎕fpc, or external precision:

lenfld←{⌊3.322÷⍨⎕fpc-1+⌊2⍟1⌈⍵}

The question requires writing two functions:

  1. One called "truncdgt," with inputs of a non-negative integer dg (for the number of digits) and a float w, and output of a float res. The output of this function is such that if it is constructed in a string with the float w truncated at the digit dg—let's call it Str—then the conversion of that string to a float always satisfies this formula:

    abs(res-(conversion to float)(Str))< 10^-lenfld(w)

  2. One called "roundgt," with inputs a nonnegative integer dg (for the digit number) and a float w, and output a float res. The output of this function is such that if it is constructed in a string with the float w rounded to the digit dg, let's call it Str, then the conversion of that string to a float always satisfies this formula:

    abs(res-(conversion to float)(Str))< 10^-lenfld(w)

The function (conversion to float)(String_trunc dg w) it seems be ok as the function truncdgt, the same for roundgt. But should be many functions of them.

If the digit number for the float number to be truncated or rounded is outside the 64 bits that can be reached for that number, both functions must return NaN or it is not a number, or something that is clearly not a float number.

Here on my PC, in the APL language, there is an implementation of these two functions, the float point numbers, it is possible, them have a "v" suffix; that's how they are written in the exercises.

This question has the codegolf tag, so answers that solve all the exercises will be ranked by the number of bytes of code in the answer, and the answer with the fewest bytes of code implementing the two functions "truncdgt" and "roundgt" will win.

The exercises are as follows:

  1. First line is the input, then the name of the function that prints the result and other info; "tds" mean it call truncdgt, "rds" mean it call roundgt. Then the input digit dg, input float w
  2. Next line: the float that returns as the result "res" the function "truncdgt" or "roundgt" (I think converted by the system to digits), the truncated or rounded string of the number w from digit dg, which we will call "Str", delta=abs(res-(conversion to float)(Str))
  3. Next line: lenfld(w), and delta<10^-lenfdl(w), 1 means true, 0 means false.

Exercises:

  tds 1 1234567890123456785v
∅
  rds 1 1234567890123456785v
∅
  tds 0 123456789012345678.5v
res= 123456789012345678.00v Str= 123456789012345678.v d=∣res-⍎Str= 0v
Lenfld= 2v  (d<1e¯ 2v )= 1
  rds 0 123456789012345678.5v
res= 123456789012345679.00v Str= 123456789012345679.v d=∣res-⍎Str= 0v
Lenfld= 2v  (d<1e¯ 2v )= 1
  tds 0 123456789012345678.5v
res= 123456789012345678.00v Str= 123456789012345678.v d=∣res-⍎Str= 0v
Lenfld= 2v  (d<1e¯ 2v )= 1
  rds 0 123456789012345678.5v
res= 123456789012345679.00v Str= 123456789012345679.v d=∣res-⍎Str= 0v
Lenfld= 2v  (d<1e¯ 2v )= 1
  rds 4 0.7390851332v
res= 0.739100000000000000v Str= 0.7391v d=∣res-⍎Str= 0v
Lenfld= 18v  (d<1e¯ 18v )= 1
  tds 4 0.7390851332v
res= 0.739000000000000000v Str= 0.7390v d=∣res-⍎Str= 0v
Lenfld= 18v  (d<1e¯ 18v )= 1
  rds 2 2.8078v
res= 2.810000000000000000v Str= 2.81v d=∣res-⍎Str= 0v
Lenfld= 18v  (d<1e¯ 18v )= 1
  tds 2 2.8078v
res= 2.800000000000000000v Str= 2.80v d=∣res-⍎Str= 0v
Lenfld= 18v  (d<1e¯ 18v )= 1
  rds 6 2.8078v
res= 2.807800000000000000v Str= 2.807800v d=∣res-⍎Str= 0v
Lenfld= 18v  (d<1e¯ 18v )= 1
  tds 6 2.8078v
res= 2.807800000000000000v Str= 2.807800v d=∣res-⍎Str= 0v
Lenfld= 18v  (d<1e¯ 18v )= 1
  tds 2  4.349999999999999999v
res= 4.340000000000000000v Str= 4.34v d=∣res-⍎Str= 4.33680869E¯19v
Lenfld= 18v  (d<1e¯ 18v )= 1
  rds 2  4.349999999999999999v
res= 4.350000000000000000v Str= 4.35v d=∣res-⍎Str= 0v
Lenfld= 18v  (d<1e¯ 18v )= 1
  tds 2 ¯4.349999999999999999v
res= ¯4.340000000000000000v Str= ¯4.34v d=∣res-⍎Str= 4.33680869E¯19v
Lenfld= 18v  (d<1e¯ 18v )= 1
  rds 2 ¯4.349999999999999999v
res= ¯4.350000000000000000v Str= ¯4.35v d=∣res-⍎Str= 0v
Lenfld= 18v  (d<1e¯ 18v )= 1
  tds 19  4.349999999999999999v
∅
  tds 18  4.349999999999999999v
res= 4.349999999999999999v Str= 4.349999999999999999v d=∣res-⍎Str= 0v
Lenfld= 18v  (d<1e¯ 18v )= 1
  tds 17  4.349999999999999999v
res= 4.349999999999999990v Str= 4.34999999999999999v d=∣res-⍎Str= 0v
Lenfld= 18v  (d<1e¯ 18v )= 1
  tds 16  4.349999999999999999v
res= 4.349999999999999900v Str= 4.3499999999999999v d=∣res-⍎Str= 4.33680869E¯19v
Lenfld= 18v  (d<1e¯ 18v )= 1
  rds 19  4.349999999999999999v
∅
  rds 18  4.349999999999999999v
res= 4.349999999999999999v Str= 4.349999999999999999v d=∣res-⍎Str= 0v
Lenfld= 18v  (d<1e¯ 18v )= 1
  rds 17  4.349999999999999999v
res= 4.350000000000000000v Str= 4.35000000000000000v d=∣res-⍎Str= 0v
Lenfld= 18v  (d<1e¯ 18v )= 1
  rds 16  4.349999999999999999v
res= 4.350000000000000000v Str= 4.3500000000000000v d=∣res-⍎Str= 0v
Lenfld= 18v  (d<1e¯ 18v )= 1

These two results below have undefined behavior because the input float has more digits than the float can store in its space, so they should be rejected.

  tds 2  4.3499999999999999999v
res= 4.350000000000000000v Str= 4.35v d=∣res-⍎Str= 0v
Lenfld= 18v  (d<1e¯ 18v )= 1
  rds 2  4.3499999999999999999v
res= 4.350000000000000000v Str= 4.35v d=∣res-⍎Str= 0v
Lenfld= 18v  (d<1e¯ 18v )= 1

For these last two results, there is an undefined behavior because all the digits of 4.3499999999999999999v are 20, while the float type can only render significant numbers with a total number of digits less than or equal to 19.

4.3499999999999999999v
4.3499999999999999999v
1 2345678901234567890
 is 20 digits 

when better result to me that number can hold only lenfld(4.349999999999999999v)=18 decimal digits.

Here for that number I have:

30⍕4.349999999999999999v
4.3499999999999999991v
1 2345678901234567890 is 20 digits. 

This prints digits that can't be printed because they don't exist. So I think that number has enough bits in memory to be >= 4.35.

Translate to English by Google and some my changes.

\$\endgroup\$
10
  • \$\begingroup\$ (1.) Should the floating point be stored internally in binary or in decimal? This affects rounding precision in the output. (2.) If the digit position of the round or trunc function exceeds the precision supported by the floating point type, then the number should return as is. NaN is not designed for this purpose. \$\endgroup\$ Commented Apr 6 at 1:11
  • \$\begingroup\$ @Explorer09 all in binary, base and exponent \$\endgroup\$ Commented Apr 7 at 2:22
  • \$\begingroup\$ For me for 2, it can not return one float if error condition is found. NaN will be perfect because it is a float different of other float. This can not be ok if sys rise one exception \$\endgroup\$ Commented Apr 7 at 10:28
  • \$\begingroup\$ For (2.) it's not an error for overprecision. It's as if you have the input truncdgt 10 123.0 and it returns the same floating point value because there are no fraction digits to round. If you want to warn the client (or user or whoever) about too much precision, I suggest make it an Undefined Behavior for the purpose of this challenge. In short, either allow it and return the same value, or make it UB. \$\endgroup\$ Commented Apr 7 at 11:48
  • \$\begingroup\$ @Explorer09 trunc 10 123.0 is ok , what is not ok is trunc 17 123.0 ; 17+3=20 this suppose a 20 digit number, but a float can have only 19 digits, so there is one error \$\endgroup\$ Commented Apr 7 at 14:19
  • \$\begingroup\$ I asked Google, it seems they call it float 80, that has 64 bits for store digits that result to them as 18 19 decimal digits... google.com/… \$\endgroup\$ Commented Apr 7 at 14:40
  • \$\begingroup\$ With multiprecision float library (such as GNU MPFR), the 19-digit limit can be bypassed, and the explicit guard would make no sense. In short you shouldn't care about the limit. \$\endgroup\$ Commented Apr 7 at 17:15
  • \$\begingroup\$ By the way, you didn't seem to realize there is a standard called IEEE 754 that most floating point hardware comply to. Better learn it. IEEE 754 float64 has 11 bits of exponents and 53 bits of significand precision. \$\endgroup\$ Commented Apr 7 at 17:21
  • \$\begingroup\$ @Explorer09 I mean only float that have 64 bits for store the digits as float 80 ieee754 \$\endgroup\$ Commented Apr 8 at 8:25
  • \$\begingroup\$ There is no float80 format in ieee754. You might be referring to x86 extended-precision format instead. \$\endgroup\$ Commented Apr 8 at 9:41
1
\$\begingroup\$

Manufactoria Emulator

Given a manufactoria level and its input, return its output.

Level is inputted in original form:

?lvl=32&code=r7:12f0;&ctm=Mod7;Input:_binary_number_big_endian._Output:_that_binary_number_mod_7;bbb:|brrr:b|brrrr:br|bb:bb|bbrrb:brr|brrrrb:brb|bbrb:bbr;13;3;1;
?lvl=1&code=c12:6f3;c12:7f3;c12:8f3;

Size

You can get size of the board by either:

  • Read level data.
    • For lvl < 32, the size follows size [0,5,5,5,5,9,9,9,5,7,9,7,9,13,13,13,9,9,11,13,13,13,13,13,13,7,7,9,11,11,13,13][lvl]
    • For lvl ≥ 32, the size is the 4th part in ctm.
  • Read solution.
    • The top-most cell on center column (column 12) is on the 2nd row.
      • We assume the solution isn't a trivial reject-immediately.

Emulating

  • Each part is expressed as <type><x>:<y>f<facing>;. Map of type and facing is as follow: enter image description here
  • Your function fall into infinite loop iff the inputted level also fall into infinite loop.

\$\endgroup\$
1
\$\begingroup\$

Output all repeating binary patterns

output all binary string once under rotation and repeating equivalent: (here A and B are binary strings)

  • AB = BA
  • A = AA
  • A = AAA
  • ...

Or equivalently, string A and B are equivalent iff

$$ \exists k, \forall i, A_{i \text{ mod } \left|A\right|} = B_{\left(i+k\right) \text{ mod } \left|B\right|}.$$

E.g. 101, 011, 101101, 011011 are all equivalent, but 110011 isn't equivalent to them.

You can output in any order and choose any instance of an equivalent group.

\$\endgroup\$
4
  • \$\begingroup\$ Why isn't 110011 equivalent to 101? Can't you apply A=AA to every pair of digits? \$\endgroup\$ Commented Mar 31 at 16:53
  • \$\begingroup\$ @xnor You're trying to apply A=/A\. No such rule. \$\endgroup\$ Commented Mar 31 at 17:43
  • \$\begingroup\$ I don't know what /A\ denotes, but do you mean the rules can be only applied to the string as a whole, not substrings? \$\endgroup\$ Commented Mar 31 at 17:49
  • \$\begingroup\$ @xnor Yes. 101 is ...101101101101... and 011 is ...011011011011... but 110011 is ...110011110011... that's why this named repeating binary patterns \$\endgroup\$ Commented Apr 1 at 0:45
0
\$\begingroup\$

ed(1) addresses

Given adresses for the ed(1) command, complement what are missing. That's it.

Input format

A line.

Test cases

Inputs

1,2
1;3
,
7,
,9
;
3;
;6
.,
3;7
2;
,.
,$
;$
;$
3,
2,
6,
2;
$;$
3,.
,4
;4
4;
1,
;
,
5;.

Outputs

1,2
1;3
1,$
7,$
1,9
.;$
3;3
.;6
.,$
3;7
2;2
1,.
1,$
.;$
.;$
3,$
2,$
6,$
2;2
$;$
3,.$
1,4
.;4
4;4
1,$
1;$
1,$
5;.

Meta

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

How big are the stripes?

Challenge

An \$n\$-stripey integer is an integer whose binary representation is a subsequence of \$n\$ ones, then \$n\$ zeroes, repeating infinitely. For instance, 57,825 is 4-stripey because its binary representation is 1110000111100001; each “stripe” is 4 bits long.

Given a positive integer, return any \$n\$ for which it is \$n\$-stripey. At least one \$n\$ is guaranteed to exist.

Test Cases

 Input: 57825
Binary: 1110000111100001
Output: 4

 Input: 2
Binary: 10
Output: 1 (or any number greater than 1)

 Input: 9
Binary: 1001
Output: 2

 Input: 255
Binary: 11111111
Output: 8 (or any number greater than 8)

 Input: 7937
Binary: 1111100000001
Output: 7 

Scoring

\$\endgroup\$
1
  • \$\begingroup\$ 26 is not an \$n\$-stripey number for any \$n\$, so it is not a valid input. \$\endgroup\$ Commented Apr 5 at 12:43
1
\$\begingroup\$

Multiply two unit imaginary values

\$\endgroup\$
2
  • \$\begingroup\$ You can explicitly specify that this asks for the direct limit of repeated application of the Cayley-Dickson construction. \$\endgroup\$ Commented Apr 3 at 8:48
  • \$\begingroup\$ @DannyuNDos noted \$\endgroup\$ Commented Apr 3 at 9:45
3
\$\begingroup\$

Is this a mahjong hand?


This is a first challenge of the Mahjong Riichi series. For more check here: [SoonTM]

Background

Excerpts from Wikipedia:

Mahjong is a tile-based game that was developed in the 19th century in China and has spread throughout the world since the early 20th century. [...] The game is played with a set of 144 tiles based on Chinese characters and symbols, although regional variations may omit some tiles or add unique ones. In most variations, each player begins by receiving 13 tiles. In turn, players draw and discard tiles until they complete a legal hand using the 14th drawn tile to form four melds (or sets) and a pair (eye). A player can also win with a small class of special hands.

Suited tiles are divided into three suits and each are numbered from 1 to 9. The suits are bamboos, dots, and characters. There are four identical copies of each suited tile totaling 108 tiles.

There are two different sets of honors tiles: winds and dragons. The winds are east, south, west, and north, beginning with east. The dragons are red, green, and white. [...] These tiles have no numerical sequence like the suited tiles (for example the bamboo pieces number 1 to 9). Like the suited tiles, there are four identical copies of each honors tile, for a total of 28 honors tiles.

Mahjong MPSZ tile notation uses numbers 1-9 followed by a letter to represent suits:

  • m (Man/Characters),
  • p (Pin/Dots),
  • s (Sou/Bamboo), and
  • z (Zi1/Honors).

Honors are numbered from 1 to 7 (Winds: 1 = East, 2 = South, 3 = West, 4 = North; Dragons: 5 = White, 6 = Red, 7 = Green). For example, 123m means 1, 2, and 3 of Characters.

1 - Collective term for honors in Japanese Mahjong is Jihai


Input

You will receive a string representing 14 (or more) tiles in the hand. Assume that:

  • input string is always sorted by suit (Manzu, Pinzu, Souzu, Jihai) and number,
  • multiple numbers followed by a single letter represent several tiles of the same suit (e.g. 234s is equivalent to 2s3s4s),
  • no more than 4 copies of each tile are presented in the input string.

If preferred, the input may be an array of numbers/characters instead. However, you must note how are tiles mapped in your program.

Output

Determine whether a hand is a complete hand, which has either:

  • 4 groups of 3-tile sequences, triplets or quads AND a pair,
  • 7 distinct pairs, or
  • 1 of each terminal and honor tile + 1 duplicate (Thirteen Orphans)

Return a truthy value if the hand is complete, falsey otherwise.

Test cases

123456789m55p333z => true       # Pure Straight
11m223344p234567s => true       # Pure Double Sequence
113456m44488899p => false       # (incomplete group 1)
2255m4499p11s5577z => true      # Seven Pairs
4444p113355s1144z => false      # (duplicate pair)
11123455666789p => true         # Full Flush
119m19p19s1234567z => true      # Thirteen Orphans
119m119p19s124567z => false     # (missing honor for Thirteen Orphans)
222666m444p9999s22z => true     # All Triples w/ 1 quad
111133m4444p8888s5555z => true  # Four Quads
23488s555666777z => true        # Big Three Dragons
333444666m333666777p => false   # (excess tile)
33355m456s112233z => false      # (honors cannot form sequences)

Standard loophole, I/O and rules apply.

\$\endgroup\$
2
  • \$\begingroup\$ Mostly a duplicate of this. \$\endgroup\$ Commented Apr 1 at 7:47
  • \$\begingroup\$ Ah dang, how did I not find this the first time? \$\endgroup\$ Commented Apr 1 at 8:44
0
\$\begingroup\$

My vinyls have all caught colds!

\$\endgroup\$
11
  • 3
    \$\begingroup\$ Suggestion: simply the output to just say whether the title is truly "ill" (i.e. positive or negative). Also add tag decision-problem \$\endgroup\$ Commented Mar 26 at 18:20
  • 2
    \$\begingroup\$ Suggested examples: "Chill", "Villa" are false positives. "Illegitimate" is truly sick. \$\endgroup\$ Commented Mar 26 at 18:28
  • \$\begingroup\$ @Explorer09 i feel that the existing output requirements add more of a challenge to the problem \$\endgroup\$ Commented Mar 26 at 19:40
  • \$\begingroup\$ Challenges about parsing specific form of outputs are not interesting challenges. See this \$\endgroup\$ Commented Mar 26 at 23:20
  • \$\begingroup\$ @Explorer09 the array type of output isn't required, all that is required is the sick albums be outputted \$\endgroup\$ Commented Mar 27 at 0:23
  • 1
    \$\begingroup\$ Yes, and so your challenge can work equally well by checking individual titles rather than a list of titles input all at once. \$\endgroup\$ Commented Mar 27 at 0:47
  • \$\begingroup\$ @Explorer09 I suppose you have a good point, the bulk of the challenge is the identification, rather than the output. I'll edit it now \$\endgroup\$ Commented Mar 27 at 12:57
  • \$\begingroup\$ No need to quarantine them when you have some cleaning fluid… \$\endgroup\$ Commented Mar 28 at 23:04
  • \$\begingroup\$ @TheEmptyStringPhotographer i mean yea i get that but i just needed a story behind the challenge \$\endgroup\$ Commented Mar 29 at 1:05
  • \$\begingroup\$ Does upper/lower case of letters matter here and if so, in what way? \$\endgroup\$ Commented Mar 29 at 22:36
  • \$\begingroup\$ @TheEmptyStringPhotographer no, this challenge is case-insensitive \$\endgroup\$ Commented Mar 29 at 23:05
0
\$\begingroup\$

Input: a crafting recipe, each ingredients containing its crafting recipe or "not obtainable from crafting table". No item is shown.

Output: an ID. Same item has same ID and different item has different ID. You can assume such an item exist.

Example Input:

OOO OOO OOO
OOO OOO OOO
OOO OOO OOO

OOO     OOO
OOO  X  OOO
OOO     OOO

OOO     ...
OOO  X  ..O
OOO     ...

Example Output:

Your ID representing iron leggings or golden leggings.


Scoring

  • Shortest code wins. Is only a choice if this doesn't make question trivial. (Likely chosen, x=>x+'' is invalid e.g. there're 128 leggings recipe but only 4 types)
  • Minimize len(code)+introduced item count.

To decide

  • Shapeless crafting handle (maybe would force on left-top)
\$\endgroup\$
7
  • \$\begingroup\$ I'm a bit confused: what is there to signify which materials are being used? Functionally, by this input, iron nuggets and oak planks would have the same crafting recipe (unless I'm misunderstanding something) \$\endgroup\$ Commented Mar 28 at 20:42
  • \$\begingroup\$ @MijiGamin1 Yes they look same, so this input can also result golden leggings. An answer can make use of this returning two values for similar recipe, claiming one is iron and one is gold \$\endgroup\$ Commented Mar 28 at 21:19
  • \$\begingroup\$ this just feels like the code would consist of importing every single crafting recipe into a program, that doesn't seem very fun \$\endgroup\$ Commented Mar 28 at 21:34
  • \$\begingroup\$ @MijiGamin1 For e.g. items with unique recipe, such a recipe can just return an unique ID, it doesn't need to know what it is. That's why I don't require the ID meaning anything \$\endgroup\$ Commented Mar 28 at 21:54
  • 2
    \$\begingroup\$ i just feel like this problem needs to be more properly defined, i'm quite confused \$\endgroup\$ Commented Mar 29 at 1:04
  • \$\begingroup\$ @MijiGamin1 Idea from xiaoce.fun/mcitem though it's interactive and require the chosen item(besides some equivalents on color) while I just allow anything that works \$\endgroup\$ Commented Mar 29 at 1:40
  • \$\begingroup\$ i just feel like too much of the code would go towards hardcoding in the individual crafting recipes, so much so that golfing wouldn't really affect much \$\endgroup\$ Commented Mar 29 at 4:26
3
\$\begingroup\$

Get index of aperiodic number

\$\endgroup\$
2
  • 2
    \$\begingroup\$ why specifically focusing on the oeis sequences? a simple challenge classifying numbers as having binary expansions (a)periodic and just mentioning the oeis sequences for further reference would be fine \$\endgroup\$ Commented Aug 27, 2025 at 13:45
  • 2
    \$\begingroup\$ We already have this similar challenge for strings without the binary aspect. I'd expect most answers to use a binary-string built-in then apply the same techniques. \$\endgroup\$ Commented Aug 27, 2025 at 17:03
3
\$\begingroup\$

41 years of confusing Windows version naming

\$\endgroup\$
2
  • 1
    \$\begingroup\$ You missed Windows 2000 and Windows 8. Maybe explain why. \$\endgroup\$ Commented Mar 26 at 4:35
  • \$\begingroup\$ @Explorer09 Thanks a lot! I added explanations in the challenge, and luckily found a mistake in my source that allowed to introduce Windows 8 back into the challenge, and found another mistake. And if i didn't want to stick to the history of Home versions, i would gladly put 2000 in place of ME \$\endgroup\$ Commented Mar 26 at 10:39
-2
\$\begingroup\$

The Improper Quine (code golf or pop con?)

In this challenge, all you need to do is make code that outputs its own source code. The only restriction is that the source code cannot be empty.

\$\endgroup\$
4
  • \$\begingroup\$ This already exists \$\endgroup\$ Commented Mar 25 at 13:22
  • \$\begingroup\$ @MijiGamin1 no, that one explicitly disallows improper quines, this one allows you to read your own source code. \$\endgroup\$ Commented Mar 25 at 18:28
  • \$\begingroup\$ Regardless, it seems too similar to this one \$\endgroup\$ Commented Mar 25 at 18:29
  • \$\begingroup\$ This is just a generalized version of the two challenges MijiGamin1 posted \$\endgroup\$ Commented Mar 26 at 19:11
0
\$\begingroup\$

Got closed, and was referred here

Despite being an incredibly popular graphical output demo video (similar to "It runs DOOM!), there is no code golf for Bad Apple yet!

The Challenge:

Output the attached 20 consecutive frames (or more if you want!) (I used this tool and set the frame rate to 1fps) of the video, in ascii, or any other method of graphical output (such as pygame, turtle, LED lights, GCODE that 3d prints a frame, anything goes).

The Rules:

Standard rules on loopholes apply

Resolution of the frame must be (at minimum) 40*30. Any downsampling can be used

Scoring is done based on standard Code Golf rules

An example ascii output is available at this link (Note that it is animated, but you do not need to clear the terminal between frames, only output 20)

The Frames:

enter image description here enter image description here enter image description here enter image description here enter image description here enter image description here enter image description here enter image description here enter image description here enter image description here enter image description here enter image description here enter image description here enter image description here enter image description here enter image description here enter image description here enter image description here enter image description here enter image description here

Ascii Output:

Hosted here: https://github.com/SiffrinSuffrin/BadAppleTXT/blob/main/badapple.txt

Good luck!

\$\endgroup\$
2
  • \$\begingroup\$ I believe that simply adding an ascii output to reproduce to the question should fix the original close reason? \$\endgroup\$ Commented Mar 24 at 9:33
  • \$\begingroup\$ Update: I am unable to do this due to breaking the character limit, will probably just host an output on github \$\endgroup\$ Commented Mar 24 at 9:40
3
\$\begingroup\$

Sort Key for Japanese Wikipedia Article

\$\endgroup\$
1
2 3 4 5
168

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.