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 low-quality flag.

Return to FAQ index

  • 95
    Loopholes are part of what makes the game interesting. Even common ones can be funny or clever, depending on context. If you find a loophole in an answer disinteresting, don’t vote for it, or vote against it. I don’t think we need a canonical list of fun things that you can’t do. (With the exception of Interpreting the challenge too literally below. That’s always boring. ;)) – Ry- Feb 27 '14 at 18:16
  • 11
    @minitech: And the countless variations of curl -L http://bit.ly/012foobar aren't? – Ilmari Karonen Mar 2 '14 at 14:59
  • 6
    @IlmariKaronen: Depends whether it’s actually clever. If you don’t find it clever, vote appropriately. As always. – Ry- Mar 2 '14 at 15:57
  • 3
    @minitech, there seems to be a strong consensus that the appropriate vote is "Low quality, delete". – Peter Taylor Mar 2 '14 at 22:56
  • 32
    "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. – derobert Apr 14 '14 at 16:05
  • 4
    @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. – Peter Taylor Apr 14 '14 at 16:31
  • @PeterTaylor Ah. I'm surprised "Using the program name to store data" isn't one of them, considering the +26 comment on it. – derobert Apr 14 '14 at 16:51
  • @derobert, it's at +28/-4. Very puzzling. My best guess is that most of the people upvoting the answer agreed with the part of the comment which says that the filename should be counted towards the length of the program. – Peter Taylor Apr 14 '14 at 16:57
  • 2
    The condition for whether the loophole applies should probably be changed to +10 or +15. All of the answers are currently above the +5 mark due to the surge in popularity of this post. Perhaps it could be a moving window (all answers with a score of average of all answer scores / 2 or the score of the highest voted answer / 5 or something), but that would be pretty complicated. – Doorknob Apr 27 '14 at 21:24
  • 1
    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. – trlkly Jun 29 '14 at 12:34
  • When I say it is "no obvious way to get to the FAQ", I am referring to the fact that it does not seem to be linked in the Help dropdown itself nor mentioned in the Tour or Help Center pages. I know I only found out about this page after I saw a question that downvoted because of it. (And because it was mentioned explicitly in some questions, but those keep being removed.) – trlkly Jun 29 '14 at 12:46
  • While I agree with the intention of a list of standard loopholes, I think I have shown here that even the answers below are not clear cut – Alchymist Sep 9 '14 at 14:18

44 Answers 44

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";
}
  • 231
    I believe you meant "Compiling the challenge too literally" :P – Jwosty Jun 10 '14 at 17:21
  • 67
    @Jwosty not in this case, as PHP is interpreted. – Hugo Zink Jun 20 '14 at 9:28
  • 8
    @Rokk Or is it? IT'S ALL A RUSE! – Jwosty Jun 20 '14 at 15:59
  • 5
    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. – Fabinout Jul 4 '14 at 12:07
  • 24
    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." – Matthew Najmon Sep 5 '14 at 12:25
  • 10
    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 – Luis Mendo Jan 25 '15 at 18:02
  • 7
    @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". – Ilmari Karonen Jul 16 '15 at 8:54
  • 1
    @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) – Luis Mendo Jul 16 '15 at 9:11
  • 5
    "the $n-th prime" is not the n-th prime. – Khaled.K Jan 19 '16 at 11:59
  • 7
    @Jwosty I think you're interpreting the answer too literally. – Andrew Grimm Aug 21 '16 at 6:13

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.

  • 29
    Especially getting the highest voted answer from the selected wuestion – TheDoctor Apr 10 '14 at 21:13
  • 69
    We could allow it, if the size of the external source is added to the size of the answer. – vsz Aug 30 '15 at 21:21
  • 3
    You mean a copy-paste answer? – Khaled.K Jan 19 '16 at 12:01
  • 3
    @KhaledAKhunaifer, no, I mean an answer which saves bytes by replacing a large string with a wget or similar that fetches it. – Peter Taylor Jan 19 '16 at 14:33
  • 2
    @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. – Khaled.K Jan 19 '16 at 16:06
  • some internet questions may need to do so, but source code itself still not allowed to just be fetched – l4m2 Apr 4 at 4:58
  • 7
    In that case, I'll just do an HTTPS request! – Redwolf Programs Apr 14 at 14:30

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.

  • 120
    I think HQ9+ should no longer be considered made up. It's useless for almost all challenges, and can sometimes be used creatively. – ugoren Feb 23 '14 at 14:53
  • 6
    @ugoren Thanks for calling my answer creative :-) – Justin Feb 23 '14 at 18:51
  • 6
    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. – asteri Feb 24 '14 at 21:03
  • 97
    -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. – SztupY Feb 25 '14 at 14:09
  • 7
    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. – manatwork Mar 2 '14 at 15:52
  • 4
    @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. – Ilmari Karonen Mar 2 '14 at 16:13
  • I'd bound this in with "get from external source" and other ways of hiding byte count. – Allen Gould Mar 12 '14 at 19:11
  • 54
    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+). – Johannes Kuhn Mar 13 '14 at 15:27
  • 1
    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? – Holger May 27 '15 at 11:54
  • 3
    @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. – Ilmari Karonen May 27 '15 at 12:56
  • 5
    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." – apsillers Dec 18 '15 at 15:06
  • To anyone else who is looking for the more exact rule "the language should be released before the question was posted": it was given here. – jimmy23013 Jan 5 '16 at 9:11
  • Isn't that just called "a golfing language"? – AJFaraday Mar 8 at 9:10

