428
\$\begingroup\$

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.

Return to FAQ index

\$\endgroup\$
11
  • 135
    \$\begingroup\$ 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. ;)) \$\endgroup\$
    – Ry-
    Commented Feb 27, 2014 at 18:16
  • 19
    \$\begingroup\$ @minitech: And the countless variations of curl -L http://bit.ly/012foobar aren't? \$\endgroup\$ Commented Mar 2, 2014 at 14:59
  • 13
    \$\begingroup\$ @IlmariKaronen: Depends whether it’s actually clever. If you don’t find it clever, vote appropriately. As always. \$\endgroup\$
    – Ry-
    Commented Mar 2, 2014 at 15:57
  • 3
    \$\begingroup\$ @minitech, there seems to be a strong consensus that the appropriate vote is "Low quality, delete". \$\endgroup\$ Commented Mar 2, 2014 at 22:56
  • 49
    \$\begingroup\$ "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. \$\endgroup\$
    – derobert
    Commented Apr 14, 2014 at 16:05
  • 6
    \$\begingroup\$ @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. \$\endgroup\$ Commented Apr 14, 2014 at 16:31
  • \$\begingroup\$ @PeterTaylor Ah. I'm surprised "Using the program name to store data" isn't one of them, considering the +26 comment on it. \$\endgroup\$
    – derobert
    Commented Apr 14, 2014 at 16:51
  • \$\begingroup\$ @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. \$\endgroup\$ Commented Apr 14, 2014 at 16:57
  • 2
    \$\begingroup\$ 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. \$\endgroup\$
    – Doorknob
    Commented Apr 27, 2014 at 21:24
  • 1
    \$\begingroup\$ 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. \$\endgroup\$
    – trlkly
    Commented Jun 29, 2014 at 12:34
  • 1
    \$\begingroup\$ 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.) \$\endgroup\$
    – trlkly
    Commented Jun 29, 2014 at 12:46

56 Answers 56

471
\$\begingroup\$

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";
}
\$\endgroup\$
11
  • 314
    \$\begingroup\$ I believe you meant "Compiling the challenge too literally" :P \$\endgroup\$
    – Jwosty
    Commented Jun 10, 2014 at 17:21
  • 98
    \$\begingroup\$ @Jwosty not in this case, as PHP is interpreted. \$\endgroup\$
    – user23597
    Commented Jun 20, 2014 at 9:28
  • 15
    \$\begingroup\$ @Rokk Or is it? IT'S ALL A RUSE! \$\endgroup\$
    – Jwosty
    Commented Jun 20, 2014 at 15:59
  • 7
    \$\begingroup\$ 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. \$\endgroup\$
    – Fabinout
    Commented Jul 4, 2014 at 12:07
  • 39
    \$\begingroup\$ 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." \$\endgroup\$ Commented Sep 5, 2014 at 12:25
  • 21
    \$\begingroup\$ 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 \$\endgroup\$
    – Luis Mendo
    Commented Jan 25, 2015 at 18:02
  • 16
    \$\begingroup\$ @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". \$\endgroup\$ Commented Jul 16, 2015 at 8:54
  • 1
    \$\begingroup\$ @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) \$\endgroup\$
    – Luis Mendo
    Commented Jul 16, 2015 at 9:11
  • 15
    \$\begingroup\$ "the $n-th prime" is not the n-th prime. \$\endgroup\$
    – Khaled.K
    Commented Jan 19, 2016 at 11:59
  • 23
    \$\begingroup\$ @Jwosty I think you're interpreting the answer too literally. \$\endgroup\$ Commented Aug 21, 2016 at 6:13
  • \$\begingroup\$ @Khaled.K: Exactly. It is ridiculous that people on CG SE do not understand the difference between strings and their evaluation (if any). \$\endgroup\$
    – user21820
    Commented May 14, 2021 at 11:25
389
\$\begingroup\$

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.

\$\endgroup\$
8
  • 46
    \$\begingroup\$ Especially getting the highest voted answer from the selected wuestion \$\endgroup\$
    – TheDoctor
    Commented Apr 10, 2014 at 21:13
  • 106
    \$\begingroup\$ We could allow it, if the size of the external source is added to the size of the answer. \$\endgroup\$
    – vsz
    Commented Aug 30, 2015 at 21:21
  • 5
    \$\begingroup\$ You mean a copy-paste answer? \$\endgroup\$
    – Khaled.K
    Commented Jan 19, 2016 at 12:01
  • 6
    \$\begingroup\$ @KhaledAKhunaifer, no, I mean an answer which saves bytes by replacing a large string with a wget or similar that fetches it. \$\endgroup\$ Commented Jan 19, 2016 at 14:33
  • 3
    \$\begingroup\$ @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. \$\endgroup\$
    – Khaled.K
    Commented Jan 19, 2016 at 16:06
  • \$\begingroup\$ some internet questions may need to do so, but source code itself still not allowed to just be fetched \$\endgroup\$
    – l4m2
    Commented Apr 4, 2018 at 4:58
  • \$\begingroup\$ codegolf.stackexchange.com/a/23968/59169 is an excellent example how this can be used creatively \$\endgroup\$ Commented Aug 11, 2019 at 14:36
  • 1
    \$\begingroup\$ @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. \$\endgroup\$ Commented Aug 11, 2019 at 16:20
338
\$\begingroup\$

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.

