text:
Write a Playfair encryption program
Write a program that takes two lines of input and uses the first as a key phrase to encrypt the second according to the Playfair encryption technique.
Wikipedia describes Playfair encryption in some detail, but to avoid any ambiguity, here's a brief summary:
1. Generate a key table:
Replace all occurrences of J in the key phrase with I, then strip all non-alphabet characters and repeated characters. Insert into a 5×5 encryption table, filling the remaining cells with the rest of the alphabet (except J; we don't like J).
Example:
                                        S T A C K
                                        O V E R F
Stack Overflow  -->  STACKOVERFLW  -->  L W B D G
                                        H I M N P
                                        Q U X Y Z

2. Prepare the message to be encrypted
Replace every J with an I, strip all non-alphabet characters and split into pairs, using an X to break any pairs that contain the same letter twice. If you end up with an odd number of letters, add X at the end. (Note: Numerals have to be spelt out in full — ONE, TWO, THREE, etc. — but you can assume this has already been done for you.)
Example:
In:
The cat crept into the crypt, crapped, and crept out again.

Out:
TH EC AT CR EP TI NT OT HE CR YP TC RA PX PE DA ND CR EP TO UT AG AI NX

3. Encryption
Encrypt each pair of letters in turn. If they are in different rows and columns of the key table, replace each with the letter from the same row in the column where the other letter is found (e.g., VM⇒EI, LZ⇒GQ). If they are in the same row (or column), choose the two characters immediately to the right (or below), wrapping around if necessary (e.g., OE⇒VR, ZG⇒KP).
Example:
In:
TH EC AT CR EP TI NT OT HE CR YP TC RA PX PE DA ND CR EP TO UT AG AI NX

Out:
SI RA CA RD FM VU IC VS MO RD ZN AK EC MZ MF BC YN RD FM SV TV KB TM MY

The string produced by this process is the encrypted message, which your program should output.
Rules:

The input text and key may be obtained from stdin, command line arguments or other such sources. Hard-coded input is not allowed.
Your program must accept both upper and lower case text for the pass phrase and message.
The encrypted output may be upper or lower case.
Your program should accept key phrases of at least 64 characters in length, and message texts of at least 16 KB.
You are not required to handle non-ASCII input.
You may ignore the possibility of the letter pair XX occurring during encryption.
There is no need to add whitespace to the output of the program.
Your answer should include an example of a message, key phrase and encrypted output produced by your program.
This is a code golf challenge, so the answer with the shortest code (in bytes) will win.

NOTE: Please remember that you only need to break consecutive letters if they appear in the same pair. So for example MASSACHUSETTS should be encrypted as MA SX SA CH US ET TS — the double S has to be split, but the double T doesn't.

"we don't like J" Do you harbour similar sentiments about APL?

Gobbledygook! (Although the lack of a J in its name is creditworthy, I suppose.)

Regarding the input requirement, are function arguments allowed? (not sure if this constitutes "hard-coding") If not, can we assume that the key contains no newlines (preferrably, the plaintext too)? If not, command line args might be more viable compared to stdin.

J I*, 536 431 417 380 263 218 203 197 186 167
p=:4 :0
a=.u:65+9-.~i.26
,_2(5|,:~@|.@(=/)+$$,A.~5*1-0{=/)&.(5 5#:(~.n x,a)&i.)\(,'X'#~2|#)(({.,'X',}.)~1+2*1{&I._2{.\2=/\]) ::]^:_(n=:a(e.~#])'JI'charsub toupper)y
)

(with extensive suggestions from @algorithmshark)
example use:
   'Stack Overflow' p 'The cat crept into the crypt, crapped, and crept out again.'
SIRACARDFMVUICVSMORDZNAKECMZMFBCYNRDFMSVTVKBTMMY

splits input correctly:
   d=:(({.,'X',}.)~1+2*1{&I._2{.\2=/\]) ::]
   d^:_ 'MASSACHUSETTS'
MASXSACHUSETTS

*replace every J with an I, right?

We don't like J, but I is beautiful!

Wow, this is extraordinary.

While the first version looked a bit like witchcraft to me, this latest one is pure voodoo. Very impressive reduction.

Pop pop pop, watching keystrokes drop! If anyone wants an explanation of how this voodoo magic works, here is a link; it's too long to fit in the answer without severe cramping.

I like J now :-)

Ruby, 461 411 366 359 352 346 330 characters
k,m=$<.map{|x|x.tr(?j,?i).upcase.tr('^A-Z','').chars}
t=[*((k&k)|[*?A..?Z]-[?J]).each_slice(5)]
m=(m*'').gsub(/(.)\1/,'\1X\1').chars
c=->n{[t.index{|r|k=r.index n},k]}
$><<(m.size%2<1?m:m+[?X]).each_slice(2).map{|p,q|a,b,d,e=*c[p],*c[q]
a==d ?[t[a][(b+1)%5],t[d][(e+1)%5]]:b==e ?[t[(a+1)%5][b],t[(d+1)%5][e]]:[t[a][e],t[d][b]]}*''

Thanks to @daniero for saving... err, a lot of bytes. \o/
Here's the ungolfed code:
key = gets.chomp
msg = gets.chomp
transform = ->str{
    str.gsub! 'j', 'i'
    str.upcase!
    str.gsub! /[^A-Z]/, ''
    str.split('')
}

# 1. Generate a key table
key = transform[key]
chars = key.uniq + ([*?A..?Z] - key - ['J'])
tbl = Array.new(5) {
    Array.new(5) {
        chars.shift
    }
}

# 2. Prepare the message
msg = transform[msg]
msg = msg.join('').gsub(/(.)\1/){ "#{$1}X#{$1}" }.split('')
msg = (msg.length % 2 == 0 ? msg : msg + ['X']).each_slice(2).to_a

# 3. Encryption
coords = ->chr{
    i = -1
    [tbl.index{|row| i = row.index chr}, i]
}
msg.map! do |c1, c2|
    c1, c2 = coords[c1], coords[c2]
    if c1[0] == c2[0]
        # same row
        [tbl[c1[0]][(c1[1] + 1) % 5], tbl[c2[0]][(c2[1] + 1) % 5]]
    elsif c1[1] == c2[1]
        # same column
        [tbl[(c1[0] + 1) % 5][c1[1]], tbl[(c2[0] + 1) % 5][c2[1]]]
    else
        # neither
        [tbl[c1[0]][c2[1]], tbl[c2[0]][c1[1]]]
    end
end

# Output!
puts msg.join

Here's some sample outputs:
llama@llama:...code/ruby/ppcg23276playfair$ printf 'Stack Overflow\nThe cat crept into the crypt, crapped, and crept out again.\n' | ./playfair.rb; printf 'This is a password!\nProgramming Puzzles and Code Golf is a Stack Exchange site.\n' | ./playfair.rb
SIRAVXRDFMVUUYVSBLRDZNYVECMZMFBCYNRDFMSVTVKBVBMY
WDDEDSXIXOQFBTUYVQFISQWGRPFBWMESATAHHGMBVEITQFFISHMI

Looks nice, but there's room for improvement: On the first line there's no need to "cast" chars into an array, assuming you're using Ruby 2. Also you can use & as a set operator instead of tr: t=->s{s.gsub(?j,?i).upcase.chars&[*?A..?Z]} (7 bytes saved). The two next lines can be joined with something like k,m=[1,2].map{t[gets.chop]} (note chop rather than chomp).

Using & also eliminates the need for uniq later. And the chars to array thing also applies to line 6.

@daniero Right, this was done a looong time ago, so there's probably lots more improvements I could make. Thanks for the tips; time to revisit this!

Yeah, I see that :) I stumbled upon the challenge and I immediately wanted to take a stab at it in Ruby, until I saw your answer.. The complexity of the code kind of scared me out of it, but I had to take a look at it :)

@daniero Unfortunately, tr to & on line 1 doesn't work because m can't be uniqified. However, k.uniq can be shortened to (k&k) (1 byte off).

Aw, you're right. I didn't fully understand the usage of m.. Dang, that's some confusing code :D

@daniero Haha, yeah, even I'm having trouble understanding my own code. I shaved 50 bytes off, but I'm fairly certain way more is possible; I've got to go for now though.

@daniero 115 characters later... I'm still 5 chars above the C answer >_<. See any more optimizations?

Oh wow, that's a lot of golfing :) I think the second line is equivalent to c=(k&k)|[*?A..?Z]-[?J] ..? And the third line is just c.each_slice(5), isn't it? :)

@daniero I can't believe I missed each_slice there. I even used it later in the code! Thanks; Ruby is finally in its rightful place: shorter than C ;)

C: 495 401 355 341 characters
It's just a rough sketch as of now. I should be able to shave off at least a hundred characters.
Goal accomplished: more than a hundred characters (154 as of now) have mysteriously vanished from the code.
p[25],l[96],a=1,b,c;o(x,y){putchar(p[x%5^y%5?x/5*5+(x/5^y/5?y:x+1)%5:(x+5)%25]);}main(){for(;a&&((a=(b=getchar())>31)||(b=65))||b++<90;c=0)for(b&=-33;b/65-b/91&&p[c]^b-(b==74);p[c++]||(p[--c]=b-(b==74),l[b]=c));for(;b=getchar(),b=b>31?b&-33:(c=88),b=b/65-b/91?a?a^b?(c*=c==88,b):(c=b,88):(a=b,0):0,a&b&&(o(a=l[a],b=l[b]),o(b,a),a=c),c^88;);}

With some pleasant whitespace:
p[25],l[96],a=1,b,c;
o(x,y){
    putchar(p[
        x%5^y%5
            ?x/5*5+(x/5^y/5?y:x+1)%5
            :(x+5)%25
    ]);
}
main(){
    for(;
        a&&(
            (a=(b=getchar())>31)||
            (b=65)
        )||b++<90;
        c=0
    )for(
        b&=-33;
        b/65-b/91&&
        p[c]^b-(b==74);
        p[c++]||(
            p[--c]=b-(b==74),
            l[b]=c
        )
    );
    for(;
        b=getchar(),
        b=b>31
            ?b&-33
            :(c=88),
        b=b/65-b/91
            ?a
                ?a^b
                    ?(c*=c==88,b)
                    :(c=b,88)
                :(a=b,0)
            :0,
        a&b&&(
            o(a=l[a],b=l[b]),
            o(b,a),
            a=c
        ),
        c^88;
    );
}

I wrote the first iteration of the program on the verge of falling asleep, so it had a lot of superfluous meaningless statements and such. Most of that is rectified, but there are quite a few areas where improvement is most definitely possible.

Well this is making my effort look very bad!! Looking forward to see how far you can go with this :-)

Haskell - 711
Demo:
[timwolla@/data/workspace/haskell/PCG]ghc pcg-23276.hs
[1 of 1] Compiling Main             ( pcg-23276.hs, pcg-23276.o )
Linking pcg-23276 ...
[timwolla@/data/workspace/haskell/PCG]./pcg-23276 "Stack Overflow" "The cat crept into the crypt, crapped, and crept out again."
SIRACARDFMVUICVSMORDZNAKECMZMFBCYNRDFMSVTVKBTMMY

Code:
import Data.List
import Data.Char
import Data.Maybe
import System.Environment
main=do a<-getArgs
    putStrLn$concat$map(x (a!!0))$map(\x->if (length x)==1 then x++"X"else x)$s 2$concat$map(\x->if (length x)==1then x else intersperse 'X' x)$group$p (a!!1)
p=map(\x->if x=='J' then 'I' else x).filter(isUpper).map toUpper
k x=y++(delete 'J'$['A'..'Z']\\y)where y=nub$p x
u l m=(div i 5,mod i 5)where i=fromJust$elemIndex l$k m
x y z
    |a/=c&&b/=d=(e!!(a*5+d)):(e!!(c*5+b)):[]
    |a==c=(e!!(a*5+(mod(b+1)5))):(e!!(c*5+(mod(d+1)5))):[]
    |True=(e!!((5*(mod(a+1)5))+b)):(e!!((5*(mod(c+1)5))+d)):[]
    where
        o=u(z!!0)y
        t=u(z!!1)y
        a=fst o
        b=snd o
        c=fst t
        d=snd t
        e=k y
s _ []=[]
s n l=(take n l):(s n(drop n l))

Large version:
import Data.List
import Data.Char
import Data.Maybe

encryptAll key text = map (encrypt key) (transformValue text)

clean x = map (\x -> if x == 'J' then 'I' else x) $ filter (isUpper) $ map (toUpper) x
transformKey x = y ++ (delete 'J' $ ['A'..'Z'] \\ y)
    where y = nub (clean x)

