571
\$\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\$
1
  • \$\begingroup\$ What if I posted on the sandbox a long time ago and get no response? \$\endgroup\$
    – None1
    May 15 at 14:05

4691 Answers 4691

1
82 83
84
85 86
157
1
\$\begingroup\$

Render an Ideographic Description Sequence

There are 12 characters in Unicode that can be used to describe any CJK character, which are often made up of reoccurring parts ("radicals") composed in different ways.

For example, U+86D9 蛙 can be described as U+2FF0 U+866B U+572D ⿰虫圭.

Your task is to take such an Ideographic Description Sequence as input and produce an image of the resulting character as an output. You can assume the input conforms to the following grammar, which is taken from the Unicode standard, which explains this topic very well:

IDS := Ideographic | Radical | CJK_Stroke | Private Use | U+FF1F
    | IDS_BinaryOperator IDS IDS
    | IDS_TrinaryOperator IDS IDS IDS
CJK_Stroke := U+31C0 | U+31C1 | ... | U+31E3
IDS_BinaryOperator := U+2FF0 | U+2FF1 | U+2FF4 | ... | U+2FFA | U+2FFB
IDS_TrinaryOperator := U+2FF2 | U+2FF3

This is a kind of prefix notation (polish notation).

Ideographic and Radical are defined in PropList.txt:

2E80..2E99    ; Radical # So  [26] CJK RADICAL REPEAT..CJK RADICAL RAP
2E9B..2EF3    ; Radical # So  [89] CJK RADICAL CHOKE..CJK RADICAL C-SIMPLIFIED TURTLE
2F00..2FD5    ; Radical # So [214] KANGXI RADICAL ONE..KANGXI RADICAL FLUTE

3006          ; Ideographic # Lo       IDEOGRAPHIC CLOSING MARK
3007          ; Ideographic # Nl       IDEOGRAPHIC NUMBER ZERO
3021..3029    ; Ideographic # Nl   [9] HANGZHOU NUMERAL ONE..HANGZHOU NUMERAL NINE
3038..303A    ; Ideographic # Nl   [3] HANGZHOU NUMERAL TEN..HANGZHOU NUMERAL THIRTY
3400..4DBF    ; Ideographic # Lo [6592] CJK UNIFIED IDEOGRAPH-3400..CJK UNIFIED IDEOGRAPH-4DBF
4E00..9FFF    ; Ideographic # Lo [20992] CJK UNIFIED IDEOGRAPH-4E00..CJK UNIFIED IDEOGRAPH-9FFF
F900..FA6D    ; Ideographic # Lo [366] CJK COMPATIBILITY IDEOGRAPH-F900..CJK COMPATIBILITY IDEOGRAPH-FA6D
FA70..FAD9    ; Ideographic # Lo [106] CJK COMPATIBILITY IDEOGRAPH-FA70..CJK COMPATIBILITY IDEOGRAPH-FAD9
16FE4         ; Ideographic # Mn       KHITAN SMALL SCRIPT FILLER
17000..187F7  ; Ideographic # Lo [6136] TANGUT IDEOGRAPH-17000..TANGUT IDEOGRAPH-187F7
18800..18CD5  ; Ideographic # Lo [1238] TANGUT COMPONENT-001..KHITAN SMALL SCRIPT CHARACTER-18CD5
18D00..18D08  ; Ideographic # Lo   [9] TANGUT IDEOGRAPH-18D00..TANGUT IDEOGRAPH-18D08
1B170..1B2FB  ; Ideographic # Lo [396] NUSHU CHARACTER-1B170..NUSHU CHARACTER-1B2FB
20000..2A6DF  ; Ideographic # Lo [42720] CJK UNIFIED IDEOGRAPH-20000..CJK UNIFIED IDEOGRAPH-2A6DF
2A700..2B739  ; Ideographic # Lo [4154] CJK UNIFIED IDEOGRAPH-2A700..CJK UNIFIED IDEOGRAPH-2B739
2B740..2B81D  ; Ideographic # Lo [222] CJK UNIFIED IDEOGRAPH-2B740..CJK UNIFIED IDEOGRAPH-2B81D
2B820..2CEA1  ; Ideographic # Lo [5762] CJK UNIFIED IDEOGRAPH-2B820..CJK UNIFIED IDEOGRAPH-2CEA1
2CEB0..2EBE0  ; Ideographic # Lo [7473] CJK UNIFIED IDEOGRAPH-2CEB0..CJK UNIFIED IDEOGRAPH-2EBE0
2F800..2FA1D  ; Ideographic # Lo [542] CJK COMPATIBILITY IDEOGRAPH-2F800..CJK COMPATIBILITY IDEOGRAPH-2FA1D
30000..3134A  ; Ideographic # Lo [4939] CJK UNIFIED IDEOGRAPH-30000..CJK UNIFIED IDEOGRAPH-3134A
31350..323AF  ; Ideographic # Lo [4192] CJK UNIFIED IDEOGRAPH-31350..CJK UNIFIED IDEOGRAPH-323AF

Rules

Keep in mind that output has to be an image, not a unicode character, as per the default loophole, but I recommend a text rendering engine to render each radical.

You can assume the input won't contain private use characters.

Use the following definitions of the Ideographic Description Characters. The percentages are not defined in unicode, but made up for this challenge. Each component should be squashed to the required shape, so that each intermediate result is a square. The output should also be a square image. See also: https://en.wikipedia.org/wiki/Chinese_character_description_languages#Ideographic_Description_Sequences

Code point Character Meaning
U+2FF0 divide horizontally in halves
U+2FF1 divide vertically in halves
U+2FF2 divide horizontally in thirds
U+2FF3 divide vertically in thirds
U+2FF4 enclose; the lengths should be 20%, 60%, 20%
U+2FF5 surround from top; the inner has 60% the width and 80% of the height
U+2FF6 surround from below; the inner has 60% the width and 80% of the height
U+2FF7 surround from left; the inner has 80% the width and 60% of the height
U+2FF8 surround from top-left; the inner has 80% the width and height
U+2FF9 surround from top-right; the inner has 80% the width and height
U+2FFA surround from top-right; the inner has 80% the width and height
U+2FFB overlay with transparency

Examples