\$\endgroup\$
13
  • 153
    \$\begingroup\$ I think HQ9+ should no longer be considered made up. It's useless for almost all challenges, and can sometimes be used creatively. \$\endgroup\$
    – ugoren
    Commented Feb 23, 2014 at 14:53
  • 6
    \$\begingroup\$ 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. \$\endgroup\$
    – asteri
    Commented Feb 24, 2014 at 21:03
  • 127
    \$\begingroup\$ -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. \$\endgroup\$
    – SztupY
    Commented Feb 25, 2014 at 14:09
  • 11
    \$\begingroup\$ 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. \$\endgroup\$
    – manatwork
    Commented Mar 2, 2014 at 15:52
  • 5
    \$\begingroup\$ @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. \$\endgroup\$ Commented Mar 2, 2014 at 16:13
  • \$\begingroup\$ I'd bound this in with "get from external source" and other ways of hiding byte count. \$\endgroup\$ Commented Mar 12, 2014 at 19:11
  • 73
    \$\begingroup\$ 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+). \$\endgroup\$ Commented Mar 13, 2014 at 15:27
  • 2
    \$\begingroup\$ 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? \$\endgroup\$
    – Holger
    Commented May 27, 2015 at 11:54
  • 7
    \$\begingroup\$ @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. \$\endgroup\$ Commented May 27, 2015 at 12:56
  • 12
    \$\begingroup\$ 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." \$\endgroup\$
    – apsillers
    Commented Dec 18, 2015 at 15:06
  • 2
    \$\begingroup\$ 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. \$\endgroup\$
    – jimmy23013
    Commented Jan 5, 2016 at 9:11
  • 2
    \$\begingroup\$ Isn't that just called "a golfing language"? \$\endgroup\$
    – AJFaraday
    Commented Mar 8, 2018 at 9:10
  • \$\begingroup\$ MetaGolfScript is a notable one. \$\endgroup\$ Commented Apr 14, 2023 at 11:44
249
\$\begingroup\$

Note: as the tag has now been retired, this loophole is no longer relevant.

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);
}
\$\endgroup\$
11
  • 20
    \$\begingroup\$ 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. \$\endgroup\$ Commented Jul 9, 2014 at 18:52
  • 19
    \$\begingroup\$ @m.buettner codegolf.stackexchange.com/questions/28786/… codegolf.stackexchange.com/questions/12291/… \$\endgroup\$ Commented Jul 9, 2014 at 18:58
  • 114
    \$\begingroup\$ ugh, have an upvote. \$\endgroup\$ Commented Jul 9, 2014 at 19:01
  • 7
    \$\begingroup\$ This is why I set all my editors to show whitespace. \$\endgroup\$ Commented Nov 5, 2014 at 10:39
  • 61
    \$\begingroup\$ @MartinBüttner Ugh, have an upvote on your comment about having an upvote. \$\endgroup\$ Commented Apr 13, 2015 at 16:12
  • 93
    \$\begingroup\$ It should be r = 4. \$\endgroup\$ Commented Dec 6, 2015 at 19:54
  • 67
    \$\begingroup\$ Obligatory xkcd for that last comment: xkcd.com/221 \$\endgroup\$
    – user18932
    Commented Feb 23, 2016 at 3:16
  • 3
    \$\begingroup\$ 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. \$\endgroup\$
    – Heimdall
    Commented Nov 8, 2017 at 10:27
  • 10
    \$\begingroup\$ [underhanded] is dead, so should this be deleted? \$\endgroup\$ Commented Mar 12, 2018 at 1:59
  • 2
    \$\begingroup\$ It'll be easy to discover if the VERY random number is always 5 \$\endgroup\$
    – rydwolf
    Commented Apr 14, 2018 at 14:35
  • 1
    \$\begingroup\$ So we don't count characters when scrutineering ? \$\endgroup\$
    – mckenzm
    Commented Jul 10, 2019 at 4:40
185
\$\begingroup\$

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.

\$\endgroup\$
15
  • 304
    \$\begingroup\$ -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. \$\endgroup\$
    – SztupY
    Commented Feb 25, 2014 at 14:06
  • 16
    \$\begingroup\$ @SztupY It's absolutely standard for the filename to be the first parameter. argv[0] is the filename in C for example. \$\endgroup\$
    – user26400
    Commented Jun 21, 2014 at 13:57
  • 14
    \$\begingroup\$ It's quite standard for C executable to be named a.out. Can it be used without increasing bytes count? \$\endgroup\$
    – enedil
    Commented May 30, 2017 at 18:02
  • 3
    \$\begingroup\$ @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 \$\endgroup\$ Commented Jul 20, 2017 at 16:53
  • \$\begingroup\$ 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. \$\endgroup\$ Commented Jul 20, 2017 at 17:01
  • \$\begingroup\$ @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 ``. \$\endgroup\$
    – ugoren
    Commented Jul 20, 2017 at 18:12
  • \$\begingroup\$ 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. \$\endgroup\$ Commented Jul 20, 2017 at 18:15
  • 2
    \$\begingroup\$ 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? \$\endgroup\$
    – l4m2
    Commented Dec 1, 2017 at 8:12
  • 2
    \$\begingroup\$ @l4m2: What happens if I name it 1.cmd? \$\endgroup\$
    – SamB
    Commented Sep 21, 2018 at 21:17
  • \$\begingroup\$ @SamB Discuss both situation \$\endgroup\$
    – l4m2
    Commented Oct 1, 2018 at 13:05
  • 1
    \$\begingroup\$ 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. \$\endgroup\$
    – LWChris
    Commented Apr 24, 2019 at 17:23
  • 4
    \$\begingroup\$ It should just be 12. The backslash in the filename doesn't really exist on disk. \$\endgroup\$
    – S.S. Anne
    Commented Mar 22, 2020 at 21:40
  • \$\begingroup\$ 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. \$\endgroup\$
    – ilkkachu
    Commented Mar 31, 2021 at 14:25
  • \$\begingroup\$ Funny is that 286 users likes your comment, but only 24 people dislike the answer :P \$\endgroup\$
    – math scat
    Commented Jun 10, 2021 at 14:41
  • \$\begingroup\$ Is it ok to require a certain filename, even when it is not used to store data? One example would be this bash script named 0 $1||exec 0 $(($1-1)) which calls itself with a lower argument (recursive) till it reaches 0. Do i have to count the script name or not? \$\endgroup\$ Commented Jul 21, 2023 at 15:10
176
\$\begingroup\$

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.

