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.
49 Answers 49
Storing information in platform specifications
We often allow people to require certain qualities of the machine their answer is run on, (for example Operating System). However we should disallow requiring the program to be run on a certain specification to store information used for the challenge.
For example the language Nullary only has zero length programs instead deriving its source from the time since epoch. Similar languages could be created to exploit things such as monitor/terminal size, screen brightness, volume or even Operating System.
These types of answers should be disallowed.
-
\$\begingroup\$ I'm not sure about this one. For example, there could be languages where its interpreter only works properly on one operating system. \$\endgroup\$Okx– Okx2017年05月03日 17:07:17 +00:00Commented May 3, 2017 at 17:07
-
4\$\begingroup\$ @Okx Its not forbidding specifing the platform, only drawing information from the platform to circumvent having to put it in the program. \$\endgroup\$2017年05月03日 17:08:47 +00:00Commented May 3, 2017 at 17:08
-
1\$\begingroup\$ What I mean is, that the interpreter could act slightly differently on different operating systems (as, for example, it may not have some operating system specific function) therefore breaking answers. But about storing information that, I totally agree. \$\endgroup\$Okx– Okx2017年05月04日 10:01:48 +00:00Commented May 4, 2017 at 10:01
-
1\$\begingroup\$ I think this would be better rephrased as creating an environment, and it goes together with having the output pre-stored in a file already (unless you actually have an os that has that stuff stored there by default) \$\endgroup\$Destructible Lemon– Destructible Lemon2017年05月08日 05:45:28 +00:00Commented May 8, 2017 at 5:45
-
6\$\begingroup\$ Hmm. There was a Bash answer to the "output any string as long as the program" that ran
arch, which outputsi386on the appropriate hardware. I found that pretty creative - not cheaty at all. \$\endgroup\$Steve Bennett– Steve Bennett2017年06月05日 05:45:09 +00:00Commented Jun 5, 2017 at 5:45 -
\$\begingroup\$ Nullary is not a programming language as no code can be given to it. \$\endgroup\$The Empty String Photographer– The Empty String Photographer2023年06月27日 18:49:35 +00:00Commented Jun 27, 2023 at 18:49
Sidestepping in a theorem-proving challenge
A theorem-proving challenge is about proving a statement (= constructing a value of the given type) given in a specific host language (designed for theorem proving, most likely Lean or Coq).
One problem with this is that the host language may have various utilities that allow writing a "proof" that is not actually a sound proof of the given statement. This loophole bans any kind of answer that does this, including (but not limited to):
- Using a feature that introduces explicit holes in a proof (in Lean,
sorry,axiom,admit) - Using a feature that allows introducing a value of False (in Lean,
constant) - Proving a similar-looking, but not identical statement. e.g. in Lean,
is not considered a valid proof oflocal notation a `=` b := true theorem X (n : N) : ((list.nat.antidiagonal n).map (function.uncurry nat.choose)).sum = n.succ.fib := trivialtheorem X (n : N) : ((list.nat.antidiagonal n).map (function.uncurry nat.choose)).sum = n.succ.fib
Note: Per community consensus, languages/language versions are allowed regardless of when they were created, and as such this loophole is no longer enforced.
Features added to a pre-existing language, after the challenge was posted
See Covfefify a string. This might been solved in 45 bytes using:
select covfefify(:a) from dual@datadictionary
This isn't the same as these pre-existing loopholes:
- Using a made-up language specifically designed for the challenge: it is not a made-up language; it is a programming language in use.
- Using prior knowledge to circumvent other loopholes: it is not made up.
- Creating a new compiler for a language after a challenge was posted: it is not creating a new compiler, but extending an existing grammar.
None of these covers the scenario where an existing language is extended by a new function.
-
6\$\begingroup\$ It's the same as creating a new compiler. It's not a compiler, but it's still adding a feature after the challenge. \$\endgroup\$Riker– Riker2017年06月04日 15:05:13 +00:00Commented Jun 4, 2017 at 15:05
-
\$\begingroup\$ And was this what you meant? I tried to clarify a bit. \$\endgroup\$Riker– Riker2017年06月04日 15:07:18 +00:00Commented Jun 4, 2017 at 15:07
-
\$\begingroup\$ Hi @Riker, yes, this covers the loophole I think. I now find it impossible to perform fraud using this loophole. \$\endgroup\$Guido Leenders– Guido Leenders2017年06月04日 17:13:16 +00:00Commented Jun 4, 2017 at 17:13
-
1\$\begingroup\$ I would argue that the bytes added or changed in adding a language feature are part of your byte count for the challenge. While it is unlikely to be small, maybe someone has written a golfing language in a golfing language. \$\endgroup\$David G.– David G.2020年01月08日 12:58:06 +00:00Commented Jan 8, 2020 at 12:58
Exploiting the controller in a King-of-the-Hill challenge
I'm surprised that this wasn't here before, but this answer found a loophole to exploit in the KotH problem that should really be sealed off. (The rules of the challenge at time of writing only forbade using code that modifies the controller or the other bots, so the bot in question returned NaN instead knowing that the way it interacts with comparison operations would ensure that it would always be eliminated last.)
-
6\$\begingroup\$ If you find a behaviour in the controller that seems to be against the spirit of the challenge, it is better to report it by commenting on the question rather than post an answer exploiting it. \$\endgroup\$Jo King– Jo King2020年03月25日 00:14:57 +00:00Commented Mar 25, 2020 at 0:14
-
1\$\begingroup\$ Define "exploiting the controller". \$\endgroup\$the default.– the default.2020年09月08日 15:04:25 +00:00Commented Sep 8, 2020 at 15:04
-
\$\begingroup\$ @thedefault. Seems to me like a "know it when you see it" type thing. Taking advantage of what is obviously a bug, changing global variables to mess up other bots, getting forbidden information by tricking the controller, and so on. \$\endgroup\$2020年09月08日 22:09:14 +00:00Commented Sep 8, 2020 at 22:09
Empty answers to questions requiring an interpreter
If a question asks for an implementation of a language or a machine, the language/machine itself is a terribly boring answer. In particular:
"Simulating" a machine on that machine by accepting the initial state as its own initial state and producing the final state as its own final state.
"Interpreting" a language using an empty program that "accepts input" as the rest (i.e., all) of what's fed to the interpreter.
-
2\$\begingroup\$ What if your answer is "eval"? \$\endgroup\$Hello Goodbye– Hello Goodbye2021年04月20日 17:01:41 +00:00Commented Apr 20, 2021 at 17:01
-
1\$\begingroup\$ @HelloGoodbye, then that's quite a boring answer, isn't it? \$\endgroup\$dfeuer– dfeuer2021年04月20日 17:04:15 +00:00Commented Apr 20, 2021 at 17:04
-
3\$\begingroup\$ but does it fall under this loophole? \$\endgroup\$Hello Goodbye– Hello Goodbye2021年04月20日 17:04:43 +00:00Commented Apr 20, 2021 at 17:04
Bypassing restricted-source by storing data in the file name
Consensus says that it is perfectly fine to store data in the file name as long as that is added to the byte count. However, this doesn't seem entirely appropriate in restricted-source questions, since it could bypass the restrictions.
An example (which is what spurred me to write this) is this answer which was disqualified by the challenge author because the filename followed the restrictions and not the file content. I don't think this is the right approach. That answer was written in Pxem, a language where the program is often stored in the file name and the file itself is empty.
I think the best solution here is not actually to ban storing data in the file name for restricted-source challenges, which gives Pxem and some similar languages an inherent disadvantage, but instead to restrict submissions to one of:
- typical programs, where the filename doesn't matter, and the content adheres to the restrictions
- empty or functionally meaningless program content, but where the filename must adhere to the restrictions instead
There are still a few cases where this won't work (slashes and null bytes in Unix-like filesystems, and more on Windows), but I imagine we can just declare that as long as it works in theory it's fine.
Using a very high base (like base Graham’s number) in a challenge where you need to output a big number
In my answer, I just outputted 10, and claimed it was in base number that is bigger than any number printed in the challenge by another submission. And of course, this seems like cheating.
The answer has been deleted, so here is the exact answer, quoted. I had to change a bit of the markdown to fit it in a quote, but it looks the same.
Vyxal, \$\operatorname g\left(f_{\varphi(1,0,0)+7}(256^{26})\right)\$ where \$\operatorname g(x) = x \uparrow^x x\$ (outputs in base \$\operatorname g\left(f_{\varphi(1,0,0)+7}(256^{26})\right) \times {10}^6\$), 10 bytes
››››››››››Non base-10 numbers haven't been banned... so we have a new winner!
For context, here is the question.
-
1\$\begingroup\$ Come to think of it, I don't think we need to rule to get rid of these. Bases > 0x10FFFF can't be output as one character per output, so the answer doesn't do what it says it does. \$\endgroup\$Joshua– Joshua2024年10月11日 02:22:22 +00:00Commented Oct 11, 2024 at 2:22
Precomputing data (including compile-time computation) to achieve lower runtime in fastest-code challenges
Consider a challenge where solutions must print out as many Fibonacci numbers as possible within a certain time limit. A C++ solution might look like this:
#include <iostream>
using namespace std;
int main() {
int a = 1, b = 1, c = 0;
while(true) {
cout << b << endl;
c = b;
b = a+b;
a = c;
}
return 0;
}
This is a perfectly valid solution. All of the computation is done at runtime, and its score can be determined fairly.
Now, consider the following solution (adapted from this SO answer):
#include <iostream>
#include <cstdint>
using namespace std;
template<uintmax_t N>
struct fibonacci : integral_constant<uintmax_t, fibonacci<N-1>{} + fibonacci<N-2>{}> {};
template<> struct fibonacci<1> : integral_constant<uintmax_t,1> {};
template<> struct fibonacci<0> : integral_constant<uintmax_t,0> {};
int main() {
const uintmax_t max = 10000ull;
cout << fibonacci<1>() << endl;
cout << fibonacci<2>() << endl;
cout << fibonacci<3>() << endl;
// ...
cout << fibonacci<10000>() << endl;
return 0;
}
This program (compiled with g++ -o template_fib template_fib.cpp -std=c++14 -ftemplate-depth=12257) shifts the burden of computing the 10000 Fibonacci numbers to the compiler. At runtime, it's simply outputting 10000 constant values.
Such solutions which attempt to cheat the scoring system by doing all of the computation during a time where the clock is not running should either not be allowed, or be required to count their compilation time into their score.
-
\$\begingroup\$ Looks like a bad question to me. In most cases you could just also count the compile time for all submissions. But in your example, someone could just post a PHP or /// answer with the required output in it. \$\endgroup\$jimmy23013– jimmy230132016年10月22日 09:59:38 +00:00Commented Oct 22, 2016 at 9:59
-
1\$\begingroup\$ @jimmy23013 But there could be a legitimate solution that does all the work during runtime, but the compiler is woefully slow. We wouldn't want to penalize such a solution. \$\endgroup\$user45941– user459412016年10月22日 10:01:08 +00:00Commented Oct 22, 2016 at 10:01
-
\$\begingroup\$ Do you have any examples of such a compiler? \$\endgroup\$jimmy23013– jimmy230132016年10月22日 10:04:02 +00:00Commented Oct 22, 2016 at 10:04
-
\$\begingroup\$ I know that C++ itself could be slow if you use some libraries. But there are a lot of things that could be abused there. For example someone can write a compiler that automatically convert something like your first code to the second, and technically it could be just an optimization, without changing the semantics of the language. I'm thinking about something like limiting the size of the source code (if counting compile time) or the compiled code (if not counting compile time). Some questions already do, but I'm not sure it works for all cases. \$\endgroup\$jimmy23013– jimmy230132016年10月22日 10:23:58 +00:00Commented Oct 22, 2016 at 10:23
-
21\$\begingroup\$ Sorry, but I felt that I had to downvote this. As has already been mentioned, a compiler could easily do this optimisation itself, with the required flags of course. But in the example you've shown, it's just manually hard-coding the input using some syntactic sugar, and so it's barely different to
printf("1\n1\n2\n3\n5...");. \$\endgroup\$wizzwizz4– wizzwizz42016年10月22日 10:59:03 +00:00Commented Oct 22, 2016 at 10:59 -
4\$\begingroup\$ It doesn't matter if its code or a compiler flag doing the storage. Fundamentally, nearly all fastest-code challenges can be precompiled (if it takes input, you could simply precompile all possible input). This is a loophole, and one we often have to say "don't do" in all fastest-code challenges. \$\endgroup\$Nathan Merrill– Nathan Merrill2016年10月22日 12:30:59 +00:00Commented Oct 22, 2016 at 12:30
-
6\$\begingroup\$ This is an interesting point. Hard-coding manually is one thing, but actually having the real work done at compile-time is another. In the latter case, maybe you should count compile-time as part of the total run-time of the program. This is mostly an issue with C++ template "metaprogramming". Since C++ compilers use memoization instead of redoing recursive work every time, a dumb recursive algorithm implemented with template args can run much faster at compile time than the run-time performance of the same algo implemented in plain C. \$\endgroup\$Peter Cordes– Peter Cordes2017年07月20日 17:49:26 +00:00Commented Jul 20, 2017 at 17:49
-
1\$\begingroup\$ In the case of large data, the size of a stripped binary executable (or at least its
text+datasegments) is a useful measure. Getting the compiler to make a big table for you at compile-time has a run-time cost, but repeated runs (with the executable's pages hot in memory instead of cold on disk) doesn't reflect that. Still, pre-computing (especially from compact and maintainable source) is a valid option for real programs. Depending on the task, doing it at program-startup instead of compile-time is more appropriate, though, for a long-running program. \$\endgroup\$Peter Cordes– Peter Cordes2017年07月20日 17:53:17 +00:00Commented Jul 20, 2017 at 17:53 -
1\$\begingroup\$ Also, sequential Fibonacci numbers is a poor example, unless you were showing a stupid recursive implementation. Both of those will run at near-identical speeds, totally dominated by the
cout <<function calls. If anything, the loop might run faster on a modern x86 because it stays hot in the uop cache and branch predictors, instead of having to decode newmovandcallinstructions. (Even unconditional direct branches likecallneed branch prediction to run efficiently.) \$\endgroup\$Peter Cordes– Peter Cordes2017年07月20日 17:58:13 +00:00Commented Jul 20, 2017 at 17:58 -
1\$\begingroup\$ If you really wanted to optimize, you'd write code that turned into a string of multiple numbers and newlines at compile time. That could really run fast, not requiring any integer->string conversions and only one I/O function call for a big block of data, and might actually have the run-time dominated by a write() system call, and/or soft page-faults reading the giant string. Either way, printing
'\n'instead ofstd::endlis probably faster (since it forces an extra flush), but printing multiple newlines at once is way faster on a line-buffered stream. \$\endgroup\$Peter Cordes– Peter Cordes2017年07月20日 18:00:34 +00:00Commented Jul 20, 2017 at 18:00 -
6\$\begingroup\$ TL:DR, the first version probably runs faster! Fully unrolling a loop that long is bad, especially with no loop-condition. \$\endgroup\$Peter Cordes– Peter Cordes2017年07月20日 18:02:23 +00:00Commented Jul 20, 2017 at 18:02
-
\$\begingroup\$ @PeterCordes The specific example isn't very important. The point is, fastest code challenges are timed based on runtime, which excludes compile time for compiled languages. Thus, solving the problem at compile time to get an extremely low run time is loophole abuse. \$\endgroup\$user45941– user459412017年07月21日 02:37:54 +00:00Commented Jul 21, 2017 at 2:37
-
\$\begingroup\$ @Mego: I guess I'd agree with that, even if template metaprogramming to achieve that would be the right solution in a real program for that case. The problem is that it's hard to state the rule in a way that blocks everything we want to block, but allows everything we want to allow. (Analyzing the specific example was an interesting side-track, but ultimately irrelevant. Still, since I don't think we can do much better than just knowing it when we see it, having the at-compile-time example do some string concatenating to beat the run-time version would be good.) \$\endgroup\$Peter Cordes– Peter Cordes2017年07月21日 02:53:03 +00:00Commented Jul 21, 2017 at 2:53
-
1\$\begingroup\$ As other people have pointed out, pre-computing some quick things as part of a bigger algorithm is realistic. It's only fully pre-computing the final answer that we probably must always disallow. So the headline wording of this answer should be more specific. \$\endgroup\$Peter Cordes– Peter Cordes2017年07月21日 02:54:43 +00:00Commented Jul 21, 2017 at 2:54
-
3\$\begingroup\$ @Kaz Having to count the compile time for a program that doesn't abuse this loophole would be unfair, since it's the compiler and not the specific program taking time. \$\endgroup\$user45941– user459412017年08月01日 04:44:52 +00:00Commented Aug 1, 2017 at 4:44
Infinite output programs that wouldn't give all output given infinite resources
Example, loophole-violating code to output all integers:
bigint i = 0;
for(;;) bigint_print(i++);
This would never output negative numbers, even given unlimited resources, so it does not fulfil the challenge's requirements. A program that does fulfil the requirements would be:
bigint i = 0;
for(;;) {
bigint_print(i++);
bigint_print(-i);
}
-
\$\begingroup\$ I think this needs some context. \$\endgroup\$Peter Taylor– Peter Taylor2019年10月04日 20:04:58 +00:00Commented Oct 4, 2019 at 20:04
-
\$\begingroup\$ @PeterTaylor chat.stackexchange.com/transcript/message/51976966#51976966 \$\endgroup\$wizzwizz4– wizzwizz42019年10月04日 20:11:00 +00:00Commented Oct 4, 2019 at 20:11
-
3\$\begingroup\$ I don't get it. The context looks like a bad joke, and responses to a bad joke don't seem like a sound basis for proposing standard loopholes. \$\endgroup\$Peter Taylor– Peter Taylor2019年10月04日 20:52:45 +00:00Commented Oct 4, 2019 at 20:52
-
9\$\begingroup\$ I think infinite unordered output is a rare enough class of problem that it might be best to just leave it up to the the question to specify that "Any [element of the output] must eventually be printed after a finite amount of time." \$\endgroup\$Unrelated String– Unrelated String2019年10月04日 21:04:19 +00:00Commented Oct 4, 2019 at 21:04
Cracking your own answer (including using an alt account) in a cops-and-robbers challenge.
It would just allow you to get a large number of points with no effort! Plus, it doesn’t even make any sense to do that.
Outputting a Lazy list/Lazy data type in fastest-code challenges
This just moves the computation to after runtime. For example, in Python, the code:
def f():
return 492084389428**209480438084, 6356425635**23984723879
takes a very long time to run. However, if you use the yield keyword to generate a Lazy List:
def f():
yield 492084389428**209480438084
yield 6356425635**23984723879
it returns the result instantly, without computing it. However, when you iterate through it:
x = f()
print(next(x))
print(next(x))
It takes a really long time, since the computation was moved here, after the runtime.
-
3\$\begingroup\$ Related: codegolf.meta.stackexchange.com/a/12327/106545 "If this method is used in time-based challenges then the time required to resolve the final promise must be counted towards your score." Not quite a duplicate since generators and promises aren't quite the same thing. \$\endgroup\$Bbrk24– Bbrk242023年07月17日 18:17:55 +00:00Commented Jul 17, 2023 at 18:17
-
1\$\begingroup\$ @Bbrk24 I think they’re similar enough. \$\endgroup\$The Empty String Photographer– The Empty String Photographer2023年07月17日 18:45:34 +00:00Commented Jul 17, 2023 at 18:45
Teaming up in a KOTH
Each KOTH bot must try for its own win. If a bot has logic that specifically benefits a different bot, especially a bot by the same author, that wouldn't be fair. Then you could "win" simply by submitting a large number of teaming bots.
Conversely, targeting a specific bot to hurt them is also unfair. Of course, efficient counter-play is part of any winning strategy, but long as you are targeting a range of bots and not anyone specific that is ok.
It is also OK if your winning strategy ends up benefiting some other bot without explicitly targeting it.
Examples that would violate this:
-
8\$\begingroup\$ this feels like combining two separate answers; teaming up in a koth and specifically targeting another bot are completely different issues IMO. At the very least, the title of this post should reflect the full contents. \$\endgroup\$thejonymyster– thejonymyster2023年03月08日 00:07:43 +00:00Commented Mar 8, 2023 at 0:07
Creating custom objects whose truthiness function solves the problem
For decision-problem with restricted-time or restricted-complexity:
Example of a disallowed submission: For Check if 2 arrays contain the same element, the following python submission (or stuff like this) would not be permitted:
class A:
def __init__(self,x,y):self.x=x;self.y=y
def __bool__(self):
for a in self.x:
if a in self.y:return True
return False
and using the class A as the function submission, while ignoring the run-time of the __bool__ method.
-
3\$\begingroup\$ I think this would be fine as long as you include the
__bool__method in your complexity or time calculation \$\endgroup\$mousetail– mousetail2025年05月24日 11:34:25 +00:00Commented May 24 at 11:34 -
\$\begingroup\$ The way I see it, the time complexity is the time takes to output the value. \$\endgroup\$Lucenaposition– Lucenaposition2025年05月24日 23:42:04 +00:00Commented May 24 at 23:42
Making an OS specifically designed for the challenge
In this sandboxed challenge, it says you can use any environment you want. So I thought, what if you made a specific OS where the Python distribution that was made for the OS had a feature that played the tune in just a single function call? Surely that would be cheating?
Storing information in type of input
Imagine a language with billions kinds of arrays and you choose one type as input to do the job, which is silly
-
-
\$\begingroup\$ Do you have an example post where this is (ab)used? \$\endgroup\$Mast– Mast2023年01月08日 12:57:24 +00:00Commented Jan 8, 2023 at 12:57
-
\$\begingroup\$ @Mast As mentioned in chat I don't know any language that doing this is good, it's only preventing \$\endgroup\$l4m2– l4m22023年01月08日 12:59:05 +00:00Commented Jan 8, 2023 at 12:59
-
\$\begingroup\$ If it hasn't happened yet, forbidding it seems premature to me. \$\endgroup\$Mast– Mast2023年01月08日 13:10:07 +00:00Commented Jan 8, 2023 at 13:10
-
-
\$\begingroup\$ I can't even comprehend this suggestion. \$\endgroup\$Oskar Skog– Oskar Skog2023年02月28日 09:19:40 +00:00Commented Feb 28, 2023 at 9:19
A script invoking itself as a form of looping/recursion, where the filename has to be a specific name
e.g. I answered a question with PowerShell which included sleep 1;t where the script had to be called t.ps1 and saved in the PATH, so it would call itself.
I considered it maybe reasonable because running programs is part of what shell scripts do, and there's no reference to it in this meta topic as a standard loophole. The closest is about hiding information in the filename, e.g. a file called "hello world".
People commented to say relying on the filename is frowned upon, so I'm submitting it here so it can be voted on and be on record as approved/denied in future. Is it a loophole, or is it valid in the same way as an answer might say "requires version 3 or above" or "only works in a particular interpreter"?
-
5\$\begingroup\$ I don't think requiring a specific filename is a problem in general, unless this is abused to hide code or store information in the filename. For example, every full Java program requires a specific filename for compilation. \$\endgroup\$2015年12月16日 17:46:55 +00:00Commented Dec 16, 2015 at 17:46
-
\$\begingroup\$ @Dennis But that is also a requirement of the language - using it explicitly for purposes other than compiling seems a bit loophole-y. \$\endgroup\$Addison Crump– Addison Crump2015年12月16日 18:25:30 +00:00Commented Dec 16, 2015 at 18:25
-
2\$\begingroup\$ If it is not considered a loophole, then the filename should also be counted in the byte count. \$\endgroup\$Addison Crump– Addison Crump2015年12月16日 18:29:18 +00:00Commented Dec 16, 2015 at 18:29
-
\$\begingroup\$ The filename is counted,
tin the script is the filename. if you had a bash script which calledsedwould you countsedas 3 more characters as well as it appearing in the script? It's also relying on a particular program with a particular filename being in the PATH. \$\endgroup\$TessellatingHeckler– TessellatingHeckler2015年12月16日 18:48:19 +00:00Commented Dec 16, 2015 at 18:48 -
\$\begingroup\$ Then you'd need to count the
tin the code and thet.ps1in the filename - if you changed either of these, it wouldn't function, would it? \$\endgroup\$Addison Crump– Addison Crump2015年12月16日 18:53:50 +00:00Commented Dec 16, 2015 at 18:53 -
8\$\begingroup\$ @FlagAsSpam I fail to see why we would count
t.ps1as 5 bytes, yett.javaas 0 bytes, especially since this seems to be the most natural form of recursion for PowerShell. \$\endgroup\$2015年12月16日 18:55:51 +00:00Commented Dec 16, 2015 at 18:55 -
2\$\begingroup\$ @Dennis You need to call it in Java, because that's how the language works. Recursion can be called via other methods in PowerShell, as shown by another answer in the same question. \$\endgroup\$Addison Crump– Addison Crump2015年12月16日 18:57:38 +00:00Commented Dec 16, 2015 at 18:57
-
\$\begingroup\$ @FlagAsSpam If we're talking about the same answer, it uses a for loop, not recursion. In any case, I could get behind a convention that counts
t.ps1as one byte (for thet), since the rest is just the typical PowerShell extension. \$\endgroup\$2015年12月16日 19:04:24 +00:00Commented Dec 16, 2015 at 19:04 -
2\$\begingroup\$ For a sed script which requires a flag, the flag must be counted in the byte count because it's a required extra to make the answer work. But it's not possible to save a script with no filename, so I'm not mandating extra information, so why would it count extra? You always need a filename ending in
.ps1for a PS script, constraining what the filename can be doesn't add any extra bytes. (@Dennis, I partly deleted my answer because it would eventually overflow - but I also wonder about that - usable answers which would eventually hit real world limits are sometimes allowed). \$\endgroup\$TessellatingHeckler– TessellatingHeckler2015年12月16日 19:06:29 +00:00Commented Dec 16, 2015 at 19:06 -
\$\begingroup\$ @TessellatingHeckler I don't think we have a default for that. The best option is to ask the OP in a comment. (Note that
exec 0ドルin Bash should not have the same limitation, sinceexecreplaces the current shell with another one.) \$\endgroup\$2015年12月16日 22:18:47 +00:00Commented Dec 16, 2015 at 22:18
Using comments to circumvent character requirements/restrictions
It's cute and makes you laugh once, but when you see it several times over several challenges, it just becomes facetious and contrary to the spirit of the game.
-
66\$\begingroup\$ I think that's actually a good answer for that question \$\endgroup\$SztupY– SztupY2014年02月25日 14:15:02 +00:00Commented Feb 25, 2014 at 14:15
-
\$\begingroup\$ @SztupY It's clever, and I laughed about it and upvoted it. But it is against the "spirit" of the question, and this kind of thing is done in lots of places. \$\endgroup\$asteri– asteri2014年02月25日 14:26:33 +00:00Commented Feb 25, 2014 at 14:26
-
5\$\begingroup\$ It's funny once. But I agree, if you post something like that challenge, you should forbid comments. (If someone does not, leave a link to this answer). \$\endgroup\$Johannes Kuhn– Johannes Kuhn2014年03月13日 15:17:10 +00:00Commented Mar 13, 2014 at 15:17
-
4\$\begingroup\$ @JeffGohlke Actually, for that particular question, it's completely fair game - but sadly it's not the shortest by a long shot. \$\endgroup\$Joe Z.– Joe Z.2014年03月24日 22:28:20 +00:00Commented Mar 24, 2014 at 22:28
-
\$\begingroup\$ @JohannesKuhn I don't think comments was a big concern with that question, since the comments don't make it trivial. You still need to be printing characters without using them. \$\endgroup\$Cruncher– Cruncher2014年05月14日 20:34:43 +00:00Commented May 14, 2014 at 20:34
-
\$\begingroup\$ Perhaps "don't submit a program without any code" is what you mean \$\endgroup\$Ky -– Ky -2014年10月17日 03:53:09 +00:00Commented Oct 17, 2014 at 3:53
-
2\$\begingroup\$ As I told in some comment, my answer should be the worst possible answer. And funnily some people even posted longer answers. \$\endgroup\$Johannes Kuhn– Johannes Kuhn2014年10月17日 14:36:59 +00:00Commented Oct 17, 2014 at 14:36
-
6\$\begingroup\$ I am strongly against this; this means that there is something wrong with the question, not the answer. \$\endgroup\$MilkyWay90– MilkyWay902019年04月13日 03:16:23 +00:00Commented Apr 13, 2019 at 3:16
Compressing your source code
Some language provide builtin facilities to compress data and execute the result as source code. I consider this to be a standard loophole, especially when the challenge is counted in characters instead of bytes.
-
\$\begingroup\$ This can be argued and extended to many other built-ins. Like Mathemetica's built in
MandelbrotSetPlotto plot a mandelbrot set. I think the practice of questions themselves explicitly disallowing such compressions is the most favorable scenario and holds true for any such built-in, not just code compression ones \$\endgroup\$Optimizer– Optimizer2015年04月13日 14:25:56 +00:00Commented Apr 13, 2015 at 14:25 -
35\$\begingroup\$ I do not think that this is a loophole. The default scoring is in bytes for good reason. If a challenge author deviates, then I'd assume they have a good reason for doing so. \$\endgroup\$Rainbolt– Rainbolt2015年04月13日 14:27:11 +00:00Commented Apr 13, 2015 at 14:27
-
\$\begingroup\$ In addition, if you're doing a kolmogorov-complexity challenge in a language like ///, the only way to be competitive whatsoever is to compress the source code. If you can find a way to encode and then
evalyour code so that it's shorter than the normal algorithm, than good for you. \$\endgroup\$Esolanging Fruit– Esolanging Fruit2017年03月08日 06:14:52 +00:00Commented Mar 8, 2017 at 6:14 -
\$\begingroup\$ +1: You write source code for humans. The fact that a computer will process your code is (almost) none of your business. Hence source code needs to remain legible for humans. \$\endgroup\$Kai Burghardt– Kai Burghardt2024年09月22日 09:08:38 +00:00Commented Sep 22, 2024 at 9:08
Using built-in functions to do the work
Mathematica is a big one for this, with Fibonacci[n] to calculate the n'th Fibonacci number.... I have no objection to these being posted as a side note within the main answer though - that is interesting and helps me learn different languages capabilities.
Another one that encounters this more often than most is with Assembly, especially with questions requiring bitwise-related operations, such as ARM's rbit reversing the bits in place or Haswell's pext to extract bits according to a mask.
-
11\$\begingroup\$ Or using
CellularAutomatonto implement a Game of Life \$\endgroup\$AShelly– AShelly2014年02月24日 01:59:27 +00:00Commented Feb 24, 2014 at 1:59 -
5\$\begingroup\$ I think this only applies when the main part of the question is for the function. \$\endgroup\$Justin– Justin2014年02月24日 02:56:10 +00:00Commented Feb 24, 2014 at 2:56
-
\$\begingroup\$ @Quincunx Yes, I know. Still... \$\endgroup\$user10766– user107662014年02月24日 03:24:34 +00:00Commented Feb 24, 2014 at 3:24
-
68\$\begingroup\$ Perhaps if it were qualified with "lion's share of the work". Fibonacci[n] to solve a Fibonacci problem is bad form, but there are also plenty of instances of high-level stats/graphics/maths functions in R, Processing, Mathematica, etc. being used in the context of good answers. It's hard to define objectively the line between good answer playing to the language's strengths and lazy answer plastering over the answerer's weakness. But you generally know it when you see it. \$\endgroup\$Jonathan Van Matre– Jonathan Van Matre2014年02月24日 06:28:50 +00:00Commented Feb 24, 2014 at 6:28
-
15\$\begingroup\$ If we were all limited to the same set of built-in functions, every contest would be won by APL or Golfscript because their command names are the shortest. \$\endgroup\$Michael Stern– Michael Stern2014年02月28日 16:01:46 +00:00Commented Feb 28, 2014 at 16:01
-
5\$\begingroup\$ @MichaelStern I mean that if the challenge is to implement a function, we shouldn't just give a function that was already implemented into the source of your language. \$\endgroup\$user10766– user107662014年02月28日 16:22:43 +00:00Commented Feb 28, 2014 at 16:22
-
\$\begingroup\$ I believe one purpose of code golf is to display features, especially obscure ones, of a language, but I still agree they should be disallowed. \$\endgroup\$Ming-Tang– Ming-Tang2014年04月15日 21:06:48 +00:00Commented Apr 15, 2014 at 21:06
-
123\$\begingroup\$ Contrarily, I think using built-in functions is good. It highlights the benefits of different languages. \$\endgroup\$daviewales– daviewales2014年04月19日 09:51:33 +00:00Commented Apr 19, 2014 at 9:51
-
\$\begingroup\$ I made an edit to include the increasing prevalence of assembly built-ins under the same umbrella here. \$\endgroup\$Claudia– Claudia2014年09月02日 00:07:25 +00:00Commented Sep 2, 2014 at 0:07
-
3\$\begingroup\$ What if, in a certain language, there's no work to be done to solve a problem? For example, for a snippet, by receiving the input the result is already calculated? That's what I ran into for my AVR answer \$\endgroup\$rsaxvc– rsaxvc2015年01月04日 19:06:21 +00:00Commented Jan 4, 2015 at 19:06
-
\$\begingroup\$ @rsaxvc I do not know. You will have to ask a question about this. \$\endgroup\$user10766– user107662015年01月05日 01:45:52 +00:00Commented Jan 5, 2015 at 1:45
-
8\$\begingroup\$ Isn't that the whole point of built in functions, though? I mean I thought the whole idea behind programming was to not reinvent the wheel. \$\endgroup\$tfitzger– tfitzger2015年04月15日 18:12:50 +00:00Commented Apr 15, 2015 at 18:12
-
8\$\begingroup\$ @Hosch250 Then it should be up to the poster to determine what level of function answers can contain. Technically, most of the answers on this site rely on functions, routines, subroutines, etc to get their answer. Some can just do it in one or two instead of twelve of fifteen. I've seen posts limit the use of min or max functions, use of inherent random functions, use of mod, etc. There, the person asking the question was responsible for deciding the level of function that was allowed. \$\endgroup\$tfitzger– tfitzger2015年04月15日 18:35:56 +00:00Commented Apr 15, 2015 at 18:35
-
2\$\begingroup\$ There was a question that required the computation of the Kolmogorov—Smirnov statistic. It is a built-in in R that requires no extra packages, so why should I re-invent the wheel? Forcing to re-implement the intrinsic features of a language in the same language seems futile to me. \$\endgroup\$Andreï V. Kostyrka– Andreï V. Kostyrka2016年08月31日 23:05:40 +00:00Commented Aug 31, 2016 at 23:05
-
5\$\begingroup\$ Banning built-ins is like banning golfing languages; it is done out of annoyance and there is no formal definition of a builtin \$\endgroup\$MilkyWay90– MilkyWay902019年03月17日 18:38:11 +00:00Commented Mar 17, 2019 at 18:38
You must log in to answer this question.
Explore related questions
See similar questions with these tags.
;)) \$\endgroup\$curl -L http://bit.ly/012foobararen't? \$\endgroup\$average of all answer scores / 2orthe score of the highest voted answer / 5or something), but that would be pretty complicated. \$\endgroup\$