text:
Shortest Program to Solve a Quartic Equation
Write the shortest program to solve a quartic equation.
A quartic equation is a polynomial equation of the form:
\$ax^4 + bx^3 + cx^2 + dx + e=0\$
A solution for \$x\$ is a number such that the above evaluates to 0.

Rules

The program must take in the 5 floating point coefficients of the equation \$ax^4+bx^3+cx^2+dx+e\$ as "a b c d e" separated by spaces.
It must then output a single real solution. If there exist no real solutions then it outputs an "n".
No bonus for extra solutions.
No use of CAS (Computer algebra systems). This includes symbolic manipulation properties of Mathematica and related software.
No connecting to external libraries, web calculators etc...
You may use formulas or your own manipulation
Native math libraries that do not solve equations may be used, eg. .NET: System.Math
You may deduct 50 from your char count if recursion is a main technique used.
As long as there is no difference with the answer obtained algebraically, numerical approximation is welcome however adds 25 chars to your solution. This really relies on the accuracy of the floating-point numbers. (Which should be 64 bit).

The winner will be picked in 1 week. (26/02/2014)

Hints at http://math.stackexchange.com/questions/785/is-there-a-general-formula-for-solving-4th-degree-equations

I would remove "Program has to return answer in under a second". It may be under a second on my machine but 30s on yours.

You may deduct -50 from your char count - isn't this the same as adding +50 to the char count?  Who would choose to do that?

The "NEW RULE" is somewhat unclear. Is there a means of evaluating a general Bring radical in floating point other than by numerical approximation?

Now I was thinking "You may deduct 50 from your char count if recursion is a main technique used" is an invitation to use numerical methods (e.g. Newton-Raphson), but the NEW RULE seems to nix that - or am I missing something?

I should also note that this is close to being a duplicate of an old question of mine.

As written, the question requires solutions for the general case.

Does the last rule imply that the result should be computed as a radical expression, such as 2⁴√3 for x⁴-48=0 ? Otherwise, is there a penalty if the closest floating-point value is obtained neither algebraically nor by numerical methods? (such as by enumerating all floats, since there's no limit on computational complexity)

Until you clarify the point about "the answer obtained algebraically", I don't think it's possible to judge whether a submission meets that criterion.

@PeterTaylor if an answer did output the solution for x⁴-48=0 as 2×∜3 (or 2 4√3, 2*3^.25 or any equivalent syntax) instead of 2.632148026… then I guess it'd be hard not to consider it obtained algebraically.

Use Newton Raphson with care, it can get stuck in the wrong place and divide by zero. See my comments on existing answers (unfortunately it is only possible to tag one person per comment, otherwise I would only have made a general comment here.)

So far, I'm only seeing solutions only presenting one possible root out of four... shouldn't it be outputting all 4 possible roots?

@WallyWest it does say "No bonus for extra solutions."

For me, you forget to write examples for testing

Solvable quintics next? :)

C++ A fast and robust solution, 704 chars + numeric - recursion = 679
#include "stdafx.h"
#include "math.h"
double a,b,c,e,j,k,l,p,q,t,z;void s(double x, int i){if(i==99)printf("%f\n",x);else s(x-((x+b)*x*x*x+c*x*x+l*x+e)/(4*x*x*x+j*x*x + k*x + l),i+1);}
void _tmain(){double r[8];scanf_s("%lf%lf%lf%lf%lf",&a,&b,&c,&l,&e);b/=a;c/=a;l/=a;e/= a;j=3*b;k=2*c;p=(12*k-j*j)/48;q=(2*j*j*j-36*j*k+432*l)/1728;z=q*q/4+p*p*p/27;int u=0,v=0,g;
for(g=1;g<4;g++){r[g]=z>0|p==0?cbrt(-q/2+sqrt(z))+cbrt(-q/2-sqrt(z))-j/12:sqrt(-p/.75)*cos(acos(-q/sqrt(-p*p*p*4/27))/3-g*acos(-.5))-j/12;r[g+4]=(r[g]+b)*pow(r[g],3)+c*r[g]*r[g]+l*r[g]+e;if(r[g+4]>r[g+3]|g==1)u=g;if(r[g + 4]<r[g+3]|g==1)v=g;}
if(r[v+4]>0)printf("n\n");if(r[v+4]==0)printf("%f\n",r[v]);if(r[v+4]<0)s(2*r[v]-r[u]+(r[v]-r[u]==0),0);}

This is by no means the shortest answer, but so far no other answer has confirmed that it will work with curves with the full 3 stationary points (maxima/minima.) These correspond to curves with large values of b and c of opposite sign to a. None of the test data in the other solutions has local maxima/minima apart from the global one. The nearest is Eelvex's 1 2 0 0 1 which has a kink on one side where dy/dx falls to zero.
This program handles all the test data shown in other solutions, plus the following interesting examples, amongst others:
1 0 1 0 0 --> multiple root 0
1 0 -1 0 0 --> multiple root at 0, but the program prefers the simple root at -1
1 0 -1 0 0.25 -->  multiple roots at +/- 0.7071 = sqrt(0.5)