\$\endgroup\$
6
  • 6
    \$\begingroup\$ +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. \$\endgroup\$
    – SztupY
    Commented Feb 25, 2014 at 14:12
  • \$\begingroup\$ @SztupY But much of the time, they aren't link only answer. They in fact do contain some working running code. \$\endgroup\$ Commented Feb 25, 2014 at 15:59
  • 85
    \$\begingroup\$ 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. \$\endgroup\$ Commented Feb 27, 2014 at 12:08
  • 12
    \$\begingroup\$ I agree with Ilmari - fetch code and fetch answer are two sides of the same coin. A very low-valued coin. \$\endgroup\$ Commented Feb 27, 2014 at 14:56
  • 6
    \$\begingroup\$ I think all networking should be banned unless explicitly allowed in the question.. \$\endgroup\$ Commented Aug 1, 2014 at 17:41
  • 13
    \$\begingroup\$ 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. \$\endgroup\$
    – Atsby
    Commented Mar 23, 2015 at 3:32
143
\$\begingroup\$

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.

\$\endgroup\$
10
  • 202
    \$\begingroup\$ Often, this vulnerability is an indicator of a dumb question... \$\endgroup\$
    – boothby
    Commented Mar 7, 2014 at 19:37
  • 28
    \$\begingroup\$ 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. \$\endgroup\$ Commented Mar 13, 2014 at 15:23
  • 4
    \$\begingroup\$ How does Bubblegum fit into this? It seems to be designed to kill pure kolmogorov-complexity questions. \$\endgroup\$
    – CJ Dennis
    Commented Feb 18, 2016 at 1:12
  • 4
    \$\begingroup\$ @CJDennis Unless the question is an obvious exception (the primary exception being those tagged kolmogorov-complexity) \$\endgroup\$
    – user45941
    Commented Mar 3, 2016 at 0:29
  • 1
    \$\begingroup\$ 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. \$\endgroup\$
    – Paper
    Commented Sep 30, 2016 at 18:12
  • \$\begingroup\$ 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 \$\endgroup\$
    – user202729
    Commented Jan 12, 2018 at 13:53
  • \$\begingroup\$ @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. \$\endgroup\$ Commented Jan 12, 2018 at 18:57
  • 4
    \$\begingroup\$ And as specified in the answer, it's better to downvote such challenges. Thanks. \$\endgroup\$
    – user202729
    Commented Jan 13, 2018 at 2:07
  • 4
    \$\begingroup\$ I fell it's not a loophole to answers, but a requirement to questions \$\endgroup\$
    – l4m2
    Commented Apr 4, 2018 at 4:57
  • \$\begingroup\$ Is f=n=>[1,7,31,105,300,754,1712,3576,6975,12871][n] valid for codegolf.stackexchange.com/questions/170437/… ? \$\endgroup\$ Commented Aug 11, 2018 at 16:38
142
\$\begingroup\$

Note: We now have standard definitions of "uniformly random" ("random" on its own is not well-defined), so any answer not fulfilling these is invalid. Additionally, has been retired, so this loophole is no longer relevant.

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.

\$\endgroup\$
19
  • 12
    \$\begingroup\$ Can I assume you're not including seeding a PRNG to force a known sequence? I see that as related, but different. \$\endgroup\$
    – Geobits
    Commented Jun 17, 2014 at 14:55
  • \$\begingroup\$ @Geobits: Correct, I am not including seeding the PRNG in this one. \$\endgroup\$
    – Kyle Kanos
    Commented Jun 17, 2014 at 15:12
  • 1
    \$\begingroup\$ This works the same in any challenge type. When the challenge looks for a random number, there needs to be some randomness. \$\endgroup\$
    – Justin
    Commented Jun 17, 2014 at 15:12
  • 9
    \$\begingroup\$ Strange that 100% of those rolls resulted in four... Not so random or fair, eh? \$\endgroup\$
    – Jwosty
    Commented Jun 22, 2014 at 4:28
  • 19
    \$\begingroup\$ Related to that, I'm also sick of that comic being referred to so often. \$\endgroup\$
    – Beta Decay
    Commented Aug 22, 2014 at 17:00
  • \$\begingroup\$ Actually is random number generator, just P(4)=1. \$\endgroup\$
    – durum
    Commented Dec 23, 2015 at 22:06
  • \$\begingroup\$ @duran: No, it is P(x)=4 for all x in reals with probability 1, therefore it is not random but completely deterministic. \$\endgroup\$
    – Kyle Kanos
    Commented Dec 23, 2015 at 23:43
  • 5
    \$\begingroup\$ But a constant is a random variable too! :D \$\endgroup\$
    – durum
    Commented Dec 23, 2015 at 23:53
  • 7
    \$\begingroup\$ Someone's gotta make a language that takes 4 as a random call, or maybe one that has randomly mutating constants. \$\endgroup\$
    – busukxuan
    Commented Jan 26, 2016 at 9:43
  • \$\begingroup\$ 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. \$\endgroup\$
    – CJ Dennis
    Commented Feb 18, 2016 at 0:44
  • \$\begingroup\$ @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. \$\endgroup\$
    – Kyle Kanos
    Commented Feb 18, 2016 at 2:24
  • 3
    \$\begingroup\$ 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. \$\endgroup\$
    – CJ Dennis
    Commented Feb 18, 2016 at 2:35
  • \$\begingroup\$ @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. \$\endgroup\$
    – Kyle Kanos
    Commented Feb 18, 2016 at 2:37
  • 3
    \$\begingroup\$ Randall Munroe, and Scott Adams \$\endgroup\$
    – xdhmoore
    Commented Jan 16, 2017 at 4:56
  • 3
    \$\begingroup\$ [underhanded] is dead, so should this be deleted? \$\endgroup\$ Commented Mar 12, 2018 at 2:05
140
\$\begingroup\$

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.

