# Loopholes that are forbidden by default

There are a number of standard loopholes which experienced question-setters seek to explicitly close. However, inexperienced question-setters may unintentionally leave them open, or respondents may try to argue for contorted interpretations of the question in order to side-step attempts to close them.

The purpose of this question is to provide a repository of standard loopholes which may be assumed to be closed without the question-setter having to explicitly close them. The intention is that each answer shall contain one and only one loophole (to allow independent voting); and that the loophole described in any answer which is at +5 or above and has at least twice as many upvotes as downvotes may be taken to be deemed to be unacceptable to the community. A link to that answer may be provided in a comment to accompany a downvote and a flag.

• Loopholes are part of what makes the game interesting. Even common ones can be funny or clever, depending on context. If you find a loophole in an answer disinteresting, don’t vote for it, or vote against it. I don’t think we need a canonical list of fun things that you can’t do. (With the exception of Interpreting the challenge too literally below. That’s always boring. ;))
– Ry-
Feb 27 '14 at 18:16
• @minitech: And the countless variations of curl -L http://bit.ly/012foobar aren't? Mar 2 '14 at 14:59
• @IlmariKaronen: Depends whether it’s actually clever. If you don’t find it clever, vote appropriately. As always.
– Ry-
Mar 2 '14 at 15:57
• @minitech, there seems to be a strong consensus that the appropriate vote is "Low quality, delete". Mar 2 '14 at 22:56
• "at least twice as many upvotes as downvotes" ... You can't see that until you have at least 750 rep on the site. Seems like the rules should be visible to everyone. Apr 14 '14 at 16:05
• @derobert, I don't want to be seen to claim that a 105 vs 100 voting situation represents a clear community consensus, and I think that looking for a supermajority is the best way to avoid that. It's unfortunate that the score breakdown isn't visible to everyone, but I don't generally expect many low-rep users to visit meta. FWIW, the only current answer which doesn't have a supermajority is "Using comments to circumvent character requirements/restrictions" on +11/-6. Apr 14 '14 at 16:31
• @PeterTaylor Ah. I'm surprised "Using the program name to store data" isn't one of them, considering the +26 comment on it. Apr 14 '14 at 16:51
• @derobert, it's at +28/-4. Very puzzling. My best guess is that most of the people upvoting the answer agreed with the part of the comment which says that the filename should be counted towards the length of the program. Apr 14 '14 at 16:57
• The condition for whether the loophole applies should probably be changed to +10 or +15. All of the answers are currently above the +5 mark due to the surge in popularity of this post. Perhaps it could be a moving window (all answers with a score of average of all answer scores / 2 or the score of the highest voted answer / 5 or something), but that would be pretty complicated.
– Doorknob Mod
Apr 27 '14 at 21:24
• It's nice that this is in the FAQ, but I can find no obvious way to get to the FAQ so that new users can see it. I don't think we should be downvoting users for breaking a rule they don't know about. The FAQ needs to be easily available to new users who get her via any means. Jun 29 '14 at 12:34
• When I say it is "no obvious way to get to the FAQ", I am referring to the fact that it does not seem to be linked in the Help dropdown itself nor mentioned in the Tour or Help Center pages. I know I only found out about this page after I saw a question that downvoted because of it. (And because it was mentioned explicitly in some questions, but those keep being removed.) Jun 29 '14 at 12:46

## Interpreting the challenge too literally

That is, if the challenge says "write a function that, given a number n, returns the n-th prime", posting something equivalent to:

function f($n) { return "the$n-th prime";
}

• I believe you meant "Compiling the challenge too literally" :P Jun 10 '14 at 17:21
• @Jwosty not in this case, as PHP is interpreted. Jun 20 '14 at 9:28
• @Rokk Or is it? IT'S ALL A RUSE! Jun 20 '14 at 15:59
• Someone may answer my question, I've said this a few months ago (meta.codegolf.stackexchange.com/questions/924/… ), but why does my question have a tag "this question has already been answered in {this topic}"? Even though my own one was months prior to this one? I didn't think it would be like that. Jul 4 '14 at 12:07
• Your example is actually one of not interpreting the challenge quite literally enough. You would have a good point if this were a spoken medium, but on a typed challenge, "the $n-th prime" in quotes is different from "the$n-th prime" without the quotes. Punctuation matters. It's the difference between "I had a dream about 3 ballerinas, Stalin, Mussolini, and Hitler." and "I had a dream about 3 ballerinas: Stalin, Mussolini, and Hitler." Sep 5 '14 at 12:25
• This is not a loophole actually. It's just a misconception (albeit a very extended one), a confusion between use and mention. The challenge didn't include quotation marks Jan 25 '15 at 18:02
• @LuisMendo: It could also be viewed as a representation issue. That is, if we accept, say, "13", "13.0", "thirteen", "XIII", "0xD" and "1.3e1" as valid representations of the same number, then why not also "10 + 3" or "int(pi^2 + pi)" or "x: x^2 - 26*x + 169 = 0" or "the 6th prime"? This is not a trivial issue in philosophy of mathematics, since in math, we're constantly dealing with numbers that we can't write down as, say, a finite sequence of decimals, like pi or sqrt(2) or even just 1/3. Just about the only easy and simple answer is "because it would make the challenge boring". Jul 16 '15 at 8:54
• @IlmariKaronen I tend to agree with your reasoning. But for the n-th prime there is a convenient decimal representation, whereas for the cases you mention there is not. Saying "sqrt(2)" is probably the simplest explicit representation of the intended number, whereas saying "the n-th prime" is not (you could write it explicitly and simply as "23", or as "127", etc) Jul 16 '15 at 9:11
• "the $n-th prime" is not the n-th prime. Jan 19 '16 at 11:59 • @Jwosty I think you're interpreting the answer too literally. Aug 21 '16 at 6:13 • @Khaled.K: Exactly. It is ridiculous that people on CG SE do not understand the difference between strings and their evaluation (if any). May 14 '21 at 11:25 ## Fetching the desired output from an external source This includes doing an HTTP request to fetch the page with the question and extracting a solution from that page. This was mildly amusing back in 2011, but now is derivative and uninteresting. • Especially getting the highest voted answer from the selected wuestion Apr 10 '14 at 21:13 • We could allow it, if the size of the external source is added to the size of the answer. – vsz Aug 30 '15 at 21:21 • You mean a copy-paste answer? Jan 19 '16 at 12:01 • @KhaledAKhunaifer, no, I mean an answer which saves bytes by replacing a large string with a wget or similar that fetches it. Jan 19 '16 at 14:33 • @PeterTaylor I see; well if the content that the solution depends on is retrieved from a source that is not part of the platform, then its size has to be added to the size of the answer. I don't see a difference between manually copy-paste or make a wget do the copy-paste. Jan 19 '16 at 16:06 • some internet questions may need to do so, but source code itself still not allowed to just be fetched – l4m2 Apr 4 '18 at 4:58 • codegolf.stackexchange.com/a/23968/59169 is an excellent example how this can be used creatively Aug 11 '19 at 14:36 • @val, not really. It could have been golfed considerably by self-hosting a page with just the desired content and, if necessary, using a URL shortener. And that's really the point: outsourcing the output gives you arbitrary text at a fixed byte count. Aug 11 '19 at 16:20 ## Using a made-up language specifically designed for the challenge This includes any language with commands that "do whatever I choose them to do". Claiming that your answer is written in "MyOwnLanguage", where the command x means "read a sequence of numbers, split them into groups of three, and print the last numbers of those groups where the second number is less than the first", was clever the first time it was done. That was a long time ago. • I think HQ9+ should no longer be considered made up. It's useless for almost all challenges, and can sometimes be used creatively. Feb 23 '14 at 14:53 • Sorry, I agree with the poster. Makes for boring answers. The question it was used to answer could have been a lot more exciting and interesting without the trolly languages and GolfScript. Feb 24 '14 at 21:03 • -1: if a question can be answered creatively with HQ9+ or any other language that was already existing before the challenge was posted, then maybe the question was boring and not the answer. Feb 25 '14 at 14:09 • Could this be split in two answers? I would vote up for “made-up language” but not for HQ9+. And given this answer has the most mixed votes (+13/-7), maybe I'm not the only with similar opinion. Mar 2 '14 at 15:52 • @manatwork: I originally included the mention of HQ9+ because I was (and still am) kind of tired of people invariably trying to use it for each and every hello-world and quine challenge, even those where it fails to meet the spec. But you're right, it's been around long enough to become sort of established. I've edited this answer not to mention HQ9+, except tangentially as a "historical example". I haven't posted a separate "using HQ9+" answer, since I honestly don't see it as that much of an issue in itself; if anyone else wants to do so, feel free. Mar 2 '14 at 16:13 • I'd bound this in with "get from external source" and other ways of hiding byte count. Mar 12 '14 at 19:11 • I don't have any problem with made-up languages. But the language should already exist when the challenge was posted. Never versions of the language are not allowed (to prevent changing the language e.g adding an extra command to HQ9+). Mar 13 '14 at 15:27 • Where to draw the line between “made up” languages and languages which are not made up for one specific challenge but still are not really used outside of codegolf (or similar) challenges? Does using a language for two challenges already qualify? May 27 '15 at 11:54 • @Holger: Nowadays, from what I've seen, the general consensus seems to be that any language (version) released before the challenge started (or was first proposed in the sandbox, etc.) is OK. That is, the important point is that the language should not be made up for the challenge. May 27 '15 at 12:56 • This standard loophole also closes the possibility of saying "since all Turing-computable programs are enumerable (and therefore representable as a number -- say, a compiled binary interpreted as a binary number), I hereby define a family of languages, MyLang-N, where each MyLang-N correspond to a language where the empty string executes the Nth program in the enumeration of all programs." Dec 18 '15 at 15:06 • To anyone else who is looking for the more exact rule "the language should be released before the question was posted": it was given here. Jan 5 '16 at 9:11 • Isn't that just called "a golfing language"? Mar 8 '18 at 9:10 Using lots of spaces to "hide" code out of bounds, especially in questions. This isn't very clever or tricky, in my opinion, and yet wins all too often. Example: #include <stdio.h> #include <time.h> #include <stdlib.h> int main() { srand(time(NULL)); // Make sure to seed rand so it's VERY random, we want to make super sure that it's very random! Otherwise the program is useless! int r = rand() % 6 + 1; r = 5; // Sneaky sneaky! printf("Here is your TOTALLY random dice roll: %d",r); }  • I haven't even seen this before, do you have some examples? I actually think that is so lame I can't imagine it getting a lot of upvotes even without it being on this list. Jul 9 '14 at 18:52 • Jul 9 '14 at 18:58 • ugh, have an upvote. Jul 9 '14 at 19:01 • This is why I set all my editors to show whitespace. Nov 5 '14 at 10:39 • @MartinBüttner Ugh, have an upvote on your comment about having an upvote. Apr 13 '15 at 16:12 • It should be r = 4. Dec 6 '15 at 19:54 • Obligatory xkcd for that last comment: xkcd.com/221 – user18932 Feb 23 '16 at 3:16 • I've seen such trick in malware scripts in 90s. mIRC, an IRC client, was configurable with scripts that would add functionality. A way to do it was by creating the file script.ini in mIRC's main folder. Earlier versions of mIRC would use its main folder as a default download folder (when another user sends you a file), with the default option to accept a download automatically if the filename doesn't exist. So sending script.ini malware was quite popular. I had collected a few and the trick in this answer was used in some of them. Nov 8 '17 at 10:27 • [underhanded] is dead, so should this be deleted? Mar 12 '18 at 1:59 • It'll be easy to discover if the VERY random number is always 5 Apr 14 '18 at 14:35 • So we don't count characters when scrutineering ? Jul 10 '19 at 4:40 # Using the program name to store data without counting those bytes Example - this bash script prints Hello World! echo$0