transformValue x = map (\x -> if (length x) == 1 then x ++ "X" else x) $ split 2 $ concat $ map (\x -> if (length x) == 1 then x else intersperse 'X' x) $ group $ clean x

search letter key = (div index 5, mod index 5)
    where index = fromJust $ elemIndex letter $ transformKey key

encrypt key chars
    | rowA /= rowB && colA /= colB = (key' !! (rowA * 5 + colB)) : (key' !! (rowB * 5 + colA)) : []
    | rowA == rowB = (key' !! (rowA * 5 + ((colA + 1) `mod` 5))) : (key' !! (rowB * 5 + ((colB + 1) `mod` 5))) : []
    | otherwise = (key' !! ((5 * ((rowA + 1) `mod` 5)) + colA)) : (key' !! ((5 * ((rowB + 1) `mod` 5)) + colB)) : []
    where
        rowA = fst $ search (head chars) key
        colA = snd $ search (head chars) key
        rowB = fst $ search (last chars) key
        colB = snd $ search (last chars) key
        key' = transformKey key

-- http://stackoverflow.com/a/12876438/782822
split :: Int -> [a] -> [[a]]
split _ [] = []
split n l
  | n > 0 = (take n l) : (split n (drop n l))
  | otherwise = error "Negative n"

Matlab - 458 chars
function p=pf(k,p)
k=[upper(k),65:90];k(k==74)=73;k(k<65|k>90)='';[~,i]=unique(k,'first');k=reshape(k(sort(i)),5,5);e=[k,k(:,1);k(1,:)];p=upper(p);p(p==74)=73;p(p<65|p>90)='';n=length(p);for i=1:2:n
if i<n&&p(i)==p(i+1)p=[p(1:i),88,p(i+1:end)];end
n=length(p);end
if mod(n,2)p=[p,88];n=n+1;end
for i=1:2:n [x,y]=find(k==p(i));[w,z]=find(k==p(i+1));p(i:i+1)=[k(w,y),k(x,z)];if x==w p(i:i+1)=[e(w,y+1),e(x,z+1)];end
if y==z p(i:i+1)=[e(x+1,z),e(w+1,y)];end
end

Some examples:
octave:180> pf('Stack Overflow', 'The cat crept into the crypt, crapped, and crept out again.')
ans = SIRACARDFMVUICVSMORDZNAKECMZMFBCYNRDFMSVTVKBTMMY

octave:181> pf('This is a password!','Programming Puzzles and Code Golf is a Stack Exchange site.')
ans = WDDEDSXIXOQFBTUYVQFISQWGRPFBWMESATAHHGMBVEITQFFISHMI

octave:182> pf('Matlab needs lambdas', 'Who thought elseif is good syntax?')
ans = XGQMFQPKQDSACDKGRIFPQNILDMTW