\$\endgroup\$
12
  • 48
    \$\begingroup\$ +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. \$\endgroup\$ Commented Feb 24, 2014 at 9:42
  • 63
    \$\begingroup\$ 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. \$\endgroup\$ Commented Feb 24, 2014 at 10:36
  • 5
    \$\begingroup\$ @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. \$\endgroup\$ Commented Feb 24, 2014 at 15:16
  • 8
    \$\begingroup\$ @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." \$\endgroup\$ Commented Feb 24, 2014 at 15:21
  • 1
    \$\begingroup\$ 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". \$\endgroup\$
    – corsiKa
    Commented Apr 8, 2014 at 19:30
  • 16
    \$\begingroup\$ 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. \$\endgroup\$ Commented Jun 22, 2014 at 18:21
  • 1
    \$\begingroup\$ 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. \$\endgroup\$
    – Daniel
    Commented Jan 24, 2018 at 22:18
  • 2
    \$\begingroup\$ @PeterTaylor not a violation if it's copied from another SE site, or other appropriately licensed source, with any requisite attribution. \$\endgroup\$
    – Sparr
    Commented Feb 20, 2019 at 21:36
  • \$\begingroup\$ What if the answer works in another different language (obviously with attribution) \$\endgroup\$ Commented Feb 7, 2023 at 18:03
  • \$\begingroup\$ Does this apply for AI-related answers where the AI-asker doesn't golf the response of the AI? \$\endgroup\$ Commented Feb 26, 2023 at 14:23
  • \$\begingroup\$ Sometimes there exist 2 answer in the same language. And you can use one to improve the other and vice versa, sometimes the best answer is a combination of both. What to do in this case? Which answer should be improved? \$\endgroup\$ Commented Jul 21, 2023 at 16:04
  • \$\begingroup\$ ±0, what if you’re making an account for a chatbot and you want it to get enough rep so it can actually chat? \$\endgroup\$ Commented Sep 4 at 15:40
137
\$\begingroup\$

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.

\$\endgroup\$
8
  • 3
    \$\begingroup\$ Do you have a link to this, or was it deleted? \$\endgroup\$ Commented Jun 30, 2014 at 22:07
  • \$\begingroup\$ @PeterTaylor codegolf.stackexchange.com/a/32725/8478 \$\endgroup\$ Commented Jun 30, 2014 at 22:09
  • 7
    \$\begingroup\$ 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. \$\endgroup\$
    – jaybz
    Commented Jul 22, 2014 at 12:47
  • \$\begingroup\$ @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"? \$\endgroup\$ Commented Jul 22, 2014 at 12:50
  • 8
    \$\begingroup\$ @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. \$\endgroup\$
    – jaybz
    Commented Jul 22, 2014 at 13:33
  • \$\begingroup\$ @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. \$\endgroup\$ Commented Jul 22, 2014 at 13:39
  • \$\begingroup\$ @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. \$\endgroup\$
    – jaybz
    Commented Jul 23, 2014 at 4:57
  • 3
    \$\begingroup\$ Reminds me of this xkcd comic. \$\endgroup\$ Commented Dec 18, 2015 at 18:08
123
\$\begingroup\$

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.

\$\endgroup\$
5
  • 12
    \$\begingroup\$ I mean technically, it is a quine, since the source is nothing and it outputs nothing \$\endgroup\$ Commented Jan 15, 2017 at 5:33
  • 11
    \$\begingroup\$ @TrojanByAccident Quine: a non-empty computer program which takes no input and produces a copy of its own source code as its only output \$\endgroup\$
    – Stephen
    Commented Jun 26, 2017 at 13:58
  • \$\begingroup\$ 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". \$\endgroup\$
    – Heimdall
    Commented Nov 8, 2017 at 15:16
  • 3
    \$\begingroup\$ @Heimdall Improper quines is its own loophole. \$\endgroup\$
    – Dennis Mod
    Commented Nov 8, 2017 at 15:21
  • \$\begingroup\$ your link is dead \$\endgroup\$ Commented Feb 7, 2023 at 18:04
110
\$\begingroup\$

Note: Banning builtins that perform specific operations is generally considered an unobservable requirement, and as such this loophole generally isn't enforced anymore.

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.

\$\endgroup\$
7
  • 3
    \$\begingroup\$ Seems to be the same as this one: meta.codegolf.stackexchange.com/a/1077/18865 \$\endgroup\$ Commented Jul 2, 2014 at 23:40
  • 4
    \$\begingroup\$ @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). \$\endgroup\$
    – ProgramFOX
    Commented Jul 3, 2014 at 6:25
  • 5
    \$\begingroup\$ "subroutine"/"function" or "add"/"+", it's all about using the same functionality with another name. Looks very related. \$\endgroup\$ Commented Jul 3, 2014 at 9:54
  • 3
    \$\begingroup\$ Yes, it's certainly related. But not really the same. Anyway, it does not hurt having this loophole in another answer. \$\endgroup\$
    – ProgramFOX
    Commented Jul 3, 2014 at 10:01
  • 1
    \$\begingroup\$ This would seem to apply only to a "Do X without Y" question, which is normally a sign of a bad question. \$\endgroup\$
    – MilkyWay90
    Commented Feb 24, 2019 at 16:36
  • \$\begingroup\$ @ProgramFOX But it's certainly ironic. \$\endgroup\$
    – wizzwizz4
    Commented May 12, 2019 at 15:30
  • \$\begingroup\$ @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... \$\endgroup\$
    – ProgramFOX
    Commented May 12, 2019 at 15:41
96
\$\begingroup\$

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.

