Obfuscation Challenge

24

8

You are to write a program that does one of the following.

  1. Only displays "Hello World" does nothing else
  2. Quits and nothing else (no output, no errors.)
  3. Takes one line of input, parses it as an integer, displays the first that many primes (or gives a nice error if it is given input that can't be parsed as an integer, or is less than 0.)
  4. Given one line of input, it parses it has a stock symbol, and checks online for the current stock value and its change.

The catch, it should not be apparent which function it performs. Namely, for someone looking at your code, it should not be apparent which function it will do. Also, it may only perform and be able to perform one function (it can not pick and choose.) How good a program is is determined by how uncertain someone is that looks at it as to what its function is, and also how familiar that person is with that language.

BONUS: If you in a clever way make it so although for any one compiler/intrpreter and platform, the program will also perform the same function, different compilers/interpreters or platforms, it will perform a different function. This bonus may only be collected if done cleverly.

BONUS: If your program only contains code that is capable of one function (save nothing, as empty code is capable of that), and it is not possible to make a simple modification unrelated to the function to allow it to perform a different function. For example: if you did

obfuscatedBool = 1g8uhad'l8fygrcetdu8y4fd/,.oe87fy4d --Magic
if obfuscatedBool: print "Hello World"

Would not count as obfuscatedBool could be made True or False to make it print "Hello World" or do nothing respectively.

INFINITY BONUS: If you realize both bonuses simultaneously, you are magic.

NEGATIVE BONUS: Using libraries with specific abilities to do the functions.

Voters, take the bonuses in to consideration, because the program with the most votes wins!

Note: If you say what your program does, make sure to use spoiler syntax!

PyRulez

Posted 2014-03-12T22:18:28.010

Reputation: 6 547

Question was closed 2016-05-15T23:43:13.587

I'm voting to close this question because underhanded contests are off-topic by community consensus.

– Dennis – 2016-05-15T23:43:13.587

2To be honest, I can't understand most of the question. I go further and will say that I only understand the 4 points. – Ismael Miguel – 2014-03-12T22:27:35.890

Make a program such that it does one of the 4 things, but no one knows what. – PyRulez – 2014-03-12T22:39:27.793

25And what about the bonuses? Seriously, even the question is obfuscated. – Ismael Miguel – 2014-03-12T22:49:28.023

They are just to guide voters. If you trick the compiler, you get a bonus. If you only have code for one function, you get a bonus. Libraries are a negative bonus. – PyRulez – 2014-03-12T23:05:44.813

possible duplicate of Obfuscated Hello World

– TheDoctor – 2014-03-13T00:00:09.173

@PyRulez What's in NEGATIVE BONUS ?(meaning what is the bonus) – Mukul Kumar – 2014-03-13T02:08:57.730

4Since this is a popularity-contest, what for is the bonus? – Ismael Miguel – 2014-03-13T02:24:59.570

@TheDoctor no it's not ! There's a lot of difference between them – Mukul Kumar – 2014-03-13T07:20:43.607

Can you clarify "immediately" please? Can you have code in front of the bit which actually does the display or nothing/quits? – Bill Woodger – 2014-03-13T10:10:30.500

1@MukulKumar - as in, mine actually made sense? – TheDoctor – 2014-03-13T12:53:56.680

Option 1 is similar to http://codegolf.stackexchange.com/questions/22533/weirdest-obfuscated-hello-world/ ?

– microbian – 2014-03-13T21:57:38.520

Answers

43

Whitespace/Brainfuck/Python

'''begin''''''''''''  
main(args){   	  	   
	parseArgs=args.Find('^++++++++^[<++++[<++<+++<+++<+>>>>a-z]<+<+<A-Z[>]>0-9]<<.<---.*$');
    for(int i=0;	Range(GetLength(parseArgs));	i++){validateArg(parseArgs(i));}  	 	
	//name
    string stockName="";		 		  
	//loop
    for(int i=0;Range(GetLength(parseArgs));i++){		 		  
	//validate
     	if(matchFound=Find('a+z+A+.Z.0+9+_+.<<*$'){	 				
	//found
     	parseArgs(i).Split('>-.>.+');}     
	
     	for(int j=0;Range(GetLength(parseArgs(i)));j++){	 			
	//download
    data=ConvertTo.String(eval("curl -get	http://some-stock-ticker-source-url-here.com"));	 				
	print;
    print data;			  	 
	
    //line separator		 		  
	
    print "--------.";		  	  
	}}
}  


''finish'''''''''''''''

Wikipedia: Whitespace (programming language)
Online Whitespace Interpreter to Test Answer
Online Brainfuck Interpreter to Test Answer

Output (Whitespace/Brainfuck):

Hello World
Ouput (Python):
Nothing, but runs successfully.

grovesNL

Posted 2014-03-12T22:18:28.010

Reputation: 6 736

2This is really cool! I think you should update the description. Isnt the obvious code a third program that does something too? Also if you could change one of brainfuck or whitespace to perform one of the other function I would give you the INFINITY bonus! – SebastianH – 2014-03-13T08:59:09.850

1What language is the pretend program in? – durron597 – 2014-03-13T14:11:03.000

1@durron597 It's a weird C# and Python hybrid. I was going to do it all in C# but it was difficult to make the syntax work all the way through. – grovesNL – 2014-03-13T14:47:58.383

@SebastianH It's a pretend program to mask its actual function. – grovesNL – 2014-03-13T14:49:14.350

The Python functionality is too transparent. After you see the first 3 characters, you just have to scan the rest of the code for the end of the string literal. – user2357112 supports Monica – 2014-03-13T17:05:19.630

@user2357112 Perhaps. I just added the Python functionality because I thought it would be an easy addition. I'll obfuscate it more. – grovesNL – 2014-03-13T17:22:52.250

40

JS

゚ω゚ノ=/`m´)ノ~┻━┻//*´∇`*/['_'];o=(゚ー゚)=_=3;c=(゚Θ゚)=(゚ー゚)-(゚ー゚);(゚Д゚)=(゚Θ゚)=(o^_^o)/(o^_^o);(゚Д゚)={゚Θ゚:'_',゚ω゚ノ:((゚ω゚ノ==3)+'_')[゚Θ゚],゚ー゚ノ:(゚ω゚ノ+'_')[o^_^o-(゚Θ゚)],゚Д゚ノ:((゚ー゚==3)+'_')[゚ー゚]};(゚Д゚)[゚Θ゚]=((゚ω゚ノ==3)+'_')[c^_^o];(゚Д゚)['c']=((゚Д゚)+'_')[(゚ー゚)+(゚ー゚)-(゚Θ゚)];(゚Д゚)['o']=((゚Д゚)+'_')[゚Θ゚];(゚o゚)=(゚Д゚)['c']+(゚Д゚)['o']+(゚ω゚ノ+'_')[゚Θ゚]+((゚ω゚ノ==3)+'_')[゚ー゚]+((゚Д゚)+'_')[(゚ー゚)+(゚ー゚)]+((゚ー゚==3)+'_')[゚Θ゚]+((゚ー゚==3)+'_')[(゚ー゚)-(゚Θ゚)]+(゚Д゚)['c']+((゚Д゚)+'_')[(゚ー゚)+(゚ー゚)]+(゚Д゚)['o']+((゚ー゚==3)+'_')[゚Θ゚];(゚Д゚)['_']=(o^_^o)[゚o゚][゚o゚];(゚ε゚)=((゚ー゚==3)+'_')[゚Θ゚]+(゚Д゚).゚Д゚ノ+((゚Д゚)+'_')[(゚ー゚)+(゚ー゚)]+((゚ー゚==3)+'_')[o^_^o-゚Θ゚]+((゚ー゚==3)+'_')[゚Θ゚]+(゚ω゚ノ+'_')[゚Θ゚];(゚ー゚)+=(゚Θ゚);(゚Д゚)[゚ε゚]='\\';(゚Д゚).゚Θ゚ノ=(゚Д゚+゚ー゚)[o^_^o-(゚Θ゚)];(o゚ー゚o)=(゚ω゚ノ+'_')[c^_^o];(゚Д゚)[゚o゚]='\"';(゚Д゚)['_']((゚Д゚)['_'](゚ε゚+(゚Д゚)[゚o゚]+(゚Д゚)[゚ε゚]+(゚Θ゚)+(゚ー゚)+(゚Θ゚)+(゚Д゚)[゚ε゚]+(゚Θ゚)+((゚ー゚)+(゚Θ゚))+(゚ー゚)+(゚Д゚)[゚ε゚]+(゚Θ゚)+(゚ー゚)+((゚ー゚)+(゚Θ゚))+(゚Д゚)[゚ε゚]+(゚Θ゚)+((o^_^o)+(o^_^o))+((o^_^o)-(゚Θ゚))+(゚Д゚)[゚ε゚]+(゚Θ゚)+((o^_^o)+(o^_^o))+(゚ー゚)+(゚Д゚)[゚ε゚]+((゚ー゚)+(゚Θ゚))+(c^_^o)+(゚Д゚)[゚ε゚]+(゚ー゚)+((o^_^o)-(゚Θ゚))+(゚Д゚)[゚ε゚]+(゚Θ゚)+(゚Θ゚)+(c^_^o)+(゚Д゚)[゚ε゚]+(゚Θ゚)+(゚ー゚)+((゚ー゚)+(゚Θ゚))+(゚Д゚)[゚ε゚]+(゚Θ゚)+((゚ー゚)+(゚Θ゚))+(゚ー゚)+(゚Д゚)[゚ε゚]+(゚Θ゚)+((゚ー゚)+(゚Θ゚))+(゚ー゚)+(゚Д゚)[゚ε゚]+(゚Θ゚)+((゚ー゚)+(゚Θ゚))+((゚ー゚)+(o^_^o))+(゚Д゚)[゚ε゚]+(゚ー゚)+(c^_^o)+(゚Д゚)[゚ε゚]+(゚Θ゚)+((o^_^o)-(゚Θ゚))+((゚ー゚)+(o^_^o))+(゚Д゚)[゚ε゚]+(゚Θ゚)+((゚ー゚)+(゚Θ゚))+((゚ー゚)+(o^_^o))+(゚Д゚)[゚ε゚]+(゚Θ゚)+((o^_^o)+(o^_^o))+((o^_^o)-(゚Θ゚))+(゚Д゚)[゚ε゚]+(゚Θ゚)+((゚ー゚)+(゚Θ゚))+(゚ー゚)+(゚Д゚)[゚ε゚]+(゚Θ゚)+(゚ー゚)+(゚ー゚)+(゚Д゚)[゚ε゚]+(゚ー゚)+((o^_^o)-(゚Θ゚))+(゚Д゚)[゚ε゚]+((゚ー゚)+(゚Θ゚))+(゚Θ゚)+(゚Д゚)[゚o゚])(゚Θ゚))('_');

Alerts "Hello World"
Was answered at https://codegolf.stackexchange.com/a/3946/803
Since I did not come up with this answer, making it a community wiki

Clyde Lobo

Posted 2014-03-12T22:18:28.010

Reputation: 1 395

It was probably generated by this online encoder

– Aaron – 2015-08-26T09:40:44.363

28Are you entirely sure this is not APL? – mniip – 2014-03-13T12:25:48.113

2

@mniip Oh Yeah!! its is JS. Demo http://jsfiddle.net/7mqL8/

– Clyde Lobo – 2014-03-13T13:42:31.287

11I see smileys everywhere.. – Thorkil Holm-Jacobsen – 2014-03-13T17:47:44.223

1This is the best usage of Unicode in JavaScript I've ever seen! – Cole Johnson – 2014-03-13T23:33:23.117

4+1 for the smiley: (o^_^o). – Amal Murali – 2014-03-14T11:37:23.613

Can you explain why this works? I would like to understand this. – Josh – 2014-03-14T18:38:48.757

Does it perform a different function in IE7? – RMorrisey – 2014-03-14T21:30:03.953

31

MS-DOS x86 Assembly

Because it isn't already obfuscated when it's in assembly, let's make it even worse! This SHOULD work with any assembler that can assemble to a COM file, but I've only tested with TASM for DOS using tasm obfuse, tlink /t obfuse

.286
CODE SEGMENT
ASSUME CS:code, DS:code
ORG 0100h

start:
.586

xor eax, eax
xor ecx, ecx
xor edx, edx
xor ebx, ebx
xor edi, edi
xor esi, esi
stc
pushfd
rcr di, 8
mov cx, 35
cli
push edi
xor word ptr [di + 8], 2720
pushfd
sub bx, 64512
rcr ebx, 11
sub word ptr [di + 125], 61702
pop eax
dec dx
and word ptr [di + 4], cx
mov ecx, eax
sub byte ptr [di + 124], 21
xor eax, ebx
push eax
xor byte ptr [di + 127], 240
popfd
xor dword ptr [di], 179066414
pushfd
xor byte ptr [di + 11], dl
pop eax
mov bp, 8268
xor byte ptr [di + 123], 110
pop edx
add byte ptr [di + 10], 49
popfd
sti
and ecx, ebx
or word ptr [di + 4], bp
and eax, ebx
xor word ptr [di + 6], 23601
cmp eax, ecx
db 'u', 5
dec cl
movsx dx, cl
int 32

CODE ENDS
END start

This is self-modifying code that does several things:
1) It modifies the first 12 bytes to 'Hello World[dollar sign]'
2) It modifies the seemingly out of place 'dec cl' and 'movsx dx cl' to 'nop', 'mov ah, 9', 'int 021h'
3) Everything is highly interspersed within each other. This is also doing a flags test to see if your CPU supports CPUID
4) Hex values converted to decimal so you have no clue....
5) Even if you did, it uses xor, or, and and sub to modify the existing code to the correct values. No direct values.
6) If your CPU doesn't support CPUID (not a Pentium or above, see DOSBox for a great example), you see "Hello World". Otherwise, nothing happens.