Using two different chars which look the same

Very common in contests: you set variable a to a value, then you set variable <CYRILLIC A WHICH LOOKS THE SAME> to another value, then you pretend they're the same thing.

Most recent occurence is in the 2+2 = 5 question, in JavaScript, here.

It's just boring. It's effectively impossible to detect unless explained.

Also, it isn't a display of programming skill, it's just an easy troll. It isn't even one of those things that are funny the first time you see them (at least for me).

  • 8
    Impossible to detect? Manual inspection with od -a? Automatically with iconv --unicode-subst=whatever? I'll give you the "boring" part though. – Lloeki Jun 1 '14 at 16:34
  • 55
    @Lloeki I don't exactly hexdump every underhanded answer I see. But you could do that. – user16402 Jun 1 '14 at 16:36
  • 26
    Just use Ctrl-F in your browser and search for a. – Konstantin Weitz Jun 1 '14 at 17:20
  • 113
    @KonstantinWeitz Yeah cos there will obviously be very few results only. – Pierre Arlaud Jun 2 '14 at 9:44
  • 5
    @ArlaudPierre It highlights the characters? – Yet Another User Jun 15 '14 at 23:43
  • 9
    @YetAnotherUser In an usually really unconvenient way? It also often scrolls the page somewhere else and takes a few seconds (a.k.a. a life time) to highlight them? – Pierre Arlaud Jun 16 '14 at 7:14
  • i dont get how that works – Math chiller Jun 26 '14 at 12:10
  • 40
    I think using homoglyphs is very much in the spirit of underhanded programming. – Brian Minton Aug 6 '14 at 12:50
  • 7
    @BrianMinton It's good for underhanded contests (the goal is to trick the user), but not very good anywhere else. – ASCIIThenANSI Apr 15 '15 at 18:25
  • 10
    I thought underhanded was supposed to look like an honest typo even after someone finds the trick, which would make this unsuitable for it. – Random832 Apr 25 '15 at 17:34
  • This should be trying to fool the reader rather than do the trick since it's one way of doing it. Let's avoid selectivism. – Khaled.K Jan 19 '16 at 12:06
  • 8
    @Random832 "oops I forgot my keyboard was in Greek mode" – Cyoce May 10 '16 at 18:58
  • Moot since underhanded challenges are no longer on topic – ppperry Jul 10 '17 at 2:01
  • Though it is fun :l – V. Courtois Jul 19 '17 at 13:12
  • 2
    [underhanded] is dead, so should this be deleted? – Esolanging Fruit Mar 12 at 1:59

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);
}
  • 10
    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. – Martin Ender Jul 9 '14 at 18:52
  • 11
  • 81
    ugh, have an upvote. – Martin Ender Jul 9 '14 at 19:01
  • 4
    This is why I set all my editors to show whitespace. – ratchet freak Nov 5 '14 at 10:39
  • 42
    @MartinBüttner Ugh, have an upvote on your comment about having an upvote. – ASCIIThenANSI Apr 13 '15 at 16:12
  • 59
    It should be r = 4. – Conor O'Brien Dec 6 '15 at 19:54
  • 44
    Obligatory xkcd for that last comment: xkcd.com/221 – user18932 Feb 23 '16 at 3:16
  • 2
    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. – Heimdall Nov 8 '17 at 10:27
  • 3
    [underhanded] is dead, so should this be deleted? – Esolanging Fruit Mar 12 at 1:59
  • 1
    It'll be easy to discover if the VERY random number is always 5 – Redwolf Programs Apr 14 at 14:35

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.

  • 5
    +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. – SztupY Feb 25 '14 at 14:12
  • @SztupY But much of the time, they aren't link only answer. They in fact do contain some working running code. – Victor Stafusa Feb 25 '14 at 15:59
  • 63
    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. – Ilmari Karonen Feb 27 '14 at 12:08
  • 10
    I agree with Ilmari - fetch code and fetch answer are two sides of the same coin. A very low-valued coin. – Jonathan Van Matre Feb 27 '14 at 14:56
  • 4
    I think all networking should be banned unless explicitly allowed in the question.. – user2813274 Aug 1 '14 at 17:41
  • 6
    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. – Atsby Mar 23 '15 at 3:32

