560
\$\begingroup\$

This "sandbox" is a place where Code Golf users can get feedback on prospective challenges they wish to post to main. This is useful because writing a clear and fully specified challenge on your first try can be difficult, and there is a much better chance of your challenge being well received if you post it in the sandbox first.

Sandbox FAQ

Posting

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

Write your challenge just as you would when actually posting it, though you can optionally add a title at the top. You may also add some notes about specific things you would like to clarify before posting it. Other users will help you improve your challenge by rating and discussing it.

When you think your challenge is ready for the public, go ahead and post it, and replace the post here with a link to the challenge and delete the sandbox post.

Discussion

The purpose of the sandbox is to give and receive feedback on posts. If you want to, feel free to give feedback to any posts you see here. Important things to comment about can include:

  • Parts of the challenge you found unclear
  • Comments addressing specific points mentioned in the proposal
  • Problems that could make the challenge uninteresting or unfit for the site

You don't need any qualifications to review sandbox posts. The target audience of most of these challenges is code golfers like you, so anything you find unclear will probably be unclear to others.

If you think one of your posts requires more feedback, but it's been ignored, you can ask for feedback in The Nineteenth Byte. It's not only allowed, but highly recommended! Be patient and try not to nag people though, you might have to ask multiple times.

It is recommended to leave your posts in the sandbox for at least several days, and until it receives upvotes and any feedback has been addressed.

Other

Search the sandbox / Browse your pending proposals

The sandbox works best if you sort posts by active.

To add an inline tag to a proposal, use shortcut link syntax with a prefix: [tag:king-of-the-hill]. To search for posts with a certain tag, include the name in quotes: "king-of-the-hill".

\$\endgroup\$
0

4329 Answers 4329

1
9 10
11
12 13
145
4
\$\begingroup\$

Hexagonify™ a String Block

\$\endgroup\$
4
\$\begingroup\$

Rennab

Reverse banneR

In the language of your own choosing write a program or function that takes as input the output of the super-handy-for-the-farsighted tool banner. And simply outputs the original text.

Example 1a of banner output on Linux:

> banner 'Code Golf'

   XXXX              XX                    XXXX            XX       XX
  X    X              X                   X    X            X      X
 X                    X                  X                  X      X
 X        XXXXX   XXXXX   XXXXX          X        XXXXX     X     XXXX
 X       X     X X    X  X     X         X       X     X    X      X
 X       X     X X    X  XXXXXXX         X   XXX X     X    X      X
 X       X     X X    X  X               X     X X     X    X      X
  X    X X     X X    X  X     X          X    X X     X    X      X
   XXXX   XXXXX   XXXXXX  XXXXX            XXXX   XXXXX   XXXXX   XXXX

Example 1b of rennab program that runs on Linux and takes input from stdin as lines of strings, and outputs to stdout, and supports the characters: [' ', 'C', 'G', 'd', 'e', 'f', 'l', 'o']:

> banner 'Code Golf' | rennab
Code Golf

Example 2a of banner output on Linux:

> banner ':-)'


                   X
                    X
                    X
    X                X
                     X
         XXXXXXX     X
                     X
                     X
    X               X
                    X
                   X

Example 2b of rennab program that runs on Linux and takes input from stdin as lines of strings, and outputs to stdout, and supports the characters: [':', '-', ')']:

> banner ':-)' | rennab
:-)

Choose what ever characters (minimum of 3) you want to support but that effects your score (see Rules below).

Rules

  • Program or function - your choice.
  • Input the output of banner in whatever format you'd like (eg 2d array of characters, list of strings, reading from stdin straight from the horse's mouth, &c).
  • For this challenge we'll use Cedar Solutions' open-source GNU/GPL banner implementation common on Linux. Prints horizontally only with a fixed size.
  • Output the original text in whatever format you'd like, return character at the end optional (eg as a string, a list of characters, as output to stdout, &c).
  • You can assume only the characters supported are input.
  • You must support a minimum of 3 characters.
  • Score is calculated by this formula (where \$n\$ is the number of code bytes and \$c\$ is the number of characters supported): \$n - 8c\$.
  • Scores can be negative.
  • No standard loopholes.
  • Lowest score wins.

Questions

  • Has this been done before?
  • Is the score formula any good? Any and all suggestions welcome.
  • Is the question any good? Any and all feedback welcome.
\$\endgroup\$
7
  • \$\begingroup\$ Shouldn't banner output be rotated 90 degrees? When I was testing banner, everything was sideways, not horizontal. \$\endgroup\$
    – lyxal
    Jan 13, 2020 at 20:55
  • \$\begingroup\$ @Jono2906 The output in my post is copy/pasted straight from my Linux terminal. \$\endgroup\$
    – Noodle9
    Jan 13, 2020 at 21:57
  • \$\begingroup\$ Huh, serves me right for using Unix. \$\endgroup\$
    – lyxal
    Jan 13, 2020 at 21:59
  • 1
    \$\begingroup\$ @Jono2906 Found out there's a few different types of banner implementations out there thanks to your comments. I've picked the one I'm used to and noted that in the post. Thanks :-) \$\endgroup\$
    – Noodle9
    Jan 15, 2020 at 10:59
  • \$\begingroup\$ No problem! I learnt something myself as well (the banner command and also that different OS's implement commands differently). \$\endgroup\$
    – lyxal
    Jan 15, 2020 at 11:02
  • \$\begingroup\$ This is pretty similar, just a different big-character set. \$\endgroup\$ Jan 17, 2020 at 19:50
  • \$\begingroup\$ This one is also really close, with just slight modifications to the big-character set. \$\endgroup\$ Jan 17, 2020 at 19:52
4
\$\begingroup\$

Reversed Iota's

I didn't invent this challenge, but I find it very interesting to solve.

For every input number, e.g.:

4

Generate a range from 1 to that number:

[1 2 3 4]

And then, for every item in that list, generate a list from 1 to that number:

[[1] [1 2] [1 2 3] [1 2 3 4]]

Then, reverse every item of that list.

[[1] [2 1] [3 2 1] [4 3 2 1]]

Notes:

  • 1 being a loose item is allowed, since flattening will not matter with this anyway.
  • To preserve the spirit of the challenge, the range has to be 1-indexed.
\$\endgroup\$
4
  • \$\begingroup\$ How should output be formatted? \$\endgroup\$
    – S.S. Anne
    Jan 26, 2020 at 16:20
  • \$\begingroup\$ This old challenge is pretty similar. The regular challenge isn't really a dupe, but one of the more common ways to get the bonus was to do essentially this. I don't think I would close it because the old one has a bonus, but I can't speak for everyone. \$\endgroup\$ Jan 26, 2020 at 19:01
  • \$\begingroup\$ A naming suggestion: Reveresed Iota's \$\endgroup\$
    – lyxal
    Jan 27, 2020 at 9:05
  • \$\begingroup\$ May the initial 1 be a loose item instead of a list [1]? I.e. 3 bytes in Jelly. \$\endgroup\$ Jan 28, 2020 at 13:37
4
\$\begingroup\$

Is it a doubling sequence?

Posted here:

Is it a doubling sequence?

\$\endgroup\$
3
  • \$\begingroup\$ Can the input array be empty or of length 1? \$\endgroup\$
    – Jo King Mod
    Feb 12, 2020 at 1:45
  • \$\begingroup\$ @JoKing In that case, the output must be vacuously True, I guess. \$\endgroup\$ Feb 12, 2020 at 4:47
  • \$\begingroup\$ @JoKing good question, I edited the input to only handle arrays with two or more numbers. \$\endgroup\$ Feb 12, 2020 at 13:16
4
\$\begingroup\$

Posted to main.

\$\endgroup\$
12
  • \$\begingroup\$ The initial set of squares should have a guaranteed distance from each other set of squares. grid needs better specification. What does "nearby square" mean? Other than that, solid spec. \$\endgroup\$ Oct 31, 2018 at 13:12
  • 2
    \$\begingroup\$ 1) The wording is weird on the Game of Life rule explanation. Please take a look at the Wikipedia page and clarify them. Currently, I'm not sure if a cell can change color if it's surrounded by more opponents than allies. Also, it seems to be implied that a live cell surrounded by 3 neighbors dies (which I'm pretty sure wasn't your intention). 2) What happens when no colors remain on the board? 3) Nitpick: the "this" in "it has at this time" threw me off - "that" instead, perhaps? \$\endgroup\$
    – Alion
    Oct 31, 2018 at 13:18
  • 2
    \$\begingroup\$ 4a) Since there's no explicit ban on cooperation, it's allowed by default. Was this your intention? 4b) Can bots communicate with each other? 5) Can bots store data across games? 6) Can we get a more easy-to-use system of storing data within one game? Scopes are useful for this: function externalFunc() { /* Storage */ return function gameLoopFunc(args) { /* Code */ }; } 7) next is not very robust. Some people (including myself) will remake the game simulation to gain access to more advanced functionality. 8) What happens if the returned value isn't within 2 cells of one of my own cells? \$\endgroup\$
    – Alion
    Oct 31, 2018 at 13:30
  • 1
    \$\begingroup\$ 9a) Why is selecting a live cell that is not your own a legal move, despite not doing anything? 9b) Is it legal to pass a move always? If so, what should we return if we want to pass a turn? 9b2) If it's not legal to pass a turn... why? It sounds pretty useful and makes sense. Please consider it. \$\endgroup\$
    – Alion
    Oct 31, 2018 at 13:33
  • \$\begingroup\$ @NathanMerrill Thanks, I've clarified that now. \$\endgroup\$ Oct 31, 2018 at 13:46
  • \$\begingroup\$ @Alion I've fixed 1, 3. I've removed next - good point (7). I've changed access to localStorage to access to this, clears between games (5,6). I've changed the scoring to a percentage and clarified draws (2). I've clarified that passing values out of bounds is illegal (8) and what (9a) does. I've also made passing legal (9b/c). (4) I did intend for cooperation (but not communication) to be legal; I've clarified that. Thanks for all the help! \$\endgroup\$ Oct 31, 2018 at 14:02
  • 2
    \$\begingroup\$ Splendid work. That being said, I'm not done yet. 10) Typos: id > it (line 2 of rule explanation), bot's > bots' (last restriction). 11) Can bots modify the grid passed to them (in the non-malicious sense)? 12) Black doesn't immediately strike me as a living cell. I'd recommend specifying that there exist neutral living cells (I only realized this during my 4th reading). 13) What format should submissions be? Template and example submissions both work. 14) Controller: If you haven't already, you should check out Dave's JS KotH framework. \$\endgroup\$
    – Alion
    Oct 31, 2018 at 15:21
  • \$\begingroup\$ 15) You've opened Pandora's Box with cooperation restriction. I'll illustrate what I mean with several abstract examples. GrudgeBot and PassiveBot: GrudgeBot will not attack PassiveBot, because PassiveBot doesn't bother GrudgeBot. FriendlyBot: Attempts to make friends with bots that it comes into contact with by testing if they will attack it. 2 instances would quickly team up after meeting each other. AlgoBot: Runs simulations and tests how well other bots play according to its idea of "optimal". 2 instances quickly realize that the other is playing optimal or near-optimal moves and team up. \$\endgroup\$
    – Alion
    Oct 31, 2018 at 15:40
  • \$\begingroup\$ 15 cont.) So, where do you draw the line? 16) performance.now() for timing purposes. Introduces unpredictability, but lets bots police their own time instead of their creators having to wildly guess the right values. Allowed or not? 17) cellular-automata, game, grid (maybe). \$\endgroup\$
    – Alion
    Oct 31, 2018 at 15:44
  • \$\begingroup\$ Whew, what a rampage. Despite all of that, I'm impatiently looking forward to this hitting main. Expect to see me there immediately. Keep up the good work! \$\endgroup\$
    – Alion
    Oct 31, 2018 at 15:47
  • 1
    \$\begingroup\$ Thank you very much! I've fixed (10)-(12). I'll add an example submission when I'm finished the controller - and I will definitely check out that framework! (15) - Good point, but I don't want to give an advantage to people who build multiple bots. I've added a clarification that a test for "too much cooperation" is preset move sequences and the like - identifying a bot by its strategy is okay. There's room for interpretation, but I trust that non-malicious entries will be reasonable. All of your examples I'm okay with. :) I will add some tags. \$\endgroup\$ Oct 31, 2018 at 15:58
  • \$\begingroup\$ @Alion I know it's taken way too long for me to get around to this, but if you're still interested... \$\endgroup\$ Feb 17, 2020 at 17:32