Mark Ormston

Posted 2014-03-12T22:18:28.010

Reputation: 799

25Writing a program in Assembler is obfuscation enough! xD – SebastianH – 2014-03-13T08:59:53.557

25

C

int puts(const char *s) {
  char error[] = "Error: invalid number\n";

  int a, b=0, c=0, i, j;
  scanf("%d", &b);

  if (b<1) {
     printf(error);
  }

  for (i=2; c<b; i++) {
     int z=1;
     for (j=2; j<i; j++) {
        z = z&&(i%j);
     }
     if (z) {
        printf("%d\n", i);
        c++;
     }
  }
}

int main () {
  printf("Hello World\n");
}

On gcc, with default settings, this does the prime thing. Using tcc, you get Hello World. A C compiler may rewrite a printf("String\n") call into a puts("String") call. This is more efficient, but it does assume nobody wrote their own puts. A compiler does not have to do this, so depending on your compiler and your compiler settings, you will get either Hello World or a bunch of primes. The printf calls in puts are not affected, because they don't match the exact template. I think I qualify for the bonus.

marinus

Posted 2014-03-12T22:18:28.010

Reputation: 30 224

16

LOLCODE

This language is already obfuscated by itself. Here is my code:

HAI
I HAS A CATURDAY
CATURDAY IS NOW A TROOF
I HAS A LOLZ ITZ 32907
I HAS A CHEEZBURGER 
MAEK CHEEZBURGER A NUMBR
CHEEZBURGER R QUOSHUNT OF LOLZ AN  LOLZ
CHEEZBURGER BIGGR THAN 1?, O RLY?
YA RLY BTW RLY LOLZ
CATURDAY R WIN 
OBTW EVERYDAY IS CATURDAY 
ME LIKEZ CATURDAY!!1!
TLDR
CHEEZBURGER R QUOSHUNT OF LOLZ AN CHEEZBURGER
NO WAI
CATURDAY R FAIL BTW LOLZ!!1!
I HAS A LIMIT ITZ 10
CHEEZBURGER R 0
OIC 
IM IN YR LOOP
CHEEZBURGER, WTF?
OMG 1
VISIBLE "Hello World!" 
OMGWTF
CATURDAY R FAIL
OIC
GTFO
IM OUTTA YR LOOP
KTHXBYE

