text:
Your car only turns right!
Introduction
You have the misfortune of being stuck in a runaway car on an obstacle course.  All of the car's features are non-responsive, save for the steering system, which is damaged.  It can drive straight, or it can turn right.  Can the car be guided to safety?
Mechanics
Your car begins in the upper-left corner of an 8x8 map, and is trying to get to safety in the lower-right corner.  The car has an orientation (initially to the right), measured in 90-degree increments.  The car can perform one of two actions:

Drive one square forward, or
Turn 90 degrees clockwise, then drive one square forward

Note that the car is unable to turn sharply enough to perform a 180-degree turn on a single square.
Some of the squares are obstacles.  If the car enters an obstacle square, it crashes.  Everything outside the 8x8 course is assumed to be obstacles, so driving off the course is equivalent to crashing.
The lower-right square is the safe square, which allows the car to escape the obstacle course.  The starting square and safe square are assumed not to be obstacles.
Task
You must write a program or function which takes as its input an 8x8 array (matrix, list of lists, etc.), representing the obstacle course.  The program returns or prints a Boolean, or something similarly truthy.  If it's possible for the car to make it to the safe square without crashing (i.e., if the map is solvable), the output is True, otherwise, it's False.
Scoring
Standard code golf rules - the winner is the code with the fewest bytes.
Bonuses:

If, for a solvable map, your code outputs a valid series of driver inputs which guide the car to the safe square, deduct 10 percentage points from your score.  An example output format might be SRSSR (indicating Straight, Right, Straight, Straight, Right).  This output would replace the standard True output.
If, for an unsolvable map, your code's output distinguishes between situations where a crash is unavoidable, and situations where it's possible to drive around the obstacle course forever, deduct 10 percentage points from your score.  An example output might be Crash if a crash is unavoidable, or Stuck if the car is stuck in the obstacle course forever.  These outputs would replace the standard False output for an unsolvable map.

Example
If the program is given an 8x8 array such as this:
[[0, 0, 0, 0, 0, 1, 0, 0],
 [0, 0, 0, 0, 0, 0, 1, 0],
 [1, 1, 0, 0, 0, 0, 0, 0],
 [0, 1, 0, 1, 0, 0, 0, 0],
 [0, 0, 1, 1, 0, 0, 0, 0],
 [0, 0, 0, 0, 1, 0, 1, 0],
 [0, 0, 0, 0, 0, 0, 1, 0],
 [0, 1, 1, 0, 0, 0, 1, 0]]

It would be interpreted as a map like this, with black squares indicating obstacles:

And a possible solution might be:

Since a solution exists, the program should return/print True for this map.  The sequence of moves shown here is SSSSRSRRRSRSSRRRSSRSSS.

Could you also provide example inputs for for the Crash and Stuck cases?

I wrote some incredibly simple test cases for Crash and Stuck. They're here because of how long they are. Row 2 filled, everything else empty -> Crash. Row 7 filled, everything else empty -> Stuck

I'm confused about percentage points (as opposed to percentages). Getting either bonus multiplies your score by 0.9. Does getting both multiply it by 0.8 or 0.9^2?

Another question: Can we exit with an exception or do we have to go out gracefully?

I was attempting to imply that the percentage points are deducted from the actual number of code bytes, so claiming both bonuses results in multiplication by 0.8.  Sorry if it wasn't clear.

Exiting with an exception is OK, as long as that exception alerts the viewer about the (non)existence of a solution.  No ambiguity allowed, basically.

For Stuck or Crash, could we return something like 'S' or 'C'? Or does it have to be the whole word? This doesn't seem ambiguous to me.

Sure, S and C are fine.  My outputs were only suggestions.

"Two wrongs don't make a right, but three lefts do." - Dad.

I actually considered using 'three lefts' in the title.

"Your car can make only zero or three lefts!"

@feersum "Your car is pretty shitty!"

@flawr But it's very fast and that's what's important!

Is it ok if the function takes a named argument as the board, instead of just the argument? i.e. f(b=board)?

Sure, the input formats is not particularly important.

This question reminded me of an odd route I took to a previous work site. The route that I took was literally exactly 7 lefts from home to work, and vice versa (7 rights from work to home). No joke. I took that route for a while before I realized it.

That's a funny story.  Hopefully the route didn't cross over itself!

JavaScript (ES6) - 122 124 148 162 172 178 187 190 193 208 bytes
Many thanks to Optimizer and DocMax for helpful suggestions on how to improve this code:
F=a=>(D=(x,y,d)=>!D[i=[x,y,d]]&&(D[i]=1,x-=~d%2,y-=~-~d%2,x*y==49||!((x|y)&8||a[y][x])&&(D(x,y,d)||D(x,y,~-d%4))),D(-1,0))

Returns true (truthy) for solvable and false (falsy) for unsolvable.
Works only in Firefox as of today becasue of JavaScript 1.7 features.
Test Board

This is 193 bytes : D=(x,y,d,t,a)=>!t[i=x+y*8+d*64]&&(t[i]=1,x+=d==0?1:d==2?-1:0,y+=d==1?1:d==3?-1:0,x==7&&y==7||!((x|y)&~7||a[y][x])&&G(x,y,d,t,a));G=(x,y,d,t,a)=>D(x,y,d,t,a)||D(x,y,d+1&3,t,a);F=a=>G(0,0,0,[],a) .

@Optimizer: thank you, I updated my answer.

172 : D=d=>!t[i=x+y*8+d/4]&&(t[i]=1,x+=d?d^2?0:-1:1,y+=d^1?d^3?0:-1:1,x==7&&y==7||!((x|y)&~7||b[y][x])&&G(x,y,d));G=(X,Y,d)=>D(d,x=X,y=Y)||D(d+1&3,x=X,y=Y);F=a=>G(0,0,0,b=a,t={}) - Tested.

@Optimizer I'm still getting true for the second test case [[0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]]. That should give false.

That is because since x and y are both globals, you cannot run two testcases before reloading the page...

@Optimizer sorry, your're perfectly right. I was running some test cases with globals like a, b, c, and that would break the code. Feeling ashame now. Thank so much, you're the best!

Is there a bitwise and operator in Javascript? I think you can do x&y==7 instead of x==7&&y==7.

You can save a total of 9 more by replacing x+=d?d^2?0:-1:1 with x+=d&1?0:1-d and y+=d^1?d^3?0:-1:1 with y+=d&1&&2-d.

@FryAmTheEggman well, those are not the same, but thanks, I optimized that part in a different way now :)

@DocMax thanks! I implemented your suggestions in my new version.

Two more things which I think may help (but I'm not entirely sure): Instead of D=d=> and calling D with D(...,x=X,y=Y) it saves two to do D=>(d,x,y) and call it D(...,X,Y). I just don't know if there are side effects.   The other is to replace x+[y]==77 with x*y==49 (yay primes) since I don't think (49,1) or (1,49) are possible.

@DocMax Awesome, thanks! I also replaced the input array with D, any object. Together a few other optimizations I've done, we're at 148 bytes now!!! Wish I could share my points with you guys :)

I really, really like how you've abused D as both the function and the object.

One more for the morning: save one more by replacing my d&1?0:1-d with d-3&&1-d.

Replace G with its definition. Then start at x=-1: F=a=>(D=(x,y,d)=>!D[i=[x,y,d]]&&(D[i]=1,x+=d-3&&1-d,y+=d&1&&2-d,x*y==49||!((x|y)&8||a[y][x])&&(D(x,y,d)||D(x,y,d+1&3))),D(-1,0,0)). And now it fits well inside a tweet at 128 chars.

Thanks so much @DocMax that's really a great job! - I managed to save 4 more bytes switching the direction sign (right = 0, down = -1 ...). Down to 124 bytes now B-)

@RenaeLider Are you sure? I tested it and seems ok to me. Your board has no solution.

Python 2 - 123 125 133 146 148 150 154 160
True on success, False on failure.
def f(h=1,v=0,b=0,x=0,y=0,c=[]):s=x,y,h,v;a=b,x+h,y+v,c+[s];return(s in c)==(x|y)&8==b[y][x]<(x&y>6or f(h,v,*a)|f(-v,h,*a))

You must supply input like f(b=var_containing_board).
Lambda version - 154
Returns 0 (falsy) for failure, True for success.

F=lambda b,x=0,y=0,h=1,v=0,c=[]:0if[x,y,h,v]in c or x|y>7or x|y<0 or b[y][x]else x&y==7or F(b,x+h,y+v,h,v,c+[[x,y,h,v]])or F(b,x+h,y+v,-v,h,c+[[x,y,h,v]])

Thanks to Will and Brandon for making the function shorter than the lambda. Also for adding more horizontal scrolling :D
Thanks to xnor for superior bit-bashing and logic!
Edit note: I am reasonably confident that b[y][x] will never be executed when going out of range. Since we are outside of the board, the history check s in c will be False. Then the boundary check (x|y)&8 will be 8. Then python will not even check the last value of == because the first two are already different.

The functional version can combine the two ifs which both return; as return alone returns None which is falsy, you also don't need to return 0. .just returning the favour ;)

If you flip the checks you can combine both ifs too

Can you combine both return statements?

Python seems to be winning so far!

instead of not(...) you can do (...)-1 :)  And there's a few spaces you can zap between numbers and keywords.

@Will Thanks, I knew there was a better way to do that :D Um, I couldn't find any spaces to remove that don't cause me syntax error. I don't really get why x|y>7or works but x|y<0or doesn't...

You can make an octal literal beginning with 0o.

