text:
Traverse a directory tree and output a list of all files
Write the shortest code that traverses a directory tree and outputs a flat list of all files.

It should traverse the whole directory tree
The order in which it enters sub-directories doesn't matter
The directories should not be output
The output should be a plain list — the definition is flexible, but it shouldn't contain irrelevant data
You are free to use any programming technique

Two questions. 1: what about files in subdirectories? 2: If I do it in bash, can I just use ls (or, recursively, ls -R)?

find 14 characters (12 on GNU)
find . -type f

Run this in the directory you want to list. Add -printf '%f\n' to only print names without the path.
Non-portable: find -type f.

GNU find seems to let you omit the .  for a 2 char saving.  Doesn't seem to work with the BSD find in OSX though.

'-printf' is a GNU find extension. GNU find has assimilated parts of the functionality of 'stat' and 'xargs'. These extensions are not available allwhere in tne unix world (as kindly being warned by the name GNU (GNU is not Unix!)).

I sometimes wonder if non-GNU tools have any functionality at all. Everything that I use seems to be GNU-specific :)

Pure Bash, 7
"ls -R" and "find" are the obvious, already mentioned common shell utilities.  For completeness, we also have this pure bash option (no utility programs):
echo **

This requires the "globstar" shell option to be set with shopt -s globstar.
Note:
This works only for Bash 4.0 and greater.

Python
Aleksi Torhamo's answer is the correct and idiomatic one. My answer is just an exercise of what if there was no os.walk.
I was inspired by an elegant recursive function for Emacs Lisp that does the same.
from os import *
from os.path import *
def walk(path):
    return [basename(f) for f in listdir2(path) if not isdir(f)] +\
        sum([walk(f) for f in listdir2(path) if isdir(f)], [])

listdir2 here is a non-existent function that returns absolute paths of files in a directory. Unfortunately, listdir doesn't return absolute paths, therefore i had to manually enter and exit directories with chdir, so my result wasn't a slick one-liner.
from os import *
from os.path import *
def walk(path, old_path):
    chdir(path)
    result = [f for f in listdir(path) if not isdir(f)] +\
        sum([walk(join(path, f), getcwd()) for f in listdir(path) if isdir(f)], [])
    chdir(old_path)
    return result

To understand it you must read about os.chdir, os.getcwd, os.listdir, os.path.isdir, os.path.basename, os.path.join, sum. The function creates a list of files and recursively repeats this for sub-directories. The list of sub-directories is summed up and appended to the list of original files.
We iterate thru list 2 times, this is inefficient. Better to partition the list into files and directories in one go. This answer proposes a smart use of reduce:
reduce(lambda x, y: x[not p(y)].append(y) or x, l, ([], []))

Attempt #1 (179 171)
from os import*
def w(p,o):chdir(p);r=[f for f in listdir(p)if not path.isdir(f)]+sum([w(path.join(p,f),getcwd())for f in listdir(p)if path.isdir(f)],[]);chdir(o);return r

Attempt #2 (190 178)
from os import *
def u(p,o):chdir(p);a,b=reduce(lambda x,y:x[path.isdir(y)].append(y)or x,listdir(p),([],[]));r=a+sum((u(path.join(p,c),getcwd())for c in b),[]);chdir(o);return r

Hi, and welcome to PPCG! In [tag:code-golf] it's OK to do the inefficient approach if it saves you bytes. :)

I agree with @JonathanVanMatre here, a) Welcome, and b) code golf doesn't care so long as you bring it down to as few bytes as possible... The 179 approach is pretty cool... Very nice SindiKat!

Small tip for golfing in python that could save you a byte or two: You'd be surprised at some places that whitespace isn't required. For example, from os import* is valid.

@sindikat: nice. when I wrote that comment, I actually thought changing the walk(f) to walk(path+'/'+f) would've been enough, I didn't realize the isdir() calls used f too. I think it might still be shorter to do the path+'/'+f thing in all three places instead of passing old_dir and doing two chdir()s, though. (Although os.path.join is definitely the correct way to do it :) Changing the strategy a bit and doing the isdir() straight to the path argument would probably be even shorter.

DOS (11 characters)
dir/s/b/a-d
I love the simplicity, /s allows dir to traverse through all subfolders, while /b suppresses the header and directory information. /a-d suppresses outputting of directories. A quick check to see if the additional space was required, and I was happy enough to submit this...

+1. Though this breaks the third rule The directories should not be output. Add /a-d to suppress the outputting of directories.

Or better yet /aa which will only show Files ready for archiving - which should be all files. Might not always be as accurate as /a-d but it saves a character.

Hold on a second... "The directories should not be output" is a bit vague... Does that mean that the header information with regards to the directory should not be output, or that the directory path cannot be output?
Big difference...

@sindikat, can you please clarify? Are directory paths allowed in my case? What's the point of listing all files in a filesystem without a point of reference? Using /a-d strips the output of this reference point? So if anything UncleMeat's edit of my code screws this up, right?

good point, I took it as 'only enumerate all files in the tree'. Using /a-d doesn't ruin doesn't ruin the point of reference, as each file has it's entire directory path. It just removes outputting the directories themselves.

Python3 - 53 characters
Two equally long ways for doing it:
import os;print(*sum((x[2]for x in os.walk('.')),[]))

and
import os;print(*sum(list(zip(*os.walk('.')))[2],[]))

These print the filenames separated by spaces on one line, I assumed that counts as a "flat list".

C - 203 194
This example works when compiled with TCC:
t(char*p){DIR*d;struct dirent*e;if(d=opendir(p))while(e=readdir(d)){char*n=e->d_name,f[PATH_MAX];sprintf(f,"%s/%s",p,n);if((*n++-46|*n&(*n++-46|*n))&&!t(f))printf("%s\n",f);}return!closedir(d);}

This recursive function displays the path of every file present in the folder which path has been given as a parameter.
Note: one character had to be added to get the same result with GCC:
int t(char*p){DIR*d;struct dirent*e;if(d=opendir(p))while(e=readdir(d)){char f[PATH_MAX];char*n=e->d_name;sprintf(f,"%s/%s",p,n);if((*n++-46|*n&&(*n++-46|*n))&&!t(f))printf("%s\n",f);}return!closedir(d);}

I replaced & with && in the condition. I guess the & operator has priority over && in TCC syntax, while the opposite occurs with GCC.
See the full working example here: http://ideone.com/lGBtJw
C - 220 215 (full program with include)
I liked that Coaumdio used a full program to answer... so I started adapting mine, here is the result:
#include<dirent.h>
main(i,char**p){DIR*d=opendir(*++p);char*n,f[4096],*a=f;struct dirent*e;d||puts(*p);if(d)while(e=readdir(d))sprintf(f,"%s/%s",*p,n=e->d_name),(*n++-46|*n&&(*n++-46|*n))&&main(i,&a-1);closedir(d);}

Expanded version:
#include<dirent.h>

int main(int i,char**p){
    DIR*d=opendir(*++p);
    char f[4096],*n,*a=f;
    struct dirent*e;
    d||puts(*p);
    if(d)while(e=readdir(d))
        sprintf(f,"%s/%s",*p,n=e->d_name),
        (*n++-46|*n&&(*n++-46|*n))&&main(i,&a-1);
    closedir(d);
}

Usage:
gcc list_files.c -o list_files
./list_files /var

Bash, 18
ls -R

Windows CMD.
dir /S

Compliant version
ls -R1|grep -v ^./

ls -R unfortunately prints the headers for each directory. It may not count as a "flat list".

As does dir /S, this also displays the header information...

C, 216 228 chars (#include included)
The other C solution contians nice tricks, but as I like compilable complete C solutions, here is my shot:
#include <dirent.h>
main(int _,char**v){char n[4096],*a=n,*b;DIR*d;struct dirent*e;(d=opendir(*++v))||puts(*v);while(d&&(e=readdir(d)))b=e->d_name,sprintf(n,"%s/%s",*v,b),strcmp(".",b)&&strcmp("..",b)&&main(0,&a-1);}

It's also a recursive traversal algorithm, and it's using the main function as recursive function. The main function tries to open the path contained in argv[1]. If it fails, it prints it, otherwise, it calls main on every sub-element (if it's different from "." or "..").
Usage
It's a standalone, working C program:
$ gcc dir.c -o dir
$ ./dir /var.log
/var/log/kern.log.1
/var/log/alternatives.log.1
/var/log/user.log.2.gz
/var/log/nvidia-installer.log
/var/log/debug.4.gz
/var/log/wtmp.1
/var/log/lastlog
/var/log/messages.2.gz
/var/log/vmware-installer
/var/log/pm-powersave.log
/var/log/syslog.4.gz
/var/log/news/news.err
/var/log/news/news.notice
/var/log/news/news.crit
/var/log/apt/history.log.3.gz
/var/log/apt/history.log.9.gz
/var/log/apt/history.log.4.gz
/var/log/apt/term.log.10.gz
/var/log/apt/history.log.10.gz
/var/log/apt/term.log.4.gz

Tips
I used a few (somewhat classic) C tricks:

replace if(condition)statement with contition && statement
replace if(!condition)statement with condition || statement
use the , operator to save { and } in the while code

Here is a readable version:
#include <dirent.h>
main(int _,char**v) {
    char n[4096], *a=n,*b;
    DIR *d;
    struct dirent *e;
    (d = opendir(*++v)) || puts(*v);
    while(d && (e = readdir(d)))
        b = e->d_name,
        sprintf(n, "%s/%s", *v, b),
        strcmp(".", b)&&strcmp("..", b)&&
            main(0, &a-1);
}

Edit
I have to insert a closedir(d); statement at the end, because a limit is reached when too much folders are opened (wild guess: the open files limit) and the the program stops. This happens only for folder containing many other folders.
the code is now:
#include <dirent.h>
main(int _,char**v){char n[4096],*a=n,*b;DIR*d;struct dirent*e;(d=opendir(*++v))||puts(*v);while(d&&(e=readdir(d)))b=e->d_name,sprintf(n,"%s/%s",*v,b),strcmp(".",b)&&strcmp("..",b)&&main(0,&a-1);closedir(d);}

Without closedir(d), this will abruptely stop if you traverse a big directory (for instance, /)... I also tried to do without the closedir, but had to retract for this reason.

Oh c**p, you're absolutely right! I thought not using closedir was only dirty. Well that's 12 more chars then.

Groovy 58
new File("/").eachFileRecurse(){if(it.isFile())println it}

CMD - 32 Bytes
Another CMD / DOS method -
for /r %a in (*)do @echo %~dpnxa

The /r switch recursively looks through a directory (defaulting to current directory), while %~dpnxa outputs %a, the current directory or file in the loop, to the following output format -
d - drive
p - path
n - name
x - extension
Because x is specified it will only output files, ignoring directories.

Groovy 45
Now even shorter:
new File(".").traverse{if(it.file)println it}

Uses one of the traverse() methods available since Groovy 1.7.1.
Groovy 46 ;-)
Another nice solution, if you don't count the required import statement, is this one:
import groovy.io.FileType.*
new File(".").traverse type:FILES,{println it}

Ruby 18 characters
puts Dir['./**/*']

Java 11, 52 bytes
Files.list(Path.of("")).forEach(System.out::println)

Java, 87 bytes
void t(File f){if(f.isFile())System.out.println(f);else for(File c:f.listFiles())t(c);}

SmileBASIC, 78 bytes
DIM F$[0],D$[0]FILES"//",D$@L
FILES POP(D$),F$WHILE LEN(F$)?POP(F$)WEND
GOTO@L

Displays a * or   before each filename, depending on whether it's a text file (is this allowed?)


text:
Spanish Verb Conjugator
Explanation
¡Hola! For those of you who don't take Spanish, a verb is conjugated based on the person who does the action. Here's a chart:
English                   Spanish
I                         Yo
You                       Tú
He                        Él
She                       Ella
You (formal)              Usted
We all                    Nosotros
You all                   Vosotros
They (masculine, plural)  Ellos
They (feminine, plural)   Ellas
You (plural)              Ustedes

In Spanish, all verbs end with ar, er, or ir. Here's another helpful chart:
          Ar    Er    Ir
Yo        o     o     o
Tú        as    es    es
Él        a     e     e
Ella      a     e     e
Usted     a     e     e
Nosotros  amos emos imos
Vosotros  áis  éis  ís
Ellos     an   en   en
Ellas     an   en   en
Ustedes   an   en   en

Challenge
Given a pronoun and an unconjugated verb, write the shortest program or function that outputs the verb conjugated for the pronoun in the present tense.
Conjugations are given in the tables above, where it is a process of replacing the ar/er/ir ending with its respective conjugated ending.
You do not need to worry about accented output (i.e. "Vosotros" verbs can be conjugated as ais eis is). You also do not need to worry about stem changing and irregular verbs.

Examples
Input        Output
Yo escribir  Escribo
Tu enseñar   Enseñas
Ella querer  Quere (It should be quiere but ignore stem changes)

You can find more words with which to test here: http://spanish.speak7.com/spanish_vocabulary_verbs.htm. Note that contester should be contestar.

Challenge: Stem Changes
In Spanish, some verbs have stem changes. Let's take the verb querer for example. In all forms except nosotros and vosotros, the first e changes to ie. So, yo quiero, but nosotros queremos.
If your program can account for stem changes, you may subtract twice the length of each word you support from your final score.
For example, if you support the i -> ie change querer and only querer, you can subtract twice the length of querer, or 12, from your score.
For some stem-changing verbs, try this: https://conjuguemos.com/chart.php?language=spanish&id=2&etre=no&commands=no&all=no&source=public

(As I am not a native Spanish speaker, please correct me on any mistakes)

I don't take Spanish: I just speak it; but a) tú is the nominative form of the pronoun: tu is genitive; b) verbs aren't "paired" with pronouns; c) nominative pronouns are rarely used in Spanish, so this exercise teaches bad habits; d) you should mention that this is only conjugating the present indicative; e) you haven't said how to handle pronomial (aka reflexive) verbs; f) the most common verbs are irregular, so this isn't a practical tool: if you want to make a verb conjugation question without worrying about irregularities you should use Esperanto instead of Castellano.