Hard-coding the output

Unless the question is an obvious exception (the primary exception being those tagged ), your program is expected to do work, not just print a pre-calculated result. If the question doesn't require input and so a solution which just prints the answer would seem to meet the spec, downvote the question rather than post a protest answer consisting of the literal output.

  • 164
    Often, this vulnerability is an indicator of a dumb question... – boothby Mar 7 '14 at 19:37
  • 20
    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. – Johannes Kuhn Mar 13 '14 at 15:23
  • 2
    How does Bubblegum fit into this? It seems to be designed to kill pure kolmogorov-complexity questions. – CJ Dennis Feb 18 '16 at 1:12
  • 2
    @CJDennis Unless the question is an obvious exception (the primary exception being those tagged kolmogorov-complexity) – Mego Mar 3 '16 at 0:29
  • 1
    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. – timmyRS Sep 30 '16 at 18:12
  • Now I can't understand what this loophole means. Mr.Xcoder recently posted this chat message which doesn't seem to be correct. If the question requires input, hardcoding is impossible. Can you explain more? @PeterTaylor – user202729 Jan 12 at 13:53
  • @user202729, it was addressed at questions like "Write a program to output the smallest three-digit prime", where the GolfScript program 101 would almost certainly beat any program in any language which actually did work. – Peter Taylor Jan 12 at 18:57
  • 1
    And as specified in the answer, it's better to downvote such challenges. Thanks. – user202729 Jan 13 at 2:07
  • I fell it's not a loophole to answers, but a requirement to questions – l4m2 Apr 4 at 4:57
  • Is f=n=>[1,7,31,105,300,754,1712,3576,6975,12871][n] valid for codegolf.stackexchange.com/questions/170437/… ? – Евгений Новиков Aug 11 at 16:38

Using Trigraphs in an underhanded contest

Anyone who has seen a few contests on this site will know why this snippet is valid code:

//Why does this not throw an error??/
This is invalid syntax in C