It gives the wrong answer if you try [0, 1, 0, 1, 0, 0, 0, 1] as the fourth array (as in the OP's example).

@RenaeLider I believe it correctly gets false in that case. I don't see how the car could make it to the end. Could you give me some more info?

You can shorten x|y>7or x|y<0 to (x|y)&-8.

The (x|y)&-8 trick doesn't play well with the (...)-1 for not, but it's still worth it if you revert to not(...). And I think return((s in c)==b[y][x]==0<x|y<8) is even shorter (though I haven't checked that it works)`.

@xnor Thanks for the tips! I had been trying to golf down those statements for quite a while, but I never could get it to be worth losing the -1 for not. I'm going to fiddle with the == thing to see if I can get it to work.

@FryAmTheEggman I think I see why it doesn't work. First, it should be 0<=x|y<8. Also, b[y][x] must not be evaluated with out-of-bounds indices, so it needs to be short-circuited with something like 0<=x|y<8and ....

@xnor I think I got it to work with (x|y)&-8. I just had to change the order of the == so that it would short-circuit itself (I didn't know python did this until just today). You saved me almost enough to get back into the lead :D

@FryAmTheEggman That's clever. I had no idea that chained comparison operators short circuit.

C (GNU-C), 163 bytes * 0.9 = 146.7
#C (GNU-C), 186 bytes * 0.9 = 167.4
My new version uses a signed rather than unsigned integer. Earlier I was afraid of signed right shift, but I realized since the sign bit is the goal square, it doesn't matter what happens after that.
The function takes an array of bits (ones represent blocked squares) in the form of a 64-bit integer. The bits are arranged least to most significant in the same way you would read a book. It returns -1 for a crash, 0 for driving forever, or 1 for escaping to the bottom right corner.
g(long long o) {
    typeof(o) a=0,i=255,r=1,u=0,l=0,d=0,M=~0LLU/i,D;
    for( ;i--;d = D<<8&~o)
        a |= D = d|r,
        r = (r|u)*2&~M&~o,
        u = (u|l)>>8&~o,
        l = ((l|d)&~M)/2&~o;
    return a<0?:-!(d|r|u|l);
}

Test program
f(long long o){typeof(o)a=0,i=255,r=1,u=0,l=0,d=0,M=~0LLU/i,D;for(;i--;d=D<<8&~o)a|=D=d|r,r=(r|u)*2&~M&~o,u=(u|l)>>8&~o,l=((l|d)&~M)/2&~o;return a<0?:-!(d|r|u|l);}
{
    char* s[] = {"Crash", "Stuck", "Escape"};
    #define P(x) puts(s[f(x)+1])
    L ex = 0x4640500C0A034020;
    P(ex);
    L blocked = 0x4040404040404040;
    P(blocked);

    L dead = 0x10002;
    P(dead);

    return 0;
}

Output
Escape
Stuck
Crash

Python array-to-hex converter:
a2b=lambda(A):"0x%X"%sum(A[i/8][i%8]<<i for i in range(64))

Replace memset(&M,~1,8) (15 chars) with M=~(-1ULL/255) (14 chars).

@R.. Nice one! -4 bytes from that.

I like the input format - very cool!

I'm getting 'crash' for P(0x00fefefefefefefe); =( Should be straight shot to upper right, one turn, straight to corner. Same for P(0x00eeeeeeeeeeeeee); (dead end on 4th col). I don't think you need to assign a initially.

@tolos You've got the row/column-major order transposed. To have the top row and right column open, it should be 0x7f7f7f7f7f7f7f00. Also it is necessary to initialize a because later it is only modified by ORing in additional bits, so I can't afford to have an unwanted bit set initially.

Python, 187 213
207 chars, 10% bonus for printing path
b=map(ord," "*9+" ".join("".join("o "[i]for i in j)for j in input())+" "*9)
def r(p,d,s):
 p+=(1,9,-1,-9)[d]
 if b[p]&1<<d:b[p]^=1<<d;return(s+"S")*(p==79)or r(p,d,s+"S")or r(p,(d+1)%4,s+"R")
print r(8,0,"")

On the test input it finds a slightly different path: SSSSRSRSRRSSRSSRRSRSSRSSSSS
The general approach is to first turn the input into a spaces and os.  Spaces have a hex of 20, so all four lower bits are unset.  o has a hex of 6F, so the low four bits are all set.
A border of os is placed around the board so we don't have to worry about bad indices.
As we walk over the board, we use the bits in each tile to see if we are allowed to pass when coming from that side.  In this way, we avoid infinite loops.  Its not enough to have a single boolean per tile, as your exit direction depends on your entry direction, so tiles can be visited twice.
We then do a recursive search for a safe path.

"Your car begins in the upper-left corner of an 8x8 map" - can't you hardcode 9 in place of w=len(b[0])+1, etc?

@FryAmTheEggman thank you, how could I have overlooked that? :D

You can reverse your ternary statement and replace p==79 with p-79. I got a syntax error doing this both ways without a space before the else. I think that trick only works with if.

@FryAmTheEggman I think the depth test has to before the recurse?  I've been playing with a multiplication by boolean instead.

I just found a really neat trick. You probably know that -~x == x+1 but both unary operators have higher precedence than multiplication, division and modulus! So (d+1)%4 could be -~d%4! This also would work with x-1 but just use ~-x instead.

Javascript - 270 - 20% = 216 262 - 20% = 210 bytes
Since there ought to be at least one solution that earns both bonuses (and doesn't lead to a ridiculous stack depth ;)...
Minified:
V=I=>{n=[N=[0,0,0]];v={};v[N]='';O='C';for(S='';n[0];){m=[];n.map(h=>{[x,y,d]=h;D=i=>[1,0,-1,0][d+i&3];p=v[h];for(j=2;j--;){O=v[c=[X=x+D(j),Y=y+D(3-3*j)),d+j&3]]?'K':O;J=X|Y;J<0||J>7||I[Y][X]||v[c]?O:(m.push(c),v[c]=p+'SR'[j])}S=(x&y)>6?p:S});n=m;}return S||O;};

Expanded:
V = I => {
    n = [N=[0,0,0]];
    v = {};
    v[N] = '';
    O = 'C';

    for( S = ''; n[0]; ) {
        m = [];
        n.map( h => {
            [x,y,d] = h;
            D = i => [1,0,-1,0][d+i&3];
            p = v[h];
            for( j = 2; j--; ) {
                O = v[c = [X = x+D(j),Y = y+D(3-3*j),d+j&3]] ? 'K' : O;
                J = X|Y;
                J<0 || J>7 || I[Y][X] || v[c] ? O : (
                    m.push( c ),
                    v[c] = p + 'SR'[j]
                );
            }

            S = (x&y) > 6 ? p : S;
        } );
        n = m;
    }
    return S || O;
};

v is a hashtable with keys that are state triples (x,y,d) corresponding to (x,y) coordinate and direction of entry d. Each key has an associated value that is the string of S (straight) and R (turn right) moves required to reach the state represented by the key.
The code also maintains a stack of triples (in variable n) that have not been processed yet. The stack initially contains only the triple (0,0,0), corresponding to the state where the car faces right in the (0,0) cell. In the outer loop, for( S = ... ), the routine checks if any unprocessed triples remain. If so, it runs each unprocessed triple through the inner loop, n.map( ....
The inner loop does five things:

computes the two possible moves (driving straight, turning right) out of the current state
if either of these moves leads to a state already registered in the hashtable, it is ignored for further processing. We flag the FALSE output as K (stuck), however, since we have found at least one loop where the car can continue to circle forever without crashing.
if a state is legal and novel, it is added to the hashtable (v) and to the stack of unprocessed triples (m) for the next pass of the outer loop
when the new state is registered in v, its value is set to the value of the originating state (the sequence of moves) plus R or S based on the current move
if x and y are 7, the value of the originating state (the sequence of moves taken to reach the originating state) is copied to S, since this move sequence is a solution to the problem

After the inner loop terminates, n (the stack) is replaced by m (the new stack).
After the outer loop terminates (no new states were reached), the function returns its output. If the (7,7) cell was reached, S will contain a sequence of moves leading to this cell, and this is outputted. If the cell was not reached, S will be the empty string, and the routine falls through to outputting O, which will contain K (stuck) if and only if a loop was found, or C (crash) if the car will inevitably crash.

Got confirmation from OP, you can rename 'Crash' and 'Stuck' to 'C' and 'S'.

Ah. That saves a bit, then. Thanks. ;)

Can you explain what your code is doing?  I can't make heads or tails of it.

@phosgene: I've included a detailed explanation inline.

That's a clever procedure.  Nothing is wasted.

Python 339 - 10% = 305 bytes
I used a recursive depth-first search, which is terminated early on success via exit. Also printing path on success in the form of 00001010101010101010101110100111001000, 0 for straight, 1 for right. The answer will be longer than optimal, since it is depth-first. I'm sure some optimizations to the algorithm could bring the byte count down quite a bit.
b=input()
D=[(-1,0),(0,-1),(1,0),(0,1)]
def a(l):
 x,y=0,0
 v=2
 for d in l:
  if d=='1':v=(v+1) % 4
  x+=D[v][0]
  y+=D[v][1]
  if x<0 or x>7 or y<0 or y>7:return 0,x,y
  if b[y][x]:return -1,x,y
 return 1,x,y
def c(l):
 if len(l) < 39:
  t,x,y=a(l)
  if t==1:
   if (x,y)==(7,7):
    print l;exit(0)
   c(l+"0")
   c(l+"1")
c("")
print 0

Since this is Python 2, you can mix tabs and spaces for indents, like in a's for loop. You also don't need spaces around operators, e.g. (v+1) % 4 -> (v+1)%4. You can also join multiple statements onto one line by using ; if there is no if or for, etc on the line, e.g c(l+"0");c(l+"1"). Some other golfs: x,y,v=0,0,2, x|y>7 or x|y<0, x==y==7. Good luck :)


text:
¿Yo Quiero jQuery?
The Setup
You are given a simple web page with 11 elements:

10 input elements with IDs i1 thru i10, in order
one output element with ID out

The input elements have value attributes defined in the HTML source. The value of any given input may be any integer from 0 to 10 inclusive.
The webpage is equipped with the core jQuery 1.10.1 library (as seen in the fiddle), and executes a block of code as soon as the DOM is loaded.
The Challenge
Six specific challenges are presented below. In each case the objective is to compute some function of the inputs and place the computation result into the inner HTML of the output. Each challenge should be solved independently from the others. The solution to a challenge is the block of code that implements the computation/output (e.g. the code in the "Javascript" window in the fiddle). The length of a solution is the length (in bytes) of this block of code.
All this would seem very simple, if not for some rather interesting restrictions.
Your Code May...

invoke the jQuery function $() and pass in arguments
define and use variables
use this
read any property of any jQuery object (with .length being the most useful)
define functions/lambdas, which may subsequently be invoked, stored in variables, and passed as arguments. Functions may accept arguments and return values if needed.
invoke any of the jQuery DOM traversal methods
invoke any of the jQuery DOM manipulation methods, excepting width, height, innerWidth, innerHeight, outerWidth, outerHeight, offset, position, replaceAll, replaceWith, scrollLeft, scrollTop, css, prop, removeProp, which may not be invoked
use the operators:  object creation {}; array creation / index reference / field reference [], function/method invocation (), string concatenation +, and assignment =
use string literals

Your Code May Not...

use any operators except for those listed above
use any literals that are not string literals
invoke any function/method other than those specifically excepted above
use any control structure or keyword (e.g. for, while, try, if, with, etc.), excepting this, var, let, functions and lambdas
manipulate the DOM in any way that results in the injection of code (see more below)
access any non-user-defined variable or non-user-defined field/property excepting those listed above

The 6 Challenges

Compute the sum of all input values that are even, placing the result in the inner HTML of the output.
Compute the maximum of all input values, placing the result in the inner HTML of the output.
Compute the product of all input values <= 2, placing the result in the inner HTML of the output. If all input values are > 2, place 0 into the inner HTML of the output.
Compute the modal value (i.e. the value with greatest frequency) of all input values, placing the result in the inner HTML of the output. If the modal value is not unique, place any one of the modal values in the inner HTML of the output.
Let I1 be the value of input i1, I2 be the value of input i2, etc.  If the sequence of input values I1 .. I10 forms a fence with I1 < I2, place "TRUE" into the inner HTML out the output; otherwise place "FALSE" into the inner HTML of the output. Specifically, the fence condition is I1 < I2 > I3 < I4 > I5 < I6 > I7 < I8 > I9 < I10.
Place a comma-separated list of all input values, sorted in ascending order, into the inner HTML of the output.

Scoring
The contest winner is the programmer who submits correct solutions to the greatest number of challenges. In the event of a tie, the winner is the programmer with the lowest total solution length (the sum of the lengths of all solutions). Hence this is a minor variant of code golf.
Important Notes
Solutions may mangle the DOM (e.g. delete inputs, create new elements that appear as visual detritus) so long as the final state of the DOM contains an output element with ID out and the correctly-computed value.
Solutions may make use of any advanced jQuery selectors and CSS3, excepting features that evaluate expressions or execute code.
Solutions may not modify the HTML source of the document. All DOM manipulation must occur in the script through jQuery.
Solutions may not inject code of any kind during DOM traversal/manipulation. This includes (but is not limited to) writing out script elements, writing out event attributes containing code, or exploiting the expression (IE) or calc features of CSS3. This challenge is about creative thinking using sets and trees, and masterful use of jQuery; it is not about sneaking code into the DOM or making end runs around the operator restrictions. I reserve the right to disqualify any solution on this basis.
All solutions are realizable, and each can be implemented in fewer than 400 bytes. Your solutions may of course exceed 400 bytes or be far shorter than 400 bytes. This is just my basic guarantee that all 6 problems are solvable using a reasonably small amount of code.
Finally: When in doubt, please ask. :)
Example
Consider the hypothetical challenge: "If 3 or more input values equal 5, place "TRUE" into the inner HTML of the output; otherwise place "FALSE" into the inner HTML of the output."
One valid solution is:
F = () => $('body').append( 'TRUE' );
$('input').each( F );
F();
$('a:lt(3)').html( 'FALSE' );
$('#out').html( $('a:eq(' + $('input[value="5"]').length + ')') );

May the best jQuerier win! ;)