\$\endgroup\$
16
  • 20
    \$\begingroup\$ You forgot Mathematica. ;) What about paid-for languages with free trials though? \$\endgroup\$
    – Martin Ender Mod
    Commented Oct 18, 2015 at 8:26
  • 9
    \$\begingroup\$ And what about Matlab and Octave? \$\endgroup\$
    – Beta Decay
    Commented Oct 18, 2015 at 9:30
  • 42
    \$\begingroup\$ @MartinBüttner If the free trial can expire, and block a user from using that language afterwards, it's still no good. \$\endgroup\$
    – isaacg
    Commented Oct 18, 2015 at 16:01
  • \$\begingroup\$ @BetaDecay Octave is fine. Matlab isn't \$\endgroup\$
    – isaacg
    Commented Oct 18, 2015 at 16:02
  • 10
    \$\begingroup\$ 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? \$\endgroup\$
    – Dennis Mod
    Commented Oct 18, 2015 at 16:12
  • 13
    \$\begingroup\$ Such as AppleScript. \$\endgroup\$ Commented Oct 19, 2015 at 18:18
  • 2
    \$\begingroup\$ Mathematica is so popular on this site. TinyMUSH, although free, seemed much worse than that... \$\endgroup\$
    – jimmy23013
    Commented Oct 22, 2015 at 9:45
  • 30
    \$\begingroup\$ 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. \$\endgroup\$
    – lirtosiast
    Commented Nov 7, 2015 at 6:09
  • 1
    \$\begingroup\$ Are there any platform-specific languages? \$\endgroup\$ Commented Dec 19, 2015 at 16:07
  • 8
    \$\begingroup\$ @ASCIIThenANSI Well most assembly languages, for instance \$\endgroup\$
    – isaacg
    Commented Dec 19, 2015 at 17:00
  • 1
    \$\begingroup\$ @AlexA. started a discussion about the free-ness here. \$\endgroup\$
    – flawr
    Commented Dec 27, 2015 at 10:08
  • 17
    \$\begingroup\$ Note: Mathematica can now be used freely online. \$\endgroup\$ Commented Nov 19, 2016 at 1:59
  • 3
    \$\begingroup\$ 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." \$\endgroup\$ Commented Mar 8, 2017 at 6:01
  • 1
    \$\begingroup\$ @isaacg I think Beta Decay meant that matlab code can be (mostly?) checked with free octave, as they have compatible syntax. \$\endgroup\$
    – jena
    Commented May 12, 2021 at 13:38
  • \$\begingroup\$ 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. \$\endgroup\$ Commented Jul 25, 2021 at 11:41
91
\$\begingroup\$

Note: Banning builtins that perform specific operations is generally considered an unobservable requirement, and as such this loophole generally isn't enforced anymore.

Identical functions with different names

For example, if + is forbidden, using any of the following is also forbidden:

num3 = num1.add(num2)

or

num3 = num1
num3 += num2

or

num1++

or (GolfScript)

)

etc.

\$\endgroup\$
3
  • 30
    \$\begingroup\$ 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 \$\endgroup\$
    – SztupY
    Commented Feb 25, 2014 at 14:11
  • 126
    \$\begingroup\$ 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 ++. \$\endgroup\$ Commented Mar 5, 2014 at 10:23
  • 30
    \$\begingroup\$ 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). \$\endgroup\$ Commented Mar 7, 2014 at 16:56
90
\$\begingroup\$

Note: As per community consensus, languages/language versions are allowed regardless of when they were created, so this loophole is no longer enforced.

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.

\$\endgroup\$
6
  • \$\begingroup\$ Does this mean that if you write a language to golf easily, you can't use for challanges? \$\endgroup\$
    – Lucas
    Commented Sep 7, 2015 at 22:44
  • 37
    \$\begingroup\$ @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. \$\endgroup\$
    – Dennis Mod
    Commented Sep 7, 2015 at 23:26
  • 5
    \$\begingroup\$ Just use first sandbox post date as acceptable language deadline instead of actual question post date. \$\endgroup\$
    – Vi.
    Commented Sep 30, 2016 at 14:05
  • 4
    \$\begingroup\$ @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. \$\endgroup\$
    – Dennis Mod
    Commented Sep 30, 2016 at 15:36
  • 2
    \$\begingroup\$ @Dinnis, Then maybe allow using languages created even after the challenge officially started provided they are developed independently of the challenge participant? \$\endgroup\$
    – Vi.
    Commented Sep 30, 2016 at 16:02
  • \$\begingroup\$ 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. \$\endgroup\$
    – Vi.
    Commented Sep 30, 2016 at 16:05
85
\$\begingroup\$

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.

\$\endgroup\$
9
  • 29
    \$\begingroup\$ Isn't this covered by "languages must have an interpreter before challenge was posted"? Or "made up languages" more specifically? \$\endgroup\$
    – Geobits
    Commented Apr 14, 2015 at 19:07
  • 6
    \$\begingroup\$ @Geobits Someone can make interpreters for MetaGolfScript before those challenges posted. At least they can be appeared to exist on the internet. \$\endgroup\$
    – jimmy23013
    Commented Apr 14, 2015 at 19:19
  • 3
    \$\begingroup\$ 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. \$\endgroup\$
    – Geobits
    Commented Apr 14, 2015 at 19:21
  • \$\begingroup\$ Well, I think I'll delete this after a few days. \$\endgroup\$
    – jimmy23013
    Commented Apr 14, 2015 at 19:25
  • 1
    \$\begingroup\$ 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. \$\endgroup\$ Commented Aug 24, 2015 at 17:26
  • 1
    \$\begingroup\$ 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. \$\endgroup\$
    – user62131
    Commented Mar 18, 2017 at 1:49
  • \$\begingroup\$ @ais523 You could implement a special purpose compression algorithm, and release the interpreters in that format. \$\endgroup\$
    – jimmy23013
    Commented Apr 28, 2017 at 9:01
  • 6
    \$\begingroup\$ 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. \$\endgroup\$
    – Sylwester
    Commented Jul 17, 2018 at 15:18
  • 1
    \$\begingroup\$ 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) \$\endgroup\$ Commented Jun 2, 2020 at 4:18
82
\$\begingroup\$

Posting a code snippet instead of a complete answer

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 their 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!");}

But, the answerer, with the intent to defeat another answer in code-golf, posts this instead, claiming that their answer is 22 bytes:

printf("Hello World!")
\$\endgroup\$
11
  • 6
    \$\begingroup\$ Provide an example? I don't see anything wrong with this, as long as the snippet does what is required. \$\endgroup\$
    – Doorknob
    Commented Mar 2, 2014 at 21:21
  • \$\begingroup\$ @Doorknob Ok, done. \$\endgroup\$ Commented Mar 2, 2014 at 21:29
  • 57
    \$\begingroup\$ 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. \$\endgroup\$ Commented Mar 2, 2014 at 22:58
  • 5
    \$\begingroup\$ @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. \$\endgroup\$ Commented Mar 2, 2014 at 23:16
  • \$\begingroup\$ 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 \$\endgroup\$
    – user80551
    Commented Mar 12, 2014 at 10:49
  • 24
    \$\begingroup\$ Well, printf("Hello World!") is obviously nonsense, but main(){printf("Hello World!");} compiles with GCC. \$\endgroup\$
    – Dennis
    Commented Mar 25, 2014 at 22:42
  • 16
    \$\begingroup\$ 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. \$\endgroup\$ Commented Jun 22, 2014 at 18:15
  • 1
    \$\begingroup\$ There is a more recent meta post for this specific topic here. \$\endgroup\$ Commented Dec 28, 2015 at 14:59
  • 13
    \$\begingroup\$ This should include Java answers where the answerer posts a function/method/subroutine/whatever outside of a class/interface/enum. \$\endgroup\$ Commented Jun 28, 2016 at 18:41
  • 1
    \$\begingroup\$ @dorukayhan EXACTLY - This was precisely what I was thinking for when I originally posted this a few years ago. \$\endgroup\$ Commented Jun 28, 2016 at 20:03
  • \$\begingroup\$ @Doorknob This Way Java will never suck for code golfing \$\endgroup\$
    – Ha'Penny
    Commented Oct 26, 2021 at 14:10
69
\$\begingroup\$

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.

\$\endgroup\$
8
  • 47
    \$\begingroup\$ 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. \$\endgroup\$ Commented Jul 31, 2014 at 7:30
  • 2
    \$\begingroup\$ @MartinBüttner I agree. That's what I tried to say in the last paragraph. I guess I failed. \$\endgroup\$
    – Justin
    Commented Jul 31, 2014 at 17:17
  • 3
    \$\begingroup\$ 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. \$\endgroup\$ Commented Jul 31, 2014 at 17:35
  • 7
    \$\begingroup\$ Out of hand? You don't say? \$\endgroup\$
    – Geobits
    Commented Jul 31, 2014 at 23:34
  • 1
    \$\begingroup\$ 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. \$\endgroup\$
    – Ming-Tang
    Commented Aug 10, 2014 at 6:29
  • 12
    \$\begingroup\$ 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. \$\endgroup\$
    – Bob
    Commented Aug 11, 2014 at 2:28
  • 2
    \$\begingroup\$ Surely the solution is to not specifically allow a 'suicide' command in the game? \$\endgroup\$
    – Rob
    Commented Jan 6, 2017 at 4:02
  • \$\begingroup\$ Suicidal entries to king-of-the-hill challenges are not serious cotnenders. \$\endgroup\$ Commented Aug 17, 2019 at 22:23
61
\$\begingroup\$

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.

\$\endgroup\$
9
  • 18
    \$\begingroup\$ 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. \$\endgroup\$
    – lirtosiast
    Commented Feb 11, 2016 at 5:07
  • 2
    \$\begingroup\$ I don't think this is a problem, but a solution. Good on those users for thinking outside the box. \$\endgroup\$
    – user56309
    Commented Sep 12, 2016 at 19:16
  • 4
    \$\begingroup\$ @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. \$\endgroup\$
    – Dennis Mod
    Commented Sep 12, 2016 at 19:56
  • 1
    \$\begingroup\$ @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. \$\endgroup\$
    – user56309
    Commented Sep 12, 2016 at 20:03
  • \$\begingroup\$ 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? \$\endgroup\$ Commented Nov 7, 2018 at 17:07
  • 5
    \$\begingroup\$ @RossPresser That's still hardcoding. The format doesn't matter. \$\endgroup\$
    – Dennis Mod
    Commented Nov 7, 2018 at 17:09
  • \$\begingroup\$ 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. \$\endgroup\$
    – qwr
    Commented Feb 7, 2019 at 9:20
  • 5
    \$\begingroup\$ @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. \$\endgroup\$
    – Dennis Mod
    Commented Feb 7, 2019 at 12:56
  • \$\begingroup\$ 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 \$\endgroup\$
    – pqnet
    Commented May 21, 2020 at 16:34
61
\$\begingroup\$

Note: As per community consensus, languages/language versions are allowed regardless of when they were created, so this loophole is no longer enforced.

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.

\$\endgroup\$
16
  • 19
    \$\begingroup\$ 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 \$\endgroup\$
    – Timwi
    Commented Sep 24, 2015 at 5:42
  • \$\begingroup\$ @Timwi So would I, but the user in the linked answer wouldn't accept that fact. \$\endgroup\$
    – mbomb007
    Commented Sep 24, 2015 at 13:55
  • 5
    \$\begingroup\$ 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. \$\endgroup\$ Commented Dec 31, 2015 at 13:45
  • \$\begingroup\$ @user2428118 That's already a rule and is mandated. It's not a loophole. \$\endgroup\$
    – mbomb007
    Commented Dec 31, 2015 at 15:49
  • 1
    \$\begingroup\$ 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. \$\endgroup\$ Commented Oct 24, 2016 at 11:44
  • \$\begingroup\$ @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. \$\endgroup\$
    – mbomb007
    Commented Oct 24, 2016 at 14:18
  • \$\begingroup\$ @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. \$\endgroup\$ Commented Oct 24, 2016 at 14:26
  • \$\begingroup\$ @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. \$\endgroup\$
    – mbomb007
    Commented Oct 24, 2016 at 15:21
  • \$\begingroup\$ @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. \$\endgroup\$
    – mbomb007
    Commented Oct 24, 2016 at 15:29
  • \$\begingroup\$ @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. \$\endgroup\$ Commented Oct 24, 2016 at 17:19
  • \$\begingroup\$ 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. \$\endgroup\$ Commented Oct 24, 2016 at 17:22
  • \$\begingroup\$ 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. \$\endgroup\$
    – mbomb007
    Commented Oct 24, 2016 at 18:25
  • \$\begingroup\$ Your post leaves a loophole itself: building a transpiler is still possible! \$\endgroup\$
    – rydwolf
    Commented Apr 14, 2018 at 14:53
  • \$\begingroup\$ @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. \$\endgroup\$
    – mbomb007
    Commented Apr 14, 2018 at 20:48
  • \$\begingroup\$ @mbomb007 Just a joke. I knew about the interpreter-only rule already. \$\endgroup\$
    – rydwolf
    Commented Apr 14, 2018 at 22:04
