text:
Computer Generated Olympic Theme Song
Try to regenerate the olympic theme song, "Bugler's Dream" using the programming language of your choice. The language/platform used must be able to emit the physical sound. Only playing the main melody (trumpets) is required, but doing more would be great.
You must generate all the tones yourself - you cannot play back a midi/wav or any other sound file.
Here are the sound files for reference:
http://www.jonfullmer.com/music-of-the-month/buglers_dream/buglers_dream.mp4
http://www.armory.com/~keeper/1/bugdream.mid
Good luck!

Try? C: "" 0 characters, I win.  Do, or do not, but don't bother otherwise.

@NickT you better use perl/python/bash/something else. "" does not compile in C.

Twinkle Twinkle Little Star was a simple song, and the question gave the exact notes you had to produce, making it objective. This does not, and any attempt to simplify the (rather complex) music is going to sound horrible. To make it objective, I think either the exact notes should be defined in the question, or it should be changed to popularity contest. But if it is a popularity contest, I guess answerers will have to post a link to their output (as far as I know you can only attach picture files here, correct me If I`m wrong.) So complex, it could be more about data compression than music!

I would be fine changing this to a popularity contest, I just thought with the olympics, it would be cool if there was a code-golf that played the olympic song. Maybe even cooler if the code was arranged creatively, such as to create the olympic rings in ASCII or something like that. Can popularity contest still be graded on how short the source code is?

@mniip it does compile (with warnings); an empty file won the IOCCC one year for shortest quine.

@NickT In function `_start': (.text+0x20): undefined reference to `main'

@mniip http://www.ioccc.org/years-spoiler.html#1994_smr

@NickT Now if you actually take a look at the Makefile rule for smr, it does not use the C compiler

Mathematica 2576
Code
Sound[{{d, {0., 1.2}}, {a, {0., 1.2}}, {e, {0., 1.2}}, {f, {1.2, 2.2}}, {e, {1.2, 2.2}}, {e, {2.2, 2.4}}, {f, {2.2, 2.4}}, {a, {2.4, 3.}}, {c, {2.4, 3.}}, {b, {3., 3.6}}, {e, {3., 3.6}}, {d, {3.6, 4.2}}, {a, {3.6, 4.2}}, {e, {3.6, 4.2}}, {a, {4.2, 4.8}}, {c, {4.2, 4.8}}, {b, {4.8, 5.4}}, {e, {4.8, 5.4}}, {b, {5.4, 5.8}}, {e, {5.4, 5.8}}, {b, {5.8, 6.}}, {e, {5.8, 6.}}, {b, {6., 6.6}}, {e, {6., 6.6}}, {d, {6.6, 6.9}}, {a, {6.6, 6.9}}, {b, {6.9, 7.2}}, {e, {6.9, 7.2}}, {c, {7.2, 7.5}}, {a, {7.2, 7.5}}, {a, {7.5, 7.6}}, {c, {7.5, 7.6}}, {b, {7.6, 7.8}}, {e, {7.6, 7.8}}, {d, {7.8, 8.1}}, {a, {7.8, 8.1}}, {a, {8.1, 8.4}}, {c, {8.1, 8.4}}, {b, {8.4, 9.6}}, {e, {8.4, 9.6}}, {d, {9.6, 10.8}}, {a, {9.6, 10.8}}, {e, {9.6, 10.8}}, {f, {10.8, 11.8}}, {e, {10.8, 11.8}}, {e, {11.8, 12.}}, {f, {11.8, 12.}}, {a, {12., 12.6}}, {c, {12., 12.6}}, {b, {12.6, 13.2}}, {e, {12.6, 13.2}}, {d, {13.2, 13.8}}, {a, {13.2, 13.8}}, {e, {13.2, 13.8}}, {a, {13.8, 14.4}}, {c, {13.8, 14.4}}, {b, {14.4, 15.}}, {e, {14.4, 15.}}, {b, {15., 15.4}}, {e, {15., 15.4}}, {b, {15.4, 15.6}}, {e, {15.4, 15.6}}, {b, {15.6, 16.2}}, {e, {15.6, 16.2}}, {d, {16.2, 16.5}}, {a, {16.2, 16.5}}, {b, {16.5, 16.8}}, {e, {16.5, 16.8}}, {c, {16.8, 17.1}}, {a, {16.8, 17.1}}, {a, {17.1, 17.2}}, {c, {17.1, 17.2}}, {b, {17.2, 17.4}}, {e, {17.2, 17.4}}, {d, {17.4, 17.7}}, {a, {17.4, 17.7}}, {a, {17.7, 18.}}, {c, {17.7, 18.}}, {e, {18., 19.2}}, {a, {18., 19.2}}, {c, {18., 19.2}}, {d, {19.2, 20.4}}, {a, {19.2, 20.4}}, {e, {19.2, 20.4}}, {f, {20.4, 21.4}}, {e, {20.4, 21.4}}, {e, {21.4, 21.6}}, {f, {21.4, 21.6}}, {a, {21.6, 22.2}}, {c, {21.6, 22.2}}, {b, {22.2, 22.8}}, {e, {22.2, 22.8}}, {d, {22.8, 23.4}}, {a, {22.8, 23.4}}, {e, {22.8, 23.4}}, {a, {23.4, 24.}}, {c, {23.4, 24.}}, {b, {24., 24.6}}, {e, {24., 24.6}}, {b, {24.6, 25.1}}, {e, {24.6, 25.1}}, {b, {25.1, 25.2}}, {e, {25.1, 25.2}}, {b, {25.2, 25.8}}, {e, {25.2, 25.8}}, {d, {25.8, 26.1}}, {a, {25.8, 26.1}}, {b, {26.1, 26.4}}, {e, {26.1, 26.4}}, {c, {26.4, 26.7}}, {a, {26.4, 26.7}}, {a, {26.7, 26.9}}, {c, {26.7, 26.9}}, {b, {26.9, 27.}}, {e, {26.9, 27.}}, {d, {27., 27.3}}, {a, {27., 27.3}}, {a, {27.3, 27.6}}, {c, {27.3, 27.6}}, {b, {27.6, 28.8}}, {e, {27.6, 28.8}}, {d, {28.8, 30.}}, {a, {28.8, 30.}}, {e, {28.8, 30.}}, {f, {30., 31.}}, {e, {30., 31.}}, {e, {31., 31.2}}, {f, {31., 31.2}}, {a, {31.2, 31.8}}, {c, {31.2, 31.8}}, {b, {31.8, 32.4}}, {e, {31.8, 32.4}}, {d, {32.4, 33.}}, {a, {32.4, 33.}}, {e, {32.4, 33.}}, {a, {33., 33.6}}, {c, {33., 33.6}}, {b, {33.6, 34.2}}, {e, {33.6, 34.2}}, {b, {34.2, 34.7}}, {e, {34.2, 34.7}}, {b, {34.7, 34.8}}, {e, {34.7, 34.8}}, {b, {34.8, 35.4}}, {e, {34.8, 35.4}}, {d, {35.4, 35.7}}, {a, {35.4, 35.7}}, {b, {35.7, 36.}}, {e, {35.7, 36.}}, {c, {36., 36.3}}, {a, {36., 36.3}}, {a, {36.3, 36.4}}, {c, {36.3, 36.4}},{b, {36.4, 36.6}}, {e, {36.4, 36.6}}, {d, {36.6, 36.9}}, {a, {36.6, 36.9}}, {a, {36.9, 37.2}}, {c, {36.9, 37.2}}, {e, {37.2, 38.4}}, {a, {37.2, 38.4}}, {c, {37.2, 38.4}}}
/. {n_, t_} :> SoundNote[n, Round[t, .1], "Trumpet", SoundVolume -> 0.7]]
/. {a -> "C#5", b -> "D#5", c -> "F4", d -> "F5", e -> "G#4", f -> "G#5"}

Output
Bugler's Dream, Trumpet track.

Saving to file
Export["bugler.mid", bugler]

bugler.mid


text:
Shortest way to generate UUID's version 3,4 and 5 in php
I have this function to generate UUID's:
function uuid($v=4,$d=null,$s=false)//$v-> version|$data-> data for version 3 and 5|$s-> add salt and pepper
{
    switch($v.($x=''))
    {
        case 3:
            $x=md5($d.($s?md5(microtime(true).uniqid($d,true)):''));break;
        case 4:default:
            $v=4;for($i=0;$i<=30;++$i)$x.=substr('1234567890abcdef',mt_rand(0,15),1);break;
        case 5:
            $x=sha1($d.($s?sha1(microtime(true).uniqid($d,true)):''));break;
    }
    return preg_replace('@^(.{8})(.{4})(.{3})(.{3})(.{12}).*@','$1-$2-'.$v.'$3-'.substr('89ab',rand(0,3),1).'$4-$5',$x);
}

This is far from being short!
The idea is to reduce this at maximum!
Criteria to meet:

It MUST have the format xxxxxxxx-xxxx-vxxx-yxxx-xxxxxxxxxxxx, being x a hexadecimal number, y MUST be 89AB and v has to be the version! (required)
Only vcan be generated randomly for all versions (non-standard, optional)
Version 3 and 5 have to generate ALWAYS the same UUID (except for the rule above, required)
You must provide a method of making the UUID somewhat random (required, except for version 4)
Version 3 uses md5 to "pack" the data, while version 5 uses sha1 (leaving a few chars behind, required)
Function name MUST be uuid (required)

Scoring:

Lower number of chars wins
The score is calculated using (number chars)*0.75
Readable code is calculated using (number chars)*0.50
If one of the required criteria from above isn't met, the multiplier is increased by 0.5 for each criteria, except for the last which is 1.25 (maximum will be (number chars)*4.00, which means that 1 char is counting as 4)
Comments don't count but anything else between function uuid(...){ and } counts!

For example:
My function would have a crappy result:
It has 451 chars on linux.
Since it is somewhat hard to read, it is *0.75.
Since I fulfilled all the criteria, it stays *0.75.
Result: 451*0.75 = 338,25!

Your code doesn't seem to meet your own specification; for $v of 3 and 5, the y half-byte is chosen at random. Also, the criteria are somewhat hard to understand as written. For example, do you mean that versions 3 and 5 must always return the same UUID, given the same data, or do you mean that they actually always return the same value (fairly useless)?

If I run uuid(3,'this') 4 times, depending on the implementation you choose, you must have the same UUID, except the only char that can be random.

So this is a specification that you've invented? According the OSF UUID specification, a version 3 UUID must always return the same value for any given data.

I know, but I'm letting that one be a little "loose". And it is well identified as being optional and NOT standard. All i want is a UUID generator for all those 3 versions. That one was my example. It works, but it's quite a chunk of frankencode. The idea is to keep it standard. All non-standard "features" are optional, except the "random" part, that can be a simple salt given by the function.

PHP - 189 × 0.75 = 141.75
function uuid($v,$d,$s=''){
  $u=hash($v^3?sha1:md5,$v^4?$d.$s:gmp_strval(gmp_random(4)));
  $u[12]=$v;$u[16]=dechex(+"0x$u[16]"&3|8);
  return substr(preg_replace('/^.{8}|.{4}/','\0-',$u,4),0,36);
}

This implementation should be fully compliant with RFC 4122. If $s is provided, it is expected to be the byte string represention of the UUID for the applicable namespace. Otherwise, the default ("NULL") namespace is used.
gmp_random(4) is used to generate the 128 bits of entropy, which is just about the best PHP has. If the gmp module isn't available, you could also use this:
openssl_random_pseudo_bytes(16)) (requires openssl module to be enabled)
or, as a last resort:
for(;$i++<4)$r.=mt_rand();
Sample usage:
echo uuid(3,'MyCoolNewApp');

Sample output:
c478211b-224d-30b1-9116-c06048999ce2

I only see one problem with your function: The version 4 MUST be random. Other than that, it's a really nice implementation. I'm actually pleased with the result. Let's just wait a little longer to see more answers.

But that is not a completely random string. microtime() and getmypid() aren't good ways of making random values. There is a risk that running that function twice at the exact time with the same pid will generate the same UUID, and that is not so random. But still, it's a good one. I wouldn't do better.

I don't want true entropy (and i didn't even mention that anywhere). I'm just saying it is not a good way. That is just my opinion.

@IsmaelMiguel fixed.

