515
\$\begingroup\$

What is the Sandbox?

This "Sandbox" is a place where Code Golf users can get feedback on prospective challenges they wish to post to the main page. 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.

To post to the Sandbox, scroll to the bottom of this page and click "Answer This Question", or click on the "Add Proposal" link below. Click "OK" when it asks if you really want to add another answer. Write your challenge just as you would when actually posting it. 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.

To add an inline tag to a proposal use shortcut link syntax with a prefix: [tag:king-of-the-hill]

See the Sandbox FAQ for more information on how to use the Sandbox.

The Sandbox works best if you sort posts by "active".

Add Proposal

Search the Sandbox

Browse your pending proposals

Get the Sandbox Viewer to view the sandbox more easily

\$\endgroup\$
0

3273 Answers 3273

1
92 93
94
95 96
110
0
\$\begingroup\$

Improved image sampling

Quoting from the ImageMagick documentation of the very simple -sample resizer, "You can think of the image as being divided into an array of regions, and one pixel from each region is selected for the resulting image". Unfortunately, it uses a bad algorithm for choosing the one pixel: it chooses the middle one.

In this challenge, you have to write a program that takes an image and a positive integer \$N\$ (\$N\$ divides the height and the width) as input and outputs the image downscaled by the factor \$N\$. In the output image, every pixel must be taken from the corresponding \$N\times N\$ square in the original image.

[image gallery and settings used]

This is tagged , so the answer with the most upvotes wins!

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

Fetch me some data

This is the fifth post for the second RGS's Golfing Showdown.

Task

Write some code to fetch the updated total number of confirmed infected cases in a territory. The territory you choose to fetch data for will influence your score, so keep that in mind.

Input

Your code takes no input.

Output

You should output an integer or any other sensible representation of it.

Rules

Fetching the data

The data you fetch must be fetched from a URI that must have been online at least since the 25th of April of 2020. You may fetch the most recent data or the data for a specific date, as long as in that date, your territory has a non-zero number of total confirmed cases.

Scoring and Territory

The territory you fetch data for must be a territory listed in the WHO daily situation reports and the numbers you fetch for a given date must be within 10% of the WHO numbers for the same date.

Your score will be the number of bytes minus the length of the longest common substring between your code and the territory you pick, case insensitive.

E.g. If my program is abcdefghijklmno and my territory is Italy I get to shave 2 bytes of my score because of the common substring il (or al).

Sandbox

Are the rules clear enough and well-specified enough?

\$\endgroup\$
3
  • \$\begingroup\$ I understand now, I think. I read "The territory you choose to fetch data for will influence your score, so keep that in mind." and assumed that you meant that the size of the data we fetch will be part of our score. You should probably make it explicit that the size of any file fetched won't be part of our score if that's what you intend. \$\endgroup\$ – S.S. Anne Apr 29 '20 at 19:16
  • \$\begingroup\$ "Your score will be the number of bytes minus the length of the longest common substring between your code and the territory you pick, case insensitive." Are you trying to do this so, say, wget Italy will be the same size as wget UnitedStates? I think instead you should make it a requirement that the name of your territory is included in your program, and then remove the number of bytes in your territory name. \$\endgroup\$ – S.S. Anne Apr 29 '20 at 19:17
  • \$\begingroup\$ The number of confirmed cases in China has almost stopped increasing. Can we assume it won't increase by 10% and thus create an offline solution? \$\endgroup\$ – the default. Apr 30 '20 at 0:41
0
\$\begingroup\$

Posted

\$\endgroup\$
8
  • \$\begingroup\$ Can we require inputs to be padded for us? \$\endgroup\$ – user92069 Apr 17 '20 at 8:14
  • \$\begingroup\$ Can we output via a digit array? \$\endgroup\$ – user92069 Apr 17 '20 at 8:14
  • \$\begingroup\$ What do you mean by output via a digit array? Like [2,4] instead of 24? \$\endgroup\$ – Command Master Apr 17 '20 at 8:36
  • \$\begingroup\$ What do you mean by Are you sure you mean base 19, not base 10?? In base 10 16 isn't a digit, and [1, 16] isn't a number \$\endgroup\$ – Command Master Apr 17 '20 at 8:38
  • 2
    \$\begingroup\$ Why base 19? That seems pretty arbitrary \$\endgroup\$ – xnor Apr 17 '20 at 8:40
  • 1
    \$\begingroup\$ It's the smallest base for which the sum of any two digits in base 10 fit in \$\endgroup\$ – Command Master Apr 17 '20 at 8:41
  • 1
    \$\begingroup\$ Looks like a cool challenge :) I think a few more test cases would be useful. Some slightly larger test cases would also be great \$\endgroup\$ – math junkie Apr 26 '20 at 19:46
  • \$\begingroup\$ I doubt that there is any approach other than "take the decimal digits, sum the digits as vectors and convert from base 19" here. \$\endgroup\$ – the default. May 1 '20 at 2:43
0
\$\begingroup\$

This is my first question, so I don't know what exactly I should ask, but I will try. Please advise.


Russian roulette

It's Russian roulette! The rules are simple. Shoot a revolver with n slots for bullets and one round inside at your head and you might not die!

Task:

Make a program that takes integer n (you can assume that 10<=n<=128) as input and outputs nothing.

but how do I tell if I'm dead?

The program generates a random number x in the range 0 - (n) inclusive. If x=n the revolver fires and the program exits with an error (you die). Otherwise the program exits normally.

Standard loopholes forbidden, etc.


Sandbox questions:

  • This question is short. What can I explain better or add?
  • What are good tags to add?
  • Should I make it code-golf or popularity contest? Both?
  • Too easy?
  • This is a joke, will it be misinterpreted?