-1 not enough jQuery

I'd totally use the answers to this question as production code followed by //La garantia soy yo

Since the input fields are technically strings and it doesn't say we need to treat it as numbers, does "ascending order" mean alphabetically?

@IngoBürk: The input values will always be (the string representations of) integers from 0 to 10 inclusive. They should be sorted in order of their ascending values when interpreted as integers. This would actually produce the same order as a lexicographic sort, with the exception that 10 would come immediately after 1 in the latter. That should not be the case for a sort here.

Alright. Also, something slightly confusing: You write only string literals are allowed, but also that [] and {} are allowed. But these are, technically speaking, array and object literals. It's clear what you mean, though.

Indeed. I've characterized these as admissible operators rather than admissible literals, even though they're operators that create literals.

Are the inputs following a 0 based index ? Which makes the first and third input on the page as even inputs (and likewise)

@COTO - As array creation is allowed, can I also use array methods like push etc ?

@COTO - Also , one last thing, can I create new strings like a = ''; and then latest do a+='B' ?

@Optimizer: Zero indexing is a mixed bag. If you're working with arguments, arrays, etc., indices are 0-based. Hence $('input').eq(1) would filter down to the second element, and x[1] would select the second element. However, in CSS indexing is 1-based. Hence $('input:eq(1)') would select the first element, and $('a:nth-child(3)') would select the 3rd child, etc.

Yeah, but what do you expect ?

@Optimizer: You can create arrays, but you cannot use any array methods. I've allowed array and object creation since they facilitate variable storage, but none of their greater functionality should be used. Finally, you can certainly create new strings like a = '';, the += operator is off-limits, but you can use a = a + 'B'; if needed.

Also, I get now what you're asking. The "even inputs" are 1-based, hence the second, fourth, sixth, eighth, and tenth are even. The first input is 1. Their IDs indicate their indices.

Let us continue this discussion in chat.

One of the answers accesses the length property of arrays and strings. Those are definitely not jQuery objects. Note: "non-user-defined field/property excepting those listed above". If accessing the length property of any object / all objects of a predefined type is allowed, it should be made clear in the rules.

@GOTO0: The .length property of any non-jQuery object is not permitted. I've notified the poster. I've also addressed the .slice() method being invoked on a string (not permitted).

1. Sum of even inputs, 100 94 bytes
a=$();(e=$('*:odd')).map(i=>a=a.add(e.slice('0',e.eq(i).val()).clone()));$(out).html(a.length)

How it works :

a=$(); : Create a new object a
e=$('*:odd') : Get all odd elements on the page and assign it to e. Interestingly, all odd elements of page actualyl include all even input elements (amongst other things) ;)
(e=..).map(i=>...) : For each of the elements in the object e, run the given function where i is the index of the current element.
a=a.add(e.slice('0', e.eq(i).val()).clone()) : get the value of the ith element in e, slice out that many objects from e, clone them and put add them to a. Interestingly, again, e has more than 10 elements, so it works for all values of the input boxes. For non input elements in e, it just slices 0 elements from e.
$(out).html(a.length) : out is a global created by browsers for each element with an id. So we just put the length of a in the output element's html.

Note that jquery's $() acts as a set, but we are adding clones DOM elements, so it is accumulating and finally giving sum of all even input values.
2. Max of all, 79 70 bytes
a=[];(e=$('*')).map(i=>a[e.eq(i).val()]=e);$(a).map(_=>$(out).html(_))

How it works:

a=[]; : create a new array a
e=$('*') : Query all elements on the page and store it in e
(e=..).map(i=>...) : For each of the elements in the object e, run the given function where i is the index of the current element.
a[e.eq(i).val()]=e : Get the value of the ith element in e (say V) and put e in the Vth index of a. We use e here just to save a byte. Otherwise, a[e.eq(i).val()]='' would also work.
$(a).map(_=>$(out).html(_)) : This is basically putting each index of a into the html of the output element, overriding each time. This ends up with the output node having the value which corresponds to the last index of a which corresponds to the highest value in the inputs.

3. Product, 152 141 133 132 bytes
f=(i,g=_=>p=$(i1))=>$('[value='+i+']').map(g);h=p=$();f('1');f('2');f('2',_=>p=p.add(p.clone()));f('0',_=>p=h);$(out).html(p.length)

141 -> 133 reduction thanks to GOTO0 :)
4. Modal, 116 115 102 bytes
a=[];(e=$('*')).map(i=>(v=e.eq(i).val(),a[$('[value='+v+']').length]=v));$(out).html($(a).last()['0'])

5. Fence, 158 bytes
s="TRUE";g=_=>$("*").slice(A.val(),B.val()).map(_=>s="FALSE");f=a=>(A=$(a),B=A.prev(),g(),A=$(a),B=A.next(),g());f(i2);f(i4);f(i6);f(i8);f(i10);$(out).html(s)

6. Sorted comma separated values, 133 85 86 bytes
$('*').map(i=>$('[value='+i+']').map(_=>$(out).append(i+',')));$("a:last").remove()

How this works:

$('*').map(i=>...) : Take out all elements from the page and run the method for all of them where i is the index of the element.
$('[value='+i+']').map(_=>...) : For each i, get all elements whose value is i and run the method for each one of them.
$(out).append(i+',') : Append i and an anchor tag with , in it to the output element for each element whose value is i.
$("a:last").remove() : Remove the last anchor tag to remove the trailing ,

This works as it picks out all elements with values i = 0 through 19 (19 being total number of elements on page) and appends i, to the output element the number of times an element with value i appears. This takes care of all input element, sorting them in increasing order.

Run them on the given JS fiddle page on a latest Firefox.
Please comment if anything is violating rules.

Positive. A hint is that .parents() can be a useful way to compute < or >.

Looks good. Unless somebody else rises to give you a run for the money, it looks like you'll be 100 rep richer by the end of the week.

+1 Could you explain your solutions please?

@soktinpk - Sure, after the bounty ends ;)

The bounty is yours. You are the jQuery king. ;)

Nice. Maybe you could save 2 bytes in the third solution if you move p=$() outside the argument list and use $(f('1'),f('2')).map... rather than the add method.

@GOTO0 - $(f('1'),f('2')) gives 0 length object when there are no input with value 1

This one is tested - 135 bytes: f=i=>$('[value='+i+']').map(_=>p=g());p=$();f('1',g=_=>$(i1));f('2');f('2',g=_=>p.add(p.clone()));f('0',g=_=>$());$(out).html(p.length)

Interesting challenge! Here are the first few to start us off:
1. Sum, 122 112 bytes
e=$('*')
e.map(i=>e.slice('0',n=e.eq(i).val()).map(x=>e.eq(n).append('')))
e.text($(':not(a):even>a').length)

For each input n, append n  elements to the nth <input> element. Then count the  elements in every odd <input> element.
2. Maximum, 91 79 bytes
e=$('*')
s=$()
e.map(i=>(s=s.add(e.slice('0',e.eq(i).val()))))
e.text(s.length)

For each input n, join the first n <input> elements with the set s. Then count the elements in the set.
3. Product, 157 bytes
e=$(s='[value=0],[value=1],[value=2],#out')
f=x=>e.slice('0',x.val()).each(i=>f(x.nextAll(s).first().append('')))
f(e.first())
e.text($('#out a').length);

A recursive function that, given an element with value n, calls itself with the next element n times and appends an  to that next element. Then count the  elements in <output>.
Let me know if there are any mistakes or rule breaches.

Everything looks kosher except for the zero literal in #2. Very nice solutions BTW.

@grc - Aren't we supposed to put the answer in the  element instead of the  element ?

@Optimizer Yes, you're right. It seems my last edit broke the first two. I'm really busy right now, but it should just be a matter of replacing e.text with $('#out').text. I'll fix it tomorrow if I get time.

source: Stack Exchange

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

sort: votes


text:
Create an array of unique ints in a set range
Goal:
Write a piece of code that produces a array containing all integer values in a set range in random order (upper and lower bounds included).
Use any language you like, but use as little built-in functions as possible (ie PHP's array_shuffle should be avoided)
Rules:

All ints in the range must be used once, and only once
The range can be negative, or positive
When using JavaScript: ECMAScript6 features are to be avoided
If you choose to write a function the function(params){ and closing } needn't be counted. Bonus points for clever argument validation/normalization if you do write a function
Aliases like m = Math; or Array.prototype.p = [].push; will be counted, using closures/functions, passing Math as an argument will be counted as <argName>=Math;

Benchmark:
As a starting point or target: here's a snippet that meets all of the criteria apart from the randomness. It's approx. 50 bytes long (depending on v's value). That would be a nice target to hit:
for(l=3,a=[v=12],i=v>0?-1:1;(v+=i)!=l+i;)a.push(v)

Caveats: if l is bigger than v, the code fails.

@MartinBüttner: sorry, first post. Didn't realize language-specific challenges are discouraged. Would expanding the question to the entire ECMAScript family be desirable? Also: Sure, this is code-golf. It's not a question of "how should I write this?" :-)

@MartinBüttner: Done.

Why the hate against ecmascript? With other languages allowed, Javascript won't win anyway.

Rules 3,4,5 don't make sense.

@edc65: Those rules stem from the initial question, which was JavaScript specific. I edited that part out, because it was pointed out that language-specific questions are discouraged

APL, 18
{(⍺⌊⍵)-1-?⍨1+|⍺-⍵}

Takes upper/lower bounds as left/right argument. Works for any bounds, also reversed bounds.
Can be shortened to 13 characters if the assumption l<=u can be made:
{⍺-1-?⍨⍵-⍺-1}

Try

GolfScript (26 bytes)
~)1$-:x,\{+}+%{;x.*rand}$`

Online demo
Could be slightly shorter but at the cost of worse randomisation. By picking random numbers up to the square of the size of the range I come close enough IMO to avoiding collisions.

JavaScript, 73 bytes
for(i=l,s=[];i<=u;)s[i-l]=i++;s.sort(function(){return Math.random()<.5})

Assumes l and u have the lower and upper bounds resp. and l<=u

CJam, 12 (or 10) bytes
Aannnd, if other languages are allowed, here is an answer in CJam
{$~1$-),f+mr`}:F;

This creates a function F , thus not counting the { and }:F;.
Example Usage:
{$~1$-),f+mr`}:F;
[7 -2]F

Output:
[1 -2 6 2 -1 5 7 0 3 4]

If I assume that first integer is always less than the second integer, then the code comes down to 10 bytes:
{1$-),f+mr`}:F;