Your code won't work everywhere. It relies on the GMP extension. And using openssl_random_pseudo_bytes(16) on windows is a bad idea... It simply times-out your script. a small idea would be use md5(mt_rand(0,1e9)). It's always random, between 0 and 1,000,000,000.

mt_rand(0,1e9) only provides ~30 bits of entropy. But, as mentioned, the concatenation of 4 or 5 mt_rand values could be used, if no other method is available. If openssl hangs on your machine, there's something wrong with the installation.

openssl_random_pseudo_bytes(16) doesn't work on windows. not on mine, not on any windows! It's a known issue.

@IsmaelMiguel Is that so? http://i.stack.imgur.com/h9BDl.png

Well, I change my comment from "any" to "some of".

@IsmaelMiguel from PHP 5 Changelog, update 5.3.4 dated Dec. 9th, 2010: "Fixed possible blocking behavior in openssl_random_pseudo_bytes on Windows."

Not everyone has updated to php 3.3.4. Most likely, most of IIS servers are running php 5.3 or 5.4.

Firstly, the code has a syntax error. The last closing parenthesis is missing off the end. Second, this is impressive, but does not meet the RFC 4122 spec for either scenarios (grouping 3 and 5 as essentially the same), because for 3 & 5, there is no call (or need, imo) for a salt, as the expectation is to create the same UUID for a given name and namespace, and there is no namespace being used, which is a requirement as the hash is of the packed binary string of the namespace UID concatenated with the name string. For version 4 this doesn't quite work because it should be more random.

Also +1 for using bitwise operation to properly flip the 8th octet

@Anthony thanks for the feedback. Addressing your points in order: 1) Added the missing parenthesis. Not sure how that got dropped. 2) For 3 & 5, it is stated: "If [the salt] is provided, it is expected to be the byte string represention of the UUID for the applicable namespace." A fairly large caveat, to be sure, but given the proper input, the output is entirely compliant with RFC 4122. 3) gmp_random(4) produces a 128-bit random value. Only 122 bits are necessary to produce a v4 UUID.

source: Stack Exchange

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

sort: votes


text:
Create a seven-color rainbow with animation
Goal
Use any graphics library or environment that can use colours and animation to create a rainbow.
Rules

The rings should emerge one by one in some kind of animation or succession
The rainbow must have at least 7 colours.

Winning Criteria
Fewest bytes wins.

[tag:code-golf] and [tag:popularity-contest] are mutually exclusive. Seeing as you want "least bytes win", remove the [tag:popularity-contest]

@mniip done editing!

I’ve edited the question a bit in an attempt to improve it. Please anyone let me know if there’s anything else I can do to keep it from being downvoted or closed.

@Timwi I removed my downvote for the time being, good job fixing it up. I think it's still not very specific about what makes an okay rainbow though, which seems bad for a code-golf task (I think I would've preferred popularity-contest, but it's a tad late for that I guess).

HTML + CSS + JavaScript (447 440 439 432 428 434 390 388 383 bytes)
(Byte size went up at one point in order to fulfill “appear one by one” requirement)
(Some credit to Fez Vrasta’s answer for reminding me of the existence of document.write)

Screenshot (see JSFiddle for the full animation)

Explanation
The rainbow is created by having 7 pairs of  elements, which are all positioned using position:absolute and a width, height, left and bottom. Within each pair, they have the same position and size, but one has an “outer” (standard) box-shadow, the other an inset one, thus creating the nice fuzzy bands. The colors are calculated using hsl(), allowing us to vary only the hue but having the same saturation (99%) and lightness (50%) for all. The  tags are nested inside each other, but this doesn’t matter because all of their positioning is relative to the page.
In the beginning, they all have IDs 0, 1, etc., and a styling rule that applies to all b elements sets their width and height to 0, making them invisible. The code also outputs styling rules for elements with ID x0, x1, etc., which initially do not apply.
A setTimeout is then used to successively change their IDs from 0 to x0, from 1 to x1 and so on. This triggers a CSS transition which causes them to appear one by one.

You forgot to add   "+Javascript". in the title

Thanks!

As much as I like this answer and the animation, the rings don't seem to emerge one by one as far as I can tell, which the question seems to require. Still, very nice rainbow!

@FireFly: Fixed! :)

Nice colors!  You can probably save some by making a function like g=function(s){return "height"+h+"width"+w}

@Charles: Have you tried that? I can’t really see how that shortens it... function and return are very long, and width/height occur only three times.

@Timwi you're right.  Sorry bout that.

Bash + ImageMagick, 226 bytes
r=400
s=""
for c in 008 40c 03f 07f 0c0 ee0 f80 c00
do
s="-stroke '#$c' -draw 'circle 250,280 $r,$r' $s"
eval "convert -size 500x220 xc:'#008' -fill none -strokewidth 10 $s r$r.png"
r=$[r+7]
done
convert -delay 50 r*.png r.gif

Produces the following GIF animation:

BBC BASIC, 101 106 Bytes
FORC=1TO7GCOLC:A=GET:R=700-C*50FORX=-R TO R:LINE640+X,SQR(R^2-X^2)-200,640+X,SQR((R+50)^2-X^2)-200NEXTNEXT

EDIT: added A=GET: so that user must press a key to make each ring appear, to comply with animation requirement. Deleted one unnecessary white space after LINE. The original code can still be seen on the screenshot.
Runs at the command line in Mode 6. Emulator at www.bbcbasic.co.uk

I posted this to show how concise BBC basic was. No complicated libraries to include, all you had to do was type MODE6 and away you went.
Also to demonstrate the drawing of a circle using pythagoras theorem. Ungolfed version:
FOR C=1 TO 7
  A=GET                             :REM wait for user to press a key
  GCOL C                            :REM change graphics colour to C
  R=700-C*50                        :REM select the inner radius
  FOR X = -R TO R                   :REM scan through X values
    LINE 640+X,SQR(R^2-X^2)-200,   640+X,SQR((R+50)^2-X^2)-200
  NEXT
NEXT

The centre of the circle is at 640,-200. For the inner circle, the Y coordinate (before subtracting 200) is the square root of R^2-X^2, so we are using Pythagoras theorem.
It was specified that the rings be drawn "one by one" so for each X value the program draws a line directly upwards from the inner radius of the current colour to the outer radius. The Y coordinate for finishing the line is the square root of (R+50)^2-X^2 so the radius is 50 more.
Unfortunately the algorithm cannot reach the last bit of the left and right sides of the outer circle, because if we try to go there, the calculation for the inner circle gives a negative square root and the program crashes. The easiest workaround was simply to put the centre of the circle off the bottom of the screen. You can still see a little bit of the uncoloured area at the sides, though.

I don't think that's how rainbow's colors are ordered :/

@mniip Haha, I see you have yours in the "Newton" order but I am not the only one who doesn't. The spec said minimum seven colours, no order was specified. No one has used the "Hamilton" order yet: Red and yellow and pink and green, orange and purple and blue. My rings emerge slowly (BBC Basic!) This is the way this game works. Client asks for minimum bytes, accepts lowest offer based on 30 year old platform , then their staff have to maintain it.....

@mniip Sorry I just realised you're 15. That was a joke. You probably haven't experienced bad management decisions yet, so you won't find it very funny.

That was an unnecessary comment... I do understand that 's a joke, although I find it saddening (for now?).

Python 2 with Pygame
First version - 210 198 bytes
import pygame as p
s=p.display.set_mode((720,360))
c=p.Color(0,0,0)
for i in range(360,0,-1):
    c.hsla=(i,100,50,100)
    p.draw.circle(s,c,(360,360),i)
    __import__('time').sleep(0.1)
    p.display.flip()

This creates a window showing the drawing of a rainbow from the circumference to the center. It takes 36 seconds to complete the rainbow.

Alternative version - 235
import pygame as p
s=p.display.set_mode((720,360))
c=p.Color(0,0,0)
for j in range(360,-45,-45):
    for i in range(j,0,-1):
        c.hsla=(j-i,100,50,100)
        p.draw.circle(s,c,(360,360),j-i)
        __import__('time').sleep(0.01)
        p.display.flip()

This alternative version draws some rings with a cooler animation.

+1 for awesome graphics. But is it a rainbow or a nuclear bomb / supernova?

@steveverrill - I know, but otherwise it would be too longer. I've just finished an alternative version, do you like it?

I like them both. It wasn't a criticism, just an alternative interpretation.

Replacing import pygame as p with from pygame import* and removing all occurences of p. would save some bytes.

Mathematica, 177
I doubt this is the shortest Mathematica way to do it.
ListAnimate@Table[Graphics[{Thickness[0.1], Table[{ColorData["Rainbow"]@i, Circle[{0, 0}, 7 i]}, {i, 0, m, 1/7}]}, PlotRange -> {{-8, 8}, {0, 8}}], {m, 0, 1, 1/7}]

GLSL - 234 200
(heroku flavor)
At the cost of 34 characters, added animation
precision lowp float;uniform vec2 resolution;uniform float time;void main(){float f=distance(gl_FragCoord.xy/resolution,vec2(.5,0))*9.;gl_FragColor=f>2.4&&f<8.?vec4(sin(f+time)+.5,sin(f+2.+time)+.5,sin(f+4.+time)+.5,1):vec4(0,0,0,0);}

http://glsl.heroku.com/e#14103.1
non-animated answer:
precision lowp float;uniform vec2 resolution;void main(){float f=distance(gl_FragCoord.xy/resolution,vec2(.5,0))*9.;gl_FragColor=f>2.4&&f<8.?vec4(sin(f)+.5,sin(f+2.)+.5,sin(f+4.)+.5,1):vec4(0,0,0,0);}

http://glsl.heroku.com/e#14103.0

JavaScript: 304 239
i=-1,s=85,t=20;(function r(){if(++i<7){document.write('∩');setTimeout(r,999);s-=5;t+=5}})()

JavaScript 232
(thanks @Florent for the split idea)
i=7,s=85,t=20;(function r(){if(--i){document.write('∩');setTimeout(r,999);s-=5;t+=5}})()

yea I know my rainbow sucks >_<"

to test it just run this code in the JS console (F12)

that doesn't work for me in FF

@Charles Yes I've noticed it, I've tested it only on Chrome

226: i=6,s=85,t=20;!function r(){document.write('∩');s-=5;t+=5;i--?setTimeout(r,1e3):0}()

@Florent: unaxpected token illegal :\

Strange, runs fine in Chrome's console

I've tested it on Chrome console as well

Powershell: 270b (arbitrary width/height) / 307b (screen dimensions)
For a rainbow spanning most of the screen, the following leaks like a sieve, but seems to work (for 307 bytes):
$d=@{};Add-Type -A System.Drawing -Pas|foreach{$d[$_.Name]=$_};$g=$d.Graphics::FromHwnd(0);$v=$g.VisibleClipBounds;$y=$h=$v.Height;$h/=9;$c=0;@(65281,11861886,16776961,16744448,256,23296,65536)|foreach{$g.DrawArc((New-Object $d["Pen"]($d.Color::FromArgb(-$_),$h)),-$h,$y-$h*$c++-$h,$v.Width+2*$h,$h,0,-180)}

Ungolfed
$d=@{};
Add-Type -A System.Drawing -Pas | foreach { $d[$_.Name]=$_ };        # import .NET naespace "System.Drawing" and copy its members into the $d array
$g = $d.Graphics::FromHwnd(0);                                       # build a Graphics object for the screen
$v = $g.VisibleClipBounds;                                           # determine the screen size
$y = $h = $v.Height;                                                 # init start point for arcs and band height
$h /= 9;                                                             # allow space for 7 bands + clear above and below
$c=0                                                                 # counter

@(65281,11861886,16776961,16744448,256,23296,65536) | foreach {      # ARGB color values for bands (no clever calculation here, just Color.Red.ToARGB(), Color.Orange.ToARGB(), etc...)
    $g.DrawArc(
        (New-Object $d["Pen"](
            $d.Color::FromArgb(-$_),                                 # build a pen from the current color, using width = band-height
            $h
        )),
        -$h,                                                         # x-pos for start of arc (pushed slightly offscreen to avoid weird wide-pen effect)
        $y-$h*$c++-$h,                                               # y-pos for start of arc (moves up each time because of counter increment)
        $v.Width+2*$h,                                               # width of arc (pushed offscreen to avoid weird wide-pen effect)
        $h,                                                          # height of arc always the same
        0,-180                                                       # arc sweep clockwise between 0 and 180 degrees from x-axis)
    )
}

