# Sandbox for Proposed Challenges

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

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
• 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 needs more feedback, but it's been ignored, you can ask for feedback in The Nineteenth Byte. It's not only allowed, but highly recommended!

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

## Other

Search the sandbox / Browse your pending proposals

The sandbox works best if you sort posts by active.

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

Get the Sandbox Viewer to view the sandbox more easily!

You can use the Google sheets chart feature if you like, as long as the chart looks similar to what the client expects here:

Notice that a child can only have one parent, so you need to calculate the shortest path to the root element (aka "Home").

Your coding challenge is to create the same chart programatically for the static html as well as their Website at https://simple.goserverless.sg/

Example output:

generate-site-structure [index.html | https://simple.goserverless.sg/]
Jam,Products
Products,Home

• Welcome to the Sandbox! This currently isn't nearly clear enough, I'd recommend looking at some other graphical-output challenges to see the typical requirements. You also haven't specified an objective winning criterion; the most popular by far is code-golf (shortest code), but there are also some others like fastest-algorithm or test-battery. Apr 29 '21 at 2:55
• Thanks, I've tried to be clearer by stating what the expected output is to be. Does that make sense? Apr 29 '21 at 6:12
• I'm not sure I understand the goal. Are programs supposed to print that exact text, or a graphical representation of it, or take some sort of site as input and make a representation of it? Apr 29 '21 at 6:21
• The output is the text/csv which can be drawn by Google Sheets as a organizational chart. Apr 29 '21 at 7:38
• That definitely needs to be much clearer in the post. Without much prior knowledge or assumptions, it should be possible to tell exactly what is expected of answers from the challenge text, and also typically with a bit of explanation on how and some test cases. I'd recommend answering a challenge or two, doing that gives you a pretty good idea of what a challenge needs in order to be clear enough to answer. Apr 29 '21 at 13:25

# [Draft] 2x2 algorithm with half the faces

A fun fact about the 2x2x2 Rubik's cube is that due to the way a 2x2 only has two layers, doing one turn on one face is indistinguishable from doing the same direction turn on the opposite face and then rotating the cube. So algorithms, that is sequences of moves and cube rotations, ignoring the cube's orientation in space, only need to turn the up (U), right (R), and front (F) faces, and don't need to turn the down (D), left (L), and back (B) faces.

A move is represented by a face, one of the letters U, R, F, followed by a direction: clockwise (empty string or space  ), counterclockwise (apostrophe '), or 180 degrees (2). A cube rotation is represented as one of x (rotating the entire cube wrt R face), y (rotating the entire cube wrt U face), and z (rotating the entire cube wrt F face).

(credit: J Perm)

(credit: Ibero Rubik)

From the previous example, U move is equivalent to D y, meaning the result of turning the top face clockwise is indistinguishable from the result of turning the bottom face clockwise and then rotating the entire cube clockwise wrt the top face.

It is possible to rewrite algorithms with cube rotations into algorithms without cube rotations by appropriate substitution of all following face rotations. For example, y F is equivalent to R, and y U is equivalent to U.

Your task is given an input 2x2 algorithm, rewrite it using only U, R, and F moves, and without cube rotations.

I know this notation is probably confusing to people not familiar with it, so let me know how I can clarify the post.

## The Smallest Grammar Problem

Here is a write-up for the main site.

Some changes I want to add are:

1. You can use any language.
2. You must formally prove the Big-O of the worst case of your algorithm in your answer.
3. You must formally prove the correctness of your algorithm as well.

As far as running the code, that's up to the viewers of the page who wish to run the algorithm, as I can't reasonably be expected to compile code from so many different languages.

1. Before I post to main, I will have a solution to the problem which provides correct answers and can check if an output of your algorithm is correct. It will be coded in Python 3.x. But since the question is about fastest algorithm, that shouldn't matter.

2. Your algorithm only needs to provide one correct smallest grammar to a given input string (there are usually many), and it must be in standard form (see below).

3. Therefore my Python 3.x code will enumerate all smallest grammars up to standard form.

4. I will provide an example formal proof of my algorithm, both so that you can see what a formal proof entails and also so that we know that the solutions we're computing are indeed correct.

How does this all sound to you all? Where would you like to see improvements in the write-up? I am okay with rewriting the whole thing :)

The Smallest Grammar Problem (SGP), is defined as:

Given an input string s, compute a smallest CFG g such that L(g) = {s} generates the string and only the string s itself. Grammar size is defined as:

$$|g| = \sum_{A \in \text{Vars}(g)} |g(A)|$$

Where the grammar is $$g = \{ A \to g(A), B \to g(B), C \to g(C), \dots \}, \\ \text{ and, } |g(A)|$$ simply takes the string length.

So the size of the grammar g is the sum of the lengths of all right hand sides (RHS's) of the production rules making up g.

All literature on this problem talks about approximation algorithms, and not one article demonstrates a decent exact smallest grammar algorithm. That is to say, computing the very thing the article is about in the first place. I would personally like to see what an exact SGP algorithm looks like. How optimal can we make it, and so on...

I have had many ideas on how to solve the problem. Every one of my attempts ended up with inefficient (exponential running time code). The question is can you make a speedy SGP algorithm.

The language of choice for speed of development is of course Python. Though these resulting programs should not be used in a production compressor for large data. Still, an exponential algoritm remains inefficient even if ported to C++.

So, the benchmark will be running time. You are to use standard Python 3.x, and not Cython, etc.

I have included below some relatively bug-free boilerplate utility code that you may wish to use. It handles the methods for enumerating substrings of a grammar and so on.

These are methods I will use in my own answer, which I am currently still designing. My approach will use what I call the "Groupoid of smallest grammars". Groupoids are heavily involved in combinatorial optimization problems at an advanced level, so from that heuristic they seem like the right structure to use. Another way to code this problem is translating it into a linear integer programming problem and representing substring conflicts using summation modulo 2 (or something like that). Though, linear programming problems open another can of worms since a lot of those problems also have hard running times.

To teach you about the problem, let's inspect some examples. Though we cannot prove that the examples are indeed smallest grammars - there are no theorems out there that tell whether a certain grammar is indeed minimal. A proven algorithm however, tells you whether or not your grammar is minimal. You will need to provide a proof of your algorithm in English / math text accompanied by relavent chunks of your algorithm.

(**) Even though you can't get 2 as that gives you 2 $$\P_1\$$s and 2 $$\P_2\$$s, which is not enough to pay; getting 3 gives you 3 $$\P_1\$$s and 3 $$\P_2\$$s, and with the initially $1 you can pay the fee of 3 bottles of drink. One sentence meaning: Given $$\n, \{a_i\}, b, \{c_i\}, i=1..n\$$, find the largest integer $$\r\$$, maybe infinite, such that $$\b+\sum_{i=1}^n\left\lfloor\frac{c_i+r}{a_i}\right\rfloor\ge r\$$. Input range: • $$\n>0, a_i>0, b, c_i\ge 0\$$ # Sandbox Notes • Should I take c input or just assume it's zero at [1]? • I mostly get the problem statement from the first three paragraphs, but the rest of the challenge sort of loses me. I can piece together a bit from the test cases. If you added a more worked through example perhaps I could help rephrase the parts of the challenge I don't get right now. – Wheat Wizard Mod May 14 '21 at 15:24 • @WheatWizard Is treating borrowing as having negative amount of parts or pay after drinking better? Also fixed a bug in test cases. And do such question have an English usualseen version? – l4m2 May 14 '21 at 16:12 # Implement the ordering monoid ## Objective Mimic Haskell's (<>) :: Ordering -> Ordering -> Ordering. ## What's the fuss? This particular monoid is rather useful for comparing sequential containers lexicographically. ## Format Though Ordering is defined as a three-element enumeration, in this challenge, the format of the 2 inputs and the output is arbitrary. The 2 inputs and the output must be the same domain, and their classification of their values (see below) also must be the same. This restriction is due to that (<>) is associative. Any input outside of the domain falls in don't care situation. ## Operation The elements of the domain shall be classified to 3 categories: Negative, zero, and positive. • If the left operand is negative, output a negative value. • If the left operand is zero: • If the right operand is negative, output a negative value. • If the right operand is zero, output a zero value. • If the right operand is positive, output a positive value. • If the left operand is positive, output a positive value. ## Example A Python 3 implementation of this operation: lambda x,y: x if x != 0 else y  This has integers as the domain, and classifies integers by their signature. • looks like in many languages this will just be an "or" builtin May 14 '21 at 23:04 • I want to say this might be clearer if the spec for the operation just used the names LT, EQ, and GT, but the example domain leads to the unfortunate revelation that your example solution could be simply lambda x,y:x or y... May 14 '21 at 23:08 • @Wzl How would an "or" operator act? Bitwise "or" is commutative, while (<>) isn't. May 15 '21 at 0:26 • Python 3: lambda x,y: x or y May 15 '21 at 9:25 • Finally, I am the outgolfer. May 15 '21 at 9:25 • Javascript: $=>_=>$||_ May 24 '21 at 20:19 # Generate simultaneous equations code-golfrandommath You've been tasked to write maths exam questions, but you're getting quite bored of coming up with simultaneous equations with integer solutions, so you decide to write a program to generate them. Because this is a school test, the questions mustn't be too easy, but they also mustn't be trivial. The simultaneous equations should be of the form: $$ax + by = R$$ $$cx + dy = S$$ where $$\ a \$$, $$\ b \$$, $$\ c \$$, $$\ d \$$, $$\ R \$$, $$\ S \$$ are integers. The equations must have exactly one set of solutions, the solutions must both be integers, and $$\ x \$$ must not equal $$\ y \$$. The random generation method you choose is completely up to you, as long as there are at least 100 distinct equations that could be generated each with a non-zero probability. If the coefficients or equations are swapped, they count as the same (this is to discourage hard-coding of valid equations). You may output in any reasonable format, such as a string "-1x-2y=3;4x+5y=6" or a list of 6 integers like [-1, -2, 3, 4, 5, 6]. The format must be consistent for all outputs. ## Examples Valid x y ------------------------- -1x-2y=0; 4x+5y=6 4 -2 Invalid Notes -------------------------- -1x-2y=7; 4x+5y=6 Non-integer solutions -1.5x-3y=0; 4x+5y=6 Non-integer coefficients 0x+2y=8; 2x+2y=6 Zero coefficients 3x+4y=1; 6x+8y=2 Infinitely many solutions 3x+4y=1; 6x+8y=3 No solutions TODO: add more examples  ## Rules # Meta • Is this a duplicate? • Is this clear enough? • Any other feedback? • I'm not sure if this is too trivial – tsh May 17 '21 at 2:59 • @tsh A lot of Kolmogorov questions are therefore even more "trivial". May 20 '21 at 12:59 tags: # Based square-free words A square-free word is a word that contains no squares, i.e. contains no adjacent repeating subwords. For example, 0123 is square-free, while 0112 and 012123 are not (because 11 and 1212 are repetitions, respectively). In base-1 there is only one square-free word: 0. In base-2 there are 6 square-free words: 0, 1, 01, 10, 010, 101. In base-3 and up there are infinitely many. ## The challenge Given a base N and a length L, output a square-free word of length L in base N, or a distinct falsy value (or an error) if no such word exists. Both the base and the length will be positive integers. Alternatively, you may take an alphabet instead of a base as input, e.g. you may take "ABC" as an input instead of base-3 and give output in that alphabet. Any reasonable input-output, standard restrictions, code golf. ## Test cases Other similar outputs are also valid. Base Length Output 2 1 0 2 2 01 2 3 010 2 4 Error or a distinct falsy value 3 4 0121 3 5 01210 3 50 01210212012101202102012021201021012010212021020120  • This is a more general version of this older, more specific question, is this unique enough to be a standalone question? May 16 '21 at 21:20 Given an real polynomial equation $$\c_0+c_1x+c_2x^2+...+c_nx^n=0\$$, count how many real roots it has. You can and need to assume infinite precision. You can assume repeated root doesn't exist.[1] You can take input [c0,c1,...,cn], [cn,...,c1,c0], or just the polynomial or the equation in your language support. Test cases: 1=0 => 0 0=0 => Infinity 2+1x=0 => 1 3+4x+1x^2=0 => 2 6+4x+1x^2=0 => 0 0+0x+0x^2+1x^3+0x^4=0 => 1  # Sandbox Notes [1] Is checking repeated root always possible? • This feels like a factorisation code-golf, though the question is still very good May 18 '21 at 16:40 • @StackMeter But you can't solve some poly eq? – l4m2 May 19 '21 at 3:20 • Do you have a reason to believe it is solvable in finite time? May 25 '21 at 1:03 • Also, in your last example (x^3=0 in simplified form), 0 is the repeated root. May 25 '21 at 1:06 ## Golf Code Golf Given the transcript (what I mean by full transcript is you can access all days of the transcript) of The Nineteenth Byte (the general chat room of code golf), output the full transcript in text form (you only have to include messages, though including other things is allowed. You can use any format as long as it includes the poster and contents of each message. As for people changing names, the way you handle this is up to you, do whichever is shortest). You can access the full transcript in your code, but you cannot access any other external sources. Since this is code golf, shortest answer wins, and standard loopholes are not allowed • Any feedback would be helpful, since this is my first question idea here. May 18 '21 at 20:14 • By "access the full transcript" what do you mean? There's no single page with the entire transcript, so do you mean all pages that are https://chat.stackexchange.com/transcript/240/<date>? May 18 '21 at 20:18 • @cairdcoinheringaahing yes that is what I meant, I’ll update it now, thank you. May 18 '21 at 20:21 • You'll need to be much more specific about what "text form" is. I'm assuming ...people talk... is not correct, but there are a huge amount of formats, such as person: message and <person> message, not even considering stars, multi-line messages, and users changing their usernames May 18 '21 at 20:29 • @Wzl I edited it, is it more clear now or is there something I missed? May 18 '21 at 20:48 • If people are as lazy as me I think they'll just output the raw HTML, since it complies with your constraints (however I think this is a good thing as answers shouldn't be required to parse HTML) May 18 '21 at 20:54 # JS onelineriser JavaScript is a very easy language to onelinerise. All one has to do is insert a semicolon in the correct locations and concatenate every line. Your task is to write a program that, given a valid JS program, returns a program in one line but is otherwise identical to the input. ## Sandbox • Clarifications? • Any edge cases where any operation other than inserting semicolons is required? • Should I include basic JS syntax in the question or provide a link? • I think you should ask the programs to minimize the amount of semicolons placed. May 19 '21 at 2:42 • You definitely need to tell where one needs to insert ;s. – Adám May 19 '21 at 2:42 • I know where one should place semis but I'm not exactly clear whether those semis are necessary. However, I intended this to be a code-golf and not a code-challenge (shortest source) May 19 '21 at 2:59 • Either the input code is guaranteed to conform to a format where some simple rules can be applied (and you'll have to include these rules in the challenge), or this is going to require a full parsing and syntax analysis -- which is probably far too complicated for a code-golf challenge. May 19 '21 at 22:14 • Can I make the whole input toJson and then feed it to eval? This is valid since ES2019. (And CSP is never a part of ES specification, so that doesn't matter.) – tsh May 20 '21 at 2:26 • Other than inserting semicolons: remove comments. For example, foo(); // do something<line-break>bar();. And remember to keep line break in comments. For example, ()=>{return//<line-break>42;}. More terrible comments: ${()=>{return // this is a comment in template string. <line-break> }}. Even even terrible edge case: If hashbang proposal landed...
– tsh
May 20 '21 at 10:35
• @tsh tbh comments aren't "code" so to speak, so I might not actually have those test cases. They would be hell to deal with. May 20 '21 at 12:46
• Can I just warp the code eval? (ok also asked by tsh)
– l4m2
Jun 6 '21 at 5:04

# Return shortest integer-is-one-of function

Given a number of integers as input, your task is to write a function in JS, which returns a function that checks if an inputted integer is any of those. For example, f([1, 2, 4]) would return a function which would return true if given 1, 2, or 4, and false for any other inputs.

Your function will take any nonzero number of integers. There will not be any duplicates. This should return either a function, or a string containing the function's code.

The returned function should take a single integer as input. If the input is one of the integers inputted into the original function, it should return a truthy value, and a falsy one otherwise. You may also choose to return any two consistent values, or a consistent value for one possiblity (such as 0 for truthy) and any other value for the other.

Scoring:

This is metagolf, meaning the average of the byte counts of the returned programs for a certain set of inputs will be your score. This set of inputs will consist of:

• All combinations one to four integers from -10 to 10
• A random group of 2000 inputs consisting of between five and ten integers between -100 and 100
• A random group of 1000 inputs consisting of between two and six integers between -10000 and 10000

Optimizing your solution for these specific test cases is disallowed.

# Meta

• I will generate a random list of test cases that will be used for scoring when I post this
• This is my first time writing a metagolf challenge. Any improvements y'all can think of?
• I think the number of bytes should be limited in the submitted function (not the generated ones). Suggestions?
• Too many test cases? Too few?
• The option to return a function is only available in JS, I'm assuming? I think you should disallow it, because it's unclear how you measure the size of a function object. May 21 '21 at 14:22
• Maybe you should include test cases with more than six integers? If not, is it allowed for a solution to be optimized for small sizes? (given that it's a a minority in the input space) May 21 '21 at 14:23
• @CommandMaster Oh, I meant to restrict this to JS anyway, wasn't sure if I was going to do that or not. It should be possible in any language with first class functions, though. If I open it up to any language I'll allow returning a string with a program. I'll add some test cases with more items. May 21 '21 at 14:56
• If you return a function, how do you count the byte count of it? May 21 '21 at 15:14
• .toString() (plus it's pretty likely they'll return a string form of the function anyway) May 21 '21 at 15:28
• .toString() doesn't work for that, for example in function f(i) { var l = a=>a+i return x=>l(x) } f().toString() is just x=>l(x), while that's clearly not the length of the code you want to count (it's also unclear what code you do want to count in such a case) May 21 '21 at 15:39
• @CommandMaster The functions will need to be independent from the meta function. As in, no closures/accessing variables in the above scope. May 21 '21 at 15:55

# Gabriel's Horn

Posted

• 1. I don't think I've seen anything very similar. 2. Wording looks fine to me (mainly because the image helps a lot) 3. I don't have a strong opinion on this. Either way should be fine. 4. Looks correct. 5. Actually the whole challenge is simply "generate a specific arithmetic progression based on the input", which can be seen as not so interesting, and it has very little to do with Gabriel's Horn itself. Maybe a better title would be "Convince me Gabriel's Horn is possible"? May 18 '21 at 0:28

# Print a BigNum

Your task is to take an arbitrary precision unsigned integer, separated into 7-bit parts (a.k.a. base 128), and output it in base 10.

## Rules:

All arithmetic for conversion (excluding basic indexing) must be done only using values $$\-2^{15}\le x \le 2^{15}-1\$$, or in simpler terms, the range of a signed 16-bit integer.

So for example, something like this in Python would be illegal because a[i]<<i*7 and sum are capable of making a number larger than $$\2^{15}-1\$$.

lambda a:str(sum(a[i]<<i*7for i in range(len(a))))


Note that you are not required to explicitly use 16-bit integers or mask every time.

Your algorithm must be able to handle numbers of any length, if the resources are available.

Assume all inputs to be valid and the shortest possible length.

## Input/output:

The input is a list of numbers, each 0-127, in big or little endian order. You only need to handle up to 224 bits, or 32 base 128 digits, though.

Any reasonable encoding format is fine, as long as all digits are in base 128 and the length is variable. You could do this: 122 bananas, 0 bananas, 20 bananas, 12 apples, I don't care. ULEB128 is allowed if that is easier.

The output can be either an ASCII string or printed to standard output, all in base 10. These must be ordered in big endian (as if you were to print it).

## Test cases

Inputs are in little endian order.

[0] -> 0
[1] -> 1
[127] -> 127
[99] -> 99
[0, 0, 1] -> 16384
[127, 0, 0, 0, 127] -> 34091303039
[21, 26, 111, 58] -> 123456789
[1, 78, 123, 61, 102, 86, 17, 32, 74, 41, 114, 79, 1] -> 31415926535897932384626433
[63, 29, 51, 105, 61, 107, 45, 70, 105, 97, 38, 36, 121, 15, 77, 24, 72, 4, 52, 56, 6, 5, 36, 38, 87, 10, 37, 26, 96, 16, 21, 110] -> 23203475113112158652497114438750306328443726354045579113768791363263

• What does "All calculations must use a maximum of 16 bits" exactly mean? Does it mean I can only use 16 bits RAM (including registers)?
– tsh
May 20 '21 at 7:54
• You probably want to limit the absolute value, otherwise someone could calculate -<ans>, convert it to a string, and remove the first character May 21 '21 at 7:38
• Your algorithm must be able to handle numbers of any length given a large enough buffer. So given a number with >2^15 base-128 digits how to access?
– l4m2
May 21 '21 at 8:46

## Rules

1. Standard loopholes apply except for searching for the answer online. In fact, you are expected to find the answer online.
2. You are allowed to use curl or the equivalent, but you are not allowed to use any html parser library or built-in. If you need to import the library, the import declaration does NOT count into the code size as long as you don't rename any identifiers.
4. You may still assume your username, the contents of your code, and the programming language/byte count you are using. You are not allowed to assume the description below your code. If you edit the description part of the submission and the code breaks, you fail the challenge. You may assume that the code of each submission is unique and no one copies your submission into another answer.

## Scoring

This is so, the shortest answer in bytes wins.

• What prevents me from simply hardcoding my output? May 20 '21 at 9:24
• @StackMeter If you delete your answer, and post again the same answer, and it break, it fails the challenge. May 20 '21 at 9:42
• thanks for the clarification May 20 '21 at 9:44
• What if my language has built-in for HTML parser (Yes, JavaScript running in browsers , aka. BOM, does have one)? Also, what will happen if I post 2 answers to this question?
– tsh
May 20 '21 at 9:46
• Can I assume no one else will contain my code as part of an answer/comment? May 20 '21 at 10:12
• @CommandMaster Yes May 20 '21 at 11:43
• @tsh 1. You have to avoid using that built-in, 2. You have to be able to distinguish your submissions. May 20 '21 at 11:44
• [tag: self-referential] ? May 21 '21 at 5:10

# Recreate the Stack Overflow logo

• note that the last time this was attempted, it got closed May 21 '21 at 21:54
• @Wzl this one is a code-golf question. I don't see why it can be off-topic. May 21 '21 at 21:55
• @Wzl also, the logo for this one is not the one specified from that question you linked. May 21 '21 at 22:42
• I've edited this down to a stub now that it's been posted to save space May 22 '21 at 23:09

# Lowest effort to fill the bucket

There are two man, Paul and Jhon, who can move only along a line; they are real persons so Paul cannot goes to the right of John and Jhon cannot goes to the left of Paul. At time 0 they start at the opposite ends of the line.

Paul |------X1----X2----BUCKET--------X3-----X4-----| Jhon

Their goal is to pickup the balls along the line (denoted as Xn) and fill the bucket in the lowest time. The time needed to go from A to B along the line is equal to the distance from A to B.

For the challenge the balls are 20 and they are located on the line in the following way:

1. Paul = 0
2. X1 = 1
3. X2 = 2
4. X3 = 3
5. x4 = X5 = x6 = 5
6. BUCKET = 8
7. X7 = 10
8. X8 = 11
9. X9 = X10 = X11 = 15
10. X12 = 20
11. X13 = X14 = X15 = 22
12. X16 = X17 = X18 = 28
13. X19 = 29
14. X20 = 30
15. Jhon = 32

Which is the best sequence to reach they goal?

# Verify the Perfect Rectangle

According to Wolfram Mathworld, a perfect rectangle is defined to be a rectangle that can be divided into squares of different side lengths.

In this challenge, we are going to verify whether or not an arrangement is a perfect rectangle.

For the input, there should be at least 3n+2 non-negative integers in it:

• The first two numbers should show the size of the rectangle.
• Rest of the 3n numbers should describe n squares.
• Each square should be described with 3 numbers, which are the side length(>0) and the position(x, y).
• Position should be consistent throughout the whole input. For example, If the program gets the position of the bottom left corner of the square for one time, it should do that every other time as well.

For the output, the program should print a truthy value if the given arrangement is a perfect rectangle, and a falsey value otherwise.

• Every squares should be different in side length.
• There should be neither overlaps nor voids.

Test cases(Note that any input and output formats are acceptable if they are reasonable):

[[32,33],[9,0,0],[8,9,0],[15,17,0],[10,0,9],[1,9,8],[7,10,8],[14,0,19],[4,10,15],[18,14,15]]
-> True #This is the first example in the above link.

[[65,47],[23,0,0],[17,23,0],[25,40,0],[6,23,17],[11,29,17],[24,0,23],[5,24,23],[19,24,28],[3,40,25],[22,43,25]]
-> True #This is the second example in the above link.

[[4,4],[2,0,0],[2,2,0],[2,0,2],[1,2,2],[1,3,2],[1,3,3],[1,2,3]]
-> False #There are sqaures of same sizes.

[[5,5],[3,0,0],[3,2,2],[2,0,3],[1,3,1],[1,3,0],[1,7,0]]
-> False #There are overlaps and voids.


This is , which means that codes with least bytes win.