Must be saved in a file called Hello World!.

When using the filename to store data, add them as extra bytes to your solution similarly to any non-standard parameter.

For example the correct byte count for the above is 7 (echo $0) + 12 (Hello World!) = 19 bytes. • -1 I think this is completely fine, but if you are using the filename, then it has to count to the bytecount as well, just like any other non-standard parameter you have to specify in the command line / shebang. Feb 25 '14 at 14:06 • @SztupY It's absolutely standard for the filename to be the first parameter. argv[0] is the filename in C for example. Jun 21 '14 at 13:57 • It's quite standard for C executable to be named a.out. Can it be used without increasing bytes count? May 30 '17 at 18:02 • @SztupY: I fixed this answer to allow using the filename, but only disallow failure to count those bytes. Your comment had 224 upvotes, but the answer only 113 upvotes (and 26 downvotes) before I fixed it. I reversed my vote after fixing it :P Jul 20 '17 at 16:53 • Also, turns out ! instead of \! works too, with bash. History expansion doesn't apply to the results of parameter expansion, only to literal !. (And is off by default in non-interactive shells anyway.) So this example is badly golfed, but I'll leave in the \! as a hint/clue about what's going on. Jul 20 '17 at 17:01 • @PeterCordes, there was no intention to golf the file name, because its bytes are not supposed to be counted. Space needs to be quoted in a line such as cat > Hello\ World\!, but indeed the created file name won't contain a . Jul 20 '17 at 18:12 • Yeah, I realized that it only became an issue once I changed the answer. I updated it try to avoid the distraction of a sub-optimally-golfed implementation for future readers of the question, who aren't thinking about what it used to say. Your point about cat is a reason to leave both the back-slashes in, so it creates 'Hello Word!' for people that copy-paste the filename into a shell command without quoting it. Ugh, I'd rather just assume that people know how to use quote filenames in the shell, but if you want to change it back to 21 bytes, I don't object. Jul 20 '17 at 18:15 • What if relying on a necessary part as storage? e.g. a BAT file use its whole filename"1.BAT" to do operations, count as +1 or +5? – l4m2 Dec 1 '17 at 8:12 • @l4m2: What happens if I name it 1.cmd? – SamB Sep 21 '18 at 21:17 • @SamB Discuss both situation – l4m2 Oct 1 '18 at 13:05 • All answers I have recently looked at took command line arguments for granted without counting them towards the length. The problem lies in the definition here. If you ask for a program f(x) = y, and provide test values for x, then x obviously doesn't count. "Hello World" however is f() = x. Writing a program f(x) = x is not the same. So the real loophole is "defining would-be constants as variables to outsource them", which is the generalized form of multiple loopholes mentioned here. Apr 24 '19 at 17:23 • It should just be 12. The backslash in the filename doesn't really exist on disk. Mar 22 '20 at 21:40 • This is not right. If the filename contains the backslash, it will be present in the output too. If it doesn't it will not be. How the filename has to be entered in the shell is not the same as what the filename actually is. (if it's about counting the bytes needed to input it to the shell, the post should say that instead.) Also, if you were to actually create such a file, you'd need to escape or quote the space, but not the bang. (None of the shells that support history substitution trigger on a trailing !.) E.g. touch 'Hello World!', or touch Hello\ World! both work. Mar 31 '21 at 14:25 • Funny is that 286 users likes your comment, but only 24 people dislike the answer :P Jun 10 '21 at 14:41 ## Outsourcing the real answer I still did not see people using this thing here in serious answers (just in some jokes ones), but already saw it being used seriously elsewhere. To circumvent restrictions and rules in the question (normally size), the answerer writes a small program that downloads the real program from elsewhere and then compiles and runs it. A variant of this is posting an answer that takes input from the user and then submits it to somewhere on the Internet that is responsible for solving the problem and send back the output. • +1: I think this can also be considered a link-only answer, and be flagged as such. I especially hate when answer like this appears in non code-golf questions, where they have absolutely no purpose. Feb 25 '14 at 14:12 • @SztupY But much of the time, they aren't link only answer. They in fact do contain some working running code. Feb 25 '14 at 15:59 • I'd lump this together with Fetching the desired output from an external source. Fetching the code instead of the output from an external source doesn't really make it any more acceptable. Feb 27 '14 at 12:08 • I agree with Ilmari - fetch code and fetch answer are two sides of the same coin. A very low-valued coin. Feb 27 '14 at 14:56 • I think all networking should be banned unless explicitly allowed in the question.. Aug 1 '14 at 17:41 • A variant of this loophole is abusing an input-flexibility rule like "you can read the input in any format" to submit a program that evals the first line of input and requires, as part of the input format, that the input begin with a line containing a real program solving the problem. Mar 23 '15 at 3:32 ## Hard-coding the output Unless the question is an obvious exception (the primary exception being those tagged ), your program is expected to do work, not just print a pre-calculated result. If the question doesn't require input and so a solution which just prints the answer would seem to meet the spec, downvote the question rather than post a protest answer consisting of the literal output. • Often, this vulnerability is an indicator of a dumb question... Mar 7 '14 at 19:37 • Sometimes you can't solve a problem in any other way, e.g. Factorial calculation without recursion/loops/eval - but that indicates a bad question. Mar 13 '14 at 15:23 • How does Bubblegum fit into this? It seems to be designed to kill pure kolmogorov-complexity questions. Feb 18 '16 at 1:12 • @CJDennis Unless the question is an obvious exception (the primary exception being those tagged kolmogorov-complexity) – user45941 Mar 3 '16 at 0:29 • Most questions provide a couple of test cases and not only one. Only a bad question would have this problem and even then, you could edit it. Sep 30 '16 at 18:12 • Now I can't understand what this loophole means. Mr.Xcoder recently posted this chat message which doesn't seem to be correct. If the question requires input, hardcoding is impossible. Can you explain more? @PeterTaylor Jan 12 '18 at 13:53 • @user202729, it was addressed at questions like "Write a program to output the smallest three-digit prime", where the GolfScript program 101 would almost certainly beat any program in any language which actually did work. Jan 12 '18 at 18:57 • And as specified in the answer, it's better to downvote such challenges. Thanks. Jan 13 '18 at 2:07 • I fell it's not a loophole to answers, but a requirement to questions – l4m2 Apr 4 '18 at 4:57 • Is f=n=>[1,7,31,105,300,754,1712,3576,6975,12871][n] valid for codegolf.stackexchange.com/questions/170437/… ? Aug 11 '18 at 16:38 # Fake random numbers Pretty much any challenge involving random numbers will have someone post this one: int getRandomNumber() { return 4; //chosen by fair dice roll. //guaranteed to be random. }  It was funny when Randall Munroe did it 7 years ago, not anymore. It has been used in many challenges, some even multiple times in the same challenge. • Can I assume you're not including seeding a PRNG to force a known sequence? I see that as related, but different. Jun 17 '14 at 14:55 • @Geobits: Correct, I am not including seeding the PRNG in this one. Jun 17 '14 at 15:12 • This works the same in any challenge type. When the challenge looks for a random number, there needs to be some randomness. Jun 17 '14 at 15:12 • Strange that 100% of those rolls resulted in four... Not so random or fair, eh? Jun 22 '14 at 4:28 • Related to that, I'm also sick of that comic being referred to so often. Aug 22 '14 at 17:00 • Actually is random number generator, just P(4)=1. Dec 23 '15 at 22:06 • @duran: No, it is P(x)=4 for all x in reals with probability 1, therefore it is not random but completely deterministic. Dec 23 '15 at 23:43 • But a constant is a random variable too! :D Dec 23 '15 at 23:53 • Someone's gotta make a language that takes 4 as a random call, or maybe one that has randomly mutating constants. Jan 26 '16 at 9:43 • I think someone doesn't get it. The chance of rolling a 4 on any single throw is the same as any other number. It's only when you roll it many times that it becomes increasingly unlikely, but not impossible to get 4 every time. In fact, for n rolls, any specific sequence of n results is equally likely. Feb 18 '16 at 0:44 • @CJDennis: There is no dice, there is only 4. It is 4 for all eternity, so it's not particularly random. But that's irrelevant to the fact that it's played out. So I think, if anyone, it is you who doesn't get it. Feb 18 '16 at 2:24 • The XKCD comic was funny. The first person to actually use this was not funny (and every person thereafter). But you can't prove that a sequence of all 4s was not generated randomly without examining the code as it is a valid (but incredibly unlikely) sequence. Feb 18 '16 at 2:35 • @CJDennis: The comic was funny when it was written 8 years ago. It's not funny anymore. Hence, it being added to the "loopholes that are forbidden by default." And since we're displaying code here, your last sentence appears to be a complete non sequitur. Feb 18 '16 at 2:37 • Randall Munroe, and Scott Adams Jan 16 '17 at 4:56 • [underhanded] is dead, so should this be deleted? Mar 12 '18 at 2:05 # Copying an (unimproved) answer from elsewhere If it's not your own work, and you can't even try enough to golf or improve it, then it's not yours to post. • +1, although this could be argued to be acceptable if you really think the answer is optimal and cannot be improved. It might be good form to mark the answer as Community Wiki in that case, though. Feb 24 '14 at 9:42 • This shouldn't need stating, because it's already a copyright violation and liable to flagging for deletion due to non-compliance with the terms of service. Feb 24 '14 at 10:36 • @PeterTaylor Agreed; however, I have seen just such an answer occur in the past week, so it cannot hurt to hammer home the point in more than one way. Feb 24 '14 at 15:16 • @IlmariKaronen In that case, I agree the thing to do is mark it as a CW and link to the original source with a mention of the author. But even so, in the spirit of the site, I would hope to see at least a "Here's my best attempt at golfing this answer, but as you can see it just can't be improved." Feb 24 '14 at 15:21 • This can happen accidentally when two people post near the same time, or when the later poster just doesn't read the existing answers fully. Still shouldn't be allowed, but I feel this is less of a "loophole". Apr 8 '14 at 19:30 • As long as the answer is marked CW and publishing it under the original license is possible (e.g. SE answers are CC by-sa 3.0, so as long as you mention the author and publish on SE you're in the clear) I don't see any problem with it. Don't forget codegolf is on SE and also a Q&A site, not a gaming site. And if you don't like others 'using' your answers don't publish on SE. Jun 22 '14 at 18:21 • I once had a guy rip off my answer almost entirely, which made extensive use of little used quirks in C#. His first answer did not even solve the problem, so he took my logic and made it a loop rather than tail recursive. Thankfully, mine was still smaller, but it really rubbed me the wrong way. He even copied my explanation for how it worked, with his own style. Crazy. Jan 24 '18 at 22:18 • @PeterTaylor not a violation if it's copied from another SE site, or other appropriately licensed source, with any requisite attribution. Feb 20 '19 at 21:36 ## Adding input or rules which weren't explicitly mentioned in the challenge There was recently a case where an answerer claimed Nowhere does it say the program can't (also) ask the user what the [result] is. Adding additional input or new rules, because they haven't been explicitly forbidden, can considerably simplify the challenge or make it trivial. That's certainly not in the spirit of any challenge. • Do you have a link to this, or was it deleted? Jun 30 '14 at 22:07 • @PeterTaylor codegolf.stackexchange.com/a/32725/8478 Jun 30 '14 at 22:09 • I think this is a bit too broad and certainly curtails any out of the box thinking which may actually be amusing or creative. I do imagine the issue you want to tackle to get annoying, but I'm inclined to think that if a question has specific loopholes that this particular meta has not covered, it is either the fault of the question or the loophole should be added here in it's specific form. Jul 22 '14 at 12:47 • @jaybz Feel free to reword it to make it a bit more precise. I just thought if I'd write "taking the result as an additional input" it would be too narrow. "Taking more input then specified"? Jul 22 '14 at 12:50 • @MartinBüttner I had a previous reply but I deleted it because I just realized something. I believe Outsourcing the real answer and Fetching the desired output from an external source essentially covers that particular case and any similar cases. Jul 22 '14 at 13:33 • @jaybz I feel like someone said that before (and must have deleted the comment). Basically, while those two have quite generic titles which might cover this case, their descriptions seem to aim very specifically at downloading things from the web - one the answer, the other the program that solves the problem. That's why I added my answer in the first place. Jul 22 '14 at 13:39 • @MartinBüttner In that case one of those two needs to be a bit broader than they already are. Obviously though, care needs to be taken not to make the loophole descriptions too broad and while I initially didn't want to combine those two for that reason, your recommendation and link convinced me otherwise. They're not even funny the first time. Jul 23 '14 at 4:57 • Reminds me of this xkcd comic. Dec 18 '15 at 18:08 # Zero-length quines Considering an empty program a quine was original in the 1994 IOCCC. Over two decades later, if you can answer a question with an empty program and that question is scored by length (e.g., ) and is tagged as , or , just notify the OP. • I mean technically, it is a quine, since the source is nothing and it outputs nothing Jan 15 '17 at 5:33 • @TrojanByAccident Quine: a non-empty computer program which takes no input and produces a copy of its own source code as its only output Jun 26 '17 at 13:58 • In stack based languages without other output, does stack content count as output? In that case in RPL you can get a 1-character quine, like 7, which pushes number 7 onto the stack. Maybe the way to counter it we would want the stack to contain the program listing in a string, so 7 wouldn't count as it would produce 7 rather than "7". Nov 8 '17 at 15:16 • @Heimdall Improper quines is its own loophole. Nov 8 '17 at 15:21 # Using a different name for something that's prohibited The title is not very clear, I know, but this is what it means: if a specific function is prohibited, someone can use a language where another term than "function" is used (for example "subroutine"), and then that user can claim that their submission is valid because they aren't using a function but a subroutine. • Seems to be the same as this one: meta.codegolf.stackexchange.com/a/1077/18865 Jul 2 '14 at 23:40 • @SimonAndréForsberg It looks quite different to me. That one is about using functions with different names (for example, using add if + is forbidden). This one is about, for example, using a specific subroutine (if it's called like that in your language) if the equivalent function is forbidden (for example, using the "subroutine" add in your language if the function add is forbidden). Jul 3 '14 at 6:25 • "subroutine"/"function" or "add"/"+", it's all about using the same functionality with another name. Looks very related. Jul 3 '14 at 9:54 • Yes, it's certainly related. But not really the same. Anyway, it does not hurt having this loophole in another answer. Jul 3 '14 at 10:01 • This would seem to apply only to a "Do X without Y" question, which is normally a sign of a bad question. Feb 24 '19 at 16:36 • @ProgramFOX But it's certainly ironic. May 12 '19 at 15:30 • @wizzwizz4 If my memory got it right (it's been almost 5 years since I added this loophole after all), I had seen at least one non-ironic usage of this. Or I missed the irony. Who knows... May 12 '19 at 15:41 ## Identical functions with different names For example, if + is forbidden, using num3 = num1.add(num2)  or num3 = num1 num3 += num2  or num1++  or (GolfScript) )  etc. • This is usually semantics. When posting restrictions you have to specify that the restriction applies to all functions and not just that specific one. After that all posts that try to circumvent this can be downvoted/flagged as not an answer Feb 25 '14 at 14:11 • I see a big difference between addition and increment. Unless you would interpret "* is forbidden" as banning +, I don't think you should interpret "+ is forbidden" as banning ++. Mar 5 '14 at 10:23 • For + and add I am on your side. Than again if / is forbidden, I would not assume % (modulus) is forbidden (and for the same reason I would allow ++ when only + is explicitly disallowed). Mar 7 '14 at 16:56 # Using a non-free language on a Cops and Robbers challenge Most (currently all) cops and robbers challenges consist of two parts: A cop submission, where a user posts some secret property of a program, such as its output, a scrambled version of the code, etc. Then, other users, the robbers, try to deduce the original program, or another program with the same properties. An important implicit condition of such a challenge is that it is possible for the robbers to try out many variants of the code to find the true solution. While a cop submission where this is impossible would ostensibly do well, it is not in the spirit of the challenge, and is in fact a loophole. Therefore, pay-for-use languages are banned from competition in CnR challenges as a loophole. Some popular languages which are thus banned are: • Matlab • STATA However, non-free languages may still be submitted as non-competitive entries so as not to exclude potentially interesting cops from being posted altogether. If these are cracked, the crack should also be marked as non-competitive. • You forgot Mathematica. ;) What about paid-for languages with free trials though? Oct 18 '15 at 8:26 • And what about Matlab and Octave? Oct 18 '15 at 9:30 • @MartinBüttner If the free trial can expire, and block a user from using that language afterwards, it's still no good. Oct 18 '15 at 16:01 • @BetaDecay Octave is fine. Matlab isn't Oct 18 '15 at 16:02 • I think this warrants a separate meta discussion to decide what is free enough for a CnR. For example, is it enough if there is a free online interpreter, or if there is a free interpreter that works only with a particular OS? Oct 18 '15 at 16:12 • Such as AppleScript. Oct 19 '15 at 18:18 • Mathematica is so popular on this site. TinyMUSH, although free, seemed much worse than that... Oct 22 '15 at 9:45 • TI-BASIC for the TI-84+ can be emulated easily, but it's technically illegal to do unless you own a calculator. I don't know where that would fall. Nov 7 '15 at 6:09 • Are there any platform-specific languages? Dec 19 '15 at 16:07 • @ASCIIThenANSI Well most assembly languages, for instance Dec 19 '15 at 17:00 • @AlexA. started a discussion about the free-ness here. Dec 27 '15 at 10:08 • Note: Mathematica can now be used freely online. Nov 19 '16 at 1:59 • We might want to have some rules for this in normal code-golf as well, or else: "My solution to this insanely hard code-golf challenge is the empty program in this language I invented. Trust me, it works. You can verify for yourself by buying the interpreter for$1,000,000." Mar 8 '17 at 6:01
• @isaacg I think Beta Decay meant that matlab code can be (mostly?) checked with free octave, as they have compatible syntax.
– jena
May 12 '21 at 13:38
• How "official" does a free method of language access have to be? I imagine you could claim that some pay-to-use langs are free because you can keep making new email addresses for the free trial to use the language forever. Jul 25 '21 at 11:41

# Using prior knowledge to circumvent other loopholes

In particular, gaining an unfair advantage by inventing new languages for future challenges that are being sandboxed, discussed in chat, are your own, etc.

For example, creating a language that solves a task specified in a sandboxed post with a one-character built-in (or even a zero-byte solution) should be forbidden for challenges.

Likewise, publishing an interpreter MetaGolfscript-X just in time for a challenge should not be allowed.

This does not cover cases such as the creation of ??? for The Programming Language Quiz, since there is no advantage in using this particular language for the challenge.

• Does this mean that if you write a language to golf easily, you can't use for challanges? Sep 7 '15 at 22:44
• @Lucas Inventing your own golfing language is perfectly fine, but you cannot incorporate a one-character built-in for something that is already in the sandbox. That's a) unfair and b) boring. Sep 7 '15 at 23:26
• Just use first sandbox post date as acceptable language deadline instead of actual question post date.
– Vi.
Sep 30 '16 at 14:05
• @Vi. That's not always the right call. This issue came up because ??? was created for The Programming Language Quiz, which was discussed heavily in chat. Conversely, some challenges are sandboxed for years before they get posted. Sep 30 '16 at 15:36
• @Dinnis, Then maybe allow using languages created even after the challenge officially started provided they are developed independently of the challenge participant?
– Vi.
Sep 30 '16 at 16:02
• I think Using prior knowledge to circumvent ... may be genuinely intertesting if the method and style is innovative, not just boring re-application of prior hack. Prior art => forbidden loophole; no prior art => good answer (although maybe a non-competing entry). Like "best abuse of rules" in IOCCC.
– Vi.
Sep 30 '16 at 16:05

# Using MetaGolfScript

MetaGolfScript is a family of programming languages. For example, the empty program in MetaGolfScript-209180605381204854470575573749277224 prints "Hello, World!".

It is similar to using extra command line arguments, where they should also count as characters. And using the standard interpreter is likely using the program name to store data, except it's the interpreter's name. But someone can build a website with a fake directory a directory compressed by a special purpose compression algorithm like all our Kolmogorov complexity challenges, of all MetaGolfScript languages, each with an interpreter can run independently with its filename. They can also use generated descriptions and random code obfuscations to make languages not similar to each other, and it will be hard to say it's still an argument or configuration somewhere.

• Isn't this covered by "languages must have an interpreter before challenge was posted"? Or "made up languages" more specifically? Apr 14 '15 at 19:07
• @Geobits Someone can make interpreters for MetaGolfScript before those challenges posted. At least they can be appeared to exist on the internet. Apr 14 '15 at 19:19
• I guess, but that's just plain "lying" or "cheating", not a loophole. Even so, I'd suspect a torrent of downvotes on any such answer to speak for itself. Apr 14 '15 at 19:21
• Well, I think I'll delete this after a few days. Apr 14 '15 at 19:25
• I agree that this is obvious and shouldn't need to be a loophole. However, we've recently seen this yet again, so it is clear that we really do need a place to state the obvious and point people to. Aug 24 '15 at 17:26
• I think this is covered by the interpreter needing to predate the challenge. A generic MetaGolfScript interpreter would need command-line arguments to tell it what variation of the language you wanted, and you'd have to pay for those; that's fair. An interpreter for a specific instance of the language (i.e. one specific program) predating the challenge would have nothing to do with MetaGolfScript itself; it'd be more logically akin to the Hello, World program in Stuck.
– user62131
Mar 18 '17 at 1:49
• @ais523 You could implement a special purpose compression algorithm, and release the interpreters in that format. Apr 28 '17 at 9:01
• I think it's ok as long as it works as with using the file name etc. The language name part 209180605381204854470575573749277224 should be included in the byte count making it longer than eg GS version. Jul 17 '18 at 15:18
• I think this should be extended to include the perl -nF/(?{s-.*(??{!($&=~y&R&&c==$&=~y&L&&c&&$&=~y&U&&c==$&=~y&D&&c)})--g;print})(*COMMIT)/ language family, now that we consider all of these as different languages as well (codegolf.stackexchange.com/a/205249) Jun 2 '20 at 4:18

Note: There is now a separate question covering this loophole in more detail.

This is a issue mainly for , and variants.

Only in very few cases this seriously affects .

The issue is when someone post a function, a method, an instruction or a code-snippet instead of a complete program. And then score his/her answer based on only what was posted. This gives an unfair advantage over who posted a complete solution.

Here is an example of a complete C Hello World program in 53 bytes:

#include<stdio.h>
int main(){printf("Hello World!");}


printf("Hello World!")

• Provide an example? I don't see anything wrong with this, as long as the snippet does what is required.
– Doorknob Mod
Mar 2 '14 at 21:21
• @Doorknob Ok, done. Mar 2 '14 at 21:29
• In general this is a case where it's the question at fault: vote to close as unclear any question which doesn't specify whether the code supplied should be a full program, a function, an expression. Mar 2 '14 at 22:58
• @PeterTaylor, ok, but first, we should put it in a comment and see if the OP fixes this quickly, so no one need to worry with closing and eventual reopen. If he/she takes too long or choose to not handle the issue, it is already commented the exact close reason, and eventual answerers would see the comment too and become aware of the issue. Anyway, there could be people doing this on purpose using some more esoteric languages where most people do not sees the difference between an expression and a complete program, and even the ones that do, do not become aware that it is a cheating answer. Mar 2 '14 at 23:16
• Could you give a better example, that can be easily outdone with echo Hello World! in bash unless the question says the answer is required in C Mar 12 '14 at 10:49
• Well, printf("Hello World!") is obviously nonsense, but main(){printf("Hello World!");} compiles with GCC. Mar 25 '14 at 22:42
• Probably alone in this, but to me it sounds perfectly fine to leave the template-y stuff out. It in no way subtracts from the originality needed to write a short answer, but it does allow a lot more languages to compete in codegolf. True, it would be good to describe per language what one considers default stuff, but I doubt there would be a lot of discussion about it. Jun 22 '14 at 18:15
• There is a more recent meta post for this specific topic here. Dec 28 '15 at 14:59
• This should include Java answers where the answerer posts a function/method/subroutine/whatever outside of a class/interface/enum. Jun 28 '16 at 18:41
• @dorukayhan EXACTLY - This was precisely what I was thinking for when I originally posted this a few years ago. Jun 28 '16 at 20:03
• @Doorknob This Way Java will never suck for code golfing Oct 26 '21 at 14:10

# Suicidal entries to King-of-the-Hill challenges.

EmoWolf was funny the first time, but it's getting out of hand.

While some not-too-serious answers are often necessary to kickstart a challenge, purely suicidal answers put in little effort and tend to get more upvotes than serious entries, simply because they're "funny".

I'm not suggesting that other answers that are for jokes shouldn't be allowed, but this specific kind that is not even trying to do anything. Submissions should at least play the game, even if badly or in a funny way.

• I'd prefer if this loophole was a bit more closely cut to purely suicidal submissions. I find that joke submissions in general are very important to get many KotHs going. For instance, if people had only ever posted serious submissions to RPSLV, there would have been no game, since nothing can beat a uniformly random strategy with anything but luck. Furthermore, KotHs need many submissions to be fun, and a bunch of less serious submissions in the beginning help a lot to explore the strategy space and gather some popularity. Jul 31 '14 at 7:30
• @MartinBüttner I agree. That's what I tried to say in the last paragraph. I guess I failed. Jul 31 '14 at 17:17
• That last sentence does point in this direction, but I'm sure if it gets more upvotes as it stands it will be used in the future to justify downvotes for any sort of non-competitive KotH submission. I'll give rephrasing it a go later. Feel free to rollback or improve that any time. Jul 31 '14 at 17:35
• Out of hand? You don't say? Jul 31 '14 at 23:34
• In AlienWar (codegolf.stackexchange.com/questions/32782/…), I'm somewhat worried about solutions that only set the ability points and implement the methods trivially, like the Manager and Banana Peel. Well, some KotH games are designed to let trivial implementations thrive. Aug 10 '14 at 6:29
• Even purely suicidal submissions could still be a viable strategy, depending on the contest. If it works, and is allowed by the rules (especially when there's an explicit suicide action!), this really isn't much of a loophole.
– Bob
Aug 11 '14 at 2:28
• Surely the solution is to not specifically allow a 'suicide' command in the game?
– Rob
Jan 6 '17 at 4:02
• Suicidal entries to king-of-the-hill challenges are not serious cotnenders. Aug 17 '19 at 22:23

# Creating a new compiler for a language after a challenge was posted

There is some debate arising from this answer. He created his own compiler for the C programming language that extends the language specifications. It seems pretty obvious that this will be declared a loophole, to me at least, but I'm posting this for the record.

• I’d even go so far as to say that extending the language makes it a new and different language, and is therefore a special case of this Sep 24 '15 at 5:42
• @Timwi So would I, but the user in the linked answer wouldn't accept that fact. Sep 24 '15 at 13:55
• I would put it differently: answers may only make use of a language as it existed at the time the challenge was posted. If it depends on features added after the challenge was posted, it is invalid. But if you can prove your modification to the language has been published online before the challenge was posted, I don't consider this a problem. Dec 31 '15 at 13:45
• @user2428118 That's already a rule and is mandated. It's not a loophole. Dec 31 '15 at 15:49
• As the user referred to in this question, I still don't believe that this is a special case of existing loopholes. For example, a user could submit an empty source file written in the language Undefined (esolangs.org/wiki/Undefined) as a solution to any question, after requiring that the program be compiled with <new compiler that compiles empty source to xxx program>. That's making use of the language Undefined as it has always existed. Oct 24 '16 at 11:44
• @Donkey_2009 The goal in golfing is not to "get around" loopholes, which is exactly what you were trying to do. You're being intentionally dishonest in how you were answering. Languages are defined by their implementation, and the compiler is part of the implementation. Your all-new compiler did not exist at the time the question was posted. It is also a forbidden loophole now, simply because it has 33 upvotes establishing meta consensus. Oct 24 '16 at 14:18
• @mbomb007 I was one of the 33 people who voted for this, and I take issue with your statement that I was intentionally dishonest. I was always completely open about how my solution worked and that the compiler did not exist before the question was posted. And I think you'll have a hard time backing up your statement that 'languages are defined by their implementation', particularly for a language like C, for which there are numerous official standards available. Oct 24 '16 at 14:26
• @Donkey_2009 It's meta consensus that on this site we define a language by its implementation. Every implementation is considered unique. "We", meaning, all of us. Oct 24 '16 at 15:21
• @Donkey_2009 And you have to realize, we all disagree with you. Your comments in the discussion on your answer that was invalidated show that you still don't get it, and are trying to rationalize your usage of something we determined to be forbidden. Oct 24 '16 at 15:29
• @mbomb007 A word of advice - when you're trying to convince someone of a point of view, it's actually counterproductive to adopt an attitude that they're being "intentionally dishonest", that they "won't accept" things and that they "don't get it", and to adopt a combative and offensive stance when talking to them. I don't know where all this anger is coming from when I have always tried to be reasonable. I have, by and large, agreed with the community and accepted their point of view, mainly thanks to other users who have been more polite to me. Oct 24 '16 at 17:19
• Thanks anyway for pointing out the meta consensus on how a language is defined on this site - I'm not sure how I missed that, but now I've done a quick search I've found some posts about it. So I apologise for calling that into doubt earlier; I genuinely didn't realize that that was the official consensus and thought that it was just an opinion held by some users on this site. Oct 24 '16 at 17:22
• My anger is only now, because you're bumping this and it's more than a year old, and you still didn't get it, apparently. Oct 24 '16 at 18:25
• Your post leaves a loophole itself: building a transpiler is still possible! Apr 14 '18 at 14:53
• @RedwolfPrograms We don't allow languages to be posted unless they have an interpreter. A transpiler wouldn't be enough to allow an answer to be posted. Apr 14 '18 at 20:48
• @mbomb007 Just a joke. I knew about the interpreter-only rule already. Apr 14 '18 at 22:04

# Abusing native number types to trivialize a problem

It is common practice to restrict challenges to cases where input, output and/or intermediate values of the algorithm of choice fit into the language's native number type. At least for input and output, this is generally assumed even if not stated in the challenge specification.

There are at least two ways to abuse this:

1. Using a language like Boolfuck which only has a 1-bit integer type.

With one bit of input and one bit of output, there are only four different Boolfuck programs that can solve all challenges.

So far, at least two answers have done this:

2. Deliberately exceeding the precision limit.

I don't know if this has been done before, but one could start by computing A(4, y) for input y (a 19,728 digit integer for y = 2), and then do anything that works for inputs 1 and 0.

As a rule of thumb, I'd say an answer abuses the native number type if the code would require non-trivial modifications for larger number type.

Examples:

• Implementing bit rotations as

(x << n) | (x >> (32 - n))


for 32-bit integers is allowed; only the 32 has to be changed to make it work for, e.g., 64-bit integers.

• Hardcoding a list of the prime numbers below 128 is not allowed in a challenge that involves primality testing, even if the language of choice only supports signed 8-bit integers.

• I'd say instead that the flaw is in the challenge, and the default should be that the algorithm should work for all ℕ when precision/range limits are disregarded. Feb 11 '16 at 5:07
• I don't think this is a problem, but a solution. Good on those users for thinking outside the box.
– user56309
Sep 12 '16 at 19:16
• @tuskiomi The first time it was used was clever, but this trick could be applied to pretty much all challenges that do not state in what range the submissions must work. Sep 12 '16 at 19:56
• @Dennis I'd say, if the input doesn't match the challenge, it isn't an appropriate answer. It's arbitrary at this point that ints are 32 bit, doubles 64, floats 32, shorts 16, bools 1/8, and Strings are infinite.
– user56309
Sep 12 '16 at 20:03
• I know it's years since this was posted but I had a thought. "Hardcoding a list of the prime numbers below 128 is not allowed" -- what about including the single 128-bit value 0x800228A20208828828208A20A08A28AC or binary 10000000000000100010100010100010000000100000100010000010100010000010100000100000100010100010000010100000100010100010100010101100 which is a bitmap of the primes from zero to 127? Nov 7 '18 at 17:07
• @RossPresser That's still hardcoding. The format doesn't matter. Nov 7 '18 at 17:09
• For challenges that don't specify input ranges, this can go the other way: demanding a function works with 128 bits, 256 bits, etc. can be unreasonable for languages that only offer native support for 32 bit types. I think it's reasonable to accept 32 bit as a default sized input.
– qwr
Feb 7 '19 at 9:20
• @qwr Are you talking about the algorithm or the implementation? I don't think a submission in a "32-bit language" should have to support 64-bit input, but I do think the underlying algorithm should. Feb 7 '19 at 12:56
• I think the point is not abusing the fact that given limits of the language the set of inputs is finite, and the solution can be hardcoded. It is a particular case of the "do not hard-code" rule codegolf.meta.stackexchange.com/a/1063/25245 May 21 '20 at 16:34

# Optimising for the given test cases

This applies to s and things like , where you write some code that is measured by a criterion like runtime or size of your output (e.g. in compression challenges). These often employ an obviously finite set of test cases, because you have to measure the metric somehow.

It's not in the spirit of such challenges if an answer optimises exclusively for those test cases (e.g. by hardcoding them, which would usually allow you to compress them to a single byte or execute in milliseconds), but performing much worse for general/random input.

For variable-sized input there is no way around test cases (one can use some sort of big-O class for scoring, but those tend to not be accurate enough to distinguish submissions and they require proofs instead of just running the code), so the code of conduct should be that the algorithm is such that the test cases are actually representative for the implementation's performance.

This also means, that if you optimise your algorithm to perform well on the majority of cases (and worse on a handful of edge cases) and the test cases happen to be picked from that majority, that's perfectly fine. However, optimising for a minority of cases which include one or more of the test cases is not.

• +1, but also I think it would be useful guidance for question setters to either score on the worst-case input, or take such a wide variety of input that it's impossible to optimise. This is because it's hard to see from an answer whether it's been optimised for the test cases or 'happens' to give a good answer for a small amount of test input data. Nov 17 '14 at 18:57
• @abligh Yes, larger sets test cases help mitigate that, but even those can be hardcoded. And scoring by worst-case input only really works for fixed-size problems. Nov 17 '14 at 18:59
• With respect to: "but performing very badly for general input", the example that inspired trying to close this loophole permits performing optimally on all cases, yet still permit optimizing for the test cases. In that example, the result is effectively an integer between 0 and 6,670,903,752,021,072,936,959. It is easy to map n test cases to 0.._n_, resulting in compression to a single character (or less) for those cases, while having exactly zero impact on the average performance. So you may want to remove that condition to closing the loophole. Nov 17 '14 at 23:30
• By the way, detecting an optimization for the minority of cases may be extremely subtle. For example, simple choices in the ordering of what is looked at or the numbering of symbols could be optimized to improve performance on the test cases. Again having no impact on the average performance. This is fine loophole to try to close, but be prepared for ambiguity and arguments about whether it applies or not. Nov 17 '14 at 23:34
• I guess that's better. Nov 17 '14 at 23:35

## Generating all possible functions/programs to solve a challenge

In this meta post, isaacg pointed out that, under current consensus, the following Python code (edited to fix a mistake) could possibly be viewed as valid:

for i, code in enumerate(all_possible_strings):
try: exec("func" + str(i) + "=" + code)
except: pass


Given enough time, the desired function will eventually be generated and assigned to func<some large number>, which could then be called with the desired arguments and would return the desired result.

Though we do not forbid brute-forcing, solutions of this sort are clearly exploitative in the same vein as MetaGolfScript, and we certainly do not want this solution on every challenge where functions are allowed.

• Can you explain for non-pythonians what this snippet exactly does? Apr 26 '16 at 20:19
• @flawr For every possible string (enumerated with some running index i), it defines a function func<i> whose body is that string. Some of those will solve the problem at hand, and given any (ungolfed) solution to the problem it's even quite easy to reverse the process to figure out which number that is, so you could just submit that and then say "the function is named func102947812904". Apr 26 '16 at 20:22
• But in tat case function to enumerate strings should be included. Also, if we force to count length of function name in such case, it will be longer then function body itself. May 17 '16 at 13:02
• @Qwertiy The name wouldn't be included in the byte count, because it's trying them all. He's telling you so that the viewer knows which string was the one that runs. The name doesn't occur in the program's original code at all. May 18 '16 at 16:37
• @mbomb007, yes. But we have a rule about additional compilation keys - they are not inside of code, but they do count. So if we force to count name in this case - it'll solve problem with golf but would still allow to make some interesting things. May 18 '16 at 16:57
• Isn't this the Halting problem? What's to guarantee that you get to a solution in an infinite search space? Jan 16 '17 at 5:01
• @xdhmoore Given enough time is the key here - since we usually don't impose time restrictions in code golf, solutions which can take multiple lifetimes of the universe to complete are valid (assuming they don't break any other rules).
– user45941
Jan 16 '17 at 6:33
• I know that's practically correct, but that doesn't sound right math-wise. Maybe I'm missing something. Maybe math isn't the point :) Jan 16 '17 at 7:24
• You're going to lose if you use this because the name of the function is longer than the target. Apr 23 '17 at 15:42
• @xdhmoore You are correct in pointing this out. Once a non-halting program is discovered, the process of generating programs stops. But there is a well-known workaround: simulate the first function for 1 time step, then the first 2 functions for 2 time steps, the first 3 for 3 time steps, and so on. Now non-halting programs don't impede progress. I believe the technical term is dovetailing. Jun 2 '17 at 6:09
• This program is broken, since as soon as it evaluates "while true: \n&nbsp;&nbsp;&nbsp;&nbsp; pass\n", it infinitely loops and never reaches the end. Point is valid, but I would implement it differently: Have a pool of preemptible coroutines. Each iteration, add a coroutine to the pool corresponding to the evaluation of a string. The iterate over all coroutines. If one does not halt after a second, preempt it and leave it in the pool to continue on where it left off next iteration. This guarantees that all strings eventually get iterated over on an idealized computer. Nov 3 '17 at 3:08
• @eaglgenes101 The program is the wrong thing to focus on here.
– user45941
Nov 3 '17 at 6:25
• This is my kind of program...just let it run, and eventually it will create the next big thing Apr 14 '18 at 14:57