a) With what should I replace it? b) How would you word it? c) Not quite sure what you mean. The first example, yo escribo seems like something someone would commonly say. d) I'll fix that. e) You can assume that the se isn't given (ex: yo despertar). f) Not really meant to be practical, and I'll add a challenge for stem changes and one for verbs like ser and estar. Also not sure what Esperanto and Castellano are. Different forms of Spanish?

a) tú; b) Verbs are conjugated according to tense, mood, and grammatical person; c) A native speaker would say Escribo with no pronoun unless really stressing the pronoun; f) Esperanto is an artificial language which has no irregular verbs.

a) Fixing that now. b) Fair enough, fixing. c) True, but this is meant more as a challenge than a useable tool. I could remove the requirement to print the pronoun (yo escribir -> escribo) but I'd rather leave it in. f) I'll just leave it in "normal" Spanish and add a challenge for "special" verbs. Hope I didn't come off as rude, I appreciate the feedback.

Input Yo, Escribir. Correct output: Escribo (except if the person REALLY wants to stress I write!) Input Tu, Enseñar. Correct output: Enseñas (except if the person really wants to stress YOU teach.) Forget about querer, it's irregular. Here's a list of regular verbs from a quick search (contester is wrong, it should be contestar but I haven't found any other mistakes.) http://spanish.speak7.com/spanish_vocabulary_verbs.htm. I'm a native english speaker who's spent 5 years in Madrid by the way.

How should the accented letters be handled? They're not part of standard 7 bit ASCII. You need to specify an extended ASCII codepage, or Unicode, or whatever. Alternatively there's the rather ugly alternative of typing apostrophe or ~ before the relevant letter (which is incorrect but unambiguous.)

@steveverrill I'll amend the examples so they don't print the pronoun. Also, the querer example was just to show that even if an irregular verb was entered, the stem wouldn't need to be changed. I'll add a link to that list above. You can ignore accents if your language doesn't support printing with them.

Linguistically it's looking much better now (except ustedes is you plural, not they.) However you need to clarify how to handle non ASCII accents in both input (especially the pronouns that need to be recognised) and output. Parsing accented pronouns is going to be a real headache. Either specify how this should be done or specify that it's not required (seeing as you've already cut the language down from 7 tenses to one.) That "quere" looks horrible to me but I accept that it's the only way. I have seen similar sacrilege of (for example) musical conventions in other questions.

@rusher the OP has clarified we don't have to consider accents. Therefore we can parse él and ella as just e***. Relevant, and handy, given they conjugate the same.

@steveverrill Fixed ustedes.

While I was in the middle of working on my answer, you changed the scoring by adding a bonus challenge! I'm no longer interested in golfing this because of the additional bonus score modification and the promise of more changes to come. I already wasted an hour on it, and that hour has become your downvote.

@Rusher I don't quite understand what you mean. I'm sorry you feel like you wasted an hour, but I think you should still post your answer. I feel like adding challenges makes it more interesting, but you don't need to accept them. Besides, I can't think of too many more challenges that I could add.

@nrubin29: I didn't downvote but I agree w/ Rusher. You shouldn't change the scoring and rules after the question has been posted - especially after an answer has already been posted. Use the sandbox if you're not happy w/ the question yet.

@Claudiu Fair enough. This is my first question, so I wasn't quite sure how stuff works here. I won't make any more changes.

just present tense? come on, we have a lot of tenses to pick from, some other has to be more interesting :p. As Claudiu said, if you think the question could benefit from feedback, post it in the last sandbox thread in http://meta.codegolf.stackexchange.com (I think the actual is X). Changing the requirements after posting here is rude towards the people who already started to work on an answer

@Einacio the problem with doing more tenses is that, beside having to take in a lot of linguistic data, there'll be a lot of abuse of irregular verbs (ya me choca un montón lo de "quere.") Anyway, as you say, I don't think he should change it more now. I don't fully agree with the new bonuses but -30 for explaining in Spanish is easy for me (even easier for you!) so I may as well take advantage. If I wanted I could probably get -1000 for stem changing verbs (but I think that's unsporting.) Theres about 100 verbs of that type here: http://www.spanishdict.com/answers/100045/present-tense#stem

@steveverrill The -30 for posting an explanation in Spanish is pointless. I don't know more than a few words of Spanish, and I certainly don't plan on learning it for a programming challenge.

@grovesNL at least that -30 doesn't make a huge difference. The thing that's killed this question is the unlimited bonus for stem changing verbs. I thought we'd ironed out the ambiguities for the OP, then he suddenly threw in two new bonuses and offended Rusher. Hopefully he'll learn to think ahead, use the sandbox, and not add bits to his questions after posting. It's too late to go back now.

The only reason why I implemented the Spanish explanation thing was to add a little fun and keep with the theme. I didn't realize how uber-competitve everyone was here. As I said before, I'm new here, so I didn't know that you couldn't add new challenges later (I did know that you can't overhaul the question, of course). I did not know what the sandbox was, therefore I didn't use it. Also, again, I'm sorry for offending anyone by changing the question. I'll probably stay away from asking questions from now on.

@nrubin29 it's not a bad question at all. We aren't cutthroat competitive, but we do have a strong sense of fair play. We're also good at finding loopholes and if done right it's applauded. That means properly specifying a code-golf question is quite demanding as you must anticipate this (you can see the tricks people use!) Feel free to use the sandbox next time, the community will help you work on your question and make it as fair and unambiguous as possible. Judging by popularity-contest is another way to take the pressure off you. See also http://meta.codegolf.stackexchange.com/q/1061/15599

@steveverrill Thanks for the comment, that was extremely helpful. I'll use the sandbox next time. The reason why I chose code golf as opposed to popularity contest is that all answers will do the exact same thing. I guess it could go either way, but of course I'm not going to change anything ;)

@nrubin29: I just want to add that I enjoyed doing this code-golf. The changing-stem challenge was a bit too open-ended (I have a huge negative score) but it was also fun to write that. So I do encourage you to ask more questions! It is indeed difficult to come up w/ a good one.

Empezo or Empiezo?

Python, 172 168 743 characters - 1796 bonus = -1053
Updated to take the stem-changing challenge.
p,v=raw_input().split()
y="aee";z=y+'n'
x=["ooo",y+'s',y,y,y,"aeimos","ae\x00is",z,z]["YoTuElEaUdNsVsEsUs".index(p[0]+p[-1])/2]
s=v[:-2]
X=v='eJw1UuHS5CAIe1aqrNsZhR6w/tj5Hv4Sv7uODRYDxEzlylKTplHS3xrS/3yIm4kntCTVSipkazaZ\n+AA32h3tY1ut+VL7NreXxsEEsgSheGynlJv/GNVvsPs9CIl2hoCSV+gYfuH7rdAyIQdr3+x92yCg\n2g7WEp4vMfTKgogyHabbL4z1l1p/1PLBCF4o9AjtmJBc6wpOTJykM+O0Ib2Y+FyCAuv5wcwCd+Ks\n4+XCdSwhqMIf/eJOFPMjV/rc0jw6IEvm8vjKdBuy/JryMPmEXwIiDInhtK01n1iDPrGu6/A5uy4/\nkBVd89R1OjvHCXbSnoDyaB23nhseElHosf45rzYC1zOevyDojQ548fjGCGg8M5aD8EAmB9GqgFHk\nBzRwDwJ6EcgK5aSDZ2/4TSAjKOMXd3gPh6sTq/+GApG0wkSYdzSBz/AXclUQ+g=='.decode('base64').decode('zip')
if s in X:
 j=X.index(s)<326
 s=(s.replace('oe'[j],'ui'[j]+'e'),s)[p[0]in'NV']
print s+x["aei".index(v[-2])]+x[3:]

Usage:
$ echo "Ellas querer" | python conj_golf2.py
quieren

Test on non-stem-changing inputs:
Yo ensenar -> enseno
Yo escribir -> escribo
Tu ensenar -> ensenas
Tu escribir -> escribes
El ensenar -> ensena
El escribir -> escribe
Ella ensenar -> ensena
Ella escribir -> escribe
Usted ensenar -> ensena
Usted escribir -> escribe
Nosotros ensenar -> ensenamos
Nosotros escribir -> escribimos
Vosotros ensenar -> ensenais
Vosotros escribir -> escribis
Ellos ensenar -> ensenan
Ellos escribir -> escriben
Ellas ensenar -> ensenan
Ellas escribir -> escriben
Ustedes ensenar -> ensenan
Ustedes escribir -> escriben

Stem-changing input examples:
It does both e->ie changes and o->ue changes, properly avoiding the nostros + vostros cases:
$ echo "Yo abstenir"|python conj_golf2.py
abstieno
$ echo "Nostros abstenir"|python conj_golf2.py
abstenimos
$ echo "Tu almorzar"|python conj_golf2.py
almuerzas
$ echo "Vostros almorzar"|python conj_golf2.py
almorzais

Here is how the bonus was determined and the data string generated, from which you can deduce the verbs on which it works:
e="absten.acert.adher.adquer.advert.apret.asent.atraves.calent.cerr."+\
  "circunven.comenz.confer.confes.consent.conten.contraven.conven.convert."+\
  "difer.diger.discern.disent.freg.gobern.hed.hel.her.herv.infer.inger."+\
  "invern.invert.malher.manifest.ment.neg.nev.obten.ofend.pens.perd."+\
  "quer.recomend.reg.seg.sembr.sent.serr.sosegsosten.soterr.subarrend."+\
  "suger.tembl.tend.ten.tent.transfer.tropez.ven.vert"

u="absolv.acord.acost.almorz.along.amobl.apost.aprob.asol.avergonz."+\
  "coc.col.colg.cont.cost.degoll.demol.demostr.desaprob.descolg.descontr."+\
  "desos.destorc.devolv.disolv.dol.dorm.encontr.engros.envolv.forz.holg."+\
  "holl.llov.mol.mor.mostr.mov.ol.pobl.prob.record.reforz.remord.remov.renov."+\
  "repobl.resolv.resoll.reson.retorc.revolc.revolv."+\
  "rod.rog.sol.sold.sol.solt.son.torc.tost.tron.vol.volc.volv"

words = e.split(".") + u.split(".")
bonus = 0
for word in words:
    bonus += (len(word)+2)*2
print "Bonus: %d from %d stem-changing verbs" % (bonus, len(words))

s=(e+"|"+u).replace(".","")
zipped = s.encode('zip')
b64 = zipped.encode('base64')
print "The separator is at index %d" % s.index("|")
print "Uncompressed: %d chars, %d repr" % (len(s), len(`s`))
print "Compressed: %d chars, %d repr" % (len(zipped), len(`zipped`))
print "Comp+B64: %d chars, %d repr" % (len(b64), len(`b64`))

print "v="+`b64`

Which gives:
$ python conj_help.py
Bonus: 1796 from 127 stem-changing verbs
The separator is at index 326
Uncompressed: 645 chars, 647 repr
Compressed: 331 chars, 1015 repr
Comp+B64: 450 chars, 458 repr
v='eJw1UuHS5CAIe1aqrNsZhR6w/tj5Hv4Sv7uODRYDxEzlylKTplHS3xrS/3yIm4kntCTVSipkazaZ\n+AA32h3tY1ut+VL7NreXxsEEsgSheGynlJv/GNVvsPs9CIl2hoCSV+gYfuH7rdAyIQdr3+x92yCg\n2g7WEp4vMfTKgogyHabbL4z1l1p/1PLBCF4o9AjtmJBc6wpOTJykM+O0Ib2Y+FyCAuv5wcwCd+Ks\n4+XCdSwhqMIf/eJOFPMjV/rc0jw6IEvm8vjKdBuy/JryMPmEXwIiDInhtK01n1iDPrGu6/A5uy4/\nkBVd89R1OjvHCXbSnoDyaB23nhseElHosf45rzYC1zOevyDojQ548fjGCGg8M5aD8EAmB9GqgFHk\nBzRwDwJ6EcgK5aSDZ2/4TSAjKOMXd3gPh6sTq/+GApG0wkSYdzSBz/AXclUQ+g==\n'

I'll be staying away from the stem changes because it becomes question of linguistics rather than programming. Acordar should be Acord**, surely? And you can't give the right answer for both regar> riego,riegas etc and regir> rijo, riges etc.

@steveverrill: oh yep I guess "acordar" slipped through. True I can't deal with same verbs of different stem but e.g. "regir" would be wrong anyway since I don't do g->j . Accuracy is not so important for this one. I see your point but I couldn't give up the enormous boon of bonus points =).

@steveverrill: Also there's chance for error if there's a verb that happens to fit in the concatenated verbs put together. e.g. if there's a regular verb "tenacar" it will be conjugated as a stem-changing one. This I can fix by leaving in the .s, would add 50 pts or so to the score

I'm trying to deduce the verb for which you have ten in your list of roots. teñir is e to i, not e to ie; tener is e to ie, but has an irregular stem change for 1s. Similarly abstener, circunvenir, obtener, sostener, venir, cocer, destorcer, oler, retorcer, torcer. On the other hand, your scoring script doesn't seem to count both sentar and sentir. And you're missing a . in sosegsosten, and descontr should probably be descont.

@PeterTaylor: It is tener I think. I didn't realize those verbs you listed had a special case. I can remove them or account for them (whichever is cheaper) and fix the typos if there's another close contender

Python, 240 bytes - (extremely large) bonus
from re import*;import urllib2 as u,sys;x=sys.argv
try:
 print search('>.*?'+sub('a','o',sub('ella','el',x[1]))+'.*? ([^<]*)',sub(u'\u00e9','e',sub(u'\u00fa','u',u.urlopen("http://smarturl.it/xz?word="+x[2]).read()))).group(1)
except:
 pass

Sample Output:
Input         | Output
yo escribir   | escribo
tu escribir   | escribes
tu ensenar    | ensenas
ella querer   | quiere
ellas querer  | quieren
nosotros vive | vi
tu acordar    | acuerdas

Explanation:
This code uses an existing free conjugation website (http://www.conjugation.org/) that returns various conjugations from a large database of verbs. I reduced the URL slightly by using a free online URL shortener that allows parameters to be passed through the redirection (http://smarturl.it/). I simply make a HTTP request based on the verb specified, remove the accents from the u and e in the source, find the pronoun in the HTML using regular expressions, then return associated conjugation.
It's impossible to tell how many verbs have stem changes without polling the entire database against a dictionary. It's probably safe to assume the negative bonus from this database is much larger than any bonus from encoded lists passed in (which increase the length of the code).
I could obviously have handled the accented characters better, but it would've required encode/decode and extra handling within the regular expressions.

No longer funny

@Claudiu: It's not supposed to be a loophole - that post is not relevant here. The question itself has serious flaws which make some kind of external dependency necessary. Passing in a base64-encoded string of data isn't better than connecting to an external data source.

It is better because it is counted as part of my score. My script is entirely self-contained and actually does the conjugation work. Yours just retrieves it from an external data source. You can't even count your score because it depends entirely on how many verbs that data source processes. If that site or the URL shortener goes down then your answer becomes invalid.

@Claudiu: Regardless, it's irrelevant because the question is best suited to reference an external database. The conjugations themselves are as trivial as using re.sub or string.replace when not having to handle stem changes, etc. Even your program would receive a greater negative score if you keep adding further stem changing verbs to your encoded list. The question is flawed.

@Claudiu , grovesNL Hahaha. Haha. Calm down both of you. It is funny in this case because the question is flawed. It's only a game and both of you have errors in your Spanish. It's going to be impossible to call a winner on this because of that flaw. The win is only 15 reputation anyway. Here, have an upvote each and play nicely.

This answer breaks standard loopholes

Freepascal, 218 chars -30 = 189
It's a tough call to beat the (original) python answer, especially with Pascal. I may try and improve tomorrow, possibly with a similar concept in a different language. I will not be submitting a stem-changing answer, as I see this as a linguistic rather than programming challenge.
var y,p,v:string;BEGIN y:='amosemosimosais eis is  as  eso eso   o   an  en  en';readln(p);readln(v);writeln(copy(v,1,length(v)-2),copy(y,6*(7-pos(p[1],' yt v n'))+pos(v[length(v)-1],y),pos(p[length(p)],'u s')+1));END.

Ungolfed version:
var y,p,v:string;
BEGIN
  y:='amosemosimosais eis is  as  eso eso   o   an  en  en';
  readln(p);readln(v);
  writeln(copy(v,1,length(v)-2),
  copy(y,6*(7-pos(p[1],' yt v n'))+pos(v[length(v)-1],y),pos(p[length(p)],'u s')+1));
END.

Explicación (In Spanish for the -30 bonus since you asked)
el primer copy extrae la raíz del verbo, teniendo como parámetros el string, el indice para empezar (en este caso 1) y la cantidad de letras (en este caso length-2.) El segundo extrae su desinencia.
6*(7-pos(p[1],' yt v n') se evalúa según la primera letra del pronombre. Si el pronombre es él/ella(o/s) o usted(es),pos se evalúa a cero, así que el valor dentro de los paréntesis es 7. pos(v[length(v)-1],y busca la penúltima letra del infinitivo en amosemosimos así que avanza 4 por cada tipo de verbo, formando un ciclo de 12. El resto de y consiste en todas las desinencias. Se ha logrado intercalar parcialmente las desinencias para "tu" y "yo." Sin embargo queda cierta cantidad de espacio en blanco que me gustaría eliminar. Así se define el indice para buscar la desinencia en y.
pos(p[length(p)],'u s')+1) determina el numero de caracteres para imprimir. si el pronombre no termina en s o u solo se imprime un cáracter. De esta manera suprimimos la segunda letra de an  en  en en el caso de un pronombre de tercera persona singular: él, ella, usted.
Output

JavaScript (V8), 191 bytes
p=>v=>v.replace(/.r$/,e=>({"Yo":"o","Él":x=e[0]=="a"?"a":"e","Tú":x+"s","Ea":x,"Ud":x,"Ns":e[0]+"mos","Vs":({"a":"áis","e":"éis","i":"ís"})[e[0]],"Es":n=x+"n","Us":n})[p[0]+p.slice(-1)])

Was going to outgolf you and the other JS answer, then realized that I made a small mistake :(

@ophact Wouldn't be surprised if there way a way to outgolf me by 20 bytes :p

Bash, 301 309 (bugfix) 307 299 including new lines
Not great compared to the other ones out there. Could be improved.
It exploits some convenient coincidences.
The bugfix relies on no Spanish verb having "ii" anywhere, due to the way it saves characters when handling vosotros with -ir verbs. Please correct me if that's wrong.
Assumes valid input: first argument is the lower case pronoun, with any necessary accents; second argument is the infinitive of the verb. No stem changes implemented. Outputs the conjugated verb, in lower case, without accents.
e=`tail -c3<<<$2`
f=`echo ${e:0:-1}`
s=`echo ${2:0:-2}`
if [ $1 = yo ];then o="$s"o;elif [ $1 = nosotros ];then o="$s$f"mos;elif [ $1 = vosotros ];then o="$s$f"is;else
if [ $f = i ];then f=e;fi
if [ $1 = tú ];then
o="$s$f"s;elif [ `tail -c2<<<$1` = s ];then
o="$s$f"n;else o=$s$f;fi
fi
tr -s i<<<$o

Explained. ` ` is an obscure notation for $( ), saving one char.
e=`tail -c3<<<$2`

get the verb ending
f=`echo ${e:0:-1}`

get the first char of the verb ending
s=`echo ${2:0:-2}`

get the verb stem
if [ $1 = yo ]; then
o="$s"o;

Verb stem+o. $o is our output
elif [ $1 = nosotros ]; then
o="$s$f"mos;

take stem+first letter of ending+mos
elif [ $1 = vosotros ]; then
o="$s$f"is;

stem+first letter of ending+is (no accents)
else
if [ $f = i ];then f=e;fi

in all scenarios except the two above, -ir verbs behave as -er verbs. change $f to e if it is i.
if [ $1 = tú ]; then
o="$s$f"s;

stem+$f+s
elif [ `tail -c2<<<$1` = s ]; then

if the last letter of the ending is s. this includes ellos, ellas, ustedes
which all have the same endings. how convenient.
o="$s$f"n;

stem+$f+n
else o=$s$f;fi

we are assuming valid input, so the only other possibilities are Él, Ella and Usted, all with the same endings
fi
tr -s i <<< $0

print output, removing double i's (which appear when you use vosotros with an ir verb)

perl, 155 chars
Just a bunch of regular expressions this time. You can get shorter code by rearranging things slightly so that the pronoun comes after the verb, since we only really care about the end of the verb:
$_=<>;s/(.+) (.*)(.)r/$2$3 $1/;s/. yo/o/||s/ tú/s/||s/ n.*/mos/||s/ v.*/is/||s/ .*s$/n/||s/ .*//;s/i(n?)$/e$1/;s/ais$/áis/;s/eis$/éis/;s/iis$/ís/;print

Seems like the above is currently the winner of code that ignores the bonus.
ski@anito:~$ c='$_=<>;s/(.+) (.*)(.)r/$2$3 $1/;s/. yo/o/||s/ tú/s/||s/ n.*/mos/||s/ v.*/is/||s/ .*s$/n/||s/ .*$//;s/i(n?)$/e$1/;s/ais$/áis/;s/eis$/éis/;s/iis$/ís/;print'; for p in yo tú él ella usted ellos ellas ustedes vosotros nosotros ; do for v in mar mer mir ; do echo "$p $v" | perl -e "$c" ; done ; done ; echo -n "$c" | wc -c
mo
mo
mo
mas
mes
mis
ma
me
me
ma
me
me
ma
me
me
man
men
men
man
men
men
man
men
men
máis
méis
mís
mamos
memos
mimos
155

perl, 243 chars
This time focusing on hash lookup. I'm fairly surprised I couldn't get this smaller.
$_=<>;s/^(ustede|ell[oa])s\b/x/;s/^(él|ella|usted)\b/w/;%t=(yo,[o,o,o],"tú",[es,as,es],w,[e,a,e],x,[en,an,en],nosotros,[imos,amos,emos],vosotros,[qw(ís áis éis)]);@t=keys%t;$"="|";s/^(@t)\s+(\S*)([aei])r$/$2.$t{$1}[ord($3)%3]/e||die;print

And if input validation isn't important, 186 chars:
$_=<>;s/^[ue].*s /x /;s/^[éeu].* /w /;%_=(y=>[o,o,o],t,[es,as,es],w,[e,a,e],x,[en,an,en],n,[imos,amos,emos],v,[qw(ís áis éis)]);s/^(.)\S*\s+(.*)([aei])r$/$2.$_{$1}[ord($3)%3]/e;print

Is this an improved answer to your last answer?

I posted 3 different answers with 3 different methods.  The best by char count is the regular expression one.

Got it. Thanks for the submissions!

perl, 298 characters
$_=<>;($p,$b,$x)=/^\s*(yo|tú|él|ellas?|ellos|usted|ustedes|[nv]osotros)\s+(\S*)([aei])r\s*$/;sub r{($z,$y)=@_;return if$p!~/^($z)/;if($p!~/ros$/){$x="e" if$x eq"i"}$x=""if$z eq yo;$x={qw(a áis e éis i ís)}->{$x}if$p=~/^v/;print"$b$x$y";exit}r yo,o;r t,"s";r"[eu].+s",n;r"[éeu]","";r n,mos;r v

or if we can throw caution to the wind and assume valid input, 246 chars:
$_=<>;($p,$b,$x)=/^(\S+)\s+(\S*)([aei])r$/;sub r{($z,$y)=@_;return if$p!~/^($z)/;if($p!~/ros$/){$x="e" if$x eq"i"}$x=""if$z eq yo;$x={qw(a áis e éis i ís)}->{$x}if$p=~/^v/;print"$b$x$y";exit}r yo,o;r t,"s";r"[eu].+s",n;r"[éeu]","";r n,mos;r v

test output:
ski@anito:~$ c='$_=<>;($p,$b,$x)=/^(\S+)\s+(\S*)([aei])r$/;sub r{($z,$y)=@_;return if$p!~/^($z)/;if($p!~/ros$/){$x="e" if$x eq"i"}$x=""if$z eq yo;$x={qw(a áis e éis i ís)}->{$x}if$p=~/^v/;print"$b$x$y";exit}r yo,o;r t,"s";r"[eu].+s",n;r"[éeu]","";r n,mos;r v'; for p in yo tú él ella usted ellos ellas ustedes vosotros nosotros ; do for v in mar mer mir ; do echo "$p $v" | perl -le "$c" ; done ; done ; echo -n "$c" | wc -c
mo
mo
mo
mas
mes
mes
ma
me
me
ma
me
me
ma
me
me
man
men
men
man
men
men
man
men
men
máis
méis
mís
mamos
memos
mimos
246

I think it would be ok to assume valid input, but I didn't state that before. What do you guys think?

@nrubin29 If you didn't state we had to handle invalid input, then we assume we don't have to handle it. (It would have been best to state explicitly in the question that we didn't have to handle it though.) If we did have to handle it, you would have to specify how. This is code golf, virtually all answers here can be broken with invalid input. Also Rusher and I discussed whether it was necessary to parse the whole pronoun in the comments on the question (He deleted his part, but mine is still there.) BTW, you absolutely made the right decision saying that we didn't have to handle accents.

I'll add to the guidelines that valid input can be assumed as long as that doesn't count as "changing the rules". Don't want to anger anyone anymore. Also, when do I accept an answer? After a week?

Java – Too Long
I'm not even going to bother counting. If anyone would like to better golf this, please do. I'll eventually implement the stem-changing challenge.
public class Conjugator {

    public static void main(String[] args) {
        setup();
        String p = args[0].toLowerCase(), v = args[1];
        String e = v.substring(v.length() - 2);
        v = v.substring(0, v.length() - 2);
        String f = data.get(e).get(p);
        System.out.println(v + f);
    }

    static HashMap<String, HashMap<String, String>> data = new HashMap<String, HashMap<String, String>>();

    public static void add(String ending, String pronoun, String fin) {
        HashMap<String, String> hm = data.get(ending);
        if (hm == null) {
            hm = new HashMap<String, String>();
            hm.put(pronoun, fin);
            data.put(ending, hm);
            return;
        }
        hm = data.get(ending);
        hm.put(pronoun, fin);
    }

    public static void setup() {
        add("ar", "yo", "o");
        add("ar", "tu", "as");
        add("ar", "el/ella/usted", "a");
        add("ar", "nosotros", "amos");
        add("ar", "vosotros", "ais");
        add("ar", "ellos/ellas/ustedes", "an");

        add("er", "yo", "o");
        add("er", "tu", "es");
        add("er", "el/ella/usted", "e");
        add("er", "nosotros", "emos");
        add("er", "vosotros", "eis");
        add("er", "ellos/ellas/ustedes", "en");

        add("ir", "yo", "o");
        add("ir", "tu", "es");
        add("ir", "el/ella/usted", "e");
        add("ir", "nosotros", "imos");
        add("ir", "vosotros", "is");
        add("ir", "ellos/ellas/ustedes", "en");
    }
}

JavaScript (Node.js), 195 bytes
(p,v)=>(x=v.charAt(v.length-2))&&(y=p.charAt(0))&&v.substring(0,v.length-2)+(p=='Yo'?'o':p.endsWith('ros')?x+(y=='N'?'mos':(x=='i'?'':'i')+'s'):(x=='i'?'e':x)+(y=='T'?'s':p.endsWith('s')?'n':''))

Try it online!
Doesn't handle the stem changes. It would cost a few more bytes to add the accents to the Vosotros form conjugations. If the input has accents, the output will include them. Also, it doesn't matter if accents are included in the pronouns or not; my program happens to ignore the characters that have accents on them.

HAHA I outgolfed you anyway :p

@RedwolfPrograms :c lol fair enough. i don't use JS much i just did it to snipe you :P

source: Stack Exchange

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

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

sort: votes


text:
Alphanumeric balance
Write a program which gets a string as its input, and counts the number of alphanumeric and non-alphanumeric characters in it. It has to display its result like this:
input: http://stackexchange.com
output: 20 + 4 = 24
The catch is, your source code has to have the same number of alphanumeric characters as non-alphanumeric ones. Comments are not allowed, whitespace is ignored. (The language called Whitespace might compete for votes, but will not be selected as winner, obviously)
Characters in the code must have at least some minor justification, they should not be completely superfluous. For example, longer variable names are allowed, i = (j*3)+4; instead of i = j*3+4; is also allowed. However, i = i + 1;;;;;; is not.
Besides this, standard code-golf rules apply.

If I define a new, preprocessed variant of Ook where the keywords are O., O?, and O! and then any program I write meets the character class restriction... Of course it is likely to lose on the length business.

will it all be ascii?

@JordonBiondo : I was thinking of anything you want from the full 8 bit ANSI to unicode, but if your code only supports 7 bit ASCII, I will accept it as well.

Is the whitespace inside the output-string counted into the non-alphanumerics? Or ignored with all the other (non-string-literal) whitespace?

@dmckee: If you're going to define your own language, just define a variant of the language of your choice where non-empty programs work just like in the base language, but the empty program is preprocessed into code that does exactly what the question asks for.

Will the input have whitespace? Is whitespace to be counted in alphanumeric?

Could you give ascii code ranges for what you define as alphanumeric?

Perl, 32 + 32 = 64
The string is expected in STDIN. The output is written to STDOUT. White space is ignored. My interpretation of the task is that the program should be able to run on itself to get the score.
$/ = $,;
$_ = <>;
s x\sxxg;
$\ = length;
print s x[0-9a-z]xxgi,
      ' + ',
      s x.xxg,
      ' = '

Ungolfed with comments
$/ = $,; # The input separator becomes undefined, because the default for $, is "undef"
$_ = <>; # now $_ takes the whole file (STDIN) instead of the first line
s x\sxxg; # $_ =~ s/\s//g;
          # white space is removed from $_
$\ = length; # The number of the other characters are put into $\,
             # which is automatically printed the end of "print".
print s x[0-9a-z]xxgi, # s/[0-9a-z]//gi
                       # Remove alphanumeric characters and return their count
      ' + ',
      s x.xxg, # s/.//g
               # Remove the remaining special characters and return their count.
               # "." does not catch new lines, but we have already
               # removed white spaces including new lines.
      ' = '

I found several variations with the same byte counts, e.g.:
$/ = $x;
$_ = <>, s x\sxxg;
$\ = split $x;
print s x[\da-z]xxgi,
      " + ",
      s x.xxg,
      ' = '

Examples

Example from the question:
echo 'http://stackexchange.com' | perl a.pl
20 + 4 = 24

Running on itself (a.pl):
cat a.pl | perl a.pl
32 + 32 = 64

The file size is 104 bytes, thus 40 bytes are ignored as white space.

Perl, 29 + 29 = 58
$_=<>;s x\sxxg;$\=length;print s x[0-9a-z]xxgi,' + ',s/.//g,' = '

The string is expected at STDIN and it is limited to the first line. The result is printed to STDOUT.
White space is ignored.
Ungolfed
$_ = <>;
s x\sxxg; # same as s/\s//gx; removes white space;
$\ = length($_); # sum is automatically appended at the end of print
print sx[0-9a-z]xxgi, # same as s/[0-9a-z]//gi;
                      # the number of alphanumeric characters
      ' + ',
      s/.//g, # the number of the remaining special characters
      ' = '

Examples
File a.pl contains the Perl script.

Example from the question:
echo 'http://stackexchange.com' | perl a.pl
20 + 4 = 24

Running on itself:
cat a.pl | perl a.pl
29 + 29 = 58

The file size of a.pl is 65 bytes, thus 7 bytes are ignored as white space.

It seems you are assuming the input is on only one line ... I didn't see anything about that in the spec? Also, what is the justification for the /x flag in the first replace?

@skibrianski: (a) The question is not too clear about the specification of "string". Now I have added a variant that can read whole files. (b) Also it is not clear to me, how white space should be treated by the script. My interpretation is that white space is ignored in both the task and in the score. (c) The /x flag allows white space in the pattern to increase the readability. The updated answer makes use of it.

Re a), the author doesn't say anything about what will be in the string, so I'd guess it's unwise to make assumptions, which to me means newlines must be allowed. Re b) agreed, it's not clear. Re c) Right, but in your answer whitespace doesn't add readability to my eye, it just adds a alphanumeric character...  Maybe I'm being too hard on this point, but it's revealing to me that you only use /x in one of your regexes, presumably to add that one last extra alphanumeric to get the counts to align =) Still I like your answer. I cooked up something pretty similar.

haha now we have essentially identical code =) good show =)

@skibrianski: :-) Thanks, you give me a reason to post one of the other variants with a little more differences. However the byte count remains.