This code quits and does nothing else (no output, no errors). But although it does absolutely nothing, it runs like a charm (tested with version that contained a VISIBLE "test" statement before the last statement KTHXBYE, proving that all is fine). Basically it declares variables, changes their types, enters in loops and ifs and cases constructs, even has a line that would print "Hello World!" if ever reached (if only reached...). A total waste of computation :)

gilbertohasnofb

Posted 2014-03-12T22:18:28.010

Reputation: 494

1

If you'd like, you can test it here

– gilbertohasnofb – 2014-03-13T23:02:02.050

10

COBOL (IBM Enterprise COBOL)

   ID

If shown that, very close to 100% of IBM Mainframe COBOL programmers would say "that's not even a program, that won't compile!". The more experience they have, the less likely they are to think it will compile (as older Mainframe COBOLs were much more strict).

Then ask "if it does compile, what does it do?" They would say, "it won't compile, but if it did, it would give some sort of error, probably Language Environment would give a U4038 or something like that".

Managed to shorten it. There are four DIVISIONs in a COBOL program. IDENTIFICATION/ID, ENVIRONMENT, DATA, PROCEDURE. It turns out that PROCEDURE requires the word DIVISION and the others don't. Guess which one I removed first and assumed that the other words DIVISION were mandatory... further puzzling revealed otherwise. Pity it's not Golf. A two-character COBOL program...

OK, yes, the compiler does moan, and indeed gives it a Return Code of eight. Usually people don't even generate the object code for, let alone try to execute, programs with a Return Code of eight. However, this is a case where none of the E-level errors affect the code generated. So the code runs without a problem at all, if you generate it.
The above source is effectively the equivalent of this:
ID DIVISION.
PROCEDURE DIVISION.
GOBACK
.
Which simply returns to whence it came.

Bill Woodger

Posted 2014-03-12T22:18:28.010

Reputation: 1 391

2My first ever spoiler. There's code in there. All pickled. Rats. More research... – Bill Woodger – 2014-03-13T01:44:31.163

Slightly less pickled, but still not good. Late here. I'll see if there are more spoilers I can steal from tomorrow. Err... later today. ID and PROCEDURE start in column eight, GOBACK and full-stop/period in column 12. The ID in the original is also column eight, just for info. – Bill Woodger – 2014-03-13T01:53:03.237

10

JavaScript (ES6)

Using pragma black magic to reveal JavaScript true power:

var WKRBD='';
var DIJqZ=(gFJLA=WKRBD,i=29)=>(
  "use black magic", 
  gFJLA=WKRBD.concat(gFJLA),
  [String.fromCharCode((c.charCodeAt()-61)^gFJLA[i++].charCodeAt())for(c of gFJLA.substr(1,11))].join('')
);
DIJqZ(DIJqZ);

Output:

Hello World

Explanations:

This program is actually quite simple and could be summarize as bellow.
Everything else if syntactic sugar!

var dummy = function() {
  var output = '';
  var a = 'gFJLA=WKRBD';
  var b = 'black magic';

  for (var i = 0; i < a.length; i++) {
    output += String.fromCharCode((a[i].charCodeAt(0) - 61) ^ b[i].charCodeAt(0));
  }

  return output;
};

dummy();

Here is the annotated version:

// Nothing special here.
var WKRBD='';

// Define a new function. Its name doesn't matter.
// But its arguments do!
//   * gFJLA=WKRBD: encoded "Hello World"
//   * i=29: number of characters before "black magic"
var DIJqZ=(gFJLA=WKRBD,i=29)=>(
  // Store the XOR key using a fancy pragma name!
  "use black magic", 
  // Convert gFJLA to String thus it is possible to read 
  // its body and extract the encoded "Hello World".
  gFJLA=WKRBD.concat(gFJLA),
  // Use a generator to decode the message.
  [
    // Generate the decoded character
    String.fromCharCode(
      // Decode the character.
      // gFJLA[i++] retrieves a character from "black magic".
      (c.charCodeAt() - 61) ^ gFJLA[i++].charCodeAt()
    )
    // Iterates over the function body.
    // The extracted part is "gFJLA=WKRBD".
    for(c of gFJLA.substr(1,11))
  // Build the message. Since it is the last expression of 
  // the arrow function, its result is returned.
  ].join('')
);

// Invoke the function and pass itself as the first argument.
DIJqZ(DIJqZ);

Florent

Posted 2014-03-12T22:18:28.010

Reputation: 2 557

any exxplain? for the pragma? – masterX244 – 2014-03-13T15:15:19.393

9

Java,C++-11 1 Bonus claimed

Not sure about if i got both bonuses but it was already a headache to intermingle 2 programming languages...

