Take the 2-minute tour ×
Programming Puzzles & Code Golf Stack Exchange is a question and answer site for programming puzzle enthusiasts and code golfers. It's 100% free, no registration required.

Write a script that works fine when a blank line is present in the flow of program logic, but breaks or causes unexpected behaviour when that line is removed.

Avoid standard loopholes and stupid answers. Your program should do something "useful," even if all it does is add a few integers.

Removing an empty line from a multiline string doesn't count, unless the expected output from that multiline string shouldn't technically change (ie: if you're removing all blank lines matching ^$).

Whitespace foolery isn't allowed either; don't do weird things with carriage returns, tabs, spaces, etc.

share|improve this question
2  
Are empty lines inside multiline strings counted? –  Sieg Jun 12 at 18:39
7  
I think you should exclude Whitespace. –  nneonneo Jun 12 at 18:40
13  
I think that Whitespace is a "standard loophole" –  core1024 Jun 12 at 18:42
5  
nneonneo is talking about Whitespace, which is a language that uses only spaces as its syntax. –  Kyle Kanos Jun 12 at 18:48
2  
"unexpected functionality" is a very good phrase. –  Kaz Jun 13 at 19:16

28 Answers 28

Javascript

Opens an alert popup with "Hello, World!" if the blank line exists, otherwise alerts "0".

(function(){
    alert(~(arguments.callee+[]).indexOf('\n\n') && "Hello, World!");

})();

Demo

Explanation:

arguments.callee is a reference to the self-executing anonymous function.

Appending a blank array ([]) casts the function to a string, which gives you its source code.

indexOf returns -1 if the string is not found.

Performing a bitwise not operation (~) results in -1 being turned into 0, which is a falsey value.

share|improve this answer
1  
What trickery is this?! –  Kroltan Jun 13 at 1:10
1  
arguments.callee contains the source of the function. –  Matthew Jun 13 at 1:35
    
@Kroltan I've added an explanation to the answer :) –  nderscore Jun 13 at 2:34
2  
Note that this no longer works in strict mode (which most modern code would be using). Strict mode forbids the use of arguments.callee. –  Daniel Lo Nigro Jun 15 at 4:18
1  
@Michael: No, spec says nothing about the exact format. In fact‌​, there are engines running around that do not preserve whitespace. –  Bergi Jun 15 at 4:59

C

This magic 8-ball program will still work without the blank line, but it will be a bit more decisive — none of the neutral answers will ever appear in the output.

#include <stdio.h>
#include <time.h>
#include <stdlib.h>
int main() {
  int x, t;
  char *quotes[] = {
        // Positive :-)
        "It is certain", "It is decidedly so", "Without a doubt", "Yes definitely", "You may rely on it",
        "As I see it, yes", "Most likely", "Outlook good", "Yes", "Signs point to yes",
        // Indifferent :-\

        "Reply hazy try again", "Ask again later", "Better not tell you now", "Cannot predict now", "Concentrate and ask again",
        // Negative :-(
        "Don't count on it", "My reply is no", "My sources say no", "Outlook not so good", "Very doubtful" };
  srandom(time(NULL)); // Initialize random number generator
  x = random() % (sizeof(quotes) / sizeof(char*)); // Choose a random outcome
  printf("The Magic Eight Ball says...\n%s\n",quotes[x]);
  return 0;
}

Explanation

When the C parser sees a backslash followed by a newline character, it ignores both and treats the second line as a continuation of the first. Without the empty line, the "indifferent" answers will all be treated as part of the previous comment.

share|improve this answer
42  
I +1'd, but seeing C comments ending with a backslash is starting to become a standard loophole, IMO. –  Tim S. Jun 12 at 22:27
2  
It was a reference to this "standard loopholes" post, so maybe not literally a "loophole". –  Tim S. Jun 13 at 1:14
5  
@TimS. if you are bored with this "solution", why did you upvote? –  Jan Dvorak Jun 13 at 5:21
5  
The backslash-the-next-line-into-a-comment answers (trigraph or no trigraph) are making me wish I had 125 reputation. I keep seeing them and they're starting to be awfully repetitive, totally see-through, and no longer clever or funny. (Which is unfortunate for those using them, like squeamish here, because they in no way deserve the ire and are sometimes totally unaware of this - but the trick is earning it.) –  doppelgreener Jun 13 at 7:11
4  
@Jan starting to become standard is not the same as long-standard/overdone...its use is fairly clever here, it doesn't look out of place (unlike some I've seen, which inexplicably have character(s) at the end of a comment, or end their comments with the comment-start character(s) in order to do something unusual). So: I upvote the solution, not the continued use of its trick. –  Tim S. Jun 13 at 16:31