60
\$\begingroup\$

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.

\$\endgroup\$
6
  • 10
    \$\begingroup\$ +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. \$\endgroup\$
    – abligh
    Commented Nov 17, 2014 at 18:57
  • \$\begingroup\$ @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. \$\endgroup\$ Commented Nov 17, 2014 at 18:59
  • \$\begingroup\$ 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. \$\endgroup\$
    – Mark Adler
    Commented Nov 17, 2014 at 23:30
  • \$\begingroup\$ @MarkAdler how about now? \$\endgroup\$ Commented Nov 17, 2014 at 23:32
  • 18
    \$\begingroup\$ 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. \$\endgroup\$
    – Mark Adler
    Commented Nov 17, 2014 at 23:34
  • \$\begingroup\$ I guess that's better. \$\endgroup\$
    – Mark Adler
    Commented Nov 17, 2014 at 23:35
53
\$\begingroup\$

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.

\$\endgroup\$
15
  • 6
    \$\begingroup\$ Can you explain for non-pythonians what this snippet exactly does? \$\endgroup\$
    – flawr
    Commented Apr 26, 2016 at 20:19
  • 8
    \$\begingroup\$ @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". \$\endgroup\$
    – Martin Ender Mod
    Commented Apr 26, 2016 at 20:22
  • \$\begingroup\$ 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. \$\endgroup\$
    – Qwertiy
    Commented May 17, 2016 at 13:02
  • \$\begingroup\$ @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. \$\endgroup\$
    – mbomb007
    Commented May 18, 2016 at 16:37
  • 1
    \$\begingroup\$ @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. \$\endgroup\$
    – Qwertiy
    Commented May 18, 2016 at 16:57
  • 7
    \$\begingroup\$ Isn't this the Halting problem? What's to guarantee that you get to a solution in an infinite search space? \$\endgroup\$
    – xdhmoore
    Commented Jan 16, 2017 at 5:01
  • \$\begingroup\$ @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). \$\endgroup\$
    – user45941
    Commented Jan 16, 2017 at 6:33
  • \$\begingroup\$ 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 :) \$\endgroup\$
    – xdhmoore
    Commented Jan 16, 2017 at 7:24
  • 2
    \$\begingroup\$ You're going to lose if you use this because the name of the function is longer than the target. \$\endgroup\$
    – Joshua
    Commented Apr 23, 2017 at 15:42
  • 11
    \$\begingroup\$ @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. \$\endgroup\$
    – Charles
    Commented Jun 2, 2017 at 6:09
  • 1
    \$\begingroup\$ 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. \$\endgroup\$ Commented Nov 3, 2017 at 3:08
  • 1
    \$\begingroup\$ @eaglgenes101 The program is the wrong thing to focus on here. \$\endgroup\$
    – user45941
    Commented Nov 3, 2017 at 6:25
  • 1
    \$\begingroup\$ This is my kind of program...just let it run, and eventually it will create the next big thing \$\endgroup\$
    – rydwolf
    Commented Apr 14, 2018 at 14:57
  • \$\begingroup\$ @eaglgenes101 No. The program merely defines the function. At no point are any of the functions actually run. E.g. tio.run/##K6gsycjPM/7/… \$\endgroup\$
    – E. Z. L.
    Commented Jan 5, 2023 at 14:23
  • \$\begingroup\$ However, it does kind of need modification. But no really as extreme as the answers seem to imply. \$\endgroup\$
    – E. Z. L.
    Commented Jan 5, 2023 at 18:08
46
\$\begingroup\$

Changing your username to fit a username dependent challenge

Changing your username or registering a new one to make your score better in username or userID dependent challenges.

\$\endgroup\$
6
  • \$\begingroup\$ 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? \$\endgroup\$
    – user39326
    Commented Jun 20, 2015 at 23:59
  • 5
    \$\begingroup\$ @M.I.Wright Username: Output your username without using any of the characters in your username! [duplicate] UserID: Red vs. Blue - Pixel Team Battlebots \$\endgroup\$
    – randomra
    Commented Jun 21, 2015 at 8:17
  • 80
    \$\begingroup\$ 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 \$\endgroup\$
    – Mohammad
    Commented Sep 22, 2015 at 11:56
  • 7
    \$\begingroup\$ 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! \$\endgroup\$ Commented Sep 9, 2016 at 11:49
  • 2
    \$\begingroup\$ my username is 1. <s>2-1</s> 3-2. How did I manage to mess that up?! \$\endgroup\$
    – Miriam
    Commented Mar 25, 2019 at 19:41
  • \$\begingroup\$ This reminds me of Pokemon Blue Arbitrary Code Execution, because some depend on your trainer ID. \$\endgroup\$
    – mekb
    Commented Jul 12, 2019 at 6:01
42
\$\begingroup\$

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.

\$\endgroup\$
6
  • 11
    \$\begingroup\$ 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. \$\endgroup\$ Commented Jul 19, 2017 at 13:46
  • 6
    \$\begingroup\$ @V.Courtois The OP can still decide; this is just the default. \$\endgroup\$
    – Dennis Mod
    Commented Jul 19, 2017 at 16:02
  • \$\begingroup\$ 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. \$\endgroup\$
    – BlackCap
    Commented Oct 25, 2017 at 10:48
  • \$\begingroup\$ 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. \$\endgroup\$
    – David G.
    Commented Jan 8, 2020 at 12:47
  • 1
    \$\begingroup\$ 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. \$\endgroup\$ Commented Mar 18, 2021 at 11:19
  • \$\begingroup\$ @V.Courtois shortening the url is allowed, so long as the full mechnism used to retrieve the full-sized URL in part of the submission. this rule is about using code and resources maintained by external services as part of your answer. \$\endgroup\$
    – Jasen
    Commented Jun 9, 2022 at 4:04
38
\$\begingroup\$

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.