It cannot handle the case a=0, but that is not a quartic so it is out of scope.  The only problem I have found but not eliminated is b=c=d=0, but that is an easy problem to fix. I will do it when I golf the code (if I get round to that.) I expect it to come in around 700-800 chars.
How it works
The program divides the whole formula by a (which does not affect the roots, but ensures that we know that y= +infinity at x = +/- infinity )
It then calculates the formula for dy/dx (a cubic) and solves this analytically for dy/dx=0. The code to do this is quite short (the explanation in the comments is much longer than the code itself.)
It calculates the values of y at the up to 3 stationary points where dy/dx=0 and looks for the lowest (global minimum.) If this y is positive here , the whole curve is above the x axis and there are no roots.
If y is zero, then it is a root and this is reported directly. Such a root would be problematic for newton raphson.
If y is less than zero, the program makes a guess for the root on the opposite side of the global minimum from the other stationary points (to avoid getting trapped in the local maximum if there is one.)
Then it searches using newton-raphson (recursive, as you insisted.) This method is fast and simple, and once the right region of the curve has been identified, does not run the risk of dividing by zero.
I did run into other problems with it though. It quickly got very close to a solution (good enough for a human) but kept searching. With the rapid initial convergence, I assumed that the problem was that it couldn't get to f(x)==0 because f'(x) was large and f(x)/f'(x) was being rounded to zero in the calculation. So I put in an extra test condition for f(x)/f'(x) but it still did the same. Then I limited it to just 10 iterations, which is more than enough for all the tests I have done.
The current version goes up to 99 iterations. The ungolfed version has medium verbosity output (with uncommentable code for high verbosity) as seen in the screenshot and has its iterations terminated when f(x)==0. The golfed version has low verbosity (in accordance with specified requirements) and always runs to 99 iterations. The golfed version has other minor differences, such as no while loop and simplified (but less clear) expressions.
There are certainly other methods which might work better, but I think that might go into another answer (which I don't think I have time for.)
Ungolfed version
#include "stdafx.h"
#include "math.h"

double a,b,c,d,e,j,k,l,p,q,t,z;
//explanation of variables
//dy/dx= i* x3 + j*x2 + k*x + l. No i variable needed as it is normalised to 4.
//depressed form of dy/dx: t3+pt+q. A subsitution is used to eliminate the squared term, see below.
//z=q2/4 + p3/27. z is proportional to the "discriminant." The sign tells the number of roots of dy/dx
// +ve z means 1 real root, -ve z means 3 real roots, 0 means one simple root plus a double root.

// recursive newton-raphson to depth i
void s(double x, int i){
    double m=(x + b)*x*x*x + c*x*x + d*x + e;
    if (m == 0 | i == 99)  printf("z= %f x= %f y= %f iteration %d\n", z,x,m,i);
    else s(x-m/(4*x*x*x + j*x*x + k*x + l), i+1);

}

void _tmain(){
    while (true){

        double r[8];
        //r[1,2,3] and r[5,6,7] store x and y values of the maxima and minima.
        //r[0] and r[4] are dummies to handle [subscript-1] references.

        scanf_s("%lf %lf %lf %lf %lf", &a, &b, &c, &d, &e);
        //uncomment for verbose output: printf("data for minima and maxima \n");
        //uncomment for verbose output: printf("   z       x       dy/x      y     hi/low \n");
        //hi/low indicate which y values are highest and lowest: 1st, 2nd, 3rd.

        //Divide by a to give a "monic polynomial" with a=1.
        //This does not affect the roots but saves a lot of typing of powers of a.
        // differentiate to i*x3 + j*x2 + k*x + l. As a=1, we know i=4.
        b /= a; c /= a; d /= a; e /= a;
        j = 3*b; k = 2*c; l = d;

        // to prepare to solve this cubic, convert to depressed cubic t3+pt+q, eliminating x2. x=t-j/(3*i)
        // p=(3*i*k - j2)/(3*i2) q=(2*j3 - 9*i*j*k + 27*i2*l)/27*i3. But we know i=4.
        p = (12 * k - j*j) / 48;
        q = (2 * j*j*j - 36 * j*k + 432 * l) / 1728;
        z = q*q / 4 + p*p*p / 27;

        //u and v indicate which of the stationary points are highest and lowest.
        //solve dy/dx, store the roots in r[1,2,3] and the y values in r[5,6,7].
        int u=0,v=0,g;
        for (g = 1; g < 4; g++){

            //if z>0 or p==0 use cardano's method to store the one real root of dy/x three times in r[1,2,3]
            //if z<=0 use viete's trigonometric method to find the multiple real roots.
            //use of different methods for each case avoids the need to handle complex numbers.

            r[g] =z > 0 | p==0? cbrt(-q / 2 + sqrt(z)) + cbrt(-q / 2 - sqrt(z)) - j / 12 :
                sqrt(-p / .75)*cos(acos(-q / sqrt(-p * p * p * 4 / 27)) / 3 - g*acos(-.5)) - j / 12;

            r[g+4] = (r[g]+b)*pow(r[g],3) + c*r[g]*r[g] + d*r[g] + e;

            if (r[g + 4]>r[g+3]|g==1)u=g;
            if (r[g + 4]<r[g+3]|g==1)v=g;

            // uncomment for verbose output
            //printf("%f %f %f %f %d %d \n  \n", z, r[g], 4 * pow(r[g], 3) + j*pow(r[g], 2) + k*r[g] + l, r[g+4], u, v);
        }

        //because we divided by a, the new a=1 and y tends to infinity at large |x|.
        //so if the lowest stationary point has y>0, the whole curve is above the x axis and there is no solution.

        //if the lowest stationary point has y=0 it is tangent to the x axis and would cause problems for newton-raphson

        //if the lowest stationary point has y<0, use newton raphson, 99 iterations. ensure 1st guess is on the side
        //opposite the highest stationary point, just in case that point also has y<0, to avoid getting trapped.
        //special case: if r[v]-r[u] == 0 (implies only one stationary point) then add 1!

        if (r[v+4] >0) printf("n\n");
        if (r[v+4]==0) printf("z= %f x= %f multiple root", z,r[v]);
        if (r[v+4] <0) s(r[v]+(r[v]-r[u])+(r[v]-r[u]==0),0);
    }
}

Output
All data tested by other answers is here, as well as many additional examples. The sign of the value z is positive when there is only one stationary point where dy/dx=0, negative when there are three (2 minima and a maximum if a is positive), and zero when there are two (a minimum if a is positive, plus an inflexion.) This is the only answer so far that presents test cases for three stationary points.
The y values are shown for easy checking of the program. y is zero at the root, and as can be seen, an acceptable zero is always found.
The golfed version is low verbosity, displaying only the root per question spec.

Nice. BTW, theoretically my answer always finds a root if it exists since I use the bisection method. Practically it might need too much time if the smallest root is a very-very big number.

J, 222
247 - recursion + numerical
NB. multiple lines for visibility
f=:[:-(]$:~[:}.[-%&{.*],#&0@l)`[@.(0>l=:-&#)
r=:1={.
s=:[:=/+/@(2=&*/\])@(,.]*_1^i.@#)@({.@>@(([;];f;j;f f j=.]f f)([:}:(i._5)*])))@|.
u=:0,0([(]*_1^r@k)>:@]^:(1 1-:k=:[:*(0 p.~[)*(p.(,-)))^:_)~]
h=:{.@((n@],]{~[:r[:*p.*(p.n=:{.+-:@-~/))^:_ u)`('n'"_)@.s@|.

Methods

Using Sturm's theorem to find number of roots.
f is polynomial division (recursive)
s is Sturm's theorem output: 0 for no real roots, 1 otherwise. It evaluates Sturm's polynomials ([;];f;j;f f j=.]f f) and checks their behaviour at +/- infinity.
Using bisection method to avoid divisions by zero, local maxima etc.
u scans from 0 to +/- infinity to find an appropriate interval
((n@],]{~[:r[:*p.*(p.n=:{.+-:@-~/))^:_ u) evaluates the polynomial at the edges and midpoint then halfs the interval accordingly

Verification of results
Using J's buildin polynomial root finder as realRoots:
ti,>([;h;realRoots) each samples
┌──────────────┬────────┬─────────────────┐
│a b c d e     │output  │all real roots   │
├──────────────┼────────┼─────────────────┤
│_1 2 3 4 5    │_1.11029│3.37192 _1.11029 │
├──────────────┼────────┼─────────────────┤
│_1 2 3 4 _5   │0.728727│3.18248 0.728727 │
├──────────────┼────────┼─────────────────┤
│1 2 3 4 5     │n       │                 │
├──────────────┼────────┼─────────────────┤
│1 1 2 _1 _1   │0.728262│0.728262 _0.52236│
├──────────────┼────────┼─────────────────┤
│1 2 3 4 0     │0       │_1.65063 0       │
├──────────────┼────────┼─────────────────┤
│1 2 0 0 1     │_1      │_1.83929 _1      │
├──────────────┼────────┼─────────────────┤
│_1 _1 _1 _1 _1│n       │                 │
└──────────────┴────────┴─────────────────┘

BTW, a simple implementation of Newton's method would be:
f=:3 :'((-(y&p.%y&p.D.1))^:_)0'@|.

Thanks for the comment on my solution. Yours is the only other practical solution here, though I do not understand your code at all. I'd love to see a clearer explanation of what's going on, especially the "scan for interval" (I assume you are looking for a change of sign) and bisection (I wonder how it handles multiple sign changes within the selected interval.)

@steveverrill, the bisection will never fail no matter what, because from an interval (+,-) you choose the midpoint that it's either +,-,or 0. In any case you can either form a new interval (+,-) or you have a solution. The weak point of my algorithm is the scanning which might go on and on. My scanning makes dx steps left and right (x-dx, x+dx) and compares them to x=0. If (x,x+-dx) <= 0, we have an interval to bisect. It would be tremendounsly faster and robust if I used Sturm's polynomial to make an initial guess but I was too tired :)

C — 340 bytes + 25 points for numerical approximation = 365
To compile gcc -o quartic quartic.c -lm, to run ./quartic a b c d e. Uses Newton–Raphson method, no big whoop. Using deterministic methods, I can't see getting anywhere near this compact.
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#define C(x) atof(argv[x])
int main(int argc,char *argv[]){int i;double a,b,c,d,e,x,y;a=C(1);b=C(2);c=C(3);d=C(4);e=C(5);for(x=0,y=1,i=0;i<100;x=y,i++){y=x-((((a*x+b)*x+c)*x+d)*x+e)/(((4*a*x+3*b)*x+2*c)*x+d);if(fabs(x-y)<1e-09){printf("%.9f\n",y);return 0;}}printf("n\n");return 1;}

e.g.
$ ./quartic 1 2 3 4 5
n

$ ./quartic -1 2 3 4 5
-1.110290760

$ ./quartic -1 2 3 4 -5
0.728726879

Verified via Wolfram|Alpha, results check out.

Troll FTW - naming it quintic to solve a "quartic" equation ;-)

Pretty sure you could work recursion into this fairly easily to grab the -50 bonus

@DigitalTrauma - fixed it...

This solution is incomplete as it runs the risk of getting caught in a local minimum/maximum and dividing by zero without showing conclusively that there are no real roots. See my comment on DigitalTrauma's answer.

@steveverrill - You're welcome to provide your own solution.

bc (driven by bash), score:137 (162 bytes -50 recursion bonus +25 numerical penalty)
bc -ql<<Q
n=0
define r(x){if(n++>99){print "n
";halt}
y=x-($1*x^4+$2*x^3+$3*x*x+$4*x+$5)/(4*$1*x^3+3*$2*x*x+2*$3*x+$4)
if(y==x){print x,"
";halt}else r(y)}r(0)
Q

This is pretty much the same algorithm as the c answer, though it uses recursion to spice it up.
Run as follows:
$ ./quartic.sh 1 2 3 4 5
n
$ ./quartic.sh -1 2 3 4 5
-1.11029075952058816917
$ ./quartic.sh 1 2 3 4 -5
.68412431945306971026
$

Of course Newton-Raphson has its limitations, and won't necessarily give all real roots in all cases where the exist.
According to WolframAlpha, this one has real roots at -1.9144 and 1.3731:
$ ./quartic.sh 1 1 -2 -1 -1
n
$

Also there is a very real risk of divide-by-zero in some cases.  But this is code-golf, so who cares ;-)

Divide by zero is a major issue. If your code fails to find a solution, it won't be for lack of iterations. It will be because it gets caught in one of the local maxima/minima, where dy/dx falls to zero. Newton-Raphson will try to divide by zero and the program will crash. With a quadratic such as x^2+1 (only one maximum/minimum) this error could be trapped and used as conclusive proof of no real roots. But a quartic has up to 3 local maxima/minima so you don't know if there's really no roots or if you made a bad first guess for x.

C, 182 + 25 = 207
This is not the most eleant solution but it is certainly creative. Using iterger pointer conversions, it loops through every possibile value that a double can hold, tries it out, and checks if it equals 0.
int main(int z,char **v){double a[5],f=0,r=1;int i=5;while(i-->0)scanf("%lf",a+i);while(++(*(int*)&f)&&r){i=5,r=0;while(i-->0)r+=a[i]*pow(f,i);}if(r)printf(“%f",r);else printf("n");}

Ruby — 132 characters + 25 numerical = 157
require'matrix';f=->a,b,c,d,e{a=-a.to_f;Matrix[[0,0,0,e/a],[1,0,0,d/a],[0,1,0,c/a],[0,0,1,b/a]].eigen.eigenvalues.find(&:real?)||?n}

I think this toes the line of using native math libraries, but it's a pretty cool demonstration of what can be done with Ruby, as well as an intriguing way to look at solving univariate polynomial equations through the lens of linear algebra.
Basically, f just constructs the companion matrix of the equivalent monic quartic and computes its eigenvalues, which is the same thing as finding the roots of the original quartic.

Javascript/ES6 148
Since only a solution is required, I used a Newton solver.
f=s=>{a=s.split(' ');for(x=i=0;i++<1e5;x-=y)z=x*x,y=(a[0]*z*z+a[1]*x*z+a[2]*z+a[3]*x+ +a[4])/(4*a[0]*z*x+3*a[1]*z+2*a[2]*x+ +a[3]);return y|0?'n':x}

If you don't have Firefox, you can test it without fat arrow :
function f(s){a=s.split(' ');for(x=i=0;i++<1e5;x-=y)z=x*x,y=(a[0]*z*z+a[1]*x*z+a[2]*z+a[3]*x+ +a[4])/(4*a[0]*z*x+3*a[1]*z+2*a[2]*x+ +a[3]);return y|0?'n':x}

Test : f('1 -2 5 -12 4') returns 0.3882914410047445
Warning : This can fail for some equations (if d=0 for example).

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


text:
Find the overall period from a list of frequencies
Inspired by http://xkcd.com/1331/
In this xkcd comic, there are several gifs that all blink with different frequency. I want to know what the period would be if was all a single GIF. Given a list of numbers representing the individual frequencies, output the period of the overall GIF.
Formal Definition
Input:
N
f1
f2
.
.
.
fN

Output:
P

Where N is the number of frequencies, fi is the ith frequency, and P is the resulting period of the total GIF.
You may choose to use any delimiting character you want(instead of \n), and you may exclude the N if you wish, and it will be inferred by the number of delimeters.
Some specifics
Frequencies are the closest double-precision floating point representation of the numbers provided as input.
The outputted period is a 64-bit unsigned integer, rounded(up on 0.5) to the nearest whole. Any input that would produce a period bigger than 2^64-1 is considered undefined behaviour.
Likewise any input <= 0 is considered undefined behaviour.
Win Condition
Code golf so shortest code wins!

Possible spoiler... wouldn't this just be the product of the given frequencies?

@crazedgremlin No it isn't, but you are pretty close.

@crazedgremlin - If A is 2s and B is 4s, then the resulting period would be 4s, not 8s.

Ah, I see, thanks.  @Cruncher, what exactly do you mean by "frequency"?  Repetitions per second or the amount of time a repetition takes?  I assume the former, as that is usually what frequency means.

There are at least 2 methods for this: Take the overall frequency as the GCD of the input frequencies and invert it. Or take the input frequencies, invert them all to get the periods and take the LCM as the overall period. I took the GCD. @DavidCarraher took the LCM. You just need to cope with the non-integers.

I'm not going to post this since it's just expressing the already posted method in a more concise language, but the J answer would be 1%+./ with the requirement that the frequencies be given without N and space separated. Alternatively, *./1% with the same requirements. Right tool for the job.

@crazedgremlin The inputs are frequencies (# of repetitions in unit time). And the output is period (units of time for each repetition)

APL, 4
∧/∘÷

∧ is both logical AND and numerical LCM (with domain over integers, floats, complex, rationals, whatever number stack is supported by the APL implementation) so ∧/ is reduction by LCM, or computing the LCM of an array.
Monadic ÷ is numeric inverse. So the composition ∧/∘÷ is the LCM of the inverses of the numbers supplied.
The other formula, inverse of the GCD, would be ÷∘(∨/), where the parentheses are needed to fix the precedence between ∘ and /.
You can try it online on http://tryapl.com/
Examples
      ∧/∘÷ .12 .02 3.9 .15 .99
100
      ∧/∘÷ (16÷5)(2÷3)(2.35)(1÷7)
420

Holy bananas!

@Cruncher that would be † )) ! in APL.

Bravo. I think that we have a winner.

Simply amazing. Hats off to you.

Mathematica 43 28
Second try
My first attempt was not correct, although it did have some of the necessary ingredients (LCM,Rationalize).  The complete solution requires taking into account both the numerator and denominator of each frequency (expressed as a common fraction).
l is the list of frequencies.
Rationalizing 2.35 converts it to the common fraction 235/100.
f@l_:=LCM@@(1/Rationalize@l)

Assume that all GIFs fire at t=0.
The following approach does not require that the frequencies be expressed as "real numbers", ie. as decimal fractions.  They may be other sort of fractions.  The example below is a case where the fractions are in fifths, thirds, hundredths and sevenths.
If two or more frequencies are incommensurate (in which case at least one must be an irrational number) then there is no solution. In other words, there will be no point in time, t>0, at which all components fire at the same time.
Example1
f[{50, 10}]

1/10

Example 2
f[{16/5, 2/3, 2.35, 1/7}]

420

If we multiply the least overall period by each of the frequencies, we find a whole number of cycles in each case:
420*{16/5, 2/3, 2.35, 1/7}

{1344, 280, 987., 60}

(1344 hops of 16/5 units) lands at 420.
(280 hops of 2/3 units) lands at 420.
(987 hops of 2.35 units) lands at 420.
(60 hops of 7 units) lands at 420.

The right tool for the right job.

I am not sure I understand. If the inputs are frequencies, the f[{50,10}] would mean the common cycle of signal that fires 50 times per second and a cycle that files 10 times per second? The correct answer would be 1/10 of a second, but f[{50, 10}] returns 1. Actually, lots of random things return an answer of 1. f[{345345, h}] returns 1.

My original approach was incomplete (and therefore incorrect). I've amended it in such a way as to address your observation.  The current solution also makes sense geometrically (using line segments against the real line).

I was coming to post just such a solution, but you beat me to it. Very nice.

@Jonathan.  Yes, your approach was almost identical to mine. But I don't see the need for Round. Won't Rationalize and LCM guarantee that the results be integers?

Yep, the way you did it Round becomes unnecessary.

Let's see the golfscript and APL aficionados try to beat this!

@MichaelStern Never underestimate APL! Marinus' solution, among the Javascript comments, weighs in at 27 chars.

Javascript: 191 characters
The input format that I chose (within the rules) is the frequency numbers separated by commas. No spaces allowed and no newlines. The initial N must not be given. Each number must be just a serie of at least one [0-9] digits with an optional dot somewhere within. If the input is malformed, the behaviour is undefined.
How it works:

 The period of some integer frequency numbers is the GCD of these numbers. If the given numbers are not integer, it sucessively multiplies they by 10 until it gets everything as an integer number (this exploit the fact that the non-integer numbers are given in base 10). After calculating the GCD, it divides the result by the power of ten used to multiply the input numbers, and hence getting the overall frequency. Inverting this we get the period.

Note: I am pretty sure that now that I gave this answer, somebody will code the same in APL or J and beat it. :(

The code:
d=1,s=prompt().split(",");for(a in s){s[a]=parseFloat(s[a]);while(s[a]*d%1>0)d*=10}g=s[0]*d;for(a in s){u=g;v=s[a]*=d;p=2;q=1;while(u>=p&v>=p)if(u%p|v%p)p++;else{u/=p;v/=p;q*=p}g=q}alert(d/g)

Testing it:
Input: 50,10
Output: 0.1
Interpretation: One GIF blinks 10 times per second (period = 0.1s) and the other 50 times (period = 0.02s). So a combined GIF would repeat itself in 0.1 seconds.

Input: 2.7,3.4
Output: 10
Interpretation: One blinking at 2.7 times per second will blink 27 times in 10 seconds. One blinking 3.4 times per second will blink 34 times in 10 seconds. So, 10 seconds is a period, and since GCD(27,34)=1, it is the smallest.

Input: 4.8,7.2
Output: 0.4166666666666667
Interpretation: One blinking at 4.8 times per second and the other at 7.2 times per second, gives a frequency of 2.4 times per second, which is a period 0.41666... seconds.

Input: 0.6,12,7.9,4.33
Output: 100
Interpretation: Similar to second case. 60, 1200, 790 and 433 times each 100 seconds. The GCD of these numbers is 1.

Input: 400,200,25,350
Output: 0.04
Interpretation: The slowest is the 25 times per second, which is the overall frequency. 25 times per second is a period of 0.04 seconds.

Input: 440,200,35,360
Output: 0.2
Interpretation: In 0.2 seconds, we have 88, 40, 7 and 72 blinks.

GCD? That's the greatest common divisor, so it would always be smaller than the frequencies. I think you mean LCM (least common multiple).

@Quincunx No, it is the GCD. The total period is the LCM of the individual periods, not individual frequencies.

Here's the APL: (⊃x÷z)×∨/z←{⍵×10}⍣{⍵≡⌈⍵}x←⎕

Would you run a test case with rational numbers or "real numbers" (in the computer science sense of the term)?  I don't think an approach based on GCD will work.

@DavidCarraher I messed frequency with period, but now I already fixed. Just changed the g/d to d/g. I will add some test cases.

@marinus Go on and post it. :) (but insert a link in your answer to this one).

@DavidCarraher Done, I added some test cases.

I think an improvement would be multiply by two.  Since these are all expressed in what is effectively "binary scientific notation" (i.e. floating-point), the multiple you are looking for is 2^n, for some n.

source: Stack Exchange

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

sort: votes


text:
Loophole for other challenge
You are to post an answer you posted that exploited a loophole in the challengers question. Bonus points if it caused them to rewrite the question.
For example, one challenge was to write a program that such that if a random character is removed, it still works, and your score is how many characters it fails on. Some one posted the empty program, since then it would fail on no characters (though the compiler would fail) and the question had to be changed. He was unrightly down-voted, so I hope he sees this challenge.
This is a popularity contest, so whoever gets the most votes wins!

You should say what is a valid answer. You didn't gave any indications. The only rule is that "You are to post an answer you posted". What are the rules for a valid answer? Can we post as many answers from as many questions as we want? Can we post answers from the same question?

I agree. I think you should edit your post to add a rule that it has to be a different question.

In my answer to Loophole for other challenge, I deliberately exploit the fact that the poster didn't specify that the answer had to be responding to another question.  This made my answer recursive and self-referential.
I also golfed my answer (even though it was a popularity contest).  0 bytes of code.

It looks like I'm not the only one exploiting the rules.

I do like recursion. Also, I was expecting and okay with someone exploiting this question. Therefore, exploiting this question is perfectly fine in my mind. Therefore, simply make a self-referential answer doesn't exploit anything.

I was going off of the word "other" in the title. ;-)

So I guess technically he did an antiexploit. He broke the literal meaning of the question, but at the same time matched what I was thinking.

Render a version of the BBC Micro owl logo
I used curl to grab the challenge page and outputted an answer posted by someone else.

In Weirdest way to produce a stack overflow, i submitted an answer that opened a web browser and displayed stackoverflow.com.

That is really a weird way, but a good one!

In Shortest Program to Sort a List of numbers into Odd and Even Category, the question clearly states:

... The Size of the program is the size of the body of the function, i.e. excluding the size of the function signature.

I thought, "Why such a bizarre and specific rule?" And as I was trying to golf down my initial submission, it dawned on me--default parameter values! According to the language spec, they're definitively not part of the function body, so I went ahead and submitted my final solution: a function whose body is a single character. That must have been what the OP wanted!... right?...
Needless to say, it did not win. :/
After accepting another answer, the challenger did eventually add a footnote as to why the one-character solution wasn't considered. The rules of the challenge, however, still remain unchanged (as of the time of this post). So, in the strictest interpretation of the rules, who would you say actually won? ;]

In Write a hash function for Morse Code, the OP didn't specifically exclude negative or floating point values which are entirely usable as hashes. Using this loophole, I was able to get a better than "perfect" score of 236. There was much griping, but the OP never changed the question, despite promising to, and the loophole was subsequently exploited by almost every other poster!

In the question https://codegolf.stackexchange.com/questions/21391/output-with-1-on-stdout-using-a-0-byte-source-code, it states that it will give a bonus of -500 bytes if we output '1' to the console using a source-code file which is 0 bytes long.
My answer is this one and 'abuses' the null devices in windows and linux.
The question wasn't rewritten, but this answer gave me a pretty big hole to go to the gold (the -500 byte bonus). Why? Because the null devices have ALWAYS 0 bytes in size and are guaranteed to exist!

Quoting this question:

Your goal is to add two input numbers without using any of the following math operators: +,-,*,/.
Additionally, you can't use any built-in functions that are designed to replace those math operators.

I posted this answer, it was not very popular though. Quoting from my answer:

And, as suggested by @Ismael Miguel (althought he was not exactly suggesting this), by really abusing the rules underspecification, we can note that only +, -, * and / operators were forbidden, but += was not, so it is allowed (it is not a built-in function either, since it is not even a function). This way, we can express the instruction with just 4 characters (and it will always work with negatives and non-integers too for both values):

y+=x

I'd say that the increment operator is designed to replace addition

I said the same. He almost jumped my throat and shoved in my face the Javascript spec.

@IsmaelMiguel :)

Well, check out my answer to this post. The one talking about you. And this is how you "bend" the rules...

In the same question that @Victor refered (Add without addition (or any of the 4 basic arithmetic operators)), i gave this asnwer.
Basicly it "ABUSES" the Javascript internal casting to integer of the boolean values.

And This question itself exploits a loophole: there is NOTHING saying we can't refer to the same question in the answers. Or the number of answers. Or the number of answers from the same question.

+1 For citing me, for abusing the same question, and for getting a downvote that is probably from the same person that downvoted me (but I can't be sure about this).

What matters is that I exploited a loophole in a question about loopholes. The irony is quite huge!

Yeah, the meta-loophole.

Still, it's a valid exploitable hole.

I don't get it. What is the loophole?

Read the 2nd part of the answer.

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


text:
Count characters, turn them into a cipher
Problem:
You must make a program that does the following:

takes a large string of lowercase text, and counts all the occurrences of each letter.
then you put the letters in order from greatest to least occurences.
then you take that list and turns it into an encoder/decoder for the text.
then encodes the text with that cipher.

Hard to understand? See this example:
Example:
Input text:

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc sed dui at nisi euismod pellentesque ac sed enim. Nullam auctor justo quis diam faucibus, eu fringilla est porttitor. Pellentesque vel pharetra nisl. Vestibulum congue ultrices magna a fringilla. Quisque porttitor, risus suscipit pellentesque tristique, orci lorem accumsan nisi, scelerisque viverra turpis metus sit amet sapien. Fusce facilisis diam turpis, nec lobortis dui blandit nec. Vestibulum ac urna ut lacus commodo sollicitudin nec non velit. Nulla cursus urna sem, at tincidunt sem molestie vel. Nullam fringilla ante eu dolor bibendum, posuere iaculis nunc lacinia. Sed ac pretium est, vel scelerisque nisl. Phasellus lobortis dolor sodales sapien mollis hendrerit. Integer scelerisque tempor tellus, viverra varius neque mattis in. Integer porta vestibulum nisl, et feugiat tortor tincidunt vel. Aenean dignissim eleifend faucibus. Morbi nec neque vel ante pulvinar mollis eu in ipsum.

Convert to lowercase.
Char count (per letter. spaces and punctuation ignored):

[('a', 49), ('b', 11), ('c', 34), ('d', 22), ('e', 93), ('f', 9), ('g', 10), ('h', 3), ('i', 89), ('j', 1), ('k', 0), ('l', 61), ('m', 31), ('n', 56), ('o', 37), ('p', 20), ('q', 12), ('r', 47), ('s', 71), ('t', 59), ('u', 65), ('v', 15), ('w', 0), ('x', 0), ('y', 0), ('z', 0)]

Ordered char count:

[('e', 93), ('i', 89), ('s', 71), ('u', 65), ('l', 61), ('t', 59), ('n', 56), ('a', 49), ('r', 47), ('o', 37), ('c', 34), ('m', 31), ('d', 22), ('p', 20), ('v', 15), ('q', 12), ('b', 11), ('g', 10), ('f', 9), ('h', 3), ('j', 1), ('k', 0), ('w', 0), ('x', 0), ('y', 0), ('z', 0)]

Then create a lookup table using the original and sorted lists:
abcdefghijklmnopqrstuvwxyz
||||||||||||||||||||||||||
eisultnarocmdpvqbgfhjkwxyz

Python dictionary:
{'o': 'v', 'n': 'p', 'm': 'd', 'l': 'm', 'k': 'c', 'j': 'o', 'i': 'r', 'h': 'a', 'g': 'n', 'f': 't', 'e': 'l', 'd': 'u', 'c': 's', 'b': 'i', 'a': 'e', 'z': 'z', 'y': 'y', 'x': 'x', 'w': 'w', 'v': 'k', 'u': 'j', 't': 'h', 's': 'f', 'r': 'g', 'q': 'b', 'p': 'q'}

And now encode the original text with this lookup table:

'Lvgld rqfjd uvmvg frh edlh, svpflshlhjg eurqrfsrpn lmrh. Njps flu ujr eh prfr ljrfdvu qlmmlphlfbjl es flu lprd. Njmmed ejshvg ojfhv bjrf ured tejsrijf, lj tgrpnrmme lfh qvghhrhvg. Plmmlphlfbjl klm qaeglhge prfm. Vlfhrijmjd svpnjl jmhgrslf denpe e tgrpnrmme. Qjrfbjl qvghhrhvg, grfjf fjfsrqrh qlmmlphlfbjl hgrfhrbjl, vgsr mvgld essjdfep prfr, fslmlgrfbjl krklgge hjgqrf dlhjf frh edlh feqrlp. Fjfsl tesrmrfrf ured hjgqrf, pls mvivghrf ujr imepurh pls. Vlfhrijmjd es jgpe jh mesjf svddvuv fvmmrsrhjurp pls pvp klmrh. Njmme sjgfjf jgpe fld, eh hrpsrujph fld dvmlfhrl klm. Njmmed tgrpnrmme ephl lj uvmvg irilpujd, qvfjlgl resjmrf pjps mesrpre. Slu es qglhrjd lfh, klm fslmlgrfbjl prfm. Paeflmmjf mvivghrf uvmvg fvuemlf feqrlp dvmmrf alpuglgrh. Iphlnlg fslmlgrfbjl hldqvg hlmmjf, krklgge kegrjf plbjl dehhrf rp. Iphlnlg qvghe klfhrijmjd prfm, lh tljnreh hvghvg hrpsrujph klm. Alplep urnprffrd lmlrtlpu tejsrijf. Mvgir pls plbjl klm ephl qjmkrpeg dvmmrf lj rp rqfjd.'

I love python!
Rules:

Your program will accept a string and output one.
Convert all input to lowercase before doing anything
I don't care how you do the list sorting, but only count lowercase letters
Bonus points (-30) for making a decryptor (no copying the decryption list, do it from scratch
This is code-golf, so the shortest code wins!
Have fun!

How many points for a decryptor?

This is a fun challenge, but the encryption method here would make a cryptographer weep. Not only is it a single-substitution cipher, but it has the audacity to introduce a recognizable and exploitable bias: the more common a ciphertext letter is in usage of the enciphered language, the more likely the plaintext lies near the beginning of the alphabet. It out-Caesar's Caesar. ;-)

@TheDoctor great idea, but you have made one little error... the ciphered text should start with the respective ciphered letters according to your algorithm! :) First sentence starts with M now, second sentence with P and so on...

@DigitalTrauma - let's say 30 points for a decryptor

Bonus points (-30) for making a decryptor (no copying the decryption list, do it from scratch? THAT’S IMPOSSIBLE! You would need to have the key (your “decryption list“ aka “lookup table”) to be able to do that. Just taking a ciphertext and expecting anyone to provide a decryptor that transforms it back into plaintext without the use of any key is as if you’re asking us to post a question to StackOverflow without typing any letters or numbers. Information theory already tells us that you can’t gain information out of nowhere… so your substitution cipher needs that lookup table (aka key).

GolfScript, 39 characters
:I{97,26,{97+}%{[.32-]I\-,}$+'{|}~'+=}%

Online version for testing. Note that the sorting is not defined if multiple characters have the same count in the input string.
Example output

Lvgld rqfjd uvmvg frh edlh, svpflshlhjg eurqrfsrpn lmrh. Njps flu ujr
eh prfr ljrfdvu qlmmlphlfbjl es flu lprd. Njmmed ejshvg ojfhv bjrf
ured tejsrijf, lj tgrpnrmme lfh qvghhrhvg. Plmmlphlfbjl wlm qaeglhge
prfm. Vlfhrijmjd svpnjl jmhgrslf denpe e tgrpnrmme. Qjrfbjl qvghhrhvg,
grfjf fjfsrqrh qlmmlphlfbjl hgrfhrbjl, vgsr mvgld essjdfep prfr,
fslmlgrfbjl wrwlgge hjgqrf dlhjf frh edlh feqrlp. Fjfsl tesrmrfrf ured
hjgqrf, pls mvivghrf ujr imepurh pls. Vlfhrijmjd es jgpe jh mesjf
svddvuv fvmmrsrhjurp pls pvp wlmrh. Njmme sjgfjf jgpe fld, eh
hrpsrujph fld dvmlfhrl wlm. Njmmed tgrpnrmme ephl lj uvmvg irilpujd,
qvfjlgl resjmrf pjps mesrpre. Slu es qglhrjd lfh, wlm fslmlgrfbjl
prfm. Paeflmmjf mvivghrf uvmvg fvuemlf feqrlp dvmmrf alpuglgrh.
Iphlnlg fslmlgrfbjl hldqvg hlmmjf, wrwlgge wegrjf plbjl dehhrf rp.
Iphlnlg qvghe wlfhrijmjd prfm, lh tljnreh hvghvg hrpsrujph wlm. Alplep
urnprffrd lmlrtlpu tejsrijf. Mvgir pls plbjl wlm ephl qjmwrpeg dvmmrf
lj rp rqfjd.

Darn golfscript! it always wins!

Bash/coreutils, 91 chars
tr a-z `echo {a..z} $1|fold -w1|grep '[a-z]'|sort|uniq -c|sort -rn|awk '{printf $2}'`<<<$1

Save as cipher.sh, chmod +x it and run:
$ ./cipher.sh "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc sed dui at nisi euismod pellentesque ac sed enim. Nullam auctor justo quis diam faucibus, eu fringilla est porttitor. Pellentesque vel pharetra nisl. Vestibulum congue ultrices magna a fringilla. Quisque porttitor, risus suscipit pellentesque tristique, orci lorem accumsan nisi, scelerisque viverra turpis metus sit amet sapien. Fusce facilisis diam turpis, nec lobortis dui blandit nec. Vestibulum ac urna ut lacus commodo sollicitudin nec non velit. Nulla cursus urna sem, at tincidunt sem molestie vel. Nullam fringilla ante eu dolor bibendum, posuere iaculis nunc lacinia. Sed ac pretium est, vel scelerisque nisl. Phasellus lobortis dolor sodales sapien mollis hendrerit. Integer scelerisque tempor tellus, viverra varius neque mattis in. Integer porta vestibulum nisl, et feugiat tortor tincidunt vel. Aenean dignissim eleifend faucibus. Morbi nec neque vel ante pulvinar mollis eu in ipsum."
Lvgld rqfjd uvmvg frh edlh, svpflshlhjg eurqrfsrpn lmrh. Njps flu ujr eh prfr ljrfdvu qlmmlphlfbjl es flu lprd. Njmmed ejshvg ojfhv bjrf ured tejsrijf, lj tgrpnrmme lfh qvghhrhvg. Plmmlphlfbjl jlm qaeglhge prfm. Vlfhrijmjd svpnjl jmhgrslf denpe e tgrpnrmme. Qjrfbjl qvghhrhvg, grfjf fjfsrqrh qlmmlphlfbjl hgrfhrbjl, vgsr mvgld essjdfep prfr, fslmlgrfbjl jrjlgge hjgqrf dlhjf frh edlh feqrlp. Fjfsl tesrmrfrf ured hjgqrf, pls mvivghrf ujr imepurh pls. Vlfhrijmjd es jgpe jh mesjf svddvuv fvmmrsrhjurp pls pvp jlmrh. Njmme sjgfjf jgpe fld, eh hrpsrujph fld dvmlfhrl jlm. Njmmed tgrpnrmme ephl lj uvmvg irilpujd, qvfjlgl resjmrf pjps mesrpre. Slu es qglhrjd lfh, jlm fslmlgrfbjl prfm. Paeflmmjf mvivghrf uvmvg fvuemlf feqrlp dvmmrf alpuglgrh. Iphlnlg fslmlgrfbjl hldqvg hlmmjf, jrjlgge jegrjf plbjl dehhrf rp. Iphlnlg qvghe jlfhrijmjd prfm, lh tljnreh hvghvg hrpsrujph jlm. Alplep urnprffrd lmlrtlpu tejsrijf. Mvgir pls plbjl jlm ephl qjmjrpeg dvmmrf lj rp rqfjd.
$

Ruby, 104 92 91 characters
Saved quite a few characters thanks to @Chron
f=->(s){m=[*?a..?z];l=m.map{|x|[-s.downcase.count(x),x]};s.tr(m*'',l.sort.transpose[1]*'')}

Online Version here. Sorting of characters with the same count is not defined, as mentioned in another answer. With the input "asdf", each answer has another output so far.
In other words: all answers have the same behaviour (thus represent a decodable encoding) when the input contains the whole alphabet with each letter having a unique count.

A couple of small improvements: ("a".."z").to_a can be [*?a..?z], m.join can be m*'' and def f(s)...end can be f=->s{...}

Mathematica 171
f@m_:=StringReplace[m,Thread[(CharacterRange["a",
FromCharacterCode[96+Length@(l=Reverse@SortBy[Tally[Select[Characters@m,
(LetterQ@#\[And]LowerCaseQ@#)&]],Last][[All,1]])]])->l ]]

Assuming t is the Lorem ipsum text.
f[t]

"Lvgld rqfjd uvmvg frh edlh,svpflshlhjg eurqrfsrpn lmrh.Njps flu ujr
  eh prfr ljrfdvu qlmmlphlfbjl es flu lprd.Njmmed ejshvg ojfhv bjrf
  ured tejsrijf,lj tgrpnrmme lfh qvghhrhvg.Plmmlphlfbjl vlm qaeglhge
  prfm.Vlfhrijmjd svpnjl jmhgrslf denpe e tgrpnrmme.Qjrfbjl
  qvghhrhvg,grfjf fjfsrqrh qlmmlphlfbjl hgrfhrbjl,vgsr mvgld essjdfep
  prfr,fslmlgrfbjl vrvlgge hjgqrf dlhjf frh edlh feqrlp.Fjfsl tesrmrfrf
  ured hjgqrf,pls mvivghrf ujr imepurh pls.Vlfhrijmjd es jgpe jh mesjf
  svddvuv fvmmrsrhjurp pls pvp vlmrh.Njmme sjgfjf jgpe fld,eh hrpsrujph
  fld dvmlfhrl vlm.Njmmed tgrpnrmme ephl lj uvmvg irilpujd,qvfjlgl
  resjmrf pjps mesrpre.Slu es qglhrjd lfh,vlm fslmlgrfbjl
  prfm.Paeflmmjf mvivghrf uvmvg fvuemlf feqrlp dvmmrf alpuglgrh.Iphlnlg
  fslmlgrfbjl hldqvg hlmmjf,vrvlgge vegrjf plbjl dehhrf rp.Iphlnlg
  qvghe vlfhrijmjd prfm,lh tljnreh hvghvg hrpsrujph vlm.Alplep
  urnprffrd lmlrtlpu tejsrijf.Mvgir pls plbjl vlm ephl qjmvrpeg dvmmrf
  lj rp rqfjd."

The replacement rules generated by Thread…-> l were:

{"a" -> "e", "b" -> "i", "c" -> "s", "d" -> "u", "e" -> "l",
   "f" -> "t", "g" -> "n", "h" -> "a", "i" -> "r", "j" -> "o",
   "k" -> "c", "l" -> "m", "m" -> "d", "n" -> "p", "o" -> "v",
   "p" -> "q", "q" -> "b", "r" -> "g", "s" -> "f", "t" -> "h",
   "u" -> "j"}

K, 43
{x^(b!b^26$>#:'=a@&(a:_x)in b:"c"$97+!26)x}

C# 386
using System.Collections.Generic;using System.Linq;namespace N{class P{static void Main(string[]a){char[] f="abcdefghijklmnopqrstuvwxyz".ToCharArray();Dictionary<char,int>l=new Dictionary<char,int>();foreach (char c in f) l.Add(c, "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc sed dui at nisi euismod pellentesque ac sed enim. Nullam auctor justo quis diam faucibus, eu fringilla est porttitor. Pellentesque vel pharetra nisl. Vestibulum congue ultrices magna a fringilla. Quisque porttitor, risus suscipit pellentesque tristique, orci lorem accumsan nisi, scelerisque viverra turpis metus sit amet sapien. Fusce facilisis diam turpis, nec lobortis dui blandit nec. Vestibulum ac urna ut lacus commodo sollicitudin nec non velit. Nulla cursus urna sem, at tincidunt sem molestie vel. Nullam fringilla ante eu dolor bibendum, posuere iaculis nunc lacinia. Sed ac pretium est, vel scelerisque nisl. Phasellus lobortis dolor sodales sapien mollis hendrerit. Integer scelerisque tempor tellus, viverra varius neque mattis in. Integer porta vestibulum nisl, et feugiat tortor tincidunt vel. Aenean dignissim eleifend faucibus. Morbi nec neque vel ante pulvinar mollis eu in ipsum.".ToLower().Trim().Count(v => v == c));foreach (KeyValuePair<char, int> i in l.OrderByDescending(p => p.Value))System.Console.Write(i.Key +""+i.Value);}}}

Uncompressed.
using System.Collections.Generic;
using System.Linq;
namespace N {
    class P {
        static void Main(string[]a){
            char[] f="abcdefghijklmnopqrstuvwxyz".ToCharArray();
            Dictionary<char,int>l=new Dictionary<char,int>();
            foreach (char c in f)
                l.Add(c, "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc sed dui at nisi euismod pellentesque ac sed enim. Nullam auctor justo quis diam faucibus, eu fringilla est porttitor. Pellentesque vel pharetra nisl. Vestibulum congue ultrices magna a fringilla. Quisque porttitor, risus suscipit pellentesque tristique, orci lorem accumsan nisi, scelerisque viverra turpis metus sit amet sapien. Fusce facilisis diam turpis, nec lobortis dui blandit nec. Vestibulum ac urna ut lacus commodo sollicitudin nec non velit. Nulla cursus urna sem, at tincidunt sem molestie vel. Nullam fringilla ante eu dolor bibendum, posuere iaculis nunc lacinia. Sed ac pretium est, vel scelerisque nisl. Phasellus lobortis dolor sodales sapien mollis hendrerit. Integer scelerisque tempor tellus, viverra varius neque mattis in. Integer porta vestibulum nisl, et feugiat tortor tincidunt vel. Aenean dignissim eleifend faucibus. Morbi nec neque vel ante pulvinar mollis eu in ipsum.".ToLower().Trim().Count(v => v == c));
            foreach (KeyValuePair<char, int> i in l.OrderByDescending(p => p.Value))
                System.Console.Write(i.Key +""+i.Value);
        }
    }
}

Don't include the input string in your char count

Did you even run this? Output: e93i89s71u65l61t59n56a49r47o37c34m31d22p20v15q12b11g10f9h3j1k0w0x0y0z0. And it doesn't come even close to the challenge.

PHP, 151
(with setting short_open_tag = On)
<?$c=array_slice(count_chars(strtolower($s=$argv[1])),97,26,1);arsort($c);echo strtr($s,array_combine(range('a','z'),array_map('chr',array_keys($c))));

This expects the text as the first argument to the script. Like so:
php cypher.php "Lorem ipsum [...]"

R, 137
l=letters;s=strsplit(readline(),"")[[1]];g=grep("[a-z]",s);s[g]=names(sort(table(factor(tolower(s),l)),d=T))[match(s[g],l)];cat(s,sep="")

Output (based on example in question):

Lvgld rqfjd uvmvg frh edlh, svpflshlhjg eurqrfsrpn lmrh. Njps flu ujr eh prfr ljrfdvu qlmmlphlfbjl es flu lprd. Njmmed ejshvg ojfhv bjrf ured tejsrijf, lj tgrpnrmme lfh qvghhrhvg. Plmmlphlfbjl klm qaeglhge prfm. Vlfhrijmjd svpnjl jmhgrslf denpe e tgrpnrmme. Qjrfbjl qvghhrhvg, grfjf fjfsrqrh qlmmlphlfbjl hgrfhrbjl, vgsr mvgld essjdfep prfr, fslmlgrfbjl krklgge hjgqrf dlhjf frh edlh feqrlp. Fjfsl tesrmrfrf ured hjgqrf, pls mvivghrf ujr imepurh pls. Vlfhrijmjd es jgpe jh mesjf svddvuv fvmmrsrhjurp pls pvp klmrh. Njmme sjgfjf jgpe fld, eh hrpsrujph fld dvmlfhrl klm. Njmmed tgrpnrmme ephl lj uvmvg irilpujd, qvfjlgl resjmrf pjps mesrpre. Slu es qglhrjd lfh, klm fslmlgrfbjl prfm. Paeflmmjf mvivghrf uvmvg fvuemlf feqrlp dvmmrf alpuglgrh. Iphlnlg fslmlgrfbjl hldqvg hlmmjf, krklgge kegrjf plbjl dehhrf rp. Iphlnlg qvghe klfhrijmjd prfm, lh tljnreh hvghvg hrpsrujph klm. Alplep urnprffrd lmlrtlpu tejsrijf. Mvgir pls plbjl klm ephl qjmkrpeg dvmmrf lj rp rqfjd.

Smalltalk, 138
input in s:
m:=(s select:[:c|cisLetter])asLowercase asBag sortedCounts map:#value.
i:=($ato:$z).m:=m,(i copyWithoutAll:m).
s copyTransliterating:i to:m

the decoder is:
s copyTransliterating:m to:i

but as (if I understand correctly) I may not reuse "i" and "m", I'll golf without it. Code above has two additional CRs inserted for readability, which were uncounted in the char count.

Clojure, 135
(Assuming the input text is contained in the var s)
(let[a(map char(range 97 123))m(->> s .toLowerCase frequencies(sort-by val >)keys(filter(set a))(zipmap a))](apply str(map #(m % %)s)))

Perl, 84
$c{$_}++for lc($_=<>)=~/./g;@h{a..z}=sort{$c{$b}-$c{$a}}a..z;s/[a-z]/$h{$&}/ge;print

.

perl cipher.pl
.. input skipped ..
Lvgld rqfjd uvmvg frh edlh, svpflshlhjg eurqrfsrpn lmrh. Njps flu ujr
  eh prfr lj rfdvu qlmmlphlfbjl es flu lprd. Njmmed ejshvg ojfhv bjrf
  ured tejsrijf, lj tgrpn rmme lfh qvghhrhvg. Plmmlphlfbjl klm qaeglhge
  prfm. Vlfhrijmjd svpnjl jmhgrslf d enpe e tgrpnrmme. Qjrfbjl
  qvghhrhvg, grfjf fjfsrqrh qlmmlphlfbjl hgrfhrbjl, vgsr  mvgld essjdfep
  prfr, fslmlgrfbjl krklgge hjgqrf dlhjf frh edlh feqrlp. Fjfsl te
  srmrfrf ured hjgqrf, pls mvivghrf ujr imepurh pls. Vlfhrijmjd es jgpe
  jh mesjf s vddvuv fvmmrsrhjurp pls pvp klmrh. Njmme sjgfjf jgpe fld,
  eh hrpsrujph fld dvmlf hrl klm. Njmmed tgrpnrmme ephl lj uvmvg
  irilpujd, qvfjlgl resjmrf pjps mesrpre. Slu es qglhrjd lfh, klm
  fslmlgrfbjl prfm. Paeflmmjf mvivghrf uvmvg fvuemlf feqrl p dvmmrf
  alpuglgrh. Iphlnlg fslmlgrfbjl hldqvg hlmmjf, krklgge kegrjf plbjl
  dehh rf rp. Iphlnlg qvghe klfhrijmjd prfm, lh tljnreh hvghvg hrpsrujph
  klm. Alplep ur nprffrd lmlrtlpu tejsrijf. Mvgir pls plbjl klm ephl
  qjmkrpeg dvmmrf lj rp rqfjd.

P.S. Was it a joke, about decipher? Or should I claim 30 bonus for proving it impossible? Is aab deciphered to aab or bba? Or babaca, was it cacaba or ababcb in original, or babaca itself, literally?

Python 2.7 (147)
Not the shortest code at all but as Python is not yet represented and as I see "I love python!" in the problem setting, here I go,
import sys;s=sys.argv[1];a=map(chr,range(97,123));print"".join([sorted(a,key=lambda x:-s.lower().count(x))[ord(c)-97]if c in a else c for c in s])

Expects the input string to be passed via the command line. (number of characters are reduced to 122 if the input string was magically inserted into the variable "s")
a=map(chr,range(97,123));print"".join([sorted(a,key=lambda x:-s.lower().count(x))[ord(c)-97]if c in a else c for c in s])

Ouput

Lvgld rqfjd uvmvg frh edlh, svpflshlhjg eurqrfsrpn lmrh. Njps flu ujr eh prfr ljrfdvu qlmmlphlfbjl es flu lprd. Njmmed ejshvg ojfhv bjrf ured tejsrijf, lj tgrpnrmme lfh qvghhrhvg. Plmmlphlfbjl klm qaeglhge prfm. Vlfhrijmjd svpnjl jmhgrslf denpe e tgrpnrmme. Qjrfbjl qvghhrhvg, grfjf fjfsrqrh qlmmlphlfbjl hgrfhrbjl, vgsr mvgld essjdfep prfr, fslmlgrfbjl krklgge hjgqrf dlhjf frh edlh feqrlp. Fjfsl tesrmrfrf ured hjgqrf, pls mvivghrf ujr imepurh pls. Vlfhrijmjd es jgpe jh mesjf svddvuv fvmmrsrhjurp pls pvp klmrh. Njmme sjgfjf jgpe fld, eh hrpsrujph fld dvmlfhrl klm. Njmmed tgrpnrmme ephl lj uvmvg irilpujd, qvfjlgl resjmrf pjps mesrpre. Slu es qglhrjd lfh, klm fslmlgrfbjl prfm. Paeflmmjf mvivghrf uvmvg fvuemlf feqrlp dvmmrf alpuglgrh. Iphlnlg fslmlgrfbjl hldqvg hlmmjf, krklgge kegrjf plbjl dehhrf rp. Iphlnlg qvghe klfhrijmjd prfm, lh tljnreh hvghvg hrpsrujph klm. Alplep urnprffrd lmlrtlpu tejsrijf. Mvgir pls plbjl klm ephl qjmkrpeg dvmmrf lj rp rqfjd.

Yep, i did all that in 20 lines of python, but it's way longer than yours

C# – 393 bytes
string e(string i){char[] f="abcdefghijklmnopqrstuvwxyz".ToCharArray();Dictionary<char,int>l=new Dictionary<char,int>();foreach (char c in f) l.Add(c, i.ToLower().Count(v => v == c));var w = (l.OrderByDescending(p => p.Value)).ToDictionary(q=>q.Key, y=>y.Value);var z = w.Keys.ToList();string r = "";foreach(char c in i) {if((int)c <=97 || (int)c>=122)r+=c;else r += z[((int)c-97)];}return r;}

The extended version of @PauloHDSousa’s answer…

Why do you have a lot of extra spaces in the answer?


text:
Print Leonardo DiCaprio without using any of the letters in his name
The Oscars are coming up soon and we all know who's going to win Best Actor in a Leading Role this year right? The great Leonardo DiCaprio of course! Despite his superb performances in all of his films during his career, he has yet to win an Academy Award. So as tribute and as a way to wish him luck during the Awards Ceremony this year, your task is to print "Leonardo DiCaprio" (without quotes and case-sensitive) without using any letters in his name in your code. This is code-golf so the shortest code wins. Score is based on your code in bytes. Any language is acceptable.
-100 Points if you can print his name on an ascii plate like so (Best Actor not required):
 _____________________________
|                             |
|      Leonardo DiCaprio      |
|         Best Actor          |
|_____________________________|

Edit For clarification, the rule for not "using any letters in his name in your code" is  case-insensitive.
Also another edit you may use spaces.

without using any letters in his name in your code Is this rule case-insensitive?

@nhahtdh yes, it's case-insensitive.

I should have phrase my question clearer. Do you allow lowercase c, or is it forbidden since uppercase C is in his name?

Case insensitive meaning I can use lEO... or cannot?

@Quincunx Case insensitive meaning you cannot use  LlEeOoNnAaRrDdOoIiCcPp

Is correct case required in the output? Which of the following are acceptable? 1. Leonardo DiCaprio 2.LEONARDO DICAPRIO 3.leonardo dicaprio 4.Something random like lEONardo dicAPRIo

@steveverrill Correct case required.

There's no obvious reason why the techniques used in Obfuscated Hello World shouldn't work for this too, making it a duplicate.

Perhaps should have said "in a manner which actually uses English letters somewhere"?

@PeterTaylor: Esolang regardless, most normal languages won't able to print anything when only the vowel u is allowed. Heck, even declaring main is not allowed.

J, 54 - 100 = -46
<17$3(3!:4)8026666198671254860 7598259084372558880 111

Output:
┌─────────────────┐
│Leonardo DiCaprio│
└─────────────────┘

"like so" was the request.

This can be trimmed down by using base-36 encoding of the long integers, reducing each with 3 characters.

@jpjacobs I think base-36 would use some of the letters that aren't permitted.

Ah sure, I totally forgot that rule, sorry.

HTML/Markdown, 96 bytes
Leonardo DiCaprio

This works even with the strictest rule (no space, no letter case-insensitive).
Markdown, 194 - 100 = 94 bytes
This is the fancy version, so it uses quite a lot of bytes (UTF-8). At the end of the first 2 lines are 2 spaces.
╔════════════╗
║Leonardo DiCaprio║
╚════════════╝

How it looks (may or may not look good depending on the font face):
╔════════════╗
║Leonardo DiCaprio║
╚════════════╝
Markdown, 142 - 100 = 42 bytes
This is the poor man's version. No Unicode character is used, so quite lightweight.
~~~~~~~~~~~~~~~~~
| Leonardo DiCaprio |
~~~~~~~~~~~~~~~~~

It looks like a cookie to me:
~~~~~~~~~~~~~~~~~
| Leonardo DiCaprio |
~~~~~~~~~~~~~~~~~

"like so" was the request. Three outputs each different in format but not as required is fun, though.

@BillWoodger: Most answers here don't even follow OP's format.

BF, 77
203 chars = 609 bits = 77 bytes
-[------->+<]>+++.-[--->++++<]>+.++++++++++.-.-------------.--[--->+<]>---.--------------.+++++++++++.[--->+<]>-----.++[->++<]>.++[-->+++<]>.++[->+++<]>++.-[-->+++<]>--.-[++>-----<]>.++.---------.++++++.

Output:
Leonardo DiCaprio

Sclipting, 39 bytes
丟냆녯닦굲뉆묠끆땃눗걲늖및

Based on the Hello, world! program, just encode the name as string.

JavaScript 221 - 100 = 121
This took a little working out... instead of printing, it pushes the result as an alert... best I could do... trying to make this code do a document.write would have floored me...
3[z=(y=''+{})[5]+y[1]+(''+1/0)[1]+'st'+(x=''+!0)[1]+'u'+y[5]+'t'+y[1]+x[1]][z]("\141\154\145\162t('"+(v="+--------------------+")+"\\\156|\114\145\157\156\141\162\144\157 \104\151\103\141\160\162\151\157|\\\156"+v+"')")()

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


text:
Solve a reverse arrow maze
This is an "arrow maze":
  v      <
>     v
      >  ^
>         v
^ <       *

The * marks the spot where you will finish. Your goal is to find where the maze starts (hence, reverse maze). In this case, it's the first > on the second line.
  v------<
S-+---v  |
  |   >--^
>-+-------v
^ <       *

Note that all arrows must be used. Also note that you can assume the lines will be padded with spaces to equal length.
Your program must input the maze in any reasonable way (stdin, from a file, message box, etc.), however the maze must be completely intact. For example, you can't input the lines separated by commas; the input must be exactly the maze.
You must output the start of the maze in any reasonable way. For example, you could

output the coordinates of the start
output the entire maze with the start arrow replaced with an S
output the entire maze with all arrows except the start arrow removed (whitespace intact!)
etc.

As long as you can tell by your output which arrow is the start arrow, then it's okay. For example, an output of
"0"
"2"

is alright, regardless of the newlines and quotes, because you can still tell where the start was.
This is code-golf, so the shortest code in bytes will win.

Is it reasonable to assume that each arrow has only one other arrow pointing to it? There isn't going to be an instance where there could be multiple starting points is there?

Is "start of the maze" an arrow from which each other arrow is visited once? In other words danny's question + assumption there are no loops.

@Danny Yes. All arrows must be used, therefore it's only possible to have one store pointing at each other store (except the start). However, an arrow may "point through" an arrow to another one, such as > v ^.

@shiona Yes, correct.

"you can't input the lines separated by commas; the input must be exactly the maze." This seems like an unnecessary restriction, since "exactly the maze" is already de facto delimited by newlines between the rows. Why prioritize one delimiter over another?

Also, is there an upper bound on maze size?  e.g. 8 characters square? 16?

@Jonathan Because I wanted to eliminate any "clever" input methods, so that all the work is done in the program. There is no upper bound on maze size (although maybe I could set 128x128 as a reasonable value).

@Doorknob That's reasonable, since one could theoretically encode an entire compressed solution in the "delimiters". However, I do suspect that the restriction introduces a certain linguistic bias against certain languages. What if the rule were "Input rows may be delimited by any one character of your choice. All rows must be delimited by the same character."? I think the upper bound is useful because it establishes a domain within which your program must work.

For this question, is a matrix or an array a legitimate input for the maze?

Howard has drawn my attention to 'an arrow may "point through" an arrow to another one'. It's not at all clear to me what this means. Please edit the question to include the full spec and full test cases.

@Peter That just means that, for example, in >v^ the > is pointing to the v, not the ^. I'll edit more stuff in when I get back home to a computer today.

You sample input has all lines padded to the same length with trailing spaces. May I assume that that will always be the case?

@IlmariKaronen Yes, you may.

GolfScript, 55 bytes
:&,,{&=42>},.{.&="><^v"?[1-1&n?~.~)]=:d;{d+.&=32=}do}%-

Online demo
Assumes that all input lines are padded with spaces to the same length and separated by newlines.  Outputs the byte offset of the starting arrow from the start of the input string (e.g. 12 for the example maze in the challenge).
Specifically, this program finds the byte offsets of all arrows that have no other arrow pointing to them (assuming that all arrows do point to an arrow or a goal; strange behavior may occur if this is not true).  By default, if there are several such arrows (which, per spec, should not be possible in valid input), their offsets will simply be concatenated in the output.  If you want, you can append n* to the program to have them separated by newlines instead.
De-golfed version with comments:
:&                     # save a copy of the input string in the variable "&"
,, { &= 42> },         # make a list of the byte offsets of all arrows
.                      # duplicate the list and apply the following loop to it:
{
  .                    # make a copy of the original offset...
  &=                   # ...and get the corresponding character in the input
  "><^v" ?             # map the arrow character to integers 0 to 3, and...
  [ 1 -1 &n?~ .~) ]=   # ...map these to +1, -1, -len-1 or +len+1, where len is the...
  :d;                  # ...length of the first input line, and save result as "d"
  { d+ . &= 32= } do   # add d to the byte offset until another non-space is found
} %
-                      # subtract the resulting list of target offsets from the
                       # original list of arrow offsets; this should leave exactly
                       # one offset, which is left on the stack for output

You can save 3 chars if you inline w.

@Howard: Huh, so I can.  Thanks!  Had to rename z to & to avoid needing an extra space, though.  OTOH, ?~.~) makes a pretty nice smiley. :-)

GolfScript (101 100 bytes)
n/:g,,{:&g=:r,,{&1$r='^v<>*'?70429 3base 2/=++}/}%{,4=},.{2<}%:&\{2/~\{[~2$~@+(@@+(\]&1$?)!}do\;}%^`

Output is in the form [[x y]] where the co-ordinates are both 0-based.
Online demo
Processing is in two phases: the first phase turns the maze into an array of [x y dx dy] tuples; the second phase maps each arrow / asterisk to the arrow / asterisk it points to. (Asterisks are considered to point to themselves). By the definition of the problem, there is exactly one arrow which isn't in the result of this map, and that is the solution.

I was just pasting my answer while you posted this. We had the same idea, but you managed to golf it successfully. Nice one!

@PeterTaylor I can't see that it handles the point through case correctly which is mentioned in the comments.

@Howard, I have no idea what that case is. Will ask for clarification.

Would you kindly post an example of your input and output?

@DavidCarraher, see the online demo. ;'STUFF' simulates supplying STUFF via stdin.

Mathematica 491 323
Ungolfed with comments
The procedure begins from the finish ("*"), finds the arrow that points to it, and so forth until reaching the start.
The function, f[maze].
(* positions of the arrowheads *)
aHeads[a_]:=Position[m,#]&/@{"^","v",">","<"}

(* position of the final labyrinth exit*)
final[a_]:=Position[a,"*"][[1]];

(* find arrowheads that point to the current location at {r,c} *)
aboveMe[{r_,c_},a_]:=Cases[aHeads[a][[2]],{r1_,c}/;r1<r]
belowMe[{r_,c_},a_]:=Cases[aHeads[a][[1]],{r1_,c}/;r1>r]
rightOfMe[{r_,c_},a_]:=Cases[aHeads[a][[4]],{r,c1_}/;c1>c]
leftOfMe[{r_,c_},a_]:=Cases[aHeads[a][[3]],{r,c1_}/;c1<c]

(*find the precursor arrowhead*)
precursor[{loc_,a_,list_:{}}]:=

(* end the search when the precursor has already been traversed or when there is no precursor *)
Which[MemberQ[list,loc],list,
loc=={},list,True,

(* otherwise find the next precursor *)

precursor[{Flatten[{aboveMe[loc,a],belowMe[loc,a],rightOfMe[loc,a],leftOfMe[loc,a]},2],a,
    Prepend[list,loc]}]]
(* return the path through the maze from start to finish *)
f[maze_]:= precursor[{final[maze[[1]]],maze[[1]]}]

Golfed
f@z_:=Module[{p,h,m=z[[1]]},h@a_:=Position[a,#]&/@{"^","v",">","<","*"};
  p[{v_,a_,j_:{}}]:=Module[{r,c,x=Cases},{r,c}=v;
  Which[MemberQ[j,v],j,v=={},j,True,
  p[{Flatten[{x[h[a][[2]],{r1_,c}/;r1<r],x[h[a][[1]],{r1_,c}/;r1>r],
  x[h[a][[4]],{r,c1_}/;c1>c],x[h[a][[3]],{r,c1_}/;c1<c]},2],a,Prepend[j,v]}]]];
  p[{Position[m,"*"][[1]],m}]]

Example
The maze.  Each ordered pair contains the row and column of a cell.
E.g. {2, 3} denotes the cell at row 2, column 3.
maze=Grid[Normal@ SparseArray[{{5, 5} -> "*",{1, 2} -> "v", {1, 5} -> "<",{2, 1} -> ">",
   {2, 3} -> "v",{3, 3} -> ">", {3, 5} -> "^",{4, 1} -> ">", {4, 5} -> "v",{5, 1} -> "^",
   {5, 2} -> "<",{_, _} -> " "}]]

Input
f[maze]

Output: The path from start to finish.

{{2, 1}, {2, 3}, {3, 3}, {3, 5}, {1, 5}, {1, 2}, {5, 2}, {5, 1}, {4,
    1}, {4, 5}, {5, 5}}

Your input format is wrong - "the input must be exactly the maze".

The input is now the maze itself.

I haven't followed the code, but the way you solved the "the input is now the maze" thing is hilarious! +1 ...the number of believers in "STDIN is universal" is astounding.

I'm glad you appreciated the solution to the input problem.

I think I found a good way to solve this, but I happened to suck at golfing it. I guess this could be WAY shorter, so I'm going to explain my idea so others can use it if they find it good.
If every arrow must be used, then all the arrows will be pointed by another arrow, except one, that is our solution.
This means we don't actually have to play the maze backwards, but, starting from the upper-left one, we just need to check the nearest pointable arrow for each one. This is a real painsaver for larger mazes (since you don't have to check all four directions, but just one).
Here's my solution:
PHP, 622 bytes
$h=fopen("a.txt","r");$b=0;while(($z=fgets($h))!==false){$l[$b]=str_split($z,1);$b++;}$v=array("^","<","v",">");$s=array();for($i=0;$i<count($l);$i++){for($j=0;$j<count($l[0]);$j++){if(in_array($l[$i][$j],$v)){switch($l[$i][$j]){case"^":$c=$i-1;while($l[$c][$j]==" ")$c--;$s[]=$c.",".$j;break;case"v":$c=$i+1;while($l[$c][$j]==" ")$c++;$s[]=$c.",".$j;break;case"<":$c=$j-1;while($l[$i][$c]==" ")$c--;$s[]=$i.",".$c;break;case">":$c=$j+1;while($l[$i][$c]==" ")$c++;$s[]=$i.",".$c;break;}}}}for($i=0;$i<count($l);$i++){for($j=0;$j<count($l[0]);$j++){if(in_array($l[$i][$j],$v)){if(!in_array($i.",".$j,$s)){echo$i.",".$j;}}}}

Ungolfed:
$h=fopen("a.txt","r");
$b=0;
while(($z=fgets($h))!==false) {
    $l[$b]=str_split($z,1);
    $b++;
}
//Input ends here
$v = array("^","<","v",">");
$s = array();
//Here i check every arrow, and save every pointed one in $s
for($i=0;$i<count($l);$i++){
    for($j=0;$j<count($l[0]);$j++){
        if(in_array($l[$i][$j],$v)){
            switch($l[$i][$j]) {
                case "^":
                    $c=$i-1;
                    while ($l[$c][$j]==" ")
                        $c--;
                    $s[]=$c.",".$j;
                    break;
                case "v":
                    $c=$i+1;
                    while ($l[$c][$j]==" ")
                        $c++;
                    $s[]=$c.",".$j;
                    break;
                case "<":
                    $c=$j-1;
                    while ($l[$i][$c]==" ")
                        $c--;
                    $s[]=$i.",".$c;
                    break;
                case">":
                    $c=$j+1;
                    while ($l[$i][$c]==" ")
                        $c++;
                    $s[]=$i.",".$c;
                    break;
            }
        }
    }
}
//I check if the arrow is in $s. If not, we have a solution.
for($i=0;$i<count($l);$i++){
    for($j=0;$j<count($l[0]);$j++){
        if (in_array($l[$i][$j],$v)){
            if (!in_array($i.",".$j,$s)){
                echo$i.",".$j;
            }
        }
    }
}

PHP - 492 bytes
$r=split("\n",$m);$h=count($r);foreach($r as &$k)$k=str_split($k);$l=count($r[0]);$e=strpos($m,"*")+1-$h;$a=$x=$e%$l;$b=$y=floor(($e-$x)/$l);do{$c=0;for(;--$a>=0;){if($r[$b][$a]==">"){$x=$a;$c++;}if($r[$b][$a]!=" ")break;}$a=$x;for(;--$b>=0;){if($r[$b][$a]=="v"){$y=$b;$c++;}if($r[$b][$a]!=" ")break;}$b=$y;for(;++$a<$l;){if($r[$b][$a]=="<"){$x=$a;$c++;}if($r[$b][$a]!=" ")break;}$a=$x;for(;++$b<$h;){if($r[$b][$a]=="^"){$y=$b;$c++;}if($r[$b][$a]!=" ")break;}$b=$y;}while($c>0);echo "$x-$y";

This solution supposes that the map can be found in local variable $m. The shortest method I have for passing that is via $_GET: $m=$_GET['m']; at 14 bytes. An ungolfed version with map in variable is provided below for clarity of reading.
$m=<<<EOT
  v      <
>     v
      >  ^
>         v
^ <       *
EOT;

$r=split("\n",$m);
$h=count($r);
foreach($r as &$k)
    $k=str_split($k);
$l=count($r[0]);

$e=strpos($m,"*")+1-$h;

$a=$x=$e%$l;
$b=$y=floor(($e-$x)/$l);
do{
$c=0;
for(;--$a>=0;)
    {
        if($r[$b][$a]==">"){$x=$a;$c++;}
        if($r[$b][$a]!=" ")break;
    }
$a=$x;
for(;--$b>=0;)
    {
        if($r[$b][$a]=="v")
            {
                $y=$b;
                $c++;
            }
        if($r[$b][$a]!=" ")break;

    }
$b=$y;
for(;++$a<$l;)
    {
        if($r[$b][$a]=="<")
            {
                $x=$a;
                $c++;
            }
        if($r[$b][$a]!=" ")break;
    }
$a=$x;
for(;++$b<$h;)
    {
        if($r[$b][$a]=="^")
            {
                $y=$b;
                $c++;
            }
        if($r[$b][$a]!=" ")break;
    }
$b=$y;
}while($c>0);
echo "$x-$y";

K, 281 277 258
{{$[&/x in*:'{{~"*"=x 1}{(s;k . s;k;s:*1_w@&(k ./:w:{{x@&x in y}[(*:'{(x[1]@x 0;x 1)}\[x;(z;y)]);i]}[(h!b,b,a,a:#k:x 2)m;(h!(0 1+;0 -1+;1 0+;-1 0+))m:x 1;x 0])in"*",h:"><v^")}\(x;y;z;x)}[*x;y .*x;y];*x;.z.s[1_x]y]}[i@&~(x ./:i::,/(!#x),/:\:!b::#*x)in" *";x]}

Here's an earlier, ungolfed version
solve:{[x]
    //j - indices of all possible starting points
    //i - every index
    j::i@&~(x ./:i::,/(!a:#x),/:\:!b:#*x) in " *";

    h::">v<^";

    //d - dictionary mapping each directional character to
    //    increment/decerement it needs to apply to the x/y axis
    d::h!((::;1+);(1+;::);(::;-1+);(-1+;::));

    //e - dictionary mapping each directional character to
    //    the maximum number of moves it should make in a
    //    given direction
    e::h!b,a,b,a;

    //f - function to produce the indices of each point that is
    //    passed once we move in a certain direction from a
    //    certain index
    f::{{x@&x in y}[(last'{(x[0];x[0]@'x 1)}\[x;(y;z)]);i]};

    //g - function that, given a starting and a direction,
    //    moves in that direction until hitting another directional
    //    character. It then moves in the new direction etc. until
    //    it reaches the end point -- *
    g::{[x;y;z]
        {[x]
            q:x 0;m:x 1; k:x 2;
            w:f[e m;d m;q];
            s:*1_w@&(k ./:w)in h,"*";
            m:k . s;
            (s;m;k;s)}\[{~"*"=x 1};(x;y;z;x)]};

    // recursive function that starts at the first possible starting point
    // and plots its way to the end. If all other potential starting points
    // have been touched in this path, then this is the correct starting point.
    // else, recursively call the function with the next possible starting point
    :{$[min "b"$j in last'g[*x;y . *x;y];*x;.z.s[1_x;y]]}[j;x]
  }

Returns the starting point as x y with 0 based indices.
k)maze
"  v      < "
">     v    "
"      >  ^ "
">         v"
"^ <       *"
k)solve maze
1 0

Python 422
with open("m.txt","r") as f:m=f.read().split("\n")
p=[(v.find("*"),p) for p,v in enumerate(m) if "*" in v][0]
g=[]
def f(a):
    x,y=b,c=a
    for p,i in enumerate((lambda x:[l[x] for l in m])(x)):
        if i in "^>v<" and((p<y and i=="v")or(p>y and i=="^")):return b,p
    for p,i in enumerate(m[y]):
        if i in "^>v<" and((p<x and i==">")or(p>x and i=="<")):return p,c
while True:
    z=f(p)
    if z in g:break
    else:g.append(z);p=z
print p

The input is in a file called m.txt. The output is (x, y) but if you change the last print statement to print g, the output will be a list like [(x, y), (x, y), ...] with all the steps to get from the end to the start.


text:
Brainf*ckish directions
Your task – should you choose to accept it – is to build a program that parses and evaluates a string (from left to right and of arbitrary length) of tokens that give directions – either left or right. Here are the four possible tokens and their meanings:
>  go right one single step
<  go left one single step
-> go right the total amount of single steps that you've gone right, plus one,
   before you previously encountered this token and reset this counter to zero
<- go left the total amount of single steps that you've gone left, plus one,
   before you previously encountered this token and reset this counter to zero

There's a catch though – the tokens of directions your program should be able to parse will be presented in this form:
<<->-><<->->>->>->

... in other words, they are concatenated, and it is your program's task to figure out the correct precedence of directions and amount of steps to take (by looking ahead). The order of precedence is as follows (from highest to lowest precedence):

->
<-
>
<

If you encounter <- when no steps to the left had previously been made since either the start or since the last reset, take one single step to the left. Same rule applies to ->, but then for going to the right.
Your program should start at 0 and its result should be a signed integer representing the final end position.
You may expect the input to always be valid (so, nothing like <--->>--<, for instance).
Example input:
><->><-<-><-<>>->

Steps in this example:
 step | token | amount | end position
------+-------+--------+--------------
   1. |   >   |     +1 |           1
   2. |   <   |     -1 |           0
   3. |  ->   |     +2 |           2
   4. |   >   |     +1 |           3
   5. |   <-  |     -2 |           1
   6. |   <   |     -1 |           0
   7. |  ->   |     +2 |           2
   8. |   <-  |     -2 |           0
   9. |   <   |     -1 |          -1
  10. |   >   |     +1 |           0
  11. |   >   |     +1 |           1
  12. |  ->   |     +3 |           4

For clarification: the output of the program should only be the final end position as a signed integer. The table above is just there to illustrate the steps my example took. No need to output such a table, table row, or even just the steps' end positions. Only the final end position, as a signed integer, is required.
Shortest code, after one week, wins.

If I understand the precedence rules correctly, the only time you could invoke <- is if it is immediately followed by a < or a ->.  There's no way in this language to represent the sequence <- then > - which would be go left the total amount of single steps that you've gone left, plus one, then go right one single step.  Is this correct and by design?

@AdamDavis You are right. That was a bit inattentive of me, unfortunately.

GolfScript, 46 chars
'->'/')'*.'<-'-.')'/);+,\'>)'-.'<-'/);\'-'-+,-

This is one of the most linear GolfScript programs I've ever written — there's not a single loop, conditional or variable assignment in it.  Everything is done using string manipulation:

First, I replace every occurrence of -> by ).  Since the input is guaranteed to be valid, this ensures that any remaining occurrence of - must be a part of <-.
Next, I make two copies of the string.  From the first copy, I remove the characters < and -, leaving only > and ).  I then duplicate the result, remove all the )s and every > following the last ) from the second copy, concatenate them and count the characters.  Thus, in effect, I'm counting:

+1 for each ),
+1 for each > after the last ), and
+2 for each > before the last ).

Next, I do the same for the other copy, except this time counting < and <- instead of > and ), and removing the -s before the final character count.  Thus, I count:

+1 for each <-,
+1 for each < after the last <-, and
+2 for each < before the last <-.

Finally,  I subtract the second count from the first one, and output the result.

Python 2.7 - 154 147 134 128 bytes
l=r=p=0
exec"exec raw_input('%s->','p+=r+1;r=0%s<-','p-=l+1;l=0%s>','r+=1;p+=1%s<','l+=1;p-=1;')"%((";').replace('",)*4)
print p

Serious changes have been made to the way this program works. I've removed the old explanation, which can still be found in this answer's edit history.
This one's gross.
It works pretty much the same way as other answers for this question, replacing the characters in the input with valid statements in that language and executing them. There's one major difference, though: replace is a long word. Screw that.
@ProgrammerDan in chat came up with the idea of using a tuple with the string ;').replace(' in it 4 times, to use the pre-str.format() method of formatting text. Four instances of %s are in the string on the second line, each one taking its value from the associated element of the tuple at the end. Since they're all the same, each %s is replaced with ;').replace('. When you perform the operations, you get this string:
exec raw_input(';').replace('->','p+=r+1;r=0;').replace('<-','p-=l+1;l=0;').replace('>','r+=1;p+=1;').replace('<','l+=1;p-=1;')

This is now valid python code that can be executed with exec. That's right, baby: Nested execs let me use string operations on code that needs to perform string operations on code. Someone please kill me.
The rest of it is pretty straightforward: Each command is replaced with code that keeps track of three variables: The current position, the number of rights since the last ->, and the same for lefts and <-. The whole thing is run and the position is printed.
You'll notice that I do raw_input(';'), using ';' as a prompt, rather than raw_input() which has no prompt. This saves characters in an unintuitive way: If I did raw_input(), I'd have to have the tuple filled with ).replace(', and every instance of %s would have ';\'' before it except the first one. Having a prompt creates more redundancy so I can save more characters overall.

"list.index() returns -1 when it fails to find the character".. erm no. It raises an IndexError. You may have confused it with str.find. In fact you could replace [list('><rl').index(c)] with ['><rl'.find(c)].

...Huh, I looked it up in the docs and could have sworn it said it returned -1. It was specifically the page for lists, so I have no idea what I read. Anyway, thanks for the help, I'll edit that into the answer.

Perl, 134 131 ... 99 95 bytes
sub f{$p+=$d;$&=~/-/?($p+=$s,$s=0):($s+=$d)}$_=<>;$d=1;s/-?>/f/eg;$s=0;$d=-1;s/<-?/f/eg;print$p

Takes input as a single line on stdin, eg:
ski@anito:~$ perl -le 'sub f{$p+=$d;$&=~/-/?($p+=$s,$s=0):($s+=$d)}$_=<>;$d=1;s/-?>/f/eg;$s=0;$d=-1;s/<-?/f/eg;print$p'
><->><-<-><-<>>->
4

or:
ski@anito:~$ echo "><->><-<-><-<>>->" | perl -le 'sub f{$p+=$d;$&=~/-/?($p+=$s,$s=0):($s+=$d)}$_=<>;$d=1;s/-?>/f/eg;$s=0;$d=-1;s/<-?/f/eg;print$p'
4

I split the instructions into the "right" operators (">" and "->") and "left" operators ("<" and "<-"). The advantages of this are that it's easier to exploit the parallelism between left and right operators, and we don't have to do anything fancy to tokenize the string. Each "direction" is dealt with as a substitution operation where we adjust the running total by the number of steps taken in that direction, ignoring the reverse direction which is taken care of by the other substitution operation. Here's a less-golfed ancestor of this code as a sort of documentation:
sub f {
  $dir=shift;
  if($1 =~ /-/) {
    $pos+=$side+$dir;
    $side=0;
  } else {
    $pos+=$dir;
    $side+=$dir;
  }
}

$_=<>;

s/(-?>)/f(1)/eg;
$side=0;
s/(<-?)/f(-1)/eg;

print $pos

In a prior iteration of this code, the substitutions were all done in one pass. This had the advantage of keeping a direct mapping between $p/$pos and the position that would be returned at any given point in time, but took more bytes of code.
If you want to use() 5.10.0, you can s/print/say/ to shave another 2 characters off the count, but that's not really my style.

Perl, 88 77 bytes
$_=<>;print s/->/F/g+2*s/>(?=.*F)//g+s/>//g-(s/<-/B/g+2*s/<(?=.*B)//g+s/<//g)

Input is expected via STDIN, for example:
echo '><->><-<-><-<>>->'|perl -e '$_=<>;print s/->/F/g+2*s/>(?=.*F)//g+s/>//g-(s/<-/B/g+2*s/<(?=.*B)//g+s/<//g)'
4

Update
There is no need to convert the string to a summation, because s// is already counting. :-)
First version
$_=<>;s/->/+1/g;s/>(?=.*1)/+2/g;s/>/+1/g;s/<-/-1/g;s/<(?=.*-)/-2/g;s/</-1/g;print eval

Input is expected via STDIN, example:
echo '><->><-<-><-<>>->'|perl -e '$_=<>;s/->/+1/g;s/>(?=.*1)/+2/g;s/>/+1/g;s/<-/-1/g;s/<(?=.*-)/-2/g;s/</-1/g;print eval'
4

Explanation:
The idea is to convert the direction string into a summation so that the result is output by a simple print eval.
> before any -> takes two steps, one at once and the other at the next ->. It does not matter, which of the -> while it follows at least one of them. The internal counter is reset after the next ->, thus > does not cause further steps, the maximum is two steps. Then -> adds one step for itself and so do any remaining > after the last ->.
The same holds for the backwards direction with negative instead of positive step counts.
E.g.: ><->><-<-><-<>>->
s/->/+1/: Start with forward direction, because -> has highest precedence.
E.g.: ><+1><-<+1<-<>>+1
s/>(?=.*1)/+2/g: The look-ahead pattern assures that only the > before any -> are converted.
E.g.: +2<+1+2<-<+1<-<+2+2+1
s/>/+1/g: Now the remaining > are covered.
E.g.: +2<+1+2<-<+1<-<+2+2+1
s/<-/-1/g: Analog the backwards direction.
E.g.: +2<+1+2-1<+1-1<+2+2+1
s/<(?=.*-)/-2/g: In the look-ahead pattern the full -1 of the former <- is not needed, because there are no - of the direction symbols left.
E.g.: +2-2+1+2-1-2+1-1<+2+2+1
s/</-1/g: The remaining < after the last <- are converted.
E.g.: +2-2+1+2-1-2+1-1-1+2+2+1
print eval: Calculate and output the result.
E.g.: 4

Good one. I was kicking around this concept last night but didn't have a chance to try implementing it until today. Good thing I checked the post and saw you already had =)

@skibrianski: Thanks for fixing the copy&paste error.

Can be golfed a bit more: 65 bytes
Or, without using -p: 74 bytes
I changed your s/>//g to y/>// to save a byte in each case which also allowed for removal of the parens in the expression.

Ruby, 141 bytes
l=1;r=1;o=0
gets.gsub('->',?R).gsub('<-',?L).chars{|c|case c
when'<';o-=1;l+=1
when'>';o+=1;r+=1
when'L';o-=l;l=1
when'R';o+=r;r=1
end}
$><<o

Ungolfed:
parsed = gets.gsub('->', 'R')
             .gsub('<-', 'L')
countL = 1
countR = 1
result = 0
parsed.each_char do |c|
    case c
    when '<'
        result -= 1
        countL += 1
    when '>'
        result += 1
        countR += 1
    when 'L'
        result -= countL
        countL = 1
    when 'R'
        result += countR
        countR = 1
    end
end
puts result

A couple of quick wins: l=1;r=1 can be l=r=1 and $><<o can be p o.  I think you could shave a lot by replacing that case statement with something less bulky, maybe something along the lines of eval %w(o-=1;l+=1 o+=1;r+=1 o-=l;l=1 o+=r;r=1)['<>LR'.index c]

In fact with the eval approach you can pull out some prefixes/suffixes to save even more.  This is 98 chars: l=r=1;o=0;gets.gsub('->',??).scan(/<-|./){eval"o+=#{%w[-1;l+ -l;l 1;r+ r;r][$&[-1].ord%4]}=1"};p o, you could go down to 94 using ruby -p

D - 243
Golfed:
import std.regex,std.stdio;void main(string[]a){int s,c,v;auto t=a[1].matchAll("->|<-(?!>)|>|<".regex);foreach(m;t){auto r=m.hit;if(r=="->"){s+=c+1;c=0;}else if(r=="<-"){s-=v+1;v=0;}else if(r==">"){++s;++c;}else if(r=="<"){--s;++v;}}s.write;}}