It seems as if every contest has one of these answers.

  • 9
    It's about as interesting an answer as a lot of the underhanded questions... – Peter Taylor Mar 17 '14 at 8:39
  • 16
    @PeterTaylor That's true, but I'm tired of seeing all these Trigraphs accompanied by "Can you figure out why this works?" I don't even program in C/C++ and I know how it works (through the many posts on this site). – Justin Mar 17 '14 at 9:05
  • 19
    I am sooooo tired of this one. +1 – durron597 Mar 24 '14 at 15:52
  • 3
    Also, codegolf.stackexchange.com/a/31662/16402 backslashes at the end of comments – user16402 Jun 13 '14 at 7:24
  • 9
    Okay, can someone please explain the validity of this code...? – WallyWest Aug 1 '14 at 4:36
  • 23
    @WallyWest When trigraphs are turned on, ??/ is replaced by a \, so the next line is made part of the comment – Justin Aug 1 '14 at 5:21
  • 8
    I think it's good to raise awareness of trigraphs, they exist for a good reason. – Pharap Sep 4 '14 at 13:00
  • 5
    I think using that particular trigraph at the "end" of a comment is getting old, but that trigraph, other trigraphs, and digraphs can still be used creatively. – The Guy with The Hat Sep 7 '14 at 20:38
  • 1
    Trigraphs can be either used to deceive the reader, do a trick, or to form ascii art in your code. – Khaled.K Jan 19 '16 at 12:13
  • 4
    All glory to the trigraphs. Thank goodness they were finally removed from the standard. – M.Stramm May 4 '16 at 14:10
  • 3
    [underhanded] is dead, so should this be deleted? – Esolanging Fruit Mar 12 at 2:05
  • 1
    @EsolangingFruit Seems reasonable to me. I don't want to just delete it unless there's consensus, though. I think it should be fine; if we ever need to resurrect this, mods or 10k+ can see it to undelete – Justin Mar 12 at 2:20
  • This isn't even a loophole, it's just an overused and boring answer. – 12Me21 Apr 30 at 14:46
  • Wait, you can use `` at the end of a comment like that? I had no idea! – SamB Sep 21 at 21:15

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) + 13 (Hello World\!) = 20 bytes.

  • 252
    -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. – SztupY Feb 25 '14 at 14:06
  • 15
    @SztupY It's absolutely standard for the filename to be the first parameter. argv[0] is the filename in C for example. – Miles Rout Jun 21 '14 at 13:57
  • 5
    It's quite standard for C executable to be named a.out. Can it be used without increasing bytes count? – enedil May 30 '17 at 18:02
  • 1
    @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 – Peter Cordes Jul 20 '17 at 16:53
  • Also, turns out ! instead of \! works too, with bash. History expansion doesn't apply to the results of parameter expansion, only to literal !. (And is off by default in non-interactive shells anyway.) So this example is badly golfed, but I'll leave in the \! as a hint/clue about what's going on. – Peter Cordes Jul 20 '17 at 17:01
  • @PeterCordes, there was no intention to golf the file name, because its bytes are not supposed to be counted. Space needs to be quoted in a line such as cat > Hello\ World\!, but indeed the created file name won't contain a ``. – ugoren Jul 20 '17 at 18:12
  • Yeah, I realized that it only became an issue once I changed the answer. I updated it try to avoid the distraction of a sub-optimally-golfed implementation for future readers of the question, who aren't thinking about what it used to say. Your point about cat is a reason to leave both the back-slashes in, so it creates 'Hello Word!' for people that copy-paste the filename into a shell command without quoting it. Ugh, I'd rather just assume that people know how to use quote filenames in the shell, but if you want to change it back to 21 bytes, I don't object. – Peter Cordes Jul 20 '17 at 18:15
  • 2
    What if relying on a necessary part as storage? e.g. a BAT file use its whole filename"1.BAT" to do operations, count as +1 or +5? – l4m2 Dec 1 '17 at 8:12
  • @l4m2: What happens if I name it 1.cmd? – SamB Sep 21 at 21:17
  • @SamB Discuss both situation – l4m2 Oct 1 at 13:05

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.

  • 9
    Can I assume you're not including seeding a PRNG to force a known sequence? I see that as related, but different. – Geobits Jun 17 '14 at 14:55
  • @Geobits: Correct, I am not including seeding the PRNG in this one. – Kyle Kanos Jun 17 '14 at 15:12
  • 1
    This works the same in any challenge type. When the challenge looks for a random number, there needs to be some randomness. – Justin Jun 17 '14 at 15:12
  • 7
    Strange that 100% of those rolls resulted in four... Not so random or fair, eh? – Jwosty Jun 22 '14 at 4:28
  • 13
    Related to that, I'm also sick of that comic being referred to so often. – Beta Decay Aug 22 '14 at 17:00
  • Actually is random number generator, just P(4)=1. – durum Dec 23 '15 at 22:06
  • @duran: No, it is P(x)=4 for all x in reals with probability 1, therefore it is not random but completely deterministic. – Kyle Kanos Dec 23 '15 at 23:43
  • 2
    But a constant is a random variable too! :D – durum Dec 23 '15 at 23:53
  • 5
    Someone's gotta make a language that takes 4 as a random call, or maybe one that has randomly mutating constants. – busukxuan Jan 26 '16 at 9:43
  • I think someone doesn't get it. The chance of rolling a 4 on any single throw is the same as any other number. It's only when you roll it many times that it becomes increasingly unlikely, but not impossible to get 4 every time. In fact, for n rolls, any specific sequence of n results is equally likely. – CJ Dennis Feb 18 '16 at 0:44
  • @CJDennis: There is no dice, there is only 4. It is 4 for all eternity, so it's not particularly random. But that's irrelevant to the fact that it's played out. So I think, if anyone, it is you who doesn't get it. – Kyle Kanos Feb 18 '16 at 2:24
  • 1
    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. – CJ Dennis Feb 18 '16 at 2:35
  • @CJDennis: The comic was funny when it was written 8 years ago. It's not funny anymore. Hence, it being added to the "loopholes that are forbidden by default." And since we're displaying code here, your last sentence appears to be a complete non sequitur. – Kyle Kanos Feb 18 '16 at 2:37
  • 2
    Randall Munroe, and Scott Adams – xdhmoore Jan 16 '17 at 4:56
  • [underhanded] is dead, so should this be deleted? – Esolanging Fruit Mar 12 at 2:05

