text:
Write the fastest Fibonacci
This is yet another challenge about the Fibonacci numbers.
The goal is to compute the 20'000'000th Fibonacii number as fast as possible. The decimal output is about 4 MiB large; it starts with:

28543982899108793710435526490684533031144309848579

The MD5 sum of the output is

fa831ff5dd57a830792d8ded4c24c2cb

You have to submit a program that calculates the number while running and puts the result to stdout. The fastest program, as measured on my own machine, wins.
Here are some additional rules:

You have to submit the source code and a binary runnable on an x64 Linux
The source code must be shorter than 1 MiB, in case of assembly it is also acceptable if only the binary is that small.
You must not include the number to be computed in your binary, even in a disguised fashion. The number has to be calculated at runtime.
My computer has two cores; you are allowed to use parallelism

I took a small implementation from the Internet which runs in about 4.5 seconds. It should not be very difficult to beat this, assuming that you have a good algorithm.

If you have high float precision, it's just Fibo(x) = (phi^x)/sqrt(5) an O(log(n)) operation

@JBernardo If you think this can beat 4.5 sec, please implement it like that for an x64 Linux. I'd live to see your code.

The operation is quite simple. It's all about precision

@Jbernardo The spec says that you have to output the exact number. (Though I won't check every single digit, just a hash). If you think you can code it like that, just do so. But I doubt, that that will be faster than 4.5 secs.

Dude, anything like Sage that has indeterminate float precision will run that thing in less thant 1/10th of second. It's just a simple expression as phi = (1+sqrt(5))/2

@FUZxxl: hash collision FTW!  :D  You can use diff to be 100% certain.

@Bothby I don't know how mlong it takes for you to get a collision for this hash, but IMHP it takes longer than 4.5 secs.

Can we output the number in hex?

@Keith Nope. That's part of the spec.

Since it's to be measured on your CPU, we might as well have some more information about it, couldn't we?  Intel or AMD?  Size of the L1 and instruction caches?  Instruction set extensions?

@J B My cpuinfo

As I compute it, your start string and MD5 are for the 20'000'000th number, not the mere 2'000'000th.

@J B, I just noticed that, too -- and FUZxxl's solution is obviously computing the 20,000,000th.

@boothby oops.... I should really think longer before postin.

@JBernardo, I implemented an arbitrary-precision solution, and it gets utterly killed by my double-and-add solution.  That, in turn, is embarrassingly slow compared to Sage.  I looked into the Sage source; it calls Pari.  I looked at the Pari source... and the algorithm is insane.  I patently refuse to re-implement it and take credit for it.

@boothby link to the algo in the pari source?

Related: first 1000 digits of Fib(10**9).  Some fast implementations, including one using a Fib(2n) and 2n+1 in terms of Fib(n),n+1 recurrence that runs near-instantly.  Also including my x86 machine code answer, featuring lots of brute force, no clever math :P.

C with GMP, 3.6s
Gods, but GMP makes code ugly.  With a Karatsuba-style trick, I managed to cut down to 2 multiplies per doubling step.  Now that I'm reading FUZxxl's solution, I'm not the first to have the idea.  I've got a couple more tricks up my sleeve... maybe I'll try 'em out later on.
#include <gmp.h>
#include <stdio.h>

#define DBL mpz_mul_2exp(u,a,1);mpz_mul_2exp(v,b,1);mpz_add(u,u,b);mpz_sub(v,a,v);mpz_mul(b,u,b);mpz_mul(a,v,a);mpz_add(a,b,a);
#define ADD mpz_add(a,a,b);mpz_swap(a,b);

int main(){
    mpz_t a,b,u,v;
    mpz_init(a);mpz_set_ui(a,0);
    mpz_init(b);mpz_set_ui(b,1);
    mpz_init(u);
    mpz_init(v);

    DBL
    DBL
    DBL ADD
    DBL ADD
    DBL
    DBL
    DBL
    DBL ADD
    DBL
    DBL
    DBL ADD
    DBL
    DBL ADD
    DBL ADD
    DBL
    DBL ADD
    DBL
    DBL
    DBL
    DBL
    DBL
    DBL
    DBL
    DBL /*Comment this line out for F(10M)*/

    mpz_out_str(stdout,10,b);
    printf("\n");
}

Built with gcc -O3 m.c -o m -lgmp.

LOL. Apart from a identifier naming, that's exactly my solution :)

@J B: FIRST!  :D

Keep it ;) The next trick up my sleeve will benefit from Haskell more than from C.

First trick up my sleeve bumped in a GHC bug.  Drat.  I'll have to fall back to the second one, which isn't remotely as fun to implement, so it'll take time and motivation.

3.6 secs on my machine.

Sage
Hmm, you seem to assume that the fastest is going to be a compiled program.  No binary for you!
print fibonacci(2000000)

On my machine, it takes 0.10 cpu seconds, 0.15 wall seconds.
edit: timed on the console, instead of the notebook

My idea was not to know, how fast your CAS can do this, but rather how fast you can code this by yourself.

For the record, I just put this up to be a smartass; you didn't say not to use builtins.

Haskell
This is my own try, although I did not wrote the algorithm by myself. I rather copied it from haskell.org and adapted it to use Data.Vector with its famous stream fusion:
import Data.Vector as V
import Data.Bits

main :: IO ()
main = print $ fib 20000000

fib :: Int -> Integer
fib n = snd . V.foldl' fib' (1,0) . V.dropWhile not $ V.map (testBit n) $ V.enumFromStepN (s-1) (-1) s
    where
        s = bitSize n
        fib' (f,g) p
            | p         = (f*(f+2*g),ss)
            | otherwise = (ss,g*(2*f-g))
            where ss = f*f+g*g

This takes around 4.5 seconds when compiled with GHC 7.0.3 and the following flags:

ghc -O3 -fllvm fib.hs

Weird... I needed to change 20000000 to 40000000 to get it to print the expected number.

Gotcha.  Should be enumFromStepN (s-1) instead of enumFromStepN s

@J B Sorry for all this confusion. I initially tested the program with different values to get a reasonably big number and saved the output into different files. But some how I confused them. I have updated the number to match the desired result.

@boothby No, I did not change the desired fibonacci number, but rather the reference output, which was wrong.

Side note: it's about 1.5s on my machine, but neither LLVM not Data.Vector seem to bring any significant advantage.

COW
 MoO moO MoO mOo MOO OOM MMM moO moO
 MMM mOo mOo moO MMM mOo MMM moO moO
 MOO MOo mOo MoO moO moo mOo mOo moo

Moo! (Takes a while. Drink some milk...)

Note: Although this really does work, it will probably never reach 20,000,000...

Mathematica, interpreted:
First@Timing[Fibonacci[2 10^6]]

Timed:
0.032 secs on my poor man's laptop.

And of course, no binary.

Doesn't print to stdout.

@boothby Wrong. It writes to standard output if you use the command line interface. See for example http://stackoverflow.com/questions/6542537/batch-input-and-output-in-mathematica/6542653#6542653

Nope, I'm using the commandline interface, version 6.0.  Even using -batchoutput, it only prints timing info and not the Fibonacci number.

Sorry, can't reproduce since I don't have mathematica.

curl 'http://www.wolframalpha.com/input/?i=Fibonacci%5B2+10^6%5D' | grep 'Decimal approximation:' | sed ...  It runs in constant time with respect to the speed of your Internet connection.  ;-)

@belisarius what a lame solution.  Why don't you code it yourself?

CLI != executable binary

Ocaml, 0.856s on my laptop
Requires the zarith library. I used  Big_int but it's dog slow compared to zarith. It took 10 minutes with the same code! Most of the time was spent printing the damn number (9½ minutes or so)!
module M = Map.Make
  (struct
    type t = int
    let compare = compare
   end)

let double b = Z.shift_left b 1
let ( +. ) b1 b2 = Z.add b1 b2
let ( *. ) b1 b2 = Z.mul b1 b2

let cache = ref M.empty
let rec fib_log n =
  if n = 0
  then Z.zero
  else if n = 1
  then Z.one
  else if n mod 2 = 0
  then
    let f_n_half = fib_log_cached (n/2)
    and f_n_half_minus_one = fib_log_cached (n/2-1)
    in f_n_half *. (f_n_half +. double f_n_half_minus_one)
  else
    let f_n_half = fib_log_cached (n/2)
    and f_n_half_plus_one = fib_log_cached (n/2+1)
    in (f_n_half *. f_n_half) +.
    (f_n_half_plus_one *. f_n_half_plus_one)
and fib_log_cached n =
    try M.find n !cache
    with Not_found ->
      let res = fib_log n
      in cache := M.add n res !cache;
      res

let () =
  let res = fib_log 20_000_000 in
  Z.print res; print_newline ()

I can't believe how much a difference the library made!

For comparison @boothby's solution takes 0.875s to run on my laptop. It seems the difference is neglible. Also, apparently my laptop is fast :o

Haskell
On my system, this runs almost as fast as FUZxxl's answer (~18 seconds instead of ~17 seconds).
main = print $ fst $ fib2 20000000

-- | fib2: Compute (fib n, fib (n+1)).
--
-- Having two adjacent Fibonacci numbers lets us
-- traverse up or down the series efficiently.
fib2 :: Int -> (Integer, Integer)

-- Guard against negative n.
fib2 n | n < 0 = error "fib2: negative index"

-- Start with a few base cases.
fib2 0 = (0, 1)
fib2 1 = (1, 1)
fib2 2 = (1, 2)
fib2 3 = (2, 3)

-- For larger numbers, derive fib2 n from fib2 (n `div` 2)
-- This takes advantage of the following identity:
--
--    fib(n) = fib(k)*fib(n-k-1) + fib(k+1)*fib(n-k)
--             where n > k
--               and k ≥ 0.
--
fib2 n =
    let (a, b) = fib2 (n `div` 2)
     in if even n
        then ((b-a)*a + a*b, a*a + b*b)
        else (a*a + b*b, a*b + b*(a+b))

Nice.  I love Haskell.

I ran this in ghci. I was pretty impressed. Haskell is great for these types of mathematical code problems.

C, naive algorithm
Was curious, and I hadn't used gmp before... so:
#include <stdio.h>
#include <stdlib.h>
#include <gmp.h>

int main(int argc, char *argv[]){
    int n = (argc>1)?atoi(argv[1]):0;

    mpz_t temp,prev,result;
    mpz_init(temp);
    mpz_init_set_ui(prev, 0);
    mpz_init_set_ui(result, 1);

    for(int i = 2; i <= n; i++) {
        mpz_add(temp, result, prev);
        mpz_swap(temp, result);
        mpz_swap(temp, prev);
    }

    printf("fib(%d) = %s\n", n, mpz_get_str (NULL, 10, result));

    return 0;
}

fib(1 million) takes about 7secs... so this algorithm won't win the race.