4
\$\begingroup\$

Is it a Happy Number?

A repost of this challenge (if I got the policy right).

Given a single positive integer (which can also be taken as a list of digits or a string), output whether the number terminates at 1 . Truthy/falsy follows the language's convention, or you can choose exactly one value for truthy and another for falsy. (This sequence is A007770.)

Your program should theoretically support all non-negative integers; however, if your language doesn't support unbounded integers, you may only support integers up to 2147483647.

Procedure

Suppose you have the number 193.

  • Square every individual digit in the number. Therefore the number's individual digits becomes:
[1] [81] [9]
  • Sum all these individual digits:
92
  • Repeat this procedure until it stabilizes at 1 or a 37-cycle like the following:
37-58-89-145-42-20-4-16-37

It has been shown that the procedure will always produce either one of these two outputs.

Test cases

Here is a sample program generating the test cases. Here is a step by step reduction of all input between 1 and 100.

1 -> true
2 -> false
3 -> false
4 -> false
5 -> false
6 -> false
7 -> true
8 -> false
9 -> false
10 -> true
11 -> false
12 -> false
13 -> true
14 -> false
15 -> false
16 -> false
17 -> false
18 -> false
19 -> true
20 -> false
21 -> false
22 -> false
23 -> true
24 -> false
25 -> false
26 -> false
27 -> false
28 -> true
29 -> false
30 -> false
31 -> true
32 -> true
33 -> false
34 -> false
35 -> false
36 -> false
37 -> false
38 -> false
39 -> false
40 -> false
41 -> false
42 -> false
43 -> false
44 -> true
45 -> false
46 -> false
47 -> false
48 -> false
49 -> true
50 -> false
51 -> false
52 -> false
53 -> false
54 -> false
55 -> false
56 -> false
57 -> false
58 -> false
59 -> false
60 -> false
61 -> false
62 -> false
63 -> false
64 -> false
65 -> false
66 -> false
67 -> false
68 -> true
69 -> false
70 -> true
71 -> false
72 -> false
73 -> false
74 -> false
75 -> false
76 -> false
77 -> false
78 -> false
79 -> true
80 -> false
81 -> false
82 -> true
83 -> false
84 -> false
85 -> false
86 -> true
87 -> false
88 -> false
89 -> false
90 -> false
91 -> true
92 -> false
93 -> false
94 -> true
95 -> false
96 -> false
97 -> true
98 -> false
99 -> false
\$\endgroup\$
8
  • \$\begingroup\$ Is there an upper bound for inputs? I think one thing to consider is whether you want answers to implement the square-summing operation, or to try to compress or overfit some heuristic that works for say, 1 to 100. \$\endgroup\$
    – xnor
    Mar 28, 2020 at 10:46
  • \$\begingroup\$ Falsy numbers belong to A007770. \$\endgroup\$
    – Arnauld
    Mar 29, 2020 at 22:49
  • \$\begingroup\$ @Arnauld Nice catch + Title suggestion! \$\endgroup\$
    – user92069
    Mar 30, 2020 at 0:25
  • 2
    \$\begingroup\$ With the term "happy number" in hand, I found a probable duplicate. \$\endgroup\$
    – xnor
    Mar 30, 2020 at 8:37
  • \$\begingroup\$ Ugh, why do I always have duplicate ideas recently... \$\endgroup\$
    – user92069
    Mar 30, 2020 at 9:01
  • \$\begingroup\$ @xnor This is a dupe indeed, but the other challenge is very old and it seems like it requires a full program with a cumbersome output format. So maybe we should rather close the old challenge as a dupe of this one instead? (I'm not sure about the right policy here.) \$\endgroup\$
    – Arnauld
    Mar 30, 2020 at 10:38
  • 3
    \$\begingroup\$ We did once repost Kolakoski one and closed the old one as dupe (with relevant meta discussion). But this case is a bit different because the author of the old challenge is no longer active. \$\endgroup\$
    – Bubbler
    Mar 30, 2020 at 23:00
  • \$\begingroup\$ @Arnauld Good point, that old challenge is sure showing its rust. \$\endgroup\$
    – xnor
    Mar 30, 2020 at 23:14
4
\$\begingroup\$

Posted

Solve a Picross Row

\$\endgroup\$
2
  • 1
    \$\begingroup\$ I don't think it is a dupe of full nonogram solver. I recommend allowing flexible I/O formats though (e.g. values other than 0,1,2 to mark each cell state). \$\endgroup\$
    – Bubbler
    May 6, 2020 at 7:54
  • 1
    \$\begingroup\$ To make the challenge more self-contained, consider adding a brief introduction to picross/nonogram and its rules. \$\endgroup\$
    – Bubbler
    May 6, 2020 at 9:18
4
\$\begingroup\$

Implement an HTML renderer

Note: This challenge explaination is very much incomplete - it merely contains ideas that will require revising to form a proper challenge post.

The premise of the challenge is to write a program that take an HTML document as an input, and outputs an ASCII equivalent. Obviously, working with real HTML is not possible, so this challenge will use a very limited and modified subset of HTML.

Here is an example of a potential input:

<body>
    <h1>A Document</h1>
    <div>
        <span>Hello, this is some text</span>
        <img> 8 2 </img>
    </div>
</body>

Which would yield the following output:

+--------------------+
|A DOCUMENT          |
|                    |
|+------------------+|
||Hello, this is som||
||e text            ||
||+--------+        ||
|||@~@~@~@~|        ||
|||~@~@~@~@|        ||
||+--------+        ||
|+------------------+|
+--------------------+

HTML elements that will be implemented:

<span> - Renders text between the tags, wrapping when necessary.

Example:

<body>
<span>
    This is a span element.
    You can write text in here.
</span>
</body>

Output:

+--------------------+
|This is a span eleme|
|nt. You can write te|
|xt in here.         |
|                    |
|                    |
|                    |
|                    |
|                    |
|                    |
|                    |
+--------------------+

(Extra explanation needed to clarify whitespace and character set issues)

<p> (Explanations are omitted to save space)

<h1> - <h6>

<div>

<img>

Sandbox questions/remakrs

  • I believe it is possible to write an unambiguous and specific set of rules for how an "HTML document" should be rendered
  • It will require lots of careful explanation, wording, and ample examples
  • However this challenge seems very long and complicated and it seems like it might not be in the spirit of a code golf challenge

What do you guys think?

\$\endgroup\$
2
  • 1
    \$\begingroup\$ "I believe it is possible" -- Yes, rewriting a subset of the HTML Spec for ASCII is possible. However, successful challenges tend to keep it simple. I'd suggest using just span and div and using no attributes. In addition, parsing has probably been done before and is cumbersome, so I'd suggest allowing input as a pre-parsed AST to focus on the key challenge of ASCII-art generation \$\endgroup\$ Jul 9, 2020 at 6:16
  • \$\begingroup\$ Personally I would keep only body, div, span and img, altho img should follow a set pattern inside of it. I would also suggest making height and width attributes mandatory, in all tags. \$\endgroup\$
    – Dion
    Jul 20, 2020 at 6:08
4
\$\begingroup\$

Solve a 2xN Maze (posted)

\$\endgroup\$
1
  • \$\begingroup\$ Now that this has been posted to main, could you delete this proposal to create more space for new answers? \$\endgroup\$ Sep 25, 2020 at 1:04
4
\$\begingroup\$

Does the naïve fill suffice?

A bot is positioned in a rectangular grid. By preference it will paint in a west direction, but if it cannot it will paint in a south, east or if all else fails north direction. Sometimes this can lead it to fill the grid, but other times it gets stuck. The following examples show how the path (indicated by ascending digits) of the bot on a given grid varies depending on its starting position:

1

The bot is always able to fill a 1×1 grid, since simply by existing it has already painted the grid.

14    21    43    34
23    34    12    21

The bot is always able to fill a 2×2 grid. As a consequence of its painting direction preferences it normally traverses anticlockwise except when it starts in the bottom right corner when it traverses clockwise.

16    21    65    ..    56    65    165    216    321    654     345    456
25    36    14    21    43    34    234    345    456    123     216    321
34    45    23    34    12    21

The bot usually fills a 2×3 grid, except when it starts in the middle right square. On the other hand, it always fills a 3×2 grid; its painting direction preferences cause it to paint clockwise if it starts in the bottom middle or bottom right cell, otherwise anticlockwise.

189    21.    321    87.    987    ...    987    ...    987
276    387    498    165    216    321    236    345    456
345    456    567    234    345    456    145    216    321

The bot is able to fill a 3×3 grid when it starts in one of the even squares. It's mathematically impossible for the bot to fill it when it starts in an odd square, but I have included these positions for completeness.

Your task is to solve the of whether the bot is able to fill a given grid from a given starting point. You can assume that the grid size is a positive integer and that the starting point lies within the grid. You can take the grid size and starting point in any consistent order, as separate inputs, a pair of pairs or a list of 4 elements, or any other reasonable input format. The starting point can be 0-indexed or 1-indexed. You can use any two consistent outputs, or you can output using any values that your language considers truthy or falsy, but not both. Please include your input and output format in your answer.

The directions west, south, east or north correspond to decrementing the x-coordinate, incrementing the y-coordinate, incrementing the x-coordinate and decrementing the y-coordinate respectively.

This is , so the shortest program or function that breaks no standard loopholes wins!

Test cases (0-indexed, width height x y):

4 4 0 0 -> True
4 4 1 1 -> False
4 4 2 2 -> True
4 4 3 3 -> True
4 7 1 3 -> False
\$\endgroup\$
11
  • 1
    \$\begingroup\$ What's the "naive fill" algorithm exactly? \$\endgroup\$
    – DELETE_ME
    Jul 12, 2020 at 11:24
  • 1
    \$\begingroup\$ Comment: it's hard for me to figure out that each "column" (separated by space) represents a x*y board. Consider clarifying that. \$\endgroup\$
    – DELETE_ME
    Jul 12, 2020 at 11:25
  • \$\begingroup\$ @user202729 The very first two sentences are supposed to describe it, just move in the first available preferred direction until you can't move any more and paint as you go. \$\endgroup\$
    – Neil
    Jul 12, 2020 at 14:11
  • \$\begingroup\$ Some comments: (1) You don't seem to define that "naïve fill" is. (2) It took me a while to undersdtand the meaning of the numbers 14, 21` etc mean the 2nd example, and similarly in others. After a while I realized that each "code section" contains several examples stacked horizontally. You should make thast more obvious (maybe increasing horizontal space, or explaining it in the text) \$\endgroup\$
    – Luis Mendo
    Jul 12, 2020 at 15:47
  • \$\begingroup\$ (3) "It normally traverses anticlockwise except when it starts in the bottom right corner when it traverses clockwise": what does "normally" mean here? How do we know/choose the direction the robot follows? Or maybe this is the definition of "naïve fill"? (4) Why can't the robot fill the 2×3 case when it starts in the middle right square? That is, why doesn't start by moving up instead of left? (5) In general, but I find it all quite confusing... maybe it's me, but consider explaining the challenge with more detail \$\endgroup\$
    – Luis Mendo
    Jul 12, 2020 at 15:47
  • \$\begingroup\$ @LuisMendo (1) The bot paints as it goes. It prefers to go west, but when it can't go west tries south, then east, then north. That's all there is to it. (2) I've added some more text and spacing. (3) "normally" means "most of the time it ends up doing this". (4) Because its first preferred direction is west so it ends up painting itself into a corner. \$\endgroup\$
    – Neil
    Jul 12, 2020 at 16:53
  • \$\begingroup\$ (1) It prefers to go west, but when it can't go west tries south, then east, then north. That phrasing makes it much totally clear. (Now I see that's probably what you meant with by preference) Include it in the text? (3) I still find the word normally confusing there, as if that were an additional degree of freedom. Also, I see now that except when it starts in the bottom right corner when it traverses clockwise is a consequence of (1). I suggest you explicitly state something like "As a consequence of the rule for direction choice, ..." \$\endgroup\$
    – Luis Mendo
    Jul 12, 2020 at 17:03
  • \$\begingroup\$ @LuisMendo Fair enough; I've tweaked the text again now. \$\endgroup\$
    – Neil
    Jul 12, 2020 at 17:35
  • \$\begingroup\$ I really like this challenge, but I wonder whether the title could be a little more descriptive/catchy - perhaps 'Can the bot fill the grid?' or similar? \$\endgroup\$
    – Dingus
    Jul 14, 2020 at 15:00
  • \$\begingroup\$ @Dingus "Can the naïve bot fill the grid?" counts as similar, right? \$\endgroup\$
    – Neil
    Jul 14, 2020 at 17:23
  • \$\begingroup\$ Ooh, that's even better. Immediately makes me curious to find out what the naïve bot is. \$\endgroup\$
    – Dingus
    Jul 15, 2020 at 0:35