Copying an (unimproved) answer from elsewhere

If it's not your own work, and you can't even be arsed to golf it or improve it, then it's not yours to post.

  • 40
    +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. – Ilmari Karonen Feb 24 '14 at 9:42
  • 51
    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. – Peter Taylor Feb 24 '14 at 10:36
  • 5
    @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. – Jonathan Van Matre Feb 24 '14 at 15:16
  • 6
    @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." – Jonathan Van Matre Feb 24 '14 at 15:21
  • 1
    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". – corsiKa Apr 8 '14 at 19:30
  • 9
    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. – David Mulder Jun 22 '14 at 18:21
  • 1
    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. – Daniel Jan 24 at 22:18

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.

  • 3
    Do you have a link to this, or was it deleted? – Peter Taylor Jun 30 '14 at 22:07
  • @PeterTaylor codegolf.stackexchange.com/a/32725/8478 – Martin Ender Jun 30 '14 at 22:09
  • 7
    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. – jaybz Jul 22 '14 at 12:47
  • @jaybz Feel free to reword it to make it a bit more precise. I just thought if I'd write "taking the result as an additional input" it would be too narrow. "Taking more input then specified"? – Martin Ender Jul 22 '14 at 12:50
  • 3
    @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. – jaybz Jul 22 '14 at 13:33
  • @jaybz I feel like someone said that before (and must have deleted the comment). Basically, while those two have quite generic titles which might cover this case, their descriptions seem to aim very specifically at downloading things from the web - one the answer, the other the program that solves the problem. That's why I added my answer in the first place. – Martin Ender Jul 22 '14 at 13:39
  • @MartinBüttner In that case one of those two needs to be a bit broader than they already are. Obviously though, care needs to be taken not to make the loophole descriptions too broad and while I initially didn't want to combine those two for that reason, your recommendation and link convinced me otherwise. They're not even funny the first time. – jaybz Jul 23 '14 at 4:57
  • 1
    Reminds me of this xkcd comic. – Lawful Lazy Dec 18 '15 at 18:08

Zero-length quines

Considering an empty program a quine was original in the 1994 IOCCC.

Over two decades later, if you can answer a question with an empty program and that question is scored by length (e.g., ) and is tagged as , or , just notify the OP.

  • 7
    I mean technically, it is a quine, since the source is nothing and it outputs nothing – TrojanByAccident Jan 15 '17 at 5:33
  • 2
    @TrojanByAccident Quine: a non-empty computer program which takes no input and produces a copy of its own source code as its only output – Stephen Jun 26 '17 at 13:58
  • In stack based languages without other output, does stack content count as output? In that case in RPL you can get a 1-character quine, like 7, which pushes number 7 onto the stack. Maybe the way to counter it we would want the stack to contain the program listing in a string, so 7 wouldn't count as it would produce 7 rather than "7". – Heimdall Nov 8 '17 at 15:16
  • @Heimdall Improper quines is its own loophole. – Dennis Nov 8 '17 at 15:21

Using a different name for something that's prohibited

The title is not very clear, I know, but this is what it means: if a specific function is prohibited, someone can use a language where another term than "function" is used (for example "subroutine"), and then that user can claim that their submission is valid because they aren't using a function but a subroutine.

  • 3
    Seems to be the same as this one: meta.codegolf.stackexchange.com/a/1077/18865 – Simon Forsberg Jul 2 '14 at 23:40
  • 2
    @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). – ProgramFOX Jul 3 '14 at 6:25
  • 5
    "subroutine"/"function" or "add"/"+", it's all about using the same functionality with another name. Looks very related. – Simon Forsberg Jul 3 '14 at 9:54
  • 1
    Yes, it's certainly related. But not really the same. Anyway, it does not hurt having this loophole in another answer. – ProgramFOX Jul 3 '14 at 10:01