• I can't think of a recent challenge that required this; could you link to one where having a specific username would give you an advantage?
– user39326
Jun 20 '15 at 23:59
• Jun 21 '15 at 8:17
• I think the problem then would be in the question itself rather than the answer, since it is giving an unfair advantage for some people. I think no post should be dependant on the username/id Sep 22 '15 at 11:56
• Some users are just fond of changing their names; it would restrict our freedom. A really good question relies on the user number, which is rigid. The ones that rely on usernames can be regarded as “take any string you want, just do not forget to throw it on your settings page”. And sometimes you can do very witty things with that! Sep 9 '16 at 11:49
• my username is 1. <s>2-1</s> 3-2. How did I manage to mess that up?! Mar 25 '19 at 19:41
• This reminds me of Pokemon Blue Arbitrary Code Execution, because some depend on your trainer ID.
– mekb
Jul 12 '19 at 6:01

# URL shorteners / shortened URLs

Every once in a while, we get a challenge that requires fetching some data from the internet. While some of them manage to ban URL shorteners in time, other don't. I propose to forbid them by default because of the following reasons.

1. URL shorteners that were created after the challenge was posted are akin to adding a feature to the interpreter after the challenge was posted, and there's usually no easy way to determine when a shortened URL was created. They also outsource the "real" URL, which is more or less a violation of this loophole. Last but not least, it's oftentimes not possible to determine whether a given URL existed before the challenge was posted.