Un-golfed:
import std.regex, std.stdio;

void main( string[] a )
{
    int s, c, v;
    auto t = a[1].matchAll( "->|<-(?!>)|>|<".regex );

    foreach( m; t )
    {
        auto r = m.hit;

        if( r == "->" )
        {
            s += c + 1;
            c = 0;
        }
        else if( r == "<-" )
        {
            s -= v + 1;
            v = 0;
        }
        else if( r == ">" )
        {
            ++s;
            ++c;
        }
        else if( r == "<" )
        {
            --s;
            ++v;
        }
    }

    s.write;
}

The required output was originally in the question. I've highlighted it now, and added further clarification.

Right, I've edited my answer to output the result now.

Javascript (116, 122, 130)
116:
for(l=r=p=i=0;c='<>-0'.indexOf(a.replace(/->/g,0)[i++])+1;p--)c-4?c-3?c-2?l++:(r++,p+=2):(p-=l-2,l=0):(p+=r+2,r=0);p

122:
for(l=r=p=i=0,a=a.replace(/->/g,0);c='<>-0'.indexOf(a[i])+1;i++,p--)c-4?c-3?c-2?l++:(r++,p+=2):(p-=l-2,l=0):(p+=r+2,r=0);p

130:
for(l=r=p=i=0;c='<>-'.indexOf(a[i])+1;i++,p--)c-3?c-1?(r++,p+=2):a[i+1]=='-'?a[i+2]=='>'?l++:(p-=l,l=0,i++):l++:(p+=r+2,r=0,i++);p