4
\$\begingroup\$

A Spherical Die

Inspiration

I have a spherical die, but it's a cheap one so it doesn't work properly. When I roll it, it doesn't always land directly on a "face" marking, but instead can result in an ambiguous result ("is that a 6, a 4 or a 2?")

Assumptions

Assume the die is a perfect, evenly-weighted Unit Sphere (i.e. all points on the surface are radius 1cm from the center) , such that a "roll" can result in any point on the sphere being the uppermost point (the "roll value").

Assume that, if the die is placed or rolled such that 1 is at the "north pole", the conventions of a normal die will follow, i.e:

  • 6 will be at the "south pole"
  • 4, 5, 3, 2 will be on the "equator", clockwise in that order, equidistant around the sphere.

So, before it's rolled, the die looks like this:

image of die

The Challenge

Given a simulated roll of the die (i.e. coordinates representing the top of the die after it's rolled) with the conditions above, identify the closest value (1-6) to that point (i.e. what the roll value should resolve to).

Input

A co-ordinate on the sphere.

There are a few co-ordinate systems used for spheres, the two I'm familiar with (and so will provide examples in) are as follows:

  • P(1, φ, Θ) where φ is the "azimuth angle" (0..360), Θ is the "polar angle" (0..180)

  • P(x,y,z) where \$x^2+y^2+z^2=1\$

(note: the conversion between the two is: x = cos(φ)·sin(Θ); y = sin(φ)·sin(Θ); z = cos(Θ))

for clarity:

  • roll "1" is at P(1,n,0)
  • roll "2" is at P(1,270,90)
  • roll "3" is at P(1,180,90)
  • roll "4" is at P(1,0,90)
  • roll "5" is at P(1,90,90)
  • roll "6" is at P(1,n,180)

Output

The nearest value (1-6) to that point. If the point is equidistant to two or more points, output any one of them.

Usual exclusions etc. apply.

\$\endgroup\$
17
  • \$\begingroup\$ Does anyone know the maths for this? Feel free to edit it in! \$\endgroup\$ Nov 22, 2019 at 9:40
  • \$\begingroup\$ I'm not sure I understand: You want us to generate a random point on a sphere and output the face of the die it corresponds to? \$\endgroup\$
    – flawr
    Nov 22, 2019 at 9:57
  • \$\begingroup\$ yeah, so generate a random point on the sphere, then find the nearest "face" - i.e. the nearest of the 6 points (top, bottom, 4 points on opposite sides around middle) \$\endgroup\$ Nov 22, 2019 at 11:11
  • \$\begingroup\$ This will be exactly equivalent to a uniform distribution over 6 values, just based on the symmetry of the situation. \$\endgroup\$ Nov 22, 2019 at 12:33
  • \$\begingroup\$ @AlienAtSystem yes, all outcomes are equally likely; but the challenge is determining which number any given point on the face of the sphere is closest to \$\endgroup\$ Nov 22, 2019 at 13:04
  • 4
    \$\begingroup\$ That's not the challenge as posted. Right now, it's "Takes no input, returns the number the (internally generated) random point is closest to" which is, under the consensus of no unobservable requirements simply equal to "Takes no input, returns uniform random value from 1-6". If you want the challenge to be "Input is point on sphere, output is number it's closest to", then write that. \$\endgroup\$ Nov 22, 2019 at 13:09
  • \$\begingroup\$ @AlienAtSystem I've edited to try and make it clearer what I'm looking for. Is it clearer now? \$\endgroup\$ Nov 22, 2019 at 13:15
  • \$\begingroup\$ It's clearer that my point still stands. Look, "Make Voronoi cells on sphere" and "Generate uniformly random points on sphere" are both good challenges. But when put together like that, they annihilate each other and give you an extremely quick shortcut right from Input (None) to output (a die roll) that doesn't require calculation of either part. \$\endgroup\$ Nov 22, 2019 at 13:21
  • 2
    \$\begingroup\$ @AlienAtSystem thanks for the feedback, I'd never heard of a Voronoi cell before. What I'm asking, then, is "generate a random point on a sphere and say which Voronoi cell that point is in". Can you explain why that doesn't work? Note that I'm asking for both the point and the cell to be output, not just the cell - otherwise I agree, given the "no unobservable requirements" rule it would be possible to just generate a random number and pretend you'd done it properly (although that would be against the spirit of it) \$\endgroup\$ Nov 22, 2019 at 13:24
  • \$\begingroup\$ Would it be better for the point on the sphere to be the input, then? \$\endgroup\$ Nov 22, 2019 at 13:27
  • \$\begingroup\$ If you want the challenge to be about finding the points it's closest to, yes. \$\endgroup\$ Nov 22, 2019 at 13:31
  • \$\begingroup\$ I want it to be a good challenge on this theme, whatever that would look like :) \$\endgroup\$ Nov 22, 2019 at 13:33
  • \$\begingroup\$ Although I don't think the current challenge is bad, it's usually best to not have multiple challenges into one nor multiple outputs (since some languages aren't able to output more than once very easily). The two challenges are: 1. Generate a random coordinate on a sphere (in whichever coordinate system you want); 2. Given a (random) coordinate on a sphere, output the dice-value closest to it. No. 1 already is a challenge, so I agree it might be better to rewrite it to challenge No. 2. I do like the general idea though, so +1 from me. \$\endgroup\$ Nov 22, 2019 at 14:36
  • \$\begingroup\$ It would also need some info about the size of the sphere, and what to do when the coordinate is exactly in the center between two or three poles. \$\endgroup\$ Nov 22, 2019 at 14:39
  • 1
    \$\begingroup\$ Note that the actual implementation is very simple, as explained in chat. \$\endgroup\$
    – DELETE_ME
    Jul 15, 2020 at 2:43
4
\$\begingroup\$

Note: this challenge is a work-in-progress, so suggestions would be appreciated

Questions for meta:

  • How can I prevent people from just using SHA or MD5 one-way compression?
  • are these language restrictions fair?
  • is this scoring system fair?
  • are there any obvious cheap answers?
  • what other tags should be added?
  • what should the challenge title be?
  • will these restrictions adequately prevent people trying to cheat their way through?
  • should a limit be put on a password length? Should I limit passwords to ASCII printable characters?

The challenge

Your challenge is to first choose a "password" (please do not use your actual password). Then, you will create a program which will output a truthy value if and only if this password is given as input, falsy otherwise. Your goal will be to make it so others are unable to reverse-engineer this password (and you will keep this password secret for now).

Scoring

The scoring for this challenge is somewhat different than regular . During the first two weeks from when an answer is posted, other users will have the opportunity to try to crack your password by reverse-engineering your code. If anyone gets your password correct during this two week period, your answer will be marked as cracked. If two weeks pass without users finding the password, your answer can be marked as safe once you share the password (again, please do not use your actual password, you should make up a new one that you don't use anywhere).

Note that you may use any tools at your disposal (online tools, brute-force attacks, modified code, etc) to extract someone else's password from their code.

Of all the safe answers, the one with the shortest source code (i.e. ) wins!

Rules

To make things fair for everyone, you may only use languages that appear on TIO, or languages that have well-written documentation and are used somewhat widely. You must also provide a link to try your code online that anyone can access (as such, you may not use languages behind paywalls like MATLAB but Octave is still on the table because it's free).

Even if you don't want to post an answer, feel free to try to crack any of the existing answer's passwords! If you get a password, you can simply leave a comment on that answer and that answer will be cracked.

Note

If you edit the code in your answer, the two week period will reset! You may edit any explanations in your answer freely (I will verify that any answers marked safe did not cheat).

tags: code-golf

\$\endgroup\$
18
  • \$\begingroup\$ Example answer \$\endgroup\$
    – Daniel H.
    Aug 19, 2020 at 12:38
  • \$\begingroup\$ Surely any cryptographic hash function (which are implemented in many languages) will make it easy to generate an impossible-to-crack answer? For instance, in R I can write test=scan(,'');if(digest::digest(test,"md5")=="b6778692586dc649267723ccc3356fad")TRUE else FALSE and I'll be pretty confident that nobody will crack my password... \$\endgroup\$ Aug 19, 2020 at 15:10
  • 1
    \$\begingroup\$ That is a good point. It seems like this challenge is similar to just writing a hash function. You might want to add other ideas to make the challenge more interesting \$\endgroup\$
    – thesilican
    Aug 19, 2020 at 16:06
  • \$\begingroup\$ That's what I was about to write, any hash function with a hidden default salt depending on the language, or anything like that, could be hiding the password easily enough. \$\endgroup\$ Aug 19, 2020 at 16:06
  • \$\begingroup\$ @DominicvanEssen is this an actual MD5 hash? I was unable to reverse it (note that a lot of MD5 hashes can be reversed with online tools like this). Note that for this challenge people would be allowed any and all tools at their disposal to crack passwords. This means people are very much allowed to reverse-engineer code in any ways they please \$\endgroup\$
    – Daniel H.
    Aug 19, 2020 at 16:06
  • \$\begingroup\$ Answering in many esolangs could hide the password easily enough, too. If I answer in Lenguage, Unary, Mariolang,... \$\endgroup\$ Aug 19, 2020 at 16:07
  • \$\begingroup\$ @V.Courtois this is true, but the point is not to read the password in the source code. The point of the challenge would be to reverse-engineer their code to crack a password (so documentation and online tools are all fair game). Also, Unary will likely be an invalid language because people must be able to actually run the program online (and Unary programs are usually way too big to run online) \$\endgroup\$
    – Daniel H.
    Aug 19, 2020 at 16:08
  • \$\begingroup\$ Now that I think about it, any type of loop could hide the password easily enough, too. But even with what I said before and what I'm saying now, I think this challenge has to exist (if not existing already), because having many valid answers is not a problem (not to me, at least). \$\endgroup\$ Aug 19, 2020 at 16:09
  • \$\begingroup\$ @DominicvanEssen also, even if nobody can reverse your password, that's still fine - the winner of this challenge is whoever has the shortest code out of all the uncracked passwords. In other words, this is still a codegolf challenge, but answers can be disqualified if anyone finds the password. So, if you want to win but you don't have the shortest code, you simply have to crack other people's passwords! \$\endgroup\$
    – Daniel H.
    Aug 19, 2020 at 16:15
  • \$\begingroup\$ @DanielH. Yes, my example was an actual MD5 hash (the password was mypassword). You're right that some hash functions can be reversed, but there are many cryptographically-secure ones for which this is difficult. \$\endgroup\$ Aug 19, 2020 at 16:17
  • \$\begingroup\$ @DominicvanEssen I'm unfamiliar with MD5 hashes, but when I converted mypassword to an MD5 hash using three different online tools I got 34819d7beeabb9260a5c854bc85b3e44 every time instead of the hash in your answer. Could you please provide a TIO link for the R code (when I copy-pasted it into TIO it didn't work for me and I'm unfamiliar with R)? I'd like to try experimenting with MD5 \$\endgroup\$
    – Daniel H.
    Aug 19, 2020 at 16:22
  • \$\begingroup\$ I'm afraid that the R 'digest' library is not installed on TIO (making a link was the first thing I tried). \$\endgroup\$ Aug 19, 2020 at 16:25
  • \$\begingroup\$ But, after some research, it turns-out that R adds some (consistent) extra characters to the string by default before applying MD5. This behaviour can be switched off, at which point mypassword indeed hashes to 34819d7beeabb9260a5c854bc85b3e44. \$\endgroup\$ Aug 19, 2020 at 16:46
  • \$\begingroup\$ how many letters are the passowrds capped at? Are unprintables allowed? \$\endgroup\$
    – Razetime
    Aug 20, 2020 at 3:30
  • \$\begingroup\$ @Razetime I might add a restriction of 16 characters, ASCII printables only. I will have to try to balance this cap though - if it's too short, passwords can easily be brute-forced. If it's too long, everyone will just use one-way compression and passwords will never be cracked \$\endgroup\$
    – Daniel H.
    Aug 20, 2020 at 11:24
4
\$\begingroup\$

Stroke Count of a Chinese Numeral Posted

\$\endgroup\$
5
  • \$\begingroup\$ Related (not dupe). Stroke count is actually good idea because it avoids the need to hardcode Chinese characters. The description looks clear enough to me. \$\endgroup\$
    – Bubbler
    Aug 5, 2020 at 3:11
  • \$\begingroup\$ Might be useful: tio.run/… \$\endgroup\$
    – DELETE_ME
    Aug 5, 2020 at 11:45
  • \$\begingroup\$ (to read the test cases) \$\endgroup\$
    – DELETE_ME
    Aug 5, 2020 at 11:45
  • \$\begingroup\$ Has it been posted to main? I can't seem to find it. \$\endgroup\$ Aug 21, 2020 at 10:02
  • 1
    \$\begingroup\$ @V.Courtois posted. \$\endgroup\$
    – att
    Aug 25, 2020 at 4:54
4
\$\begingroup\$

All work and no play but it gets thinner every time

Your objective is to output the unique string with the following properties:

  • Each paragraph consists entirely of repetitions of the sentence All work and no play makes Jack a dull boy.
  • The first paragraph is a single line with exactly one repetition of the sentence.
  • Each line of each subsequent paragraph is shorter than the longest line of the previous paragraph.
  • Each line contains as many words of the sentence as possible without exceeding the length limit, and no trailing whitespace.
  • Paragraph ends when its next line would be identical of some previous line of the same paragraph, possibly terminating the last sentence early.
  • The last paragraph has the same width as the longest word in the sentence (5).
  • There's a pair of line ends between each pair of paragraphs, a single line end after the last paragraph, and no line end before the first paragraph.

The string produced by these rules has: 5025 bytes when using Windows line ends (CR LF) or 4796 bytes using Linux line ends (LF); 229 line ends; 103 full repetitions of the sentence and 11 partial repetitions. It can be compressed into a 249-byte deflate stream (bubblegum code). The full string is included below for reference.

All work and no play makes Jack a dull boy.

All work and no play makes Jack a dull
boy. All work and no play makes Jack a
dull boy. All work and no play makes Jack
a dull boy. All work and no play makes
Jack a dull boy. All work and no play
makes Jack a dull boy. All work and no
play makes Jack a dull boy. All work and
no play makes Jack a dull boy. All work
and no play makes Jack a dull boy. All
work and no play makes Jack a dull boy.

All work and no play makes Jack a dull
boy. All work and no play makes Jack a
dull boy. All work and no play makes
Jack a dull boy. All work and no play
makes Jack a dull boy. All work and no
play makes Jack a dull boy. All work and
no play makes Jack a dull boy. All work
and no play makes Jack a dull boy. All
work and no play makes Jack a dull boy.

All work and no play makes Jack a dull
boy. All work and no play makes Jack a
dull boy. All work and no play makes
Jack a dull boy. All work and no play
makes Jack a dull boy. All work and no
play makes Jack a dull boy. All work
and no play makes Jack a dull boy. All
work and no play makes Jack a dull boy.

All work and no play makes Jack a dull
boy. All work and no play makes Jack a
dull boy. All work and no play makes
Jack a dull boy. All work and no play
makes Jack a dull boy. All work and no
play makes Jack a dull boy. All work
and no play makes Jack a dull boy. All
work and no play makes Jack a dull

All work and no play makes Jack a
dull boy. All work and no play makes
Jack a dull boy. All work and no play
makes Jack a dull boy. All work and
no play makes Jack a dull boy. All
work and no play makes Jack a dull
boy. All work and no play makes Jack
a dull boy. All work and no play

All work and no play makes Jack a
dull boy. All work and no play makes
Jack a dull boy. All work and no
play makes Jack a dull boy. All work
and no play makes Jack a dull boy.

All work and no play makes Jack a
dull boy. All work and no play
makes Jack a dull boy. All work and
no play makes Jack a dull boy. All
work and no play makes Jack a dull
boy. All work and no play makes
Jack a dull boy. All work and no
play makes Jack a dull boy. All

All work and no play makes Jack a
dull boy. All work and no play
makes Jack a dull boy. All work
and no play makes Jack a dull boy.

All work and no play makes Jack a
dull boy. All work and no play
makes Jack a dull boy. All work
and no play makes Jack a dull
boy. All work and no play makes
Jack a dull boy. All work and no
play makes Jack a dull boy. All
work and no play makes Jack a

All work and no play makes Jack
a dull boy. All work and no play
makes Jack a dull boy. All work
and no play makes Jack a dull
boy. All work and no play makes
Jack a dull boy. All work and no
play makes Jack a dull boy. All
work and no play makes Jack a
dull boy. All work and no play

All work and no play makes Jack
a dull boy. All work and no
play makes Jack a dull boy. All
work and no play makes Jack a
dull boy. All work and no play
makes Jack a dull boy. All work
and no play makes Jack a dull
boy. All work and no play makes
Jack a dull boy. All work and
no play makes Jack a dull boy.

All work and no play makes
Jack a dull boy. All work and
no play makes Jack a dull boy.

All work and no play makes
Jack a dull boy. All work and
no play makes Jack a dull
boy. All work and no play
makes Jack a dull boy. All
work and no play makes Jack a
dull boy. All work and no
play makes Jack a dull boy.

All work and no play makes
Jack a dull boy. All work
and no play makes Jack a
dull boy. All work and no
play makes Jack a dull boy.

All work and no play makes
Jack a dull boy. All work
and no play makes Jack a
dull boy. All work and no
play makes Jack a dull
boy. All work and no play
makes Jack a dull boy. All
work and no play makes

All work and no play
makes Jack a dull boy.

All work and no play
makes Jack a dull
boy. All work and no
play makes Jack a
dull boy. All work
and no play makes
Jack a dull boy. All
work and no play

All work and no
play makes Jack a
dull boy. All work
and no play makes
Jack a dull boy.

All work and no
play makes Jack a
dull boy. All
work and no play
makes Jack a dull
boy. All work and
no play makes
Jack a dull boy.

All work and no
play makes Jack
a dull boy. All
work and no play
makes Jack a
dull boy. All

All work and no
play makes Jack
a dull boy. All
work and no

All work and
no play makes
Jack a dull
boy. All work
and no play
makes Jack a
dull boy. All
work and no
play makes

All work and
no play
makes Jack a
dull boy.

All work
and no play
makes Jack
a dull boy.

All work
and no
play makes
Jack a
dull boy.

All work
and no
play
makes
Jack a
dull boy.

All work
and no
play
makes
Jack a
dull
boy. All
work and
no play

All
work
and no
play
makes
Jack a
dull
boy.

All
work
and
no
play
makes
Jack
a
dull
boy.
\$\endgroup\$
6
  • \$\begingroup\$ So a sentences can span one or more lines? Was thinking the sentences got shorter until you said there's 103 full repetitions. No clear explanation on what exactly paragraphs, paragraph widths, sentences, lines, and line ends are. \$\endgroup\$
    – Noodle9
    Sep 28, 2020 at 15:05
  • \$\begingroup\$ @Noodle9 I've added some of the reference output; would the reference suffice to explain those? \$\endgroup\$ Sep 28, 2020 at 15:30
  • \$\begingroup\$ Can you simply add the whole output? (I still don't understand it) \$\endgroup\$ Sep 28, 2020 at 15:37
  • \$\begingroup\$ @thedefault. added. I didn't want to clutter the sandbox. \$\endgroup\$ Sep 28, 2020 at 15:39
  • \$\begingroup\$ Alternative name: Write a novel for Jack Torrance \$\endgroup\$
    – Razetime
    Sep 28, 2020 at 15:51
  • \$\begingroup\$ Better to say what you mean by these terms. Maybe a template of the output where lines are, say, seperared by newline characters. Sentences are substring of "..." containing only whole words and ended by a period. Paragraphs are seperated by two newlines. Or whatever it actually is. \$\endgroup\$
    – Noodle9
    Sep 28, 2020 at 17:07
4
\$\begingroup\$

Make a quine that shrinks and grows

Write a program that outputs another program that is:

  • Larger in bytes than the original
  • Outputs a program that is smaller than itself that also obeys these rules and is larger than the original program

Basically the output should alternate between larger than the previous program and smaller than it, while increasing in total size as it goes.

Related

\$\endgroup\$
2
  • \$\begingroup\$ Perhaps it should be "larger than the program two before" rather than "larger than the original?" As stated, a 5-length program could output a 7-length, which outputs a 6-length, which then oscillates between 7 and 6, not growing in total size as it goes. \$\endgroup\$ Oct 8, 2020 at 18:51
  • \$\begingroup\$ Probably should be named something other than a quine because I find that term misleading for the challenge you described. \$\endgroup\$
    – Beefster
    Oct 14, 2020 at 21:12
4
\$\begingroup\$

Strobogrammatic Numbers


Definition

A number which is rotationally symmetrical, i.e., it'll appear the same when rotated by 180 deg in the plane of your screen. The following figure illustrates it better,


strobogrammatic-number

(source: w3resource.com)

Task

Given a number as the input, determine if it's strobogrammatic or not.

Examples

  • Truthy
1
8
0
69
96
69169
1001
666999
888888
101010101
  • Falsey
2
3
4
5
7
666
969
1000
88881888
969696969

Rules

  • The number is guaranteed to be less than a billion.
  • We are considering 1 in it's roman numeral format for the sake of the challenge.
  • Input can be taken as number, or an array of chars, or as string.
  • Output would be a truthy/falsey value.
  • This is a , so fewest bytes will win!

Meta

  • Although I've tried a search, but is this a duplicate?
  • Is the challenge's text clear enough?
  • Any tricky/interesting test case?
\$\endgroup\$
1
4
\$\begingroup\$

Explain a Code Golf Answer

Background

When writing Code Golf answers, it is often a good idea to add an explanation of the code so the reader understands what's going on. For example, this this answer by @Makonede (abridged):

        θ  # last element of
Σ          # the input, sorted in increasing order by
     1¢    # the number of ones of
   %       # modulo
 žJ        # 4294967296
    b      # in binary

The full program is written on the first line, then a blank line, then on each successive line, a little snippet of the program, aligned using spaces with its position in the full program, and then some comments on the right-hand side explaining each part.

I, for one, find writing and aligning these explanations tedious, so let's outsource it to a program.

Task

Given a program as a string, and a list of sets of pairs of start/end indices to form an inclusive range, output each sub-string defined by the indices on a new line, indented to its respective position in the whole string, with a # at the end of the line, padded so that there are two spaces before the # after the last sub-string, ready for the user to add their explanation.

Rules

  • You may use 0-based or 1-based indexing
  • You are guaranteed to receive valid, non-overlapping ranges, which together cover the whole string
  • You may assume the program string contains no newlines, tabs or other unprintable characters, and no double-width characters
  • Standard I/O rules and loopholes apply
  • This is , so shortest code in bytes wins

Examples (1-based indexing)

Inputs: abcdwxyz, (1-8)
Output:

abcdwxyz  #

Inputs: abcdwxyz, (5-7), (1-2),(8-8), (3-4)
Output:

    wxy   #
ab     z  #
  cd      #

Inputs: <<<$[grep -c wx $0-grep -c y\z $0];:<<'Q', (6-20), (22-37), (4-5),(38-38),(21-21), (1-3), (39-39), (40-40), (41-45)]
Output:

     `grep -c wx $0`                           #
                     `grep -c y\z $0`          #
   $[               -                ]         #
<<<                                            #
                                      ;        #
                                       :       #
                                        <<'Q'  #

Meta

  • Is this a duplicate?
  • Is this clear enough?
  • Any other feedback?
\$\endgroup\$
3
  • 1
    \$\begingroup\$ Related \$\endgroup\$
    – Razetime
    Dec 24, 2020 at 10:32
  • 1
    \$\begingroup\$ @Razetime I would say this is a dupe :-( \$\endgroup\$
    – pxeger
    Dec 24, 2020 at 13:35
  • \$\begingroup\$ I'd say this is simpler and more suited for code golf because it functions without the need for a complex priority system. You may want to request more opinions on the nineteenth byte. \$\endgroup\$
    – Razetime
    Dec 24, 2020 at 17:51
4
\$\begingroup\$

Interpret Interval Notation

\$\endgroup\$
13
  • \$\begingroup\$ @Adám yes to and -ish characters. I also broadened the scope to all meaningful intervals, so ranges may overlap and [5,5] (all integers x where 5<=x<=5)is [5] but not [5,5) (all integers x where 5<=x<5) and (5,5) (all integers x where5<x<5) are undefined. \$\endgroup\$
    – Aiden4
    Dec 22, 2020 at 21:07
  • 2
    \$\begingroup\$ All integers x where 5<=x<5 would be [], no? \$\endgroup\$
    – Adám
    Dec 22, 2020 at 22:25
  • \$\begingroup\$ I'd put all the undefined cases separately, or at least at the end. \$\endgroup\$
    – Adám
    Dec 23, 2020 at 0:09
  • 2
    \$\begingroup\$ Typo: the [9,13] test case should either be [9,13) or 13 is missing from the output. \$\endgroup\$
    – Dingus
    Dec 23, 2020 at 2:35
  • \$\begingroup\$ undefined cases should be undefined behavior instead. Otherwise, one need to handle it separately which feels bad. Otherwise, it's a good challenge :) \$\endgroup\$
    – vrintle
    Dec 23, 2020 at 11:22
  • \$\begingroup\$ If you allow other symbols for the brackets, make sure to prohibit other phrases as that can be abused. \$\endgroup\$
    – Adám
    Dec 23, 2020 at 15:16
  • \$\begingroup\$ @Adám what do you mean by phrases? \$\endgroup\$
    – pxeger
    Dec 23, 2020 at 16:06
  • 3
    \$\begingroup\$ @pxeger Multi-character constructs. It'd allow solutions to require an input format that contained the necessary code such that the solution becomes an eval. \$\endgroup\$
    – Adám
    Dec 23, 2020 at 16:46
  • 1
    \$\begingroup\$ Related \$\endgroup\$
    – Razetime
    Dec 24, 2020 at 10:44
  • \$\begingroup\$ Is parsing a string necessary? Could you also allow other constructs (tuples with a marker to show if they're open or closed)? \$\endgroup\$
    – user
    Dec 25, 2020 at 21:56
  • \$\begingroup\$ Just asking frankly, did you forgot to post this, or is something yet missing? \$\endgroup\$
    – vrintle
    Jan 4, 2021 at 2:59
  • \$\begingroup\$ @user I am going to say no to other constructs otherwise, it is basically a duplicate of the related challenge. \$\endgroup\$
    – Aiden4
    Jan 4, 2021 at 15:03
  • \$\begingroup\$ @vrintle Something like that. I haven't really been active since just before Christmas. I'll probably post it this afternoon. \$\endgroup\$
    – Aiden4
    Jan 4, 2021 at 15:04
4
\$\begingroup\$

Implement a zipwith function

\$\endgroup\$
14
  • \$\begingroup\$ APL or J will win this with 2 bytes (that's the shortest possible score, right?) \$\endgroup\$
    – Adám
    Jan 14, 2021 at 21:23
  • \$\begingroup\$ Required tag: restricted-source \$\endgroup\$
    – Adám
    Jan 14, 2021 at 21:24
  • \$\begingroup\$ Why the builtin restriction? \$\endgroup\$ Jan 14, 2021 at 21:45
  • \$\begingroup\$ @RedwolfPrograms To avoid trivialising the challenge \$\endgroup\$ Jan 14, 2021 at 21:52
  • \$\begingroup\$ @Adám 1) if those 2 bytes are a builtin, then no, otherwise, very possible. 2) Why [restricted-source]? \$\endgroup\$ Jan 14, 2021 at 21:52
  • \$\begingroup\$ Any reason for banning that builtin in Haskell and Jelly? What's wrong with people submitting that as answer? They won't get upvoted much anyway. And it still lets people use builtins in other languages. \$\endgroup\$
    – user
    Jan 14, 2021 at 22:14
  • \$\begingroup\$ @cairdcoinheringaahing No, that'd be prohibited by your source restrictions rule on an exact built-in. Rather, it'd be a more general built-in (so not "exact") plus a parameter that makes the general built-in choose the required behaviour. \$\endgroup\$
    – Adám
    Jan 15, 2021 at 3:21
  • \$\begingroup\$ Allowing the built-in and seeing how many languages have it could be interesting in its own right. Or, generalize the problem to nzipwith, which takes an n-ary function and n sequences (and optionally the value n) and call the function for each n-tuple from the n sequences. \$\endgroup\$
    – Bubbler
    Jan 15, 2021 at 6:10
  • \$\begingroup\$ I've softened the builtin ban to simply encourage people to post a non-builtin answer as well. @Bubbler Possibly, but I think it'd be a good challenge to simply have the basic zipwith given that it's a fairly common functional programming construct \$\endgroup\$ Jan 15, 2021 at 14:39
  • \$\begingroup\$ I think it's better to not ban them, and simply let builtin users wallow in their downvotes/shame so they don't do it again \$\endgroup\$
    – pxeger
    Jan 16, 2021 at 19:45
  • \$\begingroup\$ @pxeger I've removed the builtin ban, and changed it to encourage builtin-only answers to include a non-builtin version as well \$\endgroup\$ Jan 16, 2021 at 19:47
  • \$\begingroup\$ Would taking input as two lazily evaluated iterators over the elements of the list or outputting an iterator over the results be acceptable \$\endgroup\$
    – Aiden4
    Jan 26, 2021 at 1:39
  • \$\begingroup\$ @Aiden4 I think that taking lists as lazy iterators is an accepted I/O method, so yes \$\endgroup\$ Jan 26, 2021 at 9:11
  • \$\begingroup\$ I find the former ban on Jelly's " interesting considering that there's no way to really pass it a function. \$\endgroup\$ Jan 26, 2021 at 9:36
4
\$\begingroup\$

Calculate the 'geothmetic meandian' of a set of numbers

Randall Munroe's March 10 xkcd comic "Geothmetic Meandian" defines the 'geothmetic meandian' of a set of positive real numbers as follows.

Define a function F, such that F accepts a set of n positive real numbers and returns the set (a, b, c), where a is the arithmetic mean of the set (the sum of the numbers in the set divided by n), b is the geometric mean of the set (the product of the numbers in the set to the power of 1/n), and c is the median of the set (the average of the middle two numbers in the sorted set when n is even, and the middle number in the set when n is odd). The function F can therefore be applied again to its own output. Iterating F an infinite number of times should cause its three outputs to converge to one value g. This value g is defined as the geothmetic meandian of the original set of positive reals. (For the purposes of this challenge, you may assume this value exists and does not diverge.)

Given a nonempty list of positive real numbers in any convenient and reasonable format and a positive integer q, compute its 'geothmetic meandian' to q significant figures. Standard rules apply, and the shortest code in bytes wins.

Test cases

[[1], 2] --> 1.0
[[2, 8], 4] --> 4.742
[[1, 1, 2, 3, 5], 6] --> 2.08906
[[1, 2, 4, 8], 6] --> 3.13227
[[1.1, 2.2, 4.4, 8.8], 9] --> 3.44550208
\$\endgroup\$
9
  • 4
    \$\begingroup\$ This seems like a decent challenge, but I don't know if the rounding requirement adds anything. \$\endgroup\$
    – rak1507
    Mar 11, 2021 at 2:40
  • \$\begingroup\$ @rak1507 I was accounting for if different languages have different levels of floating-point precision, and also because the calculation needs to stop at some defined point. \$\endgroup\$
    – Cloudy7
    Mar 11, 2021 at 3:24
  • 3
    \$\begingroup\$ The problem with taking the number of significant figures q as input is that you're banning the use of float and double numbers entirely (doubles will break at q >= 16 or so), which is a big no-no. You could take the number of iterations i instead and require the solutions to output the result of i-th iteration. \$\endgroup\$
    – Bubbler
    Mar 12, 2021 at 5:05
  • \$\begingroup\$ @Bubbler I envisioned part of the challenge to be determining when to stop the iteration of F. Should I then restrict q to be a positive integer from 1 to 7 or something similar? \$\endgroup\$
    – Cloudy7
    Mar 12, 2021 at 17:28
  • \$\begingroup\$ Alternatively, we can have have a fixed number of iterations i and output the geothmetic meandian to the highest precision possible given i iterations. However, thinking about it, I agree this part of the challenge may be unfeasible. \$\endgroup\$
    – Cloudy7
    Mar 12, 2021 at 17:39
  • \$\begingroup\$ Oh dear. I just tried another test case and due to floating-point errors in calculation, my program slowly drifts by 2e-12 indefinitely as F is iterated... \$\endgroup\$
    – Cloudy7
    Mar 12, 2021 at 17:49
  • 3
    \$\begingroup\$ How about this: Given a value q (a positive floating-point number), stop iteration when the difference between the maximum and the minimum is less than q, and output any of the three numbers (or all of them). Allow the solutions to fail if q is too small compared to the input (i.e. it is outside the precision capability of the floating-point type in use). I think this is clearer to specify the error margin this way. \$\endgroup\$
    – Bubbler
    Mar 15, 2021 at 3:46
  • \$\begingroup\$ Or just require that all programs use a fixed q, e.g. 100? \$\endgroup\$
    – pxeger
    Mar 20, 2021 at 17:53
  • 1
    \$\begingroup\$ I feel like adding anything to do with the precision will just complicate things, and most of the code will be for handling that, not for actually answering the challenge. IMO it's fine to say 'until it converges', and leave specifics up to the challenge answerers. \$\endgroup\$
    – rak1507
    Mar 22, 2021 at 12:19
4
\$\begingroup\$

Hide a message in ASCII art and an image

(needs cooler title)


Cops


Robbers

\$\endgroup\$
7
  • 1
    \$\begingroup\$ How the heck?! I was just drafting a challenge about stenography and images yesterday and then I see this.. \$\endgroup\$ Mar 26, 2021 at 16:28
  • \$\begingroup\$ @RedwolfPrograms was your idea the exact same as mine? \$\endgroup\$
    – Beefster
    Mar 26, 2021 at 16:35
  • 1
    \$\begingroup\$ Not identical, there was no ASCII art included, but considering there are only 5 steganography questions on the whole site that's an insane coincidence \$\endgroup\$ Mar 26, 2021 at 17:03
  • 1
    \$\begingroup\$ If the robber doesn’t know any of the messages, it might be hard to verify any potential explanation. It might be more fun and easier to verify a correct solution if the cop posts N codes and the solutions to N-1 of them, and the robber has to use those to reverse engineer the method and decode the last one. Alternately, the cop could have to pick from a list of pre-selected messages so the robber has some idea what to look for. \$\endgroup\$ Mar 26, 2021 at 17:33
  • 1
    \$\begingroup\$ Do the ascii+png files have to contain all the information necessary for decoding? For example, could I use a book cipher where the PNG encodes word numbers, and you then have to look up the corresponding words from The Great Gatsby? \$\endgroup\$ Mar 26, 2021 at 18:03
  • \$\begingroup\$ @water_ghosts I think a book cipher should only be allowed if you provide a link to the book. All data needed to decode aside from the image and ascii art should be present in the post and be constant across all encodings. \$\endgroup\$
    – Beefster
    Mar 29, 2021 at 18:43
  • \$\begingroup\$ This is amazing! You, dear sir/ma'am, get an upvote \$\endgroup\$ Apr 3, 2021 at 17:05
4
\$\begingroup\$

Determine Circles

\$\endgroup\$
12
  • \$\begingroup\$ Nice idea, but could you make it clearer what do you mean by cross? A test case would be good. \$\endgroup\$
    – math scat
    Apr 6, 2021 at 7:04
  • \$\begingroup\$ @math intersect or some concept like that. Can you give some better wording if you can understand what I mean? I can't find any word that suit line go over dot \$\endgroup\$
    – okie
    Apr 6, 2021 at 7:09
  • \$\begingroup\$ Maybe: 1, 2, 3 points will need 1 circle only to be sure that the points touch the circles boundary? Is that what you mean? \$\endgroup\$
    – math scat
    Apr 6, 2021 at 7:17
  • \$\begingroup\$ Some testcases are definitely needed, like five points on one circle and three points on another. Also, are the coordinates integers or real numbers? \$\endgroup\$
    – Bubbler
    Apr 6, 2021 at 8:15
  • \$\begingroup\$ @Bubbler Real number I think \$\endgroup\$
    – okie
    Apr 6, 2021 at 8:17
  • \$\begingroup\$ @okie Then you need to explicitly write it down, and add some testcases with non-integer coordinates. \$\endgroup\$
    – Bubbler
    Apr 6, 2021 at 8:21
  • \$\begingroup\$ In this problem, the answer does not change continuously with small perturbations of the input coordinates. Is it allowed to output the wrong answer due to floating point errors? For instance, if the input coordinates were (0,0),(0.3,0.3),(1,1) then the output should be 2. However, if the second point were instead (0.3,0.300...00001) then the answer should be 1. Given that floating point types are usually unable to tell these two cases apart, are we allowed to output either 1 or 2? \$\endgroup\$
    – Delfad0r
    Apr 6, 2021 at 16:01
  • \$\begingroup\$ @Delfad0r Thanks for your help. To solve such problem (float precision), I decided to add a limit to float so that precision are not extreme. \$\endgroup\$
    – okie
    Apr 7, 2021 at 0:15
  • 1
    \$\begingroup\$ Another possible approach (which I personally prefer, but the choice is entirely up to you) could be to only have integer coordinates as input, and then ask for an exact solution. If I am not mistaken, this problem should be solvable without resorting to square roots and similar, and therefore without any possibility of floating point errors. \$\endgroup\$
    – Delfad0r
    Apr 7, 2021 at 12:30
  • \$\begingroup\$ @Delfad0r But it's like a float *100 0.03*100 = 30 which just get every number bigger? \$\endgroup\$
    – okie
    Apr 7, 2021 at 23:38
  • \$\begingroup\$ @okie Yes, but the difference is that computations with integers are exact, while computations with floats are not. It shouldn't matter too much however, do whatever you prefer :) \$\endgroup\$
    – Delfad0r
    Apr 7, 2021 at 23:43
  • \$\begingroup\$ @Delfad0r I think I would take Integer, Thanks! \$\endgroup\$
    – okie
    Apr 8, 2021 at 0:04
4
\$\begingroup\$

posted lol

\$\endgroup\$
8
  • \$\begingroup\$ Another suggestion it can be kolmogorov complexity challe ge too, if someone downloads tags and compresses the text \$\endgroup\$
    – Wasif
    Apr 12, 2021 at 5:31
  • \$\begingroup\$ @Wasif it's better as an internet challenge because a new tag might be created after challenge posting making the list invalid. \$\endgroup\$
    – lyxal
    Apr 12, 2021 at 5:31
  • \$\begingroup\$ Should the list include the synonym tags, i.e. the tags that are listed as being on no questions in the tag listing? \$\endgroup\$ Apr 12, 2021 at 13:30
  • \$\begingroup\$ @cairdcoinheringaahing if it is listed on the tags page, then it needs to be included \$\endgroup\$
    – lyxal
    Apr 12, 2021 at 22:54
  • \$\begingroup\$ What is the 43 for in example program? \$\endgroup\$
    – tsh
    Apr 14, 2021 at 3:18
  • \$\begingroup\$ @tsh 43 is the number of occurrences of tag when you try and access a page of tags that doesn't exist \$\endgroup\$
    – lyxal
    Apr 14, 2021 at 3:19
  • \$\begingroup\$ Rule is still too wide, everyone can upload code to codegolf.stackexchange.com \$\endgroup\$
    – l4m2
    Apr 15, 2021 at 4:19
  • \$\begingroup\$ @l4m2 if people include all the tags in a post, then they will have to a) keep it constantly updated (which wouldn't be viewed favourably by the community) and b) withstand potential downvotes for loop holing on both the answer to this and the answer that has the tags \$\endgroup\$
    – lyxal
    Apr 15, 2021 at 4:45
4
\$\begingroup\$

Implement an Over function

\$\endgroup\$
2
  • 3
    \$\begingroup\$ Can we take \$a\$ and \$b\$ as [a,b]? In effect, this would make the challenge a \$g\$ reduction of \$f\$ mapped over that input list. \$\endgroup\$
    – Adám
    Apr 19, 2021 at 21:12
  • 2
    \$\begingroup\$ @Adám I think it would be unfair (and potentially unobservable) to ban languages from taking it as [a,b], and doing so would likely just create solutions in the form pair input; map f; reduce g \$\endgroup\$ Apr 19, 2021 at 21:41
4
\$\begingroup\$

Death-onacci sequence (WIP)

The traditional Fibonacci sequence grows forever:

0 1 1 2 3 5 8 13 21 ... 1,346,269 ...

and is given by this formula:

f(n) = f(n-1) + f(n-2)

where the initial numbers in the sequence are 0, 1.

However, there's a set of as-yet unnamed sequences, where a previous number 'dies' and is removed from the total.

For instance the sequence for the 5th death-onacci (m = 5) is given by

f(n) = f(n-1) + f(n-2) + f(n-3) + f(n-4) - f(n-5)

And the first m-1 numbers is 0, followed by a single 1 (so for m=5 the sequence start 0 0 0 0 1)

Test cases:

Here are some test cases:

n f(n), m=3 f(n), m=4 f(n), m=5
0 0 0 0
1 0 0 0
2 1 0 0
3 1 1 0
4 2 1 1
5 2 2 1
6 3 4 2
7 3 6 4
8 4 11 8
9 4 19 14
10 5 32 27
11 5 56 51
12 6 96 96
13 6 165 180
14 7 285 340
15 7 490 640
16 8 844 1205
17 8 1454 2269
18 9 2503 4274
19 9 4311 8048
20 10 7424 15156
21 10 12784 28542
22 11 22016 53751
23 11 37913 101223
24 12 65289 190624
25 12 112434 358984
26 13 193620 676040
27 13 333430 1273120
28 14 574195 2397545
29 14 988811 4515065
30 15 1702816 8502786
31 15 2932392 16012476

You must write a function or program that takes one number M, and prints out the first 31 M-Death-onacci numbers. M will be a whole number larger than 0 and less than 31. The output can be in any human readable format, and you can take input in any reasonable manner. (Command line arguments, function arguments, STDIN, etc.)

As usual, this is Code-golf, so standard loopholes apply and the shortest answer in bytes wins!

\$\endgroup\$
5
  • 1
    \$\begingroup\$ Very similar. \$\endgroup\$
    – Razetime
    Apr 24, 2021 at 9:57
  • \$\begingroup\$ @Razetime definitely, but hopefully different enough? \$\endgroup\$ Apr 24, 2021 at 10:02
  • \$\begingroup\$ Well, it's a WIP. You can go ahead and add more details which distinguish it. 'tis the sandbox, after all. \$\endgroup\$
    – Razetime
    Apr 24, 2021 at 10:04
  • \$\begingroup\$ @Razetime how's it looking now? \$\endgroup\$ Apr 24, 2021 at 10:23
  • 1
    \$\begingroup\$ looks better, and the tests are more comprehensive. I suggest posting in TNB for other people's feedback. \$\endgroup\$
    – Razetime
    Apr 24, 2021 at 11:11
4
\$\begingroup\$

Do I need a win streak?

\$\endgroup\$
10
  • 2
    \$\begingroup\$ taking P as a fraction seems fine, but it seems more convenient separately since we're just supposed to increment N and P till the desired ratio is achieved. What is the allowance for floating point errors on this question? \$\endgroup\$
    – Razetime
    Apr 24, 2021 at 10:07
  • \$\begingroup\$ an additional "Streak bonus" for every x games might be an interesting addition. \$\endgroup\$
    – Razetime
    Apr 24, 2021 at 10:08
  • 1
    \$\begingroup\$ @Razetime Oh did I say fraction, I meant a decimal value between 0 and 1, eg: 0.53 for 53%. There wont be more than two decimal places in the input so I doubt if any language will run into floating point errors at all. \$\endgroup\$ Apr 24, 2021 at 10:11
  • 1
    \$\begingroup\$ I updated the question to allow P as decimal. About the streak bonus, I think it might complicate things quite a bit so I am not going with that. \$\endgroup\$ Apr 24, 2021 at 10:21
  • \$\begingroup\$ You should clarify in the text if the inputs W, N can be taken separately or only as one number corresponding to W/N. And if so, please address Razetime's comment on floating point errors \$\endgroup\$
    – Luis Mendo
    Apr 24, 2021 at 15:17
  • \$\begingroup\$ @LuisMendo Yes, taking them separately is fine. I updated the post again, please check if it is clear now. \$\endgroup\$ Apr 24, 2021 at 15:47
  • \$\begingroup\$ I'd suggest also allowing languages to take P as a fraction. Other than that, this looks good to go \$\endgroup\$ Apr 24, 2021 at 16:09
  • 1
    \$\begingroup\$ I think they have to be taken separately. In the first example, if you take W/N as 0.2 you cannot compute the output, because you don't know if W=1, N=5, or W=2,N=10, or... \$\endgroup\$
    – Luis Mendo
    Apr 24, 2021 at 17:32
  • 1
    \$\begingroup\$ Oh yes, you're right about that. You'd have to consider both the values to calculate the answer. \$\endgroup\$ Apr 24, 2021 at 19:01
  • 1
    \$\begingroup\$ @LuisMendo But if it somehow benefits you to take it say as a string of the form "W/N" with the original values of W and N, then that's fine too. I think the rules clarify that point. \$\endgroup\$ Apr 24, 2021 at 19:16
4
\$\begingroup\$

Gelatin integer metagolf

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

Drawing the Stack Overflow logo

\$\endgroup\$
14
  • \$\begingroup\$ I don't think restricting the language is a good idea. Move languages promotes diversity among submissions. However, I'm still new to the site so I'm not really sure. \$\endgroup\$ Apr 30, 2021 at 4:32
  • \$\begingroup\$ Like Ender said, language-specific challenges are strongly discouraged - here, it doesn't add anything, so removing the restriction would improve the challenge by allowing a wider variety of approaches and solutions. \$\endgroup\$
    – hyper-neutrino Mod
    Apr 30, 2021 at 4:34
  • \$\begingroup\$ Also, seeing as to how this is a ascii-art challenge, you will need to either provide the exact text that needs to be outputted or a formal specification of what is considered valid output and what isn't - for example, could I just submit . and claim it's a very zoomed out logo? These will need to be clarified. Overall, I like the idea though. \$\endgroup\$
    – hyper-neutrino Mod
    Apr 30, 2021 at 4:35
  • \$\begingroup\$ I think if you require the output to be the exact example you gave it would make it much easier to determine which answers are valid. \$\endgroup\$ Apr 30, 2021 at 5:15
  • \$\begingroup\$ @RedwolfPrograms It's the best I got, but I'll make it official. \$\endgroup\$ Apr 30, 2021 at 5:20
  • \$\begingroup\$ This challenge looks pretty good now, so I've upvoted, although I'd still recommend waiting a day or two just in case anyone else has feedback on the formatting or finds something unclear. \$\endgroup\$ Apr 30, 2021 at 5:28
  • \$\begingroup\$ A tip for future challenges: Anyone (not just you) reading the challenge and an answer should be able to decide (without disagreement) if the answer is valid or not. "Resembles a logo" is very subjective in this sense, and phrases like "as close as" should be avoided too. \$\endgroup\$
    – Bubbler
    Apr 30, 2021 at 5:34
  • \$\begingroup\$ @Bubbler Is this better? \$\endgroup\$ Apr 30, 2021 at 6:10
  • \$\begingroup\$ Yeah, it's better. A question: would you allow printing trailing spaces at the end of each line, or printing a trailing newline at the end? (These are commonly allowed because they don't impact the ascii art shown and they're hard to avoid in multiple languages) \$\endgroup\$
    – Bubbler
    Apr 30, 2021 at 6:21
  • \$\begingroup\$ @Bubbler I added a list of questions that are asked in the comments. Can I add the same if I posted this on main? \$\endgroup\$ Apr 30, 2021 at 7:39
  • \$\begingroup\$ I'd recommend to edit the challenge text directly to include any clarifications. \$\endgroup\$
    – Bubbler
    Apr 30, 2021 at 7:45
  • \$\begingroup\$ @Bubbler It will do and I'm hoping that when this gets published, I gain enough reputation just to talk in chat. \$\endgroup\$ Apr 30, 2021 at 7:50
  • \$\begingroup\$ Tags-wise: [kolmogorov-complexity]. I'd suggest just removing the 2 paragraphs beneath the output, as they just make it more confusing. A simple "output this exact text, with an optional trailing newline. Lines may have optional trailing spaces. Shortest code wins" is enough (plus the output itself) \$\endgroup\$ Apr 30, 2021 at 17:35
  • \$\begingroup\$ I've edited this down to a stub now that it's been posted to save space \$\endgroup\$ May 1, 2021 at 13:46
4
\$\begingroup\$

Reveal by Halves (in need of a better name)

Inspired by this: http://nolandc.com/smalljs/mouse_reveal/ (source).

A valid answer:

  • Takes a number \$w\$ and (assumed non-negative) integer \$x\$.
  • Outputs an integer list with a length of \$2^w\$, initially filled with zeroes.
  • For each number \$n\$ from \$0\$ to \$w-1\$ (inclusive), divide the list into sub-lists of size \$2^n\$, then increment all of the values in the sub-list that contains the index \$x\$.

Examples

(with coordinates from left, 0 indexed, but your answer may have change these)

w=3, x=1
23110000

w=2, x=2
0021

w=3, x=5
00002311

w=4, x=4
1111432200000000

w=2, x=100
Do not need to handle (can do anything) because x is out of bounds

Meta questions

  • Are these tags fitting?
  • Would this be better in one dimension? (like \$3, 2\$ returns 11320000) Edit: I've changed it to one dimension but I can revert if it makes it less interesting.
  • Should \$w\$ or \$2^w\$ be the input?
  • Is this a duplicate?
\$\endgroup\$
1
  • 1
    \$\begingroup\$ My opinions on some meta questions. 1) I think one dimension would be better, the core of the challenge remains the same but the challenge itself becomes more "pure" which, in my opinion, is a good thing. 2) I'm a fan of flexible I/O, so if it were up to me I'd let people choose if they want \$w\$, \$2^w\$ or both as input. If you don't like this, both options are honestly fine. \$\endgroup\$
    – Delfad0r
    May 10, 2021 at 22:24
4
\$\begingroup\$

I'm Lazy*: Top-left align my text

posted

\$\endgroup\$
2
  • \$\begingroup\$ Definitely not too trivial for code golf \$\endgroup\$
    – qwr
    Jun 2, 2021 at 14:20
  • \$\begingroup\$ I think squash up could be its own challenge which has room for simplification. My thoughts being using a transposed grid of strings, which I guess can work for this challenge too \$\endgroup\$
    – qwr
    Jun 2, 2021 at 14:21
1
9 10
11
12 13
145

You must log in to answer this question.

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