Example usage:
{1$-),f+mr`}:F;
-2 7F

Output:
[1 -2 6 2 -1 5 7 0 3 4]

Try it online here

PYTHON, 21
list(set(range(l,u+1)))

assumes l <= u

I believe set uses the hash value of the arguments for the order of this list it generates. This generates kind-of random ordering, for example with l, u = 30, 50, I get [32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 30, 31]. I'd say this still counts though.

J (11 (or 9))
f=:>.-?~@>:@|@-

This defines a dyadic function, the arguments of which define the start and end of the range. The order of the arguments doesn't matter. (Does this give me bonus points?)
As per the rules, I'm not counting f=: as this is part of the function definition (i.e., what would be function f(params){...}. An anonymous function would be (>.-?~@>:@|@-), where the () can be disregarded according to that rule.
If I can assume the left argument to be the upper bound, and the right argument to be the lower bound, it can be shortened to 9:
g=:[-?~@>:@-

Or, as an anonymous function, ([-?~@>:@-).
Test:
   f=:>.-?~@>:@|@-
   g=:[-?~@>:@-
   _5 f 10
_1 2 0 _2 _5 3 _4 _3 1 9 4 10 5 7 6 8
   2 f 10
2 10 5 3 8 4 9 7 6
   10 f 2
2 9 4 5 6 10 3 7 8
   10 f _5
_3 9 4 3 2 6 _2 1 5 8 7 _1 _4 10 _5 0
   10 g 2
2 3 4 7 9 5 6 10 8
   10 g _5
1 2 7 4 3 _4 5 8 6 9 _1 10 0 _5 _2 _3

_5 === -5 ? Also, not sure if that is a valid way of providing input to the program.

@Optimizer: yes, _5 is the J representation of -5. (That's necessary, because arrays are written as 0 1 2 3. So [0,1,-2,3] would be written as 0 1 _2 3, whereas 0 1 -2 3 means (0 1)-(2 3), i.e. _2 _2.) As for providing input, it's just a function. a F b is J for F(a,b). There are more people who have submitted functions, and there are even people who just assume preset variables.

I agree, but both of the other assumptions add extra bytes to the code, while you take the benefit of having the input already present. For instance, I can assume that both integers are already on stack in my CJam answer and get rid of two more bytes making the final answer only 10 bytes.

@Optimizer: according to the rules, you can define a function, and you don't have to count the function definition boilerplate. I'm not that familiar with CJam, but in Golfscript you can do {...}:f;, if I'm not mistaken, and you wouldn't have to count the {}:f; part. So if CJam works the same way, you could do that and be within the rules.

Hmm, that rule needs to be more clear that it is for all languages and not just JS.

Perl - 19
sort{rand>.5}$l..$v

Assuming $l and $v are already defined. If you wanted to make it a function:
sub random_array {
    sort{rand>.5}$_[0].._$[1]
}

You can try it with:
perl -E'$,=",";$l=1; $v=15; say sort{rand>.5}$l..$v'

or
perl -E'say random_array(0,5);sub random_array{sort{rand>.5}$_[0]..$_[1]}'

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


text:
Move the "post your answer" form next to the question on SE sites
I have a problem when posting an answer to a question that already have several answers and/or several comments:
The "post your answer" form sits on bottom, the answer is on top. There is an awful lot of "clutter" between them, that are not needed for the act of posting a new answer (yes, I've read the other answers and comments, what I am about to write is original).
I have a very short short term memory and hate to scroll all the way up and down to read question and write answer text.
Write a script or program that

Can run on vanilla (downloaded from the main page for those softwares) Firefox and/or Chrome (irrelevant if it also runs on other browsers or on all browsers)
you get 10 fake internet points from me if it runs on all browsers, but this is not a victory condition
You can call any code that ships with the browser, loads with the SE page (like jQuery) or sideloads from the web.
Can be run (as a bookmarklet, from console, any input method) on a fresh install of one of those two browsers.
Does not depend on any other software installed on the machine, or the installation of any add-ons and/or plugins on the browsers.
Irrelevant if it runs only on windows, only on mac or only on linux, as long as those browsers can be downloaded from the browsers' official download page, for that platform.
Does not break the submit answer form (I can still write my answer and submit, and the whole edit toolbar is still intact - including the help icon).
Question is intact. Title, body, votes panel, post menu and owner signature.

(italics denote editted-in content)

vertical Distance between bottom of owner signature and the top of edit toolbar is the same or smaller (negatives allowed) than when posting the first answer to a question in the same site.
Edit form toolbar cannot be higher than the question title.

both question, answer edit form, answer toolbar and answer preview have to remain visible and non-overlapping.

Only the screen display matters. If the other elements were hidden, deleted, moved, ejected into outer space or phase-shifted into a Dirac Sea is irrelevant.

Your code must work for a minimum of:

https://stackoverflow.com/
https://superuser.com/
https://codegolf.stackexchange.com/
https://rpg.stackexchange.com/
https://android.stackexchange.com/
https://scifi.stackexchange.com/

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

I am now required to link this question for the exerpts' credits. Thanks @Doorknob.
P.S.: It is my first time in PpCG, be kind.

What about an approach which moves the question? E.g. inject <style>.question{position:fixed;height:300px;background:white;overflow:auto}body{padding-top:300px}</style> into the header?

Have to add "both question, answer edit form, answer toolbar and answer preview have to remain visible and non-overlapping. Sorry for any confusion my newbieness caused.

@Mindwin Your rule changes have invalidated more than one answer. Next time, consider posting your challenge to the Sandbox before posting it here. You'll get feedback from the community that will help you avoid changing the rules after the challenge has started. I'm not sure why you felt the need to add "non-overlapping" as a rule.

I agree with @Mindwin that no overlapping was implied already.

The down votes are mostly because the challenge is not interesting enough and it is a language specific task. That combination is really hated.

JavaScript, 35 34 bytes
$(answers).before($('#post-form'))

If only the #post-form id did not have - in it ...

JavaScript (38 bytes)
$('#question').append($('#post-form'))

This could be shortened by copying Optimizer's trick of exploiting browser lifting of elements with suitable ids to global variables as $(question). etc.


text:
Tetrahedron Surface Area
The challenge
This challenge is very straightforward. Given four 3-dimensional points, calculate the surface area of the tetrahedron that they form. This is code-golf, so shortest code wins. Standard loopholes apply, with the added stipulation that any built-in function to do this task given four points is prohibited.
You can assume all four points will be distinct, and will be given via STDIN, 1 point per line. Each point will consist of three 16-bit unsigned integers. The exact format of each point can be modified if it makes things easier, such as three space separated integers. Having each point on a separate line is mandatory however. Output should be through STDOUT, to at least 2 decimal places.
For those of you who do not know, a tetrahedron is a 3-d solid, formed by 4 triangular faces.
Example
# input (format is up to you, see clarification above)
[23822, 47484, 57901]
[3305, 23847, 42159]
[19804, 11366, 14013]
[52278, 28626, 52757]

# output
2932496435.95

Please leave a note if you notice my math is wrong.

@BetaDecay No, the idea is that they will be input via STDIN on four separate lines. I will edit the question to clarify this.

Can the input be a [[list],[of],[lists]]?

@phosgene I like to think reading the input is part of the challenge, so I'm going to say no. I will try to be more lenient with input specifications in future challenges.

Is this a regular or irregular tetrahedron?

@JamesWilliams the example posted is irregular. Your program should handle any input though, including regular tetrahedrons.

Python, 198 178 161 chars
V=eval('input(),'*4)
A=0
for i in range(4):F=V[:i]+V[i+1:];a,b,c=map(lambda e:sum((a-b)**2for a,b in zip(*e)),zip(F,F[1:]+F));A+=(4*a*b-(a+b-c)**2)**.5
print A/4

The input format is as given in the question.
It calculates the length of the edges adjacent to each of the faces and then uses Heron's formula.

APL, 59
f←{+.×⍨⊃1 2-.⌽(⊂⍵)×1 2⌽¨⊂⍺}
.5×.5+.*⍨(f/2-/x),2f/4⍴x←⎕⎕⎕-⊂⎕

Works by calculating cross products
Explanation
The first line defines a function that takes two arguments (implicity named ⍺ and ⍵), implicitly expects them to be numerical arrays of length 3, treat them as 3d vectors, and calculates the squared magnitude of their cross product.
                        ⊂⍺   # Wrap the argument in a scalar
                   1 2⌽¨     # Create an array of 2 arrays, by rotating `⊂⍺` by 1 and 2 places
             (⊂⍵)×           # Coordinate-wise multiply each of them with the other argument
        1 2-.⌽               # This is a shorthand for:
        1 2  ⌽               #   Rotate the first array item by 1 and the second by 2
           -.                #   Then subtract the second from the first, coordinate-wise
       ⊃                     # Unwrap the resulting scalar to get the (sorta) cross product
   +.×                       # Calculate the dot product of that...
      ⍨                      # ...with itself
f←{+.×⍨⊃1 2-.⌽(⊂⍵)×1 2⌽¨⊂⍺} # Assign function to `f`

The second line does the rest.
                         ⎕⎕⎕-⊂⎕ # Take 4 array inputs, create an array of arrays by subtracting one of them from the other 3
                       x←        # Assign that to x
                     4⍴          # Duplicate the first item and append to the end
                  2f/            # Apply f to each consecutive pair
            2-/x                 # Apply subtraction to consecutive pairs in x
          f/                     # Apply f to the 2 resulting arrays
         (f/2-/x),2f/4⍴x←⎕⎕⎕-⊂⎕ # Concatenate to an array of 4 squared cross products
   .5+.*⍨                        # Again a shorthand for:
   .5  *⍨                        #   Take square root of each element (by raising to 0.5)
     +.                          #   And sum the results
.5×                              # Finally, divide by 2 to get the answer

If you are not sure whether it is hieroglyphs or a corrupted dll file it is probably gonna be APL. Could you perhaps explain somewhat more what some of those symbols do? It's not that I want to learn it but I am still rather intrigued by how you can program with those seemingly obscure symbols=P

@flawr I usually does that because golfing in APL mostly comes down to algorithm design and would most likely result in an uncommon approach to the problem. But I felt like "calculating cross product" conveys enough about the algorithm here. If you want a full-on explanation I will do it later today.

The idea of calculating the cross product was clear, but the code itself leaves me without any clue, so I just thought some few words about what parts of the code do what would be great, but of course I do not want to urge you to write a detailed explaination!

Matlab/Octave 103
I assume the values to be stored in the variable c. This uses the fact that the area of a triangle is the half length of the cross product of two of its side vectors.
%input
[23822, 47484, 57901;
3305, 23847, 42159;
19804, 11366, 14013;
52278, 28626, 52757]

%actual code
c=input('');
a=0;
for i=1:4;
    d=c;d(i,:)=[];
    d=d(1:2,:)-[1 1]'*d(3,:);
    a=a+norm(cross(d(1,:),d(2,:)))/2;
end
a

Each point must be entered on a separate line as standard input.

I first thought there is no such thing as standard input in Matlab, but I discovered a function that can be used to simulate this via the command window, so now you can pass the input as you could in other languages.

Interesting. That's the same command that Mathematica uses, Input[]

Why do you think that this is interesting? 'input' seems to me like a pretty generic name for a function that does this.

Until yesterday, I didn't really know what "standard input" meant, and I thought that Mathematica did not have "standard" input,  even though I had regularly used Input[],  InputString[], Import[], and ImportString[].

Ah, honestly I have never used Mathematica but it seems like a powerful program, do you use it professionally?

I use Mathematica in university courses we offer for in-service middle school teachers. For example, our teachers recently interviewed their students using a Mathematica app about multiplication as dilations on the line and in the plane.  I find it powerful and elegant. Teachers who want to design their own apps will generally find GeoGebra more appropriate and approachable.

Well the thing is also that GeoGebebra is available for free while Mathematica can - depending on what organization - still be expensive.

Python 3, 308 298 292 279 258 254
from itertools import*
def a(t,u,v):w=(t+u+v)/2;return(w*(w-t)*(w-u)*(w-v))**.5
z,x,c,v,b,n=((lambda i,j:(sum((i[x]-j[x])**2for x in[0,1,2]))**.5)(x[0],x[1])for*x,in combinations([eval(input())for i in">"*4],2))
print(a(z,x,v)+a(z,c,b)+a(b,v,n)+a(x,c,n))

This uses:

The Pythagorean Theorem (in 3D) to work out the length of each line
Heron's Formula to work out the area of each triangle

I used the same method for testing my solution. I'll have to try golfing mine and post it later.

Your for i in">"*4 is clever

You can hard code a length of 3, instead of using len(i) in your range function.

You could save a few more characters doing the square root as x**0.5, instead of math.sqrt(x).

You can save two bytes by putting def a(t,u,v) on one line like so: def a(t,u,v):w=(t+u+v)/2;return(w*(w-t)*(w-u)*(w-v))**0.5.

Mathematica 168 154
This finds the lengths of the edges of the tetrahedron and uses Heron's formula to determine the areas of the faces.
t = Subsets; p = Table[Input[], {4}];
f@{a_, b_, c_} := Module[{s = (a + b + c)/2}, N[Sqrt[s (s - #) (s - #2) (s -#3)] &[a, b, c], 25]]
  Tr[f /@ (EuclideanDistance @@@ t[#, {2}] & /@ t[p, {3}])]

There is a more direct route that requires only 60 chars, but it violates the rules insofar as it computes the area of each face with a built-in function, Area:
p = Table[Input[], {4}];
N[Tr[Area /@ Polygon /@ Subsets[p, {3}]], 25]

Sage – 103
print sum((x*x*y*y-x*y*x*y)^.5for x,y in map(differences,Combinations(eval('vector(input()),'*4),3)))/2

The input-reading part is adapted from Keith Randall’s answer.

C, 303
Excluding unnecessary whitespace. However, there's still a lot of golfing to be done here (I will try to come back and do it later.) It's the first time I've declared a for loop in a #define. I've always found ways to minmalise the number of loops before.
I had to change from float to double to get the same answer as the OP for the test case. Before that, it was a round 300.
scanf works the same whether you separate your input with spaces or newlines, so you can format it into as many or as few lines as you like.
#define F ;for(i=0;i<12;i++)
#define D(k) (q[i]-q[(i+k)%12])
double q[12],r[12],s[4],p,n;

main(i){
  F scanf("%lf",&q[i])
  F r[i/3*3]+=D(3)*D(3),r[i/3*3+1]+=D(6)*D(6)
  F r[i]=sqrt(r[i])
  F i%3||(s[i/3]=r[(i+3)%12]/2),s[i/3]+=r[i]/2
  F i%3||(p=s[i/3]-r[(i+3)%12]),p*=s[i/3]-r[i],n+=(i%3>1)*sqrt(p)
  ;printf("%lf",n);
}

Python - 260
I'm not sure what the etiquette on posting answers to your own questions is, but her is my solution, which I used to verify my example, golfed:
import copy,math
P=[input()for i in"1234"]
def e(a, b):return math.sqrt(sum([(b[i]-a[i])**2 for i in range(3)]))
o=0
for j in range(4):p=copy.copy(P);p.pop(j);a,b,c=[e(p[i],p[(i+1)%3])for i in range(3)];s=(a+b+c)/2;A=math.sqrt(s*(s-a)*(s-b)*(s-c));o+=A
print o

It uses the same procedure as laurencevs.

As a rule of thumb, it's a best idea to wait a few days before answering your own question, especially if your score is low, in order to not cool down the motivation of the viewers.

A few tips: You can save some characters by r=range. lambda is shorter than def. math.sqrt can be replaced by (…)**.5. p=copy.copy(P);p.pop(j); can be shortened to p=P[:j-1]+P[j:]. A is only used once.


text:
Practical Golf - US States
My family has an e-commerce business. On our own site, we force people to choose their state from a dropdown menu when they enter their address, but through some other channels we use, customers can enter anything they want into the box.
My mom loves the invoice templates I made for her, which are automagically generated. But because they're so pretty and balanced, she can't stand it when people WRITE OUT the names of their states, or worse, write something like "new jersey." She says it ruins the look.
My dad likes code to be lightweight. So rather than using a switch-case block, he wants a leaner solution.
So the challenge is to make a short function that takes the possible inputs and returns a two letter abbreviation (capitalized, for Mom). We're going to make a (faulty) assumption that our users can spell and always put a space in the name (where needed) or pass in the correct abbreviation. The scope is the 50 US states.

New York
new york
NY
ny

are all acceptable inputs for New York, and should output NY.
If something like New Yrok is passed in, the function can return the original value.
You can use any common language. This is a popularity contest, so the one with the most votes at the end of a week wins. I assume that this will favor novelty and utility.
EDIT: The description is story fluff, but I was working a similar project and thought that there must be a more interesting way to do it. I can do the project myself (already did) but I thought this was a good place for a more interesting challenge. By "Any common language" I was excluding custom languages/libraries designed for this challenge - I was trying to look for novel methods, rather than free code help. I figure everyone has done this at some point, but it would be fun to do it in an unusual way. I find that the most interesting projects are the ones where you tackle everyday tasks in new and interesting ways - that's why this is a popularity contest rather than golf.

Not sure if +1 for your mom's thoughts on aesthetics or -1 for your dad's thoughts on short code.

Would ny output NY?

Yes, it should. I'll make that edit.

I'm unsure why this is a popularity contest instead of code golf (especially since the name includes 'golf' and your dad favors short code).

I agree with Geobits, this would work better as a code-golf I think.

@Geobits: For actual production code, you would want the code to be lean but reasonable, not golfed... unless you want to maintain code that looks like something an electric cat coughed up (X⌿⍨Y^.=⍨X↑⍨(⊃⍴X),⍴Y)?

@Claudiu True, but this site isn't intended for production code...

@Geobits: Isn't it? "My family has an e-commerce business. On our own site [...] My dad likes code to be lightweight. So rather than using a switch-case block, he wants a leaner solution." It sounds like he plans to use this code on the e-commerce site.

@Claudiu I honestly assumed that was "story fluff" of the sort that usually goes with these challenges. Either way, when I said "this site..." I meant PP&CG, as most code here is explicitly not intended for use in production. Honestly, if he's looking for actual code to use on his site, it would be more ethical to do it himself or contract it out ;)

@Geobits I thought it was fluff as well. Based on his profile, it sounds like OP is actually looking for code since his parents have an online toy store. I deleted my answer and voting to close as off-topic. This isn't a code challenge, its free contracting.

It sounds like OP is asking us to write code for him, but trying to frame it as a code-challenge.

@chilemagic you can use any code ... so OP will rewrite his site to use your APL/CJAM/GolfScript solution? It's a challenge based on a true story. I vote up

It's a pretty trivial task, why would OP go to all the effort of typing up a question when it would be easier just to code it himself? Either way, I enjoyed giving it a go.

@edc65 IMO, There's a big difference between what you quoted ("you can use any code") and what the OP actually said ("you can use any common language").

@Geobits good point, I honestly misread. On the other hand, as you said, that's not the place for production code. I'm here to have fun.

Grossly unsuitable winning criterion

I'm disappointed it is closed.  It looks like everybody managed to get an answer in except me...

Ruby
Thought it would be interesting to extract the state abbreviations without writing any of the names or abbrevations explicitly. This one does not take misspelling of the input into consideration, because we don't care about such thing here on codegolf.SE, rihgt?
def f(s)
  [
    /(.).* (.)/,              # two words
    /^([CDGHKLPV]).*(.)$/,    # first and last letter
    /^(.).*([ZVX])/,          # unique letter
    /^([NFOUW])(.)/,          # two first letters
    /^(.)([DNR])/,            # unique second letter
    /^(.).*(L|N)\2/,          # double letters
    /^(.).SS(A|O)/,           # double S before the one used
    /^(.).*?[SNW](.)/,        # identified by the letters before them
    /(.)(.)/                  # two first letters

  ].find { |r| r =~ s.upcase }
  $1+$2
end

It took a conciderable time to figure out clever patterns to match all the states. The order of the patterns is important -- each consecutive pattern applies to the remaining states that were not matched by a previous pattern:

All states with two words in them use the initial letters of the two words:

New Hampshire, New Jersey, New Mexico, New York, North Carolina, North Dakota, Rhode Island, South Carolina, South Dakota, West Virginia

All states beggining with any letter in {CDGHKLPV} use the first and last letter in the name:

California, Colorado, Connecticut, Delaware, Georgia, Hawaii, Kansas, Kentucky, Louisiana, Pennsylvania, Virginia, Vermont

Of the remaining states, the letters {ZVX} are unique:

Arizona, Nevada, Texas

All remaining states beginning with {FNOUW} use the two first letters.

Florida, Nebraska, Ohio, Oklahoma, Oregon, Utah, Washington, Wisconsin, Wyoming

Then, {DNR} are unique as second letters:

Arkansas, Indiana, Idaho

It's really getting hard to make general patterns, but...

Only three remaining states use double N or L, and the double letter is used in the state abbreviation:

Tennessee, Minnesota, Illinois

A or O after double S is unique to

Massachusetts and Missouri

Whenever {SNW} appear before other letters in the remaining state names, the letters after them are used in the abbreviations:

Alaska, Maryland, Maine, Mississippi, Montana, Iowa

Two left. These use the two first letters:

Alabama, Michigan

It can be golfed of course:
Ruby 2 – 191 165 154 characters
Another 26 characters off by uglifying the regexes a bit. Also, one of the original regexes turned out to be redundant!
gets;[/.* (.)/,/^[CDGHKLPV].*(.)$/,/.*([ZVX])/,/^[NFOUW](.)/,/^.([DNR])/,/.*(L|N)\1/,
/.*SS(A|O)/,/.*?[SNW](.)/,/.(.)/].find{|r|$_.upcase=~r}
puts $&[0]+$1

"Currently less than a third of the size of the Golfscript entry!" :P Keep in mind, Golfscript doesn't use Regexes.

And I changed the size. :P

@JosiahWinslow No harm meant; The reason I pointed it out was just that it's quite rare that you see a normal language beat golfscript in codegolf by a factor of 3 ;)

I didn't think it meant any harm. I was just trying to make a joke. If Golfscript used regexes...if ONLY. (Oh, and the factor is more like 3.41884817 :P)

@JosiahWinslow hehe, good :P And I can't imagine what would happen if someone were to mix regex with golfscript. I'm not sure the world is ready for such a thing..

(@JosiahWinslow and oh, make that 3.9575757575... :P)

I'm trying to do something with embedding this into Golfscript, just as a test...and I'm having trouble working the input in. gets didn't work, neither did string concatenation. Help?

lol for the boobs regex in the explanation that didnt survive compression

This is the type of thing I was looking for - and shorter than writing out each state's name! I would suggest that  your explanation for  {CDGHKLPV} should read "first and last" rather than "first and second" but the regex is right.

Wow, what are the odds? Some user with the same name as me... :\ Also, I got Golfscript down to 185 bytes! (with embedded Ruby :P )

@Josiah You're right, that was a typo. It's fixed now, and also one regex could be removed.

I like this answer, but it is not valid as it can not spot invalid input (as you say). There is even a specific example If something like New Yrok is passed in, the function should return the original value.

I agree with @edc65. This is awesome but doesn't follow the requirements

C#
I used characters already in the states for the abbreviations to shorten up the state string.
public string GetAbbr(string state)
            {

                var states =
                    new[] {
                        "AlasKa", "ALabama", "AriZona", "ARkansas", "CAlifornia", "COlorado", "ConnecticuT",
                        "DElaware", "FLorida", "GeorgiA", "HawaiI", "IDaho", "ILlinois", "INdiana", "IowA", "KansaS",
                        "KentuckY", "LouisianA", "MainE", "MarylanD", "MAssachusetts", "MIchigan", "MinNnesota",
                        "MiSsissippi", "MissOuri", "MonTana", "NEbraska", "NeVada", "New Hampshire", "New Jersey",
                        "New Mexico", "New York", "North Carolina", "North Dakota", "OHio", "OKlahoma", "ORegon",
                        "PennsylvaniA", "Rhode Island", "South Carolina", "South Dakota", "TeNnessee", "TeXas", "UTah",
                        "VermonT", "VirginiA", "WAshington", "washington D.C.", "West Virginia", "WIsconsin", "WYoming"
                    };
                var all = states.ToDictionary(st => string.Concat(st.Where(char.IsUpper)));

                var wanted = all.FirstOrDefault(pair => state.ToUpper().Equals(pair.Value.ToUpper()) || state.ToUpper().Equals(pair.Key));

                return wanted.Key ?? state;
            }

Nice workaround!

JavaScript (E6)
Here the bulk is the list of names, using the camelCase trick to shorten a bit. Golfed, 617 bytes.
F=i=>
  "AkAlAzArCaCoCtDeFlGaHiIdIlInIaKsKyLaMeMdMaMiMnMsMoMtNeNvNhNjNmNyNcNdOhOkOrPaRiScSdTnTxUtVtVaWaWvWiWyAlaskaAlabamaArizonaArkansasCaliforniaColoradoConnecticutDelawareFloridaGeorgiaHawaiiIdahoIllinoisIndianaIowaKansasKentuckyLouisianaMaineMarylandMassachusettsMichiganMinnesotaMississippiMissouriMontanaNebraskaNevadaNew hampshireNew jerseyNew mexicoNew yorkNorth carolinaNorth dakotaOhioOklahomaOregonPennsylvaniaRhode islandSouth carolinaSouth dakotaTennesseeTexasUtahVermontVirginiaWashingtonWest virginiaWisconsinWyoming"
  .match(/.[^A-Z]*/g).map((w,q)=>U(w,U(w)==U(i)?p=q%50:p),U=s=>s.toUpperCase(),p=-1)[p]||i

PHP
My attempt, which was not as successful as I had hoped, uses string length and some specific character placement to extract the abbreviation from the state name. Probably some better sequencing of name elimination is possible.
function findAbb ($state) {
    $first = substr($state, 0, 1);
    $last = substr($state, -2,1);
    $state = strtolower($state);
    if (strlen($state) < 4) {
        return strtoupper($state);
    }
    if (strpos($state, ' ')) { //if it's a space, return the first letter of each word.
        $space_index = strpos($state, ' ');
        $state = explode(' ', $state);
        return strtoupper(substr($state[0], 0, 1) . substr($state[1], 0, 1));
    }
    if (startsWith($state, 'io')) { //iowa is annoying, get rid of it.
        return strtoupper($first . $last);
    }
    if (startsWith($state, 'w,i')) { //if it starts with a W, return the first 2.
        return strtoupper(substr($state, 0, 2));
    }
    if (strlen($state) < 7 && strpos($state, 'm')===false) { //matches texas, ohio, and utah.
        return strtoupper($first . substr($state, -4,1));
    }
    if (strlen($state) < 7 && substr($state, 0, 1) > 'j' && substr($state, 0, 1) < 'n') { //matches maine, kansas, and hawaii
        return strtoupper($first . $last);
    }
    if (startsWith($state, 'c,d,k,l,p,v,g,h')) { //some unique states
        return strtoupper($first . $last);
    }
    if (strpos($state, 'sk')) {
        return strtoupper ('ak');
    }
    if (startsWith($state, 'k,l', 1)) {
        return strtoupper(substr($state, 0, 2));
    }
    if (startsWith($state, 'n')) {
        return strtoupper($first . substr($state, 2, 1));
    }
    if (startsWith($state, 'n', 2) || startsWith($state, 'z', 3)) { //montana, tennessee, minnesota, and arizona
        return strtoupper($first . substr($state, 3, 1));
    }
    if (startsWith($state, 'm') && ($last == 's') || ($last == 'n')) {
        return strtoupper(substr($state, 0, 2));
    }
    if (strpos($state,'o')) {
        return strtoupper($first . 'o');
    }
    if (strpos($state,'y')) {
        return strtoupper($first . 'd');
    }
    if (strpos($state,'r')) {
        return strtoupper($first . 'r');
    }
    if (strpos($state,'ss')) {
        return strtoupper($first . 's');
    }

    return $state; //otherwise return the name of the state (it was mispelled).
}

function startsWith ($state, $letters, $index = 0) { //takes a comma separated array and finds contents.
    $letters = split(',',$letters);
    for ($q = 0; $q<count($letters); $q++) {
        if (strpos($state,$letters[$q]) === $index) {
            return true;
        }
    }
    return false;
}

Of course, it can be golfed. This is my first golfing attempt, so insight appreciated. (911)
function t($s){$s=u($s);$f=b($s,0,1);$l=b($s,-2,1);
if(strlen($s)<4)return $s;if(strpos($s,' '))$s=split(' ',$s);
return b($s[0],0,1).b($s[1],0,1);
if(w($s,'IO'))return $f.$l;
if(w($s,'W,I'))return b($s,0,2);
if(strlen($s)<7 && strpos($s,'M')===false)return $f.b($s,-4,1);
if(strlen($s)<7 && b($s,0,1)>'I' && b($s,0,1)<'N')return $f.$l;
if(w($s,'C,D,K,L,P,V,G,H'))return $f.$l;if(strpos($s, 'SK'))return 'AK';
if(w($s,'K,L',1))return b($s,0,2);if(w($s,'N'))return $f.b($s,2,1);
if(w($s,'N',2) || w($s,'Z',3))return $f.b($s,3,1);
if(w($s,'M') && ($l=='S') || ($l=='N'))return b($s,0,2);
if(strpos($s,'O'))return $f.'O';
if(strpos($s,'Y'))return $f.'D';if(strpos($s,'R'))return $f.'R';
if(strpos($s,'SS'))return $f.'S';return $s;}function w($s,$l,$i=0){$l=split(',',$l);
for($q=0;$q<count($l);$q++)if(strpos($s,$l[$q])===$i)return 1;return 0;}
function u($z){return strtoupper($z);}
function b($v,$x,$y){return substr($v,$x,$y);}

Python
Decided just to do this as a code-golf challenge. Got it down to 906 713 694 chars with the help of daniero and hsl:
s='AK,AL,AZ,AR,CA,CO,CT,DE,FL,GA,HI,ID,IL,IN,IA,KS,KY,LA,ME,MD,MA,MI,MN,MS,MO,MT,NE,NV,NH,NJ,NM,NY,NC,ND,OH,OK,OR,PA,RI,SC,SD,TN,TX,UT,VT,VA,WA,WV,WI,WY,ALASKA,ALABAMA,ARIZONA,ARKANSAS,CALIFORNIA,COLORADO,CONNECTICUT,DELAWARE,FLORIDA,GEORGIA,HAWAII,IDAHO,ILLINOIS,INDIANA,IOWA,KANSAS,KENTUCKY,LOUISIANA,MAINE,MARYLAND,MASSACHUSETTS,MICHIGAN,MINNESOTA,MISSISSIPPI,MISSOURI,MONTANA,NEBRASKA,NEVADA,NEW HAMPSHIRE,NEW JERSEY,NEW MEXICO,NEW YORK,NORTH CAROLINA,NORTH DAKOTA,OHIO,OKLAHOMA,OREGON,PENNSYLVANIA,RHODE ISLAND,SOUTH CAROLINA,SOUTH DAKOTA,TENNESSEE,TEXAS,UTAH,VERMONT,VIRGINIA,WASHINGTON,WEST VIRGINIA,WISCONSIN,WYOMING'.split(",")
x=input().upper()
print(s[s.index(x)%50]if x in s else x)

However, if modules are allowed (like the us module), I can get it down to 130 chars:
import us
i=raw_input()
x=us.states.lookup(i)
print x.abbr if x else i

And if you didn't have to return the original value when the state doesn't exist I could get it down to 50 chars:
import us
print us.states.lookup(raw_input()).abbr

You can save roughly 200 characters on the first one by letting s be one large string, then split it on commas (,); No need for all the single-quotes.

@daniero Can't believe I didn't think of that! Will do now.

You can remove Washington, D.C., as it isn't a U.S. state.

@hsl Thanks. I took the list from a list of states I found online, didn't realise Washington D.C. was in there.

Javascript
I know this isn't code golf, but I want to golf it anyway. :)

var r=new XMLHttpRequest
r.open("GET","https://gist.githubusercontent.com/mshafrir/2646763/raw/f2a89b57193e71010386a73976df92d32221d7ba/states_hash.json",0)
r.send()
var o=r.responseText,m=prompt(),a=m
o=JSON.parse(o)
for(var i in o)if(o[i].toLowerCase()==m.toLowerCase())a=i
alert(a)

Yay for new things! (Stack Snippets)

This is a standard loophole and standard loopholes apply without having to be mentioned explicitly.

@IngoBürk I don't believe this falls under the standard loopholes... It's getting the required data from the internet in the same way as reading fron a file.

So is eval(open('a.txt')) also valid? If you use a file of any kind, you must also include that file and its file name in your character count. (This isn't code golf, so it actually doesn't really matter in this case anyway.)

@Doorknob Since you raise the point that this isn't code golf, I don't see why I'm getting downvotes... I haven't violated any rules of pop cons.

@Doorknob But I do understand your point that if this was code golf, I'd be in the wrong for not including it in my byte count.

No reason to downvote, it's perfectly in the spirit of the question - favor novelty and utility - and fun

Golfscript - 750 653
The bulk is in the state names and abbreviations.
{.96>32*-}%.,2>{"ALABAMA,AL,ALASKA,AK,ARIZONA,AZ,ARKANSAS,AR,CALIFORNIA,CA,COLORADO,CO,CONNECTICUT,CT,DELAWARE,DE,FLORIDA,FL,GEORGIA,GA,HAWAII,HI,IDAHO,ID,ILLINOIS,IL,INDIANA,IN,IOWA,IA,KANSAS,KS,KENTUCKY,KY,LOUISIANA,LA,MAINE,ME,MARYLAND,MD,MASSACHUSETTS,MA,MICHIGAN,MI,MINNESOTA,MN,MISSISSIPPI,MS,MISSOURI,MO,MONTANA,MT,NEBRASKA,NE,NEVADA,NV,NEW HAMPSHIRE,NH,NEW JERSEY,NJ,NEW MEXICO,NM,NEW YORK,NY,NORTH CAROLINA,NC,NORTH DAKOTA,ND,OHIO,OH,OKLAHOMA,OK,OREGON,OR,PENNSYLVANIA,PA,RHODE ISLAND,RI,SOUTH CAROLINA,SC,SOUTH DAKOTA,SD,TENNESSEE,TN,TEXAS,TX,UTAH,UT,VERMONT,VT,VIRGINIA,VA,WASHINGTON,WA,WEST VIRGINIA,WV,WISCONSIN,WI,WYOMING,WY"","/.@?)=}{}if

Explanation:
{        }%                         Map this to every character in the input string:
 .96>32*-                             Subtract 32 from the ASCII value if it's from "a" onwards.
                                      This turns every lowercase letter into an uppercase letter.
           .,2>                     Check if the input length is greater than 2.
               {              }     If it is, they inputted the full name.
                "..."                 Our string is in the form "STATE NAME,STATE ABBREVIATION".
                     ","/             We split the string at every comma to turn it into an array.
                         .@?          Then we see where the input string is in the array...
                            )=        ...then we return the value right next to it.
                               {}   If not, they inputted the abbreviation.
                                      ...do nothing.
                                 if EndIf
                                    (implied) Print the abbreviation

Sorry, but I just don't see the point of taking my whole script and adding nothing but a few bytes of boilerplate; It simply brings nothing. But thanks for the credits I guess... Yours truly, "the other guy".

Sorry, troll entry. I know it's not a real entry.

Well, consider me trolled then ;)

@daniero Hey, at least I know it's possible to have regexes in Golfscript! That's actually the only reason I did that lol :p

bash + sed, 291 bytes
Shameless conversion of Daniero's Ruby solution to sed:
echo $*|tr a-z A-Z|sed -e\
"/\(.\).* \(.\).*/b1;/^\([CDGHKLPV]\).*\(.\)$/b1;/^\(.\).*\([ZVX]\).*/b1;\
/^\([NFOUW]\)\(.\).*/b1;/^\(.\)\([DNR]\).*/b1;/^\(.\).*\([LN]\)[LN].*/b1;\
/^\(.\).*SS\([AO]\).*/b1;/^\(.\).*\([ED])\)$/b1;/^\(.\).*[SNW]\(.\).*/b1;\
/\(.\)\(.\).*/b1;:1 s//\1\2/"

authors: Даниил Анисимов


text:
GPS: Golfed Positioning System
Your mission, should you choose to accept it, is to write code for a GPS receiver.
Input

The current time, as nanoseconds from the Unix epoch. [EDIT: This is optional, please state whether you require it]
Four satellite signals, in the following format:

The time the signal was sent, as nanoseconds from the Unix epoch. You must be able to handle dates up to and including 2020.
The location of the satellite, as Cartesian coordinates, in metres. You must be able to handle values that fit into a signed 32-bit integer (-2,147,483,648 to 2,147,483,647). Only integer coordinates will be given. You may assume valid input (i.e. your position can be calculated)

Input can be provided from command-line arguments, standard input or equivalent, but not from a variable. The input can have any separator characters in it; please specify what your input format is.
Output
The coordinates of your receiver, to the nearest 1000 metres, using 299,792,458 m/s as the speed of light. Again, I will be lenient with the output format: any separators are acceptable.
Example
Input
1412349052664203400
[1412349052692915310,2267943, 13318342, 0]
[1412349052698278110,-3757960, 3500627, 0]
[1412349052691548521,4425976, -1533193, 3469445]
[1412349052687888295,10622179, 11246951, 84184]

Output
(6223615, 5673496, 0)

I have made a GeoGebra notebook for this example. Please excuse my extremely sloppy GeoGebra skills.
How GPS Works
Because the speed of light is finite, there will be a difference between your current time and the time the satellite sent the signal.

Use the difference to calculate the distance to the satellite, d.
You are clearly located somewhere on the surface of a sphere, centered on the satellite, with radius d.
Once you have two satellites and two spheres, you have to be located somewhere on the intersection of the two sphere surfaces, which is a circle.
Adding another satellite reduces the possible positions to just two points, where all three sphere surfaces intersect.
The fourth satellite allows you to decide on a specific one of these points. Your task is to calculate the location of this point, where all four spheres intersect. Since you assume valid input, such a point does exist.

Rules

Standard loopholes are banned.

I have two programs written from testing, but neither are anywhere close to golfed solutions :D Hopefully I'll submit one in the next few days.

Why not one more satellite but without the current time? Normally you do not have a perfectly synced timer on your GPS.

@flawr Does that work? Thanks, but I won't change it now

Thats the way it does works=) At the moment I am still getting 1.0e+006 *(6.2236,5.6735,0.0002) not sure whats wrong...

I tried a few different methods now but all result in about 200 to 300m off in the z coordinate.

PS: Should we count bytes as score?

@professorfish actually 4 satellites is enough without prior knowledge of the time. There will only be one consistent solution for time and position together (or put another way, only one time that lets you get a consistent solution for position). This is more-or-less how GPS time transfer works.

@hobbs Also true. I'll add a rule that your solution doesn't need to take time if it doesn't want to

@flawr Yes, score is in bytes

MatLab/Octave (164)
I assumed the values to be saved in variables. As I said the posed problem seems to result in something about 200 to 300m off in the z coordinate compared to the given solution so this entry does not work within the 100m precision assuming the given test case is correct.
How it works
You can interpret your position as the intersectionpoint of four spheres, since you can calculate the distance to each sattelite by the runtime. The points [x,y,z] on a sphere with center [x,y,z] and radius r can be written as an equation (so 4 satelites = 4 equations):
(x-x0)^2 + (y-y0)^2 + (z-z0)^2 = r^2

Or when expanded / transformed:
-2*x0*x -2*y0*y -2*z0*z = r^2 - x0^2 - y0^2 - z0^2 - x^2 - y^2 - z^2

As you have 4 equations that look like that you can substract one from the other three, which eliminates the x^2+y^2+z^2 and get a system of 3 linear equations that can easily be solved for x,y,z.
But 3 intersecting spheres would result in two possible points, so a fourth is only needed for choosing the right one of those two points. But if the intersectionpoint of the first three is not exactly on the fourth sphere you cannot get an accurate answer.
Normally for gps you have the earth as fourth sphere, so three satelites could give you a line on which your current position must be (when the current exact time is unknonw). The line intersected with the earth surface results in only two possible points. So by comparing the different timestamps you could estimate on which side of the earth you are.
Code
%input
1412349052664203400

[1412349052692915310,2267943, 13318342, 0;
1412349052698278110,-3757960, 3500627, 0;
1412349052691548521,4425976, -1533193, 3469445;
1412349052687888295,10622179, 11246951, 84184]

%actual code
t=input('');d=input('');
c=299792458e-9;
p=d(:,2:4);
r=(d(:,1)-t)*c;
o=ones(3,1);
q=p(1:3,:)-o*p(4,:);
b=p(1:3,:).^2-o*p(4,:).^2;
s=r(1:3).^2-o*r(4).^2;
(-2*q)\(s-sum(b,2))

Output:
  1.0e+006 *

   6.223565252948585
   5.673559409007432
   0.000291267494418

"Input can be provided from command-line arguments, standard input or equivalent, but not from a variable": is there as specific limitation of Mathlab, not having any way to do input?

MATLAB can receive command-line input from the input command, which includes input in the form of matrices and arrays. Also, submissions should produce output with disp or fprintf rather than omitting the trailing semicolon, since omitting the semicolon adds <variable> = or ans = .

What does MatLab/Octave mean? Will the code run in both? Only Octave?

@professorfish Octave is the open source version of MATLAB. Generally any MATLAB program should work on Octave.

I changed it now, since I did not know about the input function. @professorfish Octave is basically the opensource clone of matlab, while it is slower in some cases, it does provide some different functoins or shorter commands like a*=b instead a=a*b but there are also some functionalities that are not available in octave. But the basics are the same.

@flawr I'm downloading Octave for Cygwin - I'll test your solution when the download finishes

@professorfish You do not need to, there are many online interpreters!

@flawr Ok, I've tested it, it works. Thanks


text:
Factor a polynomial over a finite field or the integers
Without using any built-in factoring/polynomial functions, factor a polynomial completely into irreducibles over the integers or a finite field.
Input
Your program/function will receive some prime (or zero) number n as input. The field/ring is the finite field of that order (ie Z/nZ), or just Z if n is 0. Your program may fail if n is not 0 or a prime. The polynomial will be in F[x].
Your program/function will also receive the polynomial as input.
There is some flexibility in the input, be sure to specify how you intend to receive input. For example, the polynomial could be input as a list of coefficients, or in the form most people expect (ex:50x^3 + x^2), or some other reasonable form. Or the format of inputting the field/ring could also be different.
Output
Your program/function will output the polynomial factored completely. You may leave multiple roots expanded (ie (x + 1)(x + 1) instead of (x + 1)^2). You may remove whitespace between binary operators. You may replace juxtaposition with *. You may insert whitespace in weird places. You may reorder the factors into whatever order you want. The x term could just be (x). x can be written as x^1; however the constant term may not have x^0. Extraneous + signs are allowable. You may not have a term with a 0 in front, they must be left out. The leading term of each factor must be positive, negative signs must be outside.
Test cases, your program should be able to produce output for each of these in reasonable time (say, <= 2 hours):
Input: 2, x^3 + x^2 + x + 1
Output: (x + 1)^3
Input: 0, x^3 + x^2 + x + 1
Output: (x + 1)(x^2 + 1)
Input: 0, 6x^4 – 11x^3 + 8x^2 – 33x – 30
Output: (3x + 2)(2x - 5)(x^2 + 3)
Input: 5, x^4 + 4x^3 + 4x^2 + x
Output: x(x + 4)(x + 4)(x + 1)
Input: 0, x^5 + 5x^3 + x^2 + 4x + 1
Output: (x^3 + 4x + 1)(x^2 + 1)
Special thanks to Peter Taylor for critiquing my test cases

I think this is giving me a flashback to some of the harder undergraduate maths.  Am I even heading in the right direction here?

This reminds me of the time I had nightmares trying to print polynomials correctly...

Sorry that I did not understand, but what is the first input number supposed to do ? or how does it affects the output ?

@Optimizer The first input number determines what field/the integers you are working over. If the number is nonzero, you are working over the finite field of that order. A finite field of order p has the elements {0, 1, ... , p-1} and it is under addition/multiplication mod p. Basically, reduce any coefficient by mod p and you're good. Also, note that if it has a root, ie linear factor, one of {0, ... , p-1} will produce 0 (mod p) when it is plugged into the polynomial.

How does 0, 6x^4 – 11x^3 + 8x^2 – 33x – 30 work then ?

@Optimizer That means we are working over the integers, which we are much more familiar with. If it factors, then it is the product of two integer-coefficient polynomials. BTW, I just gave you a brief preview of field-theory, you should definitely go and learn it.

You don't understand my question. What I meant was that even without the first input, all the examples' answers won't change at all. Or will they ?

@Optimizer 1st example vs 2nd example, x^2 + 1 doesn't factor into (x + 1)^2 over the integers, but it does over the finite field of order 2.

Could you prehaps restrict it to just the finite fields Z/nZ? I just thought factoring polynomials in (Z/nZ)[x] is quite a bit different from factoring in Z[x] or am I missing something? And I'd also limit the size of the polynomials, since it can be pretty difficult to factor polynomials of arbitrary degrees.

@flawr I considered doing that restriction, but Peter Taylor requested that I leave this. And there is an algorithm for factoring over Z/nZ that doesn't work over Z, but there is an algorithm that works for Z which can also be made to work for Z/nZ. How would arbitrary degrees make it terribly hard? I think it's fine.

@flawr, the standard approach to factoring over Z is to factor over Z/pZ for a suitable p and then Hensel lift. However, the golfable approach is probably (and this is certainly the route I'm looking at) to use a simple bound on the height of the factors and brute force it.

@PeterTaylor Yes that's pushing it a little bit too much. "You may not have a term with a 0 in front". I guess x^1 and s okay, and 1x is also okay. I'm thinking though, the biggest part of this challenge should be factoring, so I don't want to restrict output that much, so I'll allow the extraneous +s.

GolfScript (222 bytes)
~.@:q@.0\{abs+}/2@,2/)?*or:^{\1$^base{^q- 2/-}%.0=1=1$0=q>+{{:D[1$.,2$,-)0:e;{.0=0D=%e|:e;(D(@\/:x@@[{x*~)}%\]zip{{+}*q!!{q%}*}%}*e+])0-{;0}{@;@\D.}if}do}*;\).^3$,)2/?<}do;][[1]]-{'('\.,:x;{.`'+'\+'x^'x(:x+x!!*+\!!*}%')'}/