\$\endgroup\$
11
  • \$\begingroup\$ So do we choose our own value for n, or is there some value you want us to use. \$\endgroup\$ – lyxal May 2 '20 at 3:00
  • \$\begingroup\$ I think this challenge is extremely similar to this one: Make your code error but only sometimes \$\endgroup\$ – math junkie May 2 '20 at 3:20
  • \$\begingroup\$ @mathjunkie I saw that, but this question is more specific for how it should function. \$\endgroup\$ – Wezl May 2 '20 at 18:10
  • \$\begingroup\$ @Lyxal Originally I thought I'd let the answerers choose, but to make the question different from Make your code error but only sometimes I'll revise the question to take n from the player. \$\endgroup\$ – Wezl May 2 '20 at 18:12
  • \$\begingroup\$ is that 0-n or 1-n inclusive, exclusive, or half-open? Also, some languages give error messages when they exit with failure. \$\endgroup\$ – S.S. Anne May 2 '20 at 18:24
  • \$\begingroup\$ @S.S.Anne I meant to say you can choose. Fixing. \$\endgroup\$ – Wezl May 2 '20 at 18:27
  • \$\begingroup\$ I don't think allowing to choose is a good idea. If anything, I would prefer 0-(n-1), as that is the most common and easiest to work with. \$\endgroup\$ – S.S. Anne May 2 '20 at 18:33
  • 1
    \$\begingroup\$ I suggest tagging it code-golf instead of popularity-contest because popcons are netoriously difficult to do right. \$\endgroup\$ – lyxal May 3 '20 at 1:14
  • 3
    \$\begingroup\$ Pseudocode of (likely) most answers you will get: 1/(rand()%n); \$\endgroup\$ – the default. May 3 '20 at 3:33
  • \$\begingroup\$ @lyxal but maybe I should make it popularity-contest and encourage people to vote for ones that do not follow 1/(rand()%n)? \$\endgroup\$ – Wezl May 4 '20 at 13:55
  • \$\begingroup\$ posted \$\endgroup\$ – Wezl May 4 '20 at 15:29
0
\$\begingroup\$

Revisit sum


Why is this language specific?

As much as much as I like challenges to be language agnostic if this challenge were language agnostic it would most certainly be a duplicate of the add two numbers challenge due to our current duplicate policy. And for most languages adding two numbers and adding several numbers are no different. Revisit is not one of those languages.


In Revisit adding two numbers is easy.

+@

does the trick. However in this challenge we are going to ask you to do something much more difficult. Take a an arbitrary number of positive integers as input and output the sum of all them.

Your answer should be functioning revisit as per revisit version 0.1.

This is so answers are scored in bytes with fewer bytes being better.

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

Compass and straightedge segment reduction

You are given two points at distance 1, a compass and a straightedge. The challenge is, given a positive integer \$N\$, to find the shortest segment possible to obtain by drawing no more than \$N\$ lines or circles. A segment is defined as a pair of two points such that there is a line connecting them.

This is tagged , so the shortest answer wins!

Sandbox stuff

  • Certain details of compass-and-straightedge constructions are not specified yet.

  • Should I allow assuming normal floating point math to be exact, or to require proper arbitrary precision?

  • Is the answer trivial? I know that you can, for example, obtain geometric progressions with factor that seems to be \$\tan(x)\$ (and thus perhaps it's optimal to first bisect an angle for a while, then subtract it from a straight angle, and then do this).

More importantly, is this possible? I assume it is, because it seems possible to calculate everything necessary for the basic constructions:

  • It's (easily) possible to compare lines and circles for equality
  • It's possible to calculate the parameters of a line passing through 2 points.
  • It's possible to calculate the parameters of a circle - that is, find the point and the radius given the point and the radius.
  • It's possible to calculate the point of intersection between 2 lines (if it exists).
  • It's possible to calculate the points of intersection between a line and a circle.
  • It's possible to calculate the points of intersection between 2 circles.

Is that enough for a proof?

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

Continue an arithmetic-geometric progression

note: not related to these arithmetic-geometric sequences
An arithmetic progression has the property that \$a_n = \frac{a_{n-1} + a_{n+1}}2\$ - that is, every term is the arithmetic mean of its neighbours.
A geometric progression has a similar property: \$a_n = \root\of{a_{n-1}\cdot a_{n+1}}\$ - every term is the geometric mean of its neighbours.

There's also the arithmetic-geometric mean \$AGM(x, y)\$! It's defined as follows: define two sequences as \$a_0 = x, g_0 = y, a_{n+1} = \frac{a_n+g_n}2, g_{n+1}=\root\of{a_n g_n}\$. The sequences converge to the same number, the arithmetic-geometric mean of \$x\$ and \$y\$.

Now I can define another progression: an arithmetic-geometric progression has the property that \$a_n = AGM(a_{n-1}, a_{n+1})\$.

As input you are given two real numbers - the first two terms of an arithmetic-geometric progression. The challenge is to find the third one with absolute or relative error not exceeding \$10^{-5}\$ (and output it).

This is tagged , so the shortest answer wins!

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

Emulate a Schmitt trigger

Given low and high cutoff points, and a list of input readings, generate a list of output states at those points.

  • If an input reading is greater than the high cutoff point then the output is always in the high cutoff state.
  • If an input reading is lower than the low cutoff point then the output is always in the low cutoff state.
  • At least one of the above comparisons must be a strict inequality. (Please make both comparisons strict unless this would consume additional bytes.)
  • If the initial reading is between the two cutoff points the the output must be deterministic (i.e. the same for each run with the same inputs).
  • In all other cases the output remains in the same state.
  • It is valid for both cutoff points to be the same value.
  • The input readings may be taken in any convenient format, but it must be capable of handling at least 94 different values.
  • The output for each input reading must be one of two distinct values.

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

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

Subtract a list

You are given a list of boolean values as input. You have to find its difference.

The difference of a list of one value is equal to the value itself. The difference of a list with \$N\$ values is defined as $$(\text{the difference of the first }\lfloor\frac{N}2\rfloor\text{ items}) - (\text{the difference of the last }\lceil\frac{N}2\rceil\text{ items})$$

This is tagged , so the shortest answer wins!

[todo: examples]

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

Analyze the flow

Posted

\$\endgroup\$
3
  • \$\begingroup\$ From the example, it looks like the path can wrap around the edges of the grid. I think you should mention that explicitly. I also think you should define "tributary" \$\endgroup\$ – math junkie May 11 '20 at 21:27
  • \$\begingroup\$ Yes, you can wrap around and this is the only reason why I use a toroidal grid. I've added the definition of "tributary"... I know it's still informal but I don't want to lose readability, I've tried to go more formal but the need of a lot of definitions arises. Is it still unclear? \$\endgroup\$ – Domenico Modica May 12 '20 at 0:36
  • \$\begingroup\$ @math junkie anyway thanks for the grammar corrections, also in the main post :D \$\endgroup\$ – Domenico Modica May 13 '20 at 19:42
0
\$\begingroup\$

There are \$a\$ honest man(always tell the truth), \$b\$ dishonest man(always tell lie), and \$c\$ random man(tell random Y/N). How many times at least should you ask one of them a yes/no question to guarantee you get knowledge of who they are? You may assume that it's possible.

Test cases:

(a,b,c) -> ans
(1,1,0) -> 1
(1,1,1) -> 3
(0,0,2) -> 0

Notes:

  • I don't know if there's clever way, but anyway brute-force work
  • It's enough if you can only ask an expression about who they are. If you ask them "what will A answer if I ask B" the answer is just "(A is liar) xor B". "Did A tell lie when answering B" is just "(A's answer) xor B". Questions about the current ask or future ask may lead to paradox and are not allowed.
  • Actually it's possible to identify them iff there are less than half of random answerer, or an edge case that all are random answerers. Only considering honest and random, if there are more honest than random, ask them same question and do a majority vote gets answer to the question. If there are same honest and random, and random tell as if they are honest and real honest are random, you can't tell the difference.