C - 96 (48+48) characters
It's somewhat readable. There's room for improvement, though.
i,j;main(_){while((_=getchar())>=0)isspace(_)||(isalnum(_)?i++:j++);printf("%i + %i = %i",i,j
,i+j);}

Bash + coreutils, 72 (36 + 36) non-whitespace chars
a=`tr -dc [:alnum:]<<<$1|wc -c`
n=`tr -dt [:space:]<<<$1|wc -c`
echo $a + $[n-a] = $n

Output:

$ ./alnumbalance.sh http://stackexchange.com
20 + 4 = 24
$ ./alnumbalance.sh "$(cat alnumbalance.sh)"
36 + 36 = 72
$

Previous answer:
Pure Bash, 92 (46 + 46) non-whitespace chars
nosp=${1//[[:space:]]}
noaln=${nosp//[[:alnum:]]}
echo $[${#nosp}-${#noaln}] + ${#noaln} = ${#nosp}

Output:

$ ./alnumbalance.sh http://stackexchange.com
20 + 4 = 24
$ ./alnumbalance.sh "$(cat alnumbalance.sh)"
46 + 46 = 92
$

Woohoo - it even beats golfscript! ;-)

What about control characters? [:alnum:] is not the inverse of [:punct:]. Try eg head -c256 /dev/urandom | tr -d [:alnum:][:punct:]

@skibrianski good point.  I've edited the answer to take this into account.

PowerShell (43+43=86)
Golfed
function alf($i){$a=0;$n=0;[char[]]$i|%{if($_-match"[a-zA-Z0-9]"){$a++}else{$n++}}; write-host "$a+$n=$($a+$n)"}

Un-golfed
function alf($i){
    $a=0;$n=0;
    [char[]] $i | %{ if ($_ -match "[a-zA-Z0-9]") { $a++ } else { $n++ } };
    write-host "$a+$n=$($a + $n)"
}

Test
PS > alf "http://stackexchange.com"
20+4=24

Testing with the code itself to pass the criteria
PS > alf "function alf($i){$a=0;$n=0;[char[]]$i|%{if($_-match`"[a-zA-Z0-9]`"){$a++}else{$n++}}; write-host `"$a+$n=$($a+$n)`"}"
43+43=86

" has been escaped with ` which is not part of string.

GolfScript, 74 characters (=37+37)
{+}:PLUS;.,.@10,''*26,{65PLUS.32|}%PLUS$-,\1$-' + 'PLUS\PLUS' = 'PLUS\PLUS

Online test for the code with the code as input.

Ruby 38+38=76
This program counts trailing newline in the input.
puts"#{a=gets.scan(/[a-z0-9]/i).length}+#{b=$_.scan(/\W|_/).length}=#{a+b}"

The character count is done by the program itself: $ ruby alphabalance.rb alphabalance.rb :)

Python 2 (60+60 = 120)
Tough one, there is probably room for improvement. Like the fact the function itself can be used to evalulate its own alphnumeric balance.
def f(s):
 i=j=0
 for c in s:
  t=ord(c)
  if (t!=2**5):
   i+=1
  if (48<=t<=57 or 65<=t<=90 or 97<=t<=122):
   j+=1
 print `j`,'+',`i-j`,'=',i

Test:
>>> f("http://stackexchange.com")
20 + 4 = 24

What version of Python is this?

@Gigaflop I edited it. The print statement is Python 2 only, as is the backtick syntax for repr.

Powershell, 70 bytes (=35+35)
param($s)"$(($l=$s.Length)-($n=($s|sls '\W' -a).Matches.Count))+$n=$l"

Test script:
$f = {
param($s)"$(($l=$s.Length)-($n=($s|sls '\W' -a).Matches.Count))+$n=$l"
}

&$f "http://stackexchange.com"
&$f $f.toString().Trim()

Output:
20+4=24
35+35=70

Powershell, 70 bytes (=35+35), alternative
"$(($l="$args"|% Length)-($n=($args|sls '\W'-a).Matches.Count))+$n=$l"

C++, 146 (73+73) 178 (89+89) non-whitespace characters#
Original included <algorithm> for no good reason. Oops.
//create a test string
#include<string>
std::string a = "\?\?=include <cstdio>\
int x,y;\
int main()\?\?<\
    for(char c : a)\
            !isspace(c) ? (isalnum(c) ? y++ : x++) : 0;\
    printf(\"%d\?\?/t%c\?\?/t%d\?\?/t%c\?\?/t%d\?\?/n\",y,'+',x,'=',(x+y));\
\?\?>";

//Code itself starts here
??=include <cstdio>
int x,y;
int main()??<
    for(char c : a)
        !isspace(c) ? (isalnum(c) ? y++ : x++) : 0;
    printf("%d??/t%c??/t%d??/t%c??/t%d??/n",y,'+',x,'=',(x+y));
??>

I am only counting characters in the lines after //Code itself starts here. In particular, this means not counting #include <string>. I am also counting trigraphs as three characters each, which is perhaps debatable. Note that in testing the program on its own source code some care is required to prevent trigraph replacement within the string literal.
There are some peculiar design decisions here -- in most production code you will not encounter trigraphs and range-based-for loops in the same function -- but I think all within the bounds of 'justifiable'.

python 52 +52 = 104
Interesting challnge because python avoids non-alphanumeric characters.
def f(_):
    _=_.replace(" ","");l=len(_);a=sum([c.isalnum() for c in _][:l]);print("{0} + {1} = {2}".format(a,l-a,l))

Minor justification for using slice: it speeds it up (maybe?)

Try using Python 2, since print doesn't require parenthesis, and using the '%d + %d = %d' % (a,l-a,l) method. That should save some characters.

Julia, 64
f(s)=(b=endof(s);a=sum([isalnum(c) for c in s]);"$(a) + $(b-a) = $(b)";)

All the only unnecessary non alphanumeric characters are the last ; and some of the () in the string formatting., it came out almost perfectly balanced, and as a power of 2 without much fiddling.
julia> f("http://stackexchange.com")
"20 + 4 = 24"
julia> nowhite(s)=join(split("s"," "))
julia> f(nowhite("f(s)=(b=endof(s);a=sum([isalnum(c) for c in s]);\"\$(a)+\$(b-a)=\$(b)\";)"))
"32 + 32 = 64"

perl, 64 non-whitespace chars:
$/=$,;
$_=<>;
s 0\s00g;
$\=length;
print s 1[a-z0-9]11ig .
      " + " .
      s 2.22g .
      " = "

Clarified slightly via perl -MO=Deparse and some comments:
$/ = $,;               # input record separator = a variable defaulting to undef
$_ = <ARGV>;           # slurp stdin
s/\s//g;               # strip whitespace
$\ = length $_;        # output record separator = total length of string sans whitespace
print s/[a-z0-9]//gi . ' + ' . s/.//g . ' = '; # count alphanumerics, then everything else

The ORS, $\ is appended automatically in every call to print, putting the total count at the end.

Had 66 characters on my first pass. Thanks to Heiko Oberdiek for showing that you can unset $/ with fewer chars by setting it to $, =)