Online demo
Notes

The input format is n followed by a GolfScript array of coefficients from most to least significant. E.g. 0, x^5 + 5x^3 + x^2 + 4x + 1 should be formatted as 0 [1 0 5 1 4 1].
Over a finite field, there are only finitely many polynomials of sufficiently small degree to be relevant. However, this is not the case over Z. I handle Z by using a relaxed form of Mignotte's height bound. A great paper on height bounds in factoring is Bounds on Factors in Z[x], John Abbott, 2009 (link is to arxiv preprint; his CV says that it has been accepted by the Journal of Symbolic Computation). The most relaxed form given there is in terms of the L-2 norm, but to save bytes I relax further and use the L-1 norm instead. Then it's a case of brute forcing by trial division.
Over a finite field, every polynomial is a constant times a monic polynomial, so I only do trial division by monic polynomials and save a reciprocal in the field. However, Z is only a ring and so it's necessary to do trial division by non-monic candidate factors. I manage to get away with not implementing rational numbers by doing a leading factor division test and accumulating an "error" flag in e.
Both points 2 and 3 imply that the case of factoring over Z is generally slower, and can't be tested with the online demo. However, the slowest of the official test cases takes 10 minutes, which is well within the "reasonable" time limit.


text:
Sierpinski Layers
Starting with /\ you can create a Sierpinski triangle like pattern by adding a line beneath such that...