\$\endgroup\$
6
  • \$\begingroup\$ I think the wording is a little confusing. Will there always be one of each? Will your program be given a list of a, b, and cs as input? Also, you may want to look at this question to check if it's similar to yours. \$\endgroup\$ – Redwolf Programs May 14 '20 at 21:23
  • 1
    \$\begingroup\$ @RedwolfPrograms Yes a,b,c are given, and possibly zero. Link don't match this problem well \$\endgroup\$ – l4m2 May 15 '20 at 2:48
  • \$\begingroup\$ Wouldn't it require at least 4 questions for the test case (1, 1, 1)? How to solve in 3? \$\endgroup\$ – user202729 May 16 '20 at 3:46
  • \$\begingroup\$ @user202729 brainden.com/forum/topic/… (not wiki answer as it assume answer from random is either true or false) \$\endgroup\$ – l4m2 May 16 '20 at 3:47
  • \$\begingroup\$ Oh wiki also has a standard solution \$\endgroup\$ – l4m2 May 16 '20 at 3:53
  • 1
    \$\begingroup\$ @RedwolfPrograms Formal description (according to my understanding of the statement) \$\endgroup\$ – user202729 May 16 '20 at 4:48
0
\$\begingroup\$

The game of scrabble is played by placing lettered tiles on a grid to form words. The words being formed must read from left to right, or up to down on the grid. The words must appear in the official Scrabble dictionary, and all letters placed on the grid must be part of a valid word. This challenge will focus on a specific technique for playing a simplified version of Scrabble.

A useful technique when playing Scrabble is to add a single letter to an existing word that is already on the board to form a new word. Write a program or function that, when given a dictionary, finds the longest series of words that can be formed by adding a single letter to another word to form a new word.

Example

You are given the following dictionary:

at
ate
rate
elate
crate
belate
belated

Your submission should output:

['at', 'ate', 'rate', 'crate']

An invalid output would be:

['at', 'ate', 'elate', 'belate', 'belated']

because 'elate' cannot be formed by adding a single letter to 'ate'.

Note that this challenge is not about finding the longest word that can be formed by adding a single letter to another word, but about finding the longest chain of words that can be formed in such a way. Which means that this answer:

['elate', 'belate', 'belated']

is wrong, because it only has three steps, whereas the first example has four.

Winning Criteria

Code-golf, so shortest code wins. I/O is flexible. Standard loopholes apply. Take dictionary as a list, file, delimited string, or whatever you want. Output can be sent to stdout, returned as a single string (with delimiter), or list of strings.

Test Cases

TODO

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

Uniform necklace sampling

The challenge is, given a number \$N\$, to produce a random binary necklace of length \$N\$. All possible necklaces must have the same probability of being chosen.

[TODO: more about necklaces]

Scoring

Solutions are compared first by asymptotic memory complexity in \$N\$ (lower is better), and, in case of a tie, by size (lower is better).

Sandbox stuff

(I do intend to use code-golf as only a tiebreaker)

  • How to tag this question the most correctly?
\$\endgroup\$
2
  • \$\begingroup\$ Not time complexity? It's trivial to do this in O(n) memory (I think that is optimal, because (as far as I know) it's not possible to (deterministically) check if a string is a necklace in less memory) by iterating over all necklaces, count number of those = C (C can be represented in N bits), generate a random number x in the range 1..C, then count again and pick the xth necklace. \$\endgroup\$ – user202729 May 27 '20 at 4:10
  • \$\begingroup\$ @user202729 I tried to pick a combinatorial object that prevents a linear-memory solution (any suggestions?). I guess these answers should win (with [code-golf] used to compare them - this is mostly [restricted-memory] code-golf, but submissions that aren't good enough aren't disqualified). \$\endgroup\$ – the default. May 27 '20 at 6:44
0
\$\begingroup\$

Posted: SELECT ALL FROM SelectQL WHERE (answer="short" OR NOT length=10000)

\$\endgroup\$
5
  • \$\begingroup\$ What happens if the specified table doesn't exist? \$\endgroup\$ – lyxal May 15 '20 at 4:37
  • \$\begingroup\$ The usual SQL statement is SELECT * FROM data, where * is the wildcard operator. Also, the set of parentheses after "WHERE" is not mandatory in usual SQL. I guess these changes make the challenge easier to parse. \$\endgroup\$ – user92069 May 15 '20 at 4:56
  • \$\begingroup\$ @Λ̸̸ Yeah, it's to make it slightly easier. However, I could change it. Which I will! \$\endgroup\$ – bigyihsuan May 15 '20 at 23:54
  • \$\begingroup\$ @Lyxal undefined, the programs should assume that the table is in the database \$\endgroup\$ – bigyihsuan May 15 '20 at 23:55
  • 3
    \$\begingroup\$ Consider deleting this post, as the challenge is already on main \$\endgroup\$ – RGS May 20 '20 at 16:50
0
\$\begingroup\$

Solve some diplomatic issues

You are given a set of moves in a theoretical Diplomacy game. We're not going to handle validation of moves being legal or not, simply attempt to resolve a turn.