Python 2, 50 + 50 = 100
import re
def f(i):
    w = re.sub('\s', '', i)
    s = re.subn('[\W_]', '', w)
    a = len(s[0])
    print '%d + %d = %d' % (a, s[1], a+s[1])

Try it Online!

Rebol (64 + 64 = 128)
f: func [x] [
    c: :charset
    a: c [#"a" - #"z"]
    s: c [#" " #"^/" #"^-"]
    n: complement union a s
    a+: n+: 0
    parse x [
        some [
            a (++ a+) |
            n (++ n+) |
            s
        ]
    ]
    print [a+ "+" n+ "=" a+ + n+]
]

Usage example (in Rebol console):
>> f "http://stackexchange.com"
20 + 4 = 24

NB. Program ignores spaces, tabs & newlines from counts.

J - 46 + 46 = 92
Counts whitespace, so you can't self-test without a modification. Takes input on stdin. Has a bad mouth, should go wash it out with soap.
;":&.>(+/;' + ';(#-+/);' = ';#)(e.~1!:1@1:)(,toupper)'golfscriptSUCKSabdehjkmnquvwxyz',,":"0 i.10

Usage:
   ;":&.>(+/;' + ';(#-+/);' = ';#)(e.~1!:1@1:)(,toupper)'golfscriptSUCKSabdehjkmnquvwxyz',,":"0 i.10
http://stackexchange.com
20 + 4 = 24

   NB. modification for self-test:    vvvvvv - remove spaces, the only whitespace
   ;":&.>(+/;' + ';(#-+/);' = ';#)(e.~' '-.~1!:1@1:)(,toupper)'golfscriptSUCKSabdehjkmnquvwxyz',,":"0 i.10
;":&.>(+/;' + ';(#-+/);' = ';#)(e.~1!:1@1:)(,toupper)'golfscriptSUCKSabdehjkmnquvwxyz',,":"0 i.10
46 + 46 = 92

Javascript -  76 (38 + 38)
_ = prompt()
o = _.match(/[a-z0-9]/gi).length
$ = _.length - o
alert(o + " + " + $ + " = " + (o + $))

Sample Input: http://stackexchange.com
Output: 20 + 4 = 24
Running on self:
var a  = '_ = prompt()o = _.match(/[a-z0-9]/gi).length$ = _.length - oalert(o + " + " + $ + " = " + (o + $))'

var letters = a.match(/[a-z0-9]/g).length;
var nons = a.match(/[^a-z0-9 ]/g).length; // excludes whitespace from count

console.log(nons + " = " + letters); // 38 = 38 :)

P.S. For those concerned with (o + $) being done to maintain alphanumeric balance, it is not so. Because after seeing o + " + " JS would decide all + to be string concatenaters rather than number adders. Thus the parentheses are necessary, or 20 + 4 would become 204 rather than 24 :D
Happy Coding!

Clojure: (31 + 31 = 62) non-whitespace chars
(def ff #(let [c count y (c %) x (c (re-seq #"\w" %))] (str x " + " (- y x) " = " y)))

Output:
alphabalance.core=> (ff "http://stackexchange.com")
"20 + 4 = 24"

CJam, 27 + 27 = 54
CJam is a couple of months newer than this challenge, so this answer is not eligible for the green checkmark. It was a fun exercise anyway, though!
ea0=eu{A,s'[,65>+#)g}%_:+1@f-:+ea0=,]"DODDaD"36f-3/]zo

It takes the input string as a command-line argument, so it won't work in the online interpreter, but you can test it with the Java interpreter.
Explanation
"Distinguish alphanumeric characters:";
ea0=eu{A,s'[,65>+#)g}%
ea0=                   "Get the first command-line argument.";
    eu                 "Convert it to upper case.";
      {             }% "Map this block onto each character.";
       A,s             "Get the string '0123456789'.";
          '[,          "Get a string with all characters from the null byte to Z.";
             65>       "Remove the first 65 characters, to leave A to Z.";
                +      "Add to digit.";
                 #     "Find character in that string. Returns -1 if not alphanumeric.":
                  )g   "Increment and get signum. Yields 1 for alphanumeric characters,
                        0 otherwise.";

"Now we've got an array of 0s and 1s. Let's do the counting:";
_:+1@f-:+ea0=,]
_               "Duplicate array.";
 :+             "Get the sum. This is the number of alphanumeric characters.";
   1@           "Push a 1 and pull up the other copy of the array.";
     f-         "Subtract each element from 1, this swaps 0s and 1s.";
       :+       "Get the sum. This is the number of symbol characters.";
         ea0=   "Get the first command-line argument again.";
             ,  "Get its length. This is the total number of characters.";
              ] "Collect everything in an array.";

"And now the formatting:";
"DODDaD"36f-3/]zo
"DODDaD"          "Push this string.";
        36f-      "Subtract 36 from each character. This yields ' +  = '.";
            3/    "Split into two halves of 3 characters each.";
              ]   "Wrap this and the previous array in another array.";
               z  "Zip. Transposes the array to interleave strings with numbers.";
                o "Output the resulting array without delimiters.";

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

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