JavaScript, 136
z=0;l=r=1;c=["--z;++l;",/</g,"++z;++r;",/>/g,"z-=l;l=1;",/<-/g,"z+=r;r=1;",/->/g];for(a=8;a--;s=s.replace(c[a--],c[a]));eval(s);alert(z)

Unminified:
s="><->><-<-><-<>>->";
z=0;
l=r=1;
c=[
    "--z;++l;", /</g,
    "++z;++r;", />/g,
    "z-=l;l=1;", /<-/g,
    "z+=r;r=1;", /->/g
];
for(a=8;a--;s=s.replace(c[a--],c[a]));
eval(s);
alert(z) // Output (4)

How it works
Given a string input as s like so:
s="><->><-<-><-<>>->";

It uses a Regex to replace each command with a set of instructions which modify z (the end position), l (stored left movements) and r stored right movements. Each Regex is performed in order of precedence.
For the input above this converts s to:
"++z;++r;--z;++l;z+=r;r=1;++z;++r;z-=l;l=1;--z;++l;z+=r;r=1;z-=l;l=1;--z;++l;++z;++r;++z;++r;z+=r;r=1;"

Pretty, ain't it.
Finally we eval(s) to perform the instructions and alert z which contains the end position.

C, 148 141 140
140:
r,l,o;main(char *x,char **v){for(x=v[1];*x;x++)(*x^45)?(*x^60)?(r++,o++):(*(x+1)==45)?(x++,o-=l+2,l=0):(o--,l++):(o+=r+1,r=0,x++);return o;}