Pyth - 111
Too late for competing, I just wanted to share. Here's
the encoder
and
decoder
L@G:rb0\j\iJ{y+wGKywWhZ=Zh*2xlR{RcK2 1IhZ=KXZK\x;M@J+G?!eH5?!hH?q4%G5_4 1eHVcK2A,xJhNxJeN=Z-V.DH5.DG5pgGZpgH_RZ

Explanation:
L    b                              L defines common method y(b); 2 calls helps us saving two bytes
    r 0                             lowercase r(b,0)
   :   \j\i                         : replaces all occurrences of "j" with "i"
 @G                                 strips all non-alphabetic characters; G = pyth built-in alphabet

    w                               first input argument
   + G                              appends the alphabet (G)
  y                                 calls y(b)
 {                                  { makes set (removes duplicated characters)
J                                   assigns result to 'J' (KEY VARIABLE)

Kyw                                 assigns output from y(second input argument) to 'K' (TEXT VARIABLE)

WhZ                         ;       While (Z+1 != 0) <-> While (Z != -1) <-> While mismatched items found
             cK2                    list of K pairs.                    e.g. 'ABCCDDE' -> [AB, CC, DD, E]
         lR{R                       l length of { unique characters.    e.g. [2, 1, 1, 1]
        x       1                   1-length first index.               e.g. 1
     h*2                            *2+1 (Index in K)                   e.g. 3 'ABC CDDE'
   =Z                               Assigns to 'Z'
                  IhZ               if (Z != -1) <-> if (mismatched found)
                     =KXZK\x        X Inserts at Z index in K an 'x' and reassigns to 'K'  e.g. 'ABCXC...'

M                                   M defines function g(G, H) where G index H vector (INDEX CONVERSION)
     ?!eH                           if (same col)
         5                              then +5
         ?!hH                           else { if (same row)
             ?q4%G5                             then if (last col)
                   _4                               then -4
                      1                             else +1
                       eH                       else col
   +G                               index += increment
 @J                                 J[index]

VcK2                                V loops over cK2 list of K pairs
     ,xJhNxJeN                      x returns pair members index in J
    A                               A assigns G = xJhN, H = xJeN
                  .DH5              .D returns [row, col] = [i/5,i%5] of 5xn matrix from index of H
                      .DG5          idem. of G
                -V                  Subtracts vectors (RELATIVE POSITION)
              =Z                    Assigns to 'Z'
                          pgGZ          p prints g(G, Z) return value
                              pgH_RZ    p prints g(H, _RZ) return value, and _R changes signs of Z vector

Sample Key/Message/Output:
Stack Overflow
Gottfried Leibniz is famous for his slogan Calculemus, which means Let us calculate. He envisioned a formal language to reduce reasoning to calculation.
lfaukvvnrbbomwpmupkoexvqkovfimaqohflcmkcdsqwbxqtlintinbehcbovttksbtybsavmormwuthrhrbkevfxebqbspdxtbfsvfrwyarfrctrhmpwkrssbtybsvurh

C, 516
Linefeeds added for improved legibility presentation. (Legibility went out the window, I'm afraid.)
#define Z(u,v) putchar(o[u]),putchar(o[v])
#define X while((Y=getchar())>31){Y&=223;if(Y==74)Y--;if(Y<65||Y>90
P,L,A,Y,f,a,i,r,c=512,o[25],d[2],*e=o;Q(){for(i=0;o[i]!=d[0];i++);i-=(f=i%5);
for(r=0;o[r]!=d[1];r++);r-=(a=r%5);if(f==a)Z(f+(i+5)%25,a+(r+5)%25);
else if(i==r)Z((f+1)%5+i,(a+1)%5+r);else Z(a+i,f+r);}main(){X||c&(A=1<<Y-65))continue;
c|=A;*e++=Y;}A=1;Y=65;for(P=0;P<25;P++){if(!(c&A))*e++=Y;
if(++Y==74)Y++,A+=A;A+=A;}L=0;X)continue;if(L&&Y==*d)d[1]=88,Q(),*d=Y;
else d[L]=Y,L=1-L;if(!L)Q();}if(L)d[1]=88,Q();}

Example:
$ ./pf
Playfair
The quick brown fox jumps over the lazy dog
QMHNPEKSCBQVTPSVEPEFTQUGDOKGAYXFRTKV

Python 3, 709 705 685 664
Accepts input from stdin.
from string import ascii_uppercase as a
from itertools import product as d
import re
n=range
k=input()
p=input()
t=lambda x: x.upper().replace('J','I')
s=[]
for _ in t(k+a):
 if _ not in s and _ in a:
  s.append(_)
m=[s[i:i+5] for i in n(0,len(s),5)]
e={r[i]+r[j]:r[(i+1)%5]+r[(j+1)%5] for r in m for i,j in d(n(5),repeat=2) if i!=j}
e.update({c[i]+c[j]:c[(i+1)%5]+c[(j+1)%5] for c in zip(*m) for i,j in d(n(5),repeat=2) if i!=j})
e.update({m[i1][j1]+m[i2][j2]:m[i1][j2]+m[i2][j1] for i1,j1,i2,j2 in d(n(5),repeat=4) if i1!=i2 and j1!=j2})
l=re.findall(r'(.)(?:(?!\1)(.))?',''.join([_ for _ in t(p) if _ in a]))
print(''.join(e[a+(b if b else 'X')] for a,b in l))

Example:
mfukar@oxygen[/tmp]<>$ python playfair.py
Stack Overflow
The cat crept into the crypt, crapped, and crept out again.
SIRACARDFMVUICVSMORDZNAKECMZMFBCYNRDFMSVTVKBTMMY

Also works perfectly in Python 2.5 :-)

JS (node) - 528 466
k=n(2)+'ABCDEFGHIKLMNOPQRSTUVWXYZ',p=n(3),t=o=''
for(i=0;i<k.length;i++)if(!~t.indexOf(k[i]))t+=k[i]
for(i=0;i<p.length;){a=f(c=p[i++]),b=f(!(d=p[i])||c==d?'X':(i++,d))
if(a.x==b.x)a.y=(a.y+1)%5,b.y=(b.y+1)%5
else if(a.y==b.y)a.x=(a.x+1)%5,b.x=(b.x+1)%5
else a.x=b.x+(b.x=a.x,0)
o+=t[a.x+a.y*5]+t[b.x+b.y*5]}console.log(o)
function f(c){x=t.indexOf(c);return{x:x%5,y:x/5|0}}
function n(a){return process.argv[a].toUpperCase().replace(/[^A-Z]/g,'').replace(/J/g,'I')}

Sample output:
$ node playfair "Stack Overflow" "The cat crept into the crypt, crapped, and crept out again."
SIRACARDFMVUICVSMORDZNAKECMZMFBCYNRDFMSVTVKBTMMY
$ node playfair "Lorem ipsum" "dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat."
CRORSDAHGAMQKPXDOFQMQAMSBSSPUPBPTDMOAHURNRCRLUAULRGNMLCPLSKDSBSBSQQAHMIGRERYMQCROREMAGDTSZIMUHAIAQRQALSGLAHSLZRQPIETAPDXRPNMSFRYMEBPZGHARKIEMIOGROIGREPUHSUPAQIMUHAPUOYRPGRLLRCRKPXDUYAINZ

Good point about the regex issue — I'll ad a note to the question

There's a problem with your second example — the pair of letters at characters 75 and 76 is encoded as UU. Looks like there was a repeated E that you should have split.

You're right, I shot myself in the foot. The problem is with only looking at pairs but ending up off by one after an insertion.

Python: 591 bytes
import sys
l=list
n=len
a=[sys.stdin.readline().upper().replace('J','I') for i in (1,2)]
b=l('ABCDEFGHIKLMNOPQRSTUVWXYZ')
def z(x):
    a=0
    if x in b:
        b.remove(x)
        a=1
    return a
c=l(filter(z,a[0]))+b
d=[x for x in a[1] if x in c]
e=1
while e<n(d):
    if d[e-1]==d[e]:
        d.insert(e,'X')
    e+=2
if n(d)%2>0:
    d+='X'
def y(i):
    z=c.index(d[i])
    return z/5,z%5
x=lambda i,j:c[(i%5)*5+(j%5)]
def w(i):
    e,f=y(i)
    g,h=y(i+1)
    if e==g:
        z=x(e,f+1)+x(g,h+1)
    elif f==h:
        z=x(e+1,f)+x(g+1,h)
    else:
        z=x(e,h)+x(g,f)
    print z,
e=0
while e<n(d):
    w(e)
    e+=2
print

This uses stdin to get the key and the message in that order.  I hope it's not cheating to use a flat list to store the encryption matrix, because that made working with the matrix pretty simple.  Here are some example runs:
>python playfair.py
Stack Overflow
The cat crept into the crypt, crapped, and crept out again.
SI RA CA RD FM VU IC VS MO RD ZN AK EC MZ MF BC YN RD FM SV TV KB TM MY

>python playfair.py
Stack Overflow
The quick red fox jumps over the lazy brown dog.
SI OX TU KS FR GR EQ UT NH OL ER VC MO BS QZ DE VL YN FL

I believe you can shorten z to lambda x:0if b not in x else b.remove(x)or 1. There's also quite a lot of whitespace you can get rid of. That would also let you move it directly into the filter call instead of defining it outside .

Java - 791
My first golf, so any criticism is welcome. Using Java because I shouldn't. It doesn't seem so bad; less than double the size of the current leader. I was expecting it to be bigger since it's, well, Java :)
public class P{static String c(String s){return s.toUpperCase().replace('J','I').replaceAll("[^A-Z]","");}static int f(char[]a, char n){for(int i=0;i<a.length;i++)if(a[i]==n)return i;return -1;}public static void main(String[]a){int i=0,k,l;char j=0;String g=c(a[0]);char[]e,b,h=c(a[1]).toCharArray();b=new char[25];for(;j<g.length();j++)if(j==g.indexOf(g.charAt(j)))b[i++]=g.charAt(j);for(j=65;i<25;j++)if(f(b,j)<0&&j!=74)b[i++]=j;e=new char[h.length*2];for(i=0,j=0;j<h.length;){if(i%2>0&&h[j]==h[j-1])e[i++]=88;e[i++]=h[j++];}if(i%2>0)e[i++]=88;for(j=0;j<i;j+=2){k=f(b,e[j]);l=f(b,e[j+1]);if(k/5==l/5){e[j]=b[(k/5*5)+((k+1)%5)];e[j+1]=b[(l/5*5)+((l+1)%5)];}else if(k%5==l%5){e[j]=b[(k+5)%25];e[j+1]=b[(l+5)%25];}else{e[j]=b[(k/5*5)+(l%5)];e[j+1]=b[(l/5*5)+(k%5)];}}System.out.println(e);}}

With auto-format:
public class P {
    static String c(String s) {
        return s.toUpperCase().replace('J', 'I').replaceAll("[^A-Z]", "");
    }

    static int f(char[] a, char n) {
        for (int i = 0; i < a.length; i++)
            if (a[i] == n)
                return i;
        return -1;
    }

    public static void main(String[] a) {
        int i = 0, k, l;
        char j = 0;
        String g = c(a[0]);
        char[] e, b, h = c(a[1]).toCharArray();
        b = new char[25];
        for (; j < g.length(); j++)
            if (j == g.indexOf(g.charAt(j)))
                b[i++] = g.charAt(j);
        for (j = 65; i < 25; j++)
            if (f(b, j) < 0 && j != 74)
                b[i++] = j;
        e = new char[h.length * 2];
        for (i = 0, j = 0; j < h.length;) {
            if (i % 2 > 0 && h[j] == h[j - 1])
                e[i++] = 88;
            e[i++] = h[j++];
        }
        if (i % 2 > 0)
            e[i++] = 88;
        for (j = 0; j < i; j += 2) {
            k = f(b, e[j]);
            l = f(b, e[j + 1]);
            if (k / 5 == l / 5) {
                e[j] = b[(k / 5 * 5) + ((k + 1) % 5)];
                e[j + 1] = b[(l / 5 * 5) + ((l + 1) % 5)];
            } else if (k % 5 == l % 5) {
                e[j] = b[(k + 5) % 25];
                e[j + 1] = b[(l + 5) % 25];
            } else {
                e[j] = b[(k / 5 * 5) + (l % 5)];
                e[j + 1] = b[(l / 5 * 5) + (k % 5)];
            }
        }
        System.out.println(e);
    }
}

Sample output:
>java P "Stack Overflow" "The cat crept into the crypt, crapped, and crept out again."
SIRACARDFMVUICVSMORDZNAKECMZMFBCYNRDFMSVTVKBTMMY

>java P "Write a PlayFair encryption program" "Write a program that takes two lines of input and uses the first as a key phrase to encrypt the second according to the Playfair encryption technique."
RITEWFCPGMWPGEBLYTWYQTXWINOLMWVNLECAXRNBURZWXWQILEWUWYWNQTFLDINWWEMICOTPYRIKWZRMGCBPGUOGPUWOKYGIQILYPFAPTIWMDPFLETGCEWODOWDZTZ

Perl, 265
Very straightforward.
chomp(($k,$_)=map{uc=~y/A-Z//cdr=~y/J/I/r}<>."@{[A..Z]}",~~<>);1while$k=~s/((.).*)\2/$1/;while(/(.)((?=\1|$)|(.))/g){($a,$b,$c,$d)=map{$e=index$k,$_;5*int$e/5,$e%5}$1,$3||X;print substr$k,$_%25,1 for$a-$c?$b-$d?($a+$d,$c+$b):($a+5+$b,$c+5+$d):(++$b%5+$a,++$d%5+$c)}

Indented:
chomp(($k,$_)=map{uc=~y/A-Z//cdr=~y/J/I/r}<>."@{[A..Z]}",~~<>);
1while$k=~s/((.).*)\2/$1/;
while(/(.)((?=\1|$)|(.))/g){
    ($a,$b,$c,$d)=map{$e=index$k,$_;5*int$e/5,$e%5}$1,$3||X;
    print substr$k,$_%25,1 for
        $a-$c
            ?$b-$d
                ?($a+$d,$c+$b)
                :($a+5+$b,$c+5+$d)
            :(++$b%5+$a,++$d%5+$c)
}

PHP 582
<? list($i,$k,$v)=array_map(function($v){return str_split(preg_replace('#[^A-Z]#','',strtr(strtoupper($v),'J','I')));},$argv);@$i=array_flip;$k=$i($k)+$i(range('A','Z'));unset($k['J']);$k=array_keys($k);$q=$i($k);for($i=1;$i<count($v);$i+=2){if ($v[$i-1]==$v[$i]){array_splice($v,$i,0,'X');}}if(count($v)%2)$v[]='X';for($i=1;$i<count($v);$i+=2){$c=(int)($q[$v[$i-1]]/5);$d=$q[$v[$i-1]]%5;$e=(int)($q[$v[$i]]/5);$f=$q[$v[$i]]%5;if($c==$e){$d=($d+1)%5;$f=($f+1)%5;}elseif($d==$f){$c=($c+1)%5;$e=($e+1)%5;}else{$t=$f;$f=$d;$d=$t;}$v[$i-1]=$k[$c*5+$d];$v[$i]=$k[$e*5+$f];}echo join($v);

Ungolfed
Decoder
outputs
$ php playfair.php "Stack Overflow" "The cat crept into the crypt, crapper, and crept out again."
SIRACARDFMVUICVSMORDZNAKECMZMFECYNRDFMSVTVKBTMMY
$ php playfair.php "This was codegolf?" "The full J answers is shorter than my preparation code :("
HIOKVGFHCMWTKZWSIYWIEPWAMWTCPNXQZKMOMEHSCPODEA

CoffeeScript - 610
Demo:
[timwolla@/data/workspace/js/PCG]coffee pcg-23276.coffee "Stack Overflow" "The cat crept into the crypt, crapped, and crept out again."
SIRACARDFMVUICVSMORDZNAKECMZMFBCYNRDFMSVTVKBTMMY

Code:
String::r=String::replace
_=(t,l)->
    for r in[0..4]
        for c in[0..4]
            return [r,c]if l is t[r][c]
K = {}
K[c]=c for c in (process.argv[2].toUpperCase().r(/J/g, 'I').r x=/([^A-Z])/g, '')
for i in[1..26]when i!=10
    c=String.fromCharCode 64+i
    K[c]=c
K=(c for c of K)
t=(K[s..s+4]for s in[0..24]by 5)
v=process.argv[3].toUpperCase().r(/J/g,'I').r(x,'').r(/(.)\1/g,'$1X$1').r /(..)/g, '$1 '
o=""
for p in v.trim().r(/\s([A-Z])$/, ' $1X').split /\s/
    [a,b]=p.split '';[d,f]=_ t,a;[e,g]=_ t,b
    o+=if d!=e&&f!=g
        t[d][g]+t[e][f]
    else if d==e
        t[d][++f%5]+t[e][++g%5]
    else
        t[++d%5][f]+t[++e%5][g]
console.log o

Ungolfed version:
search = (table, letter) ->
    for row in [0..4]
        for column in [0..4]
            return [ row, column ] if letter is table[row][column]

encrypt = (key, value) ->
    key = key.toUpperCase().replace(/J/g, 'I').replace /([^A-Z])/g, ''
    keyChars = {}
    keyChars[char] = char for char in key
    for i in [1..26] when i != 10
        char=String.fromCharCode 64 + i
        keyChars[char] = char
    keyChars = (char for char of keyChars)

    keyTable = (keyChars[start..start+4] for start in [0..24] by 5)

    value = value.toUpperCase().replace(/J/g, 'I').replace(/([^A-Z])/g, '').replace(/(.)\1/g, '$1X$1').replace /(..)/g, '$1 '
    pairs = value.trim().replace(/\s([A-Z])$/, ' $1X').split /\s/

    out = ""
    for pair in pairs
        [a,b] = pair.split ''
        [rowA, colA] = search keyTable, a
        [rowB, colB] = search keyTable, b
        if rowA!=rowB&&colA!=colB
            out += keyTable[rowA][colB]+keyTable[rowB][colA]
        else if rowA==rowB
            out += keyTable[rowA][++colA%5]+keyTable[rowB][++colB%5]
        else
            out += keyTable[++rowA%5][colA]+keyTable[++rowB%5][colB]
    out.replace /(..)/g, '$1 '

console.log encrypt process.argv[2], process.argv[3]

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


text:
Predictable unpredictability
Ever programmer knows, that programs need to be predictable. Any code that is not predictable will do something undefined and therefore most likely crash or worse. But when I tried to figure out what Java's lazySet() method does, I came up with the idea
Is it possible to write a program that is unpredictable, yet works fine and does something useful/interesting?
So that will be your task. Do not avoid chaos, but utilize it. Whether you use the actual lazySet, thread timing, random or uninitialized variables is up to you. The following rules apply:

The code-path must be unpredictable. That is: if I would debug it, the program would take a "random" path each time.
The program must do something useful/interesting and handle all possible (unpredictable) states somehow. No crashes! (Core dumps are neither useful nor interesting!)
You are not allowed to check something in a loop till it has the desired value. You must work with whatever is stored in there and do something with it.
You can use any language, except those specifically optimized for this contest.

This is a creative question so the one with the most votes wins. Please note that programs doing common stuff like gambling, printing random numbers or generating RPG loot are too well-known to be considered interesting. Please surprise us.
Bonus points should be given for:

The creativity of the choice/design of unpredictability (Math.random isn't that creative).
The creativity in management of unpredictability.
Everything genius. ;)

This is... pretty broad. The objective is to do "anything based on randomness", right? Gambling, Monte Carlo Go AIs, RPG loot tables, pretty drawings, are there any limits here?

Anything interesting, yes. Answers printing random numbers are not requested. ;)

How about modifying the challenge to be code whose program flow is random but output is nonetheless deterministic? Every time the program/function is run (with the same arguments) it should return the same output, but a trace should indicate the program followed a different path of instructions.

Too many answers for a creative question... Hmm.. where would the creativity find its room, when I narrow it down and put it into a cage? "Write a simple random code" I can do myself, I was specifically asking for creative ideas on what you could do with chaos in coding.

Ruby
This works only on Windows.
if aTerribleErrorOccurredAndWeNeedToKillTheScriptNow
    c = ($$ % 94 + 33).chr
    puts "#{c * 50}\n#{c + "KILLING SCRIPT".center(48) + c}\n#{c * 50}"
    `taskkill /PID #{$$} /F`
end

The process ID, $$, is unpredictable. However, this will always kill the currently running script, while printing an error message bordered by an unpredictable character like this:
##################################################
#                 KILLING SCRIPT                 #
##################################################

Of course, exit or quit do the same thing, but this one kills Ruby forcefully with the OS! And it also bypasses at_exit handlers.

That would violate rule #1: the program always follows the same execution path.

@TwoThe Whoops, fixed!

It still does. Although c will be random, if I would debug it, it would always take the same path.

@TwoThe No, try running it multiple times and it outputs differently each time.

Where does aTerribleErrorOccurredAndWeNeedToKillTheScriptNow come from?

source: Stack Exchange

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

sort: votes


text:
Mandoline quine
Write a quine... from which every other character can be removed it still be a valid quine. You can specify whether to start removing characters at the first or second character.
Scoring criteria (add bonuses/penatly percentages together for total percentage):

Answers must be at least 4 characters long
Program must contain at least one alphabetical character in its source, so for example, 12345!@#$%^&*() is disqualified
+750% if the language used is not Turing-complete (I'm looking at you, HTML!)
-15% if the solution does not read its source from anywhere in any form
-20% if you can also keep only every 5th character and still form a quine

The score is measured by the number of characters in the first program.
Example (not real programs):
If 123456789abcdef and 13579bdf are both quines, the score is 15. Additionally, if 159d is also a quine, then the final score is 12.
This is code-golf, so lowest score wins.

What if a person writes their code so all the removed characters are unnecessary whitespace?

@hosch250 The original program wouldn't be a quine because it wouldn't print those whitespaces. Same goes for unnecessary comments.

Guess so.  Nice challenge.

@hosch250 hah, I personally am not very good at even writing an answer for this type of thing.... But no matter what challenge you hurl at the people here, several people will have a solution to your insanely hard problem :P

Yeah, I have never programed a quine before, and have no idea how to do it without reading the source code in C++.  I have seen them in C++ before though!

If you're giving bonuses to markup languages, which don't have an execution model, you must be using a non-standard definition of quine, and you need to include it.

You state: "-20% if you can also remove every 4 characters and still form a quine". But technically this is not what happens in your example. You mean you can do it a second time?

@mmumboss: "Remove every 4 characters" is not really grammatical, anyway, but yes, it appears to mean "remove all but every fourth character".

Are the bonuses additive or multiplicative?  That is, if my program is 10 chars long and qualifies for both the -15% bonus and the -20% bonus, will its score be 10 * (1 - 0.15 - 0.2) = 6.5 or 10 * (1 - 0.15) * (1 - 0.2) = 6.8? I assumed the latter, but an explicit clarification would be nice.

HQ9+ wins this easily.

@IsmaelMiguel HQ9+ is not Turing complete (or even close), so it gets +750%. Minimum number of letters is 4, so that's 4*750%= 30. Code golf fail.

Still less than most languages can

I think HQ9+ (Q+++) also qualifies for the 20% bonus... so it scores 24.

Wouldn't this be a Mandoline quine, not a Guillotine? Guillotines make one clean, generally fatal, cut and the head rolls away. Mandolines make with the many evenly spaced slices. :)

@IlmariKaronen I didn't specify, but I consider it to be additive.

@JonathanVanMatre I like that. I'll go change the title now :)

PHP, 4 chars − 15% − 20% = 2.72 2.6 points
ABCD

Yes, PHP is a Turing-complete language.  Nobody said I have to use any of its actual programming features. ;-)
Edit: Changed the score based on the clarification that bonuses are additive, not multiplicative.

This works in ASP, possibly.

@n̴̖̋h̷͉̃a̷̭̿h̸̡̅ẗ̵̨́d̷̰̀ĥ̷̳ I give up. :P

Actually, use of PHP's actual programming features is discouraged.

This is not a proper quine. Still a good answer, though

TI BASIC 4 - 35% = 2.6
I might understand them wrong, but I think I am also eligible for the -15% and the -20% bonusses, meaning I have the lowest possible score.
I can write the program:
123i

which will output 123i where i is of course the imaginary unit. When you remove the 1st and the 3rd character all that remains is 2i which outputs 2i

Not quite... '12i'  will output '12i' and '2' will output '2' for a minimum score of 1.95.

Actually, '2i' scores 1.3, and if the empty program is considered a quine, 'i' scores 0.65.

@intx13: "Answers must be at least 4 characters long."

Ah, I missed that!

Beat me to it ;)

Python - 95
Great challenge. I thought this was pretty clever, and actually a legit solution!
00;"#";print(open(__file__).read())
0#;XpXrXiXnXtX(XoXpXeXnX(X_X_XfXiXlXeX_X_X)X.XrXeXaXdX(X)X)

Nice! Note this technically doesn't work as-is since you end up deleting the newline when making the alternate quine. requires a tad bit of tweaking IOW

@Claudiu Well I guess it depends on whether OP considers newline a character. If so, you can just add a newline between each line. 96 chars

Of course a newline is a character...

Golfscript, 5 points
{hai}

is a function that, when executed, will run the (non-existing) function hai. It's not executed, however, but rather printed when the program ends - including the outer brackets. Removing each other character yields:
{a}

Lame, I know :-)

I believe you qualify for both bonuses, too: your program does not read its own source code, and {} is a quine too.

@IlmariKaronen it's hard to tell what counts as reading own source code. Does unevaluating functions count? Does evaluating strings count? As for the other bonus - maybe it's just badly worded, but I read "remove every four characters"  as "keep every fifth character", which would leave me with one bracket only (though {ab0} qualifies if 0 can be the one that's kept)

It's indeed badly worded, but the example suggests it means "keep every fourth character". Anyway, as you note, {ab0} qualifies either way.

It seems {hi} also works, will be shorter (4 chars), and will also qualify for all bonuses. (Seems the script {i evaluates to {i for some reason...)

@Claudiu {i produces an extra closing curly for me

What about {{}}?

@IlmariKaronen Sorry for the very late reply, but it would not, since it would not contain any alphabetic character.

{hai} there! Does one part of the code encode another? If not, then it is not a proper quine by PPCG standards.

@MilkyWay90 {hai} there! Those rules came way after I answered this question. In fact, I already hadn't remembered having answered this by the time I was fighting against those rules...

As to your question proper... I haven't touched quines for several years already, so I don't remember the current definition of proper quines, and I'm not even sure they hadn't changed since I last saw them...

@JohnDvorak Okay, thanks for clarifying!

HQ9+ - 4 * 7.5 * 0.8 = 24 points
Q+++

Still a quine with every second character:
Q+

...and every fifth:
Q

Sorry, I couldn't resist. :)

HTML/Markdown, 4*7.5 = 30
HHHH

I admit this is lame, but it doesn't really go against any rule in the question. Except that HTML/Markdown may not be considered a real programming language.

I suppose I didn't specify that programs that can't be split any smaller aren't valid. Revising challenge...

@Jwosty: then "HHHH" in HTML would win. Note 5555 doesn't work because it has no alphabetic character

You need an alphabetic character.

@qwr: Forgot that when looking at GolfScript. Removed.

Hmm... I suppose that this valid :P

4*7.5 = 30...

@Bakuriu: The score is maintained by the participants in this question, not me.

!/bin/sh
I liked qwr's solution so much, I shamelessly made a port for POSIX shell.  Please don't save it into a filename containing spaces.
: '#';cat $0

#c a t   $ 0

Start removing at character number 1, and count newlines as characters.  The second quine is of course:
 #;a 0
cat $0

Please upvote qwr's answer instead of this one!

Bash, 23
Newline is a character!
Some messy comment work, so that when every other character starting from the first is removed, the comment becomes code and the code becomes a comment:
#cRaRtR R$R0R R#
cat $0

After every other character (including the new line) is removed:
cat $0 #ct$

it's not a quine if it reads its own source though.

@daniero "-15% if the solution does not read its source from anywhere in any form" implies that you are allowed to read the program's source (but you don't get the bonus)

@daniero oh i looked on wikipedia I suppose it is cheating... but it's [tag:code-golf]

I always upvote cats!

Vyxal, 8 bytes -15% = 6.8
` I,` I,

Try it Online!
Every other char
`I`I

Try it Online!
Explanation :
` I,`    # push ` I,`
      I  # quote and prepend
       , # print

`I`  # push `I`
   I # quote and prepend
     # implicit output

Brainf**k, 37 - 15% = 31.45
Abusing the Portable Brainfuck Interpreter
+A[B-C<D+E]F-GÿH<I<J<K<L<M<N<O[P.Q>R]

Start removing from the second character.

When i run this I get B-C<D+E]F-GÿH<I<J<K<L<M<N<O[P.Q>R] as output so it's lacknig some characters.

Is it Brainfuck, or a particular dialect of Brainfuck that only works on one interpreter?

@immibis It's regular (those capital letters can be spaces or symbols or anything). However, you must use the portable interpreter linked from the answer.

The first part goes left until it finds the ÿ and the linked interpreter happens to store the code 5000 bytes before the start of the data tape. That's hardly portable Brainfuck.

Python 3, 145 94 bytes -15% : Score = 79.9
s ="'psr=i%nrt;(p'rsi n=t%(rs;%e%xse)c;(xsc[s11:::2  2']; p)r'i%nst)(#s#%#s#)";exec(s[1:: 2] )

Try it online!
every other char:
s='s=%r;print(s%%s);xcs1:2 ';print(s%s);xcs1:2

Try it online!
How it works :
The ugly string is the blending of :

print('s =%r;exec(s[1::2 ] )'%s)#### for the normal quine
's=%r;print(s%%s);xcs1:2 ';print(s%s) for the every-other-char quine

xcs1:2  is an annotation and doesn't throw any error as the part after the semicolumn can compile. Otherwise it would throw a SyntaxError and the program wouldn't run at all.
Python 3, with reading code source: 70 62 bytes
s ="p-r-i-n-t-(-*-o-p-e-n-(-_-_-f-i-l-e-_-_-)-)";exec(s[::2] )

Try it online!
every other char:
s=print(*open(__file__));xcs:2

Try it online!

 HQ9+T, - 4 * 0.8 = 3.2 points
qqqq

It's a valid quine (ish) and a quine every second and fifth char.
I couldn't resist . . . .

authors: n̴̖̋h̷͉̃a̷̭̿h̸̡̅ẗ̵̨́d̷̰̀ĥ̷̳

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


text:
Calculate the sine of a float (in radians)…
…without using any operator/function besides addition (+), subtraction (-), multiplication (*), division (/), modulo (%), exponent/power pow() or any of the standard C bitwise operators (<<, >>, ~, &, |, ^) or unary operators (—, ++) or assignment/comparison operators (=, ==).
If these symbols represent a different operation in your chosen language, go with the spirit of the question and don't use them.
Rules:

You cannot use any mathematical functions your language might offer (Mathematica, looking at you.)
You cannot use any operator besides the bitwise operators or the arithmetic operators listed above.
Your output should be a float and be correct to at least 2 decimal places when truncated/rounded.
You can use constants your language's standard libraries might provide.
You can hardcode the values, but your program should work correctly for all floats (up to 2 decimal places) between 0 and 2π;

This is code-golf, so the shortest answer wins.
Example:
Input: 3.141592653 / 2
Output: 1.00xxxxxx…

Please also post an ungolfed version of your code.

The tag [tag:code-challenge] needs an objective winning criterion.

@Howard Updated the tags.

I don't think that this is a good [tag:popularity-contest]. Most answer will go for the trivial solution and it will be a who-posts-first-will-get-most-upvotes challenge.

@Howard Changed it to a code-golf.

I assume that ^ is XOR and ! is bitwise NOT?

@ProgramFOX ! is logical NOT and ~ is bitwise NOT.

Err, where is the = and comparison operator? Are we disallowed to use them?

@n̴̖̋h̷͉̃a̷̭̿h̸̡̅ẗ̵̨́d̷̰̀ĥ̷̳ Sorry! Updated.

The sandbox is too dormant The sandbox isn't dormant in any way. As you just notice yourself (after more than 10 edits in the last 30 minutes) it requires time and thought to produce a good challenge. The sandbox is just the right place to iron out any dents in your question. That's the purpose of the sandbox - to keep this noise from entering the main page.

@Howard Sorry, I will use the sandbox from now on.

Most of the current answers seem to violate the letter of the question without violating the spirit. In particular, with the exception of the APL one they all use one of <, >, or ^ meaning to-the-power-of rather than bitwise-XOR. Whether you prefer to comment on those answers and inform their submitters that they're invalid, or to edit the question to permit them, you could make things a lot clearer by listing the operators by name, not symbol in some unspecified language, and by grouping them with some kind of title or label (comparison, bitwise, arithmetic, assignment).

@PeterTaylor I have edited the question to clarify. I chose to permit exponentiation.

@duci9y do we need to give input like (pie)/2 or the calculated value((pie)/2 = 1.57xxxxx) ? and till what decimal places ?

please disallow imaginary exponentiation as this uses the sine function to be calculated and makes this to easy.

If I am not mistaken, even the sine function provided by libraries will not meet the trucation criterion: You can most likely find an x such that sin(x) = a.bc9999… (with a, b, c being some digits) and thus the output being a.bd0000… (with d = c+1). Therefore matching this criterion as it stands would be very nasty. Also, I would not know any language where exp is the exponent operator (or exponentiation) and not the exponential function.

@Wrzlprmft Please read the first line of the question which refers to an "operator/ function ". And if you round the answer, you can meet the truncation rule.

@duci9y: 1) So, I may use the exponential function (e^x), but not general exponentiation (a^x for a ≠ e)? 2) Some example: sin(3.136) ≈ 0.00559262443555. Rounding to two digits and trucating would get me 0.01. Just truncating gets me 0.00. Would 0.01 be an acceptable answer? If so, why is 0.998 not an acceptable answer for sin(π/2)? Also: Why not just require the answer to deviate less than 0.01 from the actual answer?

@Wrzlprmft You can use general exponentiation.

@Wrzlprmft, the trunction criterion isn't too hard to meet: write a sensible implementation and add 0.5 ulp.

@PeterTaylor: Depends on how you interpret the criterion: If you require that your solution and the correct solution must be identical when truncated to two decimal places, you can always find an input such that this criterion is not met (as explained above). Anyway, now the criterion has been changed to “rounded/truncated” – no idea what that is supposed to exactly mean, not that I care anymore. You might also want to take a look at the comments regarding this criterion on this answer.

Python 83 69
Based on Bhaskara I's sine approximation formula
Implementation
def f(x):p=3.14;x,s=x%p,(4,-4,4)[int(x/p)];return s/(12.34/x/(p-x)-1)

Ungolfed
def apxsine(radian):
    pi = 3.14 # Approximate to 2 decimal places
    sign = (4,-4,4)[radian % pi]
    return sign / (12.34/radian/(pi - radian) - 1))

Deduction

Demo
>>> from math import pi, sin
>>> any(round(abs(f(e) - sin(e)), 2) for e in (e/180.*pi for e in range(0,360)))
False

JUst realized that if I would have opted for Euler's formula route, the code would be shorter (49 characters). But then it uses Complex numbers and am not sure if the call to the real method would be valid in the current question context.
f=lambda x:((2.72**(x*1j)-2.72**(-x*1j))/2j).real

Running f(3.141592653 / 2) returns 0.998…. Your answer should be valid to at least two decimal places (1.00…). Please tell me if I did something wrong.

@duci9y: I believe, you need to round the result to two decimal place. round(f(3.141592653 / 2),2), instead of truncating

@duci9y Abhijit is right, you're truncating.  The answer does give correct results.

Then I think you should include the round() in your code.

@duci9y: Your question demanded a result which is precise to 2 decimal places Your output should be a float and be correct to at least 2 decimal places., so mathematically speaking that's rounding rather than truncating.

@Abhijit I included an example in the question. You really should put the round() into your code. Also, the real method would be invalid.

@duci9y His answer is accurate to two decimal places. 1.00 is the same as .998 to two decimal places.

You need to change [4,-4] to [4,-4,4] in the second line, otherwise this won’t work for x = 6.282 < 2π.

PS: or you could use a library’s π – which would also shorten your code, if you do not count the import line.

Javascript 114 77
Using Taylor Series expansion at 0:
function s(y){
    var p=2*Math.PI,
        // z = sign (y)
        z=(y>0?1:-1),
        // x = (abs(y) mod 2 PI - PI) * sign(y) => put x in [-PI, PI] range
        x=-z*((z*y)%p-p/2),
        // u = x^2
        u=x*x;
        // return Taylor Expansion
        return x*(1-(1-(1-(1-u/72)*u/42)*u/20)*u/6);
}

Golfed (114):
function s(y){var z=(y>0?1:-1),p=2*Math.PI,x=-z*((z*y)%p-p/2),u=x*x; return x*(1-(1-(1-(1-u/72)*u/42)*u/20)*u/6);}

Edit
"Improved" for y in [0,2PI], golfed (77) :
function s(y){var x=3.14-y,u=x*x;return x*(1-(1-(1-(1-u/72)*u/42)*u/20)*u/6)}

Another version for more precision (varying k) :
function s(y){
    var p=2*Math.PI,
        // z = sign (y)
        z=(y>0?1:-1),
        // x = (abs(y) mod 2 PI - PI) * sign(y) => put x in [-PI, PI] range
        x=-z*((z*y)%p-p/2),
        // u = x^2
        u=x*x,
        // k = 2* expansion level +1
        k=9,
        // r = 1 initial value
        r = 1;

        // Taylor Expansion
        // while k > 1
        for(;k>1;) {
            r= 1 - r*u /k--/k--;
        }
        return x*r;
 }

Golfed (114):
function s(y){var z=(y>0?1:-1),p=2*Math.PI,x=-z*((z*y)%p-p/2),u=x*x,k=9,r=1;for(;k>1;)r=1-r*u/k--/k--;return x*r;}

Please post an ungolfed version too.

@duci9y ungolfed version given

MATLAB 35
Too bad e is not a constant in Matlab. That would have saved me 10 characters. I will see if I can come up with a solution for this.
@(x)(2.7183^(x*i)-2.7183^(-x*i))/2i

May be you can try the approximate value as 2.72? After all the question dictates that the precision  could be within 2 decimal places.

I tried this, but for all values between 0 and 2pi, this was the minimum required definition of e in order to get the desired accuracy.

Strange, I tried your implementation in Python, and it seems to give me correct result. Unfortunately, I do not have Matlab to try this out :-)

And when you try it with an input of 6.28?

If I round the result to 2 decimal places it matches i.e. the formula with 2 decimal approximation of e gives -0.0031853017931379904 where as sin returns 0.0007829010740853711, which are both zero approximate to 2 decimal places. Refer http://ideone.com/I6Ifld

You are right, sorry, I gave the wrong example. Try it for 1.47. 1.47 that sneaky bastard ;)

APL - 21
{|{.5×⍵-+⍵}0J1*⍵÷○.5}

This uses the fact that sin pi*x/2 = Im[(-1)^x].
Example test on ngn APL
Previous answer: 26
{-/((×\9⍴⍵)÷×\1+⍳9)[2×⍳5]}

This uses the Taylor/Maclaurin series up to 9th term.
Example test on ngn APL
Note about operators: only operators used were /\⍴⍳ which don't have anything to do with arithmetic, and are mostly list manipulation tools, ○ which is multiply by pi, and +-×÷* which are permitted by the rules

The 20 character line seems to give wrong answers?

@mmumboss Yeah, sorry, fixed

Your example link gives wrong result and does not match your post. Save nine bytes: 11○0J1*2÷○∘÷

11○ is just shorthand for |{.5×⍵-+⍵}.

C++ 80  68(excluding white-spaces + edit)
GOLFED
float S(float x){float z=x*x,y=x*(5040-(840+(42-z)*z)*z)/5040;return y;}

UNGOLFED
both versions are different so that, it is easy to get output.
#include<iostream>
int main()
{
    float x,y,z;
    for(;;)
    {
        std::cin>>x;
        z=x*x;
        y=(x*(5040-840*z+42*z-z*z*z))/5040;
        std::cout<<y<<'\n';
    }
}

Output
1.047197 ((pie)/3)
0.865096 (sin((pie)/3) = 1.73201/2 = 0.8660)

Haskell
import Prelude hiding (sin)
import Data.Complex
sin x=(\(_:+y) -> y) $ exp (0 :+ x)

Uses Euler's formula. (y :+ z)=y+zi I think.

Is imagPart a mathematical function?

I would consider complex arithmetics with exp cheating, as in complex, exp and trig are the same. Otherwise, there's an unfair advantage.

Sorry, not a valid answer.

Whoops, sorry, got rid of outside math function. (It wasn't much of a math function, but it is gone now.)

Javascript (56)
j=x=+prompt(r=0);for(i=1;i<99;j*=x/++i)r+=i&1?i&2?-j:j:0

Taylor series used here.
x is the input value,  r is the result, j contains x^i/i!
The result is output in console.
x=prompt();
r=0;
j=1;
for(i=1;i<99;i++) {
  j=j*x/i;
  if (i%2) {
    if (i%4 == 1) r+=j;
    else r-=j;
  }
}
alert(r);

If evaluation is needed for input (for example 3.141592653 / 2) :
j=x=eval(prompt(r=0));for(i=1;i<99;j*=x/++i)r+=i&1?i&2?-j:j:0

Bravo... a lot more compact than my: f=n=>+!n||n*f(n-1);for(x=prompt(),y=s=0;9>=y;y++)s+=Math.pow(-1,y)*Math.pow(x,z=2*y+1)/f(z);alert(s)

Python, 70 bytes
Using sin(x) = Im(exp(ix)) and the series for the exponential function:
def s(x):
    s,f=0,1
    for i in range(1,50):f*=1j*x/i;s+=f
    return s.imag

Note that imag is not a function here, strictly speaking.
Ungolfed:
def s(x):
    s = 0
    f = 1
    for i in range(1,50):
        f *= 1j*x/i
        s += f
    return s.imag

R, 80 chars
f=function(x){a=seq(1,99,2);sum((-1)^(0:49)*(x^a)/sapply(mapply(`:`,1,a),prod))}

Uses Taylor approximation at an order of 99.
sapply and mapply are just functions to vectorize the operation, while sum and prod are just vectorized + and *.
> b=seq(0,2*pi,1e5)
> all((f(b)-sin(b))<.01)
[1] TRUE

If the *apply functions are a problem, here is a solution at 91 characters:
f=function(x){a=0:100;b=c();for(i in 1:50)b[i]=(-1)^(i-1)*(x^a[2*i])/prod(1:a[2*i]);sum(b)}

C 70
This one is not only golf but also useful in microcontrollers without floating point instructions or math libraries:
float S(float a){float x,y=1,h=1e-4;while(x+=h*(y-=h*x),(a-=h)>0);return x;}

Of course, the majority of the characters is taken by these annoyingly long type declarations and return. If the function declaration doesn't count, it's much shorter. If we take the value by pointer and overwrite it (removing the return statement), we get 71 characters.
S(float*x){float a=*x,y=1,h=1e-4;*x=0;while(*x+=h*(y-=h**x),(a-=h)>0);}

However, it complains about default return value.
EDIT: 70, for is shorter:
S(float*x){float a=*x,y=1,h=1e-4;*x=0;for(;(a-=h)>0;*x+=h*(y-=h**x));}

EDIT2: forgot ungolfed version
float fake_sin(float a){
   float x=0,y=1;
   float h=1e-4;//adjust for accuracy
   while(a>0){
      y-=h*x;
      x+=h*y;
      a-=h;
   }
   return x;//return y for cosine or y/x for tangent
}

It takes arbitrary positive angle, but doesn't work for negative.

Java - 108 / 81
float s(float p){for(float q=p-=3.14,d=p=-p,i=1,m=1;i<11;)p+=(q*=d*d)/(m*=++i*++i)*(((int)i&2)-1);return p;}

Without the function declaration, it's just doing p = sin(p):
for(float q=p-=3.14,d=p=-p,i=1,m=1;i<11;)p+=(q*=d*d)/(m*=++i*++i)*(((int)i&2)-1);

The error is max ±0.00201 in the range 0..2π, much worse in either direction.
Ungolfed:
float s(float p) {
    for (float q = p -= 3.14, d = p = -p, i = 1, m = 1; i < 11;)
        p += (q *= d * d) / (m *= ++i * ++i) * (((int)i & 2) - 1);
    return p;
}

Unobfuscated:
float sin(double ph) {
    float [] dividers = {-1, 6, -120, 5040, -362880, 39916800L};
    ph -= Math.PI;
    double d = 0;
    for (int i = 0; i < 6; i++)
        d += Math.pow(ph, i * 2 + 1) / dividers[i];
    return d;
}

C# - 115 103
This code uses an approximation of Maclaurin series calculation of the sine of x, and is accurate to 7 decimal places.
float x=0;for(int i=1;i<96;i+=2){float n=i,d=1,p=a;while(n>1){d*=n;n--;p*=a;}x+=((i+1)%4==0?-1:1)*p/d;}
Where a is the input in radians.
Here's the code with whitespaces:
float x = 0; for (int i = 1; i < 96; i += 2)
{
    float n = i, d = 1, p = a;
    while (n > 1)
    {
        d *= n;
        n--;
        p *= a;
    }
    x += ((i+1)%4==0?-1:1)*p / d;
}

TI-84 BASIC, 21 bytes
(e^(iAns)-e^(⁻iAns))/2i

Perl 6, 17 16 bytes
{(e**(i*$_)).im}

Axiom, 139 bytes
s(x:Float):Complex Float==(digits()>20=>%i;x>2*%pi=>s(x-2*%pi);x< -2*%pi=>s(x+2*%pi);imag(reduce(+,[(%i*x)^k/factorial(k)for k in 0..40])))

I see this formula in the other solutions and I inplemented it in Axiom...
The formula i follow is this:
                               +oo
                               ----
                               \      (i*x)^k
sin(x)=ImPart(e^(i*x))=imPart( /     --------  )
                               ----k     k!
                                 0

ungolf
sin1(x:Float):Complex Float==
              digits()>20=>%i
              x>  2*%pi  =>sin1(x-2*%pi)
              x< -2*%pi  =>sin1(x+2*%pi)
              imag(reduce(+,[(%i*x)^k/factorial(k)for k in 0..40]))

there is some problem for the last 2 digits each number; some test cases:
(79) -> [-23, numeric(sin(-23)), s(-23) ]
   (79)  [- 23.0,0.8462204041 7517063524,0.8462204041 7517063514]
                                                 Type: List Complex Float
(80) -> [ 23, numeric(sin( 23)), s( 23) ]
   (80)  [23.0,- 0.8462204041 7517063524,- 0.8462204041 7517063536]
                                                 Type: List Complex Float
(81) -> [[x/2,numeric(sin(x/2)),s(x/2)] for x in 0..(7*2)]
   (81)
                  1
   [[0,0.0,0.0], [-,0.4794255386 0420300027,0.4794255386 0420300027],
                  2
    [1,0.8414709848 0789650665,0.8414709848 0789650665],
     3
    [-,0.9974949866 0405443094,0.9974949866 0405443093],
     2
    [2,0.9092974268 256816954,0.9092974268 256816954],
     5
    [-,0.5984721441 0395649405,0.5984721441 0395649405],
     2
    [3,0.1411200080 598672221,0.1411200080 5986722208],
     7
    [-,- 0.3507832276 8961984812,- 0.3507832276 8961984817],
     2
    [4,- 0.7568024953 0792825138,- 0.7568024953 0792825139],
     9
    [-,- 0.9775301176 6509705539,- 0.9775301176 6509705545],
     2
    [5,- 0.9589242746 6313846889,- 0.9589242746 6313846888],
     11
    [--,- 0.7055403255 7039190623,- 0.7055403255 7039190626],
      2
    [6,- 0.2794154981 9892587281,- 0.2794154981 9892587545],
     13
    [--,0.2151199880 878155243,0.2151199880 878155243],
      2
    [7,0.6569865987 187890904,0.6569865987 1878909041]]
                                                      Type: List List Any

authors: n̴̖̋h̷͉̃a̷̭̿h̸̡̅ẗ̵̨́d̷̰̀ĥ̷̳


text:
Ascii art pie chart
Your goal is to output an ASCII art pie chart. This is code-golf, so the shortest program (counting the bytes of the source code, not the characters) wins.
No external softwares or APIs are allowed. Only the native ones of each language.
The starting angle and the direction (clockwise/anticlockwise) of the circle are not important.
The output can look oval because the height of a character is always superior to its width.
The "background" (characters at the left or the right of the pie) must be spaces.
As input, you have three variables (please post the code for initializing it. The initialization of these variables is not counted in your score) :

k : Array of characters. Each character is the one which has to be used on the pie chart
v : Array of floats. It's the percentage of each character. The length of v is equal to the length of k. The sum of it's elements is always 1.0
r : Integer > 1. It's the radius of the pie chart.

Bonus : Subtract 20% of your score if your can output an incomplete pie (in case the \$(\sum_{i=1}^{|v|} v_i)<1\$).

Python: 255 chars - 20% = 204
from math import*
def s(k,v,a):
 if not v:return ' '
 if a<v[0]:return k[0]
 return s(k[1:],v[1:],a-v[0])
def p(k,v,r):
 d=range(-r,r)
 for y in d:
  t=""
  for x in d:
   if x*x+y*y<r*r:
    a=atan2(y,x)/pi/2+.5
    t=t+s(k,v,a)
   else:t=t+" "
  print t

Examples:
>>> pie.p("ABCD", [0.25,0.125,0.125,0.125],8)

     AAABBBB
   AAAAABBBBBB
  AAAAAABBBBBCC
  AAAAAABBBBCCC
 AAAAAAABBBCCCCC
 AAAAAAABBCCCCCC
 AAAAAAABCCCCCCC
        DDDDDDDD
          DDDDDD
           DDDDD
            DDDD
             DD
              D

>>>

>>> pie.p(".$!@", [0.3,0.3,0.3,0.1],6)

   .....$$
  ......$$$
 ......$$$$$
 ......$$$$$
 ......$$$$$
 @@@@@$$$$$$
 @@@@!!!$$$$
 @@@!!!!!$$$
 @!!!!!!!!!$
  !!!!!!!!!
   !!!!!!!
>>>

This can be reduced to 231 bytes by replacing the function s with a lambda s=lambda k,v,a:' 'if not v else k[0]if a<v[0]else s(k[1:],v[1:],a-v[0]) and using a semi-colon to put the if statement on one line if x*x+y*y<r*r:a=atan2(y,x)/pi/2+.5;t=t+s(k,v,a)

JavaScript, 259
d=r*2;M=Math;R=M.round;p=[];for(y=0;y<d;y++){p[y]=[];for(x=0;x<d;x++)p[y][x]=" "}t=0;i=-1;for(f=0;f<1;f+=1/(r*20)){if(f>t)t+=v[++i];a=M.PI*2*f;for(j=0;j<r;j++)p[R(M.sin(a)*j)+r][R(M.cos(a)*j)+r]=k[i]}s="";for(y=0;y<d;y++){for(x=0;x<d;x++)s+=p[y][x];s+="\n";}s

Works in Firefox scratchpad.
First example
Input :
var k = ["#", "+",  "$",  "X"];
var v = [0.2, 0.4, 0.15, 0.25];
var r = 10;

Output :
       $$$XXXX
     $$$$$XXXXXX
    $$$$$$XXXXXXX
   $$$$$$$XXXXXXXX
  +$$$$$$$XXXXXXXXX
  ++$$$$$$XXXXXXXXX
 +++++$$$$XXXXXXXXXX
 ++++++$$$XXXXXXXXXX
 +++++++$$XXXXXXXXXX
 +++++++++XXXXXXXXXX
 ++++++++++#########
 +++++++++++########
 +++++++++++########
  ++++++++++#######
  +++++++++++######
   ++++++++++#####
    +++++++++####
     ++++++++###
       +++++++

Second example :
Input :
var k = ["A",  "B", "C" ];
var v = [0.5, 0.25, 0.25];
var r = 5;

Output :
   BBCCC
  BBBCCCC
 BBBBCCCCC
 BBBBCCCCC
 BBBBCCCCC
 AAAAAAAAA
 AAAAAAAAA
  AAAAAAA
   AAAAA

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


text:
Sort characters by darkness
Your program must take as input a line of characters, like this:
@+.0

And output the characters sorted by how dark they are, like this:
.+0@

Requirements:

You must use a monospaced font for darkness detection.
You must find out how many pixels each character takes up. You must actually draw the character and count pixels, i.e. you can't just hardcode pixel amounts.

As a more concrete rule: if you switched fonts, your program should still work. Furthermore, your program should be able to switch fonts by simply changing a variable or value or string in the code.

If you use antialiasing, you must count pixels as percentages of a fully black pixel. For example, an rgb(32, 32, 32) pixel will count as 1/8 of a full pixel. Disregard this rule if your characters are not antialiased.
After counting pixels, you must sort the characters by the amount of pixels, and output them in order.
This is code-golf, so the shortest code in bytes will win.

Strangely enough, this is also appropriate for RPG.se!

What, no correction for display gamma in the darkness calculation?

Can we use a white font? If so, I think I have this one wrapped up.

Mathematica, 112 110 108 bytes
This can still likely be golfed further. Assumes the string is in variable s.
And now uses a correct syntax to sort one list by another list.
Lucky test cases -> "Oh yeah, that works" -> Facepalm
Thanks for the sharp eyes, David Carraher.
Update: Replaced OCR A with Menlo because I realized that on OSX the OCR A font family name is actually OCR A Std. So I was sorting a default font instead of the real deal. Menlo is also monospaced with the same byte count, so no net gain or loss.
I've put up a hosted CDF export of the notebook, so you can see the code in action if you wish. I'm still figuring out how to add some interactivity to web-hosted CDFs, so for now it's just static.
c=Characters@s;Last/@Sort[Transpose@{Total[1-#&/@ImageData@Rasterize@Style[#,FontFamily->"Menlo"],3]&/@c,c}]

Output for s = FromCharacterCode /@ Range[33, 135]; with "Courier"

Output for same, but with FontFamily "Monospace":

Note that the final results are shown in MM's internal font, not in the font being sorted. Hence, you see the differences in the font chosen reflected in the sort. The CDF link shows both, though, for the completists.
Ungolfed code:
s = FromCharacterCode /@ Range[33, 135];
c = Characters@s;
Last /@ Sort[
    Transpose@{Total[1 - # & /@
        ImageData@Rasterize@Style[#, FontFamily -> "Menlo"], 3] & /@ c, c}]

Examine for this input: "" <> (FromCharacterCode /@ Range[33, 135])

Default family or not, the specs required "your program should be able to switch fonts by simply changing a variable".  Because of anti-aliasing values, it is possible to get some sorts that look wrong, but I'll have another look at the full range and see if anything is wrong.

what a terrific language! just found out about the new programming language effort by Wolfram the other day, looking forward to that.

You can save two bytes by changing Characters[] to Characters@ and Reverse[] to Reverse@.

@the0ther "the new programming language effort by Wolfram" is a rebranding of Mathematica, for all practical purposes. If you want to start using Wolfram Language, pick up a Mathematica license.

@MichaelStern the cost of a Mathematica license is precisely the reason I didn't get started with Mathematica for so many years.

Actually, you can get a version of Mathematica and the Wolfram language for free with a Raspberry Pi (Net total about $35 after you buy the Pi and a software card.) Granted, you are limited by the Pi's computing power, so it's not going to be a great rig for hunting new Mersenne primes. But it's a cheap way to play with MM/WL and get your feet wet.

I don't want to post a similar answer, but I tried myself and it came up shorter StringJoin@SortBy[Characters@"@+.0",ImageData@Binarize@Rasterize@Style[#,FontFamily->"Monospace"]~Total~2&]

@swish Clearly I need to throw myself at understanding the employ of the ~ infix operator. Thanks for the tip!

I like that you applied it to a range of ASCII characters. Nice!

Bash + ImageMagick: 164 147 148 characters
while read -n1 c
do
o=`convert -size 20x15 xc: +antialias -font cour.ttf -draw "text 0,10 '$c'" xpm:-`
o=${o//[^ ]}
a[${#o}]+=$c
done
echo "${a[@]}"

Sample run:
bash-4.1$ echo -n '@+.0' | bash graysort.sh
. + 0 @

Separators are inserted between grayness groups. Characters with identical grayness level are not separated:
bash-4.1$ echo -n 'abcdefghijklmnopqrstuvwxyz' | bash graysort.sh
i cl jortz esv ax u df bgnpq y hk w m

+1 for sorting using bash array indices instead of sort

QBasic, 259 bytes
SCREEN 1
DIM a(255)
FOR i = 32 TO 255
    CLS
    PRINT CHR$(i);
    FOR p = 0 TO 64
        a(i) = a(i) + POINT(p MOD 8, p \ 8)
    NEXT p
NEXT i
FOR p = 0 TO 96
    FOR i = 32 TO 255
        IF a(i) = p THEN PRINT CHR$(i);
    NEXT i
NEXT p

I did this for fun, so it's technically non-compliant to the rules in one way. It doesn't take a list of characters, but instead prints all characters from 32-255 and uses that instead. If you really want to see a version which complies with this rule, please tell me.
It also fails another technicality: "Furthermore, your program should be able to switch fonts by simply changing a variable or value or string in the code." There is no easy way to do this from within QBasic. However, the program will of course work fine with any codepage of your choosing.
Lastly, I could squeeze away a few characters (mostly whitespace that the QBasic IDE helpfully inserts,) but it's probably not worth it since this answer stands no chance of winning anyway.

Plus one for doing it for fun!

Javascript + Canvas and Browser DOM (280 237 235 bytes)
Updated version with suggetions from Fors and toothbrush in comments:
function m(x){a=document.createElement('canvas').getContext('2d');a.font='9px Monaco';a.fillText(x,y=i=0,20);for(;i<3600;)y+=a.getImageData(0,0,30,30).data[i++];return y}alert(s.split('').sort(function(a,b){return m(a)-m(b)}).join(''))

More readable version:
// Scoring function - Calculates darkness for single character
function m(x) {
    a = document.createElement('canvas').getContext('2d');
    a.font = '9px Monaco';
    a.fillText(x, y = i = 0, 20);
    for (; i < 3600;) y += a.getImageData(0, 0, 30, 30).data[i++];
    return y
}
// Assume input is in variable s and alert as output. Comparison function now expression.
alert(s.split('').sort(function (a, b) {
    return m(a) - m(b)
}).join(''))

Can maybe be golfed more.
I'm new to this site, so I am unsure how input is normally read for Javascript answers. I assume input is contained in a variable named s. If this is not OK, I will update the answer and the char count.
JSFiddle of updated version.
JSFiddle of first version.

I really like it, however there are many possible improvements here. The variables c and s are unnecessary (a=document.createElement('canvas').getContext('2d') and y+=a.getImageData(0,0,30,30).data[i]), the element doesn't need to be appended, the zero initialisation of y can be combined with that of i (i=y=0), the post-increment of i can be combined with the adding of y (for(...;y+=...[i++]);), and the typeface Monaco is mono-spaced and has a shorter name than Courier.

Thanks! I'm not a seasoned golfer yet, so your comments help a lot. I have incorporated them into the code now.

Javascript answers here normally read input through prompt(); but this is also fine.

You can remove y=i=0; and change a.fillText(x,0,20) to a.fillText(x,y=i=0,20).

Thanks, added that as well! Two characters are two characters!

PHP, 298 characters
I've added a few line breaks so you can see it in all its hideousness:
<?php
$s=@$_GET[s];$a=array();$v=imagecreate(16,16);$f='imagecolorallocate';
$f($v,0,0,0);for($i=0;$i<strlen($s);$i++){$c=$f($v,$i,0,1);
imagechar($v,5,2,$n=0,$s[$i],$c);for($y=16;$y--;)
for($x=16;$x--;)$n+=($c==imagecolorat($v,$x,$y));
$a[]=ord($s[$i])+($n<<8);}sort($a);foreach($a as $v)echo chr($v);

This code uses the GD fonts that come built-in with PHP. The second argument of imagechar() selects the font (numbers from 1 to 5 are valid).
Example:
Input:  !@#$%^&*-=WEIX,./'
Output: '-.,^=!/*IE%X#$&@W

If you insert the following on top of the code shown above, then you'll be able to supply the list of characters in your web browser.
<?php
define("FONT_SIZE",5);
if(@$_SERVER['PATH_INFO']=='/a.png') {
  $s = $_GET['s'];
  $im = imagecreate(strlen($s)*(FONT_SIZE+4)+4,FONT_SIZE+12);
  imagecolorallocate($im,255,255,128);
  $c = imagecolorallocate($im,0,0,0);
  imagestring($im,FONT_SIZE,2,0,$s,$c);
  header("Content-Type: image/png");
  imagepng($im);
  imagedestroy($im);
  exit();
}
$me = $_SERVER['PHP_SELF'];
$t1 = $img = "";
if ($t1=htmlspecialchars(@$_GET['s'])) {
  $t2=urlencode($_GET['s']);
  $img="

";
}
echo <<<END_HTML

$img
<form action="$me" method="get">
<input type="text" name="s" size="40" value="$t1" />
<input type="submit" value="Go" />
</form>
END_HTML;
if(!isset($_GET['s'])) exit();
?>

if you use imagecreatetruecolor you can drop the first allocate and use the function name directly on the second, for -11. [] instead of array(). and foreach($a as$v) works as well

Java - 468 450 444
public static void main(String[]a){class c implements Comparable<c>{char d;c(char e){d=e;}public int compareTo(c o){return e(d)>e(o.d)?1:-1;}int e(char f){int a=0,x,y;BufferedImage img=new BufferedImage(99,99,1);img.getGraphics().drawString(""+f,9,80);for(y=0;y<99;y++)for(x=0;x<99;x++)a+=img.getRGB(x,y);return a;}}c[]s=new c[a[0].length()];int i=0;for(char d:a[0].toCharArray())s[i++]=new c(d);Arrays.sort(s);for(c d:s)System.out.print(d.d);}

@+.0abcdefghijklmnopqrstuvwxyz
->
.irl+jcvtfxyzsuonkheaqpdb0wgm@
Ungolfed:
    public static void main(String[] a) {
    a = new String[]{"@+.0abcdefghijklmnopqrstuvwxyz"};
    class c implements Comparable<c> {
        char    d;

        c(char e) {
            d = e;
        }

        @Override
        public int compareTo(c o) {
            return e(d) > e(o.d)? 1 : -1;
        }

        int e(char f) {
            int a = 0, x, y;
            BufferedImage img = new BufferedImage(99, 99, 1);
            img.getGraphics().drawString("" + f, 9, 80);
            for (y = 0; y < 99; y++)
                for (x = 0; x < 99; x++)
                    a += img.getRGB(x, y);
            return a;
        }
    }
    c[] s = new c[a[0].length()];
    int i = 0;
    for (char d : a[0].toCharArray())
        s[i++] = new c(d);
    Arrays.sort(s);
    for (c d : s)
        System.out.print(d.d);
}

Tip: avoid public or private modifiers as far as possible; that saves unnecessary bytes

forgot all about that

@MarkJeronimus this was the way I was going t otackle it, but I wanted to try using FontRenderingContext.

GTB
This has code to be the second hardest code I've ever written for a calculator. No hard-coded pixel values, it actually draws the text on a graph and loops to count each pixel.
0→I`_%I<l?_T;1,1,s;_,I,1
C;pT;{0,1,2,3,4,5},{0,1,2}→L1(I
0→I%I<l?_T;1,C;L1(I)>L1,I

Input
,O.i

Output
.,iO

If this works, it is the best answer so far. Whatever is GTB?

@slater Why don't you click on the link and find out?

Thank you for pointing out that your post title is indeed a link.

The domain to get the software necessary to decrypt your compiler is dead. Dead here too. I translated the code by hand for the fun of testing it out, but you seem to have opened 10 parens and closed only one, so I am unsure how to resolve that. The compiler in my head says: "Error::unmatched identifier"  :)

@JonathanVanMatre Don't worry; TI-84 automatically closes them for you.

Postscript, 381
Here's something completely different, just for fun. As most fonts are vector anyway, 'counting pixels' is a little odd, isn't it. Calculating glyph shape area, while being correct way, is not that easy. An alternative can be scanning a rectangle and counting 'hits' when a point is inside a glyph shape, and Postscript has operators for this kind of checks. Though, true, scanning and insideness-testing is just a weird way of counting pixels.
(%stdin)(r)file token pop/Courier 99 selectfont[1 index length{0}repeat]0 1 99{0 1 99{0 1 5 index length 1 sub{newpath 9 19 moveto 3 copy 7 index exch 1 getinterval false charpath infill{3 index exch 2 copy get 1 add put}{pop}ifelse}for pop}for pop}for 0 1 99 dup mul{0 1 3 index length 1 sub{dup 3 index exch get 2 index eq{3 index exch 1 getinterval print}{pop}ifelse}for pop}for

.
(%stdin) (r) file token pop
/Courier 99 selectfont
%/DejaVuSansMono 99 selectfont
%/UbuntuMono-Regular 99 selectfont
[ 1 index length {0} repeat ]   % str []
0 1 99 {
    0 1 99 {
        0 1 5 index length 1 sub {
            newpath
            9 19 moveto
            3 copy              % str [] n m i n m i
            7 index exch        % str [] n m i n m str i
            1 getinterval       % str [] n m i n m s
            false charpath      % str [] n m i n m
            infill              % str [] n m i bool
            {3 index exch 2 copy get 1 add put} {pop} ifelse
        } for
        pop
    } for
    pop
} for
% un-comment next line to print number of 'hits' for each glyph
%
% dup {=} forall
%
% next is 'lazy sort'
0 1 99 dup mul {                % str [] i
    0 1 3 index length 1 sub {  % str [] i j
        dup 3 index exch        % str [] i j [] j
        get 2 index eq          % str [] i j bool
        {3 index exch 1 getinterval print} {pop} ifelse
    } for
    pop
} for
()=

And here are results for 3 different fonts (selection of which can be un-commented, above):
$ echo '(.-?@AByz01)' | gs -q -dBATCH d.ps
.-?1z0yA@B
$ echo '(.-?@AByz01)' | gs -q -dBATCH d.ps
.-?z1yA0B@
$ echo '(.-?@AByz01)' | gs -q -dBATCH d.ps
.-?1zyA0B@

Counting pixels...counting pixel intersections...tomato....tomahto....

Perl (with GD) (159)
use GD;sub i{$i=new GD'Image 5,8;$B=colorExact$i 9,9,9;colorExact$i 0,0,0;char$i gdTinyFont,0,0,@_,1;$_=unpack"B*",wbmp$i 0;y/0//c}print+sort{i($a)-i($b)}@ARGV

usage:
> perl dark.pl 1 2 3 @ # . , : ~ $ M i I s S
.,~:i13Is2S$M@#

edit: shortened to 159 chars

Java, 584
Wow... This was not a good language to do this in.
import java.awt.geom.*;import java.util.*;class F{static void n(final String f,List<Character> s){Collections.sort(s,new Comparator<Character>(){public int compare(Character a,Character b){return d(f,""+a) - d(f,""+b);}});}static int d(String f,String s){int i=0;PathIterator p=new java.awt.Font(f,0,12).createGlyphVector(((java.awt.Graphics2D)new java.awt.image.BufferedImage(8,8,2).getGraphics()).getFontRenderContext(),s).getGlyphOutline(0).getPathIterator(AffineTransform.getRotateInstance(0.0, 0.0));while(!p.isDone()){i+=p.currentSegment(new double[99])/2;p.next();}return i;}}

Usage:
import java.awt.geom.*;
import java.util.*;
public class F {
    public static void main(String[]args){
        List<Character> s = new ArrayList<Character>(0);
        s.add('@');
        s.add('+');
        s.add('.');
        s.add('0');
        n("Calibri", s);
        System.out.println(s);
    }
    static void n(final String f,List<Character> s){
        Collections.sort(s,new Comparator<Character>(){
            public int compare(Character a,Character b){
                return d(f,""+a) - d(f,""+b);
            }
        });
    }

    static int d(String f,String s){
        int i=0;
        PathIterator p=new java.awt.Font(f,0,12).createGlyphVector(((java.awt.Graphics2D)new java.awt.image.BufferedImage(8,8,2).getGraphics()).getFontRenderContext(),s).getGlyphOutline(0).getPathIterator(AffineTransform.getRotateInstance(0.0, 0.0));
        while(!p.isDone()){
            i+=p.currentSegment(new double[99])/2;
            p.next();
        }
        return i;
    }
}

This setup results in:
[., +, 0, @]

The only line here that needs explanation:
PathIterator p=new java.awt.Font(f,0,12).createGlyphVector(((java.awt.Graphics2D)new java.awt.image.BufferedImage(8,8,2).getGraphics()).getFontRenderContext(),s).getGlyphOutline(0).getPathIterator(AffineTransform.getRotateInstance(0.0, 0.0));

Initialize the 12pt font object with the passed font.
Create a new BufferedImage obejct to create a Graphics2D object linked to a GraphicsContext.
Get the font rendering context of the 2D graphics context for the string s.
Get the first glyph (only glyph) in the string.
Get the path iterator (list of points).

Then this final piece brings it together...
while(!p.isDone()){
    i+=p.currentSegment(new double[99])/2;
    p.next();
}

By iterating through all points and summing count of points. This density information is passed back up to the comparator and is used for sorting.

R, 195 characters
A=strsplit(scan(,""),"")[[1]];cat(A[order(sapply(A,function(x){png('a',a='none',fa='monospace');frame();text(0,0,x);dev.off();sum(apply(png::readPNG('a'),c(1,2),function(x)any(x!=1)))}))],sep="")

Indented with comments:
A=strsplit(scan(,""),"")[[1]] #Take characters as strings and split into single chars
cat(A[order(sapply(A,function(x){ #Apply the following function to each char and order accordingly
                 png('a',a='none',fa='monospace'); #Open empty png without antialiasing and with monospace font
                 frame(); #create empty plot
                 text(0,0,x); #add the char as text to the plot
                 dev.off(); #close png device
                 sum(apply(png::readPNG('a'), #read it back as rbga 3d matrix
                           c(1,2), #check every layer (R, G, B, A)
                           function(x)any(x!=1))) #if any are not 1, send TRUE
                 }))], #Sum all TRUEs
    sep="") #Prints to output

Example:
> A=strsplit(scan(,""),"")[[1]];cat(A[order(sapply(A,function(x){png('a',a='none',fa='monospace');frame();text(0,0,x);dev.off();sum(apply(png::readPNG('a'),c(1,2),function(x)any(x!=1)))}))],sep="")
1: @+.0
2:
Read 1 item
.+0@
> A=strsplit(scan(,""),"")[[1]];cat(A[order(sapply(A,function(x){png('a',a='none',fa='monospace');frame();text(0,0,x);dev.off();sum(apply(png::readPNG('a'),c(1,2),function(x)any(x!=1)))}))],sep="")
1: 1234567890
2:
Read 1 item
1723450689

The gestion of fonts in R plots being platform-dependent, I cannot guarantee that it works on PC, but it does on a Mac (OS X 10.7.5, R 2.14.2).

SmileBASIC, 179 176 173 bytes
INPUT S$DIM Q$[0],A[0],Z[0]WHILE""<S$C$=POP(S$)GCLS
PUSH Q$,C$
GPUTCHR.,0,C$
GSAVE.,0,8,8,A,0S=0FOR I=0TO 63S=S+A[I]NEXT
PUSH Z,S
WEND
RSORT Z,Q$
WHILE LEN(Q$)?POP(Q$);
WEND

Uses the currently loaded font.
Fonts can be loaded with LOAD"GRPF:filename".
More readable code:
INPUT STRING$
DIM CHARS$[0],PIXELS[0],SIZES[0]
WHILE STRING$>""
 CHAR$=POP(STRING$)
 PUSH CHARS$,CHAR$
 GCLS
 GPUTCHR 0,0,CHAR$
 GSAVE 0,0,8,8,PIXELS
 SIZE=0
 FOR I=0 TO 63
  INC SIZE,PIXELS[I]
 NEXT
 PUSH SIZES,SIZE
WEND
RSORT SIZES,CHARS$
WHILE LEN(CHARS$)
 PRINT POP(CHARS$);
WEND

PHP - 485
Demo:
$ php pcg-23362.php "@+.0"
.+0@

Code:
<?php $f='x.ttf';$d=array();foreach(str_split($argv[1]) as$_){$B=imagettfbbox(50,0,$f,$_);$w=abs($B[4]-$B[0]);$h=abs($B[5]-$B[1]);$im=imagecreate($w,$h);imagecolorallocate($im,255,255,255);imagettftext($im,50,0,0,$h-$B[1],imagecolorallocate($im,0,0,0),$f,$_);$b=$w*$h;for($x=0;$x<$w;$x++)for($y=0;$y<$h;$y++){$z=imagecolorsforindex($im,imagecolorat($im,$x,$y));$color=$z['red']*$z['green']*$z['blue'];$b-=$color/0x1000000;}$d[$_]=$b / ($w * $h);}asort($d);echo implode(array_keys($d));

Hey, send me a copy of X.TTF...the shortest font I have is OCR A.  ;-D

Python + freetype-py: 147
import sys,freetype as F;f=F.Face('m.ttf');f.set_char_size(99);print(sorted([(f.load_char(c)or sum(f.glyph.bitmap.buffer),c)for c in raw_input()]))


text:
Write an object-oriented program that produces one example from each signature combination available to that language
Write an object-oriented program that, when ran, outputs one complete example from each reserved-word-vise unique signature combination available to that language. Reserved words for primitive types are excluded. Each example should start from a new line.
This implies that for all signatures any changes in parameters, return types or in their counts do not contribute towards the goal.
The resulting output for Java could be something like this:
private int a;
protected int a;
public int a;
private static int a;
protected static int a;
public static int a;
private static final int a;
protected static final int a;
...
private void a(){};
protected void a(){};
...
private abstract void a();
protected abstract void a();
...

Does the solution itself have to be OOP, or the output?

only for primitive type or for classes too? this would be extremly large, because there are thousands of classes...

@Doorknob Yes the solution must be an object-oriented program that prints the combinations for the same language

@PhilippSander as stated, changing types do not count as they are just different instances for the same signature combination.

Who determines whether our code is object oriented? I don't think that a program is necessarily object oriented just because it was written in a particular language.

@John it is true that many languages are multi-paradigm. I'm hopeful that for solutions not meeting the general definitions of OOP, they are pointed out by the community and accordingly met.

It's clear that what you mean by signature isn't what e.g. the Java Language Specification means by signature (Two methods have the same signature if they have the same name and argument types), but since you haven't specified what you do mean this question is impossible to answer.

I don't think the edit helps. I can tell that you're really asking about something to do with possible partial expansions of declaration-related non-tokens of the language grammar, but you don't give any definitions, and all I can infer from the incomplete example is that you seem to be avoiding some illegal combinations but not all of them; and that you want to at minimum include field and either method or constructor declarations (but what about classes, interfaces, annotations, properties, namespaces, ...? And can I claim to use an earlier version of a language to reduce the cases?)


text:
Merging text files based on a prefix key
Imagine an ordered file set : file1, file2, ... fileN.
Each file is a textual file that is made of lines that have the same format : A concatenation of a fixed-size key (the same among all the file set) and a variable length value.
The merging algorithm is very similar to UPSERT :

To merge 2 files:

Iterate on all lines of the first file.

If the key of the current line is not in the second file, emit the current line.
If the key of the current line is in the second file, emit only the line of the second file

For each line of the second file that has a key not present in the first file emit the line of the second file.

If more than 2 files are to be merged, each file is merged to the result of the previous merge. The result of merge(file1, file2, file3, file4) is defined as the result of merge(merge(merge(file1, file2), file3), file4).

As an example, we take the length of the key of 4 :
$ cat file1
0010THIS_IS_LINE_1_FROM_FILE1
0011THIS_IS_LINE_2_FROM_FILE1
00A0THIS_IS_LINE_3_FROM_FILE1
$ cat file2
0010THIS_IS_LINE_1_FROM_FILE2
0100THIS_IS_LINE_2_FROM_FILE2
$ cat file3
0100EMPTY_LINE
0011EMPTY_LINE

Will result in :
$ merge --key-size=4 file1 file2 file3
0010THIS_IS_LINE_1_FROM_FILE2
0011EMPTY_LINE
00A0THIS_IS_LINE_3_FROM_FILE1
0100EMPTY_LINE

Several precisions :

Textual data is made of printable ASCII7 chars plus tabs and spaces.
Preserving order is nice, but not required
Uniqueness of key is obviously required
Multicore-aware algorithms are allowed.
The first file is usually bigger than the others.

How are you going to check which code is the fastest?

How should my program know how long the key is?

@PeterTaylor using ENV var or cli arguments are perfectly valid solutions. Edited the example to reflect that.

@ProgramFOX i'll be using time on a 15GiB + 4x10MiB dataset on a 4-way i5. I'm adding the fact that the 1rst file is usually bigger than the others.

@SteveSchnepp: And how will you handle different languages?

@ProgramFOX I was thinking about having a winner per language. But we could also make them compete alltogether and start holy wars :)

@ProgramFOX the main purpose of that question is to have fun crafting a solution. As I already did it internally, it isn't as easy as it looks :)

Winner per language is a good idea, except that this site only allows one winner.

Interesting fact is that we only have Perl solutions :) I'll be posting my own solution later, as I didn't want to hamper creativity.

perl, memory-constrained:
Since rubik mentioned it, here's code for when you haven't the memory to keep all of your keys in memory. Basically we just use the filesystem as a dumb key/value store (you could easily use eg DBM or what have you instead).
#!/usr/bin/perl -w

use strict;
use warnings;

use File::Spec ();
use File::Path qw(make_path remove_tree);
use File::Glob ':globally';
use Path::Iterator::Rule;

my $key_size = $ARGV[0] =~ /--key-size=(\d+)/ ?
               (shift @ARGV, $1) : 4;

my $BASE = File::Spec->catfile( File::Spec->tmpdir(), "merger" );

sub pathify {
  my ($key, $mkdirs) = @_;
  my @path = ($BASE, split //, $key);
  my $dirpart = File::Spec->catdir( @path );
  make_path( $dirpart )  if  $mkdirs;
  return File::Spec->catfile( $dirpart, $key );
}

sub set {
  my ($key, $value) = @_;
  open my $fh, '>', pathify($key, 1) || die "open(w) $key failed: $!";
  print { $fh } $value;
  close $fh;
}

sub get {
  my ($key) = @_;
  open my $fh, '<', pathify($key) || die "open(r) $key failed: $!";
  chomp(my $x = <$fh>);
  close $fh;
  return $x;
}

remove_tree( $BASE );

my %keys;
while(@ARGV) {
  my $fn = shift;
  open my $fh, "<", $fn || die "can't open $fn for reading: $!";
  while(<$fh>) {
    chomp;
    set( substr($_, 0, $key_size), substr($_, $key_size) );
  }
  close $fh || die "can't close $fn: $!";
}

my $next = Path::Iterator::Rule->new->file->iter( $BASE );
while( defined( $_ = $next->() ) ) {
  (undef,undef,$_) = File::Spec->splitpath( $_ );
  print $_.get($_)."\n";
}

remove_tree( $BASE );

I felt bad about using a non-core module, Path::Iterator::Rule, but it wasn't worth reinventing the wheel just to avoid the dependency - it's a great module.
You could adapt this to preserve order by changing what is stored in the file from just the $value to include the $order and $value as well. This is trivial because we only ever add keys to the end of the list.

perl
I'm sure this can be done a few percent faster in some other language, but perl makes this super quick to implement at the optimal big-O level, and likely performs well enough. This code preserves order.
#!/usr/bin/perl -w

use strict;
use warnings;

my $key_size = $ARGV[0] =~ /--key-size=(\d+)/ ?
               (shift @ARGV, $1) : 4;

sub slurp {
  my $fn = shift;
  open my $fh, "<", $fn || die "can't open $fn for reading: $!";
  my (%keys, @order);
  while(<$fh>) {
    chomp;
    my $key = substr $_, 0, $key_size;
    push @order, $key;
    $keys{$key} = substr $_, $key_size;
  }
  close $fh || die "can't close $fn: $!";
  return [ \@order, \%keys ];
}

$_ = slurp shift @ARGV;
my @order = @{ $_->[0] };
my %keys  = %{ $_->[1] };
while(@ARGV) {
  my ($order2, $keys2) = @{slurp shift @ARGV};
  $keys{$_} = delete $keys2->{$_}  for (grep { exists $keys2->{$_} } @order);
  for (grep { exists $keys2->{$_} } @{$order2}) {
    $keys{$_} = $keys2->{$_};
    push @order, $_;
  }
}

print "$_$keys{$_}\n"  for  @order;

Test output:
ski@anito$ perl merger.pl --key-size=4 file1 file2  file3
0010THIS_IS_LINE_1_FROM_FILE2
0011EMPTY_LINE
00A0THIS_IS_LINE_3_FROM_FILE1
0100EMPTY_LINE

And here's a slightly faster version that doesn't preserve order:
#!/usr/bin/perl -w

use strict;
use warnings;

my $key_size = $ARGV[0] =~ /--key-size=(\d+)/ ?
               (shift @ARGV, $1) : 4;

my %keys;
while(@ARGV) {
  my $fn = shift;
  open my $fh, "<", $fn || die "can't open $fn for reading: $!";
  while(<$fh>) {
    chomp;
    $keys{substr $_, 0, $key_size} = substr $_, $key_size;
  }
  close $fh || die "can't close $fn: $!";
}

print "$_$keys{$_}\n"  for  keys %keys;

Can this program process a 15Gib dataset + 4 * 10Mib like specified by the OP on a machine with less RAM?

Hmm, I missed that bit. It probably wouldn't work as written above if you have less than ~15GiB ram. The easiest fix would probably be to tie() the hash to a DBM file.

@rubik thx, I didn't say that the machine had less RAM, but I used a 15GiB file to make it obvious :)

Yeah, I didn't see the 15GiB bit at first. Who has time to read comments? ;-) BTW, I have 16GiB of memory on my server downstairs, so it's not entirely a given that the data set can't fit in memory. My other entry keeps the data on disk instead of in memory.


text:
Tetris, Here We Go Again
Code Golfed Tetris
Inspired by a popularity-question (Re)Implementing Tetris and a challenge on SO 3 years ago when PCG did not yet exist, the classy tetris has yet to live again in the art-work of PCG's golfers. So here are the features:
Required:

Game must be playable.
Playfield or blocks are 10 in width and 20 in height
Complete 7 tetrominoes are involved
Controls on the current tetromino: Right and Left Navigator, Tetromino rotator (Can be only clockwise), & Hard drop.

Bonuses:

-50 Distinguished color for each tetromino
-50 Distinguished texture for each tetromino

Provide a photo of the output for those who can't emulate it

There's potential for a really good question here, but as it stands the spec is way too loose. Your bonuses aren't worth the effort because, for example, adding a menu will cost more than 35 characters in any language so it's cheaper to leave it out. I think it would be better to be more strict about what you do and do not want in the entries, and skip the bonuses.

It's always better to be strict about what you do and don't want and skip the bonuses.

must have a reasonable distribution of tetrimnoes What does this mean? Is this just protecting against http://xkcd.com/221/ ?

nope, reasonable in a way that it's variation is supplied for the player to have all 7 tetromino at least every 14 distribution.

@Daniel Are you saying that you want the program to skew the random results to FORCE a distribution? If so that should seriously be put into the question. (NVM, I see that you did). This leads to the question, is this the only restriction on producing tetriminos? If I assign them an ID and pick it with (++curID)%7 would that be valid?

yes, that's my point, but I think that requirement is just way to obvious or normal for tetris game, I'm gonna remove it

"different texture for every tetromino" : Since most answers will be ASCII art, I assume this is just using a different symbol for every tetromino.

Is this challenge still available? Or has it just been abandoned?