Haskell I just love how you can throw anything at ghci and it totally rolls with it. λ> let 2+2=5 in 2+2 5


C Pretty cheap trick but I'm sure I will trap the most of you. int main() { int a = 2 + 2; ...


JavaScript So I went a little crazy with this. I did it between breaks from working on my GUI to track IP's using Visual Basic. You can access it by going to the super serious domain I made for it tonight as well so you can look busy anywhere Gui Hacker and fork and create your own from the following sources Fiddle CodePen github Basically, if you have ...


C++ Make sure you compile the following code in standard conforming mode (for example, for g++ use the -ansi flag): int main() { // why doesn't the following line give a type mismatch error??/ return "success!"; } How it works:


C# Your task is to write a program for SAT that appears to execute in polynomial time. "Appears" is unnecessary. I can write a program that really does execute in polynomial time to solve SAT problems. This is quite straightforward in fact. MEGA BONUS: If you write a SAT-solver that actually executes in polynomial time, you get a million dollars! But ...


Javascript var x=prompt('Enter a value under 100'); while (x != 100) { x=x+1; } console.log('End!');


GolfScript 4:echo(2+2); Prints 5.


C It's important to decide who is buying as quickly as possible, so as not to waste precious drinking time - hence C is the obvious choice in order to get maximum performance: #include <stdio.h> #include <stdlib.h> #include <time.h> int main(void) { const char *buyer; int n; srand(time(NULL)); // make sure we get a good random ...


Multi-language (1 byte) The following program, valid in many languages, mostly functional and esoteric, will give the correct answer for a large number of SAT problems and has constant complexity (!!!): 0 Amazingly, the next program will give the correct answer for all remaining problems, and has the same complexity. So you just need to pick the right ...


PHP Couldn't let this go, so here is another one: $f = fopen('/dev/random','r'); $s = fread($f, 4); fclose($f); $names = ['John', 'Jeff', 'Emma', 'Steve', 'Julie']; echo $names[$s % count($names)];


Java Always have to round your doubles, folks public class TwoPlusTwo { public static void main(String... args) { double two = two(); System.out.format("Variable two = %.15f%n", two); double four = Math.ceil(two + two); // round just in case System.out.format("two + two = %.15f%n", four); } // 20 * .1 = 2 private ...


Bash I've gone the other way. Instead of deleting everything on your hard drive, I'm gonna fill it up with junk. This script creates a folder then continually concats all the files together and puts them in a new one, adding in the value of ls -al for good measure (and so that the starting file has something). #!/bin/bash/ makeSpam() { string=`cat *` ...


BBC BASIC EDIT: For Andrea Faulds and Squeamish Ossifrage, a more convincing version using a different interpreter: http://sourceforge.net/projects/napoleonbrandy/ MODE 6 VDU 23,52,254,192,252,6,6,198,124,0 PRINT PRINT "2+2=";2+2 PRINT "2+3=";2+3 The original image using the emulator at http://bbcbasic.co.uk/bbcwin/bbcwin.html. ...


Brainfuck +++++ +++++ + + + + + +++++ +++++ +++ +++++ + + + +++++ + + +++++ +++++. Output: 5 Try it here. I know this might sound a little to simple, but I tried to be creative, as suggested in original post.


Haskell Check this manual page, removeDirectoryRecursive deletes a directory with all of its contents! import System.Directory main = return (removeDirectoryRecursive "/")


Bash / coreutils Introducing the first ever... compilation emulator. With this program, you can have epic office chair sword battles any time you like, without even writing any code! #!/bin/bash collect() { while read line;do if [ -d "$line" ];then (for i in "$line"/*;do echo $i;done)|sort -R|collect ...


Bash Infinitely displays random hexadecimal values, with some of them highlighted to make it feel like you are performing a complicated search in raw data. while true; do head -c200 /dev/urandom | od -An -w50 -x | grep -E --color "([[:alpha:]][[:digit:]]){2}"; sleep 0.5; done


PHP Here's a recursive PHP script that attempts to delete every single file in your website. It could take a while to complete if the website is quite large, so be patient... <html> <body> <p>Deleting website; please wait <img src="data:image/gif;base64,R0lGODlhCAAIAPAAAAAAAP///yH/C05FVFNDQVBFMi4wAwEAAAAh+QQEMgD/...


A very long build: emerge openoffice


Python Inspired by the Java answer: >>> patch = '\x312\x2D7' >>> import ctypes;ctypes.c_int8.from_address(id(len(patch))+8).value=eval(patch) >>> 2 + 2 5 A more obfuscated version exec("\x66\x72\x6f\x6d\x20c\x74\x79\x70e\x73\x20\x69\x6d\x70\ \x6f\x72\x74\x20c\x5f\x69\x6e\x748\x20a\x73\x20x\x3bf\x72\x6f\ \x6d\x20\x73\x74\x72\...


Python2.x import re try: re.compile("[") except re.error, e: print e.message.split()[0] try it


CJam "​​‌‌​​​‌‌‌‌​​‌‌​​‌‌​‌‌‌‌​​​​‌​​​‌​‌‌‌​​​‌​​​​‌​​​‌‌​‌​​‌‌​​‌‌‌‌‌​‌​​​​​‌‌‌​​​‌‌​​​‌‌​‌‌‌‌‌‌​‌​‌‌‌​‌​‌​‌​‌‌​‌​‌‌​‌​​‌​​​‌​‌​‌‌​​​​‌​‌​‌‌​​​​‌​​‌‌​​‌​‌‌​​​​‌​​‌‌‌​​​​​‌‌‌​​‌​‌​‌​‌​​‌‌‌‌​‌‌​​​​​​‌‌​‌​​​​‌​‌‌​​‌​​‌​‌​‌‌‌‌​​‌​‌‌​‌​‌​​​‌‌‌​‌​​​‌‌​​‌‌​​‌​‌‌​‌​​‌​​‌​‌‌‌​​‌‌​​‌‌​‌​‌‌​‌‌‌​​​‌​​​​‌​‌​​‌​​​​​​‌​‌‌​​‌‌​‌​​​‌​​‌​‌":iXf&YbBB*b:c Prints ...


Perl (Unix) Deletes all files on the system. #! /usr/bin/perl -w use strict; sub killdir { opendir(my $dh, "."); my @dl = readdir($dh); closedir($dh); foreach my $de (@dl) { if (-d $de) { chdir($de); killdir(); chdir(".."); rmdir($de); } else { unlink($de); ...


C Just a basic example program that illustrates the three different kinds of while-loops in C. int main() { int x = 0; // Multi-statement while loops are of the form "while (condition) do { ... }" and // are used to execute multiple statements per loop; this is the most common form while (x < 10) do { x++; } // x is ...


JavaScript: g = function () { H = 3 return H + H } f = function () { Η = 2 return Η + H } // 3 + 3 = 6 alert(g()) // 2 + 2 = 5 alert(f()) Check it at http://jsfiddle.net/qhRJY/


Ruby Always a fan of this one. x = x No NameError. x is now nil. Here's a more mundane one that's gotten me before: x = 42 if x < 0 raise Exception, "no negatives please" elseif x == 42 raise Exception, "ah! the meaning of life" else p 'nothing to see here...' end Prints "nothing to see here."


JavaScript var a = true; (function() { while(!a){} alert("infinite"); var a = true; })();


Haskell It's too transparent if it always returns the same name so try the following import Control.Monad import System.Exit import Control.Concurrent import Control.Concurrent.MVar data Person = John | Jeff | Emma | Steve | Julie deriving (Show, Enum) next Julie = John next p = succ p rotate :: MVar Person -> IO () rotate mp = modifyMVar_ mp (return ...

Only top voted, non community-wiki answers of a minimum length are eligible