Input Output
⿰虫圭
⿲彳圭亍
⿵几皇
⿻工从
⿴囗⿰⿱鹵凼⿰丨㇌ 2
⿱井蛙 1
⿱井⿰虫圭 1
⿱井⿰虫⿱土土 1
\$\endgroup\$
4
  • 1
    \$\begingroup\$ Is it too long? \$\endgroup\$
    – corvus_192
    Oct 25, 2022 at 20:00
  • 1
    \$\begingroup\$ Downvoter, could you please explain why? \$\endgroup\$
    – corvus_192
    Oct 26, 2022 at 11:46
  • \$\begingroup\$ why not restrict output to graphical ones only for simplicity? \$\endgroup\$ Oct 27, 2022 at 11:55
  • 1
    \$\begingroup\$ @鳴神裁四点一号 I'm not sure I understand what you mean. This is graphical-output, so the output must be an image or image file. \$\endgroup\$
    – corvus_192
    Oct 27, 2022 at 12:37
1
\$\begingroup\$

Increment, decrement, undo, peek

\$\endgroup\$
4
  • 1
    \$\begingroup\$ Nice challenge! I was thinking maybe add the tags: function and number \$\endgroup\$
    – The Thonnu
    Oct 25, 2022 at 16:21
  • \$\begingroup\$ I think this is a very interesting challenge, but the definitions for the four functions are very difficult to understand as they're currently written. I haven't figured out a really good way to phrase them, but at the very least I think replacing "has the value" with something like "contains the value". When I read "Increment has the value of the function that created it plus 1" it took me a long time to figure out that it didn't mean incr == 1. \$\endgroup\$ Oct 25, 2022 at 16:47
  • \$\begingroup\$ What should eval(undo)() return in your example? Maybe this is undefined and we don't need to handle such cases? Do we need to keep track of all operations for undo or there's a limit? \$\endgroup\$
    – pajonk
    Oct 27, 2022 at 7:13
  • \$\begingroup\$ @pajonk Good questions, thanks. I suppose that behavior should just be undefined. Re: Limit I think the only limit should be the limitations of your system/language. \$\endgroup\$
    – Jordan
    Oct 27, 2022 at 12:00
1
\$\begingroup\$

Length of Binary as Base 10 [OEIS A242347]

\$\endgroup\$
6
  • 3
    \$\begingroup\$ Can we use default sequence rules and output infinitely, or output the first \$n\$ terms? \$\endgroup\$
    – naffetS
    Oct 26, 2022 at 4:13
  • \$\begingroup\$ I'll edit it to output the first n terms \$\endgroup\$
    – pacman256
    Oct 26, 2022 at 13:00
  • \$\begingroup\$ I second @Sʨɠɠan's suggestion to allow standard sequence rules. Also, your wording now is misleading - A242347 isn't the number of digits in the first n terms of A008559 (it's the number of digits of the nth term). I suggest changing the tile to reflect the challenge by adding "Length of" and updating the OEIS number accordingly. Another thing, good practice is to give meaningful labels to hyperlinks - I suggest changing "here" to "A008559" and "this sequence" to "sequence A242347". \$\endgroup\$
    – pajonk
    Oct 27, 2022 at 7:06
  • \$\begingroup\$ @pajonk will do \$\endgroup\$
    – pacman256
    Oct 27, 2022 at 12:59
  • \$\begingroup\$ Your test cases don't match the specs currently (only one number instead of first n terms). Also, the \$a(1)=2\$ in the Input section is confusing. \$\endgroup\$
    – pajonk
    Oct 27, 2022 at 15:37
  • \$\begingroup\$ fixed those issues \$\endgroup\$
    – pacman256
    Oct 27, 2022 at 16:14
1
\$\begingroup\$

Power sequence differences

\$\endgroup\$
6
  • \$\begingroup\$ Any reason for the first 5 terms portion in the challenge description? I see in the rules you allow the default [sequence] rules, so it can be the \$n^{th}\$, first \$n\$, or infinite sequence, instead of specifically the first \$5\$, right? \$\endgroup\$ Oct 27, 2022 at 12:29
  • 1
    \$\begingroup\$ @KevinCruijssen I will edit the challenge to allow anything that includes the 5th term. This includes the first 5 terms, just the 5th term, or the infinite sequence. \$\endgroup\$
    – The Thonnu
    Oct 27, 2022 at 12:32
  • \$\begingroup\$ These finite differences have a closed form, which I'm not sure is your intention? No matter what you choose you should define the domains of \$ x \$ and \$ d \$. \$\endgroup\$ Oct 27, 2022 at 18:52
  • \$\begingroup\$ @FryAmTheEggman I don't get what you mean by that. Could you explain further? \$\endgroup\$
    – The Thonnu
    Oct 28, 2022 at 9:03
  • \$\begingroup\$ For the first part of my comment, I wanted to let you know that the 5th term of the \$d\$th difference sequence of \$n^{x}\$ was \$ \sum_{i=0}^{d} \binom{d}{i} (4+d-i)^{x} (-1)^{x} \$. I think a lot of answers would probably use that rather than manually computing difference sequences, which I wasn't sure was what you wanted. There isn't anything wrong with it, unless you don't like it. The other part is that you don't specify that \$ x \$ and \$ d \$ are positive integers and \$ d < x \$. You can choose other domains, but those are true of your test cases. \$\endgroup\$ Oct 28, 2022 at 14:56
  • \$\begingroup\$ @FryAmTheEggman - for the first bit, I don't really mind if people use a formula for it. For the second bit, yes that is the domain I wanted. I'll edit that in now. \$\endgroup\$
    – The Thonnu
    Oct 28, 2022 at 15:36
1
\$\begingroup\$

Longest Total Distance Cyclic Quine Chain

Write a program of upto 100 bytes that outputs another program that outputs another program etc. until after a finite number of iterations outputting the original program again.

Each program in the cycle must have a length less than or equal to 100 bytes.

Your score is the sum of the Levenshtein distance between each program and it's output. I hope this leads to answers that do something more creative than change a single digit each time.

Maximum possible score is: $$256^{101}$$

\$\endgroup\$
14
  • \$\begingroup\$ finite? As in, how many iterations exactly? \$\endgroup\$ Nov 1, 2022 at 7:47
  • \$\begingroup\$ Like after 10, 20, or 100? \$\endgroup\$ Nov 1, 2022 at 7:47
  • \$\begingroup\$ The goal is to get the highest finite number of iterations \$\endgroup\$
    – mousetail
    Nov 1, 2022 at 7:48
  • \$\begingroup\$ I imagine scores will be around 10^100 \$\endgroup\$
    – mousetail
    Nov 1, 2022 at 7:49
  • \$\begingroup\$ I see. And why upto 100 bytes? I imagine some really verbose language like Taxi wouldn't be able to answer this. \$\endgroup\$ Nov 1, 2022 at 7:50
  • 2
    \$\begingroup\$ Related: Cyclic levenquine \$\endgroup\$
    – Bubbler
    Nov 1, 2022 at 7:52
  • \$\begingroup\$ I need to set a limit or you could easily get arbitrarily high scores. Shorter languages can easily get scores that are so high as to be uncomputable even for short lengths. I hope with this length languages like python can participate but golfing languages can still genuinely compete against each-other, since their difference in score is hopefully representable. \$\endgroup\$
    – mousetail
    Nov 1, 2022 at 7:52
  • \$\begingroup\$ And I don't really understand ` that outputs another program `. Are we supposed to output the source code of another program, that when executed output's the source code of yet another one? \$\endgroup\$ Nov 1, 2022 at 7:54
  • \$\begingroup\$ @Bubbler It's different since you are trying to get the highest distance possible instead of a distance of exactly 1 \$\endgroup\$
    – mousetail
    Nov 1, 2022 at 7:54
  • \$\begingroup\$ @py3_and_c_programmer yes, it's a quine like \$\endgroup\$
    – mousetail
    Nov 1, 2022 at 7:55
  • 1
    \$\begingroup\$ @py3_and_c_programmer Not being answerable in some languages is totally OK. @ mousetail: Yes, I'm aware of the differences. \$\endgroup\$
    – Bubbler
    Nov 1, 2022 at 7:55
  • \$\begingroup\$ Would some test cases in a particular... No, never mind. \$\endgroup\$ Nov 1, 2022 at 7:58
  • 1
    \$\begingroup\$ 1) I think you should clarify that it is NOT "longest chain, ties broken by highest distance sum". I guess my initial misconception is due to the title. Maybe "Most distant cyclic quine chain"? 2) The theoretical maximum score is (sum of lengths of all possible programs of 100 bytes or shorter) * 2, which is a bit lower than 256^101. \$\endgroup\$
    – Bubbler
    Nov 1, 2022 at 8:00
  • \$\begingroup\$ Suggested tag: busy-beaver \$\endgroup\$
    – alephalpha
    Nov 1, 2022 at 11:13