Identical functions with different names

For example, if + is forbidden, using

num3 = num1.add(num2)

or

num3 = num1
num3 += num2

or

num1++

or (GolfScript)

)

etc.

  • 21
    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 – SztupY Feb 25 '14 at 14:11
  • 101
    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 ++. – Peter Taylor Mar 5 '14 at 10:23
  • 19
    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). – TheConstructor Mar 7 '14 at 16:56

Using prior knowledge to circumvent other loopholes

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

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

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

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

  • Does this mean that if you write a language to golf easily, you can't use for challanges? – Lucas Sep 7 '15 at 22:44
  • 28
    @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. – Dennis Sep 7 '15 at 23:26
  • 3
    Just use first sandbox post date as acceptable language deadline instead of actual question post date. – Vi. Sep 30 '16 at 14:05
  • 2
    @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. – Dennis Sep 30 '16 at 15:36
  • @Dinnis, Then maybe allow using languages created even after the challenge officially started provided they are developed independently of the challenge participant? – Vi. Sep 30 '16 at 16:02
  • I think Using prior knowledge to circumvent ... may be genuinely intertesting if the method and style is innovative, not just boring re-application of prior hack. Prior art => forbidden loophole; no prior art => good answer (although maybe a non-competing entry). Like "best abuse of rules" in IOCCC. – Vi. Sep 30 '16 at 16:05