text:
Golfed+Fast sorting in C
[Latest update: benchmark program and preliminary resuls available, see below]
So I want to test the speed/complexity tradeoff with a classic application: sorting.
Write an ANSI C function that sorts an array of floating point numbers in increasing order.
You can't use any libraries, system calls, multithreading or inline ASM.
Entries judged on two components: code length and performance. Scoring as follows: entries will be sorted by length (log of #characters without whitespace, so you can keep some formatting) and by performance (log of #seconds over a benchmark), and each interval [best,worst] linearly normalised to [0,1]. The total score of a program will be the average of the two normalised scores. Lowest score wins. One entry per user.
Sorting will have to (eventually) be in place (i.e. the input array will have to contain sorted values at return time), and you must use the following signature, including names:
void sort(float* v, int n) {

}

Characters to be counted: those in the sort function, signature included, plus additional functions called by it (but not including testing code).
The program must handle any numeric value of float and arrays of length >=0, up to 2^20.
I'll plug sort and its dependencies into a testing program and compile on GCC (no fancy options). I'll feed a bunch of arrays into it, verify correctness of results and total run time. Tests will be run on an Intel Core i7 740QM (Clarksfield) under Ubuntu 13.
Array lengths will span the whole allowed range, with a higher density of short arrays. Values will be random, with a fat-tail distribution (both in the positive and negative ranges). Duplicated elements will be included in some tests.
The test program is available here: https://gist.github.com/anonymous/82386fa028f6534af263
It imports the submission as user.c. The number of test cases (TEST_COUNT) in the actual benchmark will be 3000. Please provide any feedback in the question comments.
Deadline: 3 weeks (7 April 2014, 16:00 GMT). I will post the benchmark in 2 weeks.
It may be advisable to post close to the deadline to avoid giving away your code to competitors.
Preliminary results, as of benchmark publication:
Here are some results. The last column shows the score as a percentage, the higher the better, putting Johnny Cage in first place. Algorithms that were orders of magnitude slower than the rest were run on a subset of tests, and time extrapolated. C's own qsort is included for comparison (Johnny's is faster!). I'll perform a final comparison at closing time.

Can you provide the benchmark? Different sorting functions perform differently based on the nature of the data. E.g. bubble sort is faster than the stdlib quicksort for tiny arrays. We might like to optimize for your benchmark.

@Claudiu I once saw a lovely short version of quicksort, that ran just as well as any other on data where every element was different. But if some elements were the same, it ran at an absolute snail's pace.  I'm not talking about the known issue of bad choice of pivot in sorted / partially sorted arrays. My test data was completely randomly shuffled. This particular version just didn't like duplicates. Weird, but true.

I haven't written it yet :-) See edit though.

Ok if you want to have a metric that considers both length and runtime, but it's not clear how much weight you're putting on each. length * runtime might be clearer than xlength + yruntime, where x and y are unknown to us.

@steveverrill: x and y are 1 (same weight). length and runtime are normalised based on best and worst entries in each category. Is there any unfairness in this?

Welcome to PPCG! While we don't prohibit language-specific challenges, we do strongly encourage formulating questions in a language-agnostic manner whenever possible. Consider it for your next question, and have fun with this one!