Of course, if you don't factor the screen size or the wide-pen effect, and just go with any arbitary width/height, you can lose the VisibleClipBounds stuff for approx 270 bytes, but your "animation" speed will be affected by the number of pixels it has to draw:
$d=@{};Add-Type -A System.Drawing -Pas|foreach{$d[$_.Name]=$_};$g=$d.Graphics::FromHwnd(0);$y=$h=300;$h/=9;$c=0;@(65281,11861886,16776961,16744448,256,23296,65536)|foreach{$g.DrawArc((New-Object $d["Pen"]($d.Color::FromArgb(-$_),$h)),0,$y-$h*$c++-$h,400+2*$h,$h,0,-180)}

Results
Window-redraw makes it particularly difficult to get a screencap of the full-screen one in action, but the arbitrary-sized one (with the wide-pen awkwardness) looks like:

Edit: OK, I've managed to get a fullscreen cap, but not before some of my screen redrew:

Disclaimer: The following solutions work only in Chrome Dev Tools!
Note: The following solutions will draw a rainbow with an infinite radius, thus arcs are not curved!

JavaScript (ES6), 121
i=0;'f43f82fd03c407d72eb2c'.replace(/.../g,p=>setTimeout("console.log('%c'+' '.repeat(99),'background:#"+p+"')",1e3*i++))

Thanks to @manatwork for this one!
JavaScript, 126
for(c='f43f82fd03c407d72eb2c',i=7;i--;)setTimeout("console.log('%c'+' '.repeat(99),'background:#'+c.substr("+i+"*3,3))",1e3*i)

Details:
for(
  // Colors:
  //   - #f43 (red)
  //   - #f82 (orange)
  //   - #fd0 (yellow)
  //   - #3c4 (green)
  //   - #07d (blue)
  //   - #72e (indigo)
  //   - #b2c (purple)
  c='f43f82fd03c407db1c',
  // Iterate through each color
  i=6; i--;
)
  // Delay the arc emergence
  setTimeout(
    // Display a colored line into the console
    "console.log('%c'+' '.repeat(99),'background:#'+c.substr("+i+"*3,3))",
    // 1 second
    1e3*i
  )

Rainbow:

Tricky. But where is the 7th color?

@manatwork Fixed

You forgot to update the character count in the post heading. But before counting the code, remove the -color part. By the way, defining c as array of strings and accessing it by index instead of substr() seems to be shorter by 1 character.

@manatwork The character count is right (132). Previous was 129. Moreover, I'm unable to reduce the size of this solution by removing substr (and defining the array as ['f43','f82','fd0','3c4','07d','72e','b2c'], or with a number and then split on it)

Sorry, my mistake, I described a wrong attempt.

And sorry again, no idea why, but although the code was modified by the site's inplace updating functionality, the heading stayed at 129 until a full reload.

@manatwork No problem. Thanks for noticing the -color suffix.

shouldn't the rainbow be made out of half-rings as described by the OP? (ps. your code doesn't work on my FF Nightly, it doesn't print a colored stripe but just plain text)

I think finally I found a shorter one: i=0;'f43f82fd03c407d72eb2c'.replace(/.../g,p=>setTimeout("console.log('%c'+' '.repeat(99),'background:#"+p+"')",100*i++)). And is even more ES6.

@manatwork Well done!

@FezVrasta I've added a note explaining why arcs are not curvy.

@florent I'm not sure this is a valid reason ._.

“The following solutions work only in Chrome Dev Tools!” – Sorry, but how could they work in anything Chrome related while Chrome doesn't implemented Harmony yet? So absolutely no String.repeat() and no fat arrow functions in Chrome. (At least not in the latest stable version.)

@manatwork String.repeat works in Chrome with experimental JavaScript setting activated. About fat arrows function, traceur can fix that.

Thank you, @Florent. All this sounds interesting, will have to look them up.

all_licenses: 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/


text:
Let's learn geometry
Today our lesson is about rectangles and triangles.
you will be given as an input an n x n grid that is based on two characters # and *
you have to classify it into :  triangle or rectangle.
where # represents a point and * represents a blank space.
Example input:
 #***
 ##**
 ###*
 ####

Output:
 triangle

Another example
  ##**
  ##**
  ##**
  ##**

Output:
  rectangle

Rules:

You should assume that the input is always either a triangle or a rectangle.
The only two characters you will receive are: * and #.
Assume that n < 100.
Be creative, this is a popularity-contest so the most up-voted answer will win.

is the aspect ratio considered 1? What I mean is, square is n lines by n columns, right?

@mniip no there could be 2x2 square in an 4x4 grid

Could it for example also be an inverted square, ie a hole?

@JoachimIsaksson no the square(rectangle) should be filled completely.

Is it guaranteed that all triangles will have exactly one character at their vertex?

@user80551 yes, or that would make it a trapezoid

TSQL
Image recognition? Sounds like a job made for SQL :)
WITH cte AS (
  SELECT LEN(data)-LEN(REPLACE(data,'#','')) c FROM test_t
)
SELECT
  CASE WHEN COUNT(DISTINCT c)>2                           THEN 'triangle'
       WHEN SUM(CASE WHEN c=0 THEN 0 ELSE 1 END) = MAX(c) THEN 'square'
                                                          ELSE 'rectangle'
       END result
FROM cte;

An SQLfiddle with sample data and test.

Python
Creativity
Triangle
Forward     Reverse
#***        ####      ####
##**  +     *###  =   ####
###*        **##      ####
####        ***#      ####

Rectangle
Forward  Reverse
##**     ##**     ##**
##**  +  ##**  =  ##**
##**     ##**     ##**
##**     ##**     ##**

Implementation
s=raw_input();print["tri","rect"][all(a!=b for a,b in zip(s,s[::-1])if a!='\n')]+"angle"

Python + Sympy
A problem in Geometry should be only solved mathematically
Creativity
if s if the number of "#" in the input stream
Triangle: n**2+n-2s=0 -> n should be an integer
Implementation
from sympy import *
s,n=2*raw_input().count("#"),Symbol('n');print["rect","tri"][float(solve(n**2+n-s)[0]).is_integer()]+"angle"

C
Assumption: the input does not represent a single-line degenerate rectangle, e.g.
****
*##*
****
****

as arguably this is also a degenerate triangle, and violates "the input is always one of the two cases."
Logic: Count the number of points in the first two non-empty lines. If they are the same, it is a rectangle. Otherwise, it is a triangle.
Code:
#include <stdio.h>
#include <string.h>
int main() {
    char s[99];
    int cnt1=0, cnt2=0;
    int i;
    while(!cnt1) {
        gets(s);
        for(i=0;i<strlen(s);i++) cnt1+=(s[i]=='#');
    };
    gets(s);
    for(i=0;i<strlen(s);i++) cnt2+=(s[i]=='#');
    puts(cnt1==cnt2?"rectangle":"triangle");
    return 0;
}

Java
A simple straightforward java implementation. It scans the input looking for some 2x2 square which have # in two opposing corners with something not a # (presumable a *) is some other corner. I.E, it searchs for something that shows that the drawing has a diagonal-lined border.
import java.io.ByteArrayOutputStream;
import java.io.IOException;

public class TrianglesAndRectangles {
    public static void main(String[] args) throws IOException {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        int r;
        while ((r = System.in.read()) != -1) {
            baos.write(r);
        }
        String[] lines = baos.toString().split("\n");
        System.out.println(hasTriangle(lines) ? "triangle" : "rectangle");
    }

    public static boolean hasTriangle(String[] lines) {
        for (int i = 0; i < lines.length - 1; i++) {
            for (int j = 0; j < lines[i].length() - 1; j++) {
                boolean a = lines[i].charAt(j) == '#';
                boolean b = lines[i].charAt(j + 1) == '#';
                boolean c = lines[i + 1].charAt(j) == '#';
                boolean d = lines[i + 1].charAt(j + 1) == '#';
                if ((a && d && (!c || !b)) || (b && c && (!a || !d))) return true;
            }
        }
        return false;
    }
}


text:
Longest Common Subsequence of Two Strings containing a particular Substring
A subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements.
Given three strings A, B and C (note the order) as input, find the length of the longest string S such that:

Condition 1: S is a subsequence of A
Condition 2: S is a subsequence of B
Condition 3: C is a substring of S

.
Testcase #1

Input:
ABCDEF
CDEFAB
B
Output:
2
Testcase #2

Input:
HELLO
WORLD
SUCKS
Output:
0
Testcase #3

Input:
ABCXD
BCDEF
CD
Ouput:
3
Testcase #4

Input:
X
Y
Z
Ouput:
0
Note:

The empty string is regarded as a subsequence as well as a substring of every string.
Assume all input strings are in uppercase.
Return 0 as output if any of the first two conditions (Condition 1 and Condition 2) is not going to be satisfied using Condition 3.

Constraints:

Assume the lengths of A, B and C will always be between 1 and 3000 (both inclusive)

Winner:
One with the shortest code.

Either your spec is wrong or your sole test case is wrong. This question needs a definition (or at least a reference to a definition) of subsequence, and to be a good question it also needs test cases with better coverage (at a minimum, where S is not a substring of A or B).

@PeterTaylor Why do you think the example is wrong? AB is the longest subsequence which fulfills all three conditions. (It also happends to be a substring of A and B but that doesn't exclude it from the set of solutions.) I agree that the choice of the test case is not sufficient for any case but at least it isn't wrong.

My apologies, I misread the test case and got it into my mind that the third parameter was C. As @Howard says, it is correct.

Why would case#2 and #4 return 0? Error fallback in case there's no matching sequence? 'SUCKS' isn't a substring of any subsequence, and even if as you say '' is a substring of every string/subsequence, there's nothing saying that '' should be compared...?

@JoachimIsaksson My mistake. Return 0 as output if any of the first two conditions (Condition 1 and Condition 2) is not going to be satisfied using Condition 3.

APL (45)
⌈/0,⍴¨m/⍨∨/¨⍞∘⍷¨m←⊃∩/{/∘⍵¨↓⍉(z/2)⊤⍳2*z←⍴⍵}¨⍞⍞

Explanation:

¨⍞⍞: read two lines. For each of them:

⍳2*z←⍴⍵: get the numbers from 1 up to 2^length.
(z/2)⊤: encode each number as bits
↓⍉: separate each string of bits into its own array
/∘⍵¨: and use each of them as a bitmask on the string, giving the subsequences

m←⊃∩/: take the intersection of the two arrays of subsequences, store in m
∨/¨⍞∘⍷¨: read a third line, and see in which subsequences it occurs
m/⍨: select those elements from m that contained the third line
⍴¨: get the length of each remaining subsequence
0,: add a zero entry in case the resulting list is empty
⌈/: get the highest number in the list

Test cases:
      ⌈/0,⍴¨m/⍨∨/¨⍞∘⍷¨m←⊃∩/{/∘⍵¨↓⍉(z/2)⊤⍳2*z←⍴⍵}¨⍞⍞
ABCDEF
CDEFAB
B
 2
      ⌈/0,⍴¨m/⍨∨/¨⍞∘⍷¨m←⊃∩/{/∘⍵¨↓⍉(z/2)⊤⍳2*z←⍴⍵}¨⍞⍞
HELLO
WORLD
SUCKS
 0
      ⌈/0,⍴¨m/⍨∨/¨⍞∘⍷¨m←⊃∩/{/∘⍵¨↓⍉(z/2)⊤⍳2*z←⍴⍵}¨⍞⍞
ABCXD
BCDEF
CD
 3
      ⌈/0,⍴¨m/⍨∨/¨⍞∘⍷¨m←⊃∩/{/∘⍵¨↓⍉(z/2)⊤⍳2*z←⍴⍵}¨⍞⍞
X
Y
Z
 0

Yep, soundly beat it was, I can't even figure out how to type those characters... :) +1

SWI-Prolog, 166
s(A,[H|R]):-(A=[H|T],s(T,R);s(A,R)).
s([],[]).
r(A,B,C,O):-(r(A,B,C,0,O),!;O=0).
r(A,B,C,M,O):-s(S,A),s(S,B),append([_,C,_],S),length(S,L),L>M,!,(r(A,B,C,L,O),!;L=O).

Usage:
?- r("abcxd","bcdef","cd",O).
O = 3.

Python (181)
Will probably be beat soundly by more operator rich languages, but since I so far have nothing to beat... :)
EDIT: I originally read substring where it said subsequence, this is the subsequence version;
from itertools import*
def f(a,b,c):
 f=lambda x:set(''.join(z)for y in range(len(x))for z in combinations(x,y))
 return max(len(x)for x in f(a).intersection(f(b))if c in x or not x)