2. Using a non-canonical URL is not only a bit unimaginative and rather unrelated to programming, the same URL can be used in pretty much all answers. Every time someone finds a shorter URL, all other posts can be updated to use that URL as well. That's a very tedious and boring way of saving bytes.

3. In some challenges, API queries have to be made. Being able to fit a very complex query – which will make parsing its output easier – in the same amount of bytes as simple one actively harms the challenge; instead of coming up with clever ways to parse the output, the complex query is "golfed" down using a URL shortener.

URL shorteners are rather easy to identify. That leaves non-canonical domain names.

I propose counting all URLs on domains as shortened (and therefore forbidden) if the domain name isn't owned by the same individual/company as the canonical one. Thus, e.g., if the task at hand involves querying https://api.stackexchange.com, only URLs that belong to Stack Exchange, Inc. may be used in the challenge.

• Why, I don't really agree. The principle of code-golf is that you want to shorten everything - why not the URL? You should let OP decide for this, in place of saying it is a standard loophole. Actually, for every challenge using data from internet, the question 'can I shorten URL' is asked, and every answerer is at last using a bit.ly link. Jul 19 '17 at 13:46
• @V.Courtois The OP can still decide; this is just the default. Jul 19 '17 at 16:02
• I disagree with the final paragraph. I think it can be fun to get a long url by other means than to store it directly in the source code, and I think we should ban url shortening services specifically. That is information that you have stored somewhere else, and you may not do that, much in the same way that you may not create a language specifically to solve a question. Oct 25 '17 at 10:48
• I think the correct solution is to count the database entry on the URL shortener as part of the solution for the byte count. If custom code on the URL shortener is involved, then it all counts too. Jan 8 '20 at 12:47
• That last clause seems to have some pretty big loopholes, like if the company in question happens to operate a public URL shortener, then you can do whatever you want with it? I think the main consideration here is that if you're using a URL shortener, you're essentially storing code/data somewhere, and therefore you should count that data in your solution. Mar 18 '21 at 11:19