Here are the simplified rules to Diplomacy (full rules here):

  • There are two types of units: Armies and Fleets. Armies can only move on land, Fleets on land and in the sea. You can safely ignore this, because we're assuming that all of the moves you've been given are at least theoretically valid.
  • There are four types of moves: Hold (stay in place), Move, Support (a certain other unit), Convoy.
  • When two or more units end up in the same country, whichever unit has the most support stays. Each unit without the most support (or each unit tied for the most) returns to its original country. A unit which is not Moving and which is not tied for the most support is Dislodged.
  • A Fleet can Convoy an Army through its space to another space. That convoy is cancelled if the Fleet is Dislodged. Only a Fleet in a sea space can Convoy.
  • A unit can support another unit holding or moving into an adjacent country if it can move into that country (Armies can't Support Fleets in the sea).
  • A supporting unit which is attacked ceases to support, unless it is supporting an attack on the unit attacking it. If it is dislodged, it ceases to support in any case.
  • The Beleaguered Garrison rule: If a unit is attacked by two units with the same amount of support, the attacked unit is not Dislodged, and the attackers return to their original countries.

You will receive a list of moves. Each move will be in the following format:

Power Unit_type Origin_country Move_type Destination_country

There is no Destination_country if a unit holds (or you can insert a placeholder). Destination_country for Support or Convoy is the Origin_country of the unit being Supported or Convoyed. For example, you could get:

E F Eng M Pic
F A Pic H
G A Bel S Eng

This means:

English Fleet in the English Channel Moves to Picardy
French Army in Picardy Holds
German Army in Belgium Supports the Fleet in the English Channel to Move to Picardy

Your output should be the location of each unit after the move. Any Dislodged unit should be marked as such.

Output format:

Power Unit_type Country Dislodged?

For the example given above, the output should be:

E F Pic
F A Pic D
G A Bel

The more difficult part of this is in regards to convoys. A convoy fails if there is no valid path for the army to take. For instance, if we have:

E F Nth C Den
E A Den M Hol
F F Eng M Nth
F F Bel S Eng

The French fleets dislodge the English Fleet in the North Sea, and the convoy does not take place. But if we also had

E F Hel C Den

There would still be a valid path for the English Army and the convoy would succeed.

Paradoxes

Be warned, there are paradoxes in Diplomacy. These are to be treated as undefined behaviour; any output is acceptable where

  1. Each unit is listed
  2. There is only one non-dislodged unit per country
  3. In any country with a dislodged unit there is a non-dislodged unit
  4. Each non-moving unit is listed in its origin country
  5. Each moving unit is listed either in its origin country or its destination country

Note that, in particular, each unit being in its starting country is a valid output.

Adjacency list

For use with convoys, it's helpful to know which countries are adjacent to which other countries. (Everything is assumed to be valid, but it may not be clear whether a convoy with a single cut link is still possible otherwise).

You may assume that this list is available to you in any format: a function that takes two countries and returns true/false, a variable, a file, etc. In any case, the list itself does not add to your byte count.

[To be added]

Input/Output Formats

You can use any Input/Output formats you choose, as is standard.

Questions for the sandbox

  • How much clearer does my description of the rules of Diplomacy need to be?
  • Does this sound like an interesting challenge?

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

Enforce Social Distancing!

Related to Maintain Social Distancing!.

As in that challenge, there is a 2-dimensional array of 1s and 0s representing people. In it, social distancing is maintained if and only if all 1s are at least 6 squares apart, where distance metric used is \$|\Delta x| + |\Delta y|\$ (rectilinear or Manhattan).

The challenge here is to move some people in a given 2D array so that social distancing is maintained. It's guaranteed that it's possible to do so. Your program's score on a given input is the total distance moved by all people.

Your program's running time must not exceed 10 seconds on any of the test cases.

This is tagged , so there is a large set of inputs your programs will be tested on [TODO: actually create it]. The program with the lowest total score on all of these inputs wins.

Sandbox stuff

  • Is this currently a bad idea for the reasons specified by Shaggy in the following comment?

    I am sorry but I have downvoted this for what others may perceive to be a trivial reason: Code Golf is one of the few things I have left where I can escape how fucked my world has become; I absolutely do not want to come here to be reminded that I can't hug my family and friends.

  • Is there an optimal algorithm? (I hope not)
\$\endgroup\$
0
\$\begingroup\$

Shorten the numbers

These numbers are taking up far too many bytes on my computer. Create a function/program to shorten any number using only Alphanumeric characters as the output.

Scoring

Scoring is based on optimized-output. Shortest number of characters produced for the following randomly generated numbers (plus one special number with repetition) wins. Add the number of output characters output for the 5 test numbers together for total score.

  • 94949267912781
  • 75477115147709
  • 79547324913976
  • 12345678998765
  • 11111122222222

The score of the non-optimized numbers = 70. (14 * 5)

Sandbox questions

  • does scoring make sense?
  • should I include a sample script, output, or both?
  • should I be more clear the answers should work on any number? (ie. "replacing each test number with one character is disallowed")?
\$\endgroup\$
2
  • 2
    \$\begingroup\$ Base conversion from base 10 to base-255? \$\endgroup\$ – user92069 May 23 '20 at 8:29
  • 2
    \$\begingroup\$ As long as you're scoring on those five test numbers, the winning score is going to be the absolute smallest thing you haven't explicitly forbidden. Not allowing solutions to be tailored to those five is what we'd call a non-observable requirement, and considering how many different ways it could be approached I'm not sure how well a human could even really try to judge it. On the other hand, if you try to score it over the natural numbers, we just do base conversion. I feel like this can't work as an output optimization challenge. \$\endgroup\$ – Unrelated String May 23 '20 at 10:07
0
\$\begingroup\$

Posted.

\$\endgroup\$
5
  • \$\begingroup\$ Are the prompts mandatory, should they be in that format? (or maybe all the input should be on one line like ?> [line]:[content] \$\endgroup\$ – Wezl May 21 '20 at 18:49
  • \$\begingroup\$ This seems like an interesting challenge, but I think some details are missing. For starters, you should provide a full list of commands that our program must support, as well as a few more examples \$\endgroup\$ – math junkie May 21 '20 at 18:56
  • \$\begingroup\$ @mathjunkie What do you think now? \$\endgroup\$ – nope May 21 '20 at 22:30
  • \$\begingroup\$ Looks better. However, Bonuses in Code Golf is high on the list of "Things to avoid when writing challenges". I would recommend either including those bonus tasks as part of the main challenge or removing them completely \$\endgroup\$ – math junkie May 21 '20 at 22:36
  • \$\begingroup\$ Ahh, good ol' edlin. \$\endgroup\$ – user92069 May 22 '20 at 8:29
0
\$\begingroup\$

Match the entire lyrics of All-Star

The challenge is simple: create a program/function that, when given a string consisting of the entire lyrics to All-Star as they appear in this paste (or not), output whether or not they are, in fact, the entire lyrics. The given string may be off by one of two characters, or something completely different, like Moby Dick (approximately). Output may consist of any of two values that map to true and false. They could be 0 and 1, or t and f, or whatever you like so long as there are two distinct values. You can choose to print the output or return it (if you are a program or a function). This is , so shortest answer in bytes wins!

\$\endgroup\$
1
  • 2
    \$\begingroup\$ If the input string can be anything, is there anything one could do other than to compress the correct text and compare to it? If so, that would just be a generic compression challenge. One could check some cryptographic hash of the input, but there will exist collisions even if they are not practical to find. \$\endgroup\$ – xnor May 24 '20 at 3:44
0
\$\begingroup\$

Golf me a Bookmarklet Quine

Given a javascript program (or any utf-8 text) of arbitrary length, output it in my simplified version of URI form, like a bookmarklet. You can use https://mrcoles.com/bookmarklet/ as reference. Output should be in the form

javascript:[input with percent-encoding for special characters]

Special characters are any character that is not

  • Alphabetic (upper or lower)
  • a digit
  • the characters .,-,_, or ~ (period, hyphen, underscore, tilde)

Your program "should convert all other characters to bytes according to UTF-8, and then percent-encode those values"w

A percent-encoding mechanism is used to represent a data octet in a component when that octet's corresponding character is outside the allowed set or is being used as a delimiter of, or within, the component. A percent-encoded octet is encoded as a character triplet, consisting of the percent character "%" followed by the two hexadecimal digits representing that octet's numeric value. For example, "%20" is the percent-encoding for the binary octet "00100000" (ABNF: %x20), which in US-ASCII corresponds to the space character (SP). source

Lowercase hex is okay, but uppercase is preferred.

This is code golf, standard loopholes are prohibited, programs should handle input up to 20 lines and output in a single line.

The Twist (so it's not a duplicate)

If run with no input or just a newline (your choice), the program should output itself in the same format as if the program's source was inputted normally.

Examples

In                                              Out

[blank]                                         javascript:[the%20program%27s%20source]
g/re/p                                          javascript:g%2Fre%2Fp
https://www.youtube.com/watch?v=dQw4w9WgXcQ     javascript:https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DdQw4w9WgXcQ
alert("test!")                                  javascript:%7Balert(%22test!%22)


sandbox questions

  • What should I add?
  • What tags does this need?
  • Are my examples inconsistent?
  • What parts of the challenge are redundant?
\$\endgroup\$
0
\$\begingroup\$

Comment: might be too similar to previous mutual quine challenge?

Collaboration/quasi-quine challenge

Write a valid submission (A) which prints the code for another competitor's valid submission (B). The languages used in A and B must be different.

Clarifying rules

If B prints the code for a third submission, C, it is not required that A and C be different languages. Similarly, the authors of A and B must be different, but A and C need not be. (More different languages/authors score higher, however.)

The shortest chain is for A to print B and B to print A.

Note that if A prints B, and B prints C, but C is not valid for some reason, then neither A nor B are valid either.

It is acknowledged that the validity of your submission may change over time, due to factors beyond your control. Try not to let this worry you too much. :)

Input

None

Output

Just the code described above. Nothing extraneous.

Scoring

Scoring is (A + L) * 100 + C where:

  • A is the number of distinct authors that directly or indirect print your solution. So if you are Q, and Z=>X=>Q=>X, your "A" is 2. (Each submission only has one author, the "answerer".)
  • L is the number of distinct languages in your quine circle, along the same lines as for authors. (Each submission only has one language. "Distinct" means really different, not just different versions or implementations of the same languages.)
  • C is the length of your solution in bytes.

(So, for a given circle of quines, all the submissions will have similar scores, with the length of the submission as tie-break.)

Standard loopholes are forbidden.

\$\endgroup\$
6
  • \$\begingroup\$ I like it when your score improves if you use more languages. Any reason why you didn't include that? \$\endgroup\$ – Wezl Apr 30 '20 at 21:51
  • \$\begingroup\$ Oh, what would an example of that be? I did consider something like having your score improve, the longer the chain is. Like, your score is the sum of the length of all the submissions divideded by the square of the number of participants or something. \$\endgroup\$ – Steve Bennett May 1 '20 at 2:09
  • \$\begingroup\$ That would be nice, but I wouldn't know how to balance it well. Just a thought. \$\endgroup\$ – Wezl May 1 '20 at 17:46
  • 2
    \$\begingroup\$ This seems to me like a chicken-and-egg situation. How could the first posted answer be valid if there are no B answers to print the code for? \$\endgroup\$ – math junkie May 25 '20 at 15:35
  • 1
    \$\begingroup\$ This is another similar challenge. It had several problems that I think might occur again with your current setup. I'd recommend giving the criticism and answers there a read over. \$\endgroup\$ – FryAmTheEggman May 25 '20 at 20:45
  • \$\begingroup\$ @mathjunkie It wouldn't. I don't think that's inherently problematic, it's just an interesting bootstrapping challenge. \$\endgroup\$ – Steve Bennett May 26 '20 at 1:00
0
\$\begingroup\$

Price this word

So, I'm going shopping in the Word Market™. There are shelves of words which I can buy around me, but I only have one dollar bills and the change machines at the market are broken. To add to the problem, there are words with... non-word characters in them. That's no good, I can't buy those... can you help me figure out which words I can buy and which I can't?

Task

So, I can only buy words that consist of only alphabetical characters and are worth a dollar. To determine a word's value, you have to sum the letters in the word where A = 1¢, B = 2¢... to Z = 26¢. I'm too lazy to look at the output and judge whether it is equal to one dollar (100 cents), so you'll need to return a specific value for words equal to a dollar (...or 100 cents) and a specific value for not equal to a dollar (I'm going to stop including this).

I'll also offer a bonus byte reduction: if your code returns whether the word is less than a dollar, equal to a dollar, greater than a dollar, or invalid (e.g. <, =, >, x), your score will be multiplied by 3/4.

SANDBOX NOTE: Is this a balanced bonus value?

Examples

Word          Non-bonus value     Bonus value

a                  false               <
b                  false               <
printera           false               >
$word              false               x
printer            true                =

And here's a JavaScript snippet you can use if you want to check for non-bonus validity:

(it's also 52 bytes; you can use it by calling f())

f=s=>([...s].map(x=>a+=parseInt(x,36)-9),a==100),a=0

Anyways, standard loopholes apply, shortest answer in bytes wins (but I'll add shortest answers for esoteric and functional languages)... you get the idea.

\$\endgroup\$
6
  • 1
    \$\begingroup\$ In general, bonuses in code golf are seen as something to avoid \$\endgroup\$ – math junkie May 28 '20 at 2:45
  • \$\begingroup\$ Standard Loopholes \$\endgroup\$ – math junkie May 28 '20 at 2:46
  • 2
    \$\begingroup\$ This challenge doesn't seem interesting to me. We've already have plenty of challenges about summing up characters in a string, and having to determine whether a string contains non-word characters just seem like tacked on challenge that makes the whole thing more cumbersome. \$\endgroup\$ – Surculose Sputum May 28 '20 at 15:40
  • 2
    \$\begingroup\$ What's a bit ironic about this is that after you posted this you went on to write a program that went through words in the English language and summed up their values depending on what character they were, sharpness of a word \$\endgroup\$ – Ethan Slota May 28 '20 at 20:53
  • \$\begingroup\$ Never say I like the sharpness challenge either. :P But I do think that that challenge is a bit more interesting, due to the somewhat arbitrary mapping of letter to values. Yours just straight up uses the vanilla alphabetical order. \$\endgroup\$ – Surculose Sputum May 29 '20 at 14:53
  • \$\begingroup\$ You do have a point; in Jelly or 05AB1E there's probably a builtin that would sum up a string based on values like I want people to do. \$\endgroup\$ – Ethan Slota May 29 '20 at 21:50
0
\$\begingroup\$

Magic card trick: Hide information by flipping cards

(This is inspired by a series of questions on puzzles.stackexchange.com: 10, 8, 7)

Fix two integers m and u. Your task is to perform the following magic trick:

  • A Magician brings a pack of m distinct cards, and leaves the room.

  • In their absence, a volunteer from the audience shuffles the deck and arranges all cards in a line, in any order they want.

  • Still in the absence of the magician, their assistant flips u cards. On the table are the n cards, still in the order chosen by the volunteers, but u are face down, leaving only mu cards face up.

  • The magician returns, and from the order of the cards alone, knows each card.

Input:

m - number of cards.

u - number of cards to flip face down.

  • You may assume 0 < u < m.

Output, if the trick is possible for m and u:

f - an mapping assigning to each sequence the order the assistant will create by flipping cards.

  • If the trick is to work, this mapping must be bijective.
  • Use the integers 1...m (or 0...m−1), or single letters as card values.
  • Use any meaningful way to express f: a hash maps, a table, a function.
  • Use a fixed placeholder for any face-down cards.

Output, if the trick is impossible for given values of m and u

This case should be indicated in a meaningful way.

Example output (m=3, u=1):

Using the digits 0, 1, and 2 as cards, and _ for their flipside:

012 01_
021 0_1
102 _02
120 12_
201 2_1
210 _10

(For these values of m and u, this isn't very impressive as a magic trick, of course.)

Example output (m=4, u=2):

Using 1, 2, 3, and 4 for the cards and 0 for their flipside, and a JSON representation:

{"1234":"0034","1243":"0043","1324":"0024","1342":"0042","1423":"0023","1432":"0032",
"2134":"0104","2143":"0103","2314":"0014","2341":"0041","2413":"0013","2431":"0031",
"3124":"0120","3142":"0102","3214":"0204","3241":"0201","3412":"0012","3421":"0021",
"4123":"4003","4132":"0130","4213":"0203","4231":"0230","4312":"0302","4321":"0301"}

This is correct because as required, the keys are all permutations of 1234, each value has two cards face-down and the other cards match the original sequence, and each value appears only once.

Scoring

This is code-golf. Shortest solution wins.

\$\endgroup\$
4
  • \$\begingroup\$ I think I should not allow all that input/output flexibility and require some fixed format. For example: input is u and a string whose (unique) characters are the decks. Require _ as placeholder. Require a fixed table format. \$\endgroup\$ – retzler May 29 '20 at 4:27
  • 1
    \$\begingroup\$ There were some clarity issues I had while reading this, but as is I think this has a much bigger problem. It seems very likely to me that outputs for large m will be prohibitively difficult to verify, given the complexity of the proofs from the related puzzling challenges. There are many ways you could approach this, like upper bounding m, making this a test-battery, or making a code-challenge where the goal is to find the maximum u for the highest m. There are probably other ways to handle this, so these are just some starting ideas. Thanks for using the sandbox! \$\endgroup\$ – FryAmTheEggman May 29 '20 at 19:23
  • \$\begingroup\$ Thank you for the valuable feedback @FryAmTheEggman. The proofs from the linked puzzles are long because they're reasoning & looking for insight. To just verify the list, two steps are sufficient: verify that f*(*x) is obtained from x by replacing u symbols with _, and that f is a bijection and defined for all permutations. Non-golfed solution including full tests . The output will still be huge, no chance of cursory manual verification. I didn't know about alternatives to code-golf, actually! I'll be looking into these. \$\endgroup\$ – retzler May 29 '20 at 21:44
  • \$\begingroup\$ No problem! I do want to clarify though - I was aware of the ability to prove by exhaustion when I posted my first comment. However, I did base my assessment of it being a true problem around you not wanting a completely naive brute force search through each strategy, which I see now wasn't correct, so if you are fine with that then there isn't really a problem. But of course, if you want anything besides those solutions I'd recommend looking into what I suggested, or asking in our chat room for other people's points of view. \$\endgroup\$ – FryAmTheEggman May 29 '20 at 22:43
0
\$\begingroup\$

_

\$\endgroup\$
5
  • \$\begingroup\$ What kind of numbers can be in the sequence? \$\endgroup\$ – xnor May 22 '20 at 10:30
  • \$\begingroup\$ @xnor Integers, basically. \$\endgroup\$ – user92069 May 22 '20 at 10:35
  • \$\begingroup\$ Would the test cases that time out, 1,2 and 7,4, be excluded by "the input will always be provided in a way such that it won't take forever to zero the accumulator"? No product of exclusively odd numbers can end up being divisible by a power of 2. \$\endgroup\$ – Unrelated String May 23 '20 at 9:35
  • 1
    \$\begingroup\$ @UnrelatedString Thanks for nothing that; I've removed these test cases. \$\endgroup\$ – user92069 May 23 '20 at 9:46
  • 2
    \$\begingroup\$ Now this post is zeroed eventually \$\endgroup\$ – l4m2 Jun 5 '20 at 1:36
0
\$\begingroup\$

Mobile games money representation

In many mobile clicker games where the player is usually required to tap on the screen to make money (in order to buy upgrades for you to generate money faster), it gets to a point in the game that the money made per second is so big that if represented in its "normal" form, it would clutter the mobile screen. Imagine showing the user that they are making \$1,000,000,000,000,000,000,000,000\$ per second in a small mobile phone screen!

From my experience as a regular player of these type of games, I have noticed that most of them represent bigger numbers by using letters. If the number of money per second is a number less than \$10,000,000\$ then print the number as is. Otherwise, if the number is in the millions (but \$ \geq 10,000,000\$), for example \$ 102,000,000\$ it should print \$102M\$. If it is in the billions, it should print \$102B\$. You should use \$T\$ for trillion and \$Q\$ for quadrillion.

As you can notice, the next would be quintillion which would also use the letter \$Q\$ if followed the pattern. Instead of following this pattern which can be confusing at one point, game developers usually start a new pattern: Quintillion is used with the suffix \$AA\$, sextillion is \$AB\$, septillion is \$AC\$ and so on.

Notice that this pattern would go until \$AZ\$ and if the player is making more money than that, it would start from \$BA\$, \$BB\$, ..., \$BZ\$, ...,\$ZA\$, \$ZB\$, ... , \$ZZ\$ which for our problem we will assume is the limit one player can make per second.

Task

Given an integer \$x\$ where \$0 \lt x \leq 999\$ and a natural number \$y\$ where \$y \gt 0\$ representing the number of zeroes the number has, output the number in a "mobile game money representation" as described above.

Observations

  • The number of zeroes that \$y\$ represent does not include the possible zeroes \$x\$ might have! Example: if \$x = 100\$ and \$y = 6\$, you should output \$100M\$ and not \$1,000,000\$

Test Cases (x, y --> game money representation)

100,  6 --> 100M
100,  5 --> 10M 
100,  4 --> 1000000
1,   12 --> 1T
10,  12 --> 10T
100, 12 --> 100T
1,   18 --> 1AA
10,  18 --> 10AA
100, 18 --> 100AA
# To be added...

Meta questions

  1. Is this a duplicate? I have looked around but didn't find anything similar.
  2. Is the wording confusing? I'm open to recommendations!
  3. I haven't written a program yet so the test cases might be wrong (I'll add more later).
  4. Pretty much any feedback is appreciated!
\$\endgroup\$
5
  • 2
    \$\begingroup\$ Looks like it needs some test cases with decimal points, e.g. 123, 17 -> 12.3AA. \$\endgroup\$ – Bubbler Jun 1 '20 at 0:20
  • \$\begingroup\$ Shouldn't 100, 4 become 1M? \$\endgroup\$ – Surculose Sputum Jun 1 '20 at 13:03
  • \$\begingroup\$ @SurculoseSputum In these games, when the number is small enough (as I said in the second paragraph), if the number is less than 10 million, then it is printed in its "normal" form. The abreviations starts after 10 million. \$\endgroup\$ – ihavenoidea Jun 1 '20 at 19:33
  • \$\begingroup\$ Suggest cases where \$y\$ don't just go the AA \$\endgroup\$ – l4m2 Jun 19 '20 at 4:24
  • \$\begingroup\$ Thanks all, I'm pretty busy lately unfortunately. Whenever I get the time I'll try to update the challenge \$\endgroup\$ – ihavenoidea Jun 19 '20 at 21:59
0
\$\begingroup\$

Shift the letters, soldier !

posted, finally

\$\endgroup\$
12
  • \$\begingroup\$ Thank you for sandboxing this. I usually recommend doing so for at least a week, and periodically ask for review in TNB. \$\endgroup\$ – Adám Feb 28 '20 at 9:09
  • \$\begingroup\$ I think people would be forced to do the bonus in this case because of the -30% margin. I got a 42 without bonus but a 57*0.7=39.9 with bonus in JS. \$\endgroup\$ – Shieru Asakoto Feb 29 '20 at 3:16
  • \$\begingroup\$ Bonuses are discouraged for a variety of reasons. I would strongly recommend either making it mandatory or completely leaving it out. \$\endgroup\$ – FryAmTheEggman Mar 1 '20 at 18:58
  • \$\begingroup\$ The main challenge is add by position, the bonus challenge is minus by position. So it's a good idea to completely leave the bonus out. \$\endgroup\$ – user92069 Mar 2 '20 at 0:29
  • \$\begingroup\$ Thanks for the comments, I'll remove the bonus as it will never be balanced enouth to be interesting. I'll add some example as soon as I can. \$\endgroup\$ – The random guy Mar 3 '20 at 20:02
  • \$\begingroup\$ I would say that allowing the usage of the ascii range 1 to 255 or a language's code page could allow for some interesting golfs :) \$\endgroup\$ – RGS Mar 3 '20 at 20:39
  • \$\begingroup\$ Use asciii values from 0 to 255 was my original plan, but I'm afraid some interestings languages would be disadvantaged. Also, wouldn't the usage of language's code page be too permissive ? \$\endgroup\$ – The random guy Mar 4 '20 at 15:51
  • \$\begingroup\$ @Therandomguy it depends on what you mean by "too permissive". Sometimes it is done, as it may allow some languages to do some funny things. As to the range being from 0 to 255, I don't see it hurting any language at all, but of course I may be missing something :) \$\endgroup\$ – RGS Mar 4 '20 at 21:36
  • \$\begingroup\$ Are you interested in re-posting it? \$\endgroup\$ – user92069 Mar 6 '20 at 7:38
  • \$\begingroup\$ This weekend I'll post it, I just need some time creating the examples \$\endgroup\$ – The random guy Mar 6 '20 at 8:25
  • \$\begingroup\$ I'd be glad to see it posted in Main! \$\endgroup\$ – user92069 Mar 25 '20 at 12:19
  • \$\begingroup\$ Finally posted it in main \$\endgroup\$ – The random guy Jun 3 '20 at 7:45
0
\$\begingroup\$

Compute the pointiness, sharpness and smoothness of a letter

Inspired by Determine the sharpness of a word.
You are given an uppercase letter of the English alphabet as input. You have to compute (and output) its pointiness, sharpness and smoothness. Since it is difficult to define these objectively, here's a table of the outputs:

            A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
pointiness: 2 0 2 0 3 3 2 4 4 2 4 2 2 2 0 1 1 2 2 3 2 2 2 4 3 2
sharpness:  1 2 0 2 2 1 1 0 0 1 0 1 3 2 0 1 0 1 0 0 0 1 3 0 0 2
smoothness: 0 2 1 1 0 0 1 0 0 1 0 0 0 0 1 1 1 1 2 0 1 0 0 0 0 0

Transposed version (first lists the letter, then the pointiness, then the sharpness and then the smoothness) (like a true CGCC user, I transposed it with Jelly and added spacing with Retina):

A 2 1 0
B 0 2 2
C 2 0 1
D 0 2 1
E 3 2 0
F 3 1 0
G 2 1 1
H 4 0 0
I 4 0 0
J 2 1 1
K 4 0 0
L 2 1 0
M 2 3 0
N 2 2 0
O 0 0 1
P 1 1 1
Q 1 0 1
R 2 1 1
S 2 0 2
T 3 0 0
U 2 0 1
V 2 1 0
W 2 3 0
X 4 0 0
Y 3 0 0
Z 2 2 0

Bonus imaginary internet points if you find a language where this is built-in.

This is tagged , so the shortest answer wins.

Sandbox stuff

  • Is this not a duplicate?
  • Is the table computed correctly? (the only ones that don't seem certain with the current font are I's pointiness, G's sharpness and S's smoothness)
\$\endgroup\$
1
  • \$\begingroup\$ After fiddling about a bit, I think this should probably have enough patterns that mindlessly compressing the numbers won't be the best strategy. Still, I could be wrong, but here is what I used to see roughly how long such an approach would be (I encoded each set of values to a base 5 number, then in turn encoded that list of numbers into a base 61 number). Separately, you probably want to include the data in a more copy-pastable way. \$\endgroup\$ – FryAmTheEggman Jun 3 '20 at 20:34
0
\$\begingroup\$

Is this a simple cutting template?

A simple cutting template is a rectangle that can be recursively cut into smaller rectangles using only full-width cuts.

If you prefer a bottom-up description, then:

  • A single rectangle is a simple cutting template with 0 cuts.
  • Two simple cutting templates of the same width (or length) can be joined along their common side into a larger simple cutting template.

Input: A diagram of a rectangle subdivided into smaller rectangles, or a list of rectangles in some standard format, e.g. position and size.

Output: A truthy value if the diagram is a simple cutting template.

Note that if you take input as a diagram then all of the rectangle edges will use the same character, whearas in the truthy examples below, some of the edges have been replaced with digits to show a possible ordering of cuts while the falsy examples have the smallest portion of the input that is not a simple cutting template marked on them.

####2################
#   2               #
111111111111111111111
#                   #
#                   #
#                   #
111111111111111111111
#     2   2   2 4 4 #
3333332   2   2 4 4 #
# 4   2   2   2 4 4 #
# 45552   2   2 454 #
# 4 6 2   2   2 4 4 #
# 4 6 2   2   2 4 4 #
# 4 6 2   2   2 4 4 #
33333323332   2 4 4 #
#     2   2   2 4 4 #
#     23332   2 4 4 #
#     2   2   2 4 4 #
#     2   2   233333#
#     2   2   2     #
######2###2###2######

-> Truthy

##2#####4############
# 2     4           #
# 2333333333333333333
# 2         6     4 #
# 25555555555555554 #
# 2 6   6     8   4 #
# 2 6   67777777774 #
# 2 6   6         4 #
# 2 6   6         4 #
# 2 6   6         4 #
111111111111111111111
#               2   #
#               2333#
#               2   #
111111111111111111111
#   2             2 #
#   233333333333332 #
#   2 4 4     4   2 #
#   2 4 4555554   2 #
#   2 4 4     4   2 #
####2#############2##

-> Truthy

#####################
#                   #
#                   #
#                   #
111111111111111111111
# 2   4           2 #
# 2   4           2 #
# 2   4           2 #
# 23333333333333332 #
# 2     4   4 6 4 2 #
# 2     45554 6 4 2 #
# 2     4 6 4 6 4 2 #
# 2     4 6 4 6 4 2 #
# 2     4 6 4 6 4 2 #
# 2     4 6 45554 2 #
# 2     4 6 4   4 2 #
# 2     4 6 4   4 2 #
# 2     4 6 4   4 2 #
# 2     4 6 4   4 2 #
# 2     4 6 4   4 2 #
##2#####4#6#4###4#2##

-> Truthy

#####################
#               # # #
################# # #
#               # # #
#               # # #
#               # # #
?????????############
?     # ?     #     #
?     # ?     #     #
?     # ?     #     #
?     ##?     #     #
?     # ?     #     #
?###### ?############
?     # ? #       # #
?     # ? #       # #
?     # ? #       # #
?###### ?##       ###
? #   # ? #       # #
? ######? #       # #
? #     ? #       # #
?????????############

-> Falsy

?????????????????????
?     # # # # #     ?
?###### # # # #     ?
?     # # # # #     ?
?     # # # # ######?
?     # # # # #     ?
?###### # ##########?
? #   # # #         ?
? ##### # #         ?
? # # # # #         ?
? # # # # #         ?
? # # # # #         ?
? ####### #         ?
? #     # #         ?
? #     ############?
? #     #     #     ?
? #############     ?
? #     #     #     ?
? ##################?
? #         #       ?
?????????????????????

-> Falsy

#####################
#       #   #     # #
################### #
#                 # #
#####################
# #                 #
# ###################
# #   #             #
# ###################
# #   #     #       #
# ###################
# #                 #
# ???????????????????
# ?   #             ?
# ?   #             ?
# ?   #             ?
# ?   ##############?
# ?   #   #         ?
# ?########         ?
# ?       #         ?
##???????????????????

-> Falsy

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

\$\endgroup\$
3
  • \$\begingroup\$ I think you should include an explicit definition: 'A simple cutting template is a rectangle that can be recursively cut into smaller rectangles using only full-width cuts.' \$\endgroup\$ – Dingus Jun 6 '20 at 4:06
  • 1
    \$\begingroup\$ @Dingus Thanks for pointing that out, I think I must have accidentally edited it out by mistake when writing the sentence for the output. \$\endgroup\$ – Neil Jun 6 '20 at 10:29
  • 1
    \$\begingroup\$ I'd prefer one or two small examples with extra markings and then a list of copy-pasteable test cases. \$\endgroup\$ – Zgarb Jun 6 '20 at 11:13
0
\$\begingroup\$

ax + by, a & b are coprime

Backstory

A doctor in Berlin, after analyzing his medical history, has realized that all of the results of his integral measurement results can be represented in the form of \$23x+28y\$, where \$x\$ and \$y\$ are integers.

However, he could have extended his theory. \$23\$ and \$28\$ can be replaced by any two coprime numbers, and this theory would still hold. (He didn't have time to write his theory in a paper, that's quite awful.)

Task

Without examples, I'll never be convinced that this nonsensical theory holds!

Given \$the\ output\ of\ (ax+by)\$ (let's call it \$z\$), \$x\$, and \$y\$, find the smallest pair of \$(a,\ b)\$ that makes \$ax + by = z\$ true.

Example cases


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

Duplicate of Find the minimum edit distance between two strings

\$\endgroup\$
1
92 93
94
95 96
110

You must log in to answer this question.

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