141:
r,l,o;main(char *x,char **v){for(x=v[1];*x;x++)(*x^45)?(*x^60)?(r++,o++):(*(x+1)==45)?(x++,o=o-l-2,l=0):(o--,l++):(o+=r+1,r=0,x++);return o;}

148:
r,l,o;main(char *x,char **v){for(x=v[1];*x;x++){if(*x^45){if(*x^60)r++,o++;else{o--,l++;if(*(x+1)==45)x++,o-=l,l=0;}}else o+=r+1,r=0,x++;}return o;}

With whitespace:
r,l,o;
main(char *x,char **v)
{
    for(x=v[1];*x;x++)
    (*x^45) ?
        (*x^60) ?
            (r++,o++)
            :
            (*(x+1)==45) ?
                (x++,o-=l+2,l=0)
            :(o--,l++)
        :(o+=r+1,r=0,x++);
    return o;
}

Probably a lot more room to golf this.  I mostly gave up on trying to manipulate 4 variables in ternaries that captured lvalues (it kept coming out longer and getting later), but not a bad first pass. Pretty straight-forward array pass. Takes input as a command-line argument, outputs via the return value.
You'll need the -std=c99 flag to compile it with gcc.
EDIT:
Yep, it's late - missed some obvious stuff.

You can remove two spaces in the argument list of main: main(char*x,char**v). Then you have 138 instead of 140.