Using 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.

  • 13
    You forgot Mathematica. ;) What about paid-for languages with free trials though? – Martin Ender Oct 18 '15 at 8:26
  • 4
    And what about Matlab and Octave? – Beta Decay Oct 18 '15 at 9:30
  • 25
    @MartinBüttner If the free trial can expire, and block a user from using that language afterwards, it's still no good. – isaacg Oct 18 '15 at 16:01
  • @BetaDecay Octave is fine. Matlab isn't – isaacg Oct 18 '15 at 16:02
  • 7
    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? – Dennis Oct 18 '15 at 16:12
  • 9
    Such as AppleScript. – Addison Crump Oct 19 '15 at 18:18
  • 1
    Mathematica is so popular on this site. TinyMUSH, although free, seemed much worse than that... – jimmy23013 Oct 22 '15 at 9:45
  • 21
    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. – lirtosiast Nov 7 '15 at 6:09
  • 1
    Are there any platform-specific languages? – ASCIIThenANSI Dec 19 '15 at 16:07
  • 6
    @ASCIIThenANSI Well most assembly languages, for instance – isaacg Dec 19 '15 at 17:00
  • 1
    @AlexA. started a discussion about the free-ness here. – flawr Dec 27 '15 at 10:08
  • 9
    Note: Mathematica can now be used freely online. – LegionMammal978 Nov 19 '16 at 1:59
  • 2
    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." – Esolanging Fruit Mar 8 '17 at 6:01

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.

  • 22
    Isn't this covered by "languages must have an interpreter before challenge was posted"? Or "made up languages" more specifically? – Geobits Apr 14 '15 at 19:07
  • 4
    @Geobits Someone can make interpreters for MetaGolfScript before those challenges posted. At least they can be appeared to exist on the internet. – jimmy23013 Apr 14 '15 at 19:19
  • 3
    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. – Geobits Apr 14 '15 at 19:21
  • Well, I think I'll delete this after a few days. – jimmy23013 Apr 14 '15 at 19:25
  • 1
    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. – trichoplax Aug 24 '15 at 17:26
  • I think this is covered by the interpreter needing to predate the challenge. A generic MetaGolfScript interpreter would need command-line arguments to tell it what variation of the language you wanted, and you'd have to pay for those; that's fair. An interpreter for a specific instance of the language (i.e. one specific program) predating the challenge would have nothing to do with MetaGolfScript itself; it'd be more logically akin to the Hello, World program in Stuck. – user62131 Mar 18 '17 at 1:49
  • @ais523 You could implement a special purpose compression algorithm, and release the interpreters in that format. – jimmy23013 Apr 28 '17 at 9:01
  • I think it's ok as long as it works as with using the file name etc. The language name part 209180605381204854470575573749277224 should be included in the byte count making it longer than eg GS version. – Sylwester Jul 17 at 15:18

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.

  • 35
    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. – Martin Ender Jul 31 '14 at 7:30
  • 2
    @MartinBüttner I agree. That's what I tried to say in the last paragraph. I guess I failed. – Justin Jul 31 '14 at 17:17
  • 2
    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. – Martin Ender Jul 31 '14 at 17:35
  • 7
    Out of hand? You don't say? – Geobits Jul 31 '14 at 23:34
  • 1
    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. – Ming-Tang Aug 10 '14 at 6:29
  • 7
    Even purely suicidal submissions could still be a viable strategy, depending on the contest. If it works, and is allowed by the rules (especially when there's an explicit suicide action!), this really isn't much of a loophole. – Bob Aug 11 '14 at 2:28
  • 1
    Surely the solution is to not specifically allow a 'suicide' command in the game? – Rob Jan 6 '17 at 4:02

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 his/her answer based on only what was posted. This gives an unfair advantage over who posted a complete solution.

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

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

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

printf("Hello World!")
  • 5
    Provide an example? I don't see anything wrong with this, as long as the snippet does what is required. – Doorknob Mar 2 '14 at 21:21
  • @Doorknob Ok, done. – Victor Stafusa Mar 2 '14 at 21:29
  • 51
    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. – Peter Taylor Mar 2 '14 at 22:58
  • 2
    @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. – Victor Stafusa Mar 2 '14 at 23:16
  • Could you give a better example, that can be easily outdone with echo Hello World! in bash unless the question says the answer is required in C – user80551 Mar 12 '14 at 10:49
  • 17
    Well, printf("Hello World!") is obviously nonsense, but main(){printf("Hello World!");} compiles with GCC. – Dennis Mar 25 '14 at 22:42
  • 13
    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. – David Mulder Jun 22 '14 at 18:15
  • 1
    There is a more recent meta post for this specific topic here. – trichoplax Dec 28 '15 at 14:59
  • 6
    This should include Java answers where the answerer posts a function/method/subroutine/whatever outside of a class/interface/enum. – dorukayhan Jun 28 '16 at 18:41
  • @dorukayhan EXACTLY - This was precisely what I was thinking for when I originally posted this a few years ago. – Victor Stafusa Jun 28 '16 at 20:03

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.

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

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.

  • 8
    +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. – abligh Nov 17 '14 at 18:57
  • @abligh Yes, larger sets test cases help mitigate that, but even those can be hardcoded. And scoring by worst-case input only really works for fixed-size problems. – Martin Ender Nov 17 '14 at 18:59
  • With respect to: "but performing very badly for general input", the example that inspired trying to close this loophole permits performing optimally on all cases, yet still permit optimizing for the test cases. In that example, the result is effectively an integer between 0 and 6,670,903,752,021,072,936,959. It is easy to map n test cases to 0.._n_, resulting in compression to a single character (or less) for those cases, while having exactly zero impact on the average performance. So you may want to remove that condition to closing the loophole. – Mark Adler Nov 17 '14 at 23:30
  • @MarkAdler how about now? – Martin Ender Nov 17 '14 at 23:32
  • 11
    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. – Mark Adler Nov 17 '14 at 23:34
  • I guess that's better. – Mark Adler Nov 17 '14 at 23:35

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.

  • 10
    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. – lirtosiast Feb 11 '16 at 5:07
  • 1
    I don't think this is a problem, but a solution. Good on those users for thinking outside the box. – user56309 Sep 12 '16 at 19:16
  • 2
    @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. – Dennis Sep 12 '16 at 19:56
  • 1
    @Dennis I'd say, if the input doesn't match the challenge, it isn't an appropriate answer. It's arbitrary at this point that ints are 32 bit, doubles 64, floats 32, shorts 16, bools 1/8, and Strings are infinite. – user56309 Sep 12 '16 at 20:03
  • I know it's years since this was posted but I had a thought. "Hardcoding a list of the prime numbers below 128 is not allowed" -- what about including the single 128-bit value 0x800228A20208828828208A20A08A28AC or binary 10000000000000100010100010100010000000100000100010000010100010000010100000100000100010100010000010100000100010100010100010101100 which is a bitmap of the primes from zero to 127? – Ross Presser Nov 7 at 17:07
  • 1
    @RossPresser That's still hardcoding. The format doesn't matter. – Dennis Nov 7 at 17:09

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.

  • 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? – M. I. Wright Jun 20 '15 at 23:59
  • 4
  • 48
    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 – Mhmd Sep 22 '15 at 11:56
  • 3
    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! – Andreï Kostyrka Sep 9 '16 at 11:49

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.

  • 4
    Can you explain for non-pythonians what this snippet exactly does? – flawr Apr 26 '16 at 20:19
  • 7
    @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". – Martin Ender Apr 26 '16 at 20:22
  • But in tat case function to enumerate strings should be included. Also, if we force to count length of function name in such case, it will be longer then function body itself. – Qwertiy May 17 '16 at 13:02
  • @Qwertiy The name wouldn't be included in the byte count, because it's trying them all. He's telling you so that the viewer knows which string was the one that runs. The name doesn't occur in the program's original code at all. – mbomb007 May 18 '16 at 16:37
  • 1
    @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. – Qwertiy May 18 '16 at 16:57
  • 4
    Isn't this the Halting problem? What's to guarantee that you get to a solution in an infinite search space? – xdhmoore Jan 16 '17 at 5:01
  • @xdhmoore Given enough time is the key here - since we usually don't impose time restrictions in code golf, solutions which can take multiple lifetimes of the universe to complete are valid (assuming they don't break any other rules). – Mego Jan 16 '17 at 6:33
  • I know that's practically correct, but that doesn't sound right math-wise. Maybe I'm missing something. Maybe math isn't the point :) – xdhmoore Jan 16 '17 at 7:24
  • 1
    You're going to lose if you use this because the name of the function is longer than the target. – Joshua Apr 23 '17 at 15:42
  • 7
    @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. – Charles Jun 2 '17 at 6:09
  • This program is broken, since as soon as it evaluates "while true: \n&nbsp;&nbsp;&nbsp;&nbsp; pass\n", it infinitely loops and never reaches the end. Point is valid, but I would implement it differently: Have a pool of preemptible coroutines. Each iteration, add a coroutine to the pool corresponding to the evaluation of a string. The iterate over all coroutines. If one does not halt after a second, preempt it and leave it in the pool to continue on where it left off next iteration. This guarantees that all strings eventually get iterated over on an idealized computer. – eaglgenes101 Nov 3 '17 at 3:08
  • 1
    @eaglgenes101 The program is the wrong thing to focus on here. – Mego Nov 3 '17 at 6:25
  • This is my kind of program...just let it run, and eventually it will create the next big thing – Redwolf Programs Apr 14 at 14:57

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.

  • 3
    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. – V. Courtois Jul 19 '17 at 13:46
  • 2
    @V.Courtois The OP can still decide; this is just the default. – Dennis Jul 19 '17 at 16:02
  • I disagree with the final paragraph. I think it can be fun to get a long url by other means than to store it directly in the source code, and I think we should ban url shortening services specifically. That is information that you have stored somewhere else, and you may not do that, much in the same way that you may not create a language specifically to solve a question. – BlackCap Oct 25 '17 at 10:48