## Using a language's lack of features to trivialize a challenge

This is in the same vein as this other loophole.

Consider this challenge. Using a language that cannot access an Internet connection would be a violation of this loophole - it could simply output a falsey output all the time, because it would never be able to access the Internet.

• Challenge: "Check if this device is connected to the internet". If your language cannot determine that, it's the wrong tool for the job and therefore an invalid submission. All you can say fir sure is that your program is not connected to the internet, but it says nothing about the device as a whole. Jan 26 '17 at 14:53

# When consistent and distinct values are asked as input, you cannot input complete or partial functions

When I create a challenge and ask for a boolean or two 'consistent and distinct values' I mean it in the sense of a truthy and falsey value. Usually I leave the choice to the ones doing the challenge, since I don't care whether it's true/false, 1/0, "yes"/"no", etc.

I know just asking for a truthy/falsey value specifically in the challenges is also an option, but since 1/0 isn't considered truthy/falsey in for example Java or .NET C# and I still don't mind if they are used, this default loop hole would be relevant.

Since it isn't part of this default loopholes page yet, there have been answers in the past which input partial or complete functions, if the challenge rules allow this loophole. This JavaScript answer for example, takes the inputs as '/\n|-DI>-/---< ' for left, '/\n|-DI<-\\---> ' for right. In the challenge description it states:

the other being one of two distinct, consistent values of your choice (1 / 0, l / r, left / right, etc.)
...
Standard loopholes are forbidden.

Although original, and it does comply with the challenge description above, I think it would be wise to prevent these kind of partial or complete functions as input in the future. What would prevent someone from having the fictional program run param where the param is a complete program when a truthy value is asked, or a different complete program when a falsey value is asked? Also sharply mentioned by @darrylyeo as comment on that same challenge:

JavaScript, 4 bytes: eval - Input a program that generates a left-facing plane for left, and a program that generates a right-facing plane for right.

Related: Using the program name to store data without counting those bytes
In this related loophole the file-name is counted towards the byte-count. But I don't think adding the two values to the byte-count is a good idea either, otherwise the 1/0, true/false should also be counted. Where do we draw the line of which inputs should be counted towards the byte-count, and which shouldn't? So just preventing these kind of inputs as standard loophole would be better in my opinion.

• Where will you draw the line between valid and invalid here? I can't think of a borderline case right now, but I think there might be some grey area here and we need to be able to make a definitive objective decision about it.
– hyper-neutrino Mod
Oct 27 '17 at 14:08
• @HyperNeutrino I agree. Been thinking the same thing just yet. I remember seeing some answers with parameters like A/null, using the A for something in the code if present, which is part of the grey area you're talking about. So I'm also not sure how to consistent and definitively define it. Maybe never allowing string/text inputs, but I can imagine there are some programming languages out there without boolean nor number inputs and only have string parameter options. So yes, I definitely agree it should be specified a lot better, but I'm not sure how (yet). Oct 27 '17 at 14:14
• I consider this is most similar to extra inputs; specifically it's "hiding" extra inputted information inside an input which IS part of the challenge specification. I'm not certain of a good way to objectively distinguish when that happens though. Oct 27 '17 at 19:14
• One possible rigorous definition of falling into this loophole is this: Suppose that the program expects foo as an input for the program, and take bar to be an arbitrary alternate input that we want the program to accept instead of foo. If patching the program to accept bar instead of foo would entail translating bar into foo or otherwise incorporating a portion of foo into the program, it falls under this loophole. (I have a sneaking suspicion that this doesn't work quite right for data typing-based inputs, but that's what other heads are for, right?) Dec 4 '17 at 4:05
• Can I do this but add the byte count of input function?
– l4m2
Dec 30 '17 at 4:57
• While I agree with the intent of this post, the wording needs work. 1, 0, l, and r are complete functions in Jelly. May 8 '18 at 15:17
• @Dennis Hmm.. good point. But what would be a good alternative wording. Feel free to edit it as you see fit, btw; it's a community wiki for a reason. May 8 '18 at 15:20