Befunge-93

v
&
&
+
#

.
@

My first befunge program :)

It reads two numbers from the input and prints their sum. If you delete the empty line, it doesn't print anything.

Explanation:

v sets a downward direction for executing the code
& reads an integer
+ adds the numbers together
# skips the next command
. prints an integer from the stack
@ ends the program

As written, # skips over the empty line and contines with .. Buy when you delete the empty line, . is skipped.

There seems to be a nice interpreter at http://befunge.aurlien.net/

share|improve this answer
    
Ah, clever one. –  Sieg Jun 12 at 19:55
    
Befunge 98 also does this. Good thinking. And this interpreter has some benefits (I haven't used yours much, so I don't know its benefits). –  Quincunx Jun 12 at 20:31

Ruby/Shell

​​​​​​
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#!   The Amazing Integer Adder             !
#! Adds 1 and 1, and displays the result   !
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

p 1+1

Works fine if a newline is at the top, otherwise the first comment line is interpreted by the shell as a malformed shebang.

share|improve this answer
2  
Wouldn't this either always work or always not work? For example, if you ran it as ruby youranswer.rb, it wouldn't look for a shebang because it's being run in the ruby interpreter already, but if you ran it as ./youranswer.rb it wouldn't run at all because there's no shebang.. –  Brendan Long Jun 13 at 18:27
4  
At least with my ruby, the shebang is honored even if you run it as ruby youranswer.rb, which can be useful to set necessary command-line switches in the file. So without the newline I get ruby: no Ruby script found in input (LoadError) –  histocrat Jun 13 at 18:48

Scala

case class IntWrapper(i: Int)

{
  val answer = (IntWrapper(0) /: (1 to 100)){(x, y) => IntWrapper(x.i + y)} // Add up ints
  println(s"Sum of wrapped integers is $answer")
}

If you remove the blank line, no output will be printed. Which is for the best, as your stack would overflow if you actually called IntWrapper.

This is a corner case of Scala's semicolon inference. Normally newlines get a semicolon whenever the resulting code would be valid. However, the Scala devs didn't want to force people to use Egyptian brackets, so it's valid to put the brackets for a class definition on the line immediately after - no semicolon is added, even though one could be. However, a blank line divorces the brackets from the class definition. With the blank line removed, the code changes from being a class definition and a block, to a class definition with a constructor - and a recursive constructor at that!

share|improve this answer
5  
Very nice of them not to force Egyptian Brackets. But semicolon inferrence is a bad idea, in my opinion. –  Almo Jun 13 at 20:26
    
Semicolon inference gets a bad name, largely due to JavaScript. It's a bit less painful if you design the language with it in mind (no one complains about it in Python, for example). Unfortunately Scala included a couple of features that don't play nice with semicolon inference. There's this, and postfix operators (which I was tempted to use in my answer, but it's a bit passé). –  James_pic Jun 13 at 21:51
1  
@James_pic: AFAIK no one complains about it in Python because it doesn't exist in Python. In JS, semicolons are a necessary part of the syntax, and can be inserted (inferred) at certain points. In Python, semicolons are not a necessary part of the syntax, but can be used optionally. That's a big difference. –  Mason Wheeler Jun 16 at 21:42
    
It may seem like a big difference, but if Scala removed a few features, which currently make statement boundaries ambiguous, it would move from JavaScript's side of the fence to Python's. –  James_pic Jun 17 at 8:11
1  
@James_pic: What makes python different is that there newline terminates the statement unless escaped or inside any kind of bracket. That is there is no complete/incomplete rule. –  Jan Hudec Jun 17 at 8:21

GolfScript

~{.@\%:

}do;

Calculates the GCD of two non-zero integers. Removing the blank line breaks the program.

Try it online.

How it works

This is a GolfScript implementation of the Euclidean algorithm:

      # STACK: "15 24"
~     # Interpret the input string.
{     # STACK: 15 24
  .@  # Duplicate the topmost integer and rotate the other on top of both copies.
      # STACK: 24 24 15
  \   # Swap the topmost integers.
      # STACK: 24 15 24
  %   # Calculate the modulus.
      # STACK: 24 15
}do   # If the modulus is non-zero, repeat the loop.
;     # Discard the last modulus.

There's just one tiny problem:

{}do pops the modulus from the stack to check if it's truthy, so it has to get duplicated at the end of the loop. This is normally accomplished by ., but :\n\n has the same effect: It stores the topmost stack item in the variable LF (:\n), then pushes the contents of that variable.

share|improve this answer
5  
Wow, even that's a variable? :O –  aditsu Jun 13 at 3:32
    
@aditsu: Only #, { and } cannot be used as variable names, as they're part of the syntax. Every other token is fine, including strings. –  Dennis Jun 13 at 3:53
    
@Dennis wow. TIL even strings can be used as variables. Is that useful for anything? –  Jan Dvorak Jun 13 at 5:24
    
@JanDvorak: Aside from some edges cases (palindromic code, underhanded code, probably not. I think this is just a (documented) side effect of how the GolfScript interpreter splits the code into tokens. –  Dennis Jun 13 at 13:06
    
@Dennis does that mean that .:-1 stores the input into -1, not the minus sign itself? Hmm... –  Jan Dvorak Jun 13 at 13:58

MediaWiki Template Syntax

Define Template:Foo as

{{{a

b|Uh-oh!}}}

In another page,

{{Foo|a

b=Works!}}  <!-- outputs "Works!" -->

{{Foo|a


b=Works!}}  <!-- outputs "Uh-oh!" -->

{{Foo|a
b=Works!}}  <!-- outputs "Uh-oh!" -->

In MediaWiki, parameter names can contain newlines.

share|improve this answer
1  
Nice, this is along the lines of what I was looking for, weird edge cases like this. –  Naftuli Tzvi Kay Jun 12 at 19:26

LaTeX (backref)

The following LaTeX code uses a citation and the citation contains a list of pages, where the entry is citated. Here it is the first page. Package hyperref also adds PDF links, the page back reference is red, the citation link is green.

\documentclass{article}
\usepackage[colorlinks,pagebackref]{hyperref}
\begin{document}
Donald E. Knuth is the inventor of \TeX~\cite{knuth}.
\begin{thebibliography}{9}
\bibitem{knuth}
Donald E. Knuth: \textit{The \TeX book}; Addison Wesley, 1984.

\end{thebibliography}
\end{document}

Result

But LaTeX does not require the empty line, the empty line looks superfluous and the example will still work without hyperref and the empty line:

\documentclass{article}
\begin{document}
Donald E. Knuth is the inventor of \TeX~\cite{knuth}.
\begin{thebibliography}{9}
\bibitem{knuth}
Donald E. Knuth: \textit{The \TeX book}; Addison Wesley, 1984.
\end{thebibliography}
\end{document}

Result without hyperref

But the links and back reference are gone, thus we reinsert them:

\documentclass{article}
\usepackage[colorlinks,pagebackref]{hyperref}
\begin{document}
Donald E. Knuth is the inventor of \TeX~\cite{knuth}.
\begin{thebibliography}{9}
\bibitem{knuth}
Donald E. Knuth: \textit{The \TeX book}; Addison Wesley, 1984.
\end{thebibliography}
\end{document}

But now the example is broken and will not compile anymore:

Runaway argument?
 Donald E. Knuth: \textit {The \TeX book}; Addison Wesley, 1984. \end \ETC.
! File ended while scanning use of \BR@@bibitem.
<inserted text> 
                \par 
<*> knuth

?

What happened? Package hyperref (or more precise package backref, which is loaded by hyperref) wants to get at the end of the bibliography entry to add the back reference list. But the syntax in LaTeX only provides the beginning of the entry by \bibitem, the end can be anywhere. In this emergency package backref has added a restriction that \bibitem has to end the entry with an empty line. Then the package can redefine \bibitem to put the back references at the end of the entry.

Since the empty line is missing, TeX keeps looking for it, but found the end of file instead and issues the error message.

share|improve this answer

C

This program works as expected (as described in the comments) unless the blank line before foo = 5; is removed.

Sadly, I encountered an error almost exactly like this in production code once.

#include <stdio.h>

int main()
{
    int foo = 0;

    #define FROB(x) do {                                            \
        x++;                                                        \
        printf("%d\n", x);                                          \
    } while (0);                                                    \

    foo = 5;
    FROB(foo); /* prints 6 */
    FROB(foo); /* prints 7 */
    FROB(foo); /* prints 8 */

    return 0;
}