1
\$\begingroup\$

Perfect Nontransitive Sets

\$\endgroup\$
7
  • \$\begingroup\$ "in comparing two tuples the one that has more elements greater than the other is greater" - how do we compare each element to the other tuple? Maybe you mean that we should compare elements to the respective element in the other tuple (i.e. zip with <) and then the lesser tuple is the one with more truthy results? Or maybe you mean we compare an element to each of the three in the other tuple? Maybe a worked example would help. \$\endgroup\$ Nov 3, 2022 at 16:50
  • \$\begingroup\$ @JonathanAllan Shoot, I was afraid the wording there was confusing. Yes, it's essentially zip with <, hopefully the the edits clear up my intent. \$\endgroup\$ Nov 3, 2022 at 18:01
  • \$\begingroup\$ It seems that {(n-i, 0, i) for i in range(n)} will satisfy the property (since no pair of elements contain one that is less than the other). \$\endgroup\$ Nov 3, 2022 at 18:15
  • \$\begingroup\$ ...e.g. {(1, 0, 4), (2, 0, 3), (3, 0, 2), (4, 0, 1), (5, 0, 0)} \$\endgroup\$ Nov 3, 2022 at 18:22
  • \$\begingroup\$ @JonathanAllan This would not be a valid set since none of them are comparable. It appears things are still confusing. Do you think it would be better if I simply disallow tuples that have any element-wise equalities? \$\endgroup\$ Nov 3, 2022 at 18:30
  • \$\begingroup\$ So "all pairs must be comparable" means one must be "less than" the other? If you spell that out it's probably fine, but it would probably be worth adding an invalid example output to ensure the point gets accross. \$\endgroup\$ Nov 3, 2022 at 18:43
  • 1
    \$\begingroup\$ Went ahead and did both, if anybody still finds this confusing let me know \$\endgroup\$ Nov 3, 2022 at 18:57
1
\$\begingroup\$

Number to letters

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

Is it a legal atomic chess move?

\$\endgroup\$
8
  • \$\begingroup\$ How would one know what the move is? Make sure to include that in the input \$\endgroup\$
    – DialFrost
    Nov 20, 2022 at 5:40
  • \$\begingroup\$ @DialFrost errr I’m not too sure I understand… it is part of the input, that’s the entire point of the challenge. \$\endgroup\$
    – Aiden Chow
    Nov 20, 2022 at 8:52
  • \$\begingroup\$ You didnt state it in any part of the question! \$\endgroup\$
    – DialFrost
    Nov 20, 2022 at 10:05
  • \$\begingroup\$ @DialFrost I did… “….given a board state, whose turn it is (black or white), and a move….” \$\endgroup\$
    – Aiden Chow
    Nov 20, 2022 at 11:03
  • \$\begingroup\$ You didnt show it in the input examples you have :/ (NOT testcases) \$\endgroup\$
    – DialFrost
    Nov 20, 2022 at 11:07
  • \$\begingroup\$ @DialFrost Wait what, but those aren't even test cases... those are just example positions to explain the game rules. Those aren't actual inputs. I haven't even made any test cases yet. \$\endgroup\$
    – Aiden Chow
    Nov 20, 2022 at 17:26
  • \$\begingroup\$ Given that this challenge is already complicated enough, I suggest simplifying input to just cover white's turn (or black's, whatever). \$\endgroup\$
    – pajonk
    Nov 22, 2022 at 5:45
  • \$\begingroup\$ @pajonk good idea, I will edit that in. \$\endgroup\$
    – Aiden Chow
    Nov 22, 2022 at 8:33
1
\$\begingroup\$

Print the most uncommon character

Your task is to write a full program or function that prints the character(s)* that appears in your code the least. For example, if my code was AAAABBBBCCCDDD, then the program should print CD or DC.

Rules

  • All printed characters must appear at least three times in your code, but you will print only one character for each.
  • You are only printing those character(s). If your language always includes a trailing newline, then that is allowed.
  • All printed characters must be printable characters or newlines.
  • If multiple characters all appear the least, you must print them all, without separation. Order does not matter.
  • The program or function cannot be empty, so it has to be a minimum of three characters long.
  • This is , so the shortest code in bytes wins.

*Where "character(s)" is mentioned in the rules above, exceptions may be made for languages like TI-Basic or Piet which do not use characters.

Meta

  • Are there any similar questions to this?
  • Should I change the rules?