/* *??/
/
#include <iostream>
using namespace std;

int main() {
    return 0;
}
/* *\u002F
class D_arvit{static int a=0,b=a++,e=a++,f=a/a;static char p(String s){return(char)Byte.parseByte(s,a);}public static void main(String[]z){//\u000Along x=e,y=b;String c=((Long)x).toString(),d=((Long)y).toString();char u=p(c+c+d+c+c+d+d),m=p(c+c+d+d+c+d+c),o=(char)(u+a+f);char _=p(c+d+d+d+d+d),$=_++;System.out.print(new char[]{p(c+d+d+c+d+d+d),m,u,u,o,$,p(c+d+c+d+c+c+c),o,(char)(o+a+f),u,(char)(m-f),_});\u000A}}
/\u002A*/

Getting the C++ inbetween the java code which i already used on another Hello World answer was a Pain in the ass. Took me a while to find a fitting second language where i was able to juggle around comments as needed so they disable/enable differently at different languages

masterX244

Posted 2014-03-12T22:18:28.010

Reputation: 3 942

Using trigraphs to exit a comment in C++. This is neat! – FUZxxl – 2014-06-19T09:50:08.943

2^It's also one of the standard loopholes, I think. Just saying. – Soham Chowdhury – 2014-09-05T02:04:39.597

8

Python - 1 Bonus Claimed

import base64
try:
    a=1/(1/2)
    eval(compile(base64.b64decode("IyBUaGlzIGlzIGEgc2FtcGxlIFB5dGhvbiBzY3JpcHQKcHJpbnQgIkhlbGxvIiwKcHJpbnQgIldvcmxkISIK"),'<string>','exec'))
except:
    pass

In Python 2, 1 divided by 2 equals 0. 1 divided by 0 can't be evaluated and throws a division by zero error. Nothing is printed, and still the program terminates without error.

In Python 3, 1/2 => 0.5, and 1/0.5 => 2.0. No error. Hello, World! is printed.

Rainbolt

Posted 2014-03-12T22:18:28.010

Reputation: 6 176

3I don't know that this is obfuscated enough. – None – 2014-03-12T22:36:40.863

@hosch250 Is right, it is not very obfuscated. Is second part is wrong though. – PyRulez – 2014-03-12T22:40:19.670

Oh, I see. It does one in Python 2 and the other in Python 3. – None – 2014-03-12T22:41:51.097

@hosch250 Oh well. At least I got the bonus. I won't really mind if someone else steals the bonus part of my answer and molds it. I'd be honored, even. – Rainbolt – 2014-03-12T22:43:24.467

Just obfuscate hello world in some way and you will be fine. – None – 2014-03-12T22:51:49.853

@hosch250 Well, it's no longer obvious what it prints. – Rainbolt – 2014-03-13T00:02:09.227

7

Batch

@echo off&setLocal enableDelayedExpansion&for /L %%a in (2,1,%1)do (set/aa=%%a-1&set c=&for /L %%b in (2,1,!a!)do (set/ab=%%a%%%%b&if !b!==0 set c=1)
if !c! NEQ 1 set l=!l!%%a,)
echo !l:~0,-1!

This will return a list of prime numbers less than the inputted value.
H:\uprof>obf.bat 12
2,3,5,7,11

I don't know that convoluted counts as obfuscated, though there are definitely some aspects of obfuscation present.

unclemeat

Posted 2014-03-12T22:18:28.010

Reputation: 2 302

The program may only preform one function. – PyRulez – 2014-03-12T23:30:34.743

@PyRulez Sorry, fixed. – unclemeat – 2014-03-13T00:02:32.690

2I also recommend using spoilers so people don't what it does immediately. – PyRulez – 2014-03-13T00:10:34.650

+1 for %%%% xD – SebastianH – 2014-03-13T08:53:40.940

7

Ruby - or is it Whitespace?

Well, can anyone guess what I do? Small hint: if you want to run it, please copy all of the code in the code box ;)

Update: Copying the code doesn't seem to work due to Unicode-related problems? Forking the online version and then copying the code seems to work! Look out for the whitespace ;)

Online version

# encoding: utf-8

def method_missing(m, *a)
  $* << (m.to_s.size-1).to_s
end

at_exit do
  eval ($**'').scan(/.../).map(&:to_i).pack('C*')
end

                                                                                                                                                                                                                                                   

Output:

Hello world!

Explanation:

  • The last line consists of quite a few chunks of no-break-spaces (UTF-8: 160dec) separated by regular spaces.
  • Ruby handles the chunks as though they were methods - since no such methods are defined, method_missing is called, which saves the lengths of the chunks
  • Each chunk represents one digit of a three digit number, which represents a character
  • in at_exit the characters are formed by concatenating the digits etc. and the expression is evaluated, in this case puts 'Hello world!'
  • Instead of using UTF-8 whitespaces, you could also use underscores for better visibility:
def method_missing(m, *a)
  $* << (m.to_s.size-1).to_s
end

at_exit do
  eval ($**'').scan(/.../).map(&:to_i).pack('C*')
end

__________ ____ _ ____ ____ _ _ _ __ _________ _ __ _____ __ __ __ __ __ __________ __ __ ___ ____ _ __ __ __ _________ _ __ _________ _ __ __ _ __ ___ ________ _ __________ ____ _ ___ ____ _ ______ __ __ _______ __ __ ________ __ __ ___ __ __

David Herrmann

Posted 2014-03-12T22:18:28.010

Reputation: 1 544

Copying Whitespace from SE doesn't work because SE's markdown interpreter replaces tab characters with 4 spaces. – undergroundmonorail – 2014-03-15T12:24:09.177

7

Forth

Let's create a new TASK.

FORTH ok
: TASK
  [ HEX ] 3A91224B. 1F836AFE.  
  4A BASE ! D. D.     
;
TASK Hello World ok

It displays two 32-bits numbers in base 74 (4Ah). 74 because it is the difference between ASCII "z" and ASCII "0" plus one, so I can use it to display a small words starting from a number. The first number is "Hello" (1F836AFEh) and the second number is "World" (3A91224Bh). It really prints a trailing space after the number "World".

Real execution

Mattsteel

Posted 2014-03-12T22:18:28.010

Reputation: 381

Forth...one of the few languages SHOUTIER than SQL. Welcome to the site! – Jonathan Van Matre – 2014-03-13T14:16:43.837

3I tried it on my Sinclair-ZX-Spectrum Forth and it works... – Mattsteel – 2014-03-13T14:29:55.967

1

... and realize that using a different base (4F) will be compliant with another puzzle

– Mattsteel – 2014-03-13T22:51:36.697

6

PHP:

$words=array('Heart','eagle','low','lonely','over',' SPACE ','Window','optimus','rotting','list','done','!done');

$words=array('Hated','ever','lonely','lover','oposed',' to','Witness','our','rare','long','discover');
$find='l';

foreach($words as $word)echo($find^(($find&$word)^($find|$word)));

Prints 'Hello World'.
It takes off the 1st letter from each word in the array.
The var $find can have any single-byte string of 1 byte.
Using a longer value for the var $find will give weird outputs.

Ismael Miguel

Posted 2014-03-12T22:18:28.010

Reputation: 6 797

6Without looking at the spoiler, I could see that this string has to be connected with "Hello World"! – SebastianH – 2014-03-13T08:54:55.367