There is a bug: >><- gives 0 instead of 1 or ><-> gives 0 instead of 2.

You can save 4 bytes if your remove spaces between char and *, and replace (*(x+1)==45)?(x++,o-=l+2,l=0):(o--,l++) with (*++x==45)?(o-=l+2,l=0):(x--,o--,l++).

PHP, 284 282
No regex.
$i=fgets(STDIN);$c=$a=0;$s=str_split($i);while($c<count($s)){switch($s[$c]){case"<":if($s[$c+1]=="-"){if($s[$c+2]==">"){$c+=3;$a+=$rr;$rr=0;$ll++;}else{$c+=2;$a+=-($ll+1);$ll=0;}}else{$c++;$a--;$ll++;}break;case">":$c++;$a++;$rr++;break;case"-":$c+=2;$a+=$rr+1;$rr=0;break;}}echo$a;

Ungolfed:
$i=fgets(STDIN);
$c=$a=0;
$s=str_split($i);
while($c<count($s)){
    switch($s[$c]){
    case "<":
        if($s[$c+1]=="-"){
            if($s[$c+2]==">"){
                $c+=3;$a+=$rr;$rr=0;$ll++;
            }
            else{
                $c+=2;$a+=-($ll+1);$ll=0;
            }
        }
        else{
            $c++;$a--;$ll++;
        }
    break;
    case ">":
        $c++;$a++;$rr++;
        break;
    case "-":
        $c+=2;$a+=$rr+1;$rr=0;
        break;
    }
}
echo $a;