\$\endgroup\$
4
  • \$\begingroup\$ Can't find any challenges that are similar. And I think the rules itself are fine, but I personally find the * after every character a bit distracting. Maybe remove those five * and change the footnote to "*Where 'character(s)' is mentioned in the rules above, exceptions may be made for languages like TI-Basic or Piet, which do not use characters." And just to make sure: the shortest program is 3 bytes with three of one character, that outputs one of such character? \$\endgroup\$ Nov 25, 2022 at 16:18
  • \$\begingroup\$ Also, is there any reason why you specifically said 'full program', as apposed to the default program/function? The default is there for languages with verbose boilerplate code like Java or .NET C#. \$\endgroup\$ Nov 25, 2022 at 16:37
  • \$\begingroup\$ @KevinCruijssen The shortest possible solution would indeed be 3 characters long. I found that a full program would fit better for a self-referential challenge, but I suppose a function would also be fine. I will replace the *s in the rules. \$\endgroup\$
    – Yousername
    Nov 25, 2022 at 19:43
  • \$\begingroup\$ I think a lot of languages will have the solution 000. Additionally, I think it isn't a great idea to say "character" as characters are things that we see, rather than the bytes that make up a program. For example, should the Jelly program AAA output A or )? Both are 0x41 (what appears in the program) but one is the ASCII code page and the other is the Jelly code page. \$\endgroup\$ Nov 28, 2022 at 20:30
1
\$\begingroup\$

Find the nth number where the digit sum equals the number of factors

\$\endgroup\$
3
  • \$\begingroup\$ Tag: sequence \$\endgroup\$
    – naffetS
    Nov 26, 2022 at 3:23
  • \$\begingroup\$ Since this is sequence, can we use default sequence rules and output infinitely? Or return the first n numbers? \$\endgroup\$
    – naffetS
    Nov 26, 2022 at 3:24
  • 1
    \$\begingroup\$ @Steffan yes you can. I've edited it into the challenge. \$\endgroup\$
    – The Thonnu
    Nov 26, 2022 at 7:07
1
\$\begingroup\$

Range of ASCII values

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

Join Columnar Strings

Tags:

\$\endgroup\$
2
  • \$\begingroup\$ "You may NOT assume inputs are ASCII only" seems like a really bad rule. It heavily restricts the challenge for a ton of languages and adds absolutely nothing. \$\endgroup\$ Nov 28, 2022 at 16:45
  • \$\begingroup\$ @RadvylfPrograms edited to ascii only \$\endgroup\$
    – bigyihsuan
    Nov 28, 2022 at 18:04
1
\$\begingroup\$

Merged strings

Not sure if this is already done

Basically, take two strings of reasonable length (like <32 chars) of numbers and X's and find the shortest superposition of those strings such that there's no 2 numbers at the same position. Number+X or X+X is allowed. Print the result.

Examples:

["01XX02","10XX2"]
-----
010X02

["5234XXX","431XXX"]
-----
523431XXX

Note:

  • Even if the string ends with X's, print those X's as they're part of the strings.
  • Oh and the result must start with the first string. (like test 4)

Tests:

1234   | 345    -> 12345
6573   | 2625   -> 65732625
11X    | 12     -> 112
XX1XX  | XX2XX  -> XX12XX
X1X2X3 | 1XX234 -> X1X2234

Scoring

The program with the least bytes wins!

\$\endgroup\$
2
  • \$\begingroup\$ In the current form this question is unclear. Please expand a bit and include test cases. Make sure to also include a scoring criteria \$\endgroup\$
    – mousetail
    Dec 4, 2022 at 14:31
  • \$\begingroup\$ @mousetail Is it better? \$\endgroup\$
    – SuperPizz
    Dec 4, 2022 at 15:38
1
\$\begingroup\$

><> numbers metagolf