# Outputting an expression instead of a number

For example, outputting 3*3 instead of 9, or outputting 7/4 instead of 1.75.

Unless the challenge explicitly allows expression output, the output should be in a number format where a number is requested.

As the comments point out that what counts as a number format is hard to define, there's a separate meta discussion Which number formats are acceptable in output?

• This is common sense. It shouldn't even need to be written down. +1. May 26 '16 at 17:38
• It never occurred to me to write it down until someone asked if they could use it, and I realised I didn't have a place to point to in order to say no... May 26 '16 at 17:39
• I think this is a bit fuzzy. Yes, you shouldn't be allowed to output a expression, but some things (Like 2/3 vs. 0.6666) should be allowed IMO. May 26 '16 at 17:41
• Perhaps we need a new meta post to cover which number formats are acceptable by default (for things like .1 instead of 0.1 and scientific notation and rationals and symbolic constants). May 26 '16 at 18:44
• I posted a more detailed meta discussion May 27 '16 at 3:59
• I think this would kill creativity. If it is asked to output 14 and your programme prints 2*7 or 2×7 or 2·7, normally a sane person would write a code that evaluates to 14 because printing an expression is seldom easier. There are a bunch of hugely upvoted answers that, for example, print ASCII art instead of numbers, which is even more creative. And throw a rock at me if 7·2≠14. Sep 9 '16 at 11:39
• @AndreïKostyrka In Bases 8, 9, B-D and F-\inf it isn't... :-) Oct 2 '16 at 11:30
• It's hard to define this clearly. Is 1e2 an expression or a number? Is 1e9? Is 1.43e20? 1.43e22? (FWIW, Javascript expands 1.43e20 but ouputs 1.43e22 as is...) Jun 5 '17 at 5:51
• @SteveBennett yes this topic proved to be worth its own separate meta discussion (see my previous comment), and there are a variety of answers there covering more detail. Feel free to add another answer each time something turns up that is not covered. Jun 5 '17 at 11:41