You can win 2 chars with str_split($i) (1 is the default for the second argument.) And $i should probably be $c, correct?

First line was wrong (it was $i) :P Fixed it!

JavaScript [217 bytes]
prompt(x=l=r=0,z='replace',f='$1 $2 ')[z](/(>.*?)(->)/g,f)[z](/(<.*?)(<-)/g,f)[z](/(<|>)(<|>)/g,f)[z](/<-?|-?>/g,function(c){c=='>'&&(x++,r++),c=='<'&&(x--,l++),c=='->'&&(x+=++r,r*=0),c=='<-'&&(x-=++l,l*=0)}),alert(x)

Probably it may be shortened a bit more...

Another perl solution, 113 chars
There are already two answers that beat this, it's just for giggles. It uses an approach based on Ilmari's observation about the value of tokens:
$_=<>;chomp;s/->/#/g;s/<-/%/g;s/>(?=.*#)/?/g;s/<(?=.*%)/;/g;s/#/>/g;s/%/</g;$t+=ord for split//;print$t-61*length

Exploded a bit:
$_=<>;
chomp;
s/->/#/g;
s/<-/%/g;
s/>(?=.*#)/?/g;
s/<(?=.*%)/;/g;
s/#/>/g;
s/%/</g;
$t+=ord for split//;
print$t-61*length