\$\endgroup\$
1
  • \$\begingroup\$ I suggest linking to TIO (tio.run/#fish) or other online interpreter in the section "you can test your programs..." \$\endgroup\$
    – pajonk
    Nov 30, 2022 at 13:49
1
\$\begingroup\$

KotH: Don't Kill the Curve!

In this KotH, you will take a test at school. Your goal, of course, is to get the highest grade, up to a maximum of 110%. This score consists of your actual grade, curved, as well as 10% which is the average of other students' scores, since your teacher wants to encourage students to study together.

You have a minimum of 100 turns leading up to the test. You can use these to either:

  • Study: This add a point to your score (initially 0), unless your score is already 100
  • Tutor: Adds two points to the score of any other student, up to a max of 100
  • Arson: Majorly disrupt another student's life, dropping their score by 10 points (down to a minimum of zero), and negating their next 10 actions as they rebuild their life

Arson requires a lengthy jail sentence, meaning that your next 10 actions are also negated. If you have fewer than 10 actions left, you miss the test, and must retake it, making the maximum score you can receive (after the curve, before the bonus from other students) 70 points. Your real score is still used in the class average. Note that being an arson victim in the last 10 turns does not prevent you from taking the test; it only prevents you from studying, tutoring, or paying it forward.

You can also miss the test by taking more than 100 turns. After 100 turns you can only tutor or commit arson against other students which have not yet taken the test. Missing the test normally still has the same impact as if you had missed it while in jail, so it is likely only an effective strategy if you would otherwise receive a score below 70 (perhaps due to being an arson victim or avid tutor).

The test is also curved. Whichever student has the highest raw score will have theirs adjusted to 100, and that same shift will be applied to all other students. The curve is not taken into account for student averages, so if all students receive a 20% raw score, they would receive 102% as their final score (if they did not miss the test).

Information:

You are aware of all other students' scores on previous tests, your own "preparedness" (the raw score you would get if you took the test now), and the list of students who are recovering from arson and/or in jail.

\$\endgroup\$
4
  • \$\begingroup\$ The cooperative aspect seems like it's intended to be a major aspect, but since the average score will be applied to all bots there seems to be no benefit to helping others for the final ranking. Unlike a real test where absolute score matters. \$\endgroup\$
    – mousetail
    Dec 10, 2022 at 7:19
  • \$\begingroup\$ @mousetail That's a good point. One thing I'm considering, not sure if this would fix the problem, is running different combinations of bots instead of all of them for every game. That way a bot that's really bad at collaborating would lose points for pretty much every game, while the others it's matched with would only lose points due to it on a few games, giving the bad bot a lower total amount of points. \$\endgroup\$ Dec 10, 2022 at 16:01
  • \$\begingroup\$ Yes that might be better. You could even consider putting multiple copies of each bot in each classroom to increase the benefit of cooperation even more \$\endgroup\$
    – mousetail
    Dec 10, 2022 at 16:28
  • \$\begingroup\$ @mousetail Ooh that's a good idea. Maybe even running a bot against itself only could be interesting. \$\endgroup\$ Dec 10, 2022 at 16:29
1
\$\begingroup\$

Smallest and largest 100-bit square with maximum Hamming weight

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

Two-leg train journey

Joseph wants to travel by train from town A to town C. There is no direct train, so he wants to transfer in town B. You get the railway timetables from A to B and from B to C, and the latest time when Joseph needs to arrive to C. Compute the latest time that Joseph can arrive to the railway station in A and still be in time.

Times are given as integers between 0 and 1440, meaning the number of minutes from midnight on the day of the journey. A schedule from a town to another is given as a list of pairs, each pair made of two times, namely the time when the train departs from the first station and the time when it arrives to the second station. Your program gets three inputs: the train schedule from town A to town B, the train schedule from town B to town C, and the time when Joseph has to arrive to C the latest. Your program must output a single time, namely the latest time when Joseph has to be on station A.

The transfer at B is immediate, so if the first train arrives to B at exactly the same time as the second train departs from B then Joseph can transfer. You can assume that there are enough trains that Joseph can arrive at the required time or earlier. You can also assume that each schedule is sorted by departure time, but you cannot assume that the schedule is sorted by arrival time. For example, in the example input below, the first train from B departs at time 319 (meaning 09:27) and arrives at time 567 (meaning 9:27), but the second train departs at 366 and arrives at 539, overtaking the first train. Joseph is in a hypothetical country where trains always run exactly in time according to their schedule.

Here's a non-golfed example solution in Python 3. The function transfer solves the problem. The function travel takes just one schedule and finds when you have to arrive to the station where the trains in that schedule start.

def travel(schedule, arrival):
    departure = -2000
    for train in schedule:
        if train[1] <= arrival and departure < train[0]:
            departure = train[0]
    return departure
def transfer(schedule0, schedule1, arrival1):
    return travel(schedule0, travel(schedule1, arrival1))

Here's how we invoke the above example solution with an example input triple.

print(transfer(
    ((270, 294), (337, 357), (390, 414), (457, 477), (510, 534), (577, 597), (630, 654), (697, 717), (750, 774), (817, 837), (870, 894), (937, 957), (990, 1014), (1057, 1077), (1110, 1134), (1230, 1254), (1338, 1362)),
    ((319, 567), (366, 539), (540, 714), (545, 809), (780, 954), (785, 1055), (900, 1074), (905, 1169), (1025, 1280), (1140, 1324)),
    720))

This prints 510, which is the correct output for these inputs. In station A, Joseph will take the train at time 510 (meaning 08:30), arrive to B at time 534 (08:54), get on the second train at time 540 (09:00), and arrive to C at time 714 (11:54), which is not later then the deadline time 720 (12:00).

This is a slightly modified version of an easy programming homework problem that I posed many years ago. I am shamelessly copying the single example input from there, since I'm too lazy to make up a new one.

Golf Sandbox, besides all the other feedback, please tell me what tags I should use.

\$\endgroup\$
1
  • \$\begingroup\$ This would benefit from test cases. \$\endgroup\$
    – mousetail
    Dec 16, 2022 at 20:15
1
\$\begingroup\$

A decimal-based unit of time

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

Is this position a pure mirror mate?

\$\endgroup\$
2
  • \$\begingroup\$ I would add a test case where there is a white piece adjacent to the black king. I'd also add a test case just testing the guarding criteria. Otherwise I like it! \$\endgroup\$
    – jezza_99
    Dec 21, 2022 at 1:41
  • \$\begingroup\$ Suggested test case 8/R7/4k3/2P3P1/3K4/7B/8/8. This passes all test criteria, apart from one square (C6) being attacked by the rook and guarded by the bishop, whereas your test case 2 would return False just from a test to see if there are more than two attackers per square \$\endgroup\$
    – jezza_99
    Dec 21, 2022 at 21:00
1
\$\begingroup\$

Flip the order of operations

\$\endgroup\$
2
  • \$\begingroup\$ Your last test case (with the 2) contradicts the specs (only operators, parens and letters). \$\endgroup\$
    – pajonk
    Dec 23, 2022 at 7:28
  • \$\begingroup\$ @pajonk thanks, fixed \$\endgroup\$
    – mousetail
    Dec 23, 2022 at 7:31
1
\$\begingroup\$

Friend or Foe?

\$\endgroup\$
3
  • \$\begingroup\$ Since "Foe" is short they'd rather include in both program \$\endgroup\$
    – l4m2
    Dec 18, 2022 at 17:27
  • \$\begingroup\$ @l4m2 Good point. Maybe something like "this program is, in fact, a foe"? \$\endgroup\$ Dec 18, 2022 at 17:27
  • \$\begingroup\$ Still don't think it a good idea, slicing is easy in lots of languages \$\endgroup\$
    – l4m2
    Dec 18, 2022 at 17:32
1
\$\begingroup\$

No, thanks!

In the game “No Thanks!” playing cards numbered 3 to 35 are shuffled in a deck and 11 chips distributed to each player. The first player flips over a card and can then decide either to take the card, or to place a chip on top of it and to pass it on.

The card continues to be passed around until a player decides to take the card along with its chips. The same player flips over the next card and continues the procedure.

At the end of the game, the value of their cards get added up. Each chip they own is worth a negative point. The player with the lowest number of points wins.

Should a player have cards in succession (e.g. 18, 19, and 20), then the card with the lowest value (18) will be considered.

Rules

  • 9 cards will be removed from the deck at the start of the game

  • You will be participating with 2 other players

  • Everyone’s cards will always be visible

  • You do not have access to the amount of chips that others possess. You can, however, keep track of them.

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

Find the smallest turing machine that solves the self-counting problem

\$\endgroup\$
11
  • 1
    \$\begingroup\$ Welcome to Code Golf Stack Exchange, and interesting first challenge! I've got some comments on your submission: 1) When you say "smallest TM", how are you measuring it? fewest number of states? 2) I think the last ${0,1}$ should be ${L,R}$. 3) How are you defining input and output? 4) I would also suggest giving more background information, not everyone understands the notation used. I'm curious, does this "self-counting problem" exist in literature? (I'd be interested in articles/links.) \$\endgroup\$
    – user41805
    Dec 26, 2022 at 19:00
  • \$\begingroup\$ @user41805 thanks for the feedback, I came up with the problem myself, I don't think there is any literature on this problem. I'll edit my question to include your suggestions \$\endgroup\$
    – raoof
    Dec 27, 2022 at 2:35
  • \$\begingroup\$ Besides, try to keep your question a little more... aligned with common punctuation rules. It'll look better that way too. And besides, what's your scoring criterion? \$\endgroup\$ Dec 27, 2022 at 13:01
  • \$\begingroup\$ @UndoneStudios it's seems like inline latex is not supported is there a link for common punctuation rules. the scoring is based on number of states of the turing machine \$\endgroup\$
    – raoof
    Dec 27, 2022 at 15:30
  • \$\begingroup\$ Alternatively output 0 and 1, claiming an encoding that fit it \$\endgroup\$
    – l4m2
    Dec 28, 2022 at 7:49
  • \$\begingroup\$ 1) I meant using normal uppercase as well 2) So we have to write the code in a language that simulates a Turing Machine? Suggest using the code-challenge tag for this criterion. \$\endgroup\$ Dec 28, 2022 at 11:16
  • \$\begingroup\$ @l4m2 I didn't understand what you mean can you clarify? \$\endgroup\$
    – raoof
    Dec 28, 2022 at 15:34
  • \$\begingroup\$ @UndoneStudios no you just have to find a transition function and an encoding for the transition function \$\endgroup\$
    – raoof
    Dec 28, 2022 at 15:37
  • \$\begingroup\$ So no programming languages required? \$\endgroup\$ Dec 29, 2022 at 12:25
  • \$\begingroup\$ @raoof Also note that to fix your inline LaTeX use backslash to escape the $, like this: \$Q\$ -> \$Q\$ \$\endgroup\$ Dec 29, 2022 at 12:27
  • \$\begingroup\$ @UndoneStudios yes, no programming language is required. and thanks for the tip \$\endgroup\$
    – raoof
    Dec 29, 2022 at 19:14