# Improper quines

We've reached consensus on what counts as a proper quine over a year ago, yet the occasional "quine" that consists of nothing more than literals and/or NOPs still comes up.

While these answers used to be tolerated (and, on occasions, applauded) unless the challenge specifically asked for a proper quine, the community has recently started to downvote and/or delete improper quines even if the challenge didn't explicitly disallow them.

This course of action is a sane default; almost all quine-related challenges are rendered trivial if the program 1 is deemed quine enough for a submission. To back these actions with community consensus, I therefore propose the following.

If the challenge asks for quines and its spec doesn't explicitly allow improper quines, all submissions have to be proper quines.

If the challenge mentions quines and/or is tagged with , a program that would count as an improper quine (if its output matched its source code) is likewise disallowed.

• what is an improper quine, de facto? Jul 19 '17 at 13:55
• @V.Courtois cat \$0 in Bash or This is a quine. is PHP. Jul 19 '17 at 16:03

## Generating a random stream of output when a specific output is required

For example, if a challenge requires you to output 4, you can't output an infinite stream of random digits, and say "4 is in there somewhere!" You must output 4, and no other number.

This is similar to this other loophole.

• I would not consider this as a loophole. This just does not meet the specifications of the corresponding challenge and is therefore invalid. Why do you want to explicitly add this as a loophole? Jun 27 '16 at 8:23
• +1, but it's essentially covered by meta.codegolf.stackexchange.com/q/8379/8478 if you consider the RNG's seed as part of the program's input. Jun 27 '16 at 8:25
• @MartinEnder Good point, I didn't think about that meta post. I don't think it hurts to have it explicitly stated here as well as on that post.
– user45941
Jun 27 '16 at 8:26
• @Mego I think what is allowed or isn't should always be clear from the challenge itself. Can you provide an example where we need this loophole rule? (Where this is not alredy clear from the challenge itself?) Otherwise I think this is a tautology, which does not make any sense adding here. We could write a ton of others such as "loophole: if the output must be true you cannot output false" The challenge requiring you to output 4 does exactly imply that you cannot output any other number. Jun 27 '16 at 8:31
• @flawr here, before I added the word "deterministically". Jun 27 '16 at 8:33
• If you do not add deterministically your challenge really asks for the infinite monkeys solutions, which would be perfectly fine under these challenge rules. I can imagine that the loophole as it is now would restrain certain solutions for code-challenges or popularity-contests. I suggest rephrasing it, as it does not really catch the problem of LeakyNun's challenge. My suggestions: "Generating a random sream of output when specific output is required" with "For example, if a challenge requires you to output 4, you cannot output and infinite stream of random digits.". Jun 27 '16 at 8:42
• @flawr I agree with your improved wording and have made the edit.
– user45941
Jun 27 '16 at 10:15
• I still think that if the challenge requires you to output 4 and you output something like 8 7 1 2 4 3 5 6 you simply don't meet the specs Jun 27 '16 at 11:57
• @LeakyNun, if this is really a problem with that question (and I agree with those who are saying that it isn't) then adding the word "deterministically" doesn't fix anything. If finding the desired output somewhere in the middle of a stream of junk meets spec then the stream can be generated deterministically for fewer characters than required to generate it randomly. Jun 27 '16 at 16:01
• @LuisMendo Right, this is all in all quite similar to this loophole, so they could probably be merged? Jun 27 '16 at 17:42
• @flawr I'd say it's not even a loophole, it's an answer that doesn't meet the specs Jun 27 '16 at 18:02
• @LuisMendo I wouldn't agree with that, since you could argue that the program has a chance to get the correct result (and not "chance" as in "clearly invalid program produces correct output because cosmic rays cause a bit to be flipped at the right time"). Often there is a very reasonable likelihood of getting the right output by chance, so you'll see a lot of programs on the Anarchy Golf server using randomness, although usually to select a canned output (which AFAIK is already a loophole here). Jun 28 '16 at 15:20
• I think this loophole description is too narrow. I suspect you also want something like 1. to be an invalid entry. It's a program which deterministically prints Graham's number in unary. It's followed by additional digits, but it's not simply a case of "Graham's number is in there somewhere": Graham's number appears right at the start, with nothing in between, and extra output at the end is generally considered to be valid. (Or should I post that as an answer? (: )
– hvd
Jun 28 '16 at 20:47
• @hvd I believe that is already covered by another loophole. I'd drop a link, but navigating this post on mobile is a nightmare. Look for "abusing number systems".
– user45941
Jun 28 '16 at 20:58
• @Mego That doesn't appear anywhere on either of the two pages of answers here, and I cannot find that using Google either. Could it be a answer somewhere that has since been deleted? Or are you mixing it with "Abusing native number types to trivialize a problem"? That doesn't cover my idea.
– hvd
Jun 28 '16 at 21:06

# Empty / Bare Output

Not sure on the best title but hopefully the examples show what I mean. Mainly targeting where the score is determined by the output. This results in very boring, but valid, answers which tend to get upvoted especially on pop-cons with no other answers.

An example: if the goal was to output the Mona Lisa as close as possible. Outputting a blank image should be considered a loophole.

Another Example: In a such as this one where score is determined by the most correct output. Always outputting false and claiming a score of 0 should count as a loophole.

• This is already forbidden by our rules. Answers must make a serious attempt at competing.
– user45941
Jan 31 '16 at 4:58
• Already mentioned in the help center.
– Doorknob Mod
Jan 31 '16 at 4:59
• I didn't think the "serious attempts" fully covered it because many of these types of answers can be considered "serious" attempts and still violate this loophole. I've reworded Jan 31 '16 at 5:00
• Your edits so far only describe what is already forbidden by the serious attempt rule.
– user45941
Feb 2 '16 at 2:14
• I think that if the empty output actually gives a good score, then it should not be considered a loophole. If it was actually a serious attempt (which means that it would actually give a good score), then that means that it's a flaw in the challenge, not the answer Mar 17 '19 at 18:41