Improper quines

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

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

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

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

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

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

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.

  • 2
    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. – steenbergh Jan 26 '17 at 14:53

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?

  • 9
    This is common sense. It shouldn't even need to be written down. +1. – wizzwizz4 May 26 '16 at 17:38
  • It never occurred to me to write it down until someone asked if they could use it, and I realised I didn't have a place to point to in order to say no... – trichoplax May 26 '16 at 17:39
  • 27
    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. – Riker May 26 '16 at 17:41
  • 4
    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). – trichoplax May 26 '16 at 18:44
  • 1
    I posted a more detailed meta discussion – trichoplax May 27 '16 at 3:59
  • 1
    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. – Andreï Kostyrka Sep 9 '16 at 11:39
  • 4
    @AndreïKostyrka In Bases 8, 9, B-D and F-\inf it isn't... :-) – wizzwizz4 Oct 2 '16 at 11:30
  • It's hard to define this clearly. Is 1e2 an expression or a number? Is 1e9? Is 1.43e20? 1.43e22? (FWIW, Javascript expands 1.43e20 but ouputs 1.43e22 as is...) – Steve Bennett Jun 5 '17 at 5:51
  • @SteveBennett yes this topic proved to be worth its own separate meta discussion (see my previous comment), and there are a variety of answers there covering more detail. Feel free to add another answer each time something turns up that is not covered. – trichoplax Jun 5 '17 at 11:41

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.

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

You must log in to answer this question.

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