1
\$\begingroup\$

RADD decomposition of an integer

\$\endgroup\$
2
  • \$\begingroup\$ What are the winning criteria? \$\endgroup\$
    – pajonk
    Dec 18, 2022 at 14:57
  • \$\begingroup\$ @pajonk I might add fastest-code, and then use time to decompose some big problems as a criteria. n in the range 400000 - 1000000. However, I don't know how to provide a comparison environment for the many languages used here. But I suspect that only non-naive methods with a better than linear time complexity have a chance. \$\endgroup\$ Dec 18, 2022 at 18:53
1
\$\begingroup\$

Maximum of outer product of integer vectors (in linear time)

\$\endgroup\$
2
  • \$\begingroup\$ I think the dyadic product as better known as the outer product. Still, it is really needed to define the problem? I think it's easier understood as, "What's the largest product you can make by selecting one number from each list?" A linear time seems OK to be me, but if you want a looser bound then polynomial time would be fine to eliminate the exponential brute-force solution. For input, the site's convention is to leave it flexible, and allow, say, taking in a list of lists however those are formatting in the language. I'd also suggest limiting to integer-valued vectors. \$\endgroup\$
    – xnor
    Dec 24, 2022 at 22:46
  • \$\begingroup\$ @xnor thx for your suggestions. I have addressed all points and added your problem formulation as an alternative. \$\endgroup\$
    – Sebastian
    Dec 30, 2022 at 12:42
1
\$\begingroup\$

Calculate the McCombination

In 2002, McDonald's advertised a McChoice menu of 8 items, labelled with "40,312 combinations." However, this number is far greater than the actual number of combinations (255; 2^8=256, minus 1 for empty meal). What the McDonald's marketing team calculated was how many different ways you could arrange a meal containing all 8 items (8! = 40,320), but subtracted 8 from the total to remove 1-item combinations. Since their original calculation was incorrect, the final result is meaningless.

The McCombination of a number n is the factorial of n, minus n.

Task:

Given an integer greater than 0 as input, output the McCombination of that number.

Test cases:

8 -> 40312
4 -> 20
9 -> 362871
3 -> 3
1 -> 0

This is , so shortest answer in bytes wins.

\$\endgroup\$
8
  • \$\begingroup\$ Welcome to Code Golf, and nice first challenge! \$\endgroup\$
    – Ginger
    Jan 5, 2023 at 16:49
  • \$\begingroup\$ Seems a bit boring, most languages have built-ins for both parts of this \$\endgroup\$
    – mousetail
    Jan 5, 2023 at 17:09
  • 1
    \$\begingroup\$ @mousetail do you think it would be better if it were something like “generate the first n McCombinayion numbers” or something \$\endgroup\$
    – noodle man
    Jan 5, 2023 at 19:36
  • \$\begingroup\$ @Jacob that doesn't make it more interesting. Stacking trivial problems on top of each-other doesn't make a challenge interesting. Plus if you did that you'd no longer allow the standard sequence rules \$\endgroup\$
    – mousetail
    Jan 7, 2023 at 16:05
  • \$\begingroup\$ Alright then. So if this doesn't seem like a good problem, should I delete this post? Not very familiar with how the sandbox works @mousetail \$\endgroup\$
    – noodle man
    Jan 7, 2023 at 16:13
  • 1
    \$\begingroup\$ You are free to delete or not delete, some people delete their posts others just abandon them. There's no convention one way or the other \$\endgroup\$
    – mousetail
    Jan 7, 2023 at 16:14
  • \$\begingroup\$ Also don't be discouraged, my first few questions where terrible too \$\endgroup\$
    – mousetail
    Jan 7, 2023 at 16:22
  • \$\begingroup\$ Okay thanks. I think I'll just leave this here then \$\endgroup\$
    – noodle man
    Jan 7, 2023 at 16:33
1
\$\begingroup\$

Guess the song title

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

Division between two strings

Inverse function of this challenge

To multiply two strings, you take two strings and compare each character. The character with the highest code point is then added to the output. If they are equal, simply add the character to the output.1

Given an input and the output, provide a random2 input such that multiplying the two inputs returns the output. Each possible input should be possibly generated. If there's no possible input, output nothing or something that isn't a string(crashing is fine, but not infinite loop)2.

1 I know it's not a multiply but that's copyed as-is
2 Otherwise a cat solves the question

\$\endgroup\$
3
  • \$\begingroup\$ How exactly should we generate with "random"? \$\endgroup\$ Jan 10, 2023 at 5:00
  • \$\begingroup\$ @UndoneStudios Each possible input should be possibly generated. \$\endgroup\$
    – l4m2
    Jan 10, 2023 at 5:03
  • \$\begingroup\$ Can you clarify a bit further? Perhaps an example testcase? \$\endgroup\$ Jan 10, 2023 at 5:05
1
\$\begingroup\$