Any loose branch / or \ splits again into two branches: /\.
Any collision of branches \/ dies with nothing (but spaces) under it.

Repeating these rules yields
     /\
    /\/\
   /\  /\
  /\/\/\/\
 /\      /\
/\/\    /\/\
etc...

(Inspiration by ViHart)
Write a program or function that takes in a positive integer N and prints the first N lines of this pattern to stdout, with no more leading or trailing spaces than necessary.
For example, if the input is 1 the output must be
/\

If the input is 2 the output must be
 /\
/\/\

If the input is 8 the output must be
       /\
      /\/\
     /\  /\
    /\/\/\/\
   /\      /\
  /\/\    /\/\
 /\  /\  /\  /\
/\/\/\/\/\/\/\/\

And so on.
The code with the fewest bytes wins.

Can you please make it "fewest bytes" to avoid code compression shenanigans?

@xnor Changed .

I was literally about to post this. Meanie. :/

Where's the APL answer?

GolfScript (42 bytes)
~,-1%1\{' '*\.2base{'  /\\'2/=}%n@.2*^}/;;

Online demo
This exploits a well-known relationship between Pascal's triangle and the Sierpinski triangle.

CJam, 48 46 bytes
li(_S*"/\\":T+\{_N@S+TW%/S2**" /"/"\ "f/:+T*}*

Simple recursive approach based on observations  1 and 2 in the question.
Try it online.
How it works
li(         " L := int(input()) - 1            ";
_S*         " A := L * ' '                     ";
"/\\":T+    " A += (T := '/\')                 ";
\{          " do L times:                      ";
  _N        "   push A, '\n'                   ";
  @S+       "   A += ' '                       ";
  TW%/      "   B := A.split(reverse(T))       ";
  S2**      "   A := '  '.join(B)              ";
  " /"/     "   B := A.split(' /')             ";
  "\ "f/    "   C := { X.split('\ ') : X ∊ B } ";
  :+T*      "   A := T.join(sum(C, []))        ";
}*          "                                  ";

CJam, 51 bytes
li__2mL,1a\{2_@##)1$f*+}/<f{2b_"  /\\"2/f=@@,-S*\N}

I like this approach better, but it can't compete with the recursive one. Even after eliminating 2mL (which results in at least O(2n) execution time), I'm still at 48 bytes...
This approach encodes /\'s as 1's and double spaces between them as 0's. Considering the resulting arrays binary numbers, we see that the configuration of the nth row corresponds to the nth integer larger than 1 that can be expressed as a product of different Fermat numbers (integers of the form 22k+1).
How it works
li__2mL,1a         " push L := int(input()), L, R := range(log(L)/log(2)), A := [1] ";
\{2_@##)1$f*+}/    " for I in R: A += { a × 2**(2**I) : a ∊ A }                     ";
<                  " A := A[:L]                                                     ";
f{                 " for I in R: push L, I                                          ";
  2b_"  /\\"2/     "   push (B := base(I, 2)), B, S := [ '  ' '/\' ]                ";
  f=               "   for J in I: J := S[J]                                        ";
  @@,-S*\N         "   push (L - len(B)) * ' ', J, '\n'                             ";
}                  "                                                                ";

Python 2 - 140 139 127 122 121 118 116
N=input()
b,V,m,n=' V/\\'
s=b*~-N+m+n
R=str.replace
while N:print s;N-=1;s=R(R(R(R(s+b,b+m,V),n+b,V),n+m,b+b),V,m+n)

Based on temporary string replacements (https://stackoverflow.com/a/8687380/3419103):

/ > V
\ > V
\/ > __ (2 spaces)
V > /\

b*(N-1)+m+n could be b*~-N+m+n

@FryAmTheEggman: Awesome! Now I got you, JavaScript! ;)

Javascript - 117 bytes
Minified:
T=n=>{S=' '.repeat(n-1);a='/\\';for(t=s=S+a+S;--n;t+='\n'+s)s=s.replace(/\\\//g,'  ').replace(/ \/|\\ /g,a);return t}

Expanded:
T = n => {
    S = ' '.repeat( n-1 );
    a = '/\\';
    for( t = s = S + a + S; --n; t += '\n' + s )
        s = s.replace( /\\\//g, '  ' ).replace( / \/|\\ /g, a );

    return t;
}

Sample Output (for n = 20):
                   /\
                  /\/\
                 /\  /\
                /\/\/\/\
               /\      /\
              /\/\    /\/\
             /\  /\  /\  /\
            /\/\/\/\/\/\/\/\
           /\              /\
          /\/\            /\/\
         /\  /\          /\  /\
        /\/\/\/\        /\/\/\/\
       /\      /\      /\      /\
      /\/\    /\/\    /\/\    /\/\
     /\  /\  /\  /\  /\  /\  /\  /\
    /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
   /\                              /\
  /\/\                            /\/\
 /\  /\                          /\  /\
/\/\/\/\                        /\/\/\/\

Now if only the repeat and replace function names weren't so long. :P

Haskell, 128 112
g n=unlines$take n$i t([1..n]>>" ")%(i(\l->l++l%i(t.t)(t l>>"  ")%l)["/\\"]!!n)
t=tail
(%)=zipWith(++)
i=iterate

If I count the characters I get 128 - also you forgot to import Data.List (since you used unlines), which brings it up to 145

@Flonk unlines is in the prelude.

Oops, maybe I should have looked that up before commenting. My bad!

Pyth, 45 bytes
K"/\\"Jt+*QdKVQpbJ=JjKsmcd"\ "cj*2dc+Jd_K" /"

Example run
$ pyth -c 'K"/\\"Jt+*QdKVQpbJ=JjKsmcd"\ "cj*2dc+Jd_K" /"' <<< 16
               /\
              /\/\
             /\  /\
            /\/\/\/\
           /\      /\
          /\/\    /\/\
         /\  /\  /\  /\
        /\/\/\/\/\/\/\/\
       /\              /\
      /\/\            /\/\
     /\  /\          /\  /\
    /\/\/\/\        /\/\/\/\
   /\      /\      /\      /\
  /\/\    /\/\    /\/\    /\/\
 /\  /\  /\  /\  /\  /\  /\  /\
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\

How it works
                            # Q = eval(input())
K"/\\"                      # K = "/\\"
      Jt+*QdK               # J = (Q * " " + K)[1:]
             VQ             # for N in range(Q):
               pbJ          #     print(J, end="\n")
                            #
=JjK                        #     J = K.join(
    sm                      #         sum(list(map(lambda d:
      cd"\ "                #             d.split("\ "),
            c               #                                                .split(    )
             j*2d           #              " ".join(                        )
                 c   _K     #                                .split(K[::-1])
                  +Jd       #                       (J + " ")
                       " /" #                                                       " /"
                            #     ))))

Ruby, 90
f=->n{a=["/\\".center(2*n)]
2.upto(n){a<<a[-1].gsub("\\/","  ").gsub(/ \/|\\ /,"/\\")}
puts a}

Explanation

Input is taken as an argument to a lambda. It is expected to be an Integer.
Use String#center to create a String "/\" with n - 2 spaces on each side and put it into an Array (a).
Add to a the last element of a with every occurrence of "\/" replaced with "  " and every occurrence of " /" or " \" replaced with "/\".
Use puts to print each element in a on its own line.

JavaScript (E6) 107 106
Edit: fixed byte count, made recursive.
Not much different from the other JS answer ... at least this one 'prints' the pattern as requested.
The core is replacing ' /' '\ ' with '/\' and all the rest with '  ' on each new line.
F=(n,o=t='/\\',b=' ')=>
  n--&&
    console.log(b.repeat(n)+o)|
    F(n,(b+o+b).replace(/../g,s=>s==b+b|s=='\\/'?b+b:t))

Test In FireFox/FireBug console
F(15)

Output
                  /\
                 /\/\
                /\  /\
               /\/\/\/\
              /\      /\
             /\/\    /\/\
            /\  /\  /\  /\
           /\/\/\/\/\/\/\/\
          /\              /\
         /\/\            /\/\
        /\  /\          /\  /\
       /\/\/\/\        /\/\/\/\
      /\      /\      /\      /\
     /\/\    /\/\    /\/\    /\/\
    /\  /\  /\  /\  /\  /\  /\  /\

Perl 5 - 56 bytes
\0's can be replaced by actual null byte characters
#!/usr/bin/perl -l
$p="/\\";$_=$"x~$_.$p,y/\0/ /,print,$p^="\0\0$p"for-<>..-1

It is using the fact that if you ignore leading spaces and represent '/\' as 1 and '  ' as 0 the pattern in a given row f(n) = f(n-1) ^ (f(n-1) << 1). However the calculations in the code above are executed on strings that are close to the expected output (no leading spaces, other spaces replaced by null bytes) thanks to perl's bitwise string manipulation.
$p="/\\";          # initialize
  $_=$"x~$_.$p,    # loop start, add spaces
  y/\0/ /,         # replace nulls with spaces
  print,           # output
  $p^="\0\0$p"     # calculate next string
for-<>..-1         # loop from -n to -1

Python 2, 84 bytes
n=i=input()
while i:print' '*i+''.join("/ \ "[j&i+1>0::2]for j in range(n-i+1));i-=1

Mathematica, 86 bytes
Column[Row/@Mod[Table[Binomial[n,k],{n,0,#-1},{k,0,n}],2]/.{1->"/\\",0->"  "},Center]&

Javascript with lambdas, 141 128
141
f=n=>{for(a="25",q=0;++q<n;a=a[r='replace'](/^|$/mg,1)[r](/(.*)$/,"$1\n$1")[r](/..(?=.*$)/g,x=>x%3?11:25));return a[r](/./g,x=>"  /  \\"[x])}

128
f=n=>(t=a=>--n?t(a[r='replace'](/^|$/mg,1)[r](/(.*)$/,"$1\n$1")[r](/..(?=.*$)/g,x=>x%3?11:25)):a)("25")[r](/./g,x=>"  /  \\"[x])

Can be tested at Firefox (n=16):
               /\
              /\/\
             /\  /\
            /\/\/\/\
           /\      /\
          /\/\    /\/\
         /\  /\  /\  /\
        /\/\/\/\/\/\/\/\
       /\              /\
      /\/\            /\/\
     /\  /\          /\  /\
    /\/\/\/\        /\/\/\/\
   /\      /\      /\      /\
  /\/\    /\/\    /\/\    /\/\
 /\  /\  /\  /\  /\  /\  /\  /\
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\

Python 2, 97 bytes
i=input()
x=1
while i:i-=1;print " "*i+bin(x)[2:].replace("0","  ").replace("1", "/\\");x^=2*x

Welcome to Programming Puzzles & Code Golf! Nice answer :D