I implemented the matrix multiplication method (from sicp, http://sicp.org.ua/sicp/Exercise1-19) in SBCL but it takes about 30 seconds to finish.  I ported it to C using GMP, and it returns the correct result in about 1.36 seconds on my machine.  It's about as fast as boothby's answer.
#include <gmp.h>
#include <stdio.h>

int main()
{
  int n = 20000000;

  mpz_t a, b, p, q, psq, qsq, twopq, bq, aq, ap, bp;
  int count = n;

  mpz_init_set_si(a, 1);
  mpz_init_set_si(b, 0);
  mpz_init_set_si(p, 0);
  mpz_init_set_si(q, 1);
  mpz_init(psq);
  mpz_init(qsq);
  mpz_init(twopq);
  mpz_init(bq);
  mpz_init(aq);
  mpz_init(ap);
  mpz_init(bp);

  while(count > 0)
    {
      if ((count % 2) == 0)
        {
          mpz_mul(psq, p, p);
          mpz_mul(qsq, q, q);
          mpz_mul(twopq, p, q);
          mpz_mul_si(twopq, twopq, 2);

          mpz_add(p, psq, qsq);    // p -> (p * p) + (q * q)
          mpz_add(q, twopq, qsq);  // q -> (2 * p * q) + (q * q)
          count/=2;
        }

      else
       {
          mpz_mul(bq, b, q);
          mpz_mul(aq, a, q);
          mpz_mul(ap, a, p);
          mpz_mul(bp, b, p);

          mpz_add(a, bq, aq);      // a -> (b * q) + (a * q)
          mpz_add(a, a, ap);       //              + (a * p)

          mpz_add(b, bp, aq);      // b -> (b * p) + (a * q)

          count--;
       }

    }

  gmp_printf("%Zd\n", b);
  return 0;
}

Java: 8 seconds to compute, 18 seconds to write
public static BigInteger fibonacci1(int n) {
    if (n < 0) explode("non-negative please");
    short charPos = 32;
    boolean[] buf = new boolean[32];
    do {
        buf[--charPos] = (n & 1) == 1;
        n >>>= 1;
    } while (n != 0);
    BigInteger a = BigInteger.ZERO;
    BigInteger b = BigInteger.ONE;
    BigInteger temp;
    do {
        if (buf[charPos++]) {
            temp = b.multiply(b).add(a.multiply(a));
            b = b.multiply(a.shiftLeft(1).add(b));
            a = temp;
        } else {
            temp = b.multiply(b).add(a.multiply(a));
            a = a.multiply(b.shiftLeft(1).subtract(a));
            b = temp;
        }
    } while (charPos < 32);
    return a;
}

public static void main(String[] args) {
    BigInteger f;
    f = fibonacci1(20000000);
    // about 8 seconds
    System.out.println(f.toString());
    // about 18 seconds
}

Go
It's embarrasingly slow. On my computer it takes a little less than 3 minutes. It's only 120 recursive calls, though (after adding the cache). Note that this may use a lot of memory (like 1.4 GiB)!
package main

import (
    "math/big"
    "fmt"
)

var cache = make(map[int64] *big.Int)

func fib_log_cache(n int64) *big.Int {
    if res, ok := cache[n]; ok {
        return res
    }
    res := fib_log(n)
    cache[n] = res
    return res
}

func fib_log(n int64) *big.Int {
    if n <= 1 {
        return big.NewInt(n)
    }

    if n % 2 == 0 {
        f_n_half := fib_log_cache(n/2)
        f_n_half_minus_one := fib_log_cache(n/2-1)
        res := new(big.Int).Lsh(f_n_half_minus_one, 1)
        res.Add(f_n_half, res)
        res.Mul(f_n_half, res)
        return res
    }
    f_n_half := fib_log_cache(n/2)
    f_n_half_plus_one := fib_log_cache(n/2+1)
    res := new(big.Int).Mul(f_n_half_plus_one, f_n_half_plus_one)
    tmp := new(big.Int).Mul(f_n_half, f_n_half)
    res.Add(res, tmp)
    return res
}

func main() {
    fmt.Println(fib_log(20000000))
}

I tried parallelizing it (before adding the cache) using go routines and it started using 19 GiB of memory :/


text:
Meta Golf Challenge
On that challenge you have to solve that challenge.
Contest is over! Check the end of the question
Specs:

Write the smallest code (Any language*).
The score of an answer is the sum of:

Code length without whitespace.
Number of answers using that same language squared.
Length of the name of the biggest language on the contest minus the length of your language.
Downvotes minus Upvotes (a.k.a. minus Total of Votes)

Write the position of the users and the score.
Each user can write only one answer.
The lowest score wins.

Testing:
So, at the end of the contest, a possible input could be (STDIN):
The columns are: Username, Language, Code length(w/o whitespace) and TotalVotes
UserA Python 100 1
UserB Perl 30 2
UserC Java 500 3
UserD Brainfuck 499 4
UserE Perl 29 5

If your user name has spaces like "My User Name" it'll become "MyUserName" so the input will always have exactly 4 columns.
The output will be (STDOUT):
1 UserE 33
2 UserB 37
3 UserA 103
4 UserD 496
5 UserC 503

Explanation:
User  P  N^2  L   V
 A   100  1   3  -1
 B    30  4   5  -2
 C   500  1   5  -3
 D   499  1   0  -4
 E    29  4   5  -5

Brainfuck is the largest name with 9 chars (9 - 9 = 0).
Perl and Java have 4 chars (9 - 4 = 5).
Python has 6 chars (9 - 6 = 3).
Perl has 2 entries so each get 4 extra points.

About languages:
The name of the language must contain only English letters (i.e. [A-Za-z]) and those which don't fit that must be "translated" to something else.
By the end of the contest, every language must have it's representation (You may propose better representations)
Examples:
Python3      -> Python
Ruby1.9      -> Ruby
Shell Script -> Shell
C++          -> Cpp
C#           -> CSharp
><>          -> Fish

Deadline: August 20, 2011 00:00 UTC

At the end of the contest, the winner must use his/her program to find the winner. It's allowed to non winners to use their programs to find the winner and tell him/her to use his/her program to find the winner. :)

The winner (see above) gets the answer accepted!

*The Whitespace language has the unfair advantage of being able to introduce unlimited complexity without a penalty on the character count. Answers written in Whitespace may be on the contest but can't win.
If you can make the logic of your program in whitespaces, you also can't win. That's a subjective topic, but if your program can increase considerably in size without being penalized, it falls in that condition.

Final Input
Alphabetical order of names (as of Aug 20th 2011 UTC 00:00)
boothby Sage 41 9
Harpyon Python 203 4
JBernardo Python 184 7
JoeyAdams PostgreSQL 225 6
jpjacobs AWK 269 4
Lowjacker Ruby 146 2
PeterTaylor Golfscript 82 4
rmackenzie CommonLisp 542 2
shesek Javascript 243 3
userunknown Scala 252 1

As both mine and boothby's answers are not allowed to win, the winner should proclaim himself the winner by editing this question and posting the final output below.
Final Output
1 boothby 39
2 PeterTaylor 79
3 Lowjacker 151
4 JBernardo 185
5 Harpyon 207
6 JoeyAdams 220
7 shesek 241
8 userunknown 257
9 jpjacobs 273
10 rmackenzie 541

Is the goal to have the lowest score or the highest score?

@Joey Lowest (it's code golf! :) I Fixed the question.

This contest favors languages with longer names, correct?

Yes. It also favors languages with lots of whitespaces, answers with lots of upvotes and obscure languages.

Does that mean a solution in Whitespace will automatically win?

@Joey I thought of that, but i don't know if whitespace should be banned or not. Maybe if someone is crazy enough to write in Whitespace and don't get too much downvots he should win...

Where does the information about other answers come from? Are our programs supposed to connect to StackExchange and mine the answers to this question?

It's ><>, not <><. Imagine I'd call you odranreBJ instead of JBernardo! :P (Creator of ><> here)

@Justin At the end of the contest, I'll make the real program input with the answers. I gave the format

@Harpyon <>< ti dexif I !sknahT

The input format might deserve a bit more detail.  For example, some user names have spaces, which is tricky with the current example.  Which might or might not be what you want, you tell us.

@JB The spaces will be stripped (Like I did with your user name). Is anything else about the input format missing?

Must we sort the output by scores?  If so, what should we do in case of tie?

@boothby The answer posted first should win but you don't have worry about that. Just sort those with same number of points the way you like.

It seems there could be some evil strategies that could go on. For example, if a Javascript solution was currently winning, I could post three more solutions in Javascript to lower its score.

@Peter, only one per user.   I mean... you could make puppets... but don't.

@Franklin It will be on the contest but I won't choose as right answer if it wins (As said on the last paragraph). In addition, I won't choose my answer if it wins.

@JBernardo Yeah... I figured you'd update the rule once I posted my solution.  What I didn't expect is to have a positive vote total.

Added a small bounty to remind people of the August 20 deadline.

@Joey Adams Oh, nice!

"Perl has 2 entries so each get 4 extra points." <- they get 3 extra points, since the others get 1 point.

It would be a spec violation for my bootstrapping code to have the usage ./btstrp ./test-file as opposed to cat ./test-file | ./btstrp, correct?

I don't get it, what are we building? A whitespace interpreter or a parsing lib for the four column input?

@Xeoncross just sort the input using the rules (and they say Whitespace languages will make your answer 'invalid')

@rmackenzie if your language can't use stdin it might be ok... But doesn't seems like your case.

@Joey - May I please have a Mod ruling on the spec-compliance and legality of my posted solution?

@rmckenzie: I'm not a Mod.  However, the problem with your wget solution is that you can arbitrarily increase the complexity of your solution without a corresponding increase in code size (the same problem with the Sage solution).  Furthermore, downloading code and immediately executing it is dangerous, if it is not sandboxed properly.  For these reasons, I will not put a bounty on your wget solution.

@joey - my bad. Valid comments, thank you. Btw - who are the mods (if we have any)? I was under the impression that you and Peter were admins of only due to seniority.

I awarded the bounty to Peter Taylor's Golfscript solution.  He would have needed -69 votes to fall to third place.  jpjacobs and rmckenzie, I am sorry to say that you have fallen below the yellow line and will be up for elimination tonight.

@mckenzie, the most visible codegolf.se mods are gnibbler, Chris Jester-Young,  dmckee; there are a few more, but I don't know a better way to get a full list than to go through the entire Users page looking for blue diamonds. However, for rulings on this question the final arbiter would be JBernardo, and for rulings on the awarding of the bounty it would be Joey Adams.

Golfscript, 83 chars (82 not counting whitespace)
n/{},{' ':s/}%.{1=}%\{~~\~\-\.`{=}+4$\,,.*\,-+2${,}%$)\;+[\]}%$\;.,,]zip{~)s@~s@n}%

Explanation:
# Split the string containing all the input on newlines
n/
# Remove empty lines
{},
# Split each line on spaces (storing the space character in variable s)
{' ':s/}%
# We now have an array of arrays of words. Duplicate it, filter the copy to contain
# only the second word of each array, and reorder with the array of second words first
.{1=}%\
# Map each line
{
    # Unpack the array ["user" "lang" "length" "votes"] and evaluate the integers
    ~~\~\
    # Subtract votes from length and bring "lang" to the top
    -\
    # Create a function to match the string "lang"
    .`{=}+
    # Stack is currently [array of langs] "user" (length-votes) "lang" {"lang"=}
    # Duplicate the array of langs and apply the match function as a filter
    4$\,
    # Get the length of the array of matches and square it
    ,.*
    # Stack is [array of langs] "user" (length-votes) "lang" (num with lang)^2
    # Bring the "lang" to the top, get its length, subtract and add
    \,-+
    # Stack is [array of langs] "user" (score-length of longest lang)
    # Get an array of length of language names and sort it
    2${,}%$
    # Drop it apart from the largest value, and add that to the score
    )\;+
    # Package the "user" score from the top of the stack as [score "user"]
    [\]
}%
# Sort. Since each element is a [score "user"] value, this will sort by score.
$
# Discard the [array of langs].
\;
# Stack is an array of [score "user"] arrays. Get its length and create an array of the
# same length which counts from 0.
.,,
# Group and zip, so we go from [[score0 "user0"] ... [scoren "usern"]] [0 ... n] to
# [[[score0 "user0"] 0] ... [[scoren "usern"] n]]
]zip
# Map each [[scorei "useri"] i]
{
    # Expand, increment i (so we count from 1 rather than 0), add a space
    ~)s
    # Bring the [scorei "useri"] to the top, unpack, add a space
    @~s
    # Bring the scorei to the top, add a newline
    @n
}%
# We now have an array [[1 " " "userA" " " scoreA "\n"] ... [n " " "userZ" " " scoreZ "\n"]
# so Golfscript's standard output formatting does the rest

That's pretty neat, I should take a look at GolfScript... I have no idea how that's parsed into something meaningful

@shesek, added a heavily commented version

wow, very cool! thanks :-)

Sage: 48 42 41 non-whitespace (60246 bytes total)
Just to be a prick:
s = '   '
for c in '<lots of whitespace>'.split(s):
    s+=chr(len(c))
exec s

Note that the first line should be equivalent to s='\t', but the SE code block translates the tab to 4 spaces.
The whitespace unpacks to:
exec preparse("""
import sys
instances = {}
maxlen = 0
inputs = [line.split() for line in sys.stdin.readlines()]
for i in [0..len(inputs)-1]:
    user, language, length, votes = inputs[i]
    if language in instances:
        instances[language]+=1
    else:
        instances[language]=1
    if len(language) > maxlen:
        maxlen = len(language)

scoresheet = []
for i in [0..len(inputs)-1]:
    user, language, length, votes = inputs[i]
    length = int(length)
    votes = int(votes)
    score = length + (maxlen - len(language)) + instances[language]*instances[language] - votes
    scoresheet.append((score,user))

scoresheet.sort(reverse=False)
for user, score in scoresheet:
    print user, score""")

Note that my use of [0..len(inputs)-1] ensures that this isn't a Python script, since Sage is a superpython*.  Unfortunately, exec falls back on Python... so I've gotta preparse it.
edit 1: splitting on tabs, not newlines -- what was I thinking?
edit 2: made the code easier on the eyes, and recycled the splitting tab by pushing another 'newline' to the whitespace
*ok, not quite: we break xor

Python, 184
That's why I love spaces.
import          sys
x = sys.stdin.read(
    ).split()
z = x [  1 : : 4  ]
for i , ( j , k
) in enumerate (
      sorted (
       zip (
        [
      int(i)
    - int(j) +
  z.count(k) ** 2
+ max(map(len, z)) -
      len(k)
  for i, j, k in
       zip (
    x[2 : : 4],
    x[3 : : 4],
         z
         )
         ],
     x[ : : 4]
         )
         ),
         1
         ):
   print i, k, j

