text:
Smile! Just smile
It's well known that Brainf*ck is very bad at Kolmogorov-complexity problems, for example, it requires around 100 characters just to print "Hello world".
However, there might be texts where Brainf*ck is just very good at.
Your task is now to write a program that takes no input, and it displays the following:
☺

That is, a smiley face (ASCII 1, if you browser does not render it).
Brainf*ck can do it in 2 characters.
+.

Try to find a language that beats it!
We assume your console can actually display that character (or your font has it, etc.).
Shortest code wins. If there are more of the same length, the first wins, but I'll upvote the others as well.
EDIT: I'm very sorry, I did not think the first post arrives this soon. A quick edit: the language has to be Turing-complete!

I must dispute your description of the output: While your code really outputs a character with the binary code 1, it is not ASCII-encoded, but belongs to some DOS codepage encoding like CP850 or CP437. In any modern console the smiley will not appear, because modern == UTF-8. ☺

I've voted to close this as a duplicate of Hello World, because the string to output is so short, so the task is essentially "how short is it to output any string"

FALSE (2)
1,

All that reading about BF paid off! False is an ancestor of Brainfuck.

Ouch! Strange that no one thought of this until now. :)

I had to accept this one, as the versions with plain-text and html were not actually done with programming languages.

I tried to do it with BLC, but I can't make any sense out of BLC. And even a 1-state Turing machine needs 4 or 5 elements in the tuple.

C, 18 chars
Far from beating Brainf**k, but as good as C can get (I guess).
Only works on little-endian platforms, must run without parameters.
main(c){puts(&c);}

Micronetics System MUMPS 4.4 (7 chars)
w $c(1)

MUMPS? Oh, the horror... I never even imagined that I'll see it here. +1 just for the pure shock value!

@vsz it's the only Golf suitable language I know, it often beats most common langs :)

Brainf*ck (only 2 characters)
+.

Of course, I'll still accept a solution of length 2.

Could you explain how this works? It should output ASCII 1 which is a non-printable character.

@nyuszika7h : many consoles output a smiley for ASCII 1.

Really? I've never seen such a console. I bet they use some obscure charset.

Doesn't beat 2 chars, but:
PHP 11 chars.
<?=chr(1)?>

For everyone saying you can simply place the smiley in php and it will output ☺:
Running it with php.exe in the command line gives Γÿǁ and placing it in the browser gives â˜º
It does not work.

You could also go the HTML route that m0nhawk did.

@GigaWatt You cannot. It puts out gibberish using PHP. Did you even try? I tried it in the CLI and the browser.

Works fine for me.  http://ideone.com/6wYzx9

Running it with php.exe in the command line gives Γÿǁ and placing it in the browser gives â˜º

If you do a hex dump of your file, you'll see that it was saved as unicode representation of a smiley (\xE298BA), not as \x01.  Try manually making a file with a single \x01 byte in it and running it from the command line with PHP.

DC - 2 characters
1P

It doesn't require any explanation.

Golfscript, 3 characters
"☺"

Not a golfscript expert, but I don't believe there is a way to convert an integer into the corresponding ASCII character using only 1 character, so it seems like this is the shortest it can get

PHP (1)
☺

Technically this is a valid PHP file (a web server will happily serve it).

LaTeX (51/77 characters)
Short solution
\documentclass{book}
\begin{document}
☺
\end{document}

Good solution (Compile with latex main.tex):
\documentclass{book}
\usepackage{wasysym}
\begin{document}
\smiley
\end{document}

The first one does not work because pure LaTeX cannot read unicode chars. Oddly enough, this does not work neither in XeLaTeX, nor in LuaLaTeX because the default font table does not contain this symbol. Please consider this: \documentclass{book} \usepackage{fontspec} \setmainfont{DejaVu Sans} \begin{document}☺\end{document} — and please specify the rendering engine you are using (pdfLaTeX) in the “good” solution.

Q/k (9 chars)
Can't do it in 2 unfortunately.
-1"\001";

I seem to recall a bug in an older version of the interpreter which produced the other smile symbol in less characters. I'll look it up.
Edit: found the quirk. It only appears to work on windows versions of the interpreter:
q)1(1b);
☺

J (3 chars)
'☺'

The code require appropriate font.
According to Wikipedia

In the Wingdings font, the letter "J" is rendered as a smiley face (note this is distinct from the Unicode code point U+263A, which renders as ☺).

Another variation is u:1.

Whitespace, 9 bytes

Try it online!
ssstl   push 1 on stack
tlss    output char