Sorry if my obfuscated try isn't the best. And yes, the pattern is too easy, but at least I tried something different. I will edit it later and make it a little less obvious. – Ismael Miguel – 2014-03-13T09:24:05.617

6

Brainfuck

print("Hello World")

Explanation

At least if your compiler ignores invalid instructions, this program does nothing.

nyuszika7h

Posted 2014-03-12T22:18:28.010

Reputation: 1 624

The compiler must ignore non-commands, since they count as comments. – MadTux – 2014-06-10T10:03:37.060

I know of some compilers that error on them, though I can't name any. – nyuszika7h – 2014-06-10T20:22:19.070

Reminds me of this other challenge

– Qeole – 2014-06-11T00:30:54.407

5

C++11

I claim the bonus for compiler dependence - for example, this will exhibit different beahviour between gcc 4.8 and gcc 4.9.

#include <iostream>
#include <list>
#include <type_traits>
#include <utility>


// Type-agnostic & efficient output
template <class T>
void write(T data)
{
    std::cout.write((char*)&data, sizeof data);
}


// Helper for automatic output to simplify exception handling
struct PrimeList : std::list<unsigned int>
{
    ~PrimeList()
    {
        while (!empty())
        {
            write(front());
            pop_front();
        }
    }
};


// Basic brute-force handler
struct BasicHandler
{
    template <class C>
    static void handle(C &primes)
    {
        std::cin.clear(std::ios_base::failbit); // remove possible non-fatal errors
        std::cin.exceptions(std::ios_base::failbit); // easier error handling
        unsigned int count;  // unsigned so that negatives error out immediately
        std::cin >> count;
        unsigned long long candidate = 1;
        for (unsigned int p = 0; p < count; ++p)
        {
            bool isPrime;
            do {
                ++candidate;
                isPrime = true;
                for (auto prime : primes)
                {
                    if (candidate % prime == 0)
                    {
                        isPrime = false;
                        break;
                    }
                }
            } while (!isPrime);
            primes.push_back(candidate);
        }
    }
};


// Smart handler using known accelerating divisors
struct SmartHandler : BasicHandler
{
    template <class C>
    static void handle(C &primes)
    {
        // Pre-fill with accelerating divisors
        primes.push_back(1819043144u);
        primes.push_back(1867980911u);
        primes.push_back(560229490u);

        BasicHandler::handle(primes);

        // Remove divisors, as they are not primes
        primes.pop_front();
        primes.pop_front();
        primes.pop_front();
    }
};


// Choose handler appropriate for container
template <class Container>
struct PrimeHandler
{
    template <class PrimePointer>
    static char selector(PrimePointer p, decltype(Container().insert(p, *p)));

    static double selector(...);

    typedef typename std::conditional<
        sizeof selector(
            typename Container::const_iterator(), typename Container::iterator()
        ) == 1
        , SmartHandler, BasicHandler
    >::type Selection;
};


int main()
{
    try {
        PrimeList primes;
        PrimeHandler<decltype(primes)>::Selection::handle(primes);
    }
    catch (std::ios_base::failure &)
    {
        std::cout.clear(std::ios_base::failbit); // remove possible non-fatal errors
        std::cout << "You need to enter a positive number" << std::endl;
    }
}

Compiler dependency explanation:

C++11 changed the requirements for insert() and erase() functions in standard containers so that they now accept constant iterators, where previously they required mutable iterators. That's what PrimeHandler tests. gcc only changed its standard library to be compliant in 4.9; MSVC 2013 is not compliant yet; I don't know about clang.

General behaviour explanation:

The clear(x) function of streams does not clear flag x, it sets it. Therefore, the handle() function actually puts the stream in error state, so any attempt to read fails (and helpfully throws an exception). In the same way, the error output is avoided.
The auto-output destructor of PrimeList makes sure any data in it is written - as binary, not as numbers. Of course, the "smart divisors" are actually "Hello World!" encoded in little-endian ASCII. And because an exception is thrown, nothing gets added in BasicHandler, and only the "smart divisors" are added in SmartHandler (and never removed, because of said exception).

Angew is no longer proud of SO

Posted 2014-03-12T22:18:28.010

Reputation: 343

4

Delphi

Not sure if this counts but I will tell you how I saw this challenge.
My thought was to write code that wouldnt execute what you expected it to.

program Project1;

{$APPTYPE CONSOLE}

{$R *.res}

uses
  System.sysutils,Generics.Collections;
type
  TMyIntList= TList<integer>;

  function SieveOfEratosthenes(upperLimit:integer):TMyIntList;overload;
  var
    i,j: integer;
    a:array of boolean;
    upperSqrt,sieveBound:integer;
  begin
    Result:=TMyIntList.Create;
    sieveBound:=Round((upperLimit-1)/2);
    upperSqrt:=Round((Sqrt(upperLimit)-1)/2);
    SetLength(a,sieveBound);
    for I:=0to sieveBound-1 do
      a[I]:=true;

    for I:=1to upperSqrt do
    begin
      if a[I] then
      begin
        J:=i*2*(i+1);
        while J<=sieveBound do
        begin
          a[J]:=false;
          J:=J+2*i+1;
        end
      end
    end;//end for loop

    Result.Add(2);

    for I:=1to sieveBound-1do
      if a[i]then
        Result.Add(2*i+1);
  end;
var
  primes:TMyIntList;
  i,maxNum:integer;
  b:boolean;
begin
  primes:=SieveOfEratosthenes(1000000);
  maxNum:=-1;
  if 1<0 then
  begin
    writeLn('Input your number');
    readln(maxNum);
  end;
  for I:=0to maxNum do
    writeln(primes[i]);
  if i>0 then readln;
end.

What I did was write a program that implies to execute function 3 but actually runs function 2 and simply exits as soon as its started.
The hints are: SieveOfEratosthenes Algorithm for generating primes
Var primes and maxNum
code: WriteLn('Input your number');readln(maxNum);
Which is code that will never be reached since booleans are False by default

Teun Pronk

Posted 2014-03-12T22:18:28.010

Reputation: 2 599

4

Haskell

import Control.Concurrent
import System.Exit
import System.Time
import Control.Monad

hw = putStrLn "Hello World" 