It's much more readable!

is this supposed to be some kind of ascii art picturing something? if yes, what should it look like?

@oenone you tell me.

it looks like it should, but i can't recognize anything

@oneone neither do I...

PostgreSQL - 225 non-space characters
242 → 225: Replaced subqueries with windowing clauses.
\set QUIET 1
\t
\a
\f ' '
CREATE TEMPORARY TABLE t (u TEXT, l TEXT, c INT, v INT);
\copy t FROM PSTDIN WITH DELIMITER ' ';
SELECT row_number() OVER (ORDER BY score), *
    FROM (SELECT u,
                 c
                 + count(*) OVER (PARTITION BY l)^2
                 + max(length(l)) OVER ()
                 - length(l)
                 - v AS score
                 FROM t) AS q

tested on 9.2devel
Usage and output:
$ psql -f meta.sql < meta.in
1 UserE 33
2 UserB 37
3 UserA 103
4 UserD 496
5 UserC 503

Python 2 - 210 203 non-space characters
import sys
e=enumerate
n=len
l=[x.split()for x in sys.stdin.readlines()]
for i,(x,y)in e(sorted((int(x[2])-int(x[3])+n(list(y for y in l if y[1]==x[1]))**2+max(n(x[1])for x in l)-n(x[1]),i)for i, x in e(l))):print i+1,l[y][0],x

Usage and output:
$ cat meta.txt | python meta.py
1 UserE 33
2 UserB 37
3 UserA 103
4 UserD 496
5 UserC 503

you could use only x.split() (that will also remove \n)

@JBernardo Cheers! Saved 7 characters.

You could ditch the .readlines() on sys.stdin.... for any reasonable length of input the function call won't make a difference and costs some characters. Just figured that out in another golf and thought I'd share.

AWK, 277 269 non-space characters
Used in to cut 8 chars.
Spaced version and commented version:
{
        # read in user strings
        u[NR]=$0
        # count number of times language has been used
        l[$2]+=1
}

END{
        # get maximum language length
        M=0
        X=NR
        for (g in l){
                f=length(g)
                if(f>M)
                        M=f
        }
        # get score for user i
        for(i in u){
                split(u[i],c)
                s[i]=c[3]+l[c[2]]^2+M-length(c[2])-c[4]
        }
        # sort scores and users
        for(i=2;i<=X;++i){
                for(j=i;s[j-1]>s[j];--j){
                        t=s[j]
                        x=u[j]
                        s[j]=s[j-1]
                        u[j]=u[j-1]
                        s[j-1]=t
                        u[j-1]=x
                }
        }
        # output
        for(i=1;i<=X;++i){
                split(u[i],c)
                print i,c[1],s[i]
        }
}

usage:
awk -f meta.awk data.txt

used sed '/#/ d' meta.awk|sed ':a;$!N;s/\n//;ta;s/\s//g;'|wc -c for counting characters.

Common Lisp - 546
(when golfed boy consolidating parenthesis, not counting spaces)
;;;; This is an answer to Code-Golf question
;;;; 3203/meta-golf-challenge
;;;; By using Common Lisp I plan to have the longest
;;;; Language-name while I cannot hope to have the
;;;; lowest character count due to Lisp's
;;;; linguistic tradition I can avoid the 16 or 25-pt
;;;; penalty atached to being the 4th or 5th PY
;;;; based answer.

(defun f (i)
 (loop for e in y do
  (if (eq i (nth 0 e))
   (return (nth 1 e))
  )
 )
)