Burlesque - 6 Characters
,1L[sh
Explanation:
, pops stdin. 1L[ pushes one and convert to char (by codepoint) sh is used to switch to pretty format. (Otherwise it would print a leading ').

Tcl, 1
☺

Displays a ☺ with some other stuff.
There are rumors that this also works with PHP or other languages.

Arduino, 24
char a=1;Serial.print(a)

Stax, 2 bytes
1]

Run and debug it

The Stax ] doesn't work prefixly - it pops an item from the stack and creates a list from it. So you might alternatively need 1] for the program.

Keg, 2 characters
Push the number 1 and print it. (Surprised that 1, also works; -1 from Lyxal.)
1,

Try it online!
Keg, 1 character
Keg is actually Turing-complete, and any unrecognized command acts as a push onto the stack.
☺

Try it online!

It's actually 1, making it 2 bytes.

05AB1E, 2 characters
Just a boring hard-coding. It's encoded in CP437.
"☺

Try it online!
05AB1E, 2 bytes
1ç

Try it online!

You may want to include the encodings. Your top answer is only 2 bytes in an encoding like CP850 or CP437, which contains both the characters ☺ and " in their codepage. But using the 05AB1E encoding, the top answer isn't even possible, and using the UTF-8 encoding it would be 4 bytes.

The challenge says that characters are a valid encoding system...

chevron - 4 bytes/2 runes
>☺

Perl 6 (7 chars)
say '☺'

I'm bending the rules a little by assuming that a \n is welcome to avoid shell prompt mess.

Are you sure you need that space character?

JavaScript, 10 Bytes
alert("☺")

SmileBASIC, 3 characters
?"☺

PowerShell, 5 bytes
if a program should output the smile face char.
'☺'

Try it online!

PowerShell, 7 bytes
if a program should output the char with code 1.
[char]1

Try it online!

Why not just '☺' ? By the way, the face isn't rendered for me in TIO or the console

because the code for the smile face is not 1 in the Powershell. Try it online!

Should your answer be '[Char]9786' instead then? I'm really confused :-D

Ha! You are right. I thought I'd write a program that outputs a character with code 1. But you can interpret it as writing a program that outputs a smiley face.

Gol><>, 2 bytes
1H

Try it online!
Just for completeness. Push a single 1, print all the contents as characters and halt.

MineFriff, 5 bytes
C1,o;

Try it online!
Simply:

Treat the temp register as a character
Add one to the register and push
Output the top item and finish.

C (gcc), 15 bytes
f(){puts("☺");}

☺
Try it online!


text:
Cryptographic quine variant
Create a program that prints the MD5 sum of its source in the form:
MD5 sum of my source is: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

No cheating - you can't just read the source file and compute its sum. The program must not read any external information.
Of course you can use a MD5 library available for your language.

If someone manages to collide MD5 (i.e. h = f(h), where f is a crude "salt" for h with all the code garbage that is needed to print), I think they should be allowed to do that.

@NickT That would be extremely difficult though, I might add.

Python 157 149
r='r=%r;import md5;print "MD5 sum of my source is: "+md5.new(r%%r).hexdigest()';import md5;print "MD5 sum of my source is: "+md5.new(r%r).hexdigest()

Output:
MD5 sum of my source is: bb74dfc895c13ab991c4336e75865426

Verification at ideone

I'm getting a different md5sum for the source file.

@slackwear what are you getting?

oh you've edited it again. Right now I get 24ba0a79636297dab8803f571d4e3b44  md.py using md5sum in linux

@slackwear it looks like you have an extra newline at the end of your source file

I've tried it with and without a trailing newline...maybe i'm missing something here

@slackwear if I add a newline (\n) at the end of my program I get the hash you posted: 24ba0a79636297dab8803f571d4e3b44. I'm fairly certain that you have an extra newline. (I believe some editors will do this automatically)

You are correct. I was unaware vim would hide trailing LFs

I confirm that the program performs as claimed:  http://ideone.com/oYJvQh

hm, what it should do ? why not just print md5 sum of some fixed random string ?

@zb' The problem asks to print the MD5 sum of the source code, not just any string.

Python 2, 91 bytes
s="import md5;print'MD5 sum of my source is: '+md5.new('s=%r;exec s'%s).hexdigest()";exec s

Using the Python quine variant which doesn't require repeating everything twice. Tested on ideone.

this should be the accepted answer

Perl + Digest::MD5, 89 bytes
$_=q(use Digest::MD5 md5_hex;say"MD5 sum of my source is: ",md5_hex"\$_=q($_);eval");eval

No TIO link because Digest::MD5 is not installed on TIO. Note that this requires the language conformance level to be set to 5.10 or higher (-M5.010; this doesn't carry a byte penalty according to PPCG rules.
Explanation
This is yet another "print a function of the source code" challenge, meaning that it can be trivially solved via a universal quine constructor.
Universal quine constructor
$_=q(…"\$_=q($_);eval");eval

We use the q() string notation (which nests) to initialize $_, the "default" variable that Perl uses for missing arguments. Then we eval with a missing argument, so that the string inside the q() gets evaluated.
The string inside the q() is a description of how to create the entire program; we specify the rest of the program literally, then use an unescaped $_ to substitute the whole string in for the inside.
The technique thus creates a string with identical contents to the entire program's source; we could print it to produce a quine. We can also do other things to it first, though, making a universal quine constructor.
The rest of the program
use Digest::MD5 md5_hex;say"MD5 sum of my source is: ",md5_hex

Very simple: import an MD5 builtin, then print the fixed string specified in the question (it's not worth compressing it, I believe that in Perl the decompressor would take up more space than just stating the string literally), and use the MD5 builtin on the string we got via the universal quine constructor.

Node.js REPL (version 0.9.3), 96 94 bytes
Using the last version of Node.js that existed when this challenge was posted. I've tracked down the November 9, 2012 documentation for Node.js' crypto module, and it did support all the functions I've used here back in the day.
function x(s){return require("crypto").createHash("md5").update(s+";x(x)").digest("hex")};x(x)

If you don't feel like installing an antique version of Node.js just to test this code, rest assured it also works in the most recent version.
Node.js REPL (version 7.0.0), 81 bytes
And here is a version using ES6's arrow functions.
x=s=>require("crypto").createHash("md5").update(`x=${s};x(x)`).digest("hex");x(x)

Edit: thanks to Anders Kaseorg for pointing out an error in my Node.js 0.9.3 version, fixing which saved two bytes.

Although all the functions you used may have been supported by Node.js 0.9.3, the ES6 template literal syntax \${s};x(x)`` was not.

@AndersKaseorg Fixed, thanks. Turns out not using  a template literal actually saves some bytes in the Node.js 0.9.3 version.

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

sort: votes


text:
Compiled quine variant
Thinking about various quine puzzles here, I got an idea for another one:
Compose a program that outputs its own compiled code to a file (or multiple files, if the compiled code is). (This means that only compiled languages are eligible.)
Rules
Standard quine rules - no cheating allowed. In particular:

The program cannot read the compiled code from disk, cannot store it somewhere etc. It must compute it somehow without external help.
If the program is compiled to several files (i.e. several Java .class files), it must output them all.
You can use any existing libraries available for your language. However:

The libraries you use cannot be something created just for this task. (For example in order to keep some information away from what's considered to be the program.)
Any libraries you use must be older than your program. You cannot just create a program that loads a piece of data from an external library, compile the program, and copy the compiled code into the library - that'd be cheating.
You cannot embed a compiler of your language in any form. In particular, you cannot just take a standard quine and hook it up with a compiler to produce the compiled output.

As mentioned, only compiled languages are eligible. You can use a scripting language as long as it can be compiled to a bytecode that's reasonably different from the source form (if you're not sure, better ask).

Notes
Most likely, this puzzle can be solved reasonably only in languages that compile to some sort of bytecode that can be manipulated. For example, Java and compiled bytecode seems good for the task. (But if you find a genuine solution in some other compiled language, that's fine too, as long as it isn't some sort of cheating.)
Submission
Don't submit the compiled program (as this could be potentially dangerous). Instead post your sources and a description what to do to create the final program.
Evaluation
Let voters decide the best solution. Personally I'd appreciate solution that are elegant, short (in their source form) and didactic - that explain what's going on.
Bonuses
Bonus points for

Let the program output a compressed file containing its compiled code. This has the additional benefit that if the program is compiled into more files, the output will be a single packed file. For example, in Java try to create an executable JAR file that outputs the JAR itself.
Outputting the MD5 sum of the compiled file(s) - so the program would write its compiled code and its MD5 sum.

Is assembly language considered eligible for this challenge?

@IlmariKaronen Good question. I'd say yes, because compiled output is very different from what you type in source code.

Can you read the compiled code from memory? Something like main(){write(1, main, SIZE);}?

@ugoren No, that'd be similar to reading the code from a file.

Assembly (DOS .com file)
start:

%rep 2
    call $+3

    mov ah, 9
    mov dx, 100h + (end - start) / 2
    int 21h

    mov ah, 2
    mov dl, "$" - 1
    inc dx
    int 21h

    ret
    db "$"

%endrep

end:

Assemble with nasm quine.asm -o quine.com. Try with dosbox quine.com.
Proof of correctness (you can also verify by the smilies here):

If I understand correctly, it reads compiled code from memory.

I have to agree with @ugoren. The point of a quine is to construct its own code, not to read it from somewhere (whether it is a file or memory). For example, it could happen that the OS forbids reading the program's code (not under DOS probably, but in general).

@PetrPudlák The program actually consists of a code and a data section, which cannot really be separated in a .com executable. In my understanding this is a valid quine, because no byte is both interpreted as an instruction and written to output.

OK I think I understand now how it works. But I cannot compile it, nasm tells me: quine.asm:16: error: division operator may only be applied to scalar value. Any ideas?

@PetrPudlák fixed.

Just to clarify, the assembler's being asked to assemble two copies of the code (see the %rep … %endrep); one set of assembler output is treated as code by the program, the other as data (and obviously they're identical because the assembler is deterministic in this case; all the references to other addresses in the code are relative). The DOS .com format doesn't provide any way of specifying what is code and what is data, thus that distinction doesn't need to appear in the source.

Python 2.7.3
#!/usr/bin/env python
import sys
import time
import struct
import compiledquine

_ = '\x63\x00\x00\x00\x00\x00\x00\x00\x00\x06\x00\x00\x00\x40\x00\x00\x00\x73\x6e\x00\x00\x00\x64\x00\x00\x64\x01\x00\x6c\x00\x00\x5a\x00\x00\x64\x00\x00\x64\x01\x00\x6c\x01\x00\x5a\x01\x00\x64\x00\x00\x64\x01\x00\x6c\x02\x00\x5a\x02\x00\x64\x00\x00\x64\x01\x00\x6c\x03\x00\x5a\x03\x00\x64\x02\x00\x5a\x04\x00\x65\x00\x00\x6a\x05\x00\x6a\x06\x00\x64\x03\x00\x65\x02\x00\x6a\x07\x00\x64\x04\x00\x65\x08\x00\x65\x01\x00\x6a\x01\x00\x83\x00\x00\x83\x01\x00\x83\x02\x00\x17\x65\x04\x00\x65\x04\x00\x16\x17\x83\x01\x00\x01\x64\x01\x00\x53\x28\x05\x00\x00\x00\x69\xff\xff\xff\xff\x4e\x73\x08\x00\x00\x00%s\x73\x04\x00\x00\x00\x03\xf3\x0d\x0a\x74\x01\x00\x00\x00\x49\x28\x09\x00\x00\x00\x74\x03\x00\x00\x00\x73\x79\x73\x74\x04\x00\x00\x00\x74\x69\x6d\x65\x74\x06\x00\x00\x00\x73\x74\x72\x75\x63\x74\x74\x0d\x00\x00\x00\x63\x6f\x6d\x70\x69\x6c\x65\x64\x71\x75\x69\x6e\x65\x74\x01\x00\x00\x00\x5f\x74\x06\x00\x00\x00\x73\x74\x64\x6f\x75\x74\x74\x05\x00\x00\x00\x77\x72\x69\x74\x65\x74\x04\x00\x00\x00\x70\x61\x63\x6b\x74\x03\x00\x00\x00\x69\x6e\x74\x28\x00\x00\x00\x00\x28\x00\x00\x00\x00\x28\x00\x00\x00\x00\x73\x1c\x00\x00\x00\x2f\x68\x6f\x6d\x65\x2f\x67\x72\x61\x6e\x74\x2f\x63\x6f\x6d\x70\x69\x6c\x65\x64\x71\x75\x69\x6e\x65\x2e\x70\x79\x74\x08\x00\x00\x00\x3c\x6d\x6f\x64\x75\x6c\x65\x3e\x02\x00\x00\x00\x73\x0a\x00\x00\x00\x0c\x01\x0c\x01\x0c\x01\x0c\x02\x06\x01'
sys.stdout.write('\x03\xf3\x0d\x0a' + struct.pack('I', int(time.time())) + _ % _)

Note that this must be saved as compiledquine.py. These are the results I get:
$ ./compiledquine.py > compiledquine.py.out
$ md5sum compiledquine.pyc compiledquine.py.out
4b82e7d94d0d59e3d647d775fffc1948  compiledquine.pyc
4b82e7d94d0d59e3d647d775fffc1948  compiledquine.py.out

I won't guarantee that it'll work for you, but it does consistently work for me. Here's what happens:

At the bottom of the import statements, the script itself is imported. This compiles it to a .pyc file.
The variable _ is filled with the program's bytecode starting at byte 0x08, except %s is put in place of the variable itself.
The script fills in the first 4 'magic' bytes, which are specific to Python 2.7.3, followed by the timestamp in the next 4 bytes, which is generated by struct.pack and time.time, and then adds _ % _ to complete the output. (That last bit is borrowed from some other Python quines.)
Because of the timestamp at the beginning, this script technically isn't always accurate. If the self-import and the last line execute in different seconds, the output will be a byte off.

It seems to me there is a typo - shouldn't it be md5sum compiledquine.pyc compiledquine.py.out? However I tried and .pyc (679 bytes) is very different from .out (1372 bytes).

That was indeed a typo, my bad. And I'm not sure what to tell you regarding the outputs of .pyc and .out. For what it's worth, I'm using CPython 2.7.3 on 32-bit Linux.

Lua
s="s=%qf=io.open('dump.txt','w')f:write(string.dump(load(s:format(s))))"f=io.open('dump.txt','w')f:write(string.dump(load(s:format(s))))

Now, one's first concern may be that Lua is 'An Interpreted Language, not a compiled one' However, Lua actually interprets by compiling at runtime. string.dump returns the compiled byte code of the function supplied, and load returns the function defined by the string supplied.
Very simply, makes a function out of itself through the usual Lua quine method, then writes its compiled output.
Output
LuaS “

xV           (w@‰s="s=%qf=io.open('dump.txt','w')f:write(string.dump(load(s:format(s))))"f=io.open('dump.txt','w')f:write(string.dump(load(s:format(s))))            @@€À@  A A@ € $€€  €@ ÀA † B ‡@BÆ€B @ ÁB†@ $€ä   ¤   $@  & €    sEs=%qf=io.open('dump.txt','w')f:write(string.dump(load(s:format(s))))fioopen  dump.txtwwritestringdumploadformat                                                                              _ENV

Contains mostly unprintable characters, so here's a Hex Dump
00000000:  1b4c 7561 5300 1993 0d0d 0a1a 0d0a 0408 0408 0878 5600 0000  :.LuaS..............xV...
00000018:  0000 0000 0000 0000 2877 4001 8973 3d22 733d 2571 663d 696f  :........(w@..s="s=%qf=io
00000030:  2e6f 7065 6e28 2764 756d 702e 7478 7427 2c27 7727 2966 3a77  :.open('dump.txt','w')f:w
00000048:  7269 7465 2873 7472 696e 672e 6475 6d70 286c 6f61 6428 733a  :rite(string.dump(load(s:
00000060:  666f 726d 6174 2873 2929 2929 2266 3d69 6f2e 6f70 656e 2827  :format(s))))"f=io.open('
00000078:  6475 6d70 2e74 7874 272c 2777 2729 663a 7772 6974 6528 7374  :dump.txt','w')f:write(st
00000090:  7269 6e67 2e64 756d 7028 6c6f 6164 2873 3a66 6f72 6d61 7428  :ring.dump(load(s:format(
000000a8:  7329 2929 2900 0000 0000 0000 0000 0207 1400 0000 0840 4080  :s))))................@@.
000000c0:  06c0 4000 0700 4100 4140 0100 8180 0100 2480 8001 0800 0081  :..@...A.A@......$.......
000000d8:  0680 4000 0cc0 4100 8600 4200 8740 4201 c680 4200 0601 4000  :..@...A...B..@B...B...@.
000000f0:  0cc1 4202 8601 4000 2401 8001 e400 0000 a400 0000 2440 0000  :..B...@.$...........$@..
00000108:  2600 8000 0c00 0000 0402 7314 4573 3d25 7166 3d69 6f2e 6f70  :&.........s.Es=%qf=io.op
00000120:  656e 2827 6475 6d70 2e74 7874 272c 2777 2729 663a 7772 6974  :en('dump.txt','w')f:writ
00000138:  6528 7374 7269 6e67 2e64 756d 7028 6c6f 6164 2873 3a66 6f72  :e(string.dump(load(s:for
00000150:  6d61 7428 7329 2929 2904 0266 0403 696f 0405 6f70 656e 0409  :mat(s))))..f..io..open..
00000168:  6475 6d70 2e74 7874 0402 7704 0677 7269 7465 0407 7374 7269  :dump.txt..w..write..stri
00000180:  6e67 0405 6475 6d70 0405 6c6f 6164 0407 666f 726d 6174 0100  :ng..dump..load..format..
00000198:  0000 0100 0000 0000 1400 0000 0100 0000 0100 0000 0100 0000  :........................
000001b0:  0100 0000 0100 0000 0100 0000 0100 0000 0100 0000 0100 0000  :........................
000001c8:  0100 0000 0100 0000 0100 0000 0100 0000 0100 0000 0100 0000  :........................
000001e0:  0100 0000 0100 0000 0100 0000 0100 0000 0100 0000 0000 0000  :........................
000001f8:  0100 0000 055f 454e 56                                       :....._ENV

Python 3, 161 bytes
s = 's = %s; print(compile(s %% repr(s), \'file\', \'exec\').co_code.decode(\'utf-16\'))'; print(compile(s % repr(s), '<file>', 'exec').co_code.decode('utf-16'))

Try it online!
This one outputs its EXACT bytecode (that is, the bytecode that is stored in the Python interpreter when you run the program.)
Python 3, 328 bytes (Extension)
import zipfile
with zipfile.ZipFile("output.zip", "w") as f:s = 'import zipfile\n\nwith open(\"output.zip\", \"w\") as f:\ns = %s\nf.writestr(\n\'output\',\ndata=(compile(s %% repr(s), \'file\', \'exec\').co_code.decode(\'utf-16\')))\n';f.writestr('output',data=(compile(s % repr(s), '<file>', 'exec')).co_code.decode('utf-16'))

Try it online!
This one prints its EXACT bytecode (that is, the bytecode that is stored in the Python interpreter when you run the program. It also outputs it being compressed.)

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
Swap 2 objects, without using a temporary variable
There are two objects:
Object1, Object2

You can easily swap them by:
Object3 = Object1
Object1 = Object2
Object2 = Object3

However, you must solve this problem by using no temporary object and Object1 should be changed to Object 2. (and vice versa)

Here we have a prime example of what is wrong with challenges that don't have "an objective winning criteria" as currently required by the FAQ: three different answer that are all completely correct. So how will people judge them? All that we have here is a popularity context.

@dmckee, the problem here isn't lack of objective winning criteria, but of any winning criteria.

Would this count in Python? a,b=b,a

Python
I'll say it first.
object1, object2 = object2, object1

Also possible in Go. However, I think a temporary variable may still be made in the compiled code.

This is also valid Ruby.

@MaxMorin: Python-the-language-spec describes this as creating an anonymous tuple of the objects on the right, then unpacking to the names on the left. CPython-the-reference-interpreter skips the actual tuple (it just loads the two objects onto the stack, swaps the top two stack entries, then unpacks).

If you have access to the memory address of these objects, you can swap them by xor-ing their addresses.
// return 0 for success, 1 for error
int swap(void *object1, void *object2, int size)
{
    for (int i = 0; i < size; i++)
    {
        char *x = (char *)(object1 + i);
        char *y = (char *)(object2 + i);
        if (x == y)
            return 1;
        *x ^= *y;
        *y ^= *x;
        *x ^= *y;
    }
    return 0;
}

per dmckee suggestion for clarity

The solution is to pass a size as well, cast to char* and then xor swap the characters guarding against the same-value failure mode. Not as pretty, but standards compliant and working.

Only answer which doesn't do a,b = b,a. +1 :)

Mathematica
A standard feature:
a = 1; b = 2;
Print[a, " ", b];
{a, b} = {b, a};
Print[a, " ", b];

Output
(*
1 2

2 1
*)

PostScript
In PostScript, it's common to use the stack instead of named variables, so a simple
exch

would do the job. But if you have variables, you can do it like
/a 1 def
/b 2 def
/a b /b a def def

Perl
($object1, $object2) = ($object2, $object1);

Using Perl's list assertions feels like cheating, but it's a pretty common feature.

PHP
Objects / arrays / resources:
list($a, $b) = [$b, $a];

Integers / booleans / strings of equal length:
$a ^= $b ^= $a ^= $b;

Forth
swap

As i have to include more than 30 characters, here's a link to a Forth primer


text:
Match up to 10 in an array
Challenge
Given an array of single digit number, work out if any 2 of them add up to 10 and print them out
Example
Input

(1,2,3,4,5,5,6,7)

This returns ((4,6),(5,5),(3,7))
Input

(1,2,3,4,5)

This returns (). as there is only one 5
Input

(5,5,5,5,5)

This returns ((5,5),(5,5)) as there is odd number of 5s and each 5 can be used only once
Rules
Here are the rules!

Assume input will only be an unsorted array of positive single digit integers
Each number will be pair up only once, which means if there are three 5s it only form 1 pair (5,5). If there are (3,3,7) it will only form 1 pair (3,7)
For the input: You can use any type of parentheses(or lack of) as long as readers can tell that the input is a single array of numbers.
For the output: It must look like an array of pairs. Where the array is the same form as your input.(If you did not use any parenheses in your input, you have to use some kind of symbols so that any readers can tell they are pairs in an array)

Test Cases
(1,2,3,4,5,5,6,7) =((4,6),(5,5),(3,7))
(1,2,3,4,5) = ()
(5,5,5,5,5) = ((5,5),(5,5))
(1,2,3,3,4,5,6,7)=((3,7),(4,6))
(9,8,7,6,4,4,3,1)=((9,1),(7,3),(6,4))

Good luck!
The shorter an answer is, the better!
Edit 1: update the rules and Testcases from comments
Edit 2: update rules to define format of input.
Edit 3: update rules to define format of output. trying to be as accommodating as possible.

Shouldn't there be 10 different combinations of (5,5) for the final test case?

@Gareth It looks like the values get used up when they make pairs

Could you post a few more test cases? Perhaps something like (1,2,3,3,4,5,6,7)

@Matt edited. Thanks for the feedback

Does the input have to include the parentheses, or can it be inputted as 1,2,3,4,5,5,6,7?

@jdstankosky I wasn't sure how array is defined in each languages so I didn't set that as one of the rules. Since it was like that, I am gonna say that you can use any type of parentheses(or lack of) as long as readers can tell that the input is a array of numbers.

Is the output bound to some rules or are you as lenient as with the input?

@tomsmeding the output is a bit more stricter. It must look like an array of pairs to any readers. Where you are using the same format for the array as your input.

Can we assume the input is sorted?

@GigaWatt the input is not sorted else it would be a bit too easy

@Gareth i agree, there should certainly be 10 combinations of 5's

GolfScript, 45 42 37 chars
~{([.~11+.])@{1$=.{2$p!\}*!},\;\;.}do

The new approach does also take arrays with a single item as input. Moreover, it is several chars shorter.
Previous version:
~{$(\)@.2$+10-.{0>{\}*;+}{;[\]p}if.,1>}do;

The algorithm used in this code is described as follows:

Sort the array.
Take the sum of the first and the last item.

If the sum is 10 print both numbers and remove them from the array.
If the sum is greater than 10, discard the larger number.
If the sum is less than 10, discard the smaller number.

Loop until the array contains only a single digit or is even empty.

The code expects an array of at least two digits on STDIN.
Examples (see online):
>[9 8 7 6 4 4 3 1]
[1 9]
[3 7]
[4 6]

>[5 5 5 5 5]
[5 5]
[5 5]

Python 2.7 (70)
y=input()
while y:
 g=10-y.pop()
 if g in y:y.remove(g);print(g,10-g)

Testcases:
$ echo '[1, 2, 3, 4, 5, 5, 6, 7]' | python p.py
(3, 7)
(4, 6)
(5, 5)

$ echo '[1,2,3,4,5]' | python p.py

$ echo '[5,5,5,5,5]' | python p.py
(5, 5)
(5, 5)

$ echo '[1,2,3,3,4,5,6,7]' | python p.py
(3, 7)
(4, 6)

$ echo '[9,8,7,6,4,4,3,1]' | python p.py
(9, 1)
(7, 3)
(6, 4)

One byte extra for the nice parenthesis.

I think I replicated this method in PHP, but it only works occasionally and not with all pairs. Any idea why? <?$a=fgetcsv(STDIN);while($a){$b=10-array_pop($a);if($a[$b]){unset($a[$b]);echo"($b,",10-$b,")";}}

Javascript, 188 183 181 153 141 121 123 112 105 98 chars
Golfing in JS is somewhat difficult, but I just wanted to have a bash on this problem, so here's the code:
for(a=eval(prompt(i=o=[]));k=a[j=++i];)for(;p=a[--j];)k+p-10||(k=a[i]=a[j]=-o.push([p,k]));console.log(o)

Input: e.g. [1,2,3,3,4,5,6,7]. Output e.g. [[4,6],[3,7]] to the console.
105->98: Used Daniel's awesome algorithm to completely rewrite the code! See his answer for a readable algorithm. Completely messed up stuff so reverted to 105 chars.
112->105: Initialised i to zero, used output of o.push to set k (k=a[i]=a[j]=-o.push...) and logged output to console instead of alerting to eliminate "["+ and +"]" since the console outputs nicely already.
123->112: Now removed outer brackets in output, since golfscript may :) Also finally applied suggestion of removing |=0.
121->123: Changed o+="("+p+","+k+")," to o.push("("+[p,k]+")") (adds 2 chars :( ) and made o an array instead of a string (o=""->o=[]). Now output isn't wrong anymore (like ((5,5),(5,5),)).
141->121: From now on assumed that the question meant that we could get input in the language's array format, which in JS's case is [a,b,c,...] and made o, the output "accumulator" a string instead of an array (o.push(...),->o+=...,).
153->141: Reset array entries instead of removing them after usage.
181->153: Applied changes to u=[], rearranged loops, a[i]&a[j]->temp vars, converted if logic and converted int logic to a[i]|=0.
183->181: Replaced i<=0 with i+1 and the same for j.
188->183: Placed o=[] inside prompt() (;) and replaced for(j=i; with for(j=i-1; (i==j&&).
(Thanks mellamokb, Paul Walls and ryan!)

You can replace i>=0 with i+1 and j>=0 with j+1 to save 2 chars.

Also, I think you can shave a few characters by using an array to represent which items are already used.  For example, set x=[], then replace the inside of the entire if with o.push("("+a[x[j]=j]+","+a[x[i]=i]+")"), and the condition on the inner for with j>=0&!x[i]&!x[j].  I'm not convinced this can't be golfed further, but I believe it will save 1-2 chars.

@mellamokb does that really save chars? But replaced the first one :)

I applied the change to a bit field array (u=[] instead of x), rearranged the loops to go from 0 upward, assigned a[i] and a[j] to temp variables to save repeated references, moved some variable initializations into other statements, converted the if logic to chained || logic, and converted the int parsing to the more succinct a[i]|=0, to get a total savings of 30 characters :).  Here's my test harness demonstrating the accuracy of the solution: http://jsfiddle.net/GKUDb/8/, and the 151-character golfed working solution: http://jsfiddle.net/DVtW2/.

Reproduced 151-character answer for reference: a=prompt(o=[]).slice(1,i=-1).split(',');for(u=[];k=a[j=++i]|=0;)for(;p=a[--j];)k+p-10||u[i]||u[j]||o.push("("+(u[j]=u[i]=p)+","+k+")");alert("("+o+")").  BTW, you can golf in JS, the methods are just different :P

Shaved off another 11 characters by borrowing the ingenious idea from @air_blob of simply resetting array entries as they are used up (duh!): for(a=prompt(o=[]).slice(1,i=-1).split(',');k=a[j=++i]|=0;)for(;p=a[--j];)k+p-10||(o.push("("+p+","+k+")"),k=a[i]=a[j]=-1);alert("("+o+")") (test harness | example)  Current solution now beats both C and Python implementations!

@mellamokb I don't have time to get to golfing myself right now but I'll be back! You're a genius, by the way :)

With your new code using an array, you can save a few more characters by initializing i to 0.  I only had used -1 for the convenience of sharing the parameter to slice, but i=0 works as well.  In fact, if you set i="", it coalesces to an integer properly, so you can combine the initialization to a=prompt(i=o="")....  Also, since you are evaling an array, there's no longer a need to convert the entries from string to integer, so you can drop of the |=0 on k=a[j=++i] to save 6 chars total.

Here's another approach that eliminates the inner for loop entirely by using parallel nested counters chained with ||: for(a=eval(prompt(j=i=o=''));(p=~~a[--j])||(k=a[j=++i]);)k+p-10||(o+="("+p+","+k+"),",a[i]=a[j]=-1);alert("("+o+")").  Sadly, it ends up being 1 char longer than the reduced form from my previous comment, but it may have more yet that can be golfed.

Array.toString() will save you a few characters as well (i.e. o+="("+[p,k]+")").

Do you think we may output to the console instead of alerting? Then we could save some chars as well :)

If you are ok with output like that of golfscript, then you can do this:  for(a=eval(prompt(o=[])),i=-1;k=a[j=++i]|=0;)for(;p=a[--j];)k+p-10||(o.push("["+[p,k]+"]"),k=a[i]=a[j]=-1);alert(o), brings it down to 115

What golfscript can, we can do too!

You forgot my suggestion to  initialize i to 0.  You can fold a=eval(prompt(o=[])),i=-1 into a=eval(prompt(i=o=[])) without loss of fidelity, for a further 3 character savings.

Incorporated mellamokb's suggestion above and a few other shenanigans: for(a=eval(prompt(i=o=[]));k=a[j=++i];)for(;p=a[--j];)k+p-10||(k=a[i]=a[j]=-o.push("["+[p,k]+"]"));alert(o). Down to 107.

@tomsmeding: You're newest solution is fundamentally broken.  The problem is i in a doesn't check if a has value i; it checks if a has index i.  So where it is working, it's working by accident for inputs where the indexes are roughly the same as the values.  Also, in golfing C-style languages, it is generally encouraged to prefer for over while, because the basic format is the same length (while() vs for(;;)), but for allows the flexibility of squeezing out a few more chars by making elegant use of the three parts.

Here's my test harness setup with your new code to demonstrate what I mean.  Only two of the test case answers are actually correct: http://jsfiddle.net/GKUDb/16/.

Indeed, I didn't test properly :) I've tried to get David's algorithm golfed enough but didn't make it in a reasonable number of chars. Reverted now to 105.

J, 54 53 50 46 45 44 characters
(>:,.9&-)I.<.4({.,-:@{::)(<.|.)+/|:(1+i.9)=/

Usage:
   (>:,.9&-)I.<.4({.,-:@{::)(<.|.)+/|:(1+i.9)=/5 5 5 5 5
5 5
5 5
   (>:,.9&-)I.<.4({.,-:@{::)(<.|.)+/|:(1+i.9)=/9 8 7 6 4 4 3 1
1 9
3 7
4 6

The algorithm is basically:

count the instance of each number +/|:(1+i.9)=/
pair the counts of each pair that would add to 10 (<.|.) (so 1 and 9, 2 and 8 etc.)
take the minimum of those counts  (so if you have three 9s but only one 1, you'll only have one 1 9 pair) and drop everything after the first five pairs
the 5s are a special case so divide that by 2 (<.4({.,-:@{::) implements both previous steps)
take the first five items of the list and output the number and 10-the number (>:,.9&-)I.

Python (142)
Input should be given with square brackets instead of round brackets.
http://ideone.com/p2QR11
from itertools import*
a=input()
c=lambda:[i for i in product(a,a[1:])if sum(i)==10]
d=c()
while d:print d[0];[a.remove(j)for j in d[0]];d=c()

Algorithm:
1. Get input
2. Generate all pairs of input where the sum is 10
3. If there are no pairs, then END PROGRAM
4. Take the first pair's items and remove them from the input
5. Go back to step 2

If seriously malformed output is allowed (90): http://ideone.com/GR762f
a=input()
c=a.count
for i in range(6):print(`i`+`10-i`+' ')*(min(c(i),c(10-i))/(1+(i==5)))

C, 142,138, 124
char*p,*q;
main(int a,char**s){
    for(p=s[1];*p;p++)
        if(q=strchr(p+1,106-*p))a=*q=printf("%c(%c,%c)",38+a,*p,*q);
    puts("()"+a/6);
}

Testing:
./a.out "(1,2,3,4,5,5,6,7)"
((3,7),(4,6),(5,5))

./a.out "(1,2,3,4,5)"
()

./a.out "(5,5,5,5,5)"
((5,5),(5,5))

./a.out "(1,2,3,3,4,5,6,7)"
((3,7),(4,6))

./a.out "(9,8,7,6,4,4,3,1)"
((9,1),(7,3),(6,4))

Implementation notes:

initially a=2 (program has two args), set to 6 (printf prints 6 chars) once a match occurs
106 = '0'+'0'+10, i.e. uses the sum of the ascii codes
38+a, is either 44/40, i.e. '(' or ','
By setting string characters to 6 it ensures they wont add to 106 on other passes
"()"+a/6, is either "()" or ")"

Javascript - 131 129 125 chars
for(i=eval(prompt(r=[])),k=j=i.length;j--;)for(m=k;m--;)if(m!=j&&i[j]+i[m]==10)r.push([i[j],i[m]]),i[j]=i[m]=0;console.log(r)

I assume, the order of and in the nested result arrays is not compulsory :)
Evaluated test cases:
[1,2,3,4,5,5,6,7] returns [[7,3],[6,4],[5,5]]
[1,2,3,4,5]       returns []
[5,5,5,5,5]       returns [[5,5],[5,5]]
[1,2,3,3,4,5,6,7] returns [[7,3],[6,4]]
[9,8,7,6,4,4,3,1] returns [[1,9],[3,7],[4,6]]

Edit: As the problem description says 'Array', we're talking about the language specific notation of an array, right?

Perl 52
perl -ne '$a{$y=9-$_}&&0*$a{$y++}--*print"$y,$_"or$a{$_-1}++'

Proof :
> cat test
1
2
3
4
5
5
6
7
> perl -ne '$a{$y=9-$_}&&0*$a{$y++}--*print"$y,$_"or$a{$_-1}++' < test
5,5
4,6
3,7

And there is an ungolfed commented code :
while(<>) {     # made by the -n option

    # We are looking for (P,Q) pairs where P+Q=10
    # Each P entry will come in $_="P\n" (because $_ will not be chopped)
    # We choose to store the number of occurence of P in $a{P-1}
    # (For instance, if there have been five '3's in the input, then $a{2}=5)

    $y=9-$_;        # if Q=P-10, then $y=Q-1
    if ($a{$y}) {   # check if there was a Q (so $a{Q-1} != 0)
        $a{$y++}--;   # If so 'consume' this Q, and let $y=Q
        print"$y,$_"; # ... and output "Q,P\n"
    } else {
        $a{$_-1}++;   # P is not forming a new pair, so 'count it'.
                    # $a{$_} would not work because of the un-chopped \n, thus the '-1'
    }

}

Maybe the explanations looks like pidgin French (I'm not a native english writer), so if someone wants to edit it and make it more understandable, please do so.

Seriously, not even one point for this, with the explanations and all ?... :(

Mathematica 70
Cases[#//.{x___,n_,y___,d_,z___}/;n+d==10:>{x,y,z,n~f~d},a_~f~b_:>{a,b}]&

Usage
Cases[# //. {x___, n_, y___, d_, z___} /; n + d == 10 :> {x, y, z, n~f~d},
a_~f~b_ :> {a,b}] &[{1, 2, 3, 4, 5, 5, 6, 7}]

{{3, 7}, {4, 6}, {5, 5}}

PostScript (46)
This uses hand-coded binary tokens, therefore, here is a hexdump:
00000000  7b 7b 92 1a 92 3f 7b 32  92 19 92 01 31 30 92 3d  |{{...?{2....10.=|
00000010  7b 32 92 09 92 0b 3d 3d  5b 92 40 7d 69 66 92 1a  |{2....==[.@}if..|
00000020  31 92 87 7d 92 83 92 75  7d 92 65 7d 92 a3        |1..}...u}.e}..|
0000002e

I uploaded the binary file if you want to try it out.
This expects the numbers to be on the stack. They can be prepended to the code or be supplied on the command line, e.g. when using Ghostscript like so:
gsnd -c 2 8 5 5 @ 10_golfed.ps

If you insist on array syntax for input, then this requires two more tokens (aload pop) right at the beginning. In binary tokens, this is four more bytes.
Un-golfed and commented:
{ % stopped                   % we use stopped because we want to catch a
                              % stackunderflow when all numbers have been used up
  { % loop                    % repeat until all numbers have been popped off the stack
    % Test for all numbers on the stack whether they add up to 10 with the topmost number
    count{                    % ... nextNumber number currentTestNumber
      exch                    % ... nextNumber currentTestNumber number
      2 copy add 10 eq{       % ... nextNumber currentTestNumber number
        2 array astore ==     % ... nextNumber
        % We push "[" on the stack because we want to pop the topmost object after each iteration.
        % As [ is a one byte self delimiting token, this is nice for golfing.
        [ exit                % ... nextNumber [
      }if                     % ... nextNumber currentTestNumber number
      count 1 roll            % number ... nextNumber currentTestNumber
    }repeat                   % number ... nextNumber currentTestNumber
    pop                       % number ... nextNumber
  }loop
}stopped

PHP 150 149 148 146 142 --> 140
Use with PHP CLI.
<?$a=fgetcsv(STDIN);for($i=0;$i<$c=count($a);$i++){for($j=$i+1;$j<$c;$j++)if($a[$i]+$a[$j]==10){echo"({$a[$i]},{$a[$j]})";$a[$i]=$a[$j]=0;}}

Input: 1,2,3,4,5,5,6,7
Output: (3,7)(4,6)(5,5)
Un-golfed:
<?php

$a = fgetcsv(STDIN);
$c = count($a);
for ($i = 0; $i < $c; $i++) {
    for ($j = ($i + 1); $j < $c; $j++) {
        if ($a[$i] + $a[$j] == 10) {
            echo "({$a[$i]},{$a[$j]})";
            $a[$i] = 0;
            $a[$j] = 0;
        }
    }
}

?>

Python 84
Requires input in brackets instead of parenthesis.
a=input();r=[]
while a:
 n=a.pop(0);m=10-n
 if m in a:a.remove(m);r+=[(n,m)]
print r

For roughly the same answer golfed better see Daniel's answer.

SED, 112 chars
Probably somewhat simpler than the other solutions
s/.*/@&;12345678987654321/
:
s/\(@.*\)\(.\)\(.*\)\(.\)\(.*;.*\2.\{7\}\4\)/(\2,\4),\1\3\5/
t
s/^\(.*\),@.*/(\1)/

Perl, 72 with the -p flag
perl -p -e 's/^/@/;1while s/(@.*)(.)(.*)((??{10-$2}))/($2,$4)$1$3/;s/(.*)@.*/($1)/'

I think the -p should be counted since the equivalent would add LINE: while (<ARGV>){...}continue{die "-p destination: $!\n" unless print $_}

On every automated golf server, this would be counted as 80 bytes, as it requires the shebang #!perl -p plus newline.


text:
Best Scoring Scrabble Board
Challenge
Your challenge is simply to write a program in the language of your choosing that when run, determines the highest possible score for a board of Scrabble - For the sake of this challenge, a few rules have been modified.
Notably, bonus squares are counted for every single word on the board, rather than only the "first" time used, The 50 Point Bonus for 7-letter plays is removed, and scoring is calculated at the end of the entire board, for every word on the board. Do not score any words double such as text/texts being 2 separate words.
You may use any dictionary file you like, there are multiple online scrabble dictionaries you may use. The accepted answer must include only scrabble-valid words.
Rules
A Scrabble game board is made of up cells in a square grid. The Scrabble board is 15 cells wide by 15 cells high. The Scrabble tiles fit within these cells one to a cell.
Scrabble is played with exactly 100 tiles. 98 of these tiles contain letters on them, while there are 2 blank tiles. These blank tiles add a wildcard aspect to Scrabble. The blanks substitute for any letter in the alphabet. Once played, a blank tile remains for the remainder of the game the letter for which it was substituted when first played.
Various letters have different point values, depending on the rarity of the letter and the difficulty in playing it. Blank tiles have no point value.
English-language editions of Scrabble contain 100 letter tiles, in the following distribution:
2 blank tiles (scoring 0 points)
1 point: E ×12, A ×9, I ×9, O ×8, N ×6, R ×6, T ×6, L ×4, S ×4, U ×4
2 points: D ×4, G ×3
3 points: B ×2, C ×2, M ×2, P ×2
4 points: F ×2, H ×2, V ×2, W ×2, Y ×2
5 points: K ×1
8 points: J ×1, X ×1
10 points: Q ×1, Z ×1
Some squares on the Scrabble board represent multipliers. If a tile is placed on this square, then the tile's value is multiplied by a factor or either 2x or 3x. Certain tiles multiply the point value of an entire word and not simply the tile on that space.

Double Letter Scores - Light blue cells are found isolated on the board. When a tile is placed on this space, that tile's point value is multiplied by two.
Triple Letter Score - This is a dark blue cell on the Scrabble. The tile placed on this square has its points multiplied by three.
Double Word Score - Light red cells are found running diagonally towards the four corners of the board. When a player plays a word on one of these squares, the point value of the entire word is multiplied by two.
Triple Word Score - This is a dark red square on the Scrabble board. These are found on the four sides of the board equidistant from the four corners of the board. When a word is played using this square, then the points for the word are multiplied by three.

For the sake of this challenge, the rule that a colored square be counted only once will be omitted. Count the bonus for every word on the board!
The board to be used is: http://upload.wikimedia.org/wikipedia/commons/thumb/c/c2/Blank_Scrabble_board_with_coordinates.svg/300px-Blank_Scrabble_board_with_coordinates.svg.png
WINNING
The winner will be the highest valid-scoring scrabble board as of December 1st. Please be sure to include your total score, and output. If the top scoring board is mis-scored, or is invalid, the next place will be considered. No input is required, output may be in any format that is properly readable. This is not Code-Golf, highest score wins.

inspired by http://codegolf.stackexchange.com/questions/5654/best-scoring-boggle-board?rq=1

It would probably be a good idea to specify the dictionary you want people to use to reduce the chance of people using invalid words, and also to make sure everyone has the same set of possible words to choose from.

@Matt I have nothing against declaring a dictionary, I just personally don't know which would be a good "best" for this case, and don't want to limit anybody

letter counts vary by language, as do the scores for each letter: https://en.wikipedia.org/wiki/Scrabble_letter_distributions (oh, and the number of tiles: 120 in a portugese set)

Is it required to have a tile on the centre square?

yes, there must be a tile on the center square (keep in mind the center square counts as a word2x!)

@SeanCheshire I added the exact counts to the description for which revision of rules to use (standard english)

I would assume we have to pick letters at random, else I could publish this board: http://home.teleport.com/~stevena/scrabble/faqtext.html#Theoretical

assume you have all 100 letters available to determine the best possible board with the final score - note that the board published there is not necessarily the correct answer, as that board assumes turn-order, rather than scoring entirely at the end, and also provides the 50 pt bonus, as well as single-use bonus squares.  Its possible its the same board, but his board only scores high because the order that the tiles are played allows many words and scores to be repeated alot :)

Do unplayed tiles count against the score or do they simply score 0?

Note: I've reverted the change which inlined an unattributed copy of the image as a copyright violation.

@PeterTaylor Sorry about that. Would having an inlined image with a link to the original be acceptable?

@Dukeling, it's probably best to use the original image rather than a copy (I don't think there's any Markdown restriction to only use imgur URLs) with a link to the Wikicommons page and the name of the creator.

@PeterTaylor Although using the original image would still be a problem if that link were to die.

Voting to close, without a set dictionary it is impossible to unambiguously validate a solution. On top of that it is really more a computation job than a programming puzzle, it awards using arbitrary amounts of CPU power just as much as it awards clever programming, and it is the output of the program rather than the program itself that constitute the answer.

I've been looking up what is a valid word in scrabble. Some websites list words with no definition. What is a legal word... see here http://boards.straightdope.com/sdmb/archive/index.php/t-97665.html

This is currently the oldest unanswered question on CGCC.


text:
Implement DES key expansion
I wanted to make a challenge to do the full DES encryption algorithm, but that may be a bit too involved to get a ton of participation. This challenge is to simply generate the 16 48-bit subkeys used to encrypt data:

The algorithm is described well enough on wikipedia, and all relevant shift tables and such data are on this page.
Your task is to write a program or function that accepts 64 bits of input, and outputs the 16 48-bit keys. I am not picky about input or output formats, but hex coded is fairly standard.
You can check your results against the examples on this page, or this page
Shortest code wins.

you're wanting the 16 48-bit keys generated before running through the S-Box phase? or do we need to implement those lookup tables too (and which tables should we use)?

sorry, i ignored your clearly labeled link to the table data

I just want the subkeys (the outputs on the left side of the diagram). Also labelled KS[1] to KS[16] when you run the first example link.

Random story: One of my most embarrassing programming stories from college (Computer Science) was with a DES implementation for a crypto class. As usual I procrastinated, and when I had trouble getting bit-shifting working correctly the night before it was due, I changed tack and wrote a fully-functional DES implementation using String variables/operations. Yes, I mean literally strings like, "01011100" - ASCII strings of "0" and "1".  Instructor never commented on it. As long as it ran, he was happy. I have been ashamed of this for 5 years now; never told anybody before today.

That's funny, but probably significantly easier to work with as strings than the bitwise arithmetic required to keep it all in binary.

@loneboat Redeem yourself! :D

The test cases have gone missing.

Perl - 384 314 chars
input is in decimal (from STDIN), output in binary. includes all necessary tables. feel free to improve anything
use Math'BaseConvert b10;
@_=sprintf("%064b",<>)=~/./g;
$s=b10 cG4xqQ8GMvUpZSqYtTAVVCZyBjrZs7FkNdowNTFBipcmG28UIKQKyfLYHWWjdq;
$s=~s/../$_[$&-1]/g;
map{
  $n=28-$_;
  $s=~s/(.{$_})(.{$n})(.{$_})(.+)/$2$1$4$3/;
  $_=b10"G._NqruyC5whI_KjAHzrS3ZgLTX7BzGp0.zML.AaubJCuwPtzPomq";
  s|..|($s=~/./g)[$&-1]|eg;
  say$_
}b10("3_AUuKOqD")=~/./g

Do those strings not benefit from a higher base (e.g. base64)?

yep, thanks @PeterTaylor. i had to find a library that would treat the the strings as large integers transparently

GolfScript (175 chars)
I assume input and output in MSB-first upper-case hex.
For want of good test cases, I don't guarantee that this implementation is correct. I've worked to a test case which I derived from Rivest's simple test for implementations of DES: given his test input of 9474B8E8C73BCA7D I think that the expected output is
BE23F4265E76
63FD57CA5952
6DEDC3C5E33C
73E5BBF11EC8
FD8593D8923F
778A9F177EAC
3FB0963839F1
3E0CFEA3E837
41FFD1A34BCB
55FDE796B313
F3E5C3F70764
79C7A758ABCA
F1919F74F41D
3582F76B34EA
B758B6ACF92B
44FF4B3F4D29

To that caveat I must add another, which is that I use a lot of base conversion including some of strings with non-printable characters. As usual, I'll give the program in a couple of ASCII-safe formats. xxd output:
0000000: 312f 7b31 302c 2727 2a37 312c 3635 3e2b  1/{10,''*71,65>+
0000010: 3a5e 5c3f 3136 2b32 7b62 6173 657d 3a42  :^\?16+2{base}:B
0000020: 7e28 3b7e 7d25 607b 3d7d 2b5b 3536 5b5b  ~(;~}%`{=}+[56[[
0000030: 2d38 5d32 342a 372f 2e2b 2739 3939 1b37  -8]24*7/.+'999.7
0000040: 3717 275d 7a69 705b 5d2a 5b5d 2a7b 3124  7.']zip[]*[]*{1$
0000050: 2b7d 2f5d 2534 3932 3831 2032 427b 2129  +}/]%49281 2B{!)
0000060: 7b32 382f 7b28 2b7d 257e 2b7d 2a27 1d3c  {28/{(+}%~+}*'.<
0000070: f9df 2a9b 7079 2030 dea2 83df 3bca a82f  ..*.py 0....;../
0000080: 50ec 11f8 e55c 74d2 f104 b2ae 130e ac5c  P....\t........\
0000090: d627 27ff 3827 7b42 7d2f 7b31 243d 7d25  .''.8'{B}/{1$=}%
00000a0: 342f 7b32 425e 3d7d 256e 2b5c 7d2f 3b    4/{2B^=}%n+\}/;

Base-64 encoded:
MS97MTAsJycqNzEsNjU+KzpeXD8xNisye2Jhc2V9OkJ+KDt+fSVgez19K1s1NltbLThdMjQqNy8u
Kyc5OTkbNzcXJ116aXBbXSpbXSp7MSQrfS9dJTQ5MjgxIDJCeyEpezI4L3soK30lfit9KicdPPnf
KptweSAw3qKD3zvKqC9Q7BH45Vx00vEEsq4TDqxc1icn/zgne0J9L3sxJD19JTQvezJCXj19JW4r
XH0vOw==

And with the magic strings substituted with a printable (but longer) version using escape characters and some unnecessary line-breaks:
1/{10,''*71,65>+:^\?16+2{base}:B~(;~}%`{=}+
[56[[-8]24*7/.+'999\e77\027']zip[]*[]*{1$+}/]
%49281 2B{!){28/{(+}%~+}*
'\035<\371\337*\233py 0\336\242\203\337;\312\250/P\354\021\370\345\\t\322\361\004\262\256\023\016\254\\\326'
'\3778'{B}/{1$=}%4/{2B^=}%n+\}/;

This is a pretty literal translation. The vaguely interesting bits are:

Permutation PC1 turns out to have a lot of structure. If you take first differences, all but 6 of them are -8. The second line of the reformatted version reconstructs it from these differences in 39 characters. For comparison, representing it by base conversion would require 44 characters for the string literal; and representing a generic permutation of numbers 1 to 63 requires 36 base-256 digits (i.e. a 38-character string literal plus code to convert it).
49281 2B{!) ... } encodes the shift lengths. This is the most obvious place to attempt further optimisation.
Permutation PC2 doesn't seem to have any usable structure, so that's a straight double base conversion. (Not to be confused with a double bass conversion).


text:
Play a sound, any sound
Your program has to make the computer produce a sound, any sound.
Shortest code wins, not sooner than 10 days after the first valid answer. If there is a tie, the one submitted sooner, wins.

The program should run on a reasonable, not too uncommon personal computer.
Opening a pop-up, message box, etc. (for example, on a web page) does not count, as they might or might not produce a sound, depending on a lot of settings.
Just entering a wrong command or invalid character on a console and receiving a warning beep does not count, just as the compiler/interpreter/OS beeping on an error or crash does not count either. Your code must be a valid program.

^G aka system bell or OS beep may be suppressed on many systems too (e.g. switched to be a visible "bell") and should be handled like sounds of popus and so on too: Not a valid solution.

Every program that prints "\a" to a terminal fails if xterm uses a visible bell.

rm / will cause a lot of screaming.

My left fan has been dying noisily for a while. Would that be a valid 0 bit answer?

I think this question should be reopened. The joke answers that rely on the fan spinning or the CD tray opening are invalid, since the question says "play a sound". Seems pretty clear to me that the output needs to come from the speakers as a result of the program, not the OS or the user or the hardware.

dc, 2 chars
this one prints the bell character, too:
7P

Run with $ dc <<< 7P or save 7P to file and run $ dc file.
Also:
Befunge, 2 chars
Similar but infinitly looping and beeping:
7,

Could you please elaborate what language that is? I never heard about it, and its name is too short (and a very common abbreviation) to be efficiently searched for.

From the man-page: dc  is  a  reverse-polish  desk calculator which supports unlimited precision arithmetic. -- it's included in most linux/unix distros as far as I know.

A few more examples if you're interested: 1, 2 and 3. Seen a few others use it here as well.

My bad for not elaborating what I mean under "language"

@vsz dc is – of course – turing complete, as any better calculator such as ghc should be.

Here no ^G produces a sound... ^G should not count as valid answer because it can be disabled like window-create and other OS sounds...

All sounds can be disabled. Just turn the volume down.

bash (13)
sudo rm -rf /

The faster the hard drive the better the sound. Don't work with SSDs.
(Don't try this at home, sudo rm -rf / erases everything on your hard drive)

I think that one should come with a disclaimer -- "Don't try this at home" :D

Yeah, that's the sound when your computer reads your mail really fast (rm -rf).

Wait, you got it wrong. The task is to make the computer produce a sound, not the user... though I have to admit that scream was quite impressive...

It doesn't do anything without --no-preserve-root, except maybe on ancient systems.

@nyuszika7h ancient as in before 2005.

The warning Don't try this at home.. is misleading - someone might try this e.g. in /tmp/ instead of ~/, which would be equally harmful (:

Don't try this at home so it's OK at work...

*sh (5)
eject

(does not work if you have no CD/DVD or similar drive..)

I like this one. But, on my Mac (Mac OS X), the command is not found : sh: eject: command not found

Nicolas: right, on Mac, the eject "command" seems to be much shorter: ⏏ (:

@ mykhal — If you go this way, I have a solution that works on all modern Macs :

This fails with OpenBSD. usage: eject [-t] device The device argument is not optional! The shortest that works here is eject cd0 for 9 characters. Also, if the drive has no tray (as with a slot-loading drive), then eject cd0 makes no noise unless a disc is in the drive.

kernigh: you're right. on the other hand, it might succeed on many systems without a sound card or speaker, where most of the other solutions would fail

Befunge, 0
If I read the spec correctly, this is an endless loop.
Endless loop = you'll hear your CPU cooler spin up.

sh 7
w|aplay

Plays a short noise.
Also 7:
aplay *

Assembly
Another non-bell solution. Resulting binary is just 15 bytes.
mov al, 182
out 43h, al
out 42h, al
mov al, 16
out 42h, al
mov al, 3
out 61h, al
ret

Assemble with nasm sound.asm -o sound.com. Can be tried with dosbox sound.com.

+1 for not just relying on a terminal to translate BEL characters to beeps.

brainfuck: 8
+++++++.

Prints the bell character.

+1 BF Solution both understandable AND shorter than C.

A brainfuck is easier to mentally digest than C... we should learn from this incident.

bash (Mac OS X) 5
say a

although stylistically I prefer the somewhat longer:
say 'Hello, Code Golf !'

If your Mac is set to English, you could also do say 'hahahahahahahahahahahahahahahahahahahahahahahahahaj'.

Oooh... I've got ssh access to an osx box...

This command works in AppleScript. I did not know it works in the Terminal too. Funny with ssh !

Corollary on Linux: espeak...

Haha, good ol' QBASIC code.
BEEP

Ah, the fun that could be had with the PLAY command! For reminiscence, see e.g. this video.

I'm 15, xD. We learned QBASIC in school.

Python 3.3.3, one character
<bell character>

The error message will contain a bell character, causing the sound.
Python 3.3.3, 10 characters
If errors are not allowed, this solution won't output the error message, only the sound.
print('<bell character>')

Why the downvote, this code actually produces a sound.

1 char O_o nice +1

Golfscript 3
'.'

(where the . is in fact a BELL character)
The HEX representation of the above code is:
27 07 27

Ouch, Golfscript strikes again!

Java - 222
Enough of this bell character or predefined beep function stuff, this makes a real sound :)
import javax.sound.sampled.*;class S{static{try{SourceDataLine
l=AudioSystem.getSourceDataLine(new
AudioFormat(4000,8,1,0<1,0>1));l.open();l.start();for(byte
i=9;i!=0;i+=9)l.write(new byte[]{i},0,1);}catch(Exception e){}}}

Java truly sucks for golf

@boothby not always, check this out

Okay, Java sucks for golf except when the challenge is to throw errors.  ;)

@boothby What about this? http://codegolf.stackexchange.com/a/28818/24965

@JopVernooij That's not golf, that's an underhanded popularity contest.

DOS Prompt / DOS Script
a:

Requires 3.5" floppy drive :)

What magic is this?

It causes DOS to try to read from the floppy, which does cause a sound. It is, however, wrong that this needs a 3.5" floppy drive; a 5.25" floppy drive works even better.

Aye. Wouldn't the 5.25" normally be b:?

Try a CD drive with a defective disk inside, works great too :)

The drive letter in DOS depended on which connectors of the cable the drive was attached to (and on newer machines, a BIOS setting). My first computer only had a 5.25" drive and I had to attach it as master (making it the A drive), since it couldn't boot from the slave.

J (2)
a.

This prints all the characters from 0 to 255, that includes the bell.
If I have to do it without printing anything else, it's 4 characters:
7{a.

Pascal: 30 characters
uses Crt;begin
Sound(999)
end.

This takes advantage of the lack of any rule regarding the sound's duration. So just turns on the speaker on 999 Hz and lets it so. (At least until another program calls Nosound or the computer is turned off.)

And the sound keeps screaming even after the program has quit ? I like this one ! :-)

@NicolasBarbulesco, exactly. That was the normal behaviour of all programs on DOS, including those written in C or assembly.

-2: Change to 9 Hz: Sound(9).

@EʀɪᴋᴛʜᴇGᴏʟғᴇʀ, would be hard to prove the sound is actually generated. Frequency Range of Human Hearing

@manatwork Well, add an identical code with another frequency that can be heard. Because the codes are identical, it can be proved. (the number only changes)

Mathematica 6
This will evoke the system beep.  On my computer, it is currently a chirp.
Beep[]

Bash, 22
Back in the 90's, my brother taught me this one -- to be used in a computer lab where one has remote access and knows a person to be alone in said lab.  Kids these days won't know what a computer lab is... but oh well.
cd /dev;cat sda1>audio

I get bash: audio: Permission denied even running under sudo. :(

This worked on Debian as of 2006.  I can't get it to work on my Ubuntu box :*(

I think you mean dsp, not audio.  See below for a similar example I wrote using /dev/random

or cat /dev/sda | aplay

@TheDoctor or aplay</dev/sda (UUOC ;-))

What is this supposed to do ?

cat /dev/sda1>audio

cat/type/PHP 1
This is actually polyglot. It runs in cat (or Microsoft Cat called type) and PHP.
$ xxd file
0000000: 07                                       .

Execution:
$ xxd -r > file
0000000: 07                                       .
^D
$ cat file # cat could be replaced with type (on Windows) or with php

What is the program ? How to run it ? This is not clear.

@NicolasBarbulesco: The program is one byte (\x07), however because it's binary, I cannot paste it here. You can run it in PHP CLI, with php.

It is not clear. But it works ! With cat. The trick is the ASCII char 7 “bell”.

That's not a serious attempt.

brainfuck, 5 bytes
+[.+]

prints all chars including bell

R 9
The bell character
cat("\a")

Ruby, 7
$><<?\a

Tested on Windows with Ruby 1.9.3.

DOS, 5
Indirect, requires user cooperation.
pause

Are you sure? I can not remember any beeping version of DOS pause. (At least not MSDOS and FreeDOS.)

Run the program.  Cooperate.  Listen.

Could you at least specify which DOS implementation's which version you used?

Looked up. Found no mention of pause making sound. Tried it. pause made no sound.

You have to press a key... which makes a sound. @mana He said it was indirect - pause didn't make the sound, YOU did.

@Riking, how that conforms with the “Your program has to make the computer produce a sound” part of the requirement?

I do not understand programmers on puzzle sites who cannot think outside of the box.

Well, "playing a sound" cannot be considered as a "puzzle", anyway. Just move on. Nobody can feel "puzzled" by that.

@JoanLeaven Who said this was a puzzle?  I said this was a puzzle site -- do you read (I like reading)?  Well, except for manatwork, who was obviously puzzled by my far-too-subtle joke.  And anyway, you move on!  This is my solution, I'll comment as often as I please!

I wasn't criticizing your answer. I was criticizing the question. A pointless question will obviously get pointless answers. Your answer then make as much sense as any other answer to that stupid question. So, i'm giving you +1.

PowerShell, 24 17
Since nobody has posted this version yet:
[console]::beep()

UPDATE: Removed frequencies so it uses the default frequency and duration (MSDN says the default is 800 hertz and 200 milliseconds)

Surely you could at least use smaller numbers

Python 9 chars

produces beep sound when executed.
print'\a'

You can shorten this to 8 characters if you replace \a with the actual bell character (ASCII code 7).

But how to print with the help of the value 7 ?

You can type the bell character into your editor with Alt+07. Alternatively, you can run this snippet to create a python file with the 8-character solution: open("play_a_sound.py", 'w').write("print'"+chr(7)+"'")

Applescript (4 Characters)
beep

This will play the default beep sound of OS X.

top & aplay - 9
top has rhythm!
top|aplay

The periodic display sometimes does not feed the sound sink fast enough but aplay continues after grouching a bit... :-)
...this will run on many Linuxes...
Bonus:
While running this, type "s 1 ENTER" to get more beats per second. :-)
Party on!!!  \o/

This is pure genius... :D

Mathematica 7
Using Mathematica's built in text to speech capability.
Speak@x

Will make it say "x"

C: 19
main(){puts("\a");}

edit: header file is not needed for "puts"

You can remove the space between #include and < :)

puts(char*);main(){puts("\a");} is smaller IMHO.

You can just remove the #include.

@FUZxxl How can you have an opinion about code size?

@DoorknobofSnow Because of the first amendment?

The First Amendment of what country, again? Oh wait, this is the Internet and not a specific country.

><> 3
As in all answers, prints the bell (0x07) to stdout.
7o;

Tcl, 1 char
-

replace - with the bell char.
It will print the bell char as part of the error message. Twice.
And if you think this is not a valid program, add this before the bell char:
proc \007 {} {};

It is a valid program, I just did not define the command, because I like the error message.

Is that based on some Tcl 8.6 feature? In Tcl 8.5 I got different result: http://pastebin.com/bh73UF6F Or are you on Windows?

No. The 2nd part should show that this is a valid Tcl file. And it should beep 2x (the error message contains the command to be executed twice). Calling a command that does not exist is not an error for Tcl, it is only one if it can not find it. (e.g. parray, which is loaded on the first use)

Oops. I misunderstood you. I thought you mean, it should beep with the proc declaration too. (Regarding the beep count, probably my terminal is doing something as puts [string repeat ".\a" 10] displays 10 dots but beeps only once.)

Ruby 8
 puts"\a"

Tested on Windows with Ruby 1.9.3.

Bash, 26
Standard unix (not modern linux, sadly, unless you have alsa-oss installed; the BSDs are fine):
cat /dev/random > /dev/dsp

You can save 2 bytes by removing the whitespace around >.

Scala: 44
java.awt.Toolkit.getDefaultToolkit().beep();

same as @nrubin29's answer, but shorter

GolfScript (3)
Since everyone else is doing this anyway:
'^G'

where ^G is the bell character.
Hex dump:
0000000: 2707 27                                  '.'

Now what is it, '^G' or "^G"?

It doesn't matter, but I'll fix the inconsistency.

This is a duplicate of this answer.

Linux shell (6 characters)
This requires a correctly configured analog modem (you also might need to run it as root):
wvdial

sh 6
echo .

(where the . is in fact a BELL character)
The HEX representation of the above code is:
65 63 68 6f 20 07

Autoit 6
Beep()

Although declaring a function would allow for less characters, not counting the declaration:
z()
Func z()
Beep()
EndFunc

That way that you made the program longer?  It didn't make it shorter.

Writing own functions count toward the the length. otherwise everything would be a how can I call the method with less chars and some languages allow that with 1 char.

ATARI BASIC (4 chars)
?"E"

(? is short for "print".  E is in fact the "escape" symbol; see http://raster.infos.cz/atari/chars/atascii.htm, item 1B.  Printing this symbol would make a characteristic noise.)

PowerShell, 3
'^G'

Of course, the ^G has to be entered manually, or written to a file with another script, like the following:
"'$([char]7)'"|Set-Content beep.ps1

VBScript
CreateObject("SAPI.SpVoice").speak "a"

Nice thing about this is you can make it say anything you want.

Windows Command Promt
logoff

Indeed, this makes an OS sound but it is not OS beeping on an error or crash.

Which version of DOS has a logoff command?

@celtschk I don't know why did I wrote that:D

Matlab UNTESTED (1)
␇

I am not sure whether this works in matlab, as I don't have sound available, but ␇ is in fact a single character. Hence calling or printing it may produce the desired effect in some languages.
Matlab verified (4)
beep

Calling the character actually does some strange things. See this question if you are interested.

Windows batch script, 14
sort %comspec%

%comspec% just points to C:\Windows\System32\cmd.exe, and calling sort will find the bell character at some point in cmd's binary.

Doesn't seem to work on Windows 8.1 64-bit.

 Batch, 16
type sethc.exe

I discovered this. When I do this, I'll get the 'BEEP' sound from reading the < BELL > character.

JavaScript - 99 103
Audio
  ("data:audio;base64,UklGRgWsAABXQVZFZm10IBAAAAABAAEARKwAAESsAAABAAgAZGF0YeGrAACAbebe")
.play();

*chirp* (in firefox, it is definitely a chirp)

This code throws the following error: TypeError: Failed to construct 'Audio': Please use the 'new' operator, this DOM object constructor cannot be called as a function.

firefox doesn't need that operator. however if i wanted to be pedantic (crossbrowser) i would definitely use 'new' (+4 characters)

I'm getting the error TypeError: Constructor Audio requires 'new' in Firefox Aurora 32. So yeah, it does.

oh dear.. "Omit the new keyword when possible"
I had Firefox 29 now 30, it works like charm.
(it's funny you try to prove your point with an alpha release)

Java: 103
public class S {
    public static void main(String[] a) {
        java.awt.Toolkit.getDefaultToolkit().beep();
    }
}

Will fail to compile without class wrapper and import.

I didn't realize we needed everything. I'll add it.

JS, 117
new Audio('data:audio/wav;base64,UklGRl9vT19XQVZFZm10IBAAAAABAAEAQB8AAEAfAAABAAgAZGF0YU'+Array(1e3).join(123)).play()

You can save 4 bytes by using audio instead of audio/wav, and 1 byte by using join(10) instead of join(123).

Even Array(10).join(1) appears to play a sound, but Array(99).join(9) is more audible.

QBASIC (8)
PLAY "A"

Body must be at least 30 characters; you entered 19.

ಠ_ಠ

Powershell, 4
"`a"

Sends a beep signal to the computer's speaker.

OS X Command Line

say a

This causes the computer to say the letter 'A'

I do not think say is a bash command.

sorry, yeti. I was under the impression that OS X command line was Bash. Thank you for the correction

It may be BASH where you type say a but that does not make say a BASH command. So I meant something like "say is not part of the BASH language". Maybe that was trying to be too exact... it may have caused more confusion than needed...

Visual Basic 6
beep

VB 6, good times.

C 23
Make a beep sound.
int main(){putchar(7);}

This should still compile without the int  at the beginning

Debianish solution, works on some other systems too - 9 chars
aplay /i*

...will play the files /initrd.img and initrd.img.old which are symlinks to some system startup ramdisks in directory /boot.
If you prefer the sound of kernels, try...
aplay /v*

...and look yourself why it works or fails on your system.
I got...
$ LANG=C ls -l / | grep ^[^d]
total 88
lrwxrwxrwx   1 root root    36 Dec 15  2012 initrd.img -> /boot/initrd.img-3.2.0-0.bpo.4-amd64
lrwxrwxrwx   1 root root    30 Dec  9  2012 initrd.img.old -> boot/initrd.img-2.6.32-5-amd64
lrwxrwxrwx   1 root root     4 Dec  9  2012 lib64 -> /lib
lrwxrwxrwx   1 root root    32 Dec 15  2012 vmlinuz -> boot/vmlinuz-3.2.0-0.bpo.4-amd64
lrwxrwxrwx   1 root root    27 Dec  9  2012 vmlinuz.old -> boot/vmlinuz-2.6.32-5-amd64

...here and that may or may not explain a lot to you and I demand the absence of solid facts and that I may or may not be called vroomfondel!

you are saying that your solution needs neccessary data - that may not even exist - from outside the code. i think it needs reasons to prove it's valid.

Oh... I didnt see my harddisk as "outside"! :-D               ll think about a different solution for some minutes...

Ok... let's narrow it down: Debian is a common system and has these links... they can be disabled by editing some config file in /etc/ but their existence can be widely assumed because most users don't touch/change the defaults...

"The program should run on a reasonable, not too uncommon personal computer." was the wording I was looking for. And I think Debian not being configured to be far far away from the installation defaults on contemporary hardware does not describe an uncommon personal computer.

PHP (CLI): 1 byte

Source code as seen in Notepad++:

In the absence of <?php opening tag, source code is simply dumped to output.
Yeah, I know, another BEL answer, but still, tough to beat a single byte, especially in an interpreted language like PHP ;)

Python3 34
Any of the python versions printing the bell character to stdout was working for me, so here it is one using the standard libarary, in Windows:
import winsound as w;w.Beep(99,99)

The semicolon could be replaced with a newline, but looks cooler this way :)

You can save a character by using from winsound import*;Beep(99,99).

k/Q (6 chars)
Bell character to stdout.
1"c"$7

Windows Command Script - 1 Byte
As most of the answers, this also uses the bell character.
0x07

Note: Must be run from console to work, since the sound needs some time to trigger.

Spoon, 13
1111111001010

Similarly to the BF solution, it prints the bell character.

Fortran 95, 18 chars
print*,char(7);end

Produces a bell sound

C++  45
#include<iostream>
int main(){std::cout<<'\a';}

ZX Spectrum BASIC (3)
SAVE STR$ PI

It is only 3 bytes because BASIC keywords (with surrounding spaces) occupy single byte in ZX spectrum's memory. Here's its hex representation:
F8 C1 A7

This program saves current program to audio tape under the name "3.1415927" which is the string representation of π.
In fact it require 7 keypresses: S Caps+Symbol Y Caps+Symbol M

R, 7
alert()

but sadly I think this is just a wrapper for printing the bell character.

In AppleScript ; 4 characters
beep

[ This is so short that my answer firstly did not reach the minimum length to be posted ! ]

C#
System.Media.SystemSounds.Beep.Play();

It's long, but anyway...

Ruby, 8 chars
puts ?\a

><>, 2-3 chars
7o;

or with infinite loop:
7o

Autohotkey
I found my answer in the Documentation on the Autohotkey Docs.
SoundBeep

C#, 72 bytes
class Program{public void main(string[]args){System.Console.Beep(500);}}

C on linux
#include <fcntl.h>
#include <linux/cdrom.h>
#include <sys/ioctl.h>

int main() {
  ioctl(open("/dev/sdb", O_RDONLY), CDROMEJECT);
}

Opens the CD-ROM door.
You may need to change sdb to whatever your optical drive's device is.


text:
Scale from key and mode
Most of you probably know the C major scale:
C D E F G A B C

The major scale is characterised by the intervals between adjacent notes, which measured in semitones are:
2 2 1 2 2 2 1

From these intervales, we can construct any major scale starting in any note (the key of the scale). The 12 notes in our 12-tone equal temperament tuning system are:
C C♯ D D♯ E F F♯ G G♯ A A♯ B

equivalently (substituting some enharmonic equivalents):
C D♭ D E♭ E F G♭ G Ab A B♭ B

with a semitone between each pair of adjacent notes.
Each scale has to have the seven notes in order, starting from the key. Otherwise, you could have two notes in the same line of the pentagram, which would be confusing. So, in G# major/ionian, you have F## instead of G; musicians will just look at where in the pentagram is the note, they already have learned the accidentals for each scale. Indeed, in G# major, F## is represented in the line of F## without accidentals, the accidentals are in the key signature - but since that key signature would require 2 sharps for F, usually this is notated as Ab major.
Shifting the 2 2 1 2 2 2 1 intervals, we arrive at seven different modes of the diatonic scale:

Ionian: 2 2 1 2 2 2 1 - corresponds to the major scale
Dorian: 2 1 2 2 2 1 2
Phrygian: 1 2 2 2 1 2 2
Lydian: 2 2 2 1 2 2 1
Mixolydian: 2 2 1 2 2 1 2
Aeolian: 2 1 2 2 1 2 2 - corresponds to the natural minor scale, and to the melodic minor scale when descending (when ascending, the melodic minor scale has raised 6th and 7th degrees. There is also a harmonic minor scale, with a raised 7th degree compared to the natural minor).
Locrian: 1 2 2 1 2 2 2

So, the challenge is to write a program that takes as input (via stdin) a key and a mode and outputs (via stdout) the corresponding scale. Some test cases (stdin(key mode) => stdout(scale)):
Input:              Output:
C mixolydian   =>   C D E F G A Bb
F mixolydian   =>   F G A Bb C D Eb
G mixolydian   =>   G A B C D E F
G# ionian      =>   G# A# B# C# D# E# F##
Bb aeolian     =>   Bb C Db Eb F Gb Ab

Further references:
How many (major and minor) keys are there? Why?

The examples feature notation which isn't described above - flats and double-sharps. Is it acceptable to output equivalents using only the base notes and simple majors? (For what it's worth, my preference would be that you say "No" and expand the specification a bit - looks like this question could have quite a bit of hidden depth).

@PeterTaylor: Right. I hope the edit is enough. I expect output to be as shown, with the seven note names and their corresponding accidentals. This is a relatively large program.

GolfScript, 96 characters
" "/~5<{+}*7%"v]nwm[{"=2*2base(;\(" #"@?]{.1>))["b""""#"..+]=+\[~@(@+@(7%65+\1$7%4%0>-]}7*;]" "*

Golfscript solution which can be tested online.
Note: As in the examples the key has to be upper case while mode has to be given in lower case.
Examples:
>C lydian
C D E F# G A B

>C mixolydian
C D E F G A Bb


text:
Generate Esolangs
Given a file named hello_world that contains 2-100 bytes of printable ASCII, create a Turing-complete language in which hello_world is a valid program that prints "Hello World!".  The output should be two files: a compiler or interpreter, and a text file with the language spec.
Rules

Shortest code wins.  Length of (any of the) output doesn't matter.
The generated compiler/interpreter must tokenize hello_world into at least two tokens, neither of which are ignored, and can't care about the filename.
Your program can't use external resources (no cloning its own compiler).
The generated code can be in any language, and can compile to any language.

I doubt if you'll get anything interesting. It's just too hard. Most likely, any solution will just be a way to cheat your rules (e.g. "Compile" the first character to print "Hello, world", the second to a comment delimiter, map all else to BrainF**k).

That's basically what I'm picturing--although I'd consider treating something as a comment delimiter to be ignoring it.  It's still non-trivial because you have to avoid collisions between the arbitrary input file and your BrainF**k syntax. And of course writing the shortest possible program that outputs an interpreter isn't, as far as a I know, a solved problem even without the additional constraints.

Given that hello_world can be 2 bytes, any solution pretty much has to bake "Hello World!" into the language definition (or be unnecessarily long to choose not to in the greater-than-that case). How about requiring that the input has at least 13 (string length + 1) distinct characters? (I think this is an interesting problem regardless of whether that change is made.)

Also, this definition encourages the language spec to be written gratuitously tersely. How about allowing the spec to be derived from a separate template file whose length is not counted? To avoid gimmicks, the requirement would be that no information in the template file is used in the generation of the interpreter/compiler.

I'm not saying the challenge is trivial. I'm saying it's too hard. You'll get an answer only IF someone finds a trick, that follows your rules to the letter, but makes it uninteresting.

ok, then tell me how you can create a valid programm with the input aaaaaaaaaa? The only solution is to define the first occurence of a as "Print Hello World!" and a 2nd a as comment. (ok, maybe you can define aa as the print and aaaa as comment, but anyway, this is not a turing complete language. You can add unused cmds, but is that the point of the challenge?

Is it OK for the language spec and the compiler/interpreter to be the same file (e.g. with the spec included as a comment at the beginning of the interpreter code)?

Let's give it a try (and let everyone else copy it)
Tcl
set f [open hello_world rb]
set h [split [read $f] {}]
for {set i 0} {$i<256} {incr i} {if {[set c [format %c $i]] ni $h} break}
set f [open i w]
puts $f [string map [list @1 [lindex $h 0] @2 [lindex $h 1] @3 $c] {set s 0;set i 0
set f [open [lindex $argv0] rb]
set c [split [read $f] {}]
foreach d $c {incr i
if {$d eq @1 && $s==0} {puts -nonewline "Hello ";incr s}
if {$d eq @2 && $s==1} {puts "World!"}
if {$d eq @3} {eval [join [lrange $c $i end] {}];break}}}]
puts [open d wb] [string map [list @1 [list [lindex $h 0]] @2 [list [lindex $h 1]] @3 [list $c]] {At the beginning the state is 0. Commands:
@1: If the state is 0, prints "Hello " without newline, increment the state.
@2: If the state is 1, prints "World!" with newline, flushes stdout and increases the state.
@3: Treats the rest of the file as Tcl.}]

Your use of eval is forbidden by the rule "Your program can't use external resources (no cloning its own compiler)." (Make no mistake; this is not an easy challenge.)

I don't clone the compiler, nor do I use external resources. About (ab)using the interpreter... well, I may do that.

Perl, 271 chars
@e=qw'die"Hello\x20World!\n" $i-- $i++ $a[$i]-- $a[$i]++ push@s,$p $a[$i]?$p=$s[-1]:pop@s print+chr$a[$i] $a[$i]=ord<>';
$/=\1;@k=(<>..Z,A..Z);
say"# $k[$_]: $e[$_]"for 0..8;say;
say"\$e{\"\Q$k[$_]\E\"}=sub{$e[$_]};"for 0..8;
say'$/=\1;@c=<>;&{$e{$c[$p++]}||sub{}}while$p<@c'

(The code above has some non-essential line breaks inserted for readability.  All line breaks may be removed without affecting the behavior, and should not be counted for scoring purposes.)
Run with perl -M5.010 to enable the say feature.  Reads the input program from standard input (or from a file given as a command line argument), prints an interpreter to standard output.  The output is also a Perl script, and should be executed the same way.
The (rudimentary) language spec is included as comments at the beginning of the interpreter, and is formatted as a list of characters and the Perl commands each of them will execute.  In the spec, $p stands for the program counter (which points to the next instruction to execute), @s for the loop stack, $i for the tape index and @a for the tape.

Basically, the language executed by the interpreter is exactly what ugoren suggested in the comments: a simple variant of Brainf*ck, with an extra command that prints Hello World! and ends the program.  This extra command is mapped to the first character of the input program, while the other commands are mapped to subsequent letters.  All unrecognized characters are ignored.
For example, using the input AAAAAA, the output will look like this:
# A: die"Hello\x20World!\n"
# B: $i--
# C: $i++
# D: $a[$i]--
# E: $a[$i]++
# F: push@s,$p
# G: $a[$i]?$p=$s[-1]:pop@s
# H: print+chr$a[$i]
# I: $a[$i]=ord<>

$e{"A"}=sub{die"Hello\x20World!\n"};
$e{"B"}=sub{$i--};
$e{"C"}=sub{$i++};
$e{"D"}=sub{$a[$i]--};
$e{"E"}=sub{$a[$i]++};
$e{"F"}=sub{push@s,$p};
$e{"G"}=sub{$a[$i]?$p=$s[-1]:pop@s};
$e{"H"}=sub{print+chr$a[$i]};
$e{"I"}=sub{$a[$i]=ord<>};
$/=\1;@c=<>;&{$e{$c[$p++]}||sub{}}while$p<@c

Running the resulting code above with the same input produces the expected output:
Hello World!

whereas running the same code with the input EEEEEEFDCEEEEBGCFDCECEEEEBBGCEEFDCEHBG (transliterated from this answer) prints:
abcdefghijklmnopqrstuvwxyz

Ps. To convert normal Brainf*ck code to the variant understood by this interpreter, you can use the transliteration:
tr/<>\-+[].,/B-I/

where B-I should be replaced by the appropriate range of command letters as per the generated spec.
Notes on the BF implementation:

The tape is single-ended, with the read/write head starting at cell 0. Moving the head to a negative position might not cause an error, but will produce weird effects related to Perl's array indexing and should be considered undefined behavior.
Cell values do not wrap around.  Technically, each cell is stored as a double, meaning that at some point the value will saturate and further inc/decrements will have no effect.  You'll die of boredom before that happens, though.
Character I/O depends on Perl's I/O layers. By default, input values are unsigned bytes, and attempting to output values outside the range 0 – 255 gives a warning message.  Passing the -CS switch to Perl will enable Unicode I/O (encoded as UTF-8), though.  Input at EOF yields a zero.  To supply both a program and its input on stdin, separate them with a Ctrl+D character ("\cD" or "\x05").

Edit: I later realized that there's a major difference between the language I implement above and real Brainf*ck: in my language, the loop condition is checked at the end of the loop, rather than at the beginning, which means that every loop executes at least once.  In effect, loops in my language behave like do–while loops in C-ish languages, whereas those in normal BF behave like plain while loops.
As it happens, the difference doesn't matter for the example program above, since all its loops run at least once anyway.  What I'm not quite sure about is whether the proof of BF's Turing-completeness can still be made to apply to my variant of the language or not.  It might be possible, but it's going to be tricky without any easy way to implement an if statement.
I suppose I could fix my program to behave more like normal BF, but it would be a pain in the ass to do without a major redesign of the execution model. :(