This example uses the do { ... } while (0) idiom for creating a multiline statement in a macro (see https://stackoverflow.com/questions/257418/do-while-0-what-is-it-good-for). It also uses the backslash character to spread a #define over multiple lines, conveniently lined up well out of sight. However, it also does two things kind of wrong:

  • There is a semicolon after while (0), while the idiom usually omits this
  • There is a backslash after the final line of the #define

With this in place, removing the blank line before foo = 5; causes that assignment to be executed after the printf, but also after every invocation of the FROB macro. As a result, the output after removing the blank line is:

1
6
6
share|improve this answer
1  
Basically a duplicate of codegolf.stackexchange.com/a/31662/20356 –  Sieg Jun 12 at 21:43
    
@TheRare But it's less obvious. –  Ypnypn Jun 12 at 22:09
5  
It's only less obvious if you don't look at those backslashes floating very conspicuously over to the right. (But since they're floating there very conspicuously over to the right, they're going to get looked at.) –  doppelgreener Jun 13 at 7:17
3  
However, all but one of them are justified –  QuadmasterXLII Jun 14 at 18:10
2  
@QuadmasterXLII, technically speaking, they're all justified -- right-justified, to be precise. –  Mark Jun 17 at 9:05

C/C++

int main(){

    return __LINE__ - 3;
}

Returns success and can be used as an implementation for true. If the empty line is removed you can use it as an implementation for false instead.

share|improve this answer

PowerShell

This function will add two numbers.

function add ($a, $b) {
    $numbers = @($a `

            $b)
        $numbers| measure -sum| select -expand sum
}

Removing the blank line will cause the function to fail with: Unexpected token '$b' in expression or statement.

Explanation

Array elements can be separated by newlines and/or commas. Placing the line continuation character (`) after $a requires an extra newline to separate $a and $b. Otherwise, the interpreter views the code as $numbers = @($a $b) (no element separator).

share|improve this answer

TeX

\noindent\everypar{$\bullet$ hello }

world
\bye

Without the empty line, "hello" is not printed.

Explanation

TeX treats the empty line as a paragraph break, and \everypar is executed at the start of a new paragraph.

share|improve this answer

C (semi-obfuscated)

This little program takes a number on the command line and computes its factorial. However, it also contains cutting-edge AI functionality for runtime verification that the company's coding standards, including the correct use of whitespace and blank lines, are being followed. Removing a blank line will trigger the algorithm to reject the insufficiently maintainable program.

No line continuations or trigraphs anywhere. I believe it is valid ANSI C99.

Due to the advanced mathematics involved, if you compile with gcc, remember to use -lm.

#include <setjmp.h>
#include <stdio.h>
#define max(x,y) ((x<y?y:x))
#define swap(x,y) ((x^=y,y^=x,x^=y))
#include <stdlib.h>
#include <math.h>
#define vfry(x,p,z,y,i) (!!y&((z##z##L##I##p##x##z##z)))
#define NDEBUG

/* 
 * Proper use of whitespace is essential!
 * Please do not remove any blank lines.
 */

const double E = 2.71828182845904523536;

int vrfy(double epsilon, int magic, const char *key, long int L) {
  /* You are not expected to understand this */
  double x=284.2891,u=2.34e56;
  while (rand()+magic*pow(epsilon,sin(x-E))!=log(u*L))
    x*=vrfy(1.0/epsilon,(int)u,&key[swap(L,magic)],L++);
  return u/lgamma(x);
}

int main(int argc, char *argv[]) {
  int N_=831293812; /* do not change, see Knuth 1987 */
  if (!vfry(E, N,_, "M=&;VT=I!9", 0xfe86ddcaL)) {
    fprintf(stderr, "Code standards violation detected!\n");
    abort();
  }
  if (argc < 2) {
    fprintf(stderr, "Usage: %s n\nComputes n!\n", argv[0]);
    exit(1);
  }
  int m=1, n=atoi(argv[1]), i;
  for (i=1; i <= n; i++)
    m *= i;
  printf("%d! = %d\n", n, m);
  return 0;
}

Spoiler

The complicated vrfy function is never called, but rather the funny-looking vfry macro. The use of the preprocessor's string concatenation feature disguises the fact that we are really just checking the parity of __LINE__.

share|improve this answer
    
Also works with tcc -run –  Vi. Jun 14 at 18:15

Java

import java.util.Scanner;

public class BlankLine
{
    public static void main( String[] args )
    {
        //This calculates 2^ given number
        //if you remove blank line after the next line it will always print 1
        int x = new Throwable().getStackTrace()[0].getLineNumber();

        int y = new Throwable().getStackTrace()[0].getLineNumber() - x;
        System.out.println("Number:");
        Scanner scanner = new Scanner(System.in);
        int r = 1;
        int n = scanner.nextInt();

        for(int i = 0; i < n; i++){
            r *= y;
        }
        System.out.println("2^number: "+r);
    }
}

x is current line number, y is current line number - x. If there is blank line between them the result is 2. So the code calculates 2 ^ number.

share|improve this answer
1  
+1 simply because it's Java, although as a frequent visitor of Code Review I wonder why you're not using Math.pow? –  Simon André Forsberg Jun 17 at 11:09
    
Because my code has to do something. Adding 2 numbers is a bit too simple. –  Barteks2x Jun 17 at 18:28
    
Using Math.pow and print out the result is also doing something is it not? –  Simon André Forsberg Jun 17 at 19:21
    
And now I realized I really could use .Math.pow I don't know why I thought I need to do it that way... Matbe I wanted to do it in mor "sneaky" way. –  Barteks2x Jun 17 at 19:22
6  
You've been golfing too much. You should visit Code Review instead where we do things right! –  Simon André Forsberg Jun 17 at 19:29

Batch

@echo off
setLocal enableDelayedExpansion
set NL=^


echo Hello!NL!World

This code will output Hello and on the next line World. When either or both of the blank lines are removed, it outputs nothing at all.

There is an explanation here.

share|improve this answer

Python

Don't know if this falls under the standard loopholes, I looked at the list and didn't see this.

src = open(__file__, 'r')
code = src.readlines()
src.close()

if code[3] == '\n':
    print 'Hello World!'

Running this regularly returns

Hello World!

Running it without the blank line on line 4, ie like below:

src = open(
__file__, 'r')
code = src.readlines()
src.close()
if code[3] == '\n':
    print 'Hello World!'

returns nothing.

share|improve this answer

Perl 5

print(<<""
Hello, World!

);

This code prints Hello, World!. Removing the blank line gives a syntax error instead.

Explanation:

Perl's here-doc syntax for multi-line strings allows an empty terminator string. It's even explicitly documented. Removing the blank line causes the closing parenthesis (and everything else up to the next blank line, if there is one) to be interpreted as part of the string, causing a syntax error.

The error messages you get are actually pretty decent, for such an oddball syntax feature. If there are no blank lines at all in the program after the print(<<"" line, Perl simply says:

Can't find string terminator "" anywhere before EOF at foo.pl line 1.

If there is an empty line at the end of the program, you get something like this instead:

syntax error at foo.pl line 4, at EOF
  (Might be a runaway multi-line << string starting on line 1)
Execution of foo.pl aborted due to compilation errors.

share|improve this answer

Python 2.x

This program outputs the fifth character of the inputted string.

import inspect

text = raw_input()
print 'Fifth character of the string:', text[inspect.getlineno(inspect.currentframe())]

This isn't in any way hidden. If you remove the empty line, it gives the fourth character and the sixth if you add one.

share|improve this answer

Tcl

A function that adds two numbers (and checks if the newline have been deleted):

proc add {a b} {
    if {[llength [split [info body add] \n]] < 5} {error "function has been modified"}

    return [expr $a+$b]
}

There's nothing to hide here, it does what it says, so I'm not spoilerizing the explanation. The function info is a swiss army knife of introspection (what other languages call reflection). info body returns the source code of a function (if not written in C or assembly).

I have to admit that this had me stumped until I saw the javascript solution.

share|improve this answer

Ruby

Deletion of the first line will cause error:

line = IO.readlines($0).first.chomp if line.empty? puts 34+4 else raise "Please add a newline at the beginning of the program." end
share|improve this answer

JavaScript

The function whereami responds with the position of the calling line, relative to its own position in the source code.

console.log (whereami ()) //3 line(s)  before me 


function whereami () {
    var a=function a(e){try{to}catch(c){for(var d=c.stack.split("\n"),b=0;b<d.length&&!~d[b].indexOf("a");b++);return c.stack.split("\n")[b+~~e].match(/:(\d+)/)[1]-~~window.hasOwnProperty("__commandLineAPI")}},a1=a(1),i


    i= a(2)>a(1)+4?a(1):a(1)>a1+2?a1-1:a/a1



    return ((i=(a(2)<i?i-1:a(1)>i+3?a(2)-a(1)-1:a/1)) + " line(s) "   ) + (i<a(2)?" after":(i>=a(2)?" before":"confusing")) + " me";
}


console.log (whereami ()) //3 line(s)  after me

If any blank line in the whereami function is removed. The output is NaN line(s) confusing me. (Adding lines doesn't break it)

It actually only counts how many lines are between i and the first and last line respectively. If they fall under a given value. The reference line is set to NaN which neither satisfies NaN<callingLine nor NaN>=callingLine. I tried to hide it a bit in unreadable ternary expressions.

share|improve this answer
1  
Cool. I hadn't thought of using the exceptions stack like that. –  nderscore Jun 13 at 18:31

Technically not a "code" issue, but a server one. If this is sent to Apache from a CGI script (which can be generated with any language you please), it will send an HTTP response to the client:

HTTP/1.x 200 OK 
Content-Type: text/html; charset=UTF-8

Hello world!

On the other hand, this will fail as it is missing the blank space after the header.

HTTP/1.x 200 OK 
Content-Type: text/html; charset=UTF-8
Hello world!
share|improve this answer

C

#include <stdio.h>


int main() {
    const char* a = "You love blank lines.";
    #define print_out(a) \

    printf("%s\n", a);
    a = "You don't seem to love blank lines";
    print_out(a);
    return 0;
}

With the blank line, a is the local variable a and without it's the macro parameter...

share|improve this answer

Perl

#!/usr/bin/perl

use strict;
use warnings;

open IN, "<".$0 or die "Did not find input files!";
while (<IN>) {
        m/blabla/ && ((<IN> =~ /\}/ && print "tra-la-la...\n") || print "ti-ri-li\n");

}
close IN;

This perl script will read the script file and check if after the line containing "blabla" there is a closing bracket.

share|improve this answer

Java

public class TryRemovingALine {
    public static void main(String[] args) {

        int line = Thread.currentThread().getStackTrace()[1].getLineNumber();
        System.out.println(line == 4? "Hello World" : "");
    }
}
share|improve this answer

Paste this into a html file, and open it in your browser. It's pretty simple, but a little tricky because it takes the number of blank lines in the document and indexes an array to call a function which shows an alert.

<body>
<script>
[null, function(){alert("GIVE ME MY LINE BACK")}, function(){alert("2 + 2 = " + (2+2))}][document.body.innerHTML.split("\n\n").length]()

</script>
</body>

This one is borderline rule breaking. Technically JavaScript doesn't have multiline strings, which is the only reason this works.

Because you can have a syntax error in one script tag without interfering with the other script tags this shows a positive result only if there's an error on the page. The error prevents the second alert from firing because it's in the same script tag.

<body>
<script>
window.onerror=function(){
  alert("2 + 2 = " + (2+2));
}
</script>
<script>
var a = "\

";
alert("GIVE ME MY LINE BACK!");
</script>
</body>
share|improve this answer

Ruby

puts (% #{ARGV[0].to_i + ARGV[1].to_i}

)

The secret is that the newline, is really a tab, then a new line. I don't know if this counts but I thought it was cleaver. The character after the % is also a tab, but for some reason it doesn't show up like one. I'm using Ruby's percent notation to make a string, that adds the first 2 arguments passed to the script. There's more on that here: http://teohm.com/blog/2012/10/15/start-using-ruby-percent-notation/

share|improve this answer
    
It actually doesn't count, read the instructions: "No whitespace foolery." Exactly one \n should be present and should be crucial to having the program work as expected. –  Naftuli Tzvi Kay Aug 12 at 23:08
    
Ah ok :( well I tried –  addison Aug 12 at 23:32

C++

This is a classic and rather dumb trick. You will know what it is when you see it, this is just here for completion's sake. As such, I'm marking this as a community wiki answer.

int main() {
    //This program won't work without the next line, why??/

    return 1;
}

Why this works

share|improve this answer
13  
This is actually one of the loopholes. –  Mhmd Jun 13 at 2:41
    
@Mhmd I wasn't aware. Either way, I know people always use this in these kinds of question, and I just wanted to leave this here just so someone doesn't find it clever to do this. –  CrazyM4n Jun 13 at 23:51
1  
This answer is wrong for two reasons. The first is that ??/ means \​, so ??// means \/, and as the line doesn't end in \​, there is no line continuation. The second is that the behaviour is exactly the same regardless of whether return 0; is executed, because that is the standard behaviour when the execution of main reaches the closing }. –  hvd Jun 14 at 11:17
    
@hvd There. I fixed it. –  CrazyM4n Jun 14 at 11:23
3  
@cra I know people always use this in these kinds of question that's why we made it a standard loophole –  undergroundmonorail Jun 16 at 12:45

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.