(setf x
 (loop for l = (read-line () () () ())
  while l collect (loop for i = 0 then (1+ j)
                   as j = (position #\Space l :start i)
                   collect (subseq l i j) while j)
 )
)

(setf y
 (loop for a in x collect
  (list
   (+
    (read-from-string (nth 2 a))
    (expt (reduce #'+ (loop for b in x collect (if (string= (nth 1 a) (nth 1 b)) 1 0) ) ) 2 )
    (+ 5 (- (reduce #'min (loop for b in x collect (length (nth 1 b)))) (length (nth 1 a))))
    (* -1 (read-from-string (nth 3 a)))
   )
   (car a)
  )
 )
)

(setf g
 (sort (loop for c in y collect (nth 0 c)) #'<)
)

(loop for i = 0 then (1+ i) while (< i (length g)) do
 (setf a (nth i g))
 (format t "~A ~A ~A~%" (1+ i) (f a) a)
)

Heavily golfed, my common lisp solution was and is the longest on the board. So I decided
to cheat a bit by writing a significantly shorter bootloader and claiming that as my submission. (I consider @Boothby's submission to be a precedent in favor of this behavior)
Major thanks to Peter Taylor for his help squeezing every last char out of this bootstrapper.
BASH - 35
wget -q goo.gl/R4R54
cat -|clisp l.lsp

Usage: cat ./test0 | bash ./btstrp.sh
Joey Adams pointed out that this is not a fair solution because I can "arbitrarily increase the complexity of your solution without a corresponding increase in code size", a point not clearly expressed in the spec.

Wouldn't a for-loop be shorter than the until?

not sure... but found a shorter while!

Also, if you specify the variable to read into you don't have to use $REPLY. Try while read x;do a=$x"\n"$a;done. And you should be able to remove the spaces after the |s on the last line. On another note, I'm not sure that using an internal IP address is very useful: it won't work for anyone else.

Or even wget -q http://url/l.lsp ;cat - |clisp l.lsp

Okay, you lost me on the cat -

No, ok, that cat doesn't work: it's not hooked up to the shell's stdin. But I'm pretty sure you could move the wget to the start and then while read x;do echo $x;done|clisp l.lsp. (Sorry, don't have cygwin here so can't test until I get home).

... you are a wizard.

@PeterTaylor let us continue this discussion in chat

The output is not exactly right. It should be POSITION USER POINTS

@jbernardo - good catch, thanks

I don't think your code is valid because you had already posted a Lisp solution and this one require internet connection and is pretty much cheating...

I would argue otherwise. If you didn't notice, the highest voted solution also "cheats" by encoding the code entirely in whitespace which is not considered under the contest rules. Nor am I the first person to post a golf based on running remotely acquired code. Now, is it "cheating"? yes. Is it grounds for my POSTED code to not be scored same as everyone else's... that I leave to the OP and mods.

@rmackenzie if you read the last lines of the question you would see that the highest voted answer is also not valid. You bash answer require the lisp answer. So, by the rules each user can have only one answer

Ruby, 146 characters + 4 spaces
b=$<.map &:split
puts b.map{|u,l,c,v|[b.map{|_,n|n.size}.max-l.size+b.count{|_,n|n==l}**2+eval(c+?-+v),u]}.sort.map.with_index{|(s,u),i|[i+1,u,s]*' '}

JavaScript, 243 chars
for(g=0,H="length",i=J.split("\n"),p=[],l={};i[H]&&p.push(a=i.pop().split(" "));)
    X=a[1],X[H]>g&&(g=X[H]),l[X]=l[X]+1||1
for(i=-1;m=p[++i];)p[i]=[m[0],+m[2]+Math.pow(l[m[1]],2)+(g-m[1][H])-m[3]]
p.sort(function(a,b){return a[1]<b[1]?-1:1}).join("\n")

Longer than most of the other solutions... but the best I could come up with in JavaScript.
Usage
Input should be in a J variable. For example, open a console and write:
J="UserA Python 100 1\nUserB Perl 30 2\nUserC Java 500 3\nUserD Brainfuck 499 4\nUserE Perl 29 5";
for(g=0,H="length",i=J.split("\n"),p=[],l={};i[H]&&p.push(a=i.pop().split(" "));)
    X=a[1],X[H]>g&&(g=X[H]),l[X]=l[X]+1||1
for(i=-1;m=p[++i];)p[i]=[m[0],+m[2]+Math.pow(l[m[1]],2)+(g-m[1][H])-m[3]]
p.sort(function(a,b){return a[1]<b[1]?-1:1}).join("\n")

CoffeScript, 177 chars
About the same logic, in CoffeScript:
g=0;H="length";l={};([A,+C+Math.pow(l[B],2)+(g-B[H])-D] for [A,B,C,D] in for a in J.split "\n" then [_,X]=a=a.split " ";X[H]>g&&g=X[H];l[X]=l[X]+1||1;a).sort((a,b)->`a[1]<b[1]?-1:1`).join "\n"

I like how you abbreviate the length attribute by using a variable and subscripts.

Scala 269 266 252 without blanks and newlines.
val b = io.Source.stdin.getLines.toList.map (_.split (" "))
b.map (a => {
  val l = b.filter (_(1) .equals ( a(1))).size
  a(0) -> (a (2).toInt + l * l + (b.map (x => x(1).length).max - a(1).length) - a(3).toInt)
}).sortBy (_._2).zipWithIndex .map (m => m._2 + " " + m._1._1 + " "+ m._1._2).mkString ("\n")

Invocation:
cat user.lst | scala -i metagolf.scala

updates:

simplified (l => l.foo) -> (_.foo)
invocation
Gareths hint of stdin

my solution:
* 0 boothby 39
1 PeterTaylor 79
2 Lowjacker 151
* 3 JBernardo 185
4 Harpyon 207
5 JoeyAdams 220
6 shesek 241
7 userunknown 257
8 jpjacobs 273
9 rmackenzie 541

*) out of contest

You can use stdin instead of fromFile(System.in).

Thanks. Now I need 179 upvotes, and would have won the challenge - ceteris paribus.

No problem. Hmm...not sure there's enough traffic to get you 179 upvotes...

source: Stack Exchange

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

sort: votes


text:
Machine Epsilon
Machine epsilon is an important floating point number to know when doing numerical calculations. One way to understand it is when this relation
1 + machine_epsilon > 1

does not hold. One (iterative) way to extract it is executing a small program like the one above:
10 EPS=1
20 EPS=EPS/2
30 EPS1 = 1+EPS
40 IF EPS1 > 1 GOTO 20
50 PRINT EPS

But there may be more ways. Write the shortest code to extract the machine epsilon of your computer. NOTE: epsilon should be a non-zero value :)

no standard library (http://msdn.microsoft.com/en-us/library/system.single.epsilon.aspx ) nor literally typing out the memory representation of the epsilon? It's better to remind about it

shinkirou: Read the page you linked: »Note: The value of the Epsilon property is not equivalent to machine epsilon, which represents the upper bound of the relative error due to rounding in floating-point arithmetic.«

PowerShell, 5
Since .NET has certain guarantees for double, this number will not change, regardless of the implementation of the CLR or the platform it runs on. Therefore, the following suffices:
1/8pb

If you desperately need an iteration that computes the value in the way you've given in the task description, then that'd be 25 characters:
for($e=1;1+$e-1){$e/=2}$e

what is 8pb? so you mean that there is no way to calculate value doing some kind of iteration?

8PB is 9007199254740992 (i.e. the number of bytes in eight pebibytes). Of course there is, but since it's always the same value there isn't much point in using longer code to achieve the same result, I guess.

well, i am not so desperate :) thanks for your answer!

><> - 18 16 characters
1>2,:1v
n^?)1+<;

Usage and output using the python interpreter:
$ fish scripts/epsilon.fish
1.1102230246251565e-16

Edit Fixed code to return correct value (1.1e-16)

impressed! nice compact code.

I don't think this is different enough to warrant its own answer (it's the same thing just put a different way). 14 bytes with this: line 1: 12,:1+1=0$. line 2: ;n

JavaScript, 28 characters
for(y=1;y+1-1;y/=2);alert(y)

I could replace the y+1-1 with y+1>1, but I like for aesthetics of the former.

Brainfuck, 16
Brainfuck doesn't support floating-point arithmetic, so epsilon is 0.
-[>-<+++++]>---.

According to this, this is the smallest such program.  Program assumes that cells are unsigned bytes mod 256.

The Wikipedia page gives the following example: »A trivial example is the machine epsilon for integer arithmetic on processors without floating point formats; it is 1, because 1+1=2 is the smallest integer greater than 1.«

Yeah... I'd tend to agree, but the problem asks for 1+eps <= 1.

Hm, indeed. The answer should therefore be half the 2.2e-16 on WP for doubles (so the Fish one is probably wrong here). Ah well, fixing my answer yet again :)

@Joey, my answer could be wrong here, but both the python answer and the python example on wikipedia both state 2.2e-16. The ><> script actually gives 1.1e-16, but it doubles it before printing because I figured it has to be the same as it's interpreted by python. If 1.1e-16 is the correct one, however, I'm happy as it'll save me 2 characters :P

Perl
$x=1;push@a,$x/=2while$x;die@a[$#a-1];

Python, 29
t=1.
while t+1>1:t/=2
print t

Python3, 28
"true" division sucks, IMO... but I'll use it to cut a character out
t=1
while t+1>1:t/=2
print t

Your Python3 solution needs parantheses after print.

For reference, 10 bytes longer but also possible is: import sys;print sys.float_info.epsilon (documentation)

How do you do print t in python 3?

Haskell
Update
until((==1).(1+))(/2)1

Previous:
For doubles
last$takeWhile(/=0)$iterate(/2)1

For floats
last$takeWhile(/=0)$iterate(/2)(1::Float)

I think you're looking for until(<=1)(\x->2/x+1)1.  Still, though, I can't get ghci to produce anything other than 1.0.

PHP, 13 chars
For 1 + epsilon > 1, to be true, 1 + epsilon must fit into the number of bits allotted to the mantissa (5 in 5 * 10^4) in floating point numbers. 52 bits are allotted to the mantissa in 64-bit floating point numbers. It follows that 1 + epsilon is 1.000...(52)...0001 (base 2), and that episilon is 0.000...(52)...0001. Calculating this number in decimal gives:
<?=pow(2,-52);

You'll notice that negatively exponentiating 2 is the same as repeatedly dividing by 2 -- which is what many of the solutions here do.
Bonus, more platform-independent solution (13 chars):
<?=sin(pi());

MATLAB, 3 bytes
I'm going to post this purely because it's one of the rare opportunities for MATLAB to be one of if not the shortest. I think it is in the rules for what the question asks.
eps

Granted, not the most ingenious or exciting code though!

Now, let's golf this down... :)

i think this is a polyglot with Julia.

Vyxal, 9 8 bytes
1{:›1>|½

LOTM finally gave me a reason to actually try Vyxal, and so far I like it!
-1 byte thanks to Aaron Miller
Try it Online!

Nice answer! Just so you know, Vyxal autocompletes a lot of structures, like the while loop, so you can leave off the ending } for 8 bytes.

@AaronMiller Good to know, thanks!

very nicely done. bounty coming your way soon!

Mathematica 15 chars
$MachineEpsilon

-> 2.220446049250313*10^-16

Generally, a Print is used for full programs in Mathematica.

@LegionMammal978 The purpose of Print[ ] in Mathematica is no other than to provide a method for generating output from intermediate results in a CompoundExpression[ ].  It can be normally replaced for the better by Sow[ _, tag] - Reap[_, tag] pairs. And no, you'll not see Print[ ] calls in well designed and functional Mathematica program.

I try to treat Mathematica programs I write here as if they are in a script, where there is no implicit output.

@LegionMammal978 Well, yes. You can try to do that. But it isn't what most Mathematica users do. You can check common programming conventions and pitfalls for example here or here

Ada - 151
generic
type T is digits <>;function E return T;function E return T is
A,B,C:T:=1.0;begin
loop
A:=A/2.0;B:=C+A;exit when B<=C;end loop;return A;end E;

example usage:
procedure Main is
   function F is new E (Float);
   function D is new E (Long_Float);
begin
   Put_Line ("Epsilon:" & Float'Image (F));
   Put_Line ("Epsilon:" & Long_Float'Image (D));
end Main;

output:
Epsilon: 5.96046E-08
Epsilon: 1.11022302462516E-16

Pyth - 5 bytes
.IhG1

Try it online here.
Invert goes through all positive reals till it finds something that makes the lambda of G equal the second arg. So the code just inverts 1+G till it equals 1.

Excel, 35 bytes
=LET(x,2^-ROW(1:99),MAX((1+x=1)*x))

Excel (2010), 37 bytes
=MAX(2^-ROW(1:99)*(1+2^-ROW(1:99)=1))

Java, 13 bytes
It is easy by using the ulp method.
Math.ulp(1.0)

Result is 2.220446049250313E-16.

Husk, 8 bytes
Ωoε→½□√2

Try it online!
Formula is the exact same as the reference implementation.
Fixed with Leo's help by using decimals.

TIO times out because Husk uses arbitrary precision rationals, if you want to operate on floating point numbers you need to introduce non-rationals, for example starting from sqrt(2)^2 (but there may be shorter ways). Also, there is a built-in for looping until a certain condition is true: Try it online!

@Leo I thought Ω would be longer here. should've tried it out.

Grok, 21 bytes
1Y  j qzph
>1+1hY/2p{

Try it Online!
That's right, there's an online interpreter now! For those wondering, the framework is modified from the online Vyxal interpreter.
Explanation:
1Y  j       # Push 1 and copy it to the register
  +1h       # Add 1
>1          # Is it greater than 1?
        p{  # If yes, retrieve value from register
     Y/2    # Divide by 2 and copy it to the register, then repeat this line
      qzph  # If no, retrieve value from register,
         {  # then print as a number

Ruby, 18
Just for the sake of completeness:
p Float::EPSILON/2

Mathematica, 21 bytes
Print@$MachineEpsilon

JavaScript ES6 in a REPL,14
Number.EPSILON

JavaScript ES5 in a REPL,15
Math.pow(2,-52)

MMIX, 16 bytes (4 instrs)
(jelly xxd)
00000000: e0003ff0 21010001 06000100 f8010000  ṭ¡?ṅ!¢¡¢©¡¢¡ẏ¢¡¡

A bit of a hack: add 1 as int to 1.0, then subtract off as float.
Disassembled:
eps SETH $0,#3FF0
    ADD  $1,$0,1
    FSUB $0,$1,$0
    POP  1,0

C++ (gcc), 63 bytes
#import<iostream>
int main(){long x=1;std::cout<<*(double*)&x;}

Try it online!

GNU AWK, 34 bytes
BEGIN{for(e=1;1+e>1;e/=2);print e}

Try it online! Features different epsilons for different precisions.
Thanks to GNU MPFR arithmetic, GAWK can rely on any arbitrary byte precision. GAWK's manual reference.
The standard precision (double) returns 1.11022e-16.
Result:
0.000488281 half precision
5.96046e-08 single precision
1.11022e-16 double precision
9.62965e-35 quad precision
4.52784e-72 oct precision

05AB1E, 9 bytes
1[D>1›_#;

Try it online!
1[D>1›_#;  # full program
 [    _#   # while...
1 D        # literal...
  D        # or top of stack if not first iteration...
   >       # plus 1...
     ›     # is greater than...
    1      # literal...
        ;  # halve top of stack
           # implicit output

JavaScript (ES6), 24 bytes
(e=n=>n+1>1?e(n/2):n)(1)

Try it online!
Recursive solution, using the same algorithm as in the question.
Its body is an IIFE, so it's an expression that directly evaluates to the epsilon value.
(
  e = n =>       //Set e to the function, so we can call it later
    n + 1 > 1    //If n+1 is still greater than 1...
      ? e(n / 2) //...perform next iteration by calling itself with n halved
      : n        //...else, we found epsilon, return it
)(1)             //Call the function with the initial value 1

Fun fact: this will return the half of Number.EPSILON, as its value represents the smallest number that can be represented, i.e. Number.EPSILON + 1 > 1, while Number.EPSILON/2 + 1 === 1.

PostScript, 37 bytes
([){2 div dup 1 add 1 gt{[}if}def 1[=

Run through ghostscript (with optional -q to clean up output):
$ gs -q epsilon.ps
5.96046e-08
GS>

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

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


text:
Solving triangles with trigonometry
Time to dig up your old trigonometry notes from high school! The challenge is to solve the unknown sides and angles of different triangles. And as is customary in code golf, the smallest working code wins.
This is not a trivial problem; my reference implementation in python is currently down to 838 837 characters, but I'm sure you'll be able to golf solutions far smaller.
Additionally, if you're stuck, this section on Wikipedia should get you going: Triangle: Computing the sides and angles.
Input
The following triangle shows the names of the sides and angles used in this challenge. Note that sides are lowercase and angles are uppercase.

Input is given as six space-separated values, either on stdin or as command-line arguments (your choice). The six values correspond to the sides a, b, c and the angles A, B, C. The unknown sides are given as question marks (?). Both input and output angles has to be in radians. You may assume that the input values are correct (you don't have to validate anything). You may also assume that the input triangle is non-degenerate, and that all sides and angles are nonzero.
The following example input tells you that side a is 8, side b is 12 and angle A is 0.5 radians:
8 12 ? 0.5 ? ?

Output
Output is given in the same format as the input - six space-separated numbers on stdout. The only exception is when it is not possible to solve the input triangle - then the string "No solution" must be written to stdout. If two solutions are possible, they are both outputted with a newline between them.
Following is the output for the above input:
8.0 12.0 16.0899264342 0.5 0.802561439714 1.83903121388
8.0 12.0 4.97205505116 0.5 2.33903121388 0.302561439714

Output is not required to have a lot of precision, but at least a couple decimals is required.
Rules

Input is read from stdin or command-line arguments
Output is written to stdout
If two solutions are possible with the given input, output both
If there is too little information to get one or two clear solutions, consider it a "No solution" case
No built-in or pre-existing code may be used (of course you can use trig functions, but not "solveTriangle" or such)
Shortest code wins

Test cases
In   3 4 5 ? ? ?
Out 3.0 4.0 5.0 0.643501108793 0.927295218002 1.57079630572

In   ? 4 ? 0.64 0.92 1.57
Out 3.00248479301 4.0 5.02764025486 0.64 0.92 1.57

In   ? ? 5 ? 0.92 ?
Out No solution

In   ? ? 5 ? 0.92 1.57
Out 3.03226857833 3.97800936148 5.0 0.65159265359 0.92 1.57

In   8 12 ? 0.5 ? ?
Out (two solutions)
8.0 12.0 16.0899264342 0.5 0.802561439714 1.83903121388
8.0 12.0 4.97205505116 0.5 2.33903121388 0.302561439714

In   8 12 ? ? .5 ?
Out 8.0 12.0 18.3912222133 0.325325285223 0.5 2.31626736837
Good luck!

Can we assume that the triangle is non-degenerate, with all lengths and angles positive (in particular, nonzero)?

@boothby Yes, you can. I'll update the OP.

Also... if you want us to print all solutions, you need to provide at least one side.  Otherwise, y'know, infinite solutions.

@boothby, I was probably too unclear here. What I meant is, if there are two solutions to the input, you have to output both.

Python, 441 chars
from math import*
V=[map(float,raw_input().replace('?','0').split())+[0]]
for i in' '*9:
 W=[]
 for a,b,c,A,B,C,R in V:
  if B and C:A=A or pi-B-C
  if a:
   if A:R=R or a/sin(A)
   else:
    if b and c:A=acos((b*b+c*c-a*a)/2/b/c)
    elif R:N=asin(a/R);W+=[(b,c,a,B,C,N,R)];A=pi-N
  else:a=R*sin(A)
  W+=[(b,c,a,B,C,A,R)]
 V=W
V=[T for T in V if all(t>0 for t in T)]
if V:
 for T in V:print' '.join(map(str,T[:-1]))
else:print'No solution'

Does your typical trig to compute the answer.  The current possible solutions are stored as tuples in V.  Any unknown values are recorded as 0.  A seventh variable R is the value a/sin(A)==b/sin(B)==c/sin(C).
I use a trick where the a/b/c values are cycled each iteration to avoid lots of redundant logic.  The inner loop only needs to compute values of the A side or angle.

I use a similar trick of cycling the variables, but you sure beat my solution. +1, learnt a couple new tricks from this :)

By the way, there is a problem with your code: try 8 12 ? ? .5 ?.

You can get it to 419 bytes if you shave of the trailing line break and replace the two innermost indentations with one and two tabs, respectively.

Hah, this looks very similar to my solution, too, though I hadn't noticed the "all solutions" until right after you posted this.  You can save even more if you replace if a with if not a and flatten down the conditionals to 1 level.

Plain C, 565 555 530 chars
C is not the best language for Code Golf, I guess, so it's just for fun.
float t[6],u[6],P=3.1415;x,w,j,k,D,E;
#define y(V) for(V=0;V<6;++V)
#define Y if(p[j]&&p[k]&&
#define A(o,s,a,b,c,A,B,C) z(float*p){y(D)y(E)if(j=D%3,k=E%3,j-k){Y c)w=C=acos((a*a+b*b-c*c)/2/a/b);if(A&&B)w=C=P-A-B;Y C)w=c=sqrt(a*a+b*b-2*a*b*cos(C));if(A&&B&&a)w=b=s(B)*a/s(A);Y A&&!B&&!C)w=B=(x=A<P/2&&a<b&&p==u,1-2*x)*(asin(b*s(A)/a)-x*P);}y(j)k=w&&(p==t||x>0)&&o("%f ",a);o("\n");}main(int l,char*q[]){y(j)sscanf(*++q,"%f",t+j),u[j]=t[j];z(t);z(u);j=w||o("No solution\n");}
A(printf,sin,p[j],p[k],p[3-j-k],p[j+3],p[k+3],p[6-j-k])

Compiled with cc -o trig trig.c -lm. Reads input as command line args.

This solution also fails for 8 12 ? ? .5 ? - I added it as an additional test case in the OP.

Fixed! The length reduced as a side effect :)

Perl - 412 chars
As a perl one-liner, based off of Keith Randall's Python Solution:
use Math::Trig;@V=((map{tr/?/0/;$_}@ARGV),0);map{my@W;while(($a,$b,$c,$A,$B,$C,$R)=splice@V,0,7){$A||=pi-$B-$C if($B*$C);if($a){if($A){$R||=$a/sin$A;}else{if($b*$c){$A=acos(($b*$b+$c*$c-$a*$a)/2/$b/$c);}elsif($R){$N=asin($a/$R);push@W,$b,$c,$a,$B,$C,$N,$R;$A=pi-$N;}}}else{$a=$R*sin$A;}push@W,$b,$c,$a,$B,$C,$A,$R if($a*$b*$c>=0);}@V=@W;}(1..9);print($V[0]?join' ',map{(((6-$i++)%7)?$_:"\n")}@V:"No solution\n");

Here in a more readable form:
use Math::Trig;
@V = ( ( map { tr/?/0/; $_ } @ARGV ), 0 );
map {
    my @W;
    while ( ( $a, $b, $c, $A, $B, $C, $R ) = splice @V, 0, 7 ) {
        $A ||= pi- $B - $C
             if ( $B * $C );
        if ($a) {
            if ($A) { $R ||= $a / sin $A; }
            else {
                if ( $b * $c ) {
                    $A = acos(
                        ( $b * $b + $c * $c - $a * $a ) / 2 / $b / $c );
                } elsif ($R) {
                    $N = asin( $a / $R );
                    push @W, $b, $c, $a, $B, $C, $N, $R;
                    $A = pi- $N;
                }
            }
        } else {
            $a = $R * sin $A;
        }
        push @W, $b, $c, $a, $B, $C, $A, $R
            if ( $a * $b * $c >= 0 );
    }
    @V = @W;
} ( 1 .. 9 );

print( $V[0]
         ? join ' ', map { ( ( ( 6 - $i++ ) % 7 ) ? $_ : "\n" ) } @V
         : "No solution\n" );


text:
Chess endgame: White to Mate In One
Given an 8x8 grid of letters representing the current state of a game of chess, your program's task is to find a next move for white that results in checkmate (the answer will always be mate in one move).
Input
Input will be on STDIN - 8 lines of 8 characters each. The meanings of each character are as follows:
K/k - king
Q/q - queen
B/b - bishop
N/n - knight
R/r - rook
P/p - pawn
- - empty square

Upper case letters represent white pieces, and lower case represents black.
The board will be oriented so that white is playing up from the bottom and black is playing down from the top.
Output
A move for white that results in checkmate, in algebraic notation. You do not need to notate when a piece has been taken, nor do you need to be concerned about disambiguating between two identical pieces which can make the same move.
Sample input
Example 1
Input:
------R-
--p-kp-p
-----n--
--PPK---
p----P-r
B-------
--------
--------

Output:
c6

Example 2
Input:
--b-r--r
ppq-kp-p
-np-pn-B
--------
---N----
--P----P
PP---PP-
R--QRBK-

Output:
Nf5

Example 3
Input:
---r-nr-
-pqb-p-k
pn--p-p-
R-------
--------
-P-B-N-P
-BP--PP-
---QR-K-

Output:
Rh5

You can assume that the solution will not involve castling or en-passant.
This is code-golf - shortest solution wins.
(Examples taken from mateinone.com - puzzles 81, 82 and 83 Website has been replaced with spam)

No. I think for the purposes of this question you can assume that the answer will not involve castling or en-passant. I'll update the question.

How should we handle positions with more than one mate-in-one?

@Rob Only one solution is required, so output whichever solution you find first.

Is it also safe to assume that the solution doesn't involve promotion?

@Peter Yes, I don't want to over-complicate the problem.

Ruby, 589 512 510 499 493 characters
R=0..7
a=->b{o=[];R.map{|r|R.map{|c|v=Hash[?K,[6,7,8,11,13,16,17,18],?R,s=[157,161,163,167],?B,t=[156,158,166,168],?Q,s+t,?N,[1,3,5,9,15,19,21,23],?P,[32,181,183]][z=b[r][c]];v&&v.map{|s|k=2!=l=s/25+1;u=r;v=c;l.times{u+=s/5%5-2;v+=s%5-2;R===u&&R===v||break;t=b[u][v];j=t<?.&&l<8;(j||t=~/[a-z]/&&k)&&o<<=(h=b.map &:swapcase;h[u][v]=h[r][c];h[r][c]=?-;[z+"%c%d"%[97+v,8-u],h.reverse]);j&&(k||r==6)||break}}}};o}
a[$<.map{|l|l}].map{|m,b|a[b].any?{|f,x|a[x].all?{|g,y|y*""=~/K/}}||$><<m[/[^P]+/]}

Input is given via stdin, e.g.:
> ruby mateinone.rb
--------
--------
--------
-k------
b-------
-N-P----
--------
-----K-Q
^Z
Qb7

The output is not just one move that forces a mate in one but every move that does so.
Edit 1: The function e was used only once so I inlined it. Second, the encoding now is based on number 5 instead of 10. And refactoring the cloning of the board saved quite a few chars.
Edit 2: Still not as much improvement as I wanted. Changing the hash from {a=>b,c=>d} to Hash[a,b,c,d]. This costs 4 characters but saves one per key-value pair.
Edit 3: Only minor reductions: inlining M (4 characters), t==?- -> t<?. (2), removing Pawn in algebraic notation at the end (2), replaced puts (3). The program is now less than 500 characters.
Edit 4: It is interesting how much one can still find in such a program. Moved an invariant outside the loop and found another duplicate calculation.

By "not one, but any" do you mean "not necessarily one, but every"?

@Matthew You're right. I meant "every".

You can use [*$<] instead of $<.map{|l|l}.

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


text:
Musical Score Interpreter
Given an ascii musical score, you must be able to output the note and its corresponding length.  The score will contain between 5 and 15 notes inclusive, and is transcribed on a stave.  A stave is made up of five horizontal lines comprising of - (minus) characters separated by lines of spaces.  The bottom line in the stave is equivalent to the note 'E'. The line of spaces immediately above the bottom line indicates an 'F', and is of a higher pitch that the 'E' below it. This continues as below. Note that notes only go up to 'G' before starting again at 'A'.  See below:
F ----------
E
D ----------
C
B ----------
A
G ----------
F
E ----------

Note that the letters aren't included in the input.  The notes are superimposed on top of the stave using a o (lowercase ooh) character to indicate the 'note head'. This note head indicates the frequency of the note, and therefore the alphabetic representation of it as above. For example, a note placed on the score as below indicates an 'A' :
----

----

----
o
----

----

A note, like the 'A' above, is called a 'whole note' and would be played for one whole beat. Other durations can be indicated by including a 'stem' rising from the note, and between zero and three 'flags'. A stem is made up of three | (pipe, or vertical bar) characters stacked immediately above the note head .  A stem with no flags is considered a 'quarter-note', and plays for quarter of a beat.  Flags are \ (backslash) characters, and hand on the right hand side of the stem. Each stem halves the time the note is played for. The length of each note will be one of the following: a whole note, a quarter note, an eighth note, a sixteenth note or a thirty-second note.  This how each type of note would look for A :
--------------------

----|---|\--|\--|\--
    |   |   |\  |\
----|---|---|---|\--
o   o   o   o   o
--------------------

--------------------

Putting more than one note together gives you a score. Each note can be considered to be four characters wide, with a note being in the first column of each four-character block. For example :
    |\
----|\--|\----------
    |\  |       |\
----o---|---o---|\--
|       o       |
|---------------o---
|
o-------------------

--------------------

The example above contains the following notes, in order: a quarter note 'G', a thirty-second note 'D', an eighth note 'C', a whole note 'D' and a sixteenth note 'B'.  Each note in your output should be in the format letter/length, where letter is A-G and length is the fraction of the note's length when compared to a whole note. As an exception, the length and / character should not be printed if the note is a whole note. Each note in your output should be separated by a single space. Therefore, for the score above, your code should output the following:
G/4 D/32 C/8 D B/16

The notes will be in the following range: E F G A B C D E F. Note that only the letter needs to be printed, the octave is ignored.
Note that the number of lines of input varies from 9 to 12, since notes with quarter time or less on line D or higher will require more lines to show completely.
There is no half-note in this case.

Shortest code wins (whitespace doesn't count).
Edit: Fixed error in spacing in one input.
Some sample inputs:
        |\
----|\--|-------------------
|\  |   |
|---|---o---------------o---
|   o               |\
o---------------|\--|\------
            |\  |\  |\
------------|\--|\--o-------
            |\  o
------------o---------------

Output: B/8 C/8 D/8 E/32 F/32 G/32 D

----------------o-------------------
                                o
------------o-----------------------
                            o
--------o---------------------------
                        o
----o-------------------------------
                    o
o-----------------------------------

Output: E G B D F F A C E

            |\
            |\
            |\
------------o-------|-----------
|               o   |   |\
|---|\--------------|---|\------
|   |               o   |\
o---|---|\--------------o---|\--
    o   |\                  |\
--------|\------------------|---
        o                   o
--------------------------------

Output: B/4 A/8 F/32 F/32 E C/4 B/32 F/16

Why doesn't whitespace count?

@J: So that people won't feel inclined to submit programs one line long with no spaces.

It is conventional to count whitespace but to not count new-lines that are only there to keep the entry under a reasonable width. George's userscript does this with some languages (including c).

@Neil well right now all I feel inclined to submit is a Whitespace program.

@Neil, yeah, but then you get smartasses who write really verbose solutions, pack them into a string of whitespace, and golf a decode-and-exec: http://codegolf.stackexchange.com/questions/3203/meta-golf-challenge/3209#3209

How about whitespace that is required for your code to run counts?

Is input given on stdin, or as command line arguments to a program or as input to a function?

not counting whitespace is good for Haskell, since it has layout (similar to python)

Assume it's stdin, though for Javascript, assume an input variable called input which holds the equivalent input string (assigning of the input string doesn't count in the length of the program).

@J B: Obviously Whitespace is excluded as a possible language to use, though if you really wish to inflict pain on yourself, I'll let you use Whitespace, though unlike other languages, I will count whitespace characters.

What about chords? What about accidentals? If it's supposed to be musical scores then both should certainly be supported, making the task much more interesting!

@leftaroundabout: Might make a good follow-up task.  I didn't want to write an impossibly difficult task complete with rests, staccato, and a small accompanied symphony.  :)

Javascript,284,279,278,225,221,220 Characters (including necessary whitespace)
One-liner (test fiddle):
function a(c){b='',d=c.split('\n');for(e=0;d[0][e++];){f=0;for(i=0;g=d[i++];){h=g[e-1];if(h=='o')b+=(b?' ':'')+String.fromCharCode((d.length+4-i)%7+65);if(h=='|')f=f||4;if(g[e]&&g[e]=='\\')f*=2;}if(f)b+='/'+f;}return b;}

Readable (test fiddle):
function getNotes(input){
    out='',lines=input.split('\n');

    for(col=0;lines[0][col++];){
        time=0;
        for(i=0;line=lines[i++];){
            char=line[col-1];
            if(char=='o')out+=(out?' ':'')+String.fromCharCode((lines.length+4-i)%7+65);
            if(char=='|')time=time||4;
            if(line[col]&&line[col]=='\\')time*=2;
        }
        if(time)out+='/'+time;
    }
    return out;
}

By removing unnecessary ;s and do some tricks, you can make this even shorter.function a(c){b='',d=c.split('\n');for(e=0;d[0][e++];){for(i=f=0;g=d[i++];){h=g[e-1];if(h=='o')b+=(b?' ':'')+String.fromCharCode((d.length+4-i)%7+65);if(h=='|')f=f||4;f*=1+(g[e]=='\\');}if(f)b+='/'+f}return b} (209 chars)

Perl, 103 characters
(108 if you count necessary whitespace characters)
$i=0,s/\|\\/h /g,map$b[$i++].=$_,/./g for<>;/o/&&print chr 65+(4+length$')%7,/[h|]/&&"/".4*2**y/h//," "for@b

With whitespace for presentation:
$i=0,
    s/\|\\/h /g,
    map $b[$i++]. = $_, /./g
  for <>;
/o/ && print chr 65 + (4 + length $') % 7,
             /[h|]/ && "/" . 4*2**y/h//,
             " "
  for @b

Note that I assume that all lines have the same length (as per the revised version of the question).
Rearranged version with explanations:
#!/usr/bin/env perl
# First transpose the list of lines into a list of columns.
my @b = ();               # @b[$i] will contain the characters in column $i
while (<>) {              # for each input line, do
    my $i = 0;            # start in column 0
    s/\|\\/h /g;          # replace '\|' by 'h ', to keep track of part notes in the first column
    foreach (/./g) {      # for each character, do
        $b[$i++] .= $_;   # append the character to the transposed matrix
    }
}
# Now process each column.
foreach (@b) {            # for each column, do
    if (/o/) {            # if it contains a note, then
        print chr(65 + (4 + length $') % 7);    # print the note pitch
        if (/[h|]/) {                           # if this is a part note (had |\ or just |)
            print "/", 4*2**y/h//;              # print /n where n = 2^(subdivision)
        }
        print " ";
    }
}

(old, longer solution, kept because it may be interesting even if it's a little longer)
Perl, 147 126  characters
(149 131 if you count necessary whitespace)
$c=0,map{/o/?$h[$c]=E:/\\/?$d[$c-1]*=2:/\|/?$d[$c]||=4:++$h[$c];++$c}/./g for<>;print grep{s~$~/$d[$i++] ~;s~/ ~ ~;y/E-M/EFGA-F/}@h

With whitespace for presentation:
$c = 0,
map { /o/ ? $h[$c]=E :
      /\\/ ? $d[$c-1]*=2 :
      /\|/ ? $d[$c]||=4 :
      ++$h[$c];
      ++$c
    } /./g for <>;
print grep {s~$~/$d[$i++] ~; s~/ ~ ~; y/E-M/EFGA-F/} @h

Rearranged a little so as not to abuse the language so much:
#!/usr/bin/perl
my @h;          # $h[$c] will contain the note in column $c, if any
my @d;          # $d[$c] will contain the note length (e.g. 4), if any
while (<>) {    # for each input line, do
    my $c = 0;  # column number
    foreach (split //) {   # for each character, do
        if (/o/) { $h[$c] = "E"; }      # o => it's a note; if this is the last line, it's E
        elsif (/\\/) { $d[$c-1] *= 2; } # \ => halve the duration of the note in the previous column
        elsif (/\|/) { $d[$c] ||= 4; }  # | => if this is the first | in the column, we have a quarter note
        else { ++$h[$c]; }              # anything else => bump the note by 1
        ++$c;
     }
}
for (my $i = 0; $i < @h; $i++) { # for each column, do
    $_ = $h[$i];                   # look up the potential note (or garbage if there is no note in this column)
    s~$~/$d[$i++] ~;               # append the duration and a space (or "/ " if there is no duration)
    s~/ ~ ~;                       # remove the spurious "/" if there is no duration
    if (y/E-M/EFGA-F/) {           # if it's a note (i.e. if it contains a letter E-M), then
                                   # fix the letter wraparound and then
        print $_;                    # print the note
    }
}

Note that I assume that all lines have the same length. If you want to allow shorter lines, an obvious fix is to add $_.=1x$c, at the beginning of the program, at a cost of 9 characters.
I thought of another approach to avoid long words like split and map and let spaces do more of the work, but the boilerplate and punctuation took their revenge, and I can only get it down to a whooping 130 (144 with necessary whitespace).
sub p{$-[0]}
%a=qw(o $h[p]=E \ $d[&p-1]*=2 | $d[p]||=4 - ++$h[p]);
y/ /-/,s~.~$a{$&}~gee for<>;
print grep{s~$~/$d[$i++] ~;s~/ ~ ~;y/E-M/EFGA-F/}@h

The patch to cope with unfinished lines is a little weirder this time (what, you thought it couldn't get weirder?). 139 characters, 155 with necessary whitespace.
sub p{$-[0]}
%a=qw(o $h[p]=E \ $d[&p-1]*=2 | $d[p]||=4 - ++$h[p]);
$_.=" "x p,y/
 /-/,s~.~$a{$&}~gee for<>;
print grep{s~$~/$d[$i++] ~;s~/ ~ ~;y/E-M/EFGA-F/}@h

Scala(2.9), 352 313 291 294 290 277 274 273 characters
If a function is all that's needed:
def m(s:String){var(x,y,z,l)=(0,1,s.count(_=='\n'),Array.fill(99)(0))
var n=l.clone
for(c<-s){if(c=='\n'){x=0;y+=1}
if(c=='\\')l(x-1)+=1
if(c=='|')l(x)+=1
if(c=='o')n(x)="EFGABCDEF"(z-y)
x+=1}
(n,l).zipped.map((x,y)=>if(x>0)print(x.toChar+(if(y>0)"/"+(4<<y-3)else"")+" "))}

If a full program is required:
object M extends App{def m(s:String){var(x,y,z,l)=(0,1,s.count(_=='\n'),Array.fill(99)(0))
var n=l.clone
for(c<-s){if(c=='\n'){x=0;y+=1}
if(c=='\\')l(x-1)+=1
if(c=='|')l(x)+=1
if(c=='o')n(x)="EFGABCDEF"(z-y)
x+=1}
(n,l).zipped.map((x,y)=>if(x>0)print(x.toChar+(if(y>0)"/"+(4<<y-3)else"")+" "))}
m(io.Source.stdin.mkString)}

There are blank spaces inbetween bars until the end of the score, though I didn't mention it so the program should work regardless.  If the line with blank spaces ends abruptly, it means there's no more input to consider for that line anyway.  It simply just has to not crash.. :)

J - 108 characters
exit echo}.,>,&.>/_4<@((a.{~32,65+7|4+i.&'o'),(>&0#('/',0":2^]))@((+/@(=&'\'))+2*'|'&e.))@;\|:|.[;._2]stdin''

Ungolfed:
str =: stdin''
lines =: [;._2] str                          NB. split on the last character, the newline
rotated =: |: |. lines                       NB. lines reversed, then transposed
pitch =: 65 + 7 | 4 + i.&'o'                 NB. ord('A') + ( line.index('o') + 4 ) % 7
has_stem =: '|' & e.                         NB. '|' in line?
backslash_count =: (+/ @ (=&'\') )           NB. sum(char = '\\' for char in line)
denom_exp =: backslash_count + 2 * has_stem
fraction =: (>&0 # ('/', 0": 2 ^ ]))         NB. slash + 2^denom_exp, if denom_exp > 0
suffix =: fraction @ denom_exp
note_string =: (a. {~ 32,pitch) , suffix     NB. map(chr, (ord(' '), pitch)) + suffix
boxed_note_string =: < @ note_string @ ;     NB. box the string so it doesn't get padded
each_note_of_the =: boxed_note_string        NB. compute the note for a block of 4 lines
join_to_one_box =: , &. >
exit echo }. , > join_to_one_box / _4 each_note_of_the \ rotated

Python golf, 207 chars.
import sys
a=[x[:-1]+' '*99 for x in sys.stdin]
for x in range(0,99,4):
 b=''.join((y[x:x+4] for y in a))+'o'
 c=2**(b.count('\\')+('|'in b)*2)
 print'FEDCBAGFE '[b.index('o')/4-len(a)+9]+('','/'+`c`)[c>1],

I've start code golfing with Python for 2 days and I found that things like import sys, sys.stdin.read, sys.stdout.write are expansive.

If you're new to golfing in Python, you might find this python gofling tips question useful.


text:
Text Statistics: Return a list/array of the number of occurrences of each character used in a text file, including spaces, tabs, and new lines
Generic Lorem Ipsum:

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris felis
  dolor, bibendum at tincidunt vel, imperdiet eget libero. Cras vel
  felis purus. Phasellus a vestibulum enim. Sed eu orci ac nisl sodales
  scelerisque in id mi. Duis et nunc et nisl blandit aliquet ornare sed
  risus. Sed arcu magna, porttitor vel tincidunt quis, placerat non
  urna. Donec ut dolor eros, et viverra diam. Aliquam luctus, justo sed
  cursus imperdiet, velit nulla gravida nibh, vel scelerisque neque sem
  eget enim. Nunc in urna a velit adipiscing fermentum. Donec euismod
  faucibus purus. Vestibulum pretium, ligula commodo facilisis
  sollicitudin, nibh dolor adipiscing augue, nec tempus leo lectus eu
  enim. Vestibulum non erat velit, eget vulputate metus. Praesent at
  tincidunt elit.
  Add some stuff to it? !@#$%^&*()-_=+\|]}[{'";:/?.>,<`~
Nunc pretium metus sed elit dignissim porta. Cras at dui quam. Mauris
  at elementum tellus. Sed placerat volutpat enim convallis egestas.
  Suspendisse consectetur egestas mattis. Proin interdum, lectus a
  tincidunt sollicitudin, mauris ligula accumsan nisi, et suscipit
  lectus enim id mi. In est ipsum, cursus nec eleifend id, sollicitudin
  ac sem. Nam augue felis, dapibus in faucibus sit amet, ultrices eget
  purus. Etiam suscipit mauris at velit fringilla molestie. Cum sociis
  natoque penatibus et magnis dis parturient montes, nascetur ridiculus
  mus. Vivamus faucibus tortor in libero convallis pharetra. Donec eros
  diam, tincidunt vitae euismod ut, bibendum non orci. Nullam quam
  tortor, accumsan id malesuada nec, dignissim vitae magna. Suspendisse
  mi odio, commodo ut tempor porttitor, congue sit amet risus. Praesent
  feugiat lacus quis orci sodales cursus. Vivamus ac lorem id sem
  iaculis interdum.

Do we need to distinguish things like LF and CRLF as different ways of separating lines? E.g. it's trivial for me to get a file line by line, but not byte by byte which makes this quite hard. I'm fine either way, but it should be clarified.

-1. A problem statement should include a precise description of the problem, the input format (or permitted input formats), the valid range of inputs, the output format (or permitted output formats), and generally an example showing input and output. This has none of that.

What is assumed about the characters? Are we in the area of UTF-8, or more in ascii/byte-land? Return a list/array seems overly specific - why not provide a complete (testable) program, which reads a file 'f', which is your message body, and prints the result in a readable form?

I can't believe there are 11 answers already even though none of the answerers know what the question is.

PHP (16) (35) (28)
The default mode of count_chars() returns "an array with the byte-value as key and the frequency of every byte as value."
Edit: Oops, I just realized it's supposed to read in from a file. That adds 19 characters, so it might be beatable now.
Edit 2: Reduced it by 7 characters.
count_chars(join(file($s)));

hard to beat this

C: 50 chars (74 chars if done right)
"Return an array" is a pretty rare case when using C, because we can't actually return an array unless it's global or allocated by malloc(). So I decided to use a global one. The input is read from STDIN. The function works only on little-endian architectures.
n[256],r;*c(){while(read(0,&r,1))n[r]++;return n;}

The whole program that uses this function (with indentation added):
n[256],r;
*c()
{
    while (read(0,&r,1))
        n[r]++;
    return n;
}
main()
{
    int *num = c();
    int i;
    for (i = 0; i < 256; ++i)
        printf("%d ", num[i]);
}

Yeah, I know I won't ever beat anybody with C.
EDIT:
There are some rightful remarks in comments, so I've rewritten the code so that it meets all the requirements. Now it's 74 chars long.
n[256],r,*f,*s;*z(){f=fopen(s,"r");while(fread(&r,1,1,f))n[r]++;return n;}

And the indented code with main() added:
n[256],r,*f,*s;
*z()
{
    f=fopen(s,"r");
    while(fread(&r,1,1,f))
        n[r]++;
    return n;
}
main(int c,char**a)
{
    int *stat, i;
    s = a[1];
    stat = z();
    for (i = 0; i < 256; ++i)
        printf("%d ", stat[i]);
    printf("\n");
}

Nice, but read() is not a standard function in C. Also the problem states (I think) that we should read a text file instead of stdin.

@Harry K, the problem doesn't state anything.

The title suggests reading from a file though.

@Alexander Bakulin: you're missing an fclose(s); in the edited version.

@Harry K.: according to the C99 standard, all opened files are closed before program termination (see 7.19.3-5), so it's perfectly legal.

Hm... I don't remember by heart but I think according to C99 standard all vars and funcs must have their types defined too, and non-argument functions should get defined with a "void" inside the parentheses. Also, all functions, including main, should return a value. I'm rusty with the standards, but I think all the above hold for C99.

@Harry K.: you're partially right. Indeed, C99 requires that all types are explicitly specified (no "implicit int"), but I failed to get any errors from gcc even with -std=c99 -pedantic. Function declaration with empty parentheses means "no parameters" if the declaration is also a definition, and "no information about parameters" otherwise (6.7.5.3-14); but this feature is obsolescent (6.11.7). main() isn't required to have an explicit return (5.1.2.2.3).

This one is relatively simple. I chose to do it in Perl (my favorite scripting language). :)
Perl: 41 characters 63 characters
Might be able to reduce it somewhat but this is what I'm starting with.
sub s{open(I,"<$_[0]");while(!eof(I)){read(I,$c,1);$s{$c}++}%s}

EDIT:
Got it down further:
sub s{foreach(split//,$_[0]){$s{$_}++}%s}

D (87 chars)
reads from a passed in file and uses binary reads like migimaru's php function
import std.stdio;int[] f(File i){int[256] r;foreach(c;i.byChunk(1))r[c[0]]++;return r;}

Ruby, 41
F=->f{h=Hash.new 0
f.chars{|c|h[c]+=1}
h}

J - 26 characters (or perhaps 20)
The 26-character count is for the line that defines the function f.
NB. f takes a boxed filename,
NB. returns an array of integers counting occurrences of each character
NB. 26 characters

f=.[:<:[:+/"1[:=[:a.&,1!:1

NB. apply f to the file argument in jconsole textstats.ijs filename
A =. f 2{ARGV

NB. set output parameters so none of A gets elided
9!:37]0,~0,2#+:#0":A

NB. output A
exit echo A

Along the lines of Harry K.'s commentary, if we interpret the question to be about the function that computes the statistics, not also about I/O, f can go down to 20 characters:
f=.[:<:[:+/"1[:=a.&,

A =. f 1!:1]2{ARGV

f (in its shorter form) works like this:
a.&, : bond (via &) the alphabet a. (all characters J knows, in collating order) as the left argument to , (append); f's argument is the right argument to append
= : "self classify": this gives us a table where each row corresponds to a unique element of the argument (which is the result of "a. , arg ") and each column is 1 if that row's element appears in the same column of the argument, otherwise 0.  For example, row 65 would have a 1 wherever an A appears at the same offset in the input.
[: in the context here lets us use = in its monadic (unary) sense, instead of of its dyadic/binary "equals" usage.
+/"1 : +/ applies addition between each pair of items, and "1 makes it do so for the items in each row, instead of using the rows themselves as the items.  The result is each row becomes a count from the input of the character corresponding to the row.
<: : decrement all those counts, because they include the alphabet itself (a.).

Accepting the assumption that the problem doesn't specify how the characters are read (according to Peter Taylor's comment on Alexander Bakulin's C suggestion) and assuming they are already read into a global array s, we can further reduce the C code in a portable way, by defining a function that accepts as an argument an already initialized char frequency table u[256], updates it and returns a pointer to it, like this:
C - 39 chars (or 24 chars... see Edit below)
*r(int*u){while(*s)u[*s++]++;return u;}

And here is a sample, ungolfed program using the above function:
#include <stdio.h>
#include <stdlib.h>

// function selector
#define R_MORE_CHARS    0

// globals
int*s, u[256];

// ------------------------------------------------------------------------------------
#if R_MORE_CHARS
    *r(int*u){while(*s)u[*s++]++;return u;}
#else
    r(){while(*s)u[*s++]++;}
#endif
// ------------------------------------------------------------------------------------
int *read_file(char *fname, int maxfsize)
{
    int i, *s_ = calloc(maxfsize, sizeof(int));
    if ( !s_ )
        return NULL;

    FILE *fp = fopen(fname, "r");
    if ( !fp )
        return NULL;

    for (i=0; i < maxfsize && (s_[i]= getc(fp)) != EOF; i++)
        ;
    s_[i] = 0;

    fclose(fp);

    return s_;
}
// ------------------------------------------------------------------------------------
void print_freq( int freq[256] )
{
    int i=0;
    for (; i<256; i++)
        if ( freq[i] )
            printf("ACII(%3d): %3d time(s)\n", i, freq[i]);
    return;
}
// ------------------------------------------------------------------------------------
int main( void )
{
    int *p;                 // for saving address of s
    p = s = read_file("lorem.txt", 2000);   // get file contents into global s
    if ( !s )
        return 1;

#if R_MORE_CHARS
    print_freq( r(u) );         // print updated frequency table
    puts("\tmore chars: *r(int*u){while(*s)u[*s++]++;return u;}");
#else
    r();                    // update frequency table
    print_freq( u );
    puts("\tless chars: r(){while(*s)u[*s++]++;}");
#endif

    free( p );              // free saved s
    return 0;
}

EDIT: Just thought that if we are to adjust the not so well defined problem to the language features, we could also completely skip the function arguments, working directly on the globals instead. Since in C we don't even need to return anything for the frequency table to get updated, the function can be further reduced down to 24 chars (i have also edited the sample program above, so now it can be used with either of those 2 functions...
C - 24 chars
r(){while(*s)u[*s++]++;}

Haskell, 2^6 characters
import List
f=fmap(map(\x->(x!!0,length x)).group.sort).readFile

scala 164 156
val m=collection.mutable.Map[Char,Int]()
io.Source.fromFile("f").toArray.foreach(c=>m.update(c,m.getOrElseUpdate(c,0)+1))
m.mkString("\n")

Result:
> -> 1
+ -> 1
_ -> 1
{ -> 1
p -> 29
P -> 4
q -> 10
V -> 4
; -> 1
v -> 20

truncated to 10 lines.

Python 102 54 48 (87 79 78 with I/O)
As a pretty much newbie at this, and ignoring I/O:
Edit: Finding out about Counter made a difference:
from collections import*
r = Counter(s)
print(r)

The output is definitely not pretty though:
Counter({' ': 258, 'i': 155, 'e': 142, 's': 123,

Reading from file (removing a space between open() and "as" shaved one character):
from collections import*
with open("f")as f:
 s=f.read()
r=Counter(s)
print(r)

which generates the same output as the above example. I don't think I can get it smaller now, but there could be some function I've yet to explore.
Older solution:
import collections

d = collections.defaultdict(int)
for c in thestring:
    d[c] += 1

The counting itself can probably be made shorter through some function I've not encountered/understood yet. I realize it's pretty much cheating by omitting the I/O part, but I'm going to hide behind my newbie tag for a while longer.

from collections import*; f=lambda:Counter(open("f").read()).values()
I had thought about posting this as a distinct answer, you're a newbie, so whatever. I do however want to note a few things: first, the problem states that you have to return a list, not to print it. Second, you shall return a list/array, not a dictionary/mapping as you did. This is why I called the Counter's values() method, which returns only the amounts of the distinct characters. Furthermore, you used lots of unnecessary variables, and that you used with would normally be good, but is just waste of space in a golf.

@cemper93 Well that is certainly a lot shorter than my solution. I'm still learning, but I realized that I was mistaken on both returning a list (as well as Counter not yielding a list but a dictionary-type object). I've not had the chance to really understand lambda functions yet, and didn't even know that you could open a file without assigning it a variable. As for using with is just me trying to be proper. I suppose that's not the way I should think in golf.

f = lambda a,b: a + b is just the same thing as typing def f(a, b): return a + b. You can also omit the f =-part and get a totally anonymous function, which is useful for e.g. the builtins filter, map and reduce (because they take functions as arguments and can be passed lambdas, too - so that filter(lambda x: x > 0, l) will remove all elements that are not > 0 from the list l.

JavaScript, 55
Since JS can't read files, I'll assume that file is a function that returns the file as a string. (Requires Firefox!)
Array.reduce(file(),function(A,b)(A[b]=A[b]+1||1,A),{})


text:
Wordsearch Solver
Given a list of words and a grid of letters, find all the words in the grid and remove any letters which are not part of any of the words. The words could be forwards, backwards, up, down or diagonal. You may assume that no word in the list will occur in more than one place in the grid.
Input will always be: a list of words, 1 per line, followed by a blank line, followed by the grid of letters.
Examples
Input
ADA
ALGOL
ASSEMBLY
BASIC
COBOL
DELPHI
FORTRAN
JAVA
LABVIEW
LOGO
PASCAL
PERL
PHP
PYTHON
SMALLTALK
VISUALC

LLJKCABLFCI
OROLOBOCOIM
GELACSAPRSX
LPSTAHWVTAV
ANRLXLXQRBI
IHPLEDOXAHS
KJYAPHPYNOU
FABMADANZJA
EVISNOHTYPL
AAYLBMESSAC
WEIVBALOGOM

Output
LL K    FC
OR LOBOCOI
GELACSAPRS
LP T    TAV
A  L    RBI
IHPLED  A S
 J APHP N U
 A MADA   A
 V SNOHTYPL
 AYLBMESSAC
WEIVBALOGO

Input
BACKSPACE
BOLD
CLOSE
COMPACTDISC
COPY
CPU
CURSOR
DELETE
DESKTOP
DVD
EDIT
ENTER
EXIT
FLOPPY
FONT
HARDWARE
INTERNET
KEYBOARD
MONITOR
MOUSE
PASSWORD
PASTE
RETURN
SAVE
SOFTWARE
START
TEXT
TOWER
WORDPROCESSING

IAUERAWTFOSICPN
DGZPFLOPPYARFLU
RSNOCURSORVZDBM
AMNIUOMRNHEGUIN
OTBNSRMONITORNT
BEYTTSGPJBOLDRT
YRQEAHEHARDWARE
EOGRRNECECLOSEP
KIONTYKTODTOWER
ELCENSUPERPDKNN
ATRTPRYKELPVIEJ
GIEANPOTKSEDUSL
NXCMPASSWORDRUC
TEDITAGVSWJCTOV
CWOYPGYQKNLVXMW

Output
  UERAWTFOS
DG PFLOPPYA
R NOCURSORV
A NI O    E
OT NS MONITOR
B  TTS P BOLD
Y  EA EHARDWARE
E  RRNECECLOSE
K  NT KTO TOWER
   E SUPER D
 TRTPRY ELPVIE
 IEANPOTKSED S
 XC PASSWORDRUC
TEDITA       O
    P        MW

This is code-golf - shortest solution wins.
Example wordsearches from 1 and 2.

Can we assume the grid is always square?

@Bunnit No, I don't think so. Both the given examples are, but I think a solver should be able to handle other rectangular grids.

Can we assume all letters are uppercase and A-Z?

@Howard Yes you can.

@Gareth:  In your first example, the bottom row has "LABVIEW" in it, but it is not displayed on the output.

@Briguy37 Thanks. I did those things by hand and it took ages. I knew I'd mess it up. :-S

@Gareth: No worries, I didn't see it either till I was testing my program :)

I want to see a Befunge answer.

What if one word is inside of another word?  E.g. PASTE and AST?  Does that count as a word being in "more than one place in the grid" ?

Also, can we assume that the word list will be sorted?

@Joey Adams You can assume there will never be two words where one is a substring of another, but not that the list will be sorted.

05AB1E, 87 (or 83?) bytes
||UεVX8FD»YåiY1:AuSð:1Y:}D€g©ËiεSÐ0:«NFÁ}}øíJ0δKõKë®à©FD®£€нJRsεN®‹i¦}}¦}\)]€Søε{θ}J®ä»

With the actual I/O as mentioned in the challenge description.
Try it online. (For some reason, the Á is very slow on an inner list of characters instead of a string in this program, so εSÐ0:«NFÁ}} has been replaced with εÐS0:«NFÁ}S} (rotate first; then convert it to a list of characters) to speed things up substantially - it'll now output on TIO in roughly a second, instead of timing out without any output after 60 seconds.)
With less strict I/O (first words-input as a list, second grid-input as a list of lines; output-grid as a list of lines as well), this would be 83 bytes instead:
εVI8FD»YåiY1:AuSð:1Y:}D€g©ËiεSÐ0:«NFÁ}}øíJ0δKõKë®à©FD®£€нJRsεN®‹i¦}}¦}\)]€Søε{θ}J®ä

Try it online (with the same modification as above so it won't time out).
Explanation:
In pseudo-code, I do the following steps:
Map over the list of words:
 Push the input-grid
 Loop 8 times:
  If the word is present horizontally left-to-right:
   Replace everything else with a space
  Rotate the grid 45 degrees counterclockwise
Reduce/combine all grids of spaces and words

As for the actual code, of which most (50 bytes) is used to rotate the grid 45 degrees:
|                      # Get all inputs until an empty line is encountered,
                       # resulting in the list of words
 |                     # Do it again, resulting in the grid
  U                    # Pop and store the grid in variable `X`
 ε                     # Map over each of the words:
  V                    #  Pop and store the word in variable `Y`
  X                    #  Push grid `X`
   8F                  #  Loop 8 times:
     D»Yå              #   Check if the word is in the grid:
     D                 #    Duplicate the grid
      »                #    Join the lines with newline delimiter
       Yå              #    Check that this contains the word `Y`
         i             #   If this is truthy:
          Y1:          #    Replace the word temporarily with a 1
          AuSð:        #    Replace all uppercase letters with a space
          1Y:          #    Replace the 1 back to the word
         }             #   Close the if-statement
     D€g©ËiεSÐ0:«NFÁ}}øíJ0δKõKë®à©FD®£€нJRsεN®‹i¦}}¦}\)
                       #   Rotate the grid 45 degrees counterclockwise:
     D€g©Ë             #    Check if the grid is a rectangle:
     D                 #     Duplicate the grid
      €g               #     Get the length of each row
        ©              #     Save this list of lengths in variable `®` (without popping)
         Ë             #     Check whether these lengths are all equal
          i            #    If this is truthy:
           ε           #     Map over each row:
            S          #      Convert it to a list of characters
             Ð0:«      #      Append the row-length amount of 0s to the row
             Ð         #       Triplicate the row
              0:       #       Pop two, and replace all characters to 0s
                «      #       Merge this list of 0s to the row
             NF        #      Loop the 0-based map-index amount of times:
               Á       #       Rotate the row once towards the right
             }         #      Close the loop
           }           #     Close the map
            øí         #     Now rotate 90 degrees clockwise:
            ø          #      Zip/transpose; swapping rows/columns
             í         #      Reverse each row
              J        #     Join the inner list of characters back to a string
                δ      #     Map over each row:
               0 K     #      Remove all 0s from the row
                  õK   #     Remove any empty rows
          ë            #    Else (it's a diamond-shape instead):
           ®           #     Push the list of lengths
            à          #     Pop and push its maximum
             ©         #     Store this maximum as new variable `®` (without popping)
              F        #     Loop this maximum amount of times:
               D       #      Duplicate the list
                ®£     #      Only leave the first max amount of values
                  €н   #      Only leave the first character of each row
                    J  #      Join these characters together to a string
                     R #      Reverse it
               s       #      Swap so the list is at the top again
                ε      #      Map over each row:
                 N®‹i  #       If the map-index is smaller than max `®`:
                     ¦ #        Remove the first character
                    }  #       Close the if-statement
                }      #      Close the map
                 ¦     #      Remove the first (now empty) row
              }        #     Close the loop
               \       #     Discard the now empty list
                )      #     Wrap all rows on the stack into a list
 ]                     # Close the open if-statement; loop; and map
                       # (we now have a list space-grids, except for the found words)
  €S                   # Convert each inner grid to a flattened list of characters
    ø                  # Zip/transpose; swapping rows/columns
     ε                 # Map over each inner list:
      {                #  Sort; spaces at the front, potential letter(s) at the end
       θ               #  Pop and leave the last character
     }                 # Close the map
      J                # Join everything together to one huge string
       ®               # Push the last maximum `®`
        ä              # Split the string into that many equal-sized parts
         »             # Join the list of rows with newline delimiter
                       # (after which it is output implicitly as result)

Input is strict, so you can't use the 4 byte saving version I'm afraid. On the positive side, I guess you've taken the lead - 10 years after the question was first asked. :-)

I'll give @ovs a chance to reduce the size of their entry with the strict input requirement (unlikely that any of the others will update their entries now) - I'll update the big green tick in a couple of days.

Perl - 230 chars
Count includes 4 for "-ln " command-line options.
if(1../^$/){push@w,$_,''.reverse if$_}else{$a.="$_\n"}END{$_=$a;/.+/;$W=$+[0];y/A-Z/ /;chomp;for$w(@w){for$n(0,$W-1..$W+1){$r=join".{$n}",map"($_)",(@l=split//,$w);if($i=$a=~/$r/s){substr($_,$-[$i++],1,shift@l)while@l}}}print}

Ungolfed:
# -n: implicitly loop over input lines
# -l: strip the newlines
if ( 1 .. /^$/ ) {              # from first line to empty line
  push @w,                      # record in @w
    $_,                         #   the word
      ''.reverse                #   and its reverse
        if $_                   #   if it's not the empty line
}
else {
  $a .= "$_\n"                  # otherwise, add to the search array
}

END {
  $_ = $a;                      # make a copy for the output
  /.+/; $W = $+[0];             # compute array width
  y/A-Z/ /;                     # blank the output board
  chomp;                        # and remove the trailing newline,
                                #  because -l will add it back for us
  for $w (@w) {                 # for each word
    for $n (0, $W-1 .. $W+1) {  # for each direction in E, SW, S, SE
      $r = join ".{$n}",        # form a regexp with an appropriate
                                #  number of characters skipped between letters
                                #  (0 -> adjacent, so E; $W -> next line, so S;
                                #   off by one from $W for the diagonals),
        map "($_)",             #  capturing the letters of the word (for their offsets),
          (@l=split//,$w);      #  which we split up here
      if ( $i = $a =~ /$r/s ) { # if the word matches in this orientation
        substr( $_,             # set the substring of the output
                $-[$i++],       #  at the offset this letter matched
                1,              #  length 1
                shift @l )      #  to the corresponding letter
          while @l              #  (for each letter)
      }
    }
  }
  print                         # and print the output
}

I'm not too familiar with Perl, so maybe I'm not seeing something in your solution, but doesn't your regex wrap around the sides for the diagonals?

@migimaru The .{$n} portion of the regexp (along with the /s option) does wrap around for the diagonals (and straight down) to implement the downward component of the match direction. Is your concern a false match that wraps? AFAICT, this can't give false matches, because of the newlines in the string. Suppose letter i of a word matches in the rightmost column, and we're checking the SE diagonal. The .{$n} portion skips the next $W+1 characters, which are the immediately following \n and all of the next line. Letter i+1 will mismatch against the next \n, thus no overall match.

Ah, I see. I missed the fact that the newlines are included and would prevent false matches. Thanks!

Ruby 1.9, 214 210 206 182 177 173 172 166
s,G=$<.read.split$/*2
O=G.tr'^
',' '
(s+$/+s.reverse).split.map{|w|[0,l=G=~/$/,l+1,l-1].map{|d|(k=G=~/#{[*w.chars].*?.*d}/m)&&w.size.times{|i|O[k+d*i+i]=w[i]}}}
$><<O

Nicely done.  Your algorithm appears to be the same as in my answer, but considerably more compact in ruby.  You're reinforcing my belief I should add ruby to my code-golf bag.

JavaScript: 342 characters
Code-Golfed version:
function a(b){c='\n';d=b.split(c+c);e=d[1].split(c);for(f=-1,g=[];h=e[++f];)for(i=-1,g[f]=[];h[++i];)for(j=-2,g[f][i]=' ';2>++j;)for(l=-2;2>++l;)for(k=0;m=d[0].split(c)[k++];)for(n=-1;o=m[++n];)for(p=f-n*j-j,q=i-n*l-l,r=0;(s=m[r++])&&(t=e[p+=j])&&(u=t[q+=l])&&s==u;)if(r==m.length)g[f][i]=o;for(i=0;v=g[i];)g[i++]=v.join('');return g.join(c)}

Formatted version:
function solveWordsearch(input){
    var lineBreak = '\n';
    var solver = input.split(lineBreak+lineBreak);
    var board = solver[1].split(lineBreak);

    for(row=-1,output=[]; line=board[++row];){
        for(col=-1,output[row]=[]; line[++col];){
            for(rowIncrement=-2,output[row][col]=' ';2>++rowIncrement;){
                for(colIncrement=-2;2>++colIncrement;){
                    for(k=0; word=solver[0].split(lineBreak)[k++];){
                        for(charPosition=-1; wordChar=word[++charPosition];){
                            var startRowIndex=row-charPosition*rowIncrement-rowIncrement;
                            var startColIndex=col-charPosition*colIncrement-colIncrement;
                            for(wordIndex=0;(compareWordChar=word[wordIndex++])&&(compareBoardRow=board[startRowIndex+=rowIncrement])&&(compareBoardChar=compareBoardRow[startColIndex+=colIncrement])&&compareWordChar==compareBoardChar;){
                                if(wordIndex == word.length){
                                    output[row][col]=wordChar;
                                }
                            }
                        }
                    }
                }
            }
        }
    }

    for(i=0;outLine=output[i];){
        output[i++]=outLine.join('');
    }

    return output.join('\n');
}

The concept behind this solution is to iterate over all positions on the board, initialize a 2D-array's values to ' ' for each position, and then consider all potential word directions and word offsets.  If a matching word is found, the array's value for that position is updated to the correct letter.  Finally, the array is converted to a string and returned.

BQN, 126 114 bytesSBCS
{S←-++`×¬⋄{wg:g⊑∘↑˜¨¯2+∨´⥊w{H←⊒˜∊·⥊(↕≠)+⌜·/⊸⍷⋄(H˘∨1↓˘⊒˜⌽⁼˘·H˘⌾⍉⊒˜⌽˘' '⊸∾˘)⌾(⌽∘⍉⍟)g}⌜↕4}⟜>´(S⟨⟩⊸≡¨)⊸⊔⊔˜S='
'}

Run online!
One third of the code is parsing the input, the more interesting parts are outlined below:
{wg:g⊑∘↑˜¨¯2+∨´⥊w{H←⊒˜∊·⥊(↕≠)+⌜·/⊸⍷⋄(H˘∨1↓˘⊒˜⌽⁼˘·H˘⌾⍉⊒˜⌽˘' '⊸∾˘)⌾(⌽∘⍉⍟)g}⌜↕4}

Run online!
{wg:g⊑∘↑˜¨¯2+∨´⥊w{ ... }⌜↕4}
 wg:                          # A dyadic function taking:
                               #  - left argument w: word list
                               #  - right argument g: grid
                          ↕4   # 0 1 2 3
                  { ... }⌜     # For each of those numbers on the right (specifying rotation) and ...
                 w             # each word on the left, call the inner function.
                               # The inner function returns boolean matrices of the same shape of the input
              ∨´⥊              # Boolean OR of all the matrices
     g⊑∘↑˜¨¯2+                 # For 1's in the matrix take a character from the grid, for 0's take a space.

The inner function rotates the grid (as many times as its right argument specifies: ⌽∘⍉⍟), checks for words from left to right and on diagonals and then rotates the result back.
How to get get diagonals:
This method is mostly taken from BQNcrate. First a space is prepended to each row. Then each row is rotated by its index. Now words previously in the diagonals are in the columns, by transposing we get them in the rows. After marking the words, all the steps can be reversed: Try with step-by-step results!

Sorry, input is strict.

Scala  697, 666  649
val(z,n)=io.Source.fromFile("F").getLines.toList.span(_.length>0)
val m=n.tail
val(w,h)=(m.head.length,m.size)
def g(d:Int,e:Int,k:Int,g:Int,h:Int,i:Int,s:String)={
def f(x:Int,y:Int):Seq[(Int,Int)]={
val q=for(c<-(0 to s.size-1))
yield (y+c*i,x+c*k)
if((q.map(p=>m(p._1)(p._2))).mkString==s)q else Nil}
val t=for(x<-(d to e);
y<-(g to h))yield f(x,y)
t.flatten}
def i(s:String)={val l=s.size
g(0,w-l,1,0,h-1,0,s)++ g(0,w-1,0,0,h-l,1,s)++ g(0,w-l,1,l-1,h-1,-1,s)++ g(0,w-l,1,0,h-l,1,s)}
def j(s: String)=i(s)++ i(s.reverse)
val k=z.map(j).flatten
(0 to h-1).map(r=>{(0 to w-1).map(c=>if(k.contains(r,c))print(""+m(r)(c))else print(" "));println()})

degolfed:
object Golf {

def main (args: Array[String]) = {
  val (words, matrix) = io.Source.fromFile ("./wordsearch.data").getLines.toList.span (_.length > 0)
  val m = matrix.tail
  val (w,h) = (m.head.length, m.size)

  // xi: x-increment, yi: y-increment
  def find (x: Int, y: Int, xi: Int, yi: Int, s: String): Seq [(Int, Int)] = {
    val points = for (c <- (0 to s.length-1))
       yield (y + c*yi, x + c * xi)
    if ((points.map (p => m (p._1)(p._2))).mkString == s) points else Nil
  }

  def findInScope (xS: Int, xD: Int, xi: Int, yS: Int, yD: Int, yi: Int, s: String): Seq [(Int, Int)] = {
    val ppoints = for (x <- (xS to xD);
          y <- (yS to yD)) yield find (x, y, xi, yi, s)
    ppoints.flatten
  }

  def findRowColFallingClimbing (s: String) = {
    val l=s.length

    // horizontal:
      findInScope (0,   w-l,  1,   0, h-1,  0, s) ++
    // vertical:
      findInScope (0,   w-1,  0,   0, h-l,  1, s) ++
    // climbing /:
      findInScope (0,   w-l,  1, l-1, h-1, -1, s) ++
    // falling \:
      findInScope (0,   w-l,  1,   0, h-l,  1, s)
  }

  def findBoth (s: String) = findRowColFallingClimbing (s) ++ findRowColFallingClimbing (s.reverse)
  val coords = words.map (findBoth).flatten

  (0 to h-1).map ( r => {
    (0 to w-1).map (c =>
      if (coords.contains (r, c))
       print ("" + m(r)(c))
      else print (" ")
     )
     println ()
   })
  }
}

You could save a couple of characters by using stdin instead of fromFile. I didn't specify where input comes from.