What it does is basically to create 2 sets of all possible subsequences of the string a and the string b, intersecting them to find the common ones.
It then simply finds all resulting strings that contain the string c and prints the length of the longest matching string.

See my comment on the question. Because it didn't define subsequence, you've wasted your time. A string of length n has up to 2^n subsequences, and e.g. f("ABCDEF", "ACE", "C") should return 3 because "ACE" is a subsequence of "ABCDEF".

@PeterTaylor Yes, quite possibly I'll need to update this, I read subsequence as substring.

Your entry has rich operators. But, like Mathematica, its operators (more precisely, functions) have long names.

Brachylog, 12 bytes, language postdates challenge
k⊇ᵐ=h.s~t?∨0

Try it online!
This is a function. The TIO link uses a command-line argument that allows functions to be run like full programs.
Explanation
k⊇ᵐ=h.s~t?∨0
k             Take the input, apart from the last element.
 ⊇ᵐ           Find the longest subsequence of each element
   =          such that those subsequences are equal
    h         and that subsequence
      s       has a substring
       ~t?    that's the last element of the input.
     .        If you can, return the subsequence.
          ∨0  If all else fails, return 0.

GolfScript, 45 characters
n/)`{?)}+\{['']\1/{`{1$\+}+%}/}/&\,{,}%0+$-1=

Takes input as three lines on STDIN. Take a test run here.
Short explanation of the code:
n/     # split the input at newline into three strings
)`           # take the last one and stringify it
{?)}+        # and build a code block to filter for any string
             # which has that one as a substring (for later use)
\{           # now loop over the remaining two strings and
             # build their subsequences
  ['']       # start with the set of the empty string
  \1/{       # loop over each character of the string
    `{       # apply code block to each member of the set
      1$\+   # copy member and add the current character
    }+%      # -> set is updated with latest character
  }/
}/
&            # take the common subsequences
\,           # apply the filter block from above
{,}%         # from each string take length
0+           # add zero (if empty set was returned)
$-1=         # sort and take last element (largest)

Haskell, 90 81
Haskell provides everything you need in Data.List:
s=subsequences
f a b c=maximum$map length$filter(isInfixOf c)$intersect(s a)(s b)

If only the function names were shorter :)

You can get it to 81 bytes if you rename subsequences and remove the space before and after the =.

Mathematica 150 125
f[{a_,b_,c_}]:=({z=Subsets[Characters@#]&,s};s=Select[""<>#&/@(z@a⋂z@b),!StringFreeQ[#,c]&];
If[s=={},0,StringLength[s[[-1]]]])

Characters converts a string into a list of characters.
Subsets finds all the subsequences (held as lists of characters).
s refers to the list of ALL common subsequences (not the same a S).
s[[-1]] is the last (and largest) common subsequence; it is equal to S as defined in the question.

Test Cases
f[{"ABCDEF", "CDEFAB", "B"}]

2

f[{"HELLO", "WORLD", "SUCKS"}]

0

f[{"ABCXD", "BCDEF", "CD"}]

3

f[{"X", "Y", "Z"}]

0

Perl, 122
chomp(($A,$B,$C)=<>);$A=~s/(.)/($1)?.*?/g;$_=join'',map{$$_}1..$#-and/$C/&&$%<($-=length)and$%=$-while$B=~/.*?$A/g;print$%

The program expects 3 strings on STDIN and prints a number to STDOUT. Here it is re-written as sub for easier testing:
use feature 'say';
sub L{
    ($A,$B,$C,$%)=(@_,0);
    $A=~s/(.)/($1)?.*?/g;
    $_=join'',map{$$_}1..$#-and/$C/&&$%<($-=length)and$%=$-while$B=~/.*?$A/g;
    $%
}
say L(qw/ABCDEF CDEFAB B/);
say L(qw/HELLO WORLD SUCKS/);
say L(qw/ABCXD BCDEF CD/);
say L(qw/X Y Z/);

and
perl LCSoTS.pl
2
0
3
0

So, 122 even with ugly byte-consuming chomping at the start. I hope no bugs crept in while I golfed it to this size. And not sure about scalability, but let it be the question of hardware :-).

Brachylog, 13 bytes
~c~gᵗ⟨⊇ᵛs⟩l|∧

Try it online!
I didn't bother scrolling down far enough to notice that ais had already answered in Brachylog before I wrote this, but it looks like his answer doesn't actually output the length. It's way shorter doing what it does (it could be golfed down to the 10-byte k⊇ᵛ.s~t?∨ with the verify metapredicate and by leaving the output in case of failure to simply default to 0, and then every other integer), but if you try to get it to output the length it ends up tying this (while still making a lot more sense than anything that handles a set number of arguments with ~c!): k⊇ᵛXs~t?∧Xl.∨
A remarkably confusing explanation of my original solution:
~c               A partition of
                 the input
    ᵗ            such that its last element
  ~g             is a list containing one element
  ~gᵗ            which is replaced with that element
     ⟨   ⟩       is a list of two elements
          l      such that the implicit variable the length of which
           |     is the output
     ⟨⊇ᵛ ⟩       is a subsequence of both elements of the first element of the partition
     ⟨  s⟩       and has the last element of the partition as a substring.
           |     If it's not possible to find such a subsequence,
            ∧    leave the output variable unconstrained, so it will default to 0.

~chᵗ⟨⊇ᵛs⟩l|∧ is one byte shorter, but provides an incorrect output when the second element of the input is a substring of a subsequence of the first, like this or this. ~ctᵗ⟨⊇ᵛs⟩l|∧ completely disregards the second element of the input.


text:
Inverse CIDR whitelist
The task
The task is to write a program that turns a list of IPv6 addresses into a shortest possible list of CIDR masks, such that everything but those IPs is matched.
CIDR masks
A CIDR mask matches IPs by a prefix. ::/19 matches all IPs whose first 19 bits are zero, i.e. 0:0000-1fff:*:*:*:*:*:*. Similarly, 55aa::/16 matches all IPs that start with 0101010110101010 bit sequence, i.e. 55aa:*:*:*:*:*:*:*.
A /128 always matches only one IP. A /0 matches all IPs.
Input
Input is a list of IP addresses in full form: eight 4-digit hexadecimal groups separated by : in network order (most significant first). For example, 0000:0000:0000:0000:0000:0000:0000:0000.
You're free to choose any separation character for the input list, might it be newline, space, comma, \0, etc. You can also rely on a-f being in a particular case.
Output
Output is the shortest list of CIDR masks that cover all IP addresses except those listed in input.
Again you're free to choose any separation character.
The CIDR should be formatted as any representation of an IP followed by / and amount of bits in the prefix (in decimal). For example, 0243:F6A8:885A:308D:3131:98A2:0000:0000/112.
You are not required to shorten the IP at all, as in above example. However 243:f6a8:885a:308d:3131:98a2::/112 is not invalid.
The order of masks doesn't matter. If there are multiple representations using equal amount of masks - either will suffice.
Examples
I'm not posting complete outputs, since coming up with an algorithm is a part of the task :)
Instead I'm specifying how much masks does it take, according to my own calculations. If you find a mistake, or a shorter masklist, please report.
>>> 0000:0000:0000:0000:0000:0000:0000:0000
 [128 masks]
>>> 0000:0000:0000:0000:0000:0000:0000:0000 0000:0000:0000:0000:0000:0000:0000:0001
 [127 masks]
>>> ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff 0000:0000:0000:0000:0000:0000:0000:0000
 [254 masks]
>>> 0000:0000:0000:0000:0000:0000:0000:ffff 0000:0000:0000:0000:0000:0000:0000:0000
 [142 masks]
>>> 0123:4567:89ab:cdef:fedc:ba98:7654:3210 0246:8ace:1357:9bdf:0246:8ace:1357:9bdf
 [248 masks]
>>> 0000:0000:0000:0000:0000:0000:0000:0000 0000:0000:0001:0000:0000:0000:0000:0000 0000:0000:0002:0000:0000:0000:0000:0000 0000:0000:0003:0000:0000:0000:0000:0000 0000:0000:0004:0000:0000:0000:0000:0000 < snip > 0000:0000:00ff:0000:0000:0000:0000:0000
 (256 IPs)
 [20520 masks]
>>> 0000:0000:0000:0000:0000:0000:0000:0000 0000:0000:0000:0000:0000:0000:0000:0001 0000:0000:0000:0000:0000:0000:0000:0002 0000:0000:0000:0000:0000:0000:0000:0003 0000:0000:0000:0000:0000:0000:0000:0004 < snip > 0000:0000:0000:0000:0000:0000:0000:0fff
 (4096 IPs)
 [116 masks]

Scoring
Amount of characters in the code, UTF-8 characters are counted as one, if you must.
Bonus points

-16  Cover the case of empty input list.
-32  Output shortened IPs: strip leading zeros, replace sequential zero groups with ::, etc. See this Wikipedia article.

-32 Do not use the v4-in-v6 form (dead::beef:1.2.3.4).

-64  Permit shortened IPs in input.

For the 256 IPs test case I get 20520.

Oh... That's merely a typo. I get 20520 too.

GolfScript, 120 (136 characters - 16 bonus)
n%{':'-{48^71%}%16base}%-1+2.7??:W+${\)1$1$-{}{129,-1%{2\?.2$)<3$@%!&}?:~2$W+16base(;{.48+\9>39*+}%4/':'*'/'+128@-+puts\2~?+\2~?-}/;;}*;

Assumes the addresses as separate lines on STDIN. A considerable amount of the code is actually used to input/output in the correct format. The algorithm itself is quite simple and described here.

Python 3: 128 points
(240 characters - (16 + 32 + 64) bonus points)
Yay, Python!
(I used the standard library instead of actually writing my own algorithm. Is that cheating?)
from ipaddress import *
import sys
def e(x,a):
 b=[]
 for i in a:
  try: b+=i.address_exclude(ip_network(x))
  except ValueError: b+=[i]
 return b
a=[ip_network('::/0')]
for h in sys.stdin:
 for i in h.split(): a=e(i,a)
for i in a: print(i)

It accepts a list of addresses on stdin, separated by any (ASCII) whitespace you like (no commas, though).
If stdin is empty (or has only whitespace), it will print ::/0 (-16 points). It also prints (-32) and handles (-64) shortened IPs.
You can save 12 characters by replacing the stdin loop with for i in sys.stdin: a=e(i.strip(),a). The strip() is necessary to get rid of a trailing newline anyway, though, so I figured I'd use split() and another for loop and allow any whitespace.
You can probably save a few more characters by moving the code out of that pesky function. I didn't because I figured I was already confusing myself enough.
You can also make it work for IPv4 instead by changing only one line.
Ungolfed version:
#!/usr/bin/env python3

import ipaddress
import sys

def exclude(address, networks):
    new_networks = []
    for network in networks:
        try:
            new_networks.extend(network.address_exclude(ipaddress.ip_network(address)))
        except ValueError:
            new_networks.append(network)
        except TypeError:
            pass
    return new_networks

networks = [ipaddress.IPv6Network('::/0'), ipaddress.IPv4Network('0.0.0.0/0')]
for line in sys.stdin:
    for address in line.split():
        networks = exclude(line, networks)

for network in networks:
    print(network)

This one has the added benefit of working for IPv4 and IPv6, no tweaking necessary. :)


text:
Build a program that creates a minimal one-ohm resistor diagram for a given resistance
You are a contractor for a company who designs electrical circuits for the various products they make. One day, the company accidentally gets a huge shipment of one-ohm resistors and absolutely nothing else, and give you the task of putting them to good use in the newest products they're making.
Your task is to build a program that takes a positive rational number as input, in the following form:
a / b

and return a resistor diagram with the exact given resistance, that uses as few one-ohm resistors as possible.
Your resistor diagram will consist of:

The number N, to denote how many SPTs there are. (I will describe an SPT below.)
N lines, each containing two numbers A and B representing numbered electrodes on a circuit board, followed by one SPT.
One line containing two numbers P and Q denoting which two electrodes to measure the resistance between.

An SPT is a "series-parallel tree", a way to describe a series-parallel circuit in a tree format.
A valid SPT is either:

The number 1, representing a single resistor.
S( ), enclosing a number followed by zero or more P( ) SPTs.
P( ), enclosing a number followed by zero or more S( ) SPTs.

Examples of valid SPTs:
1 <- has a resistance of 1
S(1) <- equivalent to 1 and P(1)
S(2, P(3)) <- has a resistance of 7/3, using 5 resistors
P(1, S(2), S(3), S(4, P(2))) <- has a resistance of 18/37, using 12 resistors

Examples of invalid SPTs:
2 <- the two resistors are in an unknown configuration. Use P(2) or S(2) instead.
P(2, P(1)) <- use P(3) instead.
P(4, P(1, S(3), S(2))) <- use P(5, S(3), S(2)) instead.

Specifications
Your program must work for any numerator and denominator up to 150 000.
Your program's source code, excluding any imported standard or third-party libraries, must not exceed one megabyte (1,048,576 bytes) total.
Your program will be tested on a specific, randomly chosen set of 10,000 fractions (to be determined at a later date), and scored on how few resistors it requires to build all 10,000 circuits. The program that uses the fewest resistors is the winner.

Testing data
The input
3 / 8

might return
1
1 2 S(0, P(8), P(4))
1 2

to represent a series of 8 resistors and then 4 resistors in parallel. This may not be the optimal solution; but for the purposes of this problem, it is valid output.
The input
5 / 6

might return:
12
1 2 1
1 3 1
1 5 1
2 4 1
2 6 1
3 4 1
3 7 1
4 8 1
5 6 1
5 7 1
6 8 1
7 8 1
1 8

to represent a cube of one-ohm resistors with vertices numbered 1 through 8, having its resistance measured between opposite corners. Of course it is possible to just do S(P(2), P(3)) using just five resistors, but this is an example of how the notation is used to represent non-series-parallel diagrams.

I don't understand the output format. Are you trying to give people an option between always outputting 1\n0 1 SPT\n0 1 vs a solution which only uses SPTs of the form 1? Can you give some test cases for people to use in development?

Will do. I was kinda rushed this morning, so I left the bare spec there. I'll put in a few test cases now.

This isn't a duplicate, but is the link to an earlier question intentional?

I don't see a link in the question. Do you mean a conceptual link?

If it's the latter, though, yes, it did have a bit to do with the nontrivial resistance diagram evaluator problem. For example, to verify that your circuit does indeed have that sort of resistance, you'll most likely need an evaluator of that sort.

This paper might interest you. This resistor network synthesis problem is closely related to a geometric [integer] tiling problem as well, tiling a rectangle with squares as explained in that paper.

Most of your valid STPs are not valid according to your definition because of the presence of 2 and other illegal numbers (which seem to expand to a series of 1s). Also, what do S() and P() do? Interpreting them as 'series' and "parallel", they would be defined as the sum and 1/sum of their inputs respectively.  And why the requirement of exactly one numeric input? Blah blah blah oh wait this question is three years old what am I doing.