WIP: clarify

Connect WEST and EAST using n pipe.

This is an example output, where n=9.

n=9

You can make sub-component, which each pin behave an extra pipe. Sub-component cost 2 pipe. Following is n=19. (The sub-component at the center is image above) You can also make sub-component in sub-component, and et infinitum.

n=19

It has same cost and behavior as

n=19

Thing change when n=35, where using sub-component only cost 33 pipe:

enter image description here

Now given odd n>8, output the minimum cost to connect WEST and EAST using n pipe.

9 => 9
19 => 19
35 => 33

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

Decimal to String with Mandatory Length

Tags:

Introduction:

Inspired by this SO question, which asks for the most accurate precision of decimal values using either rounding or scientific notation as string, with at most 15 characters long. This would include the -, ., and E in the output-string.

Challenge:

Inputs:

  • A decimal value \$s\$
  • An integer output-length \$n\$

Output:

  • A string of the most accurate representation of the given decimal value, with a length exactly equal to the output-length \$n\$. NOTE: the linked SO question ask for at most 15 characters long, but this challenge asks for exactly \$n\$ characters long instead.

Challenge rules:

  • The output-length input is guaranteed to be \$n\geq7\$
  • The decimal input is guaranteed to be valid and non-empty
  • You are allowed to take the input-decimal \$s\$ as string
  • The input-decimal is guaranteed to only contain the characters 0123456789-., and will not start with an . (but 0. instead), nor start with unnecessary leading 0s like 001.23 instead of 1.23 (except for 0.).
  • The output-string is guaranteed to only contain the characters 0123456789-.E (or e instead of E if you choose so). The input-format restrictions mentioned one bullet-point above, do NOT apply for the output-format however!
  • If the length of the integer part of a number (including - for negative values) is larger than the given output-length: use a scientific notation (with either e or E) and rounded precision. I.e. with inputs s = "-987654321987654321.987654321"; n = 15, the output is supposed to be one of these: ["-987654321.99E9", "-9876543219.9E8", "-98765432199.E7"]
  • It is allowed to add leading 0s to get to length \$n\$ without changing its decimal (base-10) value. I.e. with inputs s = "-123.00"; n = 15, the output "-00000000000123" would be valid.
  • It is allowed to add trailing 0s to the decimal parts to get to length \$n\$ without changing its decimal (base-10) value. I.e. with inputs s = "-1.23"; n = 15, the output "-1.230000000000" or "-1.2300000000E0" are both valid. (With inputs s = "-0.123456789123456789"; n = 15, the only possible output is "-.1234567891235".)
  • Please specify which rounding type your language is using! (E.g. HALF_UP, HALF_DOWN, HALF_EVEN, BANKERS, etc.) My test cases where this is relevant use HALF_UP.
  • If multiple outputs are possible, just output one, multiple, or all of them.

General rules:

  • This is , so shortest answer in bytes wins.
    Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.
  • Standard rules apply for your answer with default I/O rules, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return-type, full programs. Your call.
  • Default Loopholes are forbidden.
  • If possible, please add a link with a test for your code (i.e. TIO).
  • Also, adding an explanation for your answer is highly recommended.

Test cases:

All these test cases will use the output-length as 15 (and rounding mode HALF_UP):

Input:                           Possible Outputs:
"987654321987654321.987654321"   "987654321.988E9","9876543219.88E8","98765432198.8E7","987654321988.E6"
"-987654321987654321.987654321"  "-987654321.99E9","-9876543219.9E8","-98765432199.E7"
"1234567891234567.123456789"     "1234567.89123E9","12345678.9123E8","123456789.123E7","1234567891.23E6","12345678912.3E5","123456789123.E4"
"-1234567891234567.123456789"    "-1234567.8912E9","-12345678.912E8","-123456789.12E7","-1234567891.2E6","-12345678912.E5"
"0.123456789123456789"           ".12345678912346"
"-0.123456789123456789"          "-.1234567891235"
"5.5555555555555555555555555"    "5.5555555555556"
"-5.5555555555555555555555555"   "-5.555555555556"
"123456789123456"                "123456789123456"
"-123456789123456"               "-123456.78912E9","-1234567.8912E8","-12345678.912E7","-123456789.12E6","-1234567891.2E5","-12345678912.E4"
"123.00"                         "123.00000000000","0123.0000000000","00123.000000000","000123.00000000","0000123.0000000","00000123.000000","000000123.00000","0000000123.0000","00000000123.000","000000000123.00","0000000000123.0","00000000000123.","000000000000123","123.000000000E0","0123.00000000E0","00123.0000000E0","000123.000000E0","0000123.00000E0","00000123.0000E0","000000123.000E0","0000000123.00E0","00000000123.0E0","000000000123.E0","12.3000000000E1","012.300000000E1","0012.30000000E1","00012.3000000E1","000012.300000E1","0000012.30000E1","00000012.3000E1","000000012.300E1","0000000012.30E1","00000000012.3E1","1.23000000000E2","01.2300000000E2","001.230000000E2","0001.23000000E2","00001.2300000E2","000001.230000E2","0000001.23000E2","00000001.2300E2","000000001.230E2","0000000001.23E2",".123000000000E3","0.12300000000E3","00.1230000000E3","000.123000000E3","0000.12300000E3","00000.1230000E3","000000.123000E3","0000000.12300E3","00000000.1230E3","000000000.123E3","1230.0000000E-1","01230.000000E-1","001230.00000E-1","0001230.0000E-1","00001230.000E-1","000001230.00E-1","0000001230.0E-1","00000001230.E-1","000000001230E-1","12300.000000E-2","012300.00000E-2","0012300.0000E-2","00012300.000E-2","000012300.00E-2","0000012300.0E-2","00000012300.E-2","000000012300E-2","123000.00000E-3","0123000.0000E-3","00123000.000E-3","000123000.00E-3","0000123000.0E-3","00000123000.E-3","000000123000E-3","1230000.0000E-4","01230000.000E-4","001230000.00E-4","0001230000.0E-4","00001230000.E-4","000001230000E-4","12300000.000E-5","123000000.00E-5","1230000000.0E-5","12300000000.E-5","123000000000E-5","123000000.00E-6","1230000000.0E-6","12300000000.E-6","123000000000E-6","1230000000.0E-7","12300000000.E-7","123000000000E-7","12300000000.E-8","123000000000E-8","123000000000E-9"
"-123.00"                        "-123.0000000000","-0123.000000000","-00123.00000000","-000123.0000000","-0000123.000000","-00000123.00000","-000000123.0000","-0000000123.000","-00000000123.00","-000000000123.0","-0000000000123.","-00000000000123","-123.00000000E0","-0123.0000000E0","-00123.000000E0","-000123.00000E0","-0000123.0000E0","-00000123.000E0","-000000123.00E0","-0000000123.0E0","-00000000123.E0","-000000000123E0","-12.300000000E1","-012.30000000E1","-0012.3000000E1","-00012.300000E1","-000012.30000E1","-0000012.3000E1","-00000012.300E1","-000000012.30E1","-0000000012.3E1","-1.2300000000E2","-01.230000000E2","-001.23000000E2","-0001.2300000E2","-00001.230000E2","-000001.23000E2","-0000001.2300E2","-00000001.230E2","-000000001.23E2","-.12300000000E3","-0.1230000000E3","-00.123000000E3","-000.12300000E3","-0000.1230000E3","-00000.123000E3","-000000.12300E3","-0000000.1230E3","-00000000.123E3","-1230.000000E-1","-01230.00000E-1","-001230.0000E-1","-0001230.000E-1","-00001230.00E-1","-000001230.0E-1","-0000001230.E-1","-00000001230E-1","-12300.00000E-2","-012300.0000E-2","-0012300.000E-2","-00012300.00E-2","-000012300.0E-2","-0000012300.E-2","-00000012300E-2","-123000.0000E-3","-0123000.000E-3","-00123000.00E-3","-000123000.0E-3","-0000123000.E-3","-00000123000E-3","-1230000.000E-4","-01230000.00E-4","-001230000.0E-4","-0001230000.E-4","-00001230000E-4","-12300000.00E-5","-123000000.0E-5","-1230000000.E-5","-12300000000E-5","-123000000.0E-6","-1230000000.E-6","-12300000000E-6","-1230000000.E-7","-12300000000E-7","-12300000000E-8"

