841
Double Brainfuck
+++++[>++[>+>+ ++>++++>++++>++++>++++++
>++++++>+++++++ ++>+++++++++<<<<<<<<<-]>>
>+>+>+> >>>+[<]< -]>> >++>-->>+>>++>+
>--<<<< <<<..... ...
547
C#
I put a random pixel in the middle, and then start putting random pixels in a neighborhood that most resembles them. Two modes are supported: with minimum selection, only one neighboring pixel is considered at a time; with average selection, all (1..8) are averaged. Minimum selection is somewhat noisy, average selection is of course more blurred, but ...
524
Vigil
Finally a usecase for Vigil!
def main():
raise Exception()
Excerpt from the "language specification":
It goes without saying that any function that throws an exception which isn't caught is wrong and must be punished.
...
If an oath is broken, the offending function [...] will be duly punished.
How?
Simple: it will be deleted from your ...
answered May 28 '14 at 9:30
Martin Ender
188k6262 gold badges416416 silver badges923923 bronze badges
328
C
Here's an oldie but goodie...
#include <stdio.h>
#define six 1+5
#define nine 8+1
int main()
{
printf("what do you get when you multiply six by nine?\n");
printf("%i x %i = %i\n", six, nine, six*nine);
}
This program contains 42 different ASCII characters.
327
JavaScript Shell
This will make the language completely unusable.
clear(this);
Isn't it nice how JavaScript has such a nice function to destroy itself?
This is pretty simple, the clear function completely empty an object. this refers to the global object clearing out everything including constructors and functions.
Because this clears everything, doing ...
302
Pretty much any Linux distro, 9 chars
This one is a classic!
#!/bin/rm
Put this in a file and run it:
> ed
a
#!/bin/rm
.
wq foo
> ls
Mail mbox foo
> chmod 777 foo
> ./foo
> ls
Mail mbox
Aaand it's gone!
As to what is going on:
I'm really just running rm! #! is called a shebang. And if you put one of these followed by a path to some ...
297
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
294
C
Pretty cheap trick but I'm sure I will trap the most of you.
int main() {
int a = 2 + 2; ...
290
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 ...
280
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:
258
Ruby
def method_missing(meth,*args)
puts 'Banana'
send(meth.next)
end
def also
puts "Orange you glad I didn't say banana?"
end
ahem
Demo
Clears its throat, prints "Banana" 3070 times, and also puts "Orange you glad I didn't say banana?".
This uses Ruby's ridiculous just-in-time method definition functionality to define every method that lies ...
253
Processing
Update! 4096x4096 images!
I've merged my second post into this one by combining the two programs together.
A full collection of selected images can be found here, on Dropbox. (Note: DropBox can't generate previews for the 4096x4096 images; just click them then click "Download").
If you only look at one look at this one (tileable)! Here it is ...
248
x86 binary, 4 bytes
F0 0F C7 C8
Assumption: Must be run on a P5 Pentium CPU.
The above instruction is commonly known as the F00F bug. It attempts to execute an invalid instruction, prefixed with lock.
This freezes the CPU up completely (not a halt nor a reboot) and it doesn't even require root access.
235
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 ...
232
Java
I decided to add another entry since this is completely different from my first one (which was more like an example).
This program calculates the average of an array entered by the user...
import java.util.Scanner;
public class Numbers {
public static double getSum(int[] nums) {
double sum = 0;
if(nums.length > 0) {
...
227
Python w/ PIL
This is based on a Newtonian Fractal, specifically for z → z5 - 1. Because there are five roots, and thus five convergence points, the available color space is split into five regions, based on Hue. The individual points are sorted first by number of iterations required to reach their convergence point, and then by distance to that point, with ...
224
Python
import sys
sys.setrecursionlimit(1)
This will cause the interpreter to fail immediately:
$ cat test.py
import sys
sys.setrecursionlimit(1)
$ python test.py
Exception RuntimeError: 'maximum recursion depth exceeded' in <function _remove at 0x10e947b18> ignored
Exception RuntimeError: 'maximum recursion depth exceeded' in <function _remove ...
209
Table cloths
Flat
I started out putting a plaid/gingham pattern into perspective like a boundless table cloth:
unsigned char RD(int i,int j){
float s=3./(j+99);
return (int((i+DIM)*s+j*s)%2+int((DIM*2-i)*s+j*s)%2)*127;
}
unsigned char GR(int i,int j){
float s=3./(j+99);
return (int((i+DIM)*s+j*s)%2+int((DIM*2-i)*s+j*s)%2)*127;
}
unsigned char ...
190
Random painter
char red_fn(int i,int j){
#define r(n)(rand()%n)
static char c[1024][1024];return!c[i][j]?c[i][j]=!r(999)?r(256):red_fn((i+r(2))%1024,(j+r(2))%1024):c[i][j];
}
char green_fn(int i,int j){
static char c[1024][1024];return!c[i][j]?c[i][j]=!r(999)?r(256):green_fn((i+r(2))%1024,(j+r(2))%1024):c[i][j];
}
char blue_fn(int i,int j){
...
answered Aug 2 '14 at 17:07
Martin Ender
188k6262 gold badges416416 silver badges923923 bronze badges
189
Python
import webbrowser
webbrowser.open("http://stackoverflow.com/")
185
Javascript
var x=prompt('Enter a value under 100');
while (x != 100) {
x=x+1;
}
console.log('End!');
184
GolfScript
4:echo(2+2);
Prints 5.
183
Commodore 64 BASIC
40 print "Line 1"
30 print "Line 2"
20 print "Line 3"
10 print "Line 4"
183
Python
#!/usr/bin/python
lizt = ["SPOI",
"LERS: Lo",
"st begins with ",
"a plane crash on",
"a desert island and end",
"s with its viewers stuck in limbo forever."
]
while True:
for item in lizt:
print len(item)
Edit: As per nneonneo's suggestion, script now includes no digits.
180
Here it is in java. It is utter cheating, unacceptable and unfixable because it creates a MySQL database, insert the number there, do a select with an ORDER BY clause and outputs the numbers given by MySQL. In fact, it is MySQL who is doing the sorting, not the program.
package sorter;
import java.sql.Connection;
import java.sql.DriverManager;
import java....
179
Emmental
;#33!
I know this isn't code golf, but the right tool for the job, you know...
The user's code can be inserted after the !.
Emmental is an interesting esolang which is based on rewriting the interpreter. Every single symbol (including the built-in ones) can be redefined as an arbitrary Emmental program. The language relies on this feature so ...
answered Oct 18 '15 at 13:07
Martin Ender
188k6262 gold badges416416 silver badges923923 bronze badges
178
Sometimes the community here doesn't like to help with homework. That's why you are getting so many joke answers. But I like to help. Here is a complete solution in 'C' (since I assume you want to learn "programming", not "scripting" with Java or Ruby). I've included many tips that I wish I had known when I was first learning
#include <stdio.h>
//...
178
2013 - Dogescript
Dogescript is a language created in 2013 by Zach Bruggeman. It is nothing more than a syntax-replacement for Javascript to make it read like the internal monologues of memetic Shiba Inus.
Hello doge
console dose loge with "Dogescript was made in 2013!"
ASCII Art
such N much N
much i as 0 next i smaller N next i more 1
...
171
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 ...
Only top voted, non community-wiki answers of a minimum length are eligible
Related Tags
popularity-contest × 395graphical-output × 56
underhanded × 46
image-processing × 25
ascii-art × 23
math × 18
restricted-source × 16
code-challenge × 13
quine × 13
hello-world × 13
obfuscation × 12
code-trolling × 10
polyglot × 9
number × 8
code-golf × 6
string × 6
random × 6
cops-and-robbers × 6
music × 6
language-design × 6
geometry × 5
sorting × 5
natural-language × 5
animation × 5
sequence × 4