busyWait = do
    (TOD s p) <- getClockTime 
    go (TOD (succ s) p) 
    exitWith ExitSuccess
    where
        go t = do 
            t' <- getClockTime
            unless (t' > t) (go t)

main :: IO ()
main = forkIO hw >> busyWait

Run with GHC and it will print hello World. With Hugs (which implements cooperative multitasking) It will always quit without printing anything.

monocell

Posted 2014-03-12T22:18:28.010

Reputation: 2 551

4

JS

[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]][([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]]([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]][([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]]((!![]+[])[+!+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+([][[]]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+!+[]]+(+[![]]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+!+[]]]+([][[]]+[])[+[]]+([][[]]+[])[+!+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(![]+[])[+!+[]]+(+(!+[]+!+[]+[+!+[]]+[+!+[]]))[(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(+![]+([]+[])[([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([![]]+[][[]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(+![]+[![]]+([]+[])[([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]])[!+[]+!+[]+[+[]]]](!+[]+!+[]+!+[]+[+!+[]])[+!+[]]+(!![]+[])[!+[]+!+[]+!+[]])()([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]][([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]]((!![]+[])[+!+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+([][[]]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+!+[]]+(+[![]]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+!+[]]]+(!![]+[])[!+[]+!+[]+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(![]+[])[+!+[]]+(+(!+[]+!+[]+[+!+[]]+[+!+[]]))[(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(+![]+([]+[])[([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([![]]+[][[]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(+![]+[![]]+([]+[])[([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]])[!+[]+!+[]+[+[]]]](!+[]+!+[]+!+[]+[+!+[]])[+!+[]]+(!![]+[])[!+[]+!+[]+!+[]])()(([]+[])[([![]]+[][[]])[+!+[]+[+[]]]+(!![]+[])[+[]]+(![]+[])[+!+[]]+(![]+[])[!+[]+!+[]]+([![]]+[][[]])[+!+[]+[+[]]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(![]+[])[!+[]+!+[]+!+[]]]()[+[]])[+[]]+[!+[]+!+[]+!+[]]+(+(+!+[]+[+!+[]]))[(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(+![]+([]+[])[([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([![]]+[][[]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(+![]+[![]]+([]+[])[([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]])[!+[]+!+[]+[+[]]]](!+[]+!+[]+[+[]])))()

Does nothing. No Error. No Output

Clyde Lobo

Posted 2014-03-12T22:18:28.010

Reputation: 1 395

4

Matlab

Here is code that can roughly perform various operations, can you predict the flow?

six=input('input your number or ticker?','s')
six=six(six==6) 

if six
    'Hello World!'
elseif ~six
    try
    primes(str2num(six))
    catch
        urlread(['http://finance.yahoo.com/q?s=' six])
    end        
end

Here is a hint:

Regardless of which number or ticker you input, you will always end up on the same spot

Dennis Jaheruddin

Posted 2014-03-12T22:18:28.010

Reputation: 1 848

1Bravo for making it hard to eliminate any of the 4 functions. – PyRulez – 2014-03-14T16:46:23.030

4

C, 346 chars

#include <stdio.h>

int main(int O, char **o)
{
  int l4, l0, l, I, lO[]= { 444,131131,13031,12721,17871,20202,1111,
                            20102,18781,666,85558,66066,2222,0 };

  for(l4=0;l4<14;++l4){
    for((l=l0=lO[l4])&&(l0=-7);
         l>4&&(I=2-((l|l>>O)&O));l=l&O?l+(l<<O)+O:l>>I,l0+=I);{
      putchar(10+l0);
    }
  }

  return 0;
}

This is an old program I created 10+ years ago. It actually prints "Hello, world!" The code uses palindromic numbers in base 10 and is slightly obfuscated.

Don't trust the indentation. Also, see: http://oeis.org/A006577

Oh, I almost forgot... The program only works when started without command line arguments. Also, if you start it with 11 command line arguments it seems to enter an infinite loop. 12 is fine though.

Emanuel Landeholm

Posted 2014-03-12T22:18:28.010

Reputation: 181

4

This one does both bonuses. Have a look at the spoilers in the end to see what it does.

Java / Brainf*ck

//[
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
//]

public class Something {
    private static String magicNumber="1000";

    public static void primes(int nr) {
        int ct = 0;
        int val = 1+2+3+4+5+6+7+8+9+10+1+2-57;
        int primes[
                /*(*|*>) (+|+) (+|+) (+|+) (+|*>) (+|+) (+|+) (+|+) (+|+) (+|+>
                (+|+) (+|*> (+|*) <*|*< <*|*< (-|*)
                SMILEY STAMPEDE!
                */
                ]; //I probably won't use that array anyways... Whatever.
        while (nr > ct) {
            val++;
            boolean isPrime = true;
            for (int i = 2; System.out!=null && val > i; i+=1) {
                if (val % i == Integer.parseInt("0")) {
                    isPrime = false;
                    break;
                }
            }
            if (isPrime) {
                println(val);
                ct++;//>*|*> (*|*>
            }
        }
    }

    public static void main(String[] args) throws IOException {//<*|*< <*|*) I like smileys!
        new Something();

        setMagicNumber(1+(getMagicNumber()+7+9+12+4));
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String input = br.readLine();
        try {
            setMagicNumber(getMagicNumber()+3+1+2);
            System.gc();
            setMagicNumber(getMagicNumber()>5 ?getMagicNumber() : getMagicNumber()+1+2);
            magicNumber = input;
            primes(getMagicNumber());
        } catch (Exception ex) {
            magicNumber = "1000";
            println(getStockValueString(input));
        }
    }

    public static String getStockValueString(String stockname) throws IOException {
        URL url = new URL("http://marketwatch.com/investing/stock/"+stockname);
        setMagicNumber(getMagicNumber2()<7 ? (getMagicNumber2()<9+3) ? 5+3+5+7+6+3 : 2+9+6+9 : 7+6+1+2+5+2+4);
        HttpURLConnection httpConnection = (HttpURLConnection) url.openConnection();

        boolean setOutput = getMagicNumber2()>2;

        httpConnection.setDoOutput(setOutput);

        setMagicNumber(getMagicNumber2()+2+3+4);

        DataOutputStream wr = new DataOutputStream(httpConnection.getOutputStream());

        setMagicNumber(getMagicNumber2()-1-2-3-4-5-6);

        wr.flush();

        setMagicNumber(getMagicNumber2()-5-3-1-8-9-5-5-4);

        BufferedReader in = new BufferedReader(new InputStreamReader(httpConnection.getInputStream()));
        String line;

        while ((line = readLine(in)) == null == (getMagicNumber2()>100000)) {
            line = line.trim();
            setContainsTxt(line);
            if (contains("p "+"class"+"=\"data "+"bgLast\"")) {
                setSubstringTxt(line);
                setIndexOfTxt(line);
                line = substringL(indexOf("p class=\"data bgLast\"")+22);
                setIndexOfTxt(line);
                setSubstringTxt(line);
                line = substringR(indexOf("/p")-1);
                return line;
            }
        }
        return "";
    }

    //>*|*> [*|*>
    public Something() {

    }
    public static int getMagicNumber2() {
        try {
            return Integer.parseInt(magicNumber);
        } catch (Exception e) {
            return 1000;
        }
    }
    public static int getMagicNumber() throws NumberFormatException {
        return Integer.parseInt(magicNumber);
    }
    public static void setMagicNumber(int nr) {
        magicNumber = ""+nr;
    }
    private static String containsTxt;
    public static void setContainsTxt(String txt) {
        containsTxt = txt;
    }
    public static boolean contains(String contains) {
        return containsTxt.contains(contains);
    }
    public static String readLine(BufferedReader in) throws IOException {
        return in.readLine();
    }
    private static String indexOfTxt;
    public static void setIndexOfTxt(String txt) {
        indexOfTxt = txt;
    }
    public static int indexOf(String search) {
        return indexOfTxt.indexOf(search);
    }
    public static void println(Object txt) {
        System.out.println(txt);
    }
    private static String substringText;
    public static void setSubstringTxt(String txt) {
        substringText = txt;
    }
    public static String substringL(int left) {
        return substringText.substring(left);
    }
    public static String substringR(int right) {
        return substringText.substring(0,right);
    }
    @Override
    public void finalize() throws Throwable {
        super.finalize();
        magicNumber = "NaN";
    }//<*|*]
}

Brainfuck

In Brainfuck this just returns "Hello World".

Java

In Java this either returns the first x prime numbers (depending on the input number) or the stock value of the given stock market symbol (e.g. GOOG for Google). Which one is chosen depends on the implementation of the currently used JavaVM, but with the Oracle JavaVM it should get the stock market value. You can also force the prime number calculator (2nd bonus) by commenting out the System.gc()-line, which in turn stops the finalize() call so the magicNumber never becomes NaN and thus no exception is thrown that would cause the stock market value getter to run instead of the prime numbers generator.

Dakkaron

Posted 2014-03-12T22:18:28.010

Reputation: 141

3

Malbolge

I'd say that it can't get anymore obfuscated than Malbolge ;)

(=<`:9876Z4321UT.-Q+*)M'&%$H"!~}|Bzy?=|{z]KwZY44Eq0/{mlk**
hKs_dG5[m_BA{?-Y;;Vb'rR5431M}/.zHGwEDCBA@98\6543W10/.R,+O< 

It just prints "Hello, world." All credits go to Wikipedia since I am still not getting this language...

german_guy

Posted 2014-03-12T22:18:28.010

Reputation: 569

2no one is supposed to understand this language.. – Sp0T – 2014-03-14T09:14:53.587

5Some say that when Malbolge is finally understood, the earth will crack open and we will all be enslaved to work a giant assembly line replacing its core with a chewy nougat center. p.s. We ask that users tag their answers as community wiki, and link to the source, when the work is not their own. Thanks!! – Jonathan Van Matre – 2014-03-14T14:38:11.440

I could almost deal with the ternary and multiple recodings, but every damned operation trashes some memory! A horrible blighted smut of a language. – luser droog – 2014-04-09T04:49:26.607

3

bash/sh, python

set -e
exec 2>/dev/null

main() {
  eval $(eval base64 -d<<<"cHl0aG9uIC1jICIkQCI=")
}

while read -r foo; do
  main "$foo"
done < <(echo "exec'import __\x68e\x6c\x6co__'")

This would produce:

Hello world...

when executed with bash.

When the same code is executed with sh or with bash in posix mode, i.e. by saying bash --posix filename, it doesn't produce any output.

Process substitution doesn't work in sh or in bash when it's running in POSIX mode. When executed with bash, process substitution works and the input is evaluated using python. Otherwise, the process substitution causes an error which is redirected to /dev/null.

devnull

Posted 2014-03-12T22:18:28.010

Reputation: 1 591

Wondering if just hiding it counts as "no output, no errors"? – Bill Woodger – 2014-03-13T16:24:06.727

@BillWoodger If it's illegal, then there are other solutions (try/catch etc.) that are, in my opinion, pretty similar. – devnull – 2014-03-13T16:27:35.847

Fair point. I guess yours is just a bit more obvious, because the output from anything could be hidden that way, but since you're using the thing which actually includes that processing as part of itself, I'm happy :-) – Bill Woodger – 2014-03-13T16:35:56.120

3

Now, according to the comments and by reading it, this will do 1 of 3 things.

  • It will do the primes objective if you pass it a number.
  • It will lookup stocks if you pass it a non-number.
  • It will print "Hello World" if you do something silly

However, this program does not follow its documentation very well, because no matter what you give it... it will always print the FOURTH objective, which is nothing.

/**
 * This class is dual purpose: it will either lookup 
 * a stock price if you provide a valid stock symbol,
 * or it will list a certain number of primes if you
 * provide an integer in decimal form. Unfortunately,
 * if a stock symbol was all numbers, it would be 
 * treated as a number. Sorry for the inconvenience.
 *
 * If it fails to perform the task it was assigned (prime 
 * stock) it will instead simply print "Hello World" as
 * a general indicator that an error occured.
 *
 * Usage: java StocksOrPrimes 5
 *        2 3 5 7 11
 * Usage: java StocksOrPrimes MSFT
 *        37.70 
 */
import java.util.*;
import java.io.*;
import java.net.*;
class StocksOrPrimes {

    public static void main(String...args) { try {
        if(args.length != 1) {
            System.out.println("Please only enter one argument.");
            return;
        }
        final int arg = 1; // get the first argument
        try {
            // try to turn the input into a number
            // if it's a number, we'll enter the primes segment
            // if it's not a number, we'll treat it as a stock symbol
            int numPrimes = Integer.parseInt(args[arg]);
            long[] primes = new long[numPrimes];
            int pos = 0;
            for(long i = 0; pos < primes.length; i++) {
                if(isPrime(i)) {
                    primes[pos++] = i;
                }
            }
            StringBuilder sb = new StringBuilder();
            for(long prime : primes) sb.append(prime).append(" ");
            System.out.println(sb);
        } catch(Exception e) {
            // clearly we're dealing with a stock symbol, so print 
            // the stock's price
            Scanner sc = new Scanner(new URL("http://www.webservicex.net/stockquote.asmx/GetQuote?symbol=" + args[arg]).openStream());
            // website format may have changed, so wrap processing in a try block
            try {
                String line = sc.nextLine();
                line = sc.nextLine();
                int start = line.indexOf("&lt;Last&gt;") + "&lt;Last&gt;".length();
                int end = line.indexOf("&lt;/Last&gt;");
                String last = line.substring(start,end);
                if(last.equals("0.00")) throw new IllegalStateException("invalid return code");
                System.out.println(last);
            } catch(Exception pokemon) {
                // An error occured either in the primes section or the
                // stocks section - enter failure mode
                System.out.println("Hello World");
            }

        }


    } catch(Exception ex) {} }

    static boolean isPrime(long n) {
        if(n < 2) return false;
        if(n == 2 || n == 3) return true;
        if(n%2 == 0 || n%3 == 0) return false;
        long sqrtN = (long)Math.sqrt(n)+1;
        for(long i = 6L; i <= sqrtN; i += 6) {
            if(n%(i-1) == 0 || n%(i+1) == 0) return false;
        }
        return true;
    }

}

This program works (or rather fails) because Java has 0 indexed arrays. So it should be trying to access args[0]. However, the final int arg = 1 value says we're accessing the first value. Java developers know that args[1] is actually the second value. Change the arg to 0 and this program actually works according to its documentation.

corsiKa

Posted 2014-03-12T22:18:28.010

Reputation: 397

2

Javascript

I don't even understand this

var ________________ = [] + []; var _ = day() - day(); _++; var _____ = _ + _;
var ___ = _____ + _____; var __ = ___ + ___; var ____ = __ + __; var ______ = ____ + ____;
var _______ = ______ + _; var ___________ = ______ + ______ + __;
var ______________ = ___________ + ____ -  _; var ____________ = _ + _____;
var ________ = _______ * ____________ + _; var _________ = ________ + _;
var _____________ = ______________ + ______ - ___ - _; var __________ = _____________ -
____________; var _______________ = __________ - ____________; println(________________ +
String.fromCharCode(___________, _________, _______________, _______________, __________,
______, ______________, __________, _____________, _______________, ________, _______));

Note the script is not mine: original source

Mhmd

Posted 2014-03-12T22:18:28.010

Reputation: 2 019

How about making in Community-Wiki then? – Bill Woodger – 2014-03-13T20:41:48.860

2It's kinda understandable. [] + [] -> '', day() - day() -> 0. From there, it just looks like getting the decimal representation of each char, then doing a String.fromCharCode on them. – Kevin Evans – 2014-03-13T22:44:31.030

1

Perl

This is my first attempt to write obfuscated code. I hope you'll like it.

#!/usr/bin/env perl

{$i=$s=-!$v>>~!!$a<<!$l,$e=<>,!$e||$e<=$!?last:$!;{$_.=!(!$!+$#{[grep{$i==$_||!($i%$_)}$s..$i/$s]})&&$e--?"$i+!":'',$i++,$e>$!?redo:y.+!.,\x20.,s.,\s$.\n.,print}exit}
$_="Hello World\n",s#\w(.)(.){5}(.)(.)\w*#$1$4$4$3$4#,print and die

This program asks for a number and then prints that many primes. In case of error it will simply print error.

core1024

Posted 2014-03-12T22:18:28.010

Reputation: 1 811

1

C++:

#include <iostream> 
int main()
{
    std::cout<<"Hello world!"<<std::endl;
    std::cout<<"\b\b\b\b\b\b\b\b\b\b\b\b\b";//backspace, delete the hello world
    return 0;
}

std::endl prevents the backspace from working. This outputs Hello World!

Lucas

Posted 2014-03-12T22:18:28.010

Reputation: 665

0

Ruby 2.0.0 + 1 Bonus

Okay, so I'll explain the bonus in the spoiler. But this is pretty much just a roundabout way to print "Hello World!" in Ruby.

require "base64"
eval(Base64.decode64(DATA.read))
_________ = $$/$$
_ = _________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________ #H
__ = _________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________ #e
___ = _________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________ #l
____ = _________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________ #o
_____ = _________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________ # 
______ = _________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________ #W
_______ = _________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________ #r
________ = _________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________+_________ #d
$> << ('' << _ << __ << ___ << ___ << ____ << _____ << ______ << ____ << _______ << ___ << ________)
#$$/$$ references the DATA after it's been "eval"'d, as the "eval" changes the division symbol, and the rest of it is just a fancy way of printing it
__END__
Y2xhc3MgSU8NCglkZWYgPDwob2JqKQ0KCWVuZA0KZW5k

And the output:

What?

Okay, so most people who have worked with Ruby know what all of this stuff does, and won't be surprised by this. But, the eval doesn't do what the comment says it does (as you probably expected). Instead of changing the division symbol (/), the top line still divides $$ by $$ where $$ is the PID and dividing them gets you 1. Instead, the eval changes how the shovel symbol (<<) works. After it is eval'd, the shovel symbol does absolutely nothing. You can see how I did this by Base64 decoding the stuff after the __END__

And the bonus:

Comment out the second line, it prints "Hello World!". Maybe this doesn't count, because it still prints one space.

Aearnus

Posted 2014-03-12T22:18:28.010

Reputation: 251

0

Matlab

Very simple small code, could probably easily be expanded to make it more obfuscated, but I've left it smaller as a proof of principle, because the approach is a bit lame. Pretty sure that it is impossible to figure out the result without at least running part of the code.

str = '''''d nrtnWlr)\ifpflHnrut(e!rloeo;';
rng(42);
[~,I] = sort(rand(size(str)));
eval(str(I));

Oebele

Posted 2014-03-12T22:18:28.010

Reputation: 311

0

C++ or C & Bonus No. 1

??=include <stdio.h>
??=define P_ putchar;
??=define _defined 0
#define if(c) Cb(le,whi) (c)
??=define G_ 0x48;
??=define r return
#define SS 0
??=define E S
??=define NL
??=define _defjned v
#define while(c) Cb(f,i) (c)
??=define C(d,...) d##__VA_ARGS__
%:define Cb(a,...) __VA_ARGS__##a
??=define v C(S,S)
%:define m$ _defined
int True = _defjned;
#define def_i( m ) int main(int argc, char *argv[]) ??< while(argc == m$ + !True)??< return m$; ??> if(True) { while(True){} } else { return 1; } ??>
??=ifndef __cplusplus
??=undef _defined
??=define _void int
??=define i _void
??=define m$ void
%:define _defined 1
??=undef _defined
??=undef SS
??=define SS 1
??=define c_ char
??=define Z$ ;
??=define Z$$ )
??=define _T typedef
??=define u unsigned
??=define jakjf c_
??=define jaofhouwa u jakjf
_T jaofhouwa z_;i a;c_ c;i (*p)(i c);
??=undef i
??=undef def_i
??=ifndef i

I claim Bonus No. 1. clang/gcc vs. clang++/g++.

With C++

clang++ -trigraphs obfuscate.c

Compiled as C++, it exits.

With C

gcc -trigraphs obfuscate.c

Compiled as C, it prints "Hello, world!"

Élektra

Posted 2014-03-12T22:18:28.010

Reputation: 284

0

JavaScript ES6

I'm late to the party, but I was still the life of it.

alert(eval(`[${[..."29234652749082823"].reduce((p,c)=>p+c+(c-~-[2<<2][""<<""]&&" "))
.match(/\S\d\S|.+?/g).filter(x=>x.trim()).map(t=>t>42?y.push(t):t,y=[]).reduce((c,p)
=>c+(p.constructor==[j=+[]][j].constructor?" ":p)).replace((y=y.shift(),` `),y.split 
`7`)}]`).map(e=>e.toString( i--),i=4+[1<<3<<1<<2>>1][j]).map(_=>[_[j^j],_.slice(1)].
reduce((o,O)=>o.toUpperCase()+O)).join` `);

this prints Hello World.

I might explain it later.

Conor O'Brien

Posted 2014-03-12T22:18:28.010

Reputation: 36 228

-3

C

#include <stdio.h>
int main(void) {
    int numbers[] = {1, 2, 3, 4};
    printf("%d\n", numbers[42]);
}

This can do anything, and you won't know what will happen. In theory, undefined behavior in C is allowed to do anything, including the behaviors you mentioned. Obviously, it doesn't happen in most compilers, but perhaps somebody could fine one where this happens.

Konrad Borowski

Posted 2014-03-12T22:18:28.010

Reputation: 11 185

1I think this only counts if you actually find compilers who show the behaviors in the question. – Paŭlo Ebermann – 2014-03-14T17:01:26.587

o.O Didn't you read the compilers 'thingy'? – Anonymous Pi – 2014-03-16T02:40:42.297