X in characters? ok. Y in milliseconds? seconds? hours? weeks? On your machine or on mine? A short slow program will do well if you measure in hours, and a long fast one if you measure in milliseconds. Hence my suggested metric of length*time which if you log it becomes log(length)+log(time) so your units of time and the speed of your machine become irrelevant.

@JonathanVanMatre: thank you!
steveverrill: normalisation makes it machine independent already, but you have a point about the possibility of a large range of different values. Changing the scoring.

@Mau It doesn't make it machine independent. It just makes it a little less dependent on processor speed. It does not take into account different amounts of registers, caches, out-of-order execution, ...

@steveverrill: I don't follow. It doesn't matter what your unit is because you scale it from 0 to 1 anyway. If min is 1 hour and max is 3 hours, something that takes 1.5 hours will be 0.25 regardless of whether min is 60 minutes, max is 180 minutes, and it takes 90 minutes

@Howard: fair enough, but all programs will be run on the same machine.

Can we use SSE instructions ?

@Michael I'm sure OP will compile with -march=native, but, as stated in the rules, you cannot use inline assembly

No inline assembly :)

@Mau Can I use void sort(float values[],int n) ? I feel more comfortable in that and I guess that both are same BTW.

OP only said no inline assembly - he didn't say anything about intrinsics.

Any minimum size?  Can it fail if n=0?

Well I'd say n=0 should be covered, like in any well-behaved algorithm :)

You should clarify whether the mandatory function signature is included in the count of "those in the sort function". There are entries counting each way.

@JonathanVanMatre: thanks, edited.

It's probably not a big deal, but which Ubuntu 13?

13.10. Stock. With the yellow salamander as background.

Really looking forward to seeing how these perform!

So any Whitespace program will have a score of −∞, because the logarithm of zero tends to negative infinity?

@WChargin any Whitespace program would not make it to the test bench :)

Your benchmark should not allow this: void sort(float*v,int n){ while(n--) *v++=0; }

O(n) performance would stand out too much :)

So? No final results?

Sorry guys, Linux box died :( One on its way soon. I took a snapshot of submission as of deadline. Will be up soon!

150 character
Quicksort.
/* 146 character.
 * sizeup 1.000; speedup 1.000; */
#define REC_SIZE    \
    sort(l, v+n-l); \
    n = l-v;

/* 150 character.
 * sizeup 1.027; speedup 1.038; */
#define REC_FAST  \
    sort(v, l-v); \
    n = v+n-l;    \
    v = l;

void sort(float* v, int n)
{
    while ( n > 1 )
     {
       float* l = v-1, * r = v+n, x = v[n/2], t;
L:
       while ( *++l < x );
       while ( x < (t = *--r) );

       if (l < r)
        {
          *r = *l; *l = t;
          goto L;
        }
       REC_FAST
     }
}

Compressed.
void sort(float* v, int n) {
while(n>1){float*l=v-1,*r=v+n,x=v[n/2],t;L:while(*++l<x);while(x<(t=*--r));if(l<r){*r=*l;*l=t;goto L;}sort(v,l-v);n=v+n-l;v=l;}
}

Leading the race!

150 chars (without whitespaces)
void sort(float *v, int n) {
    int l=0;
    float t, *w=v, *z=v+(n-1)/2;

    if (n>0) {
      t=*v; *v=*z; *z=t;
      for(;++w<v+n;)
        if(*w<*v)
        {
          t=v[++l]; v[l]=*w; *w=t;
        }
      t=*v; *v=v[l]; v[l]=t;
      sort(v, l++);
      sort(v+l, n-l);
    }
}

Awesome, first entry!

Feel free to post an answer with SSE and I'll list it in the scoreboard, though I'm interested in 'portable' solutions for the challenge.

if(*w<*v)         {           t=v[++l]; v[l]=*w; *w=t;         } can be if(*w<*v)           t=v[++l], v[l]=*w, *w=t;

67 70 69 chars
Not fast at all, but incredibly small. It's a hybrid between a selection sort and bubble sort algorithm I guess. If you are actually trying to read this, then you should know that ++i-v-n is the same as ++i != v+n .
void sort(float*v,int n){
    while(n--){
        float*i=v-1,t;
        while(++i-v-n)
            *i>v[n]?t=*i,*i=v[n],v[n]=t:0;
    }
}

if(a)b -> a?b:0 saves a char.

Well, ++i-v-n is the same as ++i != v+n only in a conditional, of course.

@ugoren i think you posted that comment on the wrong answer

@ASKASK, if(*i>v[n])... -> *i>v[n]?...:0

are you sure that is how the prescedence works?

would it be seen as (*i<v[n])?...:0 or as *i<(v[n]?...:0)

@ASKASK: declaring variables inside the loop is not ANSI-compliant, so it won't compile on GCC without special options. Could you fix it? Ta.

@mau i just fixed it

@Mau doesn't everyone have to deal with floating point operations?

I'm still confused... why would it? Also, what indicies are you reffering to?

Sorry, i was talking rubbish :o I read a float* as float I'll delete my comment

@ASKASK This case doesn't seem to terminate: https://gist.github.com/anonymous/d6b9b4b2fa6aa4148777

To be honest I think it is just taking a really really long time, after all this is a very inefficient algorithm

Yep, that's right...

123 chars (+3 newlines)
A standard Shell sort, compressed.
d,i,j;float t;
void sort(float*v,int n){
for(d=1<<20;i=d/=2;)for(;i<n;v[j]=t)for(t=v[j=i++];j>=d&&v[j-d]>t;j-=d)v[j]=v[j-d];
}

PS: discovered it is still 10x slower than quicksort.  You might as well ignore this entry.

Your choice of gaps could be better. Thats probably why this is a lot slower than quicksort. http://en.wikipedia.org/wiki/Shellsort#Gap_sequences

I was amazed to discover how much the gap sequence affects the speed.  With a good sequence it comes close to quicksort but remains slower in my experience.

Don't be too hard on yourself. You're in third place.

511 424 character
Inplace radixsort
Update: Switches to insertion sort for smaller array sizes (increases benchmark performance by a factor of 4.0).
#define H p[(x^(x>>31|1<<31))>>s&255]
#define L(m) for(i=0;i<m;i++)
void R(int*a,int n,int s){if(n<64){float*i,*j,x;for(i=a+1;i<a+n;i++){x=*i;for(
j=i;a<j&&x<j[-1];j--)*j=j[-1];*j=x;}}else{int p[513]={},*q=p+257,z=255,i,j,x,t
;L(n)x=a[i],H++;L(256)p[i+1]+=q[i]=p[i];for(z=255;(i=p[z]-1)>=0;){x=a[i];while
((j=--H)!=i)t=x,x=a[j],a[j]=t;a[i]=x;while(q[z-1]==p[z])z--;}if(s)L(256)R(a+p[
i],q[i]-p[i],s-8);}}void sort(float* v,int n){R(v,n,24);}

Formatted.
/* XXX, BITS is a power of two. */
#define BITS 8
#define BINS (1U << BITS)
#define TINY 64

#define SWAP(type, a, b) \
    do { type t=(a);(a)=(b);(b)=t; } while (0)

static inline unsigned int floatbit_to_sortable_(const unsigned int x)
{   return x ^ ((0 - (x >> 31)) | 0x80000000);
}

static inline unsigned int sortable_to_floatbit_(const unsigned int x)
{   return x ^ (((x >> 31) - 1) | 0x80000000);
}

static void insertsort_(unsigned int* a, unsigned int* last)
{
    unsigned int* i;
    for ( i = a+1; i < last; i++ )
     {
       unsigned int* j, x = *i;
       for ( j = i; a < j && x < *(j-1); j-- )
          *j = *(j-1);
       *j = x;
     }
}

static void radixsort_lower_(unsigned int* a, const unsigned int size,
  const unsigned int shift)
{
    /* @note setup cost can be prohibitive for smaller arrays, switch to
     * something that performs better in these cases. */
    if (size < TINY)
     {
       insertsort_(a, a+size);
       return;
     }

    unsigned int h0[BINS*2+1] = {}, * h1 = h0+BINS+1;
    unsigned int i, next;

    /* generate histogram. */
    for ( i = 0; i < size; i++ )
       h0[(a[i] >> shift) % BINS]++;

    /* unsigned distribution.
     * @note h0[BINS] == h1[-1] == @p size; sentinal for bin advance. */
    for ( i = 0; i < BINS; i++ )
       h0[i+1] += (h1[i] = h0[i]);

    next = BINS-1;
    while ( (i = h0[next]-1) != (unsigned int) -1 )
     {
       unsigned int x = a[i];
       unsigned int j;
       while ( (j = --h0[(x >> shift) % BINS]) != i )
          SWAP(unsigned int, x, a[j]);
       a[i] = x;
       /* advance bins.
        * @note skip full bins (zero sized bins are full by default). */
       while ( h1[(int) next-1] == h0[next] )
          next--;
     }

    /* @note bins are sorted relative to one another at this point but
     * are not sorted internally. recurse on each bin using successive
     * radii as ordering criteria. */
    if (shift != 0)
       for ( i = 0; i < BINS; i++ )
          radixsort_lower_(a + h0[i], h1[i] - h0[i], shift-BITS);
}

void sort(float* v, int n)
{
    unsigned int* a = (unsigned int*) v;
    int i;

    for ( i = 0; i < n; i++ )
       a[i] = floatbit_to_sortable_(a[i]);

    radixsort_lower_(a, n, sizeof(int)*8-BITS);

    for ( i = 0; i < n; i++ )
       a[i] = sortable_to_floatbit_(a[i]);
}

Nice! Try flagging the original answer.

@Mau: Thanks and will do. Wanted to mention an error in the benchmarking code. The cast to void* in qsort (line 88) is throwing off the pointer arithmetic.

331 326 327 312 chars
Does radix sort 8 bits at a time.  Uses a fancy bithack to get negative floats to sort correctly (stolen from http://stereopsis.com/radix.html).  It's not that compact, but it is really fast (~8x faster than the fastest prelim entry).  I'm hoping for speed trumping code size...
#define I for(i=n-1;i>=0;i--)
#define J for(i=0;i<256;i++)
#define R for(r=0;r<4;r++)
#define F(p,q,k) I p[--c[k][q[i]>>8*k&255]]=q[i]

void sort(float *a, int n) {
  int *A = a,i,r,x,c[4][257],B[1<<20];
  R J c[r][i]=0;
  I {
    x=A[i]^=A[i]>>31|1<<31;
    R c[r][x>>8*r&255]++;
  }
  J R c[r][i+1]+=c[r][i];

  F(B,A,0);
  F(A,B,1);
  F(B,A,2);
  F(A,B,3)^(~B[i]>>31|1<<31);
}

395 character
Mergesort.
void sort(float* v,int n){static float t[16384];float*l,*r,*p,*q,*a=v,*b=v+n/2,
*c=v+n,x;if(n>1){sort(v,n/2);sort(v+n/2,n-n/2);while(a!=b&&b!=c)if(b-a<=c-b&&b-
a<=16384){for(p=t,q=a;q!=b;)*p++=*q++;for(p=t,q=t+(b-a);p!=q&&b!=c;)*a++=(*p<=
*b)?*p++:*b++;while(p!=q)*a++=*p++;}else{for(l=a,r=b,p=t,q=t+16384;l!=b&&r!=c&&
p!=q;)*p++=(*l<=*r)?*l++:*r++;for(q=b,b=r;l!=q;)*--r=*--q;for(q=t;p!=q;)*a++=
*q++;}}}

Formatted.
static float* copy(const float* a, const float* b, float* out)
{   while ( a != b ) *out++ = *a++; return out;
}
static float* copy_backward(const float* a, const float* b, float* out)
{   while ( a != b ) *--out = *--b; return out;
}

static void ip_merge(float* a, float* b, float* c)
{
    /* 64K (the more memory, the better this performs). */
#define BSIZE (1024*64/sizeof(float))
    static float t[BSIZE];

    while ( a != b && b != c )
     {
       int n1 = b - a;
       int n2 = c - b;

       if (n1 <= n2 && n1 <= BSIZE)
        {
          float* p = t, * q = t + n1;
          /* copy [a,b] sequence. */
          copy(a, b, t);
          /* merge. */
          while ( p != q && b != c )
             *a++ = (*p <= *b) ? *p++ : *b++;
          /* copy remaining. */
          a = copy(p, q, a);
        }
       /* backward merge omitted. */
       else
        {
          /* there are slicker ways to do this; all require more support
           * code. */
          float* l = a, * r = b, * p = t, * q = t + BSIZE;
          /* merge until sequence end or buffer end is reached. */
          while ( l != b  && r != c && p != q )
             *p++ = (*l <= *r) ? *l++ : *r++;
          /* compact remaining. */
          copy_backward(l, b, r);
          /* copy buffer. */
          a = copy(t, p, a);
          b = r;
        }
     }
}

void sort(float* v, int n)
{
    if (n > 1)
     {
       int h = n/2;
       sort(v, h); sort(v+h, n-h); ip_merge(v, v+h, v+n);
     }
}

121 114 111 characters
Just a quick-and-dirty bubblesort, with recursion. Probably not very efficient.
void sort(float*v,int n){int i=1;float t;for(;i<n;i++)v[i-1]>(t=v[i])&&(v[i]=v[i-1],v[i-1]=t);n--?sort(v,n):0;}

Or, the long version
void sort(float* values, int n) {
  int i=1;  // Start at 1, because we check v[i] vs v[i-1]
  float temp;
  for(; i < n; i++) {
    // If v[i-1] > v[i] is true (!= 0), then swap.
    // Note I am assigning values[i] to temp here. Below I want to use commas
    // so the whole thing fits into one statement, but if you assign temp there you will get sequencing issues (i.e unpredictable swap results)
    values[i - 1] > (temp = values[i]) && (
    // I tried the x=x+y,y=x-y,x=x-y trick, but using a temp
    // turns out to be shorter even if we have to declare the t variable.
      values[i] = values[i - 1],
      values[i - 1] = temp);
  }

  // If n == 1, we are done. Otherwise, sort the first n - 1 elements recursively.
  // The 0 is just because the third statement cannot be empty.
  n-- ? sort(values, n) : 0;
}

As an aside, I found a really interesting algorithm here: http://rosettacode.org/wiki/Sorting_algorithms/Pancake_sort#C
But I cannot get it compressed enough to beat 114 :)

your program seems to fail to complete in some cases and write out of bounds in other cases.

@Mau I tested it on some inputs manually and seemed to work ok, but due to lack of time I didn't test it very thouroughly so I am sure that there is some bad behavior somewhere. Could you post a test case where you ran into trouble please?

test program available above :)