TODO: Fix the possible outputs of the other test cases as well:

"0.123"                          ".12300000000000"
"-0.123"                         "-.1230000000000"
"1.23"                           "1.2300000000000"
"-1.23"                          "-1.230000000000"
"0.000000000000001"              "10000000000E-25"
"0"                              "000000000000000"

All these test cases will use the output-length as 7 (and rounding mode HALF_UP):

Input:                           Output:
"987654321987654321.987654321"   "9.88E17"
"-987654321987654321.987654321"  "-9.9E17"
"1234567891234567.123456789"     "1.23E15"
"-1234567891234567.123456789"    "-1.2E15"
"0.123456789123456789"           ".123457"
"-0.123456789123456789"          "-.12346"
"5.5555555555555555555555555"    "5.55556"
"-5.5555555555555555555555555"   "-5.5556"
"123456789123456"                "1.23E14"
"-123456789123456"               "-1.2E14"
"123.00"                         "0000123" or "01.23E2" or "1.230E2"
"-123.00"                        "-000123" or "-12.3E1"
"0.123"                          ".123000"
"-0.123"                         "-.12300"
"1.23"                           "1.23000"
"-1.23"                          "-1.2300"
"0.000000000000001"              "100E-17" or "1.0E-15"
"0"                              "0000000",".000000","0.00000","00.0000","000.000","0000.00","00000.0","000000.","0E12345","000E-98"",etc.,etc. :/
\$\endgroup\$
12
  • 1
    \$\begingroup\$ Suggest testcase: "0.0000000001", 10 -> ".000000000", "0", 10, "0000000000" \$\endgroup\$
    – tsh
    Jan 13, 2020 at 1:50
  • \$\begingroup\$ @tsh Added (although I've used n=15 instead of 10 so I could add it to the other list instead of creating two separated test cases for the n=10. Principle remains the same for your test cases, so thanks for the suggestion! \$\endgroup\$ Jan 13, 2020 at 7:44
  • \$\begingroup\$ @tsh Your test case actually made me realize that s="0.0000000001", n=10 should be "100000E-15" instead for the most accurate result. Will have to do some fixes to my reference implementation. \$\endgroup\$ Jan 13, 2020 at 7:54
  • \$\begingroup\$ Why should it be 100E-17, not 1.0E-15? The rule makes me confusing. \$\endgroup\$
    – tsh
    Jan 13, 2020 at 9:14
  • \$\begingroup\$ @tsh 1.0E-15 would be allowed as well. I still have to change the rules after realizing that 0.00000 would be an incorrect result for s="0.0000000001", n=7, but both 100E-17 and 1.0E-15 are allowed, since they are of length 7 and retain the same exact value as 0.0000000001. I currently don't have the time to revise the rules, test cases, and reference implementation unfortunately (and if I delete the Sandbox post temporarily I can't search back for it). \$\endgroup\$ Jan 13, 2020 at 9:17
  • \$\begingroup\$ You say this challenge asks for exactly 15 characters long but you then have outputs of varying length. I assume you want the latter. I'm being pedantic, I know, but it's the only thing I can find to fix at the moment ;) \$\endgroup\$
    – lyxal
    Jan 13, 2020 at 9:28
  • \$\begingroup\$ @Jono2906 I've changed the part at the output-section. I hope it's a bit clearer now? \$\endgroup\$ Jan 13, 2020 at 9:33
  • \$\begingroup\$ @KevinCruijssen it is clearer now. I mean, as I said, I was just being pedantic about things. \$\endgroup\$
    – lyxal
    Jan 13, 2020 at 9:34
  • \$\begingroup\$ @Jono2906 Well, it was still a valid remark that I agree with, so thanks. :) \$\endgroup\$ Jan 13, 2020 at 9:36
  • \$\begingroup\$ Just another thing: Perhaps The decimal string input is guaranteed to be valid and non-empty should be The decimal string input is guaranteed to be a valid float and non-empty \$\endgroup\$
    – lyxal
    Jan 13, 2020 at 10:41
  • \$\begingroup\$ @Jono2906 Textual there isn't a difference between decimal/double/float, though. I had the sentence in my head as "the decimal string input is guaranteed to be (a) valid (decimal) and non-empty". I could change it to that if it makes it clearer, but talking about decimal first and float after that is more confusing than clarifying imho. But if you indeed meant "the decimal string input is guaranteed to be a valid decimal and non-empty" I'll change it. \$\endgroup\$ Jan 13, 2020 at 11:49
  • \$\begingroup\$ @KevinCruijssen Yep, I indeed meant decimal. I've no clue why I said float. \$\endgroup\$
    – lyxal
    Jan 13, 2020 at 20:10
1
82 83
84
85 86
157

You must log in to answer this question.

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