For series-parallel circuits with few resistors, the resistances which can be created with n resistors but not with fewer are the numbers on the nth level of the Stern-Brocot tree. (This breaks later on, with 5/6 = 1/2 + 1/3 apparently a minimal counterexample).
Instead of mapping from position in the Stern-Brocot tree to an S-P expression, it turns out to be much more convenient to use the Calkin-Wilf tree; its nodes at a given depth are permutations of the Stern-Brocot tree's nodes at that depth, but it has a different parent-child relationship: the left child of m/n is m/(m+n) = (1^-1 + (m/n)^-1)^-1 = P(1, m/n), and the right child of m/n is (m+n)/n = 1 + m/n = S(1, m/n).
GolfScript
# Parse input
'/'/' '*~
# Stack: numerator denominator
{
    # numerator denominator
    1$1$<{
        # n/d is less than 1, so parent is n/(d − n) and we're looking at Parallel
        ', P('@@.2$/@@1$%
        # ', P(' d/n n d%n
    }{
        # n/d >= 1, so parent is (n - d)/d and we're looking at Series
        ', S('@@1$1$/@2$%@
        # ', S(' n/d n%d d
    }if
    # Loop until we get to 0/1 or 1/0
    1$1$*
}do;;
# Stringify
]''*
# Trim leading ', '
2>.
# Close the parentheses
'('/,(')'*+
# Add the boilerplate
'1
0 1 '\'
0 1'

Hmm. I had no idea the "link" you were talking about was in fact the Stern-Brocot tree.

Python
As a last-place reference solution, here is a naïve solution that always works:
frac = raw_input().split(" / ")
num = int(frac[0])
den = int(frac[1])
print 1
print 1, 2,

pstr = ""
for x in range(den):
    pstr += "S(%s), " % num
pstr = pstr[:-2]

print "P(%s)" % pstr

print 1, 2

Always creates n parallel of m resistor series for the resistance m/n, using mn resistors each time.


text:
Insert typos into text
I wrote some text, but it looks too professional. I want to make it look like I was really tired when I wrote it. I need you to insert some typos.
Your challenge is to take an arbitrary single line of text, and add typos. This means that for each character, there will be a 10% chance for it to be typofied.
The definition of "typofied" is that you must choose (randomly) one of the following:

Duplicate the character.
Delete the character.
Shift the character one keyboard space. The "keyboard" is defined as:
qwertyuiop
asdfghjkl
 zxcvbnm

For the character shift, you must go one space up, down, left, or right. This must be chosen randomly. The shift option only applies to alphabetic characters. Case must be preserved. Be careful with edge-cases, like m!

The definition of "random" is that the result must not be predictable (by looking at previous results). For example, you can't typofy every tenth character. Furthermore, the randomness must have an even distribution. For example, you can't do 30% duplicate, 30% delete, and 40% shift; it has to be a 1/3 chance for each (1/2 for each if it's a nonalphabetic character).
Example input:
This is some correct text. It is too correct. Please un-correctify it.

Example output:
This iissome xorreect tex..  It is too coteect. Please jn-corretify it.

This is code-golf, so the shortest code in bytes will win.

So if M is shifted, it has a 50% chance to be N and a 50% chance to be K?

@Chron Correct.

From your example input/output I assume that Space counts as a character that can be duplicated and deleted, but not shifted. Also are capitals to be preserved?

@Xantix Yes to both.

Wish I remembered more TECO; being a terse language specifically for editing, I suspect it could be a winner here.

What about accidentally striking the capslock key? When one types an "A" or "Z", there should be a random chance that they will hit capslock instead, ND END UP LIKE THIS.

@AJMansfield Lol, that would probably be too complicated. It's already complicated enough as it is :P

I have accidentally typed ',' instead of 'm' before.

@user2509848 Hey, stop ,aking it ,ore co,plicated than it already is! :-P

OK, I guess we would then have to add numbers and other keyboard characters.

@Doorknob Your example output doesn't look like you were tired, it looks like you're new to typing and you don't know how to correct typos. (Or you didn't look over what you'd typed at all.)

Hmmmmmmmm http://codegolf.stackexchange.com/questions/12340/make-stackoverflow-explode-bookmarklet/12390#12390

@Blacklight Heh, that works too. :-P

@Sumurai Oooh, maybe that could be adapted for this challenge and used here!

Can strings be arbitrarily large after execution? I mean, if I duplicate a character, when I move on, am I going to reroll on that duplicate and maybe duplicate again, or go through to the next one. That is, is the size of the output string bounded by 2n?

@Cruncher No; after duplicating a character you do not reconsider the duplicated character.

"edge-cases" <-- I see what you did there. *slow clap*

GolfScript, 120 characters
{10{rand}:R~!{[{.}{;}{Z\?[.(.10-@).10+]{Z=}%' '-.,R=}]'QWERTYUIOP ASDFGHJKL  ZXCVBNM'' '22*11/*.{32|}%+:Z 2$?0>2+R=~}*}%

The code can be tested here.
{                      # loop over all characters
  10{rand}:R~!         # take random number [0..9] and negate (i.e. 10% chance of true)
  {                    # {...}* is the if-block
    [                  # Three possible operations (code blocks) in the arry
      {.}              # a) duplicate
      {;}              # b) delete
      {                # c) shift
        Z              #      Z is the keyboard layout (see below)
        \?             #      Find the index of the current letter
        [.(.10-@).10+] #      Calculate index of letter left, right, above, below
        {Z=}%          #      Extract the corresponding letters for indices
        ' '-           #      Remove any spaces
        .,R=           #      Take random item
      }
    ]
                       # Z is the keyboard layout (upper and lower case)
                       # with enough spaces around
    'QWERTYUIOP ASDFGHJKL  ZXCVBNM'' '22*11/*.{32|}%+:Z
    2$?0>              # Is the current letter contained in Z and not a space?
    2+                 # Add 2 (i.e. 3 for letters, 2 for any other char)
    R=                 # Take a random code block from above
    ~                  # Execute the block
  }*
}%

C, 358 bytes
(There are only three lines of code, but I've broken up line 3 for legibility)
#define x putchar
#define y random()
c,n;main(){char*s[26]={"QS","HNV","FVX","EFSX","DRW","CDGR","FHTV","BGJY","KOU","HKNU",
"IJLM","KO","KN","BJM","ILP","OO","AW","EFT","ADWZ","GRY","IJY","BCG","ESQ","CDZ","HTU",
"SX"};while((c=getchar())>0){if(y%10>0&&x(c))continue;if(isalpha(c)&&y%3<1){n=(c&31)-1;
x(s[n][y%strlen(s[n])]|(c&32));continue;}if (y&1)x(x(c));}}

The array of strings at the beginning lists the possible adjacent keys for each letter of the alphabet. I had to double up the "O" (adjacent to "P") to avoid calculating random()%1 when selecting a shifted character.
Test run:
$ echo "This is some correct text. It is too correct. Please un-correctify it." |./a.out
This is some  cofrect teext. It is too correct.. Plleaase un-correctify it..

Update:
Here's an expanded and commented version of the same source code:
#include <stdio.h>
#include <string.h>
/* ^^ These should be included, but the code compiles without them */

int c,n;

void main() {

  /* Adjacent keys for each letter of the alphabet (A, B, C, ..., Z): */
  char *s[26] = { "QS","HNV","FVX","EFSX","DRW","CDGR","FHTV","BGJY","KOU","HKNU",
                  "IJLM","KO","KN","BJM","ILP","OO","AW","EFT","ADWZ","GRY","IJY",
                  "BCG","ESQ","CDZ","HTU","SX" };

  /* Fetch input until null character or EOF reached */
  while ((c=getchar())>0) {

    /* For 90% of the time, just echo the character unchanged */
    if (random()%10>0 && putchar(c)) continue;

    /* If it's a letter of the alphabet, shift with 33% probability */
    if (isalpha(c) && random()%3<1) {
      /* Calculate offset to adjacent keys data */
      n=(c&31)-1;
      /* Choose a random adjacent key, and change to lower case if needed */
      putchar(s[n][random()%strlen(s[n])]|(c&32));
      continue;
    }

    /* If we reach this point, either we didn't fetch an alphabet character, or   */
    /* we did but chose not to shift it. Either way, we now need to either repeat */
    /* the character or delete it, with 50% probability for each. */

    /* This repeats the character by printing the return value from putchar() */
    if (random()&1) putchar(putchar(c));

    /* To delete the character, we don't have to do anything. */
  }
}

I fairly certain you don't need to put the 26 in char*s[26]. The compiler should be able to figure that out itself.

@FDinoff Ah, of course. Not much point editing now; the ship's already sunk :-D

you could also replace both continues with elses. (leave the ; where the first one was).

What's the problem with random()%1? Any int % 1 should be 0.

Ruby, 168
Slightly shorter take using an array indexing strategy:
z='qwertyuiop.asdfghjkl...zxcvbnm'+?.*11
gets.chars{|c|$_=z[c]?z:z.upcase
h=[1,-1,11,-11].map{|d|$_[d+~/#{c}/]}-[?.]rescue[]
$><<(rand<0.9?c:[c*2,'',*h.sample].sample)}

Original regular expression version (184):
s='.qwertyuiop.asdfghjkl...zxcvbnm.'
gets.chars{|c|c=~/\w/&&(s[c]?s: s.upcase)=~/((\w).{9})?((\w)|.)#{c}((\w)|.)(.{9}(\w))?/
$><<(rand<0.9?c:[c*2,'',*[*$2,*$4,*$6,*$8].sample].sample)}

Sorry, I can't read Ruby. Here I ran this program 10 times with STDIN '0123456789'x10 i.e. 100 digits (i.e. 1000 digits total in 10 runs), and there was never duplicated digit in the output. Is there a problem with that site, or my understanding of how it all works?

@VadimR good catch, thanks!  I had started using Kernel#putc to print out the output since that didn't require parens, saving me one character.  Of course putc only prints the first character, and the output string can sometimes be two characters long.  Stupid mistake.  Try this version!

Perfect now. Thank you.

Python, 251
from random import*
w=choice
o=ord
print"".join(w([z]*9+[w(["",z*2]+[chr(o(w("DGRC FHTV GJYB UOK HKUN JLIM KO NK BMJ IPL O WA ETF ADWZ RYG YIJ CBG QES ZCD TUH XS SQ VNH XVF SFEX WRD".split()[(o(z)&31)-6]))|o(z)&32)]*z.isalpha())])for z in raw_input())

Very simple look-up technique, for a moment I thought it might be cheaper to encode the keyboard as a undirected graph but the overhead for creating such a type in Python proved prohibitive. Since Python's random functions have too-descriptive names I use choice() exclusively, renaming it to w. The 10% chance of error is handled by w([z]*9+[...]) where the nine copies of an un-typoed character are in a list with one typo.
-16 characters--thanks grc, +2 characters (and
correctness, worth many more than 2 chars)--thanks Dhara

Some minor improvements: use spaces as the delimiter d="SQ VNH XVF...".split(), remove the space after print, and replace the if/else with ([...]+[...])*z.isalpha(). Also, you don't need a variable for d since you only use it once.

You can do w=__import__('random').choice (at least in Python 3 afaik).

@SimonT ahh, but unfortunately len("w=__import__('random').choice")=29 while len("from random import*;w=choice")=28.

This code breaks with several text-characters: ?;:< etc

Also, it has an off-by-one error in indexing: 'b' in 'bbbbbbbb' are replaced by 'x', 'zzzzzzzzzz' gives an index out of bounds

Nice catch @Dhara. I managed to fix the problems by changing by ord(z)&31-1 to (ord(z)&31)-6. The second expression will only return number in the range -6 to 25 and therefore will not return an out of bounds exception when trying to index the array. Now characters like ?<;: grab bogus results from the array which are then thrown out by *isalpha(z). Of course this required reordering the array, but thankfully that doesn't increase the char count.

@Kaya you can further improve by changing the [z]*9 to [z]*27. Then, you just have to use choice once in the outer-most scope, not separately for the 3 cases.

Use Python 3's input() and print() to save 2 chars.

C#, 320 bytes (360 bytes with program wrapping)
Includes support for "shifted" upper-case letters.
As a function (320 bytes):
string T(string s){
    string t="",z="      ",k=z+z+"qwertyuiop asdfghjkl   zxcvbnm";
    k+=k.ToUpper()+z+z;
    int[]m={-11,-1,1,11};
    var r=new System.Random();
    foreach(var c in s){
        if(r.Next(10)>0)
            t+=c;
        else{
            int i=r.Next(k.IndexOf(c)>0?3:2);
            if(i>1){
                while(' '==k[i=k.IndexOf(c)+m[r.Next(4)]]);
                t+=k[i];
            }
            else if(i>0)
                t=(t+c)+c;
        }
    }
    return t;
}

As a program that reads a line of text (360 bytes):
using System;
class P{
    static void Main(){
        string t="",z="      ",k=z+z+"qwertyuiop asdfghjkl   zxcvbnm";
        k+=k.ToUpper()+z+z;
        int[]m={-11,-1,1,11};
        var r=new Random();
        foreach(var c in Console.ReadLine()){
            if(r.Next(10)>0)
                t+=c;
            else{
                int i=r.Next(k.IndexOf(c)>0?3:2);
                if(i>1){
                    while(' '==k[i=k.IndexOf(c)+m[r.Next(4)]]);
                    t+=k[i];
                }
                else if(i>0)
                    t=(t+c)+c;
            }
        }
        Console.Write(t);
    }
}

Input output sample:
This is some correct text. It is too correct. Please un-correctify it.
This  is some corrrect texy. Ut is too correct. Pease un-coorrectify it.

TYPO RAGE CAPS TEXT!
TYPPORAGE CAOS TEX!

Legal C# programs need to have at the least "public class A{static void Main(){}}" to be valid. You will then need to read in from console. But it looks like your solution will still be shorter than mine, so well done.

@Xantix, I know, but they never said it had to be a program.  Either way, my answer now includes program wrappings.

I just realised, my function will accept CR and LF characters in the input which could potentially be doubled or dropped.  That would make for interesting output...

Hmm, not enough random calls to make Func<int,int> n=x=>r.Next(x); a good idea. If only the compiler could infer the type for delegates...

JS, 303, 288, 275, 273, 274 (bug fix)
function z(s){return s.split('').map(function(d){if((r=Math.random)(b='qwertyuiop0asdfghjkl000zxcvbnm')>.1)return d
if((c=r(x=(d>'`'?b:(b=b.toUpperCase())).indexOf(d))*(/[a-z]/i.test(d)+2))<2)return c>1?d+d:''
for(a=0;!a;)a=b[x+[11,-11,1,-1][~~(r()*4)]]
return a}).join('')}

Algorithm for the keyslip:

find char in string (or uppercase)
add 11, -11, 1 or -1 to the index.
if it's invalid (0 or null), re-roll

Non-Golfed version per request:
function z (s) {
  return s.split('') // split input string into characters.
          .map( // and then for each character...
    function (d) {
      r = Math.random; // set up a shortened form of Math.random
      // declare keyboard here because we have parens and we can save a delimeter.
      b = 'qwertyuiop0asdfghjkl000zxcvbnm';
      if (r() > .1) {  // normal case
        return d;
      }
      numOptions = /[a-z]/i.test(d) + 2; // if it's a character, 1+2, else 0+2 options

      // test here because we have parens. x might be -1
      if (d > '`') {
        x = b.search(d);  // x marks the spot
      } else {
        b = b.toUpperCase();
        x = b.search(d);
      }

      c = r() * numOptions; // chars can be 0-3, non-chars: 0-2
      if (c < 2) {                // this case is simple, so it comes first
        return c>1 ? d + d : ''; // double or omit.
      }

      // we must be in keyslip mode.

      // in the golfed code, this while loop become for loops,
      // but it's really a while.
      a = 0;
      while (!a) { // that is, a != null && a != 0
        v = ~~(r() * 4); // 0, 1, 2, or 3
        newX = x + [11, -11, 1, -1][v]; // choose one
        a = b[newX];  // slip the key
      }
      return a;
    }
  ) // end the map function
  .join('') // and then reassemble the string
}

Bravo! JS ninja awarded!

@SunnyRGupta Thanks!  Wish I could get it down more.  I think the massive parentheses hell might make it longer than needed.

Also try to display the non-minified version for novices!

Well, technically your code has 277 bytes on windows. You SHOULD replace all newlines with ;. That is the only way to say that it actually has 274 bytes. Besides, it only works on newer Javascript and JScript versions.

Perl, 278 239 197 169 162 156 151 149
s#((\pL)|.)#rand>.1?$&:($&x2,'',do{1until/^.{@{[(2,-10,12)[rand 4]-1+index$_=QWERTYUIOP0ASDFGHJKL000ZXCVBNM,uc($,=$&)]}}(\D)/;$,&' '|$1})[rand@-]#ge

Run with -p, then 148+1=149 bytes. E.g.:
perl -p typos.pl
Your challenge is to take an arbitrary single line of text, and add typos.
You challenge is to tale an  arbitrary singe lind of text, and add yposs.
This is some correct text. It is too correct. Please un-correctify it.
This iis some correct text. It s too coorrect.Pleqse un-correctify it.

Un-golfed, more or less:
s#((\pL)|.)#rand>.1
    ? $&
    : ($&x2,'',
        do{
            1until/^.{@{[(2,-10,12)[rand 4]-1
                +index$_=QWERTYUIOP0ASDFGHJKL000ZXCVBNM,uc($,=$&)]}}(\D)/;
            $,&' '|$1
        }
    )[rand@-]
#ge

At first I thought that choosing element randomly in an array (of 26 of them of different lengths) is more statistically 'clean' (i.e. random), but maybe it was wrong. (See previous version.) This last attempt is, following the leaders:-), stepping along a string by either -1,1,-11,11 (randomly) and repeating until valid step.
Edit: Thanks to tobyink help and other optimizations, we managed to considerably reduce code size.
The last approach uses some tricks with regexp search to find valid step along substitution string, eliminating manual checks.
Another edit: 5 bytes off because we don't need integers for array indexes + small trick with illegal array index. I tried same trick with [-4+rand@-] (i.e. negative indexes) and get rid of one list element, '', but it didn't save anything.
Edit: Back to simplicity - replacing condition ~~rand 10 with rand>.1 saves 2 bytes...

There's no need for a semicolon after the definition of sub i. You're not using strict, so 'QWERTYUIOP0ASDFGHJKL000ZXCVBNM' can be given as a bareword (saves two quote mark characters). Similarly, so can 'Z' (though this means you need to add a space between it and gt, so it only saves one character). Total savings: 4 characters.

The construct ($n=i$&=~/\pL/?3:2)?--$n?do{...}:$&x2:'' can be rewritten as ($&x2,'',do{...})[i$&=~/\pL/?3:2]. It means that the evaluation isn't lazy (it calculates all three ways that the character could be substituted before deciding on a substitution technique), but it works, and it saves another seven characters by my calculations.

Oh, I just noticed you have whitespace before gt'Z' too - that can be dropped. With all these changes, you should be able to get it down to 184 characters.

@tobyink, many thanks, especially for your second comment - how I didn't see this construct there, I don't know :-(. Sub is gone (saves us a couple of bytes). Barewords trick is nice, too, and actually I was already doing it when I read your comment. :-) Thanks again.

I've got one more character for you. If you rename $s to $, (this built-in variable is the field separator for print, but you're not printing multiple fields anywhere, so it's built-in usage is irrelevant, making the variable ripe for reuse), then you can eliminate the white space in $s x3 making it just $,x3.

I managed to edit to -7, not -1 ;-). Thanks for help.

PHP, function with 368 bytes
Here is my attempt.
It's some "frankencode", but it kinda works.
function _($m){$q=array(array('qwertyuiop','asdfghjkl',' zxcvbnm'),'!.-,;?+/');$r='mt_rand';foreach(str_split($m)as$k=>$c)if(!$r(0,9)&&$c!=' ')foreach($q[0]as$x=>$y)if(($z=strpos($y,$c))!==!1){switch($t=$r(-3,2-($z>>3)-($x>>1))){case 2:++$z;break;case 1:++$x;break;case -1:--$x;break;case -2:--$z;break;case -3:$z=8;break;}$m[$k]=$t?$q[0][$x][$z]:$q[1][$z];}return$m;}

A more "readable" code:
function _($m)
{
    $q=array(array('qwertyuiop','asdfghjkl',' zxcvbnm'),'!.-,;?+/');
    $r='mt_rand';
    foreach(str_split($m)as$k=>$c)
        if(!$r(0,9)&&$c!=' ')
            foreach($q[0]as$x=>$y)
                if(($z=strpos($y,$c))!==!1)
                {
                    switch($t=$r(-3,2-($z>>3)-($x>>1)))
                    {
                        case 2:
                            ++$z;break;
                        case 1:
                            ++$x;break;
                        case -1:
                            --$x;break;
                        case -2:
                            --$z;break;
                        case -3:
                            $z=8;break;
                    }
                    $m[$k]=$t?$q[0][$x][$z]:$q[1][$z];
                }
    return$m;
}

The only difference between the 2 codes is that one has tons of tabs and newlines.
It doesn't produce the same exact type of "incorrectness", but it either deletes or replaces a char using the said conditions.
You can try it at http://writecodeonline.com/php/.
Copy and paste this code:
function _($m){$q=array(array('qwertyuiop','asdfghjkl',' zxcvbnm'),'!.-,;?+/');$r='mt_rand';foreach(str_split($m)as$k=>$c)if(!$r(0,9)&&$c!=' ')foreach($q[0]as$x=>$y)if(($z=strpos($y,$c))!==!1){switch($t=$r(-3,2-($z>>3)-($x>>1))){case 2:++$z;break;case 1:++$x;break;case -1:--$x;break;case -2:--$z;break;case -3:$z=8;break;}$m[$k]=$t?$q[0][$x][$z]:$q[1][$z];}return$m;}
echo _('This is some correct text. It is too correct. Please un-correctify it.');

After testing, please, tell me if it is a valid answer.

It doesn't seem to affect capital letters at all.

The capital letters are unaffected in the example. But yes, it doesn't. But also notice that I said that it KINDA works.

C#, 581 bytes
using System;class B{static void Main(){var z=Console.ReadLine();var r=new Random();foreach(char C in z){String o;if(r.Next(10)==0){int w=r.Next(3);o=w==0?C+""+C:w==1?"":f(C,r);}else{o=C+"";}Console.Write(o);}Console.ReadLine();}static string f(char C,Random r){string[]k={"00000000000","0qwertyuiop0","0asdfghjkl0","00zxcvbnm0","000000000"};char L=char.ToLower(C);char h='0';for(int i=1;i<4;i++){var d=k[i].IndexOf(L);if(d!=-1){while(h=='0'){int n=r.Next(4);h=n==0?k[i][d-1]:n==1?k[i][d+1]:n==2?k[i-1][d]:k[i+1][d];}h=char.IsUpper(C)?char.ToUpper(h):h;return h+"";}}return C+"";}}

and in a more readable format:
using System;

class A
{
    static void Main()
    {
        var z = Console.ReadLine();
        var r = new Random();

        foreach (char C in z)
        {
            String o;

            if (r.Next(10) == 0)
            {
                int w = r.Next(3);
                o = w == 0 ? C + "" + C :
                    w == 1 ? "" :
                             f(C, r);
            }
            else
            {
                o = C + "";
            }

            Console.Write(o);
        }
    }

    static string f(char C, Random r)
    {
        string[] k = {
                            "00000000000",
                            "0qwertyuiop0",
                            "0asdfghjkl0",
                            "00zxcvbnm0",
                            "000000000"};
        char L = char.ToLower(C);
        char h = '0';

        for (int i = 1; i < 4; i++)
        {
            var d = k[i].IndexOf(L);

            if (d != -1)
            {
                while (h == '0')
                {
                    int n = r.Next(4);

                    h = n == 0 ? k[i][d - 1] :
                        n == 1 ? k[i][d + 1] :
                        n == 2 ? k[i - 1][d] :
                                 k[i + 1][d];
                }
                h = char.IsUpper(C) ? char.ToUpper(h) : h;
                return h + "";
            }
        }
        return C + "";
    }
}

PHP, 326 320 318 315 chars
$h=array(qs,vhn,vxf,sefx,wrd,drgc,fthv,gyjb,uko,hukn,jilm,ok,nk,bjm,ilp,o,aw,etf,awdz,rgy,yji,cgb,qse,zdc,thu,sx);$a=x.$argv[1];for(;$d=$a[++$b];)echo!rand(0,9)&&($c=ord($d)-65)?(!($g=rand(0,($e=($c>-1&&$c<26)or$c>31&&$c<58)+1))?$d.$d:($g<2?"":(($j=$i[rand(0,strlen($i=$h[$c-!$e*32]))])&&$e?strtoupper($j):$j))):$d;

And a more readable and commented version:
// $a   input
// $b   char iterator
// $c   current char ascii value
// $d   current char
// $e   is uppercase
// $g   rand() output
// $h   char displacement
// $i   current character in $h
// $j   temporary var for uppercasing

// the neighbouring characters of a-z, in alphabetical (and ASCII) order
$h=array(qs,vhn,vxf,sefx,wrd,
    drgc,fthv,gyjb,uko,hukn,
    jilm,ok,nk,bjm,ilp,
    o,aw,etf,awdz,rgy,
    yji,cgb,qse,zdc,thu,
    sx);
// input from argument
$a=x.$argv[1];

for(;$d=$a[++$b];)
    echo!rand(0,9)&&($c=ord($d)-65)? /* 10% chance, read char ASCII value - 65 into $c */
        (!($g=rand(0,($e=($c>-1&&$c<26)or$c>31&&$c<58)+1))?
          /* random number from 0 to 2 (if alphabetic) or 0 to 1 stored in $g */
            $d.$d: /* double char if $g = 0 */
            ($g<2?
                "": /* omit char if $g = 1*/
                (($j=$i[rand(0,strlen($i=$h[$c-!$e*32]))])&&$e?
                  /* $j = random neighbour of the current char */
                    strtoupper($j): /* uppercase $j */
                    $j)))
        :$d; /* keep char */

Still could be improved, I suppose.
-2, -3 thanks to Ismael Miguel

Where you have (!($g=rand(0,($e=($c>-1&&$c<26)or$c>31&&$c<58)?2:1)) change for (!($g=rand(0,($e=($c>-1&&$c<26)or$c>31&&$c<58)+1))? and you will save 2 bytes.

Where you have ($e?0:32), replacing with 32*!!$e (notice the lack of parenthesis) save 2 bytes. If $e is ALWAYS boolean, you can do 32*!$e and you save 3 bytes. This will work cause php has arithmetic precedence. This means that multiplications and divisions are made before any addition and subtraction.

Java (475 bytes)
This is my try in the verbose language that is Java. Getting random numbers is quite long in Java, and the mapping isn't really efficient. It can probably be improved.
import static java.lang.Math.*;public class T{public static void main(String[]a){String z="",v;for(char c:a[0].toCharArray()){double g=random()*60;if(g>=6)z+=c;else{boolean u='A'<=c&c<='Z',l='a'<=c&c<='z';if(g<(l|u?2:3))z+=""+c+c;else if((l|u)&g<4){v="qs,hnv,fvx,efsx,drw,cdgr,fhtv,kou,bgjy,hknu,ijlm,ko,kn,bjm,ilp,o,aw,eft,adwz,gry,ijy,bcg,eqs,cdz,htu,sx".split(",")[u?c-'A':c-'a'];c=v.charAt((int)(random()*v.length()));z+=u?(char)(c-'a'+'A'):c;}}}System.out.println(z);}}

Usage:
java T "This is some correct text. It is too correct. Please un-correctify it."

Uncompressed, accolades added:
import static java.lang.Math.*; // Need random()

public class T {
    public static void main(String[] a) {
        String z = "", v;
        for (char c : a[0].toCharArray()) {
            double g = random() * 60; // Compute random only once for two cases.
            if (g >= 6) {
                // 90% must be correct (accolades are stripped)
                // so we just copy the character.
                z += c;
            } else {
                // These tests come often.
                boolean u = 'A' <= c & c <= 'Z', l = 'a' <= c & c <= 'z';

                // reuse the random. g is [0,6[.
                if (g < (l | u ? 2 : 3)) {
                    // If c is an ascii letter (l|u) then g must be [0,2[ ; if not, then g must be [0,3[.
                    // If those conditions are met, we duplicate the character
                    z += "" + c + c;
                } else if ((l | u) & g < 4) {
                    // if c is letter and g [2,4[ then we perform the wrong key event.
                    // I could not compress it using the keyboard mapping shorter in Java than expanding it like it is now.
                    v = "qs,hnv,fvx,efsx,drw,cdgr,fhtv,kou,bgjy,hknu,ijlm,ko,kn,bjm,ilp,o,aw,eft,adwz,gry,ijy,bcg,eqs,cdz,htu,sx".split(",")[u ? c - 'A' : c - 'a'];
                    // get a random character from the string.
                    c = v.charAt((int) (random() * v.length()));

                    // Keep the case of the character.
                    z += u ? (char) (c - 'a' + 'A') : c;
                } else { // if c is not an ascii letter or if g is [4,6[
                    // Do nothing. This else is stripped.
                }
            }
        }
        System.out.println(z);
    }
}

AutoHotkey 441 bytes
The input must be given as a command line parameter, the output is given as an error message.
Golfed version
loop, parse, 1
{
k:={1:"q",2:"w",3:"e",4:"r",5:"t",6:"y",7:"u",8:"i",9:"o",10:"p",21:"a",22:"s",23:"d",24:"f",25:"g",26:"h",27:"j",28:"k",29:"l",42:"z",43:"x",44:"c",45:"v",46:"b",47:"n",48:"m"},a:=A_LoopField,q:=r(z?3:2),z=
if r(10)!=10{
h.=a
continue
}
for x,y in k
z:=y=a?x:z
if q=1
h.=a a
if q=3
{
Loop{
t:=r(4),w:=z+(t=1?20:t=2?-20:t=3?1:-1)
} until k.HasKey(w)
h.=k[w]
}
}
throw % h
r(n){
Random,w,1,n
return w
}
Un-golfed and annotated version
(difference is that this version has more white space and the variable assignments are on separate lines for readability.)
k:={1:"q",2:"w",3:"e",4:"r",5:"t",6:"y",7:"u",8:"i",9:"o",10:"p",21:"a",22:"s",23:"d",24:"f",25:"g",26:"h",27:"j",28:"k",29:"l",42:"z",43:"x",44:"c",45:"v",46:"b",47:"n",48:"m"}
loop, parse, 1
{
    a:=A_LoopField
    ;get a random number from 1-10 and check if it is 10
    ;  if it isn't skip the rest of this iteration
    if r(10)!=10
    {
        h.=a
        continue
    }

    ;check if the current character is in the k
    z=
    for x,y in k
        z:=y=a?x:z

    ;choose a random number to decide what typo to do
    q:=r(z?3:2)
    if q=1
        h.=a a ;duplicate the key
    if q=3
    {
        ;the keyboard array is set up so that by adding or subtracting
        ;  20 from the index you are moving up or down a row
        ;  and by adding or subtracting 1 you move right or left
        ;  then you just need to check if the adjusted index
        ;  is valid
        Loop
        {
            t:=r(4)
            w:=z+(t=1?20:t=2?-20:t=3?1:-1)
        } until if k.HasKey(w)
        h.=k[w]
    }
}
;display the string as an error message
throw % h
r(n)
{
    Random,w,1,n
    return w
}

With which programs does this work?

It is run by AutoHotkey.exe.   http://www.autohotkey.com/


text:
Euler's Front 9

Project Euler is another fun programming challenge site to compete (well, play) on.  Early problems start off gently, but then explode in difficulty beyond the first hundred or so. The first few problems have some commonality between finding primes, multiples, and factors, so there could be some interesting code micro-reuse opportunities to toy with.
So, write a program that solves, using no a priori knowledge, any of the first 9 problems.

The problem is selected by the user, ASCII '1' through '9', inclusive, via an argument when calling or standard input while running.  (You can compute all the answers, but only show one.)
The correct answer must be printed on a new line, in base 10, using ASCII.
Programs should execute in less than a minute (PE suggestion).
By "no a priori knowledge", I mean your code must derive the answer without external resources‡.  A program like this would be considered invalid (otherwise correct though, assuming I didn't make a typo):
print[233168,4613732,6857,906609,232792560,25164150,104743,40824,31875000][input()-1]

‡for problem #8 (involves a 1000-digit number), you may read the number from an external file, just specify how it's stored (e.g. binary, text, header, imported module) and/or include it in your answer post (does not count towards the length of the main program).
Score is by bytes.
Fifteen Unicorn Points™ awarded to the byte-count leader after 2 weeks.

Python, 505
import f
A,B,C,D=map(range,[22,1000,101,500])
R=reduce
M=int.__mul__
a=x=0
b=1
n=2
p=[]
while b<=4e6:a,b=b,a+b;x+=b*(b%2<1)
while len(p)<=1e4:p+=[n]*all(n%i for i in p);n+=1
q=y=R(M,p[:8])
while any(y%(i+1)for i in A):y+=q
print[
    sum(i for i in B if i%3*(i%5)<1),
    x,
    max(i for i in p if 600851475143%i<1),
    max(a*b for a in B for b in B if`a*b`==`a*b`[::-1]),
    y,
    sum(C)**2-sum(i**2for i in C),
    p[-1],
    max(R(M,map(int,f.s[i:i+5]))for i in B),
    [a*b*(1000-a-b)for a in D for b in D if(a+b)*1e3==5e5+a*b][0]
][input()-1]

Whitespace is added to the last line for readability. The 1000-digit number is imported from a module named f.py containing the line:
s="7316717653133062491922511967442657474235534919493496983520312774506326239578318016984801869478851843858615607891129494954595017379583319528532088055111254069874715852386305071569329096329522744304355766896648950445244523161731856403098711121722383113622298934233803081353362766142828064444866452387493035890729629049156044077239071381051585930796086670172427121883998797908792274921901699720888093776657273330010533678812202354218097512545405947522435258490771167055601360483958644670632441572215539753697817977846174064955149290862569321978468622482839722413756570560574902614079729686524145351004748216637048440319989000889524345065854122758866688116427171479924442928230863465674813919123162824586178664583591245665294765456828489128831426076900422421902267105562632111110937054421750694165896040807198403850962455444362981230987879927244284909188845801561660979191338754992005240636899125607176060588611646710940507754100225698315520005593572972571636269561882670428252483600823257530420752963450"

Javascript
Solution: 1785 chars
execute code with nodeJS
note on problem 7 : algorithm is ok, but it take a moment ! If someone has a more efficient solution...
z=process.argv[2]
y=console.log
if(z==1){b=0;for(i=1e3;i--;)if(i%3<1||i%5<1)b+=i;y(b)}
if(z==2){d=e=1;f=0;while(e<=4e6)g=d+e,d=e,e=g,f+=e%2<1?e:0;y(f)}
if(z==3){e=Math.sqrt(d=600851475143)|0+1;f=2;while(f<e){g=d/f;if(g==(g|0))h=f,d=g;f+=f==2?1:2}y(h)}
if(z==4){for(a=b=100,c=0;a+b<1998;){d=a++*b;if(d==(""+d).split("").reverse().join("")&&d>c)c=d;if(a>999)a=b+1,b++}y(c)}
if(z==5){for(a=c=1;c;){for(b=20;b>1;)a%b>0?b=0:b--;b==1?c=0:a++}y(a)}
if(z==6){for(a=100,b=Math.pow(a*(a+1)/2,2),d=a+1;d--;)b-=d*d;y(b)}
if(z==7){for(a=3,c=d=0;c<1e4;){for(b=a;b>2;){b=b>3?b-2:2;if(a%b<1)b=0}if(b>0)c++,d=a;a=a+2}y(d)}
if(z==8){a="7316717653133062491922511967442657474235534919493496983520312774506326239578318016984801869478851843858615607891129494954595017379583319528532088055111254069874715852386305071569329096329522744304355766896648950445244523161731856403098711121722383113622298934233803081353362766142828064444866452387493035890729629049156044077239071381051585930796086670172427121883998797908792274921901699720888093776657273330010533678812202354218097512545405947522435258490771167055601360483958644670632441572215539753697817977846174064955149290862569321978468622482839722413756570560574902614079729686524145351004748216637048440319989000889524345065854122758866688116427171479924442928230863465674813919123162824586178664583591245665294765456828489128831426076900422421902267105562632111110937054421750694165896040807198403850962455444362981230987879927244284909188845801561660979191338754992005240636899125607176060588611646710940507754100225698315520005593572972571636269561882670428252483600823257530420752963450";for(e=0,b=996;b--;){d=eval(a.substr(b,5).split("").join("*"));if(d>e)e=d};y(e)}
if(z==9){for(a=b=0;(c=a+b+Math.sqrt(a*a+b*b))!=1e3;)if(++a==500)a=0,b++;y(a,b,c-b-a)}

problem 1: 39 chars
b=0;for(i=1e3;i--;)if(i%3<1||i%5<1)b+=i

problem 2: 49 chars
d=e=1;f=0;while(e<=4e6)g=d+e,d=e,e=g,f+=e%2<1?e:0

problem 3: 85 chars
e=Math.sqrt(d=600851475143)|0+1;f=2;while(f<e){g=d/f;if(g==(g|0))h=f,d=g;f+=f==2?1:2}

problem 4: 105 chars
for(a=b=100,c=0;a+b<1998;){d=a++*b;if(d==(""+d).split("").reverse().join("")&&d>c)c=d;if(a>999)a=b+1,b++}

problem 5: 55 chars
for(a=c=1;c;){for(b=20;b>1;)a%b>0?b=0:b--;b==1?c=0:a++}

problem 6: 51 chars
for(a=100,b=Math.pow(a*(a+1)/2,2),d=a+1;d--;)b-=d*d

problem 7: 82 chars
for(a=3,c=d=0;c<1e4;){for(b=a;b>2;){b=b>3?b-2:2;if(a%b<1)b=0}if(b>0)c++,d=a;a=a+2}

problem 8: 1078 chars ^_^
a="7316717653133062491922511967442657474235534919493496983520312774506326239578318016984801869478851843858615607891129494954595017379583319528532088055111254069874715852386305071569329096329522744304355766896648950445244523161731856403098711121722383113622298934233803081353362766142828064444866452387493035890729629049156044077239071381051585930796086670172427121883998797908792274921901699720888093776657273330010533678812202354218097512545405947522435258490771167055601360483958644670632441572215539753697817977846174064955149290862569321978468622482839722413756570560574902614079729686524145351004748216637048440319989000889524345065854122758866688116427171479924442928230863465674813919123162824586178664583591245665294765456828489128831426076900422421902267105562632111110937054421750694165896040807198403850962455444362981230987879927244284909188845801561660979191338754992005240636899125607176060588611646710940507754100225698315520005593572972571636269561882670428252483600823257530420752963450"
for(e=0,b=996;b--;){d=eval(a.substr(b,5).split("").join("*"));if(d>e)e=d}

problem 9: 58 chars
for(a=b=0;a+b+Math.sqrt(a*a+b*b)!=1e3;)if(++a==500)a=0,b++

if(i%3<1||i%5<1)a+=i is shorter ! :)

Shorter problem 3: e=Math.sqrt(d=600851475143)|0+1;f=2;while(f<e){g=d/f;if(g==g|0)h=f,d=g;f+=f==2?1:2}

Shorter problem 4: for(a=b=100,c=0;a+b<1998;){d=a++*b;if(d==(""+d).split("").reverse().join("")&&d>c)c=d;if(a>999)a=b+1,b++}

@Florent : problem 3 g==g|0 doesn't work g|0 must be between parenthesis

I tried without it and worked as expected!

@Florent : the solution is in variable h, not the value returned by the script

problem 6 shorter : for(a=100,b=Math.pow(a*(a+1)/2,2),d=a+1;d--;)b-=d*d

Thx very much, Michael !

Does JS have some facility to import from another file to spare you 1kB of number?

NodeJS can load easily a file but I consider these numbers as a part of problem !

 R 684 characters
f=function(N){r=rowSums;p=function(x,y)r(!outer(x,y,`%%`));S=sum;x=c(1,1);n=600851475143;a=900:999;b=20;c=1:100;m=2:sqrt(n);M=m[!n%%m];A=a%o%a;d=3;P=2;z=1:1e3;Z=expand.grid(z,z);Y=cbind(Z,sqrt(r(Z^2)));W=gsub("\n","",xpathApply(htmlParse("http://projecteuler.net/problem=8"),"//p",xmlValue)[[2]]);switch(N,S(which(p(1:999,c(3,5))>0)),{while(tail(x,1)<4e6)x=c(x,S(tail(x,2)));S(x[!x%%2])},max(M[p(M,M)<2]),max(A[sapply(strsplit(c(A,""),""),function(x)all(x==rev(x)))],na.rm=T),{while(any(b%%1:20>0))b=b+20;b},S(c)^2-S(c^2),{while(P<=1e4){d=d+2;if(sum(!d%%2:d)<2)P=P+1};d},max(sapply(5:nchar(W),function(i)prod(as.integer(strsplit(substr(W,i-4,i),"")[[1]])))),prod(Y[r(Y)==1000,][1,]))}

Indented:
f=function(N){
    r=rowSums
    p=function(x,y)r(!outer(x,y,`%%`))
    S=sum
    x=c(1,1)
    n=600851475143
    a=900:999
    b=20
    c=1:100
    m=2:sqrt(n)
    M=m[!n%%m]
    A=a%o%a
    d=3
    P=2
    z=1:1e3
    Z=expand.grid(z,z)
    Y=cbind(Z,sqrt(r(Z^2)))
    W=gsub("\n","",xpathApply(htmlParse("http://projecteuler.net/problem=8"),"//p",xmlValue)[[2]])
    switch(N,S(which(p(1:999,c(3,5))>0)),
             {while(tail(x,1)<4e6)x=c(x,S(tail(x,2)));S(x[!x%%2])},
             max(M[p(M,M)<2]),
             max(A[sapply(strsplit(c(A,""),""),function(x)all(x==rev(x)))],na.rm=T),
             {while(any(b%%1:20>0))b=b+20;b},
             S(c)^2-S(c^2),
             {while(P<=1e4){d=d+2;if(sum(!d%%2:d)<2)P=P+1};d},
             max(sapply(5:nchar(W),function(i)prod(as.integer(strsplit(substr(W,i-4,i),"")[[1]])))),
             prod(Y[r(Y)==1000,][1,]))
    }

Usage:
> f(1)
[1] 233168
> f(2)
[1] 4613732
> f(3)
[1] 6857
> f(4)
[1] 906609
> f(5)
[1] 232792560
> f(6)
[1] 25164150
> f(7)
[1] 104743
> f(8)
[1] 40824
> f(9)
[1] 31875000

Separately:
1: 48 chars sum(which(rowSums(!outer(1:999,c(3,5),`%%`))>0))
2: 64 chars x=c(1,1);while(tail(x,1)<4e6)x=c(x,sum(tail(x,2)));sum(x[!x%%2])
3: 73 chars n=600851475143;m=2:sqrt(n);M=m[!n%%m];max(M[rowSums(!outer(M,M,`%%`))<2])
4: 88 chars a=900:999;b=a%o%a;max(b[sapply(strsplit(c(b,""),""),function(x)all(x==rev(x)))],na.rm=T)
5: 34 chars a=20;while(any(a%%1:20>0))a=a+20;a
6: 25 chars a=1:100;sum(a)^2-sum(a^2)
7: 54 chars d=3;P=2;while(P<=1e4){d=d+2;if(sum(!d%%2:d)<2)P=P+1};d
8: 181 chars
First line reads the number from the project euler website, second line actualy perform the computation.
W=gsub("\n","",xpathApply(htmlParse("http://projecteuler.net/problem=8"),"//p",xmlValue)[[2]])
max(sapply(5:nchar(W),function(i)prod(as.integer(strsplit(substr(W,i-4,i),"")[[1]]))))

9: 87 chars z=1:1e3;Z=expand.grid(z,z);Y=cbind(Z,sqrt(rowSums(Z^2)));prod(Y[rowSums(Y)==1000,][1,])

As of now, f(7) takes 2 mins to compute so it doesn't really comply to the execution time constraint. I'll try to work on that. (f(5) takes 48s on my machine)

J 245 236 232
load'n'
echo".>(<:".1!:1]1){<;._1'!+/I.+./0=5 3|,:~i.1e3!+/}:(],4&*@:{:+_2&{)^:(4e6>{:)^:_]0 2!{:q:600851475143!>./(#~(-:|.)@":"0),/*/~i.1e3!*./>:i.20!(([:*:+/)-[:+/*:)i.101!p:1e4!>./5*/\"."0 n!x:*/{.(#~1e3=+/"1)(+.,|)"0,j./~i.500'

n is a file containing the following:
n=:'7316717653133062491922511967442657474235534919493496983520312774506326239578318016984801869478851843858615607891129494954595017379583319528532088055111254069874715852386305071569329096329522744304355766896648950445244523161731856403098711121722383113622298934233803081353362766142828064444866452387493035890729629049156044077239071381051585930796086670172427121883998797908792274921901699720888093776657273330010533678812202354218097512545405947522435258490771167055601360483958644670632441572215539753697817977846174064955149290862569321978468622482839722413756570560574902614079729686524145351004748216637048440319989000889524345065854122758866688116427171479924442928230863465674813919123162824586178664583591245665294765456828489128831426076900422421902267105562632111110937054421750694165896040807198403850962455444362981230987879927244284909188845801561660979191338754992005240636899125607176060588611646710940507754100225698315520005593572972571636269561882670428252483600823257530420752963450'

TI-BASIC (Work in Progress)
For your TI-83 or TI-84 calculator
Main program, 15 bytes:
Input X:OpenLib(1):X:ExecLib:Disp Ans

Library 1 (4 bytes) does count toward the total number of bytes:
L1(Ans

Then, we have List #1:
work in progress