Hmm I tried running it, I am getting some  munmap_chunk(): invalid pointer errors in the cleanup part, but nothing about the test failing. However you are right that there is an off-by-one error, and I seem to have some sequencing issues (the comma-separated list of statements does not do what I expect it to). I'll try to fix it.

I get errors in deletion when a program write outside the bounds of the array (corrupting heap record?)...

Yeah, they are gone now. Updated the code. Thanks for reporting, hopefully it all works now!

That's right. Pretty slow though! :)

Yeah it's O(n^2). Pretty short as well, though :-) Maybe if I get inspiration I will write something faster. Still 7 days to go, right?

154 166 characters
OK, here is a longer but faster quicksort.
void sort(float*v,int n){while(n>1){float*j=v,*k=v+n-1,t=*j;while(j<k){while(j<k&&*k>=t)k--;*j=*k;while(j<k&&*j<t)j++;*k=*j;}*k++=t;sort(k,v+n-k);n=j-v;}}

Here is a correction to survive sorted inputs.  And formatted since white space doesn't count.
void sort(float*v, int n){
    while(n>1){
        float*j=v, *k=j+n/2, t=*k;
        *k = *j;
        k = v+n-1;
        while(j<k){
            while(j<k && *k>=t) k--;
            *j=*k;
            while(j<k && *j<t) j++;
            *k=*j;
        }
        *k++ = t;
        sort(k,v+n-k);
        n = j-v;
    }
}

This version seems to write out of bounds in some cases, not terminating in others.

PS: OK, it is very slow on a sorted set.  But the problem statement says the input is random.

The values are random. I never said anything about what order they'd be in :-) But yes, there are chunks covering about 10% of all values sorted in ascending order and another 10% in descending order.

Fair enough.  And a sort() should work on sorted input.  I'll update my submission, then...

221 193 172 characters
Heapsort - Not the smallest, but in-place and guarantees O(n*log(n)) behavior.
static void sink(float* a, int i, int n, float t)
{
    float* b = a+i;

    for ( ; (i = i*2+2) <= n; b = a+i )
     {
       i -= (i == n || a[i] < a[i-1]) ? 1 : 0;

       if (t < a[i])
          *b = a[i];
       else
          break;
     }
    *b = t;
}

void sort(float* a, int n)
{
    int i;
    /* make. */
    for ( i = n/2-1; i >= 0; i-- )
       sink(a, i, n, a[i]);
    /* sort. */
    for ( i = n-1; i > 0; i-- )
     {
       float t = a[i]; a[i] = a[0];
       sink(a, 0, i, t);
     }
}

 Compressed.
void sort(float* a,int n){
#define F(p,q,r,x,y) for(i=n/p;q>0;){t=a[i];r;for(j=x;(b=a+j,j=j*2+2)<=y&&(j-=(j==y||a[j]<a[j-1]),t<a[j]);*b=a[j]);*b=t;}
float*b,t;int i,j;F(2,i--,,i,n)F(1,--i,a[i]=*a,0,i)
}

You can save some characters by deducting the whitespace. And possibly also the mandatory function signature, but since there are some entries that counted that I've asked questioner to clarify whether it should be counted.

@user19425: If you run the test program with TEST_COUNT = 3000, it seems to fail at least one test.

C 270 (golfed)
#define N 1048576
void sort(float*v,int n)
{
float f[N],g;
int m[N],i,j,k,x;
g=v[0];k=0;
for(i=0;i<n;i++){for(j=0;j<n;j++){if(m[j]==1)continue;if(v[j]<g){g=v[j];k=j;}}f[i]=g;m[k]=1;for(x=0;x<n;x++){if(m[x]==0){g=v[x];k=x;break;}}}
for(i=0;i<n;i++){v[i]=f[i];}
}

Explanation:
A blank array is used to store each successive minimum number. An int array is a mask with 0 indicating the number has not yet been copied. After getting the minimum value a mask=1 skips already used numbers. Then the array is copied back to original.
I changed the code to eliminate use of library functions.

150 character
Shellsort (w/Knuth gap).
void sort(float* v, int n) {
float*p,x;int i,h=0;while(2*(i=h*3+1)<=n)h=i;for(;h>0;h/=3)for(i=h;i<n;i++){x=v[i];for(p=v+i-h;p>=v&&x<*p;p-=h)p[h]=*p;p[h]=x;}
}

Formatted.
static void hsort(float* v, const int h, const int n)
{
    int i;
    for (i = h; i < n; i++) {
        float* p, x = v[i];
        for (p = v + i-h; p >= v && x < *p; p -= h)
            p[h] = *p;
        p[h] = x;
    }
}

void sort(float* v, int n)
{
    int i, h = 0;
    while (2*(i = h*3+1) <= n)
        h = i;
    for (; h > 0; h /= 3)
        hsort(v, h, n);
}

144
I shamelessly took Johnny's code, added a tiny optimization and compressed the code in a very dirty way.  It should be shorter and faster.
Note that depending on your compiler, sort(q,v+n- ++q) must be replaced by sort(++q,v+n-q).
#define w ;while(
void sort(float*v, int n){
    w n>1){
        float *p=v-1, *q=v+n, x=v[n/2], t
        w p<q){
            w *++p<x )
            w *--q>x );
            if( p<q ) t=*p, *p=*q, *q=t;
        }
        sort(q,v+n- ++q);
        n = p-v;
    }
}

Well, actually, I started form my code and optimized it, but it seems Johnny already made all the right choices.  So I ended up with quasi his code.  I didn't think of the goto trick, but I could do without.

228 character
Radixsort.
void sort(float* v, int n) {
#define A(x,y,z) for(x=y;x<z;x++)
#define B h[(a[i]^(a[i]>>31|1<<31))>>j*8&255]
    int m[1<<20],*a=v,*b=m,*t,i,j;
    A(j,0,4) {
        int h[256] = {};
        A(i,0,n) B++;
        A(i,1,256) h[i] += h[i-1];
        for (i = n-1; i >= 0; i--)
            b[--B] = a[i];
        t = a, a = b, b = t;
    }
}


text:
Make a codegolf scorer
You are to make a program that given a number, such as 22009, will go for example to Pi Calculation Code Golf. Then it will, for each answer, try to figure out what the code is, and count its characters. It will then output, for each answer, its number of characters, and a link to it. It should be sorted with fewest characters at the top. For example :

$ answers 22009
5 https://codegolf.stackexchange.com/a/22138/16842
5 https://codegolf.stackexchange.com/a/22188/16842
6 https://codegolf.stackexchange.com/a/22012/16842
6 https://codegolf.stackexchange.com/a/22043/16842

and so on

This is code-golf, so shortest code wins!
Note: If there are multiple things that look like code blocks, it doesn't matter which you choose. It is better though if you look which block actually looks like a program, or you could post a different one for each block.
Note: This specifically says characters. It does not matter what the question actually says, just count characters.

Since 100% correct is a tough goal, what % correctness are we looking for to count as a "valid" answer? If one answer is shorter and the other is a bit more correct, which wins?

How can we tell which code block is the code? Just find the first one?

We could just count all code blocks and post the score for each block separately.

You might try the one with the least whitespace ratio (unless there's the term "whitespace" in the first line of course). That will filter out the common "non-golfed" blocks at least.

Count characters? How about count both characters and bytes? Please run your programs through the sandbox before posting.

@Quincunx wait...the sandbox can run programs now?!?!?  Alright!!!1!

@DavidWilkins What do you mean?

Perl - 233
use LWP::Simple;for($s="http://codegolf.stackexchange.com",$h=get"$s/questions/@ARGV";$h=~/-answerid="(\d+).+?(<div id="answer-|$)/sg;){$a=$&;$i=$1;$_=$1,$_=~s/&.+?;/@/sgm,print length."$u\t$s/a/$i/\n"while$a=~/
(.+?)</sg;}

More aerated version:
use LWP::Simple;
$s="http://codegolf.stackexchange.com";
$h=get"$s/questions/@ARGV";
for(;$h=~/-answerid="(\d+).+?(<div id="answer-|$)/gs;){
    $a=$&;
    $i=$1;
    while($a=~/
(.+?)</gs){
        $_=$1;
        $_=~s/&.+?;/@/sgm;
        print length."$u\t$s/a/$i/\n"
    }
}

This is my first script in this language... so there's still probably a lot of golfing to do.

Javascript? (jQuery) 321
This is my first golf in javascript.
var l={};$(".answercell").each(function(){var w=0,c=0,t=$(this),s;t.find("pre code").each(function(){w+=$(this).text().length;c+=1});s=Math.floor(w/c);if(!isNaN(s)){l[t.find(".short-link").prop("href")]=s}});var s=Object.keys(l).sort(function(a,b){return l[a]-l[b]});for(var i=0;i<s.length;i++){console.log(l[s[i]],s[i])}

Ungolfed:
var list = {};
$(".answercell").each(function () {
    var w = 0, c = 0, s;
    t.find("pre code").each(function () {
       w += $(this).text().length;
       c += 1;
    });
    s = Math.floor(w/c);
    if (!isNaN(s)) {
       list[$(this).find(".short-link").prop("href")] = s;
    }
});
var sorted = Object.keys(list).sort(function(a,b){return list[a]-list[b]});
for (var i=0; i<sorted.length; i++) {
    console.log(list[sorted[i]], sorted[i]);
}

Works in the browser console, so maybe it's against the rules, idk. The way it computes for the score is adding all lenghts of code blocks and then dividing by the number of blocks, for each question.
This version, at 257, just counts the first code block:
var l={};$(".answercell").each(function(){var t=$(this),s;s=t.find("pre code").text().length;if(s>0){l[t.find(".short-link").prop("href")]=s}});var s=Object.keys(l).sort(function(a,b){return l[a]-l[b]});for(var i=0;i<s.length;i++){console.log(l[s[i]],s[i])}


text:
Tips for golfing in Lua
What general tips do you have for golfing in Lua? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Lua (e.g. "remove comments" is not an answer). Please post one tip per answer.

Tips questions should be community wiki. But to whoever submitted this for close as "primarily opinion-based", the Tips for Golfing in Language questions are our accepted exception to that rule. The open-ended nature of these questions is why they are community wiki-ed.