\$\endgroup\$
7
  • 8
    \$\begingroup\$ 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. \$\endgroup\$
    – hyperneutrino Mod
    Commented Oct 27, 2017 at 14:08
  • \$\begingroup\$ @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). \$\endgroup\$ Commented Oct 27, 2017 at 14:14
  • \$\begingroup\$ 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. \$\endgroup\$ Commented Oct 27, 2017 at 19:14
  • 3
    \$\begingroup\$ 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?) \$\endgroup\$ Commented Dec 4, 2017 at 4:05
  • 2
    \$\begingroup\$ Can I do this but add the byte count of input function? \$\endgroup\$
    – l4m2
    Commented Dec 30, 2017 at 4:57
  • 13
    \$\begingroup\$ While I agree with the intent of this post, the wording needs work. 1, 0, l, and r are complete functions in Jelly. \$\endgroup\$
    – Dennis Mod
    Commented May 8, 2018 at 15:17
  • \$\begingroup\$ @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. \$\endgroup\$ Commented May 8, 2018 at 15:20
35
\$\begingroup\$

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.

\$\endgroup\$
1
  • 26
    \$\begingroup\$ 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. \$\endgroup\$
    – steenbergh
    Commented Jan 26, 2017 at 14:53
35
\$\begingroup\$

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?

\$\endgroup\$
9
  • 14
    \$\begingroup\$ This is common sense. It shouldn't even need to be written down. +1. \$\endgroup\$
    – wizzwizz4
    Commented May 26, 2016 at 17:38
  • \$\begingroup\$ 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... \$\endgroup\$ Commented May 26, 2016 at 17:39
  • 42
    \$\begingroup\$ 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. \$\endgroup\$
    – Riker
    Commented May 26, 2016 at 17:41
  • 5
    \$\begingroup\$ 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). \$\endgroup\$ Commented May 26, 2016 at 18:44
  • 1
    \$\begingroup\$ I posted a more detailed meta discussion \$\endgroup\$ Commented May 27, 2016 at 3:59
  • 1
    \$\begingroup\$ 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. \$\endgroup\$ Commented Sep 9, 2016 at 11:39
  • 6
    \$\begingroup\$ @AndreïKostyrka In Bases 8, 9, B-D and F-\inf it isn't... :-) \$\endgroup\$
    – wizzwizz4
    Commented Oct 2, 2016 at 11:30
  • 1
    \$\begingroup\$ 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...) \$\endgroup\$ Commented Jun 5, 2017 at 5:51
  • \$\begingroup\$ @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. \$\endgroup\$ Commented Jun 5, 2017 at 11:41
33
\$\begingroup\$

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.

\$\endgroup\$
16
  • 31
    \$\begingroup\$ 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? \$\endgroup\$
    – flawr
    Commented Jun 27, 2016 at 8:23
  • \$\begingroup\$ +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. \$\endgroup\$
    – Martin Ender Mod
    Commented Jun 27, 2016 at 8:25
  • \$\begingroup\$ @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. \$\endgroup\$
    – user45941
    Commented Jun 27, 2016 at 8:26
  • 1
    \$\begingroup\$ @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. \$\endgroup\$
    – flawr
    Commented Jun 27, 2016 at 8:31
  • 3
    \$\begingroup\$ @flawr here, before I added the word "deterministically". \$\endgroup\$
    – Leaky Nun
    Commented Jun 27, 2016 at 8:33
  • 2
    \$\begingroup\$ 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.". \$\endgroup\$
    – flawr
    Commented Jun 27, 2016 at 8:42
  • \$\begingroup\$ @flawr I agree with your improved wording and have made the edit. \$\endgroup\$
    – user45941
    Commented Jun 27, 2016 at 10:15
  • 4
    \$\begingroup\$ 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 \$\endgroup\$
    – Luis Mendo
    Commented Jun 27, 2016 at 11:57
  • \$\begingroup\$ @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. \$\endgroup\$ Commented Jun 27, 2016 at 16:01
  • \$\begingroup\$ @LuisMendo Right, this is all in all quite similar to this loophole, so they could probably be merged? \$\endgroup\$
    – flawr
    Commented Jun 27, 2016 at 17:42
  • 4
    \$\begingroup\$ @flawr I'd say it's not even a loophole, it's an answer that doesn't meet the specs \$\endgroup\$
    – Luis Mendo
    Commented Jun 27, 2016 at 18:02
  • \$\begingroup\$ @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). \$\endgroup\$
    – Desty
    Commented Jun 28, 2016 at 15:20
  • 2
    \$\begingroup\$ 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? (: ) \$\endgroup\$
    – hvd
    Commented Jun 28, 2016 at 20:47
  • \$\begingroup\$ @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". \$\endgroup\$
    – user45941
    Commented Jun 28, 2016 at 20:58
  • 1
    \$\begingroup\$ I don't think the randomness is important here. The important part is whether is is allowed to output more than the expected output or not. \$\endgroup\$ Commented Nov 20, 2016 at 11:18
32
\$\begingroup\$

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.

\$\endgroup\$
2
  • \$\begingroup\$ what is an improper quine, de facto? \$\endgroup\$ Commented Jul 19, 2017 at 13:55
  • 1
    \$\begingroup\$ @V.Courtois cat $0 in Bash or This is a quine. is PHP. \$\endgroup\$
    – Dennis Mod
    Commented Jul 19, 2017 at 16:03
24
\$\begingroup\$

Output shall be non-trivial (e. g. not empty)

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.

\$\endgroup\$
5
  • \$\begingroup\$ This is already forbidden by our rules. Answers must make a serious attempt at competing. \$\endgroup\$
    – user45941
    Commented Jan 31, 2016 at 4:58
  • 5
    \$\begingroup\$ Already mentioned in the help center. \$\endgroup\$
    – Doorknob Mod
    Commented Jan 31, 2016 at 4:59
  • 1
    \$\begingroup\$ 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 \$\endgroup\$
    – Downgoat
    Commented Jan 31, 2016 at 5:00
  • 3
    \$\begingroup\$ Your edits so far only describe what is already forbidden by the serious attempt rule. \$\endgroup\$
    – user45941
    Commented Feb 2, 2016 at 2:14
  • 8
    \$\begingroup\$ 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 \$\endgroup\$
    – MilkyWay90
    Commented Mar 17, 2019 at 18:41

You must log in to answer this question.

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