In addition to the ones already posted, here are some tricks I've gathered over time, in no specific order...

For the function calls that only have one parameter delimited by a symbol (" for strings, { for tables), the parameter doesn't need to be wrapped around parentheses.
For example, instead of doing print("hello"), you can simply do : print"hello"

Remove as much whitespace as possible - this is especially easy to do after a symbol that closes strings (or before one opening), function calls, tables... Instead of print(42) a=1 you can do print(42)a=1. Other example: print(a and-1 or-2).

Use the ternary operator when you can! Instead of if a>0 then print("hello") else print("goodbye") end, prefer print(a>0 and "hello" or "goodbye"). More info here.
(This can actually get even better : print(a>0 and"hello"or"goodbye"))

Use the colon-call syntactic sugar when you can : instead of string.rep(str,12), do str:rep(12). That also works on non-variables this way (and only this way) : ("a"):rep(5)

Instead of doing tonumber(str) just do str+0

For functions with no parameters, instead of defining them the usual way (function tick() blabla() end), you can do : ticks=loadstring"blabla()", which saves 1 or more bytes, depending on the content. Also, if you define multiple functions, localize loadstring to a 1-char variable before and you'll save a lot of bytes ;). Credits to Jim Bauwens for this trick.

Lua considers empty string (and 0 too unlike other languages) as true in conditional tests, so, for example, instead of doing while 1 do ... end, save 1 byte by writing while''do ... end

({""})[i]or"s" is 1 char shorter than i==1 and""or"s" and can be written without a whitespace at the beggining, which may save one more byte.

(Added the loadstring trick)

0 being a truthy value is just silly

another str+0 equivalent is ~~str, can be usefull for it's precedence

@FelipeNardiBatista however that's only supported on Lua 5.3+

Shorten your infinite loop
When you have to use an infinite loop, you may think of using a while, but using a label instead is shorter by 2 byte:
while''do end
::a::goto a

Use the less space as possible
There's a simple thing you could (ab)use to remove even more spaces from your code. Lua's specs are clear about the name you give to variables: They have to start with a letter. It imply that, sometimes, you can skip on spaces between numbers and functions/variables
x=0>1 and 0or 1print(x)

The possibility of removing the space depends on the letter following the number, here's the letter that won't allow you to do this:
a,b,c,d,e,f            -- They would be interpreted as hexadecimal
x                      -- only fail when after a 0, other number are fine
                       -- (0x indicates the following is an hexadecimal number)

By using this, and paying attention to how you call your variables, you can make most of your source codes space-free.
Picking up an example already here, and using this advice, here's one more byte you could shaved off :).
print(a and-1 or-2)
print(a and-1or-2)

Use the right input method
If we look at the boilerplate and cost for each major type of input, here's what we have:
function f(x)x end
io.read()
arg[1]

Each one of this method allow us to take 1 input, with the function being the one with the heaviest cost (but allows us to take a table as input)
We can now see that using command-line argument is the way-to-go if you want to golf, but be aware: it can be even shorter
arg[1]
...

The ... are a bit special in lua, it's a variable containing the unpacked content of arg, or the unpacked parameters in case of a variadic function.
When you will have to get more than one input, and use each of them, it can be good to do save them in a variable. Here's some ways to save 2 inputs in variables
a=arg[1]b=arg[2]    -- highly un-efficient, costs 8 bytes by variable
a,b=unpack(arg)     -- costs 15, but at least doesn't depends on the number of argument
a,b=...             -- only costs 7

and here are the shortest call you could have done without the variables:
...     -- using a allow a gain of 1-2 bytes at each use
arg[2]  -- using b allow a gain of 4-5 bytes at each use

From the point where you have 3 argument, or when you use 2 arguments, with one used twice, you're already gaining bytes due to a,b=...! :)
Almost never use if!
There's near no cases where using a if/elseif/if statement will cost less than a ternary. the boilerplate for such a statement is really heavy:
-- exemple with dumb values
if 1>0then v=1 else v=0 end
v=1>0 and 1or 0

With a simple example, you already save 12 bytes, when you have to do some elseifs, it become more and more important, so be aware of that!
Also, ternaries in lua are special, there's some condition in how they work, for those interested, I'll explain it below:
Ternaries in lua are of the form <condition> and <case true: have to be a true value> or <case false: can be anything>
First of all, let's see the truth table of the or. A or can be considered as a function: it always return a value, here's the value it returns:
x | y ||x or y
------||-------
0 | 0 ||   y
0 | 1 ||   y
1 | 0 ||   x
1 | 1 ||   x

That's what allow us to construct our ternary.
The and is what allow us to evaluate the condition, it will always return y if x and y evaluates to true.
The problem with it is that it will fail if we want a nil or false to be return when the condition is false. For instance, the following will always return 5, despite the condition being true.
v = true and false or 5

Here's a step by step evaluation of a ternary to explain how it works (it will be useful for when you have to nest them :))
-- let's use our dumb ternary
= true and false or 5
-- and statement will be evaluated first, leading to
= false or 5
-- and we saw how the or works
= 5

One tip per answer, please.

Note that the "Use the less space as possible" trick only works on Lua 5.2 and later.

@Adriweb On Lua 5.2 and Lua 5.3, actually. They fixed parser accepting madness in 5.4.

@valsaysReinstateMonica some parts of it actually.
For instance, this still works: print(a and-1 or-2)

I have already thought of one.
I don't know if it works in some other languages, but Lua is the only one I know what allows you to store functions in variables. So if e.g. string.subis used multiple times in your program, use e.g. s=string.sub.

It also works in many other languages such as Python and Ruby.

Javascript and Haskell can have function values too.

This is equivalent to s=("").sub or s=a.sub for any variable a containing string value.

This is called first class functions

It's a pretty verbose language for golfing... but some general tips that come to mind are:

Try to avoid conditionals, since if...then...else...end is a major waste.
Instead, try to focus on language constructs that are shorter, e.g. for i=1,5 do.
The # operator is pretty great for golfing (and in general).

Variadic Functions
The main variadic function that will trouble you is print(). For instance, when you're using it along String.gsub() it will print the string you modified AND the number of times gsub triggered.
To supress that second output, encapsulate your gsub in parens to force it to return only one value
print(("").gsub("aa",".","!"))    -- outputs "!!    2\n"
print((("").gsub("aa",".","!")))  -- outputs "!!\n"

I have compiled several tips as well. I'm sure some of mine will overlap with ones already stated, but I'll include them anyhow in the vein of creating a more complete answer.

Assign repeated functions to variables
Lua allows you to assign functions to variables. Even one character variables. This means if you repeat the function string.sub(x, y) more than twice,  you will get a benefit from assigning it to a variable.
Without assigning to a variable (69 characters):
print(string.sub(x, y))
print(string.sub(x, y))
print(string.sub(x, y))

Assigning to a variable (51 characters):
s=string.sub
print(s(x,y))
print(s(x,y))
print(s(x,y))

There's cases where you can take this yet a step further. Lua allows an OOP to string manipulation, like so: str:sub(x, y) or str.sub(x, y) This opens up new options for our code.
 You can assign a variable to the function by it's reference as shown (46 characters.)
s=z.sub
print(s(x, y))
print(s(x, y))
print(s(x, y))

Use the most efficient way to parse strings
You may find yourself using a for loop and string.sub to iterate character by character in Lua. Sometimes this may work best, depending on your needs, but other times, string.gmatch will work in fewer characters. Here's an example of both:
s=io.read()
for a = 1, s:len() do
    print(s:sub(a, a))
end

for i in io.read():gmatch('.') do
    print(i)
end

And when golfed, the difference is more notable:
s=io.read()for a=1,s:len()do print(s:sub(a, a))end

for i in io.read():gmatch'.'do print(i)end

Restructure Assignations To Optimize Whitespace
In Lua, you do not have to put a space character between a closed parentheses or a end quotation mark and the next character. So far, I've found two cases where restructuring with this in mind will cut characters.

Assigning variables:
 x,y=io.read(),0 print(x)
 vs.
 y,x=0,io.read()print(x)

If Statements:
 if x:sub(1,1)==1 then
 vs
 if 1==x:sub(1,1)then

Return the fewest characters possible
If you must return a true or false value, then it seems you must necessarily use at least 5 characters for the return value. In reality the following works just as well:
return true
return false
vs
return 1>0
return 0>1

Great tips, I've taken the liberty to suggest an edit to your post. Only nil and falseevaluates to false in lua, everything else is true, so your tips about replacing x==0,x=="" and x=='' by x is false. I'm currently changing it to nil :).

String paring example can be golfed to (...):gsub('.',print). Replace print with load'your function code' in real golfing.

The expression a==1 and 1or 0 can be shortened to #{[a]=0}.
This works because the array length operator # is actually measuring the number of consecutive integer array indices starting at 1. (Arrays in Lua are 1-based, but they allow assignment at other indices, even those that are negative or floating point.) If there no element at index 1, it will always report a length of zero. And {[a]=0} is an anonymous array with an element of value 0 at index a.
How many bytes this will save depends on the circumstance. For example, if you're already using n%i<1 as a shorthand for n%i==0 to test divisibility, then changing n%i<1 and z or 0 to z*#{[n%i+1]=0} saves 2 or 3 bytes, depending on whether it's followed by a symbol or a keyword/identifier.

These are Lua only (I think) optimizations:
Strings are automatically converted into numbers when doing arithmetic operations on them. Just watch out for conditional statements, they do not automatically convert. This is great for taking user input as numbers while saving space.
Switching the contents of two variables does not require a temporary variable. a,b=b,a will swap the values of a and b.
Also, to extend upon what was said above, any alphanumeric character can touch a non alphanumeric character. So a,b=io.read():match"(.+)/(.+)"u,v=a,b is a perfect, working script, even with the lack of whitespace.

Combine Local Variable Assignments
Instead of:
local a=42
local b=17
local c=99

Use parallel assignment:
local a,b,c=42,17,19

6 bytes saved for each variable!
Declare Local Variables via Unused Function Parameters
Instead of:
function foo(a,b) local c,d ... end
function bar(a,b) local c,d=42,17 ... end

Use
function foo(a,b,c,d) ... end
function bar(a,b,c,d) c,d=42,17 ... end

6 bytes saved (minus 1-2 bytes for each variable that might be duplicated).

Downvoted because there's absolutely no case where using local is justified when golfing, because you just have to use a different name. We could use ALL the names up to 7 charachters AND tables with string indexes up to 7 charachters combinations before we're hitting something that could benefit from using locals

Know how to output
There's two main method of outputting in lua
io.write()    -- outputs without trailing newline
print()       -- outputs with trailing new line and shorter by 3 bytes

When you have to concatenate multiple times, you could shorten that by using io.write() assigned to a one letter variable instead of the standard concatenation operator ..
i(a)    -- i was defined as io.write
s=s..a

You gain 2 bytes at each call while paying some upfront
i=io.write  -- longer by 6 bytes
s=""

You're even on the third concatenation, and start gaining byte on the fourth.

It is print and not printf!

@val Wow, I don't even know how I could do that mistake. Thanks for pointing it out, I'll edit

A bunch of tips in no particular order:

string is pretty long name. Efficiently, ('').char is same as string.char. Even better results can be achieved if you use it together with a semicolon on variables: a=...; print(a:sub(1, 5)), but some string functions don't take strings as input.
Lua has automatic conversions between strings and numbers for most cases, so tonumber and +0 often only waste bytes.
Always use load'your function code here' instead of function()your function code here end. Access function arguments using ... inside.
Some string functions in Lua can be used in unintended ways! For example, a:gsub('.',load'my function') seems to be the shortest way to iterate over chars in a string
While the string engine is powerful, beware of its power when using user input as patterns! Because of that, you might have to use a:find('.',1,1) (to test for this issue, try including % at various places in your input and check out results). Countless ideas broke because of Lua trying to parse input as pattern.
nil is three bytes, _ is one (it is just random name which most likely doesn't exist). Also, any digit will work as truthy value.
Know your logic behind x and i or o. It isn't just a ternary operator - it is a complete logical expression. In fact, it means the following: "if x is truthy, try i. If either x or i is falsy, return o". So if i is not truthy, result is o. Also, both and or or parts can be omitted (x and i, x or o).
Use integer division by one instead of math.floor: 5.3//1==5.0. Please note that the resulting number always follows the type of input one (integer/float).

"Also, any digit will work as truthy value." Just wanted to elaborate that this includes 0, which might not be very intuitive to some coders from a C/C++ background.