text:
Dimensional Analysis
Calculate a product or ratio of SI units.
For example, kg m / s s (kilogram-meter per second squared) should return N (newton).
The input will always be either:

A list of symbols for SI units, space-separated (representing a product) or
The above, /, and the above (representing a ratio).

The input will never contain any other characters (such as numeric literals or other punctuation).
You may assume that this will always equal a single SI unit.
Use the following symbols:
Base quantities:
s               # second
m               # meter
kg              # kilogram
A               # ampere

Derived quantities:
N  = kg m / s s # newton
J  = N m        # joule
W  = J / s      # watt
Hz = W / J      # hertz
Pa = N / m m    # pascal
C  = s A        # coulomb
V  = J / C      # volt
F  = C / V      # farad
Ω  = V / A      # ohm      (you may use the O symbol instead, for a penalty of +3 bytes)
S  = A / V      # siemens
Wb = J / A      # weber
T  = Wb / m m   # tesla
H  = Wb / A     # henry

Examples:
m            => m
N m          => J
J / W        => s
A J / W      => C
T m m        => Wb
N / A m      => T
V s / A      => H
J S / F A    => V
s / s s      => Hz
Hz kg m Hz   => N
Hz s / Ω     => S
Wb / H       => A
V Pa S s / C => Pa
N s / m Hz   => kg
V A          => W
s / Ω        => F
J / A s A    => Ω

Shortest code (in bytes) wins.

kg m / s s would actually be kilogam-meter-seconds per second, or just kilogram-meters. Multiplication and division work LTR. What you are looking for is kg m / (s s). This also applies to the other examples.

@Legion: Not necessarily. Implicit multiplication and division with the slash are ambiguous; the ordr depends on convention. Here implicit multiplication is taken to have a higher precedence than division.

...that breaks about all of mathematics. Implicit and explicit multiplication mean the exact same thing.

@LegionMammal978 Not really. Does 1 / 2x really mean x / 2?

@Ypnypn No, it means (1 / 2)x or x / 2.

@LegionMammal978 - actually, 1/2x is common notation for 1/(2x). More generally, where it's not ambiguous, the slash would be interpreted as the dividing line between numerator and denominator. The convention being used here is fine - especially because this convention is standard in units. kg/ms means kg/(m*s) when written as a unit. Take it from a guy with a PhD in Maths.

No Mathematica answer yet? Disappointed.

@Kroltan It can't understand the funny notation

@LegionMammal978 Me neither, but it is hilarious at how many builtins for this sort of thing exist in the language :P

CJam, 184 105 98 96 bytes
00000000: 22 73 20 6d 20 6b 67 41 20 4e 20 4a 20 57 20 48  "s m kgA N J W H
00000010: 7a 50 61 43 20 56 20 46 20 ce a9 53 20 57 62 54  zPaC V F ..S WbT
00000020: 20 48 22 32 2f 53 66 2d 22 d6 9c 64 c6 a1 24 a4   H"2/Sf-"..d..$.
00000030: 4b f9 1c 4a 57 f4 61 79 31 ed 82 34 22 33 31 38  K..JW.ay1..4"318
00000040: 62 35 62 32 66 6d 34 2f 6c 53 25 32 24 32 24 65  b5b2fm4/lS%2$2$e
00000050: 72 22 2f 22 61 2f 3a 3a 2e 2b 3a 2e 2d 61 23 3d  r"/"a/::.+:.-a#=

The above is a hexdump; it can be reversed with xxd -r.
Verify all test cases at once in the CJam interpreter. 1
Test run
$ LANG=en_US
$ cjam si.cjam <<< 'Hz s / Ω'; echo
S
$ cjam si.cjam <<< 'J / A s A'; echo
Ω

Idea
We can encode each unit u = sa mb kgc Ad as the vector tu = (a + c - d, b, c, d). 2
This way, for the input u1 … un / v1 … vm, we only have to calculate (tu1 + … + tun) - (tv1 + … + tvm) and check which unit it corresponds to.
Code
"s m kgA N J W HzPaC V F Î©S WbT H"

2/     e# Split the string into chunks of length 2.
Sf-    e# Remove all spaces (if any) from each chunk.

"ÖdÆ¡$¤KùJWôay1í4"

318b   e# Convert from base 318 to integer.
5b     e# Convert from integer to base 5.
2fm    e# Subtract 2 from each base-5 digit.
4/     e# Split into chunks of length 4.
lS%    e# Read one line of input sand split it at spaces.
2$2$   e# Copy the unit names and the vector table.
er     e# Perform transliteration.
"/"a/  e# Split at "/".
::.+   e# Add the vectors of numerator and denominator (if any).
:.-    e# Subtract the resulting sums (or leave a single sum untouched).
a#     e# Find the index of the resulting vector in the vector table.
=      e# Retrieve the corresponding unit.

1 Note that, due to limitations of the online interpreter, I cannot use a different encoding for source code and I/O. Therefore, the symbol Ω shows up as its UTF-8 encoding (Î©). The official Java interpreter does not share this limitation.
2 This saves a few bytes over the straightforward mapping to (a, b, c, d), since it shortens the range of the first coordinate.

GNU sed, 1118
Way too long but gets the job done.
Score includes +1 for -r option to sed.  As if it matters here.  Score excludes comments.
### convert 2-letter units to 1-letter substitutes
s/kg/k/g
s/Hz/z/g
s/Pa/P/g
s/Wb/b/g
### remove spaces
s/ //g
### start label for main loop to render all in terms of base units
:
### convert N in denominator to s s / kg m
s|/(.*)N|ss/\1km|;t
### convert N in numerator to kg m / ss
s|N(.*)/|\1km/ss|;t
### convert N in non-rational to kg m / ss
s|N(.*)|\1km/ss|;t
### ... etc for all other derived units
s|/(.*)J|ss/\1kmm|;t
s|J(.*)/|\1kmm/ss|;t
s|J(.*)|\1kmm/ss|;t
s|/(.*)W|sss/\1kmm|;t
s|W(.*)/|\1kmm/sss|;t
s|W(.*)|\1kmm/sss|;t
s|/(.*)z|s/\1|;t
s|z(.*)/|\1/s|;t
s|z(.*)|\1/s|;t
s|/(.*)P|mss/\1k|;t
s|P(.*)/|\1k/mss|;t
s|P(.*)|\1k/mss|;t
s|C|sA|;t
s|/(.*)V|sssA/\1kmm|;t
s|V(.*)/|\1kmm/sssA|;t
s|V(.*)|\1kmm/sssA|;t
s|/(.*)F|kmm/\1ssssAA|;t
s|F(.*)/|\1ssssAA/kmm|;t
s|F(.*)|\1ssssAA/kmm|;t
s|/(.*)Ω|sssAA/\1kmm|;t
s|Ω(.*)/|\1kmm/sssAA|;t
s|Ω(.*)|\1kmm/sssAA|;t
s|/(.*)S|kmm/\1sssAA|;t
s|S(.*)/|\1sssAA/kmm|;t
s|S(.*)|\1sssAA/kmm|;t
s|/(.*)b|ssA/\1kmm|;t
s|b(.*)/|\1kmm/ssA|;t
s|b(.*)|\1kmm/ssA|;t
s|/(.*)T|ssA/\1k|;t
s|T(.*)/|\1k/ssA|;t
s|T(.*)|\1k/ssA|;t
s|/(.*)H|ssAA/\1kmm|;t
s|H(.*)/|\1kmm/ssAA|;t
s|H(.*)|\1kmm/ssAA|;t
### cancel out any units appearing in both numerator and denominator
s|(.)(.*/.*)\1|\2|;t
### remove trailing slash when rational cancels down to non-rational
s|/$||
### sort numerator and denominator kg > m > s > A
:A;s|([^/A])A|A\1|;tA
:s;s|([^/s])s|s\1|;ts
:m;s|([^/m])m|m\1|;tm
:k;s|([^/k])k|k\1|;tk
### Final replacements back to derived units
s|kmm/sssAA|Ω|
s|kmm/sssA|V|
s|kmm/sss|W|
s|kmm/ssAA|H|
s|kmm/ssA|Wb|
s|kmm/ss|J|
s|km/ss|N|
s|k/mss|Pa|
s|k/ssA|T|
s|/s|Hz|
s|ssssAA/kmm|F|
s|sssAA/kmm|S|
s|sA|C|
s/k/kg/

Javascript ES6, 479 bytes
f=(s,b="s, m, gk, A, gkm,ss gkmm,ss gkmm,sss gkmm,AAss gk,mss As, gkmm,Asss AAssss,gkmm gkmm,AAsss AAsss,gkmm gkmm,Ass gk,Ass ,s".split` `,d="s m kgA N J W H PaC V F Ω S WbT Hz",p=s.split` / `.map(i=>i.split` `.map(i=>b[d.indexOf(i)/2].split`,`).reduce((p,c)=>(p[0]+=c[0],p[1]+=c[1],p),[[],[]])))=>(p[1]&&(p[0][0]+=p[1][1],p[0][1]+=p[1][0]),[x,y]=p[0].map(i=>[...i].sort().join``),d.match(/../g)[b.indexOf([...x].reduce((p,c)=>(y==(n=y.replace(c,""))&&(p+=c),y=n,p),"")+","+y)])

Ungolfed:
f=(s,                                              // define function, accept string to calculate
                                                   // vvv derived quantities reduced to base quantities in the form of <numerator>,<denominator>
   b="s, m, gk, A, gkm,ss gkmm,ss gkmm,sss gkmm,AAss gk,mss As, gkmm,Asss AAssss,gkmm gkmm,AAsss AAsss,gkmm gkmm,Ass gk,Ass ,s".split` `,
   d="s m kgA N J W H PaC V F Ω S WbT Hz",         // symbols list
   p=s.split` / `                                  // split input into [numerator,denominator]
      .map(i=>i.split` `                           // split numerator and denominator strings into list of symbols
               .map(i=>b[d.indexOf(i)/2].split`,`) // convert symbols to their base quantities
               .reduce((p,c)=>(p[0]+=c[0],p[1]+=c[1],p),[[],[]])) // consolidate base quantities
  )=>(
    p[1]&&(p[0][0]+=p[1][1],p[0][1]+=p[1][0]),     // if input was in form of numerator / denominator, reduce to numerator / 1
    [x,y]=p[0].map(i=>[...i].sort().join``),       // sort base quantities in numerator and denominator strings
    d.match(/../g)[b.indexOf(                      // derive symbol from base quantities
        [...x].reduce((p,c)=>(y==(n=y.replace(c,""))&&(p+=c),y=n,p),"")+","+y // remove duplicate symbols from numerator and denominator
  )])

Test Runs:
>> ["m","N m","J / W","A J / W","T m m","N / A m","V s / A",
    "J S / F A","s / s s","Hz kg m Hz","Hz s / Ω","Wb / H",
    "V Pa S s / C","N s / m Hz","V A","s / Ω","J / A s A"]
     .forEach(i=>console.log((i+" ".repeat(12)).slice(0,12)+"  ->  "+f(i)))

<< m             ->  m
   N m           ->  J
   J / W         ->  s
   A J / W       ->  C
   T m m         ->  Wb
   N / A m       ->  T
   V s / A       ->  H
   J S / F A     ->  V
   s / s s       ->  Hz
   Hz kg m Hz    ->  N
   Hz s / Ω      ->  S
   Wb / H        ->  A
   V Pa S s / C  ->  Pa
   N s / m Hz    ->  kg
   V A           ->  W
   s / Ω         ->  F
   J / A s A     ->  Ω


text:
Simplify binary
Challenge
Given a binary number as input through any means, "simplify" the number using a full program or a function.
Input
[binary]

binary is a number in binary that is over 0.

Output
Take the input, convert it to base 10 without using a builtin, then if that number contains only 1s and 0s, convert it into a base 10 number as if it were another binary number. Repeat the process until the number cannot be read in binary and output that number.
Other information

If the input is 1, simply output 1. Your program should not go on infinitely simplifying 1.

This is code golf, so shortest answer in bytes by Tuesday (November 17th) wins.

If anything is confusing, leave a comment specifying what I need to clear up and I will edit it accordingly.

Builtins for base conversion are not allowed.

Examples
     Input | Output

         1 | 1
      1010 | 2
      1011 | 3
   1100100 | 4
   1100101 | 5
1111110011 | 3

Could use a couple test cases.

Is the input an ASCII string, or actually 1's and 0's?

@TomCarpenter 1s and 0s.

@isaacg Added ways to get 1-5 as output.

Are functions which convert a string to a given base allowed?

Are implicit base conversions allowed?  e.g. sprintf("%d",n); in c effectively converts n to a base 10 string

@isaacg No, unless you are simply turning the string into integers.

@DigitalTrauma If it is a builtin that performs base conversion, no.

@The_Basset_Hound To clarify Digital Trauma's question, is turning a number into its standard string representation, in base 10, allowed? I wouldn't consider it a base conversion, more of a typecast.

@isaacg That's fair.

Pyth, 20 16 bytes
u?-GTG`u+yNsTG0z

4 bytes thanks to Jakube
Half of the code (u+yNsTG0) is simply the base conversion code.
Test Suite
u?-GTG`u+yNsTG0z
                    z = input() (The string of 1s and 0s)
                    T = 10
u              z    Apply until the value stops changing, starting with z
                    G is the current value, a string of 0s and 1s.
 ?-GT               If G - T, e.g., G with the digits 1 and 0 removed is not empty,
     G              Return G, to end the iteration.
       u     G0     Else, reduce over G with initial value 0.
         yN         Double the running total
        +  sT       and add the next digit, cast to an int.
      `             Convert to string.

The input 1 is handled by the fact that u notices the value has stopped changing.

Congratulations, you outgolfed Dennis! For the moment...

@CᴏɴᴏʀO'Bʀɪᴇɴ The secret is Pyth.

CJam, 24 23 bytes
q{:~{1$++}*s__,(As*-!}g

Try it online in the CJam interpreter.
How it works
q                        Read all input.
 {                   }g  Do:
  :~                       Evaluate each character. Maps '0' -> 0 and '1' -> 1.
    {    }*                Fold; for each integer but the first:
     1$                      Copy the second-topmost integer.
       ++                    Add all three integers on the stack.
           s__             Cast to string and push two copies.
              ,(           Calculate string length and subtract 1.
                As         Push the string "10".
                  *        Repeat the string length-1 times.
                   -       Remove its elements from the string representation
                           of the integer.
                    !      Apply logical NOT.
                         If `!' pushed 1, repeat the loop.

Do you have to repeat the "10" string length-1 times, or could you skip the decrement?

Subtracting 1 from the length turns "10" into "" if the integer has a single digit. This makes sure the code doesn't get into an infinite loop.

Fascinating, captain. }:^|

Pip, 28 27 bytes
Ta=1|aRMta:$+(^a)*2**RV,#aa

Takes input as a command-line argument. We want to loop until a=1 or a contains some character(s) besides 0's and 1's. This latter condition is tested by RM'ing all characters in t = 10 from a. If there's anything left, the condition is truthy.
Inside the loop, the conversion works as follows:
a:$+(^a)*2**RV,#a

              ,#a  range(len(a))
            RV     reversed
         2**       2 to the power of each element
    (^a)*          multiplied item-wise with each digit in split(a)
  $+               Sum
a:                 and assign back to a

Putting a at the end auto-prints it.
A recursive solution in 28 bytes:
a<2|aRMt?a(f$+(^a)*2**RV,#a)

Python 2, 52
f=lambda n:n>1<'2'>max(`n`)and f(n%10+2*f(n/10))or n

It's easier to think of this as two recursive functions:
g=lambda n:n and n%10+2*g(n/10)
f=lambda n:n>1<'2'>max(`n`)and f(g(n))or n

The function g converts a decimal value to binary, and the function f applies g repeatedly is long as its argument is made of digits 0 and 1 ('2'>max(`n`)) and is not 1. The golfed code collapses them into a single function by inserting the definition of g(n) for f(n), replacing the recursive call to g with f. The base case of n=0 of g is automatically handled by the check n>1.

Nice :) The only thing is that the usual problem applies - the pesky L from repr...

Prolog, 220 212 bytes
:-use_module(library(clpfd)).
x(B,N):-reverse(B,C),foldl(y,C,0-0,_-N).
y(B,J-M,I-N):-B in 0..1,N#=M+B*2^J,I#=J+1.
b(N,I):-N>47,N<50,I is(N-48).
p(N):-N>1,number_codes(N,L),maplist(b,L,Y),x(Y,B),p(B);write(N).

Explanation
p is the main function and performs the following steps (with help from b,x,y):

checks if current number is bigger than 1
converts integer to list of ascii representations of digits
checks that all numbers are 0 or 1
converts ascii list to binary integer list
converts binary integer list to decimal number
recurses
prints when a predicate fails.

Edit: Saved 8 bytes by unifying the p-clauses with OR.

Mathematica 107 106
With a byte saved by DLosc.
j@d_:=(p=0;v=IntegerDigits@d;
Which[d<2,1,Complement[v,{0,1}]=={},j@Fold[#+#2 2^p++&,0,Reverse@v],1<2,d])

Break the input into its digits.
If the input is 1, output 1.
If the input is a number consisting of 0's and 1's, convert that to decimal and run it through again.
Otherwise, return the input.

j[1]

1

j[11010001]

209

j[1111110001]

1009

j[1111110011]

3

The first step yields 1011 which in turn yields 3.

Here we test starting with 1011.
j[1011]

3

Javascript, 132, 123 bytes
Well, it's not the best answer, but..
FYI, if an invalid input is given, it displays the same to the user.

function c(x){while(x!=0&&!/[2-9]/.test(x)){for(i=r=0;x;i++)r+=x%10*Math.pow(2,i),x=parseInt(x/10);x=r}alert(x)}c(prompt())

You could save 19 bytes by using forinstead of while and setting values directly in the statement (this also reduces some {}), discarding some ;, using ES6 function description, increment i inline. It'll look like this: c=x=>{for(r=0;x&&!/[2-9]/.test(x);x=r)for(i=0;x>0;r+=x%10*Math.pow(2,i++),x=parseInt(x/10));alert(x)};c(prompt()).

114: function c(x){while(x^0&&!/[2-9]/.test(x)){for(i=r=0;x;i++)r+=x%10*Math.pow(2,i),x=0|x/10;x=r}alert(x)}c(prompt())

@insertusernamehere, thanks for the suggestion, but I didn't understand the c=x=> at the start, didn't work on Chrome or Firefox console. :(
@ןnɟuɐɯɹɐןoɯ, could not wrap my head around the XOR condition and the x=0|x/10 instead of parseInt, I've incorporated the rest of the changes. Thanks..

@GauthamPJ I'm sorry, somehow the code got broken while copying and contained unprintable characters. Here's the correct version: c=x=>{for(r=0;x!=0&&!/[2-9]/.test(x);x=r)for(i=r=0;x;)r+=x%10*Math.pow(2,i++),x=parseInt(x/10);alert(x)};c(prompt()). It definitely runs in Firefox 42, try this fiddle. Note that this more golfed version and also your original code don't work for 1 and will run into an endless loop. c=x=> is like function c(x){} see "Arrow functions".

Mathematica, 62 59 55 48 bytes
Saved 7 bytes thanks to Martin Büttner.
#//.a_/;Max[b=IntegerDigits@a]<2:>Fold[#+##&,b]&

JavaScript ES6, 52
As a function. The function argument must be either a string of binary digits or a number whose decimal representation contains only 1 and 0.
Test running the snippet below in an EcmaScript 6 compliant browser - implementing arrow functions, template strings and spread operator (I use Firefox)

f=s=>s<2|[...s+''].some(c=>(n+=+c+n,c>1),n=0)?s:f(n)

// To test
console.log=(...x)=>O.innerHTML+=x+'\n';

// Basic test cases
;[[1,1],[1010,2],[1011,3],[1100100,4],[1100101,5],[1111110011,3]]
.forEach(t=>console.log(t[0]+' -> '+f(t[0])+' expected '+t[1]))

function longtest() {
  var o=[],i;
  for (i=1;i<1e6;i++)
    b=i.toString(2),v=f(b),v!=i?o.push(b+' '+v):0;
  O.innerHTML=o.join`\n`
}
Click to run the long test <button onclick="longtest()">go</button>

Really liking n+=+c+n for the binary conversion. So elegant...

, 37 chars / 54 bytes
↺;ï>1⅋(⬯+ï)ĉ/^[01]+$⌿);)ï=+('ᶀ'+ï);ôï

Try it here (Firefox only).
Not sure if the + operator counts as a built-in for binary conversion...

Javascript (ES7) 87 80 78 77 74 bytes
Snippet demo for supporting browsers (currently only Firefox nightly supports the exponential operator)

f=x=>[...x].reverse(i=y=j=0).map(z=>(j|=z,y+=z*2**i++))&&j<2&y>1?f(y+[]):x
<input type="text" id="x" value="1111110011"><button onclick="o.innerHTML=f(x.value)">Run</button>

f=x=>
[...x].reverse(i=y=j=0) // reverse string as array, initialize vars
.map(z=>( // iterate over the all chatacters
    j|=z, // keep track of whether a digit higher than 1 is encountered
    y+=z*2**i++ // build decimal result from binary
))&&
j<2&y>1? // if we encountered only 1's and 0's and result > 1
    f(y+[]) // then call recursively and cast to a string
    :x // else return x

Javascript (ES6) 81 bytes
Snippet demo for supporting browsers

f=x=>[...x].reverse(i=y=j=0).map(z=>y+=z*Math.pow(2,i++,j|=z))&&j<2&y>1?f(y+[]):x
<input type="text" id="x" value="1111110011"><button onclick="o.innerHTML=f(x.value)">Run</button>

Perl 6, 67 bytes
get,{$_=0;for $^a.comb {$_+<=1;$_+=$^b};$_}...1|/<-[01]>/;say $_//1

PHP, 210 204 bytes
It's my first time posting here, so hope you guys will like it ! Even if it's obviously not the best way to write it, I'm still glad to show it off here !
The Code
<?function j($a){$c=0;if($a==1){return 1;}else{if(preg_match("#^[01]+$#",$a)){$b=strlen($a);$a=str_split($a);foreach($a as$d){$c+=($d==0?0:2**($b-1));$b--;}return j($c);}else{return$a;}}}echo j($_GET[0]);

I've made a recursive function "j" that will first check if the input is equal to 1. If so, the function returns 1 as expected, else it'll split the number in an array to calculate the decimal value, but only if the number is a binary one. If it's not, it'll return the number as is.
Ungolfed code
<?
function j($a) {
  $c = 0;
  if ($a == 1) {
    return 1;
  }
  else {
    if (preg_match("#^[01]+$#", $a) {
      $b = strlen($a);
      $a = str_split($a);
      foreach ($a as $d) {
        $c += ($d == 0 ? 0 : 2 ** ($b - 1));
        $b--;
      }
      return j($c);
    }
    else {
      return $a;
    }
  }
}
echo j($_GET[0]);

I've used a "foreach" statement instead of my initial "for" one, allowing me a gain of 6 bytes but I'm pretty sure there's a lot more to do.

PHP, 114 112 bytes
also works for 0. Run with -r.
for($n=$argv[1];count_chars($s="$n",3)<2&$s>1;)for($i=$n=0;""<$c=$s[$i++];)$n+=$n+$c;echo$s;

count_chars($s,3) returns a string containing all characters from the string (like array_unique does for arrays). For binary numbers, this will be 0, 1 or 01. For other numbers, this will contain a digit larger than 1, so <2will return true only for binary numbers.
&$s>1 is needed for the special case 1.
The rest is straight forward: Loop through the bits with shifting the value and adding the current bit, finally copy the number (cast to string) to $s for the outer loop test.

CoffeeScript, 92 89 bytes
f=(x)->x>1&/^[01]+$/.test(x)&&f(''+x.split('').reverse().reduce ((p,v,i)->p+v*2**i),0)||x

JavaScript (ES6), 105 101 90 bytes
f=y=>y>1&/^[01]+$/.test(y)?f(''+[...y].reverse().reduce(((p,v,i)=>p+v*Math.pow(2,i)),0)):y

Demo
Only works in ES6-compliant browsers such as Firefox and Microsoft Edge

f=y=>y>1&/^[01]+$/.test(y)?f(''+[...y].reverse().reduce(((p,v,i)=>p+v*Math.pow(2,i)),0)):y

// Snippet stuff
$(`form`).submit((e) => {
  document.getElementById(`y`).textContent = f(document.getElementById(`x`).value);
  e.preventDefault()
})

<form>
  Input:
    <input pattern=^[01]+$ required id=x>

  <button type=submit>Go</button>

Output:
    <output id=y></output>

</form>

If you use eval, you might be able to pull off an implicit return.

5 bytes shorter with eval and anonymous functions

@ןnɟuɐɯɹɐןoɯ For some reason the eval'd function does not work with 1. because it doesn't enter the loop I assume

@nderscore Thanks, but recursion was 4 bytes shorter :-)

Scala, 128 bytes
def b(s:String):String=if(s.matches("[10]{2,}"))b(""+s.reverse.zipWithIndex.collect{case('1',i)=>Math.pow(2,i)}.sum.toInt)else s

Matlab (115)
@(a)num2str(sum((fliplr(a)-48).*arrayfun(@(x)2^x,0:nnz(a)-1)));a=ans(input('','s'));while(find(a<50))a=ans(a);end,a

The anonymous function is number type conversion (bin2dec)

source: Stack Exchange

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

sort: votes


text:
90° Self-Rotating Program
Introduction
Write a complete program that rotates a rectangular block of ASCII characters 90 degrees clockwise. When the program itself is rotated 90 degrees clockwise, it rotates a block of ASCII characters 90 counterclockwise.
Rules

You many not use built-ins that rotate or transpose matrices. For example, in MATLAB/Octave rot90 and the transpose operator ' are not allowed.
You must write a complete program that uses STDIN and STDOUT or the closest equivalent.
Your program must be rectangular and assume the input is also rectangular.
The input and output are a newline separated strings and will not have trailing newlines.

When run with its source code as input, your program must rotate itself 90 degrees clockwise. The output must be a second program in the same language that rotates its input 90 degrees counterclockwise. When the rotated program is given its source code as input, it should output the source code of the original program.
Note: Both programs must work for any input, not just their own source code, so a one character quine is not allowed.
Example
Say the following is a valid program that rotates its input 90 degrees in a hypothetical language ExampleLang.
^f a2% 3
lk (^_^&
       v
D8 $4  /

When run with itself as input, it outputs another valid program that rotates its input counterclockwise:
D l^
8 kf

$ (a
4 ^2
  _%
  ^
/v&3

This second program, when given to itself as input, outputs the original program. Note that the blank line should have four spaces and there is a trailing space on the second to last line that cannot be rendered in markdown. To clarify:
$ examplelang program < program > rotProg
$ examplelang rotProg < rotProg > program1
$ diff -s program program1
Files program and program1 are identical

Shortest program wins. Standard loopholes are banned.

CJam, 26 25 21 bytes
WqN/":.+""\%"(~+N-~N*

Thanks to @MartinBüttner for golfing off 4 bytes!
Try it online in the CJam interpreter: original program | rotated program
This is the rotated program:
W
q
N
/
"
:
.
+
"
"
\
%
"
(
~
+
N
-
~
N
*

Idea
We can rotate the input a quarter turn clockwise by splitting it at linefeeds, reversing the order of the resulting rows, transposing rows with columns, and finally joining the rows, separated by linefeeds.
Likewise, we can rotate counterclockwise by transposing first, then reversing the rows.
Since the transposition built-in z is forbidden, we can use :.+ (reduce by vectorized character or string-character concatenation) to achieve the same effect.
:.+ is the only part of the source code that cannot be broken up. We push the strings "W%" and ":.+", conditionally reverse them if the second string contains a linefeed, concatenate, remove all linefeeds, and evaluate the result.
Code
W     e# Push -1.
qN/   e# Read all input at split it at linefeeds.
":.+" e# Push a string that, when evaluated, transposes rows and columns.
      e# As explained in the previous section, this does NOT use a built-in
      e# for matrix transposition.
"\%"  e# Push a string that, when evaluated, reverses the rows.
(~    e# Shift out the first character and evaluate it.
      e# For the original code, this evaluates '\', swapping the strings on
      e# the stack. For the rotated code, this evaluates `\n', doing nothing.
+N-   e# Concatenate and remove linefeeds.
      e# The stack now contains:   -1 input "%:.+"   or   -1 input ":.+\%"
~     e# Evaluate the string on top of the stack.
N*    e# Join the resulting array, separating by linefeeds.

How is this so short? Seriously though, why can't :.+ be broken over several lines?

@intrepidcoder For syntactical reasons. The meaning of both : and . depends on the character after them, and linefeeds aren't valid after either of those (and even if they were, that would change the meaning of the program).

C (gcc), 1420 1399 463 bytes
Ah... the joy of strings of undetermined length!
Assumes sizeof(char*) == sizeof(int) and sizeof(char**) <= 16.
The new approach
char**L,*r;n,i//j=>]l n}q((
,j,q;R(l){for(//,l)l, +;;rr
r=l=0;(j=     //i=)[r +))oa
getchar())>10;//,r(r( *l(fh}
r[l++]=j,r[l]=//n(r,c=6=R)c;
0)r=realloc(r,//;rajoL1q()t)
l+2);l&&R((L= //roh=l(,,r"u)
realloc(L,++n*//*fc]l(Lro"p]
16))[n-1]=r,q=//,{t+aR(=f(;q
l);}main(){for//L)e+e&c]{sn[
(R();i<q;i++, //*lglr&o1)t<]
puts(""))for(j//*(=[=ll-(uj+
=n;j--;putchar//rRjrr;lnnp;+
(L[j][i]));}  //a;(;))a[i;0j
////////////////hq;002e)a-=[
////////////////c,01=+r)m-jL

Try it online!
Output of the above
The solution was embarrassingly easy in the end. You make one program A that rotates things clockwise, and one program B that rotates counter-clockwise:
A
char**L,*r;n,i,j,q;R(l){for(r=l=0;(j=getchar())>10;r[l++]=j,r[l]=0)r=realloc(r,l+2);l&&R((L=realloc(L,16*++n))[n-1]=r,q=l);}main(){for(R();i<q;i++,puts(""))for(j=n;j--;)putchar(L[j][i]);}

B
char**L,*r;n,i,j,q;R(l){for(r=l=0;(j=getchar())>10;r[l++]=j,r[l]=0)r=realloc(r,l+2);l&&R((L=realloc(L,16*++n))[n-1]=r,q=l);}main(){for(R();q--;puts(""))for(j=0;j<n;j++)putchar(L[j][q]);}

Make a rectangle of reasonable proportions and confine A to that, and put guards of comments around it:
char**L,*r;n,i//
,j,q;R(l){for(//
r=l=0;(j=     //
getchar())>10;//
r[l++]=j,r[l]=//
0)r=realloc(r,//
l+2);l&&R((L= //
realloc(L,++n*//
16))[n-1]=r,q=//
l);}main(){for//
(R();i<q;i++, //
puts(""))for(j//
=n;j--;putchar//
(L[j][i]));}  //
////////////////
////////////////

Confine program B to a square that is the same width as the one for A plus two (for the extra lines of comments at the bottom edge), rotate it CCW and slap it to the right of program A and you get the solution above.
The old approach
 /*                                       r                               c                                                         c                                                  r
r                                         a                               o                         n                               o                          s                       a
a                          r              h                               l                         i       r                       l             r      -     t        r  =    +      h         q
h                          o              c        0     +                l                         a       o             +         l       6     o      -     u    "   o  j<   +      c  */
char**L,*s,*r;n,i,q;R(l,c){for(r=l=0;(c=getchar())>10;r[l++]=c,r[l]=0)r=realloc(r,l+2);q=l?l:q;l=r;}main(j){for(;s=R();L[n++]=s)L=realloc(L,16*n);for(;i<q;i++,puts(""))for(j=n;j--;)putchar(L[j][i]);}
 ///                        //          //e////     /     /             //e////                      ///     //            /      //e////    /     //  //  //// ///  /   // ;/   /// //u////      /
 ///                        //          //g////     /     /             //r////                      ///     //            /      //r////    /     //  //  //// ///  /   // 0/   /// //p////      /

Try it online!
Output of the above

Python 3, 119 bytes
[print(*i[# "i  0:
::-1],sep#t " **(:
="")for i#n,=r[(n[]
in zip(* #iiponpe]]
open(0))]#r*efiip)1
#########[p(s) zo)-

Try it online!
rotated :
#oi=:[
#pn":p
#e "-r
#nz)1i
#(if]n
#0po,t
#)(rs(
#)* e*
#] ipi
[####[
print#
(*i,
sep=""
)for i
 in[*
zip(*
open(0
))][::
-1]]

Try it online!
How it works :
The code is coposed of 2 parts separed by comments :
1111111111#22222222
111111111#222222222
111111111#222222222
111111111#222222222
111111111#222222222
#########2222222222

The first code rotates cockwise :
[print(*i[::-1],sep="")for i in zip(*open(0))]

Try it online!
The second rotates counter clockwise
[print(*i,sep="")for i in[*zip(*open(0))][::-1]]

Try it online!

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

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


text:
Determine winner of Connect 4
You are given a partially filled Connect 4 grid (7x6).
O X
O X
X O X O     O
X O X O   X X
O X X X O O X
O O O X X O X

(Input can be given as a 1D or 2D array and as letters or numbers, etc.)
Assume that

X started the game.
Nobody has won yet.
Players may not have played well until now, but now onwards they will both employ optimal strategies.
Input grid is not faulty.

You must output a single value that indicates which player wins (or a draw)
Code golf challenge; so shortest code wins. Your program does not have to actual compute the output in reasonable amount of time, but you should be able to prove that the output will be obtained correctly in a finite amount of time.

Related.

@MartinBüttner Does that mean I will get downvoted, or is it okay to leave my question here?

It just means the questions are related, nothing more, nothing less. The purpose of posting the link is for the challenges to appear in each other's "Linked" sidebar, so people can find related challenges more easily. If I considered your question a duplicate, I would have said so (or just closed it), so don't worry. :)

Is "optimal play" well defined? If so, can you provide a link describing the algorithm for optimal play?

@Rainbolt It has been solved and there exist perfect algorithms also. Read Wikipedia for more.

Perl, 119 118 117 bytes
Includes +4 for -0p
Give rotated board padded with spaces on STDIN (gravity pulls stones to the right)
connect4.pl
  OXXX
   XOO
    OX
  OOXX
  XXXO
XXOOXO
OOXXOO
^D

connect4.pl:
#!/usr/bin/perl -p0
y/XO/OX/if$^S|y/X//>y/O//;$_=$$_||=/Z@{[map"|O".".{$_}O"x3,0,5..7]}/sx||s% (?! )%$_="$`X$'";do$0%eg?/1/?3:1+/2/:2

Prints 3 if player to move wins, 1 if player to move loses and 2 for a draw.
On older perls you can use a literal ^S to gain one byte.
If you don't mind extreme inefficiency you can leave out the $$_||= (transposition table) and gain 6 more bytes. If you leave out the $_= it will show you where to play instead of the result (play on 1 and win if there is one, play on 2 and draw if there is one or play on any 3 and lose)
Builds and evaluates a complete minimax tree. You will run out of memory and time unless the board is already reasonably well filled.

Why on earth did someone downvote? The golfing is truly amazing (I golf with perl and obtaining such a solution is extremly hard - I'm not sure any other perl golfer I know could have come up with that code). And the code has the required behavior.

This makes my brain hurt. +1!

@Dada how do you know this answer is down voted? I see 3 as vote...

@RosLuP when I first saw this post, it had 1 downvote. Also, when you have enough rep, you can see how many up and down votes a post has : in that case, now it has 4 up and 1 down.


text:
Enumerating N-Dimensional Vectors
Given a positive integer k > 1 and a non-negative integer i, generate a k-tuple (or k-dimensional vector) of non-negative integers. For every k, the map from ℕ to ℕk, must be bijective. That is, every input i should produce a different tuple, and every possible tuple must be produced by some input i.
You may write a program or function, taking input via STDIN (or closest alternative), command-line argument or function argument and outputting the result via STDOUT (or closest alternative), function return value or function (out) parameter.
You may use any convenient, unambiguous, flat list format for the output.
Your solution should impose no artificial limits on k and i but you may assume that they fit into your language's native integer size. At the very least, you must support values up to 255, though, even your native integer size is smaller than that.
For any 1 < k < 32, i < 231, your code should produce a result in a matter of seconds (of course, if your answer doesn't support i that large due to the previous rule, the limit is adjusted accordingly). This should be no issue: it's possible to solve this challenge such that it works up to 2128 in a few seconds, but the limit is there to avoid answers which actually iterate from 0 to i to find the result.
Please include in your answer a description of your chosen mapping and a justification for why it's bijective (this doesn't need to be a formal proof).
This is code golf, the shortest answer (in bytes) wins.
Related Challenges

Generate a pair of integers from a non-negative one
Output a list of all rational numbers

Pyth, 15 12 bytes
ms+0_%Q>_zdQ

Test suite
My transformation is similar to one of xnor's, but in base 10. It works by unzipping the input into k separate numbers:
n = 21003034
k = 3

21003034
 1  3  4    134
2  0  3     203
  0  0        0

The numbers are ordered in decreasing position of the rightmost digit, so that all orderings of any group of numbers are possible.
The way the code works is we reverse the input, then slice off the last 0, 1, ... k-1 digits, then take every kth digit, reverse again, stick a 0 at the begining, and convert to int.

CJam, 20 bytes
q~({4b2fmd2/z2fb~p}*

The mapping is bijective since it applies the mapping from this answer k - 1 times.
The program reads the input as i k. Try it online in the CJam interpreter.
Idea
We can construct a bijective mapping f : N → N2 by defining f(i) as follows:

Convert i into the array of its binary digits.
Prepend a 0 to this array if there is an odd number of digits.
Deinterleave the resulting array, forming to new ones in the process.
Convert those arrays from base 2 to integer. Define f1(i) and f2(i) as the results.

To obtain a bijective mapping g : N → N3, we can define g(n) := (f1(i), f1(f2(i)), f2(f2(i))).
To obtain a bijective mapping h : N → N4, we can define h(i) := (g1(i), g2(i), f1(g3(i)), f2(g3(i))).
Continuing the above process, we eventually arrive at a bijective map N → Nk.
Code
q~      e# Read and evaluate all input. This pushes i and k.
({      e# Do k-1 times:
  4b    e#   Convert the integer on the stack (initially i) to base 4.
  2fmd  e#   Replace each base-4 digit d by d/2 and d%2.
  2/    e#   Split into the chunks [d/2 d%2].
  z     e#   Transpose. This collects all quotients in one array and all
        e#   residues in another one.
  2fb   e#   Convert each array from base 2 to integer.
  ~     e#   Dump both integers on the stack.
  p     e#   Print the topmost one.
}*      e#

xnor's idea also gives 20 bytes (or less if you golf it better than I did): q~2bW%1$Te]/zWf%2fbp (opposite input order)

J, 38 28 27 bytes
(({.,g^:_1@}.)g=:_ q:>:)~<:

This is a tacit, dyadic verb that takes i and k as left and right arguments. Try it online with J.js.
Idea
We define a map f : N → Nk by f(i) := (α1, … αk-1, p1αk…p2αk+1… - 1), where ⟨pn⟩ is the sequence of prime numbers and i + 1 = p1α1p2α2….
By the Fundamental Arithmetic Theorem, the map g : N → Nω defined by g(i) := (α1, α2, …) (exponents of the prime factorization of i + 1) is bijective.
Since f(i) = (g1(i), … gk-1(i), g-1(gk(i), gk+1(i), …)), the map f is bijective as well.
Code
                            Left argument: i -- Right argument: k
                         <: Decerement k.
(                      )~   Reverse the order of the arguments and apply the
                            dyadic verb inside the parentheses to k-1 and i.
              g=:            Define a monadic helper verb g:
                     >:       Increment its right argument.
                 _ q:         Calculate the exponents of the prime factorization.
                             (implicit) Apply g to i.
(            )               Apply the dyadic verb inside the parentheses to k-1
                             and (g i).
           }.                 Drop the first k-1 elements of (g i)...
          @                   and...
     g^:_1                    apply the inverse of g to the result.
  {.                          Take the first k-1 elements of (g i).
    ,                         Append the rightmost result to the leftmost one.

Why is your function bijective?

@xnor At least the one from my explanation wasn't, since I had swapped a couple of indices by mistake. I've added a proof sketch.

CJam, 18 bytes
q~({)2bW%_1#p))b}*

It uses a more stupid formula.
Try it here.
Explanation
q~          e# Read input.
({          e# Repeat k-1 times:
    )       e# Increment the current integer (initially i), to make it positive.
    2b      e# Convert to binary.
    W%      e# Reverse the binary.
            e# The result can be any non-empty binary string without trailing 0s.
    _1#     e# Find the position of the first 1, or the number of initial 0s.
    p       e# Print.
    )       e# Extract the final bit, which is always 1.
            e# An array that can be any binary string is left in the stack.
    )       e# Increment the 1 to make it 2.
    b       e# Convert the binary string to a number using base 2.
            e# Only the number of initial 0s doesn't affect the result,
            e# which is exactly what is printed before.
}*          e# The final integer is printed automatically when the program ends.

In summary, it maps a positive integer to:

The number of trailing zeros.
The original integer with trailing zeros removed, reversed, and the trailing (originally initial) 1 removed.

Python 2, 62
lambda z,k:[int('0'+bin(z)[~i:1:-k][::-1],2)for i in range(k)]

This code is ugly and golfable, but the idea is very simple.
Pack k binary expansions into one by reading every kth digit with different offsets. For example, with k=3, the input 357 maps to (3,0,7):
101100101 <- 357
  1  0  1 -> 5
 0  0  0  -> 0
1  1  1   -> 7

Zipping the numbers back together reverses it, so it's a bijection. In doing so, think of the binary expansions as having an infinite number of leading zeroes.

Python 2, 72
q=lambda z:z and z%2+2*q(z/4)
g=lambda z,k:1/k*[z]or[q(z)]+g(q(z/2),k-1)

The function q acts on binary numbers by taking every second bit starting from the end. As a result q(z), q(z>>1) gives two numbers whose binary digits intersperse to give z. For example, 594 splits into 12 and 17.
1001010010   <- 594
 0 1 1 0 0   ->  12
1 0 0 0 1    ->  17

This is a bijection because we can zip the numbers back together to recover the original number.
The function g applies this bijection k-1 times, expanding from a single element to a pair to a triple ... to a k-tuple. Each time, the last element is expanded to two elements. This is done recursively by mapping the input to a pair via the bijection, taking the first element of the pair for the first entry of the output, and applying the function recursively with k-1 to the second element to produce the remaining entries.

I realized I'm making this way too complicated...


text:
Square side pinpointing
Welcome to my first code-golf challenge! :) Let's hop right into it.
Challenge:
Given two floating point vectors, O (origin) and T (target), you have to create a program to print the values L and R to STDOUT.

O is one corner of the square
T is one corner of the square that is located opposite to O
L is the 2D point (corner) that marks the other point of the uncomplete square
R is the 2D point (corner) that is opposite to L

Rules

Values for O and T have to be read from STDIN (see example inputs).
Again, L and R's values has to be printed to STDOUT.

Scoring and bonuses

Count the bytes of your program.
If your program draws lines that connect between O to L to T to R, subtract 15 bytes from the byte count.

Examples
First line covers inputs (first square brackets for O and next brackets for T) and other line represents expected output.

[0, 0] [3, 3]
Expected: [0, 3] [3, 0]
[0, 0] [-2, -2]
Expected: [-2, 0] [0, -2]
[1, -1] [4, 2]
Expected: [1, 2] [4, -1]
[0, -1] [0, 1]
Expected: [-1, 0] [1, 0]

NOTICE: inputs and outputs can be floating points!
Important information!

Values O and T can be taken in any format, as long as they come from STDIN (ex. Inside [] or ()...), use whatever format you want.
L and R can be printed in any order.
Remember: when (O->L->T->R->O) are connected, each side must have the same length!

Winning

This is code-golf so fewest byte answer wins!
Winner answer will be accepted at sunday 15.11.2015  20:00-22:00 (Finland time) (If I'm not wrong, that date is written like 11.15.2015 in the US, don't get confused).

Happy golfing!

In case you're not aware of it, let me recommend the sandbox for future challenges, where you can get feedback and polish your challenge before it goes live (and before changes might invalidate existing answers).

Can we take input as a list of two complex numbers?

@ThomasKwa sure you can take it as a list. Isn't an input a complex number when it's given...? I mean you don't have to personally know the value yourself for computer to compute it, right?

When you say "point of the square", it looks like you mean a corner? There are a lot of other points in a square.

@RetoKoradi You're right. I do mean a corner with that.

Seriously, 11 bytes
A port of my TI-BASIC answer. Calculates mean(X)+i*(X-mean(X)).
,;Σ½;)±+ï*+

Explanation:
,           Read input
;           Duplicate
Σ½          Half the sum (the mean) of the top copy
;           Copy the mean
)           Rotate stack to the left
            Now there's a copy of the mean on the bottom
±+          Negate mean and add to input list
ï*          Multiply by i
+           Add to mean

Input as a list of two complex numbers: [1-1j,4+2j], and output in the same format: [(4-1j), (1+2j)].

I'm so proud...

After this answer was posted, Mego added æ for list mean, and caused î (multiply-by-i) to vectorize, allowing a non-competing 9-byte solution. Seriously is starting to become a seriously good language.

A "Seriously" good language. @ThomasKwa

Isn't Σ 2 bytes?

@AshBurlaczenko Seriously seems to use the CP437 encoding, where Σ has the code point 0xF4.

@AshBurlaczenko What Dennis said is correct. Every character in Seriously is a single byte, whose ordinal is in the range [1,255].

Seriously, 25 bytes
,i││-++½)+-+½)++-½)±+++½)
Takes input as a list: [x1,y1,x2,y2]
Same strategy as my Python answer, but in Seriously!
Explanation:
,      get input
i      flatten list
││     duplicate stack twice, so that we have 4 copies of the input total
-++½)  calculate the first x-value using the formula (x1-y1+x2+y2)/2, and shove it to the end of the stack
+-+½)  calculate the first y-value using (x1+y1-x2+y2)/2, and shove it to the end of the stack
++-½)  calculate the second x-value using (x1+y2+x2-y2)/2, and shove it to the end of the stack
±+++½) calculate the second y-value using (-x1+y1+x2+y2)/2, and shove it to the end of the stack

Try it online

This is seriously cool! (Pun intended.)

TI-BASIC, 16 bytes
For a TI-83+ or 84+ series calculator.
Input X
i∟X+.5sum(∟X-i∟X

Unless I misunderstood, OP said they were fine with taking input and output as complex numbers. The i here is the imaginary unit, not the statistics variable.
TI-BASIC has a mean( function, but annoyingly it doesn't work with complex lists, throwing an ERR:DATA TYPE.
Input in the form {1-i,4+2i} for [[1,-1],[4,2]]. Output is in the form {4-i 1+2i} for [[1,2][4,-1]].

This reminds me how TI-BASIC does not support lists of strings. That would probably be the one thing I would add to TI-BASIC :P

Matlab, 51 45 46 45 42 bytes
Now the input is expected in one column vector: [x0;y0;x1;y1] (ouput in the same format) I just modified it to be a full program.
z=eye(4);disp((.5-z([2:4,1],:))*input(''))

Or alternatively
z=[1,1;-1,1];disp([z',z;z,z']*input('')/2)

Old solution:
The input expects column vectors, e.g. f([0;0],[3;3])
@(a,b)[0,1;-1,0]*(b-a)*[.5,-.5]+(b+a)*[.5,.5]

It also returns two column vectors (as a 2x2 matrix).

Japt, 29 28 bytes
Japt is a shortened version of JavaScript. Interpreter
1o5 mZ=>$eval$(Uq'+)/2-UgZ%4

Note that the arrow functions require an ES6-compliant browser, such as the newer versions of Firefox. Input goes in as a 4-item array, e.g. [1,-1,4,2].
How it works
         // Implicit: U = input array
1o5      // Create a range of integers from 1 to 5. Returns [1,2,3,4]
mZ=>     // Map each item Z in this range to:
$eval$(  //  evaluate:
 Uq'+    //   U joined with "+" (equivalent to summing U)
)/2      //  divided by 2,
-UgZ%4   //  minus the item at Z%4 in the input. This translates to [y₁,x₂,y₂,x₁],
         //  which in turn tranlsates to:
         //   [(x₁-y₁+x₂+y₂)/2, (x₁+y₁-x₂+y₂)/2, (x₁+y₁+x₂-y₂)/2, (-x₁+y₁+x₂+y₂)/2]
         //  which is [Lx,Ly,Rx,Ry], or [Rx,Ry,Lx,Ly], depending on the situation.
         // Implicit: Output last expression

How it was golfed
I first tried simply copying @Mego's Python approach. This left me with this 48-byte monster:
(Note: the input should not currently be wrapped in an array.)
[U-V+W+X /2,(U+V-W+X /2,(U+V+W-X /2,(V+W+X-U /2]

Since each of these items needs to be divided by 2, it's shorter to map the entire array with mY=>Y/2:
[U-V+W+X,U+V-W+X,U+V+W-X,V+W+X-U]mY=>Y/2

Now what? Well, the array is now simply adding three of the inputs and subtracting the fourth, following the pattern 1,2,3,0. So, we could pack the inputs into an array, then add them together, divide by 2, and subtract the necessary item:
[1,2,3,0]mZ=>(Ug0 +Ug1 +Ug2 +Ug3)/2-UgZ

Nice, saved a byte! But is it possible to shrink the array at the beginning? Let's try packing it into a string, then splitting it back into an array with a:
"1230"a mZ=>(Ug0 +Ug1 +Ug2 +Ug3)/2-UgZ

Look at that, another byte saved. But is there an even better way? Well, we can use the fact that [1,2,3,0] ≡ [1,2,3,4] mod 4:
1o5 mZ=>(Ug0 +Ug1 +Ug2 +Ug3)/2-UgZ%4

Another two bytes! Now we're going somewhere. But that Ug0 +Ug1 +Ug2 +Ug3 is hogging a lot of space. What if we reduce the array with addition?
1o5 mZ=>Ur(X,Y =>X+Y /2-UgZ%4

Wow, that really helped! Now we're down to 29 bytes. And thanks to @ןnɟuɐɯɹɐןoɯ, I was even able to golf another byte off the reduction. But if we could use a built-in to sum the array, it'd be way shorter:
1o5 mZ=>Uu /2-UgZ%4

19 bytes! Amazing! Unfortunately, Japt does not yet have any such built-ins. I'll add this in when I get a chance. Suggestions are welcome, for either the program or the language!

Well, as of v1.4.4, I've implemented quite a few more features into Japt than I had originally planned. Starting with the original plan for the shorter version:
1o5 mZ=>Uu /2-UgZ%4

First we need to change a few things: Functions are defined with {, and the sum function is x. This version works as-is:
1o5 mZ{Ux /2-UgZ%4

Now, @ is a shorthand for XYZ{, allowing us to save a byte by switching from Z to X. Also, £ is a shortcut for m@, saving another byte:
1o5 £Ux /2-UgX%4

Recently I implemented a feature where a U at the beginning of the program can usually be left out. Due to an implementation mistake, however, this also works with functions:
1o5 £x /2-UgX%4

Finally, the g function now wraps if the index is past the end of the string, allowing us to remove the %4 for a total of 13 bytes:
1o5 £x /2-UgX

And I thought 19 was amazing ;-) Test it online!

You can probably save some bytes by using the Japt equivalent of eval(U.join\+`)`.

I love this language :D

@ןnɟuɐɯɹɐןoɯ Thanks, even though I haven't added an eval equivalent yet, that actually saves a byte!

Javascript(Node.js/ES6), 154 bytes
process.stdin.on('data',s=>(s=s.toString().split(','),a=s[0]-0,b=s[1]-0,x=s[2]-0,y=s[3]-0,console.log([a+(c=(a+x)/2-a)+(d=(b+y)/2-b),b+d-c,a+c-d,b+d+c])))

Getting stdin is the longer part of the code. The input should be the points comma separated :
echo "0,0,3,3" | node square.js

Is this a full program...? Which outputs the points to STDOUT...? Doesn't seem like that.

You're right. Damn, this will add a lot of bytes,

Voilà, fixed. almost 3 times longer now :(

Hmm :/ I still think that the point is to make beautiful code art that functions well. And the code you provided is very complex looking & handsome art. :) thanks for participating!

CJam, 30 bytes
q~_:.+\:.-(W*+_2$.+@@.-].5ff*`

Try it online
This takes input as a list of lists, e.g. for the last example:
[[0 -1] [0 1]]

Explanation:
q~      Get and interpret input.
_       Make a copy.
:.+     Reduce the list of two points with vector sum operator.
\       Swap copy of input to top.
:.-     Reduce the list of two points with vector difference operator.
(W*+    Turn (x, y) into orthogonal (y, -x) by popping off first element, inverting
        its sign, and concatenating again. We now have center and offset vector.
_2$     Create a copy of both...
.+      ... and add them.
@@      Rotate original values to top...
.-      ... and subtract them.
]       Wrap the two results...
.5ff*   ... and multiply all values by 0.5.
`       Convert list to string.

, 29 chars / 43 bytes
ô(ѨŃ(1,5)ć⇀ë(ïø`+`⸩/2-ï[$%4]⸩

Try it here (Firefox only).

ngn APL, 21 bytes
⎕←F.5 0J.5×(F←+/,-/)⎕

This takes the input as a pair of complex numbers (e.g., 1J¯1 4J2) and prints the output in the same way (e.g., 4J¯1 1J2). Try it online in the ngn/apl demo.

Works for all the positive inputs, however, it doesn't output anything when I enter negative numbers. Am I entering them in a wrong format? 1J1 3J3 works. 0J-1 0J1 does not. I also tried to use the upper minus symbol to declare number negativity.

@TuukkaX The high minus in the way to go. I get output 1 ¯1 for input 0J¯1 0J1, which is the correct answer. What are you getting?

Oh, now I got it working. I just had to remove the tiny whitespace before the high minus sign. It works and qualifies.

Pyth, 12 bytes
.jL.OQ-R.OQQ

This takes the input as a pair of complex numbers (e.g., 1-1j, 4+2j) and prints the output as an array (e.g., [(4-1j), (1+2j)]). Try it online.

Python 3, 102 bytes
g=lambda a,b,c,d:((a-b+c+d)/2,(a+b-c+d)/2,(a+b+c-d)/2,(d+b-a+c)/2)
print(g(*map(float,input().split())))

Input is taken in the form x1 y1 x2 y2, on a single line.
Try it online

You do something wrong, your byte count went up with each edit, but I try to bring the bytecount down with each edit=P

@flawr I am the anti-Dennis

I believe all answers need to be full programs, taking input from STDIN (or closest alternative). Does this qualify?

Prolog, 118 bytes
p([A,B],[C,D]):-read([E,F,G,H]),I is(E+G)/2,J is(F+H)/2,K is(G-E)/2,L is(H-F)/2,A is I-L,B is J+K, C is I+L, D is J-K.

Slightly more readable:
p([A,B],[C,D]):-read([E,F,G,H]),
                        I is(E+G)/2,
                        J is(F+H)/2,
                        K is(G-E)/2,
                        L is(H-F)/2,
                        A is I-L,
                        B is J+K,
                        C is I+L,
                        D is J-K.

To start the program:
p(X,Y).

Example input when the known corners are [1, -1] [4, 2]:
[1,-1,4,2]
Example output, where X and Y will contain the unknown corners:
X = [1.0, 2.0],
Y = [4.0, -1.0]

Try it out online here

Edit: Changed to read input from STDIN

Does this read from STDIN and print to STDOUT...?

@TuukkaX: Probably not. It takes input in the form of a query. I read the part that said that input could be whatever format we wanted. I missed the part about STDIN. Not even sure what STDIN in Prolog is. Would reading input from user be OK?

STDIN stands for standard input. So reading from user is the way to go :) and by format I mean the way user inputs the values. Ex [x, y] [x, y] or {x, y}...

Python 2, 56 bytes
i=input()
s=sum(i)/2.0
print s-i[1],s-i[2],s-i[3],s-i[0]

Input can be x1,y1,x2,y2 or (x1,y1,x2,y2)


text:
On the Subject of Keypads
Keep Talking and Nobody Explodes is a local multiplayer game where one player has control over a virtual "bomb", and has to be guided by another player, the "expert", who has access to a bomb defusal manual. One of the modules to be disarmed in the game is the keypad module, which is what we'll be dealing with in this challenge.
The task
Input will start with a single line of printable ASCII characters except space (0x21 to 0x7E). These represent the keypad buttons visible to you.
The next few lines will represent "keys" – only one line will contain all of the characters of the first line, not necessarily in order. Your task is to output the keypad characters, in the order of the matching key line.
For example, if the input was
5~Fy
HrD7K!#}
Ui%^fHnF
)Tf;y~I5
~Fi(&5gy
,'Xd#5fZ

then the keypad buttons are 5, ~, F and y. Only the 4th key line ~Fi(&5gy contains all of these characters, so we output the keypad characters in the order in which they appear, i.e. ~F5y.
Rules and clarifications

Input must be a single multiline string, with the keypad buttons and key lines on separate lines.
There will be exactly one key line which contains all of the keypad characters.
Every line, i.e. the initial keypad line and following key lines, will have no duplicate characters.
Unlike the game, you may not assume anything about the number of keypad characters, the length of each key line or the number of key lines. However, all key lines are guaranteed to be the same length.
The output may contain a single optional trailing newline. Similarly you may assume either way about an optional trailing newline in the input, but please specify in your answer if you need the assumption.
Although this already seems to be common practice, I'll state explicitly: terminating with an error is okay for this challenge, as long as STDOUT output is correct (if this is your chosen form of output). Hopefully this will make handling input easier.

Test cases
7
4?j01C3"ch
KP.OG>QB)[
z#)Kn"I2&.
]#,D|sBFy5
Qzj*+~7DLP

Output: 7. Only the last line contains a 7.
0b~
Ob+hy{M|?;>=dtszPAR5
*8rCfsw|3O9.7Yv^x>Hq
$ip.V@n}|La:TbIt^AOF
jZ[Ec4s0|%b*$id',~J6
z*#b}-x$Ua&!O2;['T+?
NVj_X8rlhxfnS\.z}];c
bykscf.w^dnWj+}-*2g_
VP`AJH|&j5Yqmw/"9IMc

Output: 0b~. The 4th key line already contains the characters in the right order.
MTuz
bIAr>1ZUK`s9c[tyO]~W
oMGIi/H&V"BeNLua%El=
j*uYbplT:~);BM|_mPZt
Q}z5TC@=6pgr<[&uJnM%
YOA(F~_nH6T{%B7[\u#5
y&t"8zQn{wo5[Idu4g:?
[0tZG"-fm!]/|nqk,_2h
dA&C.+(byo6{7,?I}D@w

Output: zTuM. The key line is the 4th one, although the 3rd key line is a close miss.
o@nj<G1
f]?-<I6h2vS*%l=:}c8>LK5rMdyeon,;sE[@m(73
ibhp+2Hq6yKzIf_Zo}EO3-[*0/e&Fvd]wQU=|%`C
;}>d'cg~CPtQG&%L\)MUl419bkTZ7@]:[*H"RyYj
L^<:zXJ#kj$EFlwN%B`Dd,Cs?]xRZ*K9-uQ.@&f+
i1v'7:90R-l}FMxj`,DTWK+(n32Z4Vs[p@%*eS!d
B|^Ti/ZG$}ufL9*wE[AVt]P7CrX-)2JpD<sYxd6O
ex.$4#KarS^j+'_!B"]H[\83:(DCXUgI*Lct?qAR
^GXQoy*KW&v}n']Em~\N9)fxP(qC=7#4sRdcD6%5
;inr[&$1j_!F~@pzo#blv]}<'|fRds6OW%tEg"G2
e;0T#gfo^+!:xHDN&4V=In?AwhEv$2Fd~ZLz_\81

Output: n1j@o<G. The key line is the second last line.
Scoring
This is code-golf, so the code in the fewest bytes wins.

Is STDOUT the only acceptable output method, or is a function return value also allowed?

@Zgarb Function input and output are both okay

sigh I have a solution that works for one test case...too many escape characters in the other test cases. Oh well.

CJam, 13 12 bytes
qN/(f&{,}$W=

Test it here.
Explanation
q     e# Read all input.
N/    e# Split into lines.
(     e# Pull off the keypad buttons.
f&    e# Take the set intersection of each key line with the keypad, preserving the order
      e# order in the key line.
{,}$  e# Sort the results by length.
W=    e# Pick the last (longest) one.

Pyth, 10
@zhf!-zT.z

Try it online
Explanation
@zhf!-zT.z         ##  z = first line of input, .z = list of rest of lines
   f    .z         ##  Filter .z as T based on
    !-zT           ##  Whether removing all the letters from z that appear in T leaves an
                   ##  Empty string or not (keep the ones that give empty strings)
  h                ##  Take the first such line (necessary indexing, shouldn't ever matter)
@z                 ##  @ is setwise intersection. Pyth implements this by iterating over
                   ##  each element of the second argument and keeping values that appear
                   ##  in the first argument, which gives the intended result

Pyth, 9 bytes
eolN@Lz.z

Demonstration
@Lz.z: Filter all lines for the intersection with the first line.
olN: Order by length
e: Take the longest.

Haskell, 49 bytes
g(!)(a:b)=[c|d<-b,all(!d)a,c<-d,c!a]
g elem.lines

The first line defines a helper function g, the unnamed function on the second line is my answer.
Explanation
The algorithm is the obvious one: split input into lines, find the line that contains all characters of the first line, and filter out all the other characters on that line.
g(!)(a:b)=                            -- g gets a binary function ! and list of strings a:b
          [c|                         -- and returns the string of characters c where
             d<-b,all(!d)a,           -- d is drawn from b and x!d holds for all x in a,
                           c<-d,c!a]  -- and c is drawn from d and c!a holds.
g elem.lines                          -- The input is split into lines and fed to g elem;
                                      -- then x!d means x `elem` d in the above.

Prolog, 204 190 bytes
This could have been a nice challenge for Prolog if it hadn't been for the combined requirements of multiline input and unescaped characters ' and " in the input. A big chunk of the code (p and r) exist to read a file as character codes which is what I had to do to take unescaped input on several lines.

If only ' existed as an unescaped character, I could read input as a string.
If only " existed as an unescaped character, I could read input as an atom.
If input wasn't multiline, say separated by space instead, I could read it as one line to codes.
r(I,[H|T]):-read_line_to_codes(I,H),H\=end_of_file,r(I,T).
r(_,[]).
q(_,[]).
q(E,[H|T]):-subset(E,H),intersection(H,E,X),writef("%s",[X]);q(E,T).
p:-open("t",read,I),r(I,[H|T]),q(H,T),!.

How it functions

Opens file t (which contains all input) to read
Read all lines as character codes and place in a list of lists (1 list per row)
Recurses over tail lists and checks if head list exist as a subset of that list
Intersects matched list with head to get wanted characters in the correct order
Prints solution

How to run
Program is run with command:
p.

File namned t containing input has to be in the same directory.
Edit: Saved 14 bytes by unifying 2 q-clauses with OR.

MATLAB, 107 bytes
b=char(strsplit(char(inputdlg),' '));[~,x]=ismember(b,b(1,:));[~,f]=min(abs(1./sum(~x')-1));b(f,(~~x(f,:)))

This ended up being a very sloppy piece of code...
When being run, an input dialog is opened where a multi-line string can be pasted into (newlines are converted to spaces and the output will be a cell with 1 very long string). I chose to convert the resulting cell to a char which makes it possible to split at the spaces (result is a cell array) and then again convert to char to retrieve the intended shape. MATLAB's built-in ismember function does a good job here in comparing our first line to the other lines.
After that it gets nasty... I've tried a lot of ways to exclude the first line from my 'best match' check and ended up with this. We look for the line and then use this information to grab the indices (by converting our ismember output to logicals) that we want our output characters from.

Wolfram Language 106 bytes
c=Characters[InputString[]~StringSplit~"\n"];o=c[[1]];t=Select;t[t[Rest@c,#~SubsetQ~o&][[1]],o~MemberQ~#&]

Example input:

Output:

Explanation of the code : First with InputString we get the full string of input, then we get the first set of letters by splitting the string by newline, and saving all the characters of the first one in variable o. Next, we select from the rest of the input lines those lines that have the first line's characters (saved as variable o) as a subset. Then with that line selected, we grab the members of that line that are in the original set.
Edit : Thanks to Martin Büttner for the tips on using infix notation and my unnecessary variables

Yay, Mathematica. Some golfing hints: As far as I can tell you use c and i only once, so there's no benefit in assigning them to variables. You can probably save some bytes from this tip. By not giving o a name. s[[1]] is #&@@s (same for your second use of [[1]]). You can use StringSplit without the second parameter (because it splits on whitespace by default). SubsetQ and MemberQ can use infix notation to save a byte, e.g. #~SubsetQ~o.

I changed it some, and didn't notice as I changed it that I only used i and c once, thanks for the tip! Also, I need to have the second parameter to StringSplit, as there were some weirdness going on with some of the characters getting interpreted as whitespace (that aren't really whitespace)

Interesting. In that case you can still embed a literal newline instead of writing \n, to save one byte, and use infix notation to save another.

Yeah, not entirely sure what's going on with StringSplit in that case, it might actually be a consequence of using InputString

Japt -h, 6 8 bytes
Takes the keypad as an array of lines. The buttons can be either a string or a character array. +2 bytes to accommodate the cumbersome input format.
·ËoFgÃñl

Try it
·ËoFgÃñl     :Implicit input of multi-line string
·            :Split on newlines
 Ë           :Map each element in array F
  o          :  Remove characters not contained in
   Fg        :  First element of F
     Ã       :End map
      ñ      :Sort by
       l     :  Length
             :Implicit output of last element

"Input must be a single multiline string, with the keypad buttons and key lines on separate lines."

Thanks, @DominicvanEssen. I should really learn to check the dates on challenges and read through the specs for unnecessary restrictions, rather than assuming current standards. Will update in the morning; think it'll cost me 3 bytes.

Nice.  I kind-of usually agree re: cumbersome input format, but in this case I found that it was actually an interesting restriction to an otherwise pretty easy challenge.  Probably depends on what's on offer in each language, though...

Javascript (ES6), 107 104 102 bytes
Snippet demo for supporting browsers.

f=x=>([a]=x.split`
`).map(y=>[...y].filter(z=>~a.indexOf(z)-x).join(x='')).find(z=>z.length==a.length)
<textarea id="i" rows="6" cols="45">o@nj<G1
f]?-<I6h2vS*%l=:}c8>LK5rMdyeon,;sE[@m(73
ibhp+2Hq6yKzIf_Zo}EO3-[*0/e&Fvd]wQU=|%`C
;}>d'cg~CPtQG&%L\)MUl419bkTZ7@]:[*H"RyYj
L^<:zXJ#kj$EFlwN%B`Dd,Cs?]xRZ*K9-uQ.@&f+
i1v'7:90R-l}FMxj`,DTWK+(n32Z4Vs[p@%*eS!d
B|^Ti/ZG$}ufL9*wE[AVt]P7CrX-)2JpD<sYxd6O
ex.$4#KarS^j+'_!B"]H[\83:(DCXUgI*Lct?qAR
^GXQoy*KW&v}n']Em~\N9)fxP(qC=7#4sRdcD6%5
;inr[&$1j_!F~@pzo#blv]}<'|fRds6OW%tEg"G2
e;0T#gfo^+!:xHDN&4V=In?AwhEv$2Fd~ZLz_\81</textarea><br /><input type="button" onclick="o.value=f(i.value)" value="Run"> Output: <input type="text" id="o" readonly />

Commented:
f=x=>
([a]=x.split('\n')) // split input by newlines, assign first value to a
.map(y=> // map function to each line
    [...y].filter(z=> // filter characters
        ~a.indexOf(z)-x // a has character z and not the first item (x is still set)
    ).join(x='') // join characters with empty string, reset x flag
).find(z=>z.length==a.length) // return string with same length as a

Python 2, 112 bytes
import sys
i=sys.stdin.readlines()
print[''.join(c for c in l if c in i[0])for l in i[1:]if set(i[0])<set(l)][0]

Example run: Ideone

Ruby, 96 71 63 bytes
-8 bytes thanks to south
Inspired by Shaggy’s Japt solution. Requires a trailing newline in the input.
->s{a,b=s.split$/,2
b.gsub(/./){a[$&]&&$&}.lines.max_by &:size}

Attempt This Online!

Nice, I managed 63. String#[] helps a lot :P

@south Nice work, thanks!

Nibbles, 8 7 bytes (14 nibbles)
/\+=~.;@`&$;$,

      .         # map over
       ;@       # all lines of input
         `&     # getting list intersection
           $    # of each line
            ;$  # with the first line of input;
    =~          # now group intersections by
              , # length,
   +            # flatten the list-of-groups,
  \             # reverse it
                # (so the 'found' keys are now first,
                # and the input is second),
/               # finally, fold from right
                # returning the (implicit) right argument
                # at each step
                # (so returning the first element)


text:
Play "Taps"
Today, November 11, 2015, is Veterans Day in the United States. "Taps" is the bugle call played at U.S. military funerals:

("Taps" on SoundCloud from vtmiller)
It is a simple melody, only twenty-four notes long and using only four different notes. Here is the sheet music:
 (source)
Challenge
Write a program or function that plays "Taps" or outputs an audio file of "Taps" in any common audio file format (e.g. MP3, WAV, MIDI). It may be played in any key, using any type of instrument or beep noise available to your language. For example, it might sound like a piano instead of a bugle. (Though still only one instrument type should be used.)
All twenty-four notes must be played with accurate pitch, duration, and spacing. Someone who is familiar with "Taps" should be able to run your code and easily recognize the song being played.
The duration of the melody (from the start of the first note to the end of the last note) must be between 30 and 70 seconds. You may optionally have up to 5 seconds of silence padding the start and/or end of your sound file, so an 80 second file is the longest allowed.
You may not, of course, simply download the song online somewhere or extract it from an audio library that happens to have it as as sample. You may, however, use audio libraries that can play/compose individual notes and create audio files.
Scoring
This is code-golf, so the shortest answer in bytes wins. However, for this particular challenge I encourage you to not focus on your byte count, especially at the expense of sound quality. Golf your submissions but allow yourself to be creative with your instrument choice or sound output methodology. This challenge is meant to be about honoring veterans, not about screeching out a barely recognizable version of "Taps".
Note that you can embed SoundCloud audio files directly into posts by just pasting the link on an empty line. If you have a SoundCloud account this would be a great way to share your output.

I'm thinking ChucK.

Calvin, if you don't mind, I'll post a couple of golfy answers in old BASIC's and make a donation to a Veterans charity outside of PPCG. You have inspired me to do that. BTW in the UK we have Remembrance Sunday, the second Sunday in November, which means that this year it was last Sunday. One of my earliest memories is standing by a monument surrounded by poppies where 2 minutes of silence were observed. I was about 3.  When I asked my mother why nobody was talking, she told me to be quiet.

Are there any rules for the lengths of the fermatas?

@SirPython I didn't even know what that symbol meant! According to https://en.wikipedia.org/wiki/Fermata "Exactly how much longer it is held is up to the discretion of the performer." Using discretion on the output doesn't really fit with codegolf, so I played it as written. I see where you're going though... Lengthening the dotted second note could compress the dotted eighth note down to a sixteenth note, making things simpler. But I think that's cheating :-)

qb64, 100 84 bytes
Updated version of old Qbasic, downloadable at http://www.qb64.net/
Count excludes the spaces, which are not required and only there to split the data into three-note phrases for clarity.
PLAY"T99L4C.L8CL1F. L4C.L8FL1A. L4CFL2A L4CFL2A L4CFL1A. L4F.L8AL1>C< L2AFL1C. L4C.L8CL1F."

Commands in the play string
T99     set tempo to 99 quarter notes per minute (default is 120, only just too short)
CDEFGAB play notes in the current octave
><      up or down one octave
Lx      following notes are of note of 1/x duration
.       extend previous note duration by 50%

Golfing history:
First post: 4/4 time to 4/2 time, which means I have some whole notes, but no sixteenth notes.
Edit 1: Key changed from C (range G-G) to F (range C-C). Now I only have to perform an octave change once, for the high C, which only occurs once, rather than all the low G's as before.
Having got rid of all those octave changes, I don't think there's any more to golf. There are total of 20 L's but there is no obvious way to avoid them.
The last phrase (11 characters) is the same as the first, but there is no way to insert it twice in under 11 characters. The repeated data would be only 9 characters if the initial L4 were eliminated (It appears unnecessary as the default note length seems to be quarter note, but it's not documented so I left it in.)

JavaScript, 203 198 196 195 bytes
with(new AudioContext)for(t=i=0;n="301093301396202346202346202396331699464390301093"[i++];)with(createOscillator())i%2?l=n/2:(frequency.value=392+n*44,connect(destination),start(t+.1),stop(t+=l))

5 bytes saved thanks to Dendrobium and 1 thanks to @PatrickRoberts.
Explanation

with(new AudioContext)        // use HTML5 audio
  for(                        // iterate through the note pitches and lengths
    t=i=0;                    // t = current time to place the note
    n=                        // n = note pitch (or temporarily length)

    // This string contains the values of each note alternating between length and pitch
    //     (l1, p1, l2, p2, etc...)
    // Length value is in 16th notes (1 = 1/16th note, 2 = 1/8th, etc...)
    //     The longer notes are limited to 9 but I think it still sounds OK
    // Pitch value 0 = G4, 3 = C5, 6 = E5, 9 = G5 (multiples of 3 saves 1 byte)
    "301093301396202346202346202396331699464390301093"

  [i++];)
    with(createOscillator())  // create the note oscillator
      i%2?                    // alternate between length and pitch characters
        l=n/2                 // l = length (stored for use in the next iteration)
                              // dividing it by 2 sets the speed to 60 beats per minute
                              //     and casts it to a number
      :(
        frequency.value=392   // base note = G5 (392hz)
          +n*44,              // there is (conveniently) roughly 132hz between each note
        connect(destination), // send the note's sound through the speakers
        start(t               // schedule the note to sound
          +.1),               // short delay to distinguish two notes of the same pitch
        stop(t+=l)            // schedule the end of the note and increment the time
      )

Test it here in the browser! Works on any browser that supports the HTML5 Web Audio API.

-5 bytes: c=new AudioContext();for(t=i=0;n="301093301396202346202346202396331699464390301093"[i++];)with(c.createOscillator())i%2?l=n/2:(frequency.value=392+n*44,connect(c.destination),start(t+.1),stop(t+=l))

I'd say the duration (changing 12 units to 9) is inaccuate; it's made worse by the fact that the dotted half notes have fermatas on them and should really be 12 or longer.

@ThomasKwa Yeah, it's not perfect, but the requirement is to be easily recognisable so I'd say it passes. (Also listen to the SoundCloud track in the question, the first dotted half note is exactly 10/16ths so if we're going by that version it's pretty close! :P )

Mathematica, 361 287 285 bytes
I went for accuracy here. Output is exactly as described in the score, played with the trumpet. You can find the file here.
"G"
e="E5";c="C5";EmitSound@Sound[SoundNote[#,5/#2,"Trumpet",SoundVolume->#3/17]&@@@{%,8,17,%,24,20,c,2,23,%,8,26,c,24,29,e,2,32,%,12,35,c,12,38,e,6,41,%,12,44,c,12,47,e,6,50,%,12,53,c,12,56,e,2,59,c,8,62,e,24,65,"G5",3,68,e,6,170/3,c,6,136/3,%,2,34,%,8,34,%,24,34,c,2,34}~Partition~3]

Thanks to @MartinBüttner for golfing suggestions.

Link does not allow me to hear the song. It seems to be either removed or not available for listening due to permissions.

To be extra pedantic, you didn't account for the fermatas!

"The duration of the melody must be between 30 and 70 seconds." This is a bit short at 24 seconds.

@Calvin'sHobbies Wait... I'm doing all this at the recommended 50 BPM... I blame you :|

%1,%2 and %% don't actually save any bytes over x="E5" --> x (in fact, seeing how often you use them you should actually save quite a lot by using variables). Then you can save tons of bytes by using EmitSount@Sound[SoundNote[#,5/#2,"Trumpet",SoundVolume->#3/17]&@@@{{%%,8,17},{%%,24,20},...} and storing the most-used note in %. And at 24 notes it might be shorter still to partition a flat list: SoundNote[#,5/#2,"Trumpet",SoundVolume->#3/17&@@@{%%,8,17,%%,24,20,%2,2,23,...}~Partition~3

Sonic Pi, 899 bytes

The timing is a little off, but I think it's ok.
Lightly golfed:

use_synth:blade
use_synth_defaults sustain:0.70,release:0.0
play:G4,release:0.05
wait 0.75
play:G4,sustain:0.25
wait 0.25
hold=rrand_i(3,4)
play:C5,sustain:hold,release:0.5
wait hold+0.5
play:G4,release:0.05
wait 0.75
play:C5,sustain:0.25
sleep 0.25
hold=rrand_i(3,4)
play:E5,sustain:hold,release:1.25
sleep hold+1.25
play:G4
sleep 0.70
play:C5
sleep 0.70
2.times do
  play:E5,sustain:1,release:0.25
  sleep 1.25
  play:G4
  sleep 0.7
  play:C5
  sleep 0.7
end
hold=rrand_i(3,5)
play:E5,sustain:hold,release:0.75
sleep hold+1
play:C5,release:0.05
sleep 0.75
play:E5,sustain:0.25
sleep 0.25
play:G5,sustain:2.45,release:0.05
sleep 2.5
play:E5,sustain:1,release:0.25
sleep 1.25
play:C5,sustain:1,release:0.25
sleep 1.25
hold=rrand_i(3,5)
play:G4,sustain:hold,release:0.5
sleep hold+0.5
play:G4,release:0.05
sleep 0.75
play:G4,sustain:0.25
sleep 0.25
hold=rrand_i(3,5)
play:C5,sustain:hold,release:1.5

Yeah, someone using Sonic Pi!

Could be slightly golfed through renaming hold with h, changing release:0.0 to release:0 and removing the spaces.

MATLAB, 338 327 262 258 230 bytes
o=@(L,f)sin(pi*.11*2^(f/12))*(1:600*L))
sound([o(3,-1) o(1,-1) o(12,2) o(3,-1) o(1,2) o(12,4) o(2,-1) o(2,2) o(4,4) o(2,-1) o(2,2) o(4,4) o(2,-1) o(2,2) o(12,4) o(3,2) o(1,4) o(8,6) o(4,4) o(4,2) o(12,-1) o(3,-1) o(1,-1) o(12,4)])

Ruby + beep, 178 bytes
f=[260,346,416,499]
n=[12,*1..4]
l=(a="001012012012012123210001310310224224220318440310".chars.map(&:to_i))[24..-1]
`beep#{24.times.map{|i|" -f#{f[a[i]]} -l#{n[l[i]]}00"}*" -n"}`

Took me awhile to make this, I think I missed the boat, but whatever.
f holds the four frequencies used. n holds the five note lengths used, in multiples of 16th notes.
a="00101... holds all the note pitchs followed by all the note lengths, as indexes into the respective arrays. l is then set to the 24th indice and onward of a. Then a beep command is constructed by iterating through all of the above, and executed

SmileBASIC, 73 bytes
BGMPLAY"@56T50L2.G8.G16B+G8.<C16E>[G8<C8E4>]2G8<C8EC8.E16G2E4C4>GG8.G16B+

All the notes and timings are correct. I used a trumpet because it's the closest thing in MIDI

<audio autoplay controls src="//12me21.github.io/resources/taps.mp3"></audio>

Powershell, 183 175 159 bytes
Nostalgia trip, who doesn't like beeps?!
foreach($i in 0..23){[console]::beep((196,262,330,392)[(001012012012012123210001-split'')[$i]],(3,1,12,3,1,12,2,2,4,2,2,4,2,2,12,3,1,8,4,4,12,3,1,12)[$i]*400)}

Explanation (sortof)
foreach($i in 0..23) { # foreach loop which ranges from 0 to 23
    [console]::beep( # [console]::beep(Pitch, Duration)
        (196,262,330,392) # the notes in Hertz
            [ # select which note to use
                (001012012012012123210001-split'') # -split '' creates an array of [0,0,1,0,1 ...], spaces can be omitted
                [$i] # select the n-th element
            ],
        (3,1,12,3,1,12,2,2,4,2,2,4,2,2,12,3,1,8,4,4,12,3,1,12) # array of durations
        [$i]*400 # duration in milliseconds * 400
    )
}

This will play in about 45 seconds.
This is my first time using Windows' Powershell, any tips on golfing this are welome.

Old versions
175
foreach($i in(0..23)){[console]::beep((196,262,330,392)[(0,0,1,0,1,2,0,1,2,0,1,2,0,1,2,1,2,3,2,1,0,0,0,1)[$i]],(3,1,12,3,1,12,2,2,4,2,2,4,2,2,12,3,1,8,4,4,12,3,1,12)[$i]*400)}

183
$d=3,1,12,3,1,12,2,2,4,2,2,4,2,2,12,3,1,8,4,4,12,3,1,12;$n=0,0,1,0,1,2,0,1,2,0,1,2,0,1,2,1,2,3,2,1,0,0,0,1;foreach($i in(0..23)){[console]::beep((196,262,330,392)[$n[$i]],$d[$i]*400)}

BBC Basic, 111
Download interpreter at http://www.bbcbasic.co.uk/bbcwin/bbcwin.html
Score excludes whitespace and newlines, which are non-essential and added for readability
FORk=1TO24
  x=ASC(MID$("')F'Lb(Ke(Ke(KbJhxeI#')F",k))
  SOUND1,-9,x DIV7*4+60,INT(12/1.4^(x MOD7))*5
  SOUND1,0,1,1
NEXT

Fairly standard compression, 1 ASCII character per note.
Parameters of SOUND are as follows:
Channel (always 1 for the purposes of this challenge)
Amplitude (negative for on, 0 for off, positive is an envelope index)
Pitch (in increments of 1/4 semitone, with middle C at 100)
Duration (20ths of a second)

The range of the song is 13 notes, even though only 4 are used. To get this range into the 95-number range of printable ASCII, I had to squeeze the duration into an integer range of 7 and take it modulo 7. The following durations (in sixteenths) are used (with the exception of 6 which is never used): 1,2,3,4,6,8,12. To produce these numbers, I hit upon the idea of dividing 12 by a power of sqrt(2) (approximated by 1.4) and truncating.
The SOUND1,0,1,1 is an annoyance, costing 12 bytes. It's necessary to provide a pause between notes of identical pitch.

C - (Raw: 318 | WAV:  437)
8-bit (unsigned) mono PCM at 44800 Hz, 33.60 seconds.

File at mediafire (Note: It gets somewhat loud in there ...)

The mezzo forte, fortissimo and forte dynamics are somewhat artistically implemented. The fermatas could be better.
Code relies on unsigned long long being 8 octets and system little endian.
#include<stdio.h>
#include<math.h>
#ifdef RAW
main(){unsigned long long D[]={0x422422c13c13,0xc13c44813c22},X[]={27863,37193,46860,55727},O=0x406e64924910,i=0,j;float Z,A,U=40,P;for(;i<24;D[i++/12]>>=4){Z=X[O&3]/1e6;P=0;O>>=2;A=i>18?--U:i<14?U+i/2:U+30;for(j=(D[i/12]&15)*13440;j;A-=--j<7e3&&A>0?.01:0)putchar(A*sin(P+=Z)+128);}}
#else
main(){unsigned long long D[]={0x422422c13c13,0xc13c44813c22},X[]={27863,37193,46860,55727},O=0x406e64924910,i=0,j;float Z,A,U=40,P;int W[]={0x46464952,1570852,0x45564157,544501094,16,65537,44800,44800,524289,0x61746164,1505280};fwrite(W,4,11,stdout);for(;i<24;D[i++/12]>>=4){Z=X[O&3]/1e6;P=0;O>>=2;A=i>18?--U:i<14?U+i/2:U+30;for(j=(D[i/12]&15)*13440;j;A-=--j<7e3&&A>0?.01:0)putchar(A*sin(P+=Z)+128);}}
#endif

Compile and run with something like:
gcc -std=c99 -o taps taps.c -lm
./taps > taps.wav
play taps.wav

Add  -DRAW to compile-line for raw variant.
Raw output can be played with e.g. SoX play as:
play -c 1 -b 8 -r 44800 -t u8 <file>
       |    |       |       |
       |    |       |       +--- Unsigned 8-bit
       |    |       +----------- Sample rate
       |    +------------------- 8 Bits
       +------------------------ 1 Channel


text:
Sobel edge detector
Your task is to write a program that takes an input image and run it through edge-detection to become an output image.
The edge-detection works as follows (if unclear, see sobel edge detection):

The value for a pixel is the total brightness of a pixel, so if it is in color, you will need to convert it to grayscale first (to keep things simple and golf-able, you can take the average value for R, G and B).
The formulae for Gx and Gy for pixel p(i,j) are:

Gx = -1 * p(i-1, j-1) - 2 * p(i-1, j) - 1 * p(i-1, j+1) + 1 * p(i+1, j-1) + 2 * p(i+1, j) + 1 * p(i+1, j+1)
Gy = -1 * p(i-1, j-1) - 2 * p(i, j-1) - 1 * p(i+1, j-1) + 1 * p(i-1, j+1) + 2 * p(i, j+1) + 1 * p(i+1, j+1)

The value for the size of the edge at that pixel is then: √(Gx2 + Gy2)

The output image is for each pixel the size of the edge √(Gx2 + Gy2) as greyscale.
Bonuses:

Perform a gaussian blur to smooth out the image before edge-detection kicks in, to omit any smaller edges. This gives a bonus of -30% on the end result.
Take the angle of the edge in account. You give the output pixel some color, by taking the same greyscale value and adding color from a color wheel using the angle obtained from the formula arctan(Gy/Gx). This gives another bonus of -30% on the end result.

Rules:

You may omit the value for the edgepixels, and set them to black, or you may use 0 for any pixel outside the image.
Your ouput image must be in an image format that can be opened on most computers.
Output must be written to disk or be pipeable to a file.
Input is given as a commandline argument, in the form of a relative path to the image, or piped in from the commandline.
This is code golf, so shortest code in bytes wins!

Can you exactly specify the gaussian blur? Is the input grayscale as well, if no, how should we apply this edge detection to coloured images? Is it correct that the output image has the exact same size as the input, but the input is only performed on the inner pixels (not the one we've set to zero)?

Have you seen the videos about edge detection from Computerphile? I can smell a connection there :)

@flawr I have to test what gaussian blur is good for edge detection, so I don't really know what is a good value. more on Gaussian blur here. The input image is in color, and you'll need to convert it to grayscale first if you want to perform the edge detection. The edge detection is performed either A: on the inner pixels, and you set the outer 1px border of the output image to black, or B: on all pixels, and you take 0 as the value for any pixels outside the image.

@GiantTree nooooooo the video is totally not related :)

Why has this been down voted? It seems to be a perfectly valid question.

J, 166 164 161 154 150 144 143 bytes.
Not golfed too much; I mostly collapsed my longer implementation (see below), so there's probably lots of room for improvement. Uses BMP library. Saves result in file o. I handled edgepixels by only using full 3x3 cells, so the final image has width and height smaller by 2 pixels.
load'bmp'
S=:s,.0,.-s=:1 2 1
p=:([:*:[:+/[:,*)"2
'o'writebmp~256#.3#"0<.255<.%:(S&p+(|:S)&p)3 3,.;._3(3%~])+/"1(3#256)#:readbmp}:stdin''
exit''

Usage:
echo 'image.bmp' | jconsole golf.ijs

Expanded:
load 'bmp'

sobel1 =: 3 3 $ 1 0 _1 2 0 _2 1 0 _1
NB. transposed
sobel2 =: |: sobel1
NB. read image
image =: readbmp }: stdin''
NB. convert default representation to R,G,B arrays
rgbimage =: (3 # 256) #: image
NB. convert to grayscale
greyimage =: 3 %~ (+/"1) rgbimage
NB. 3x3 cells around each pixel
cells =: 3 3 ,.;._3 greyimage
NB. multiply 3x3 cell by 3x3 sobel, then sum all values in it
partial =: 4 : '+/"1 +/"1 x *"2 y'
NB. square partial (vertical and horizontal) results, sum and root
combine =: [: %: *:@[ + *:@]
NB. limit RGB values to 255
limit =: 255 <. ]
newimage =: limit (sobel1&partial combine sobel2&partial) cells
NB. convert back to J-friendly representation
to_save =: 256 #. 3 #"0 <. newimage
to_save writebmp 'out.bmp'
NB. jconsole stays open by default
exit''

Sample input and output:

This is a nice example of the ;._3 subarray operator. I noticed you defined a verb p with rank 2 to operate on the subarrays after you create them. You could instead operate on each subarray when you cut. My try at implementing it based on your work is 256#.3#"0<.255<.3 3((|:S)&*+&.*:&(+/)&,S&*);._3%&3(3#256)+/@#:. That should take it down to 126 bytes total.

I've got it down to 119 bytes with 'o'writebmp~256#.3#"0<.255<.3 3(*+&.*:&(+/)&,(*|:))&((-,.0,.])1 2 1);._3%&3(3#256)+/@#:readbmp]stdin'' assuming that only the filename is input on stdin. You can perform this using echo -n so that an extra newline is not included in stdin. On my computer, the script exits automatically when using a piped input to a script  which means I don't have to include the exit'' and can save an extra 6 bytes, but I'm not sure if this is true for all.

Python, 161*0.7=112.7 bytes
With the Gaussian Blur bonus.
As you did not explicitly forbid built-in methods, here is OpenCV:
from cv2 import*
from numpy import*
g=GaussianBlur(cvtColor(imread(raw_input()),6),(3,3),sigmaX=1)
x,y=Sobel(g,5,1,0),Sobel(g,5,0,1)
imwrite('s.png',sqrt(x*x+y*y))

Without bonus, 136 bytes
from cv2 import*
from numpy import*
g=cvtColor(imread(raw_input()),6)
x,y=Sobel(g,5,1,0),Sobel(g,5,0,1)
imwrite('s.png',sqrt(x*x+y*y))

Edit1: Replaced the named constans by their values.
Edit2: Uploaded samples

Could you possibly give a sample input and output image?

@R.Kap better late than never.

MATLAB, 212*0.4=84.8 bytes
Using the filter toolbox and the HSV colorspace
function f(x);f=@(i,x)imfilter(i,x);s=@(x)fspecial(x);S=s('sobel');A=f(double(rgb2gray(imread(x)))/255,s('gaussian'));X=f(A,S);Y=f(A,S');imwrite(hsv2rgb(cat(3,atan2(Y,X)/pi/2+0.5,0*A+1,sqrt(X.^2+Y.^2))),'t.png')

or ungolfed
function f(x)
f=@(i,x)imfilter(i,x);
s=@(x)fspecial(x);
S=s('sobel');
A=f(double(rgb2gray(imread(x)))/255,s('gaussian'));
X=f(A,S);
Y=f(A,S');
imwrite(hsv2rgb(cat(3,atan2(Y,X)/pi/2+0.5,0*A+1,sqrt(X.^2+Y.^2))),'t.png')

Love2D Lua, 466 Bytes
A=arg[2]i=love.image.newImageData q=math t=i(A)g=i(t:getWidth()-2,t:getHeight()-2)m={{-1,-2,-1},{0,0,0},{1,2,1}}M={{-1,0,1},{-2,0,2},{-1,0,1}}t:mapPixel(function(_,_,r,g,b)a=(r+g+b)/3 return a,a,a end)g:mapPixel(function(x,y)v=0 for Y=0,2 do for X=0,2 do v=v+(t:getPixel(x+X,y+Y)*m[Y+1][X+1])end end V=0 for Y=0,2 do for X=0,2 do V=V+(t:getPixel(x+X,y+Y)*M[Y+1][X+1])end end v=q.max(q.min(q.sqrt(V^2+v^2),255),0)return v,v,v end)g:encode('png',"o")love.event.quit()

Takes command line input, outputs to a file called "o" under your Love2D appsdata folder. Love2D Wont let you save files anywhere else.
Just about as golfed as I could get it, probably could be golfed further.
Explained
-- Assign the Input to A
A=arg[2]

-- Assign some macros to save FUTURE BYTES™
i=love.image.newImageData
q=math

-- t is the original image, g is the new output image. g is two pixels smaller, which is easier and better looking than a border.
t = i(A)
g = i(t:getWidth()-2,t:getHeight()-2)

-- m and M are our two sobel kernals. Fairly self explanitary.
m = {{-1,-2,-1}
    ,{0,0,0}
    ,{1,2,1}}

M = {{-1,0,1}
    ,{-2,0,2}
    ,{-1,0,1}}

-- Convert t to grayscale, to save doing this math later.
t:mapPixel(function(_,_,r,g,b)a=(r+g+b)/3 return a,a,a end)

-- Execute our kernals
g:mapPixel(function(x,y)
    -- v refers to the VERTICAL output of the Kernel m.
    v=0
    for Y=0,2 do
        for X=0,2 do
            v=v+(t:getPixel(x+X,y+Y)*m[Y+1][X+1])
        end
    end

    -- V is the HORIZONTAL of M
    V=0
    for Y=0,2 do
        for X=0,2 do
            V=V+(t:getPixel(x+X,y+Y)*M[Y+1][X+1])
        end
    end

    -- Clamp the values and sum them.
    v = q.max(q.min(q.sqrt(V^2 + v^2),255),0)
    -- Return the grayscale.
    return v,v,v
end)

-- Save, renaming the file. The golfed version just outputs as 'o'
g:encode('png',"S_".. A:gsub("(.*)%....","%1.png"))

-- Quit. Not needed, but I'm a sucker for self contained LOVE2D
love.event.quit()

Test

And...
Although it doesn't actually improve my score (Makes it worse infact), here is the version with the colour wheel implemented.
900 - 270 = 630 Bytes
A=arg[2]i=love.image.newImageData q=math t=i(A)g=i(t:getWidth()-2,t:getHeight()-2)m={{-1,-2,-1},{0,0,0},{1,2,1}}M={{-1,0,1},{-2,0,2},{-1,0,1}}function T(h,s,v)if s <=0 then return v,v,v end h,s,v=h*6,s,v/255 local c=v*s local x=(1-q.abs((h%2)-1))*c local m,r,g,b=(v-c),0,0,0 if h < 1 then r,g,b=c,x,0 elseif h < 2 then r,g,b=x,c,0 elseif h < 3 then r,g,b=0,c,x elseif h < 4 then r,g,b=0,x,c elseif h < 5 then r,g,b=x,0,c else r,g,b=c,0,x end return(r+m)*255,(g+m)*255,(b+m)*255 end t:mapPixel(function(_,_,r,g,b)a=(r+g+b)/3 return a,a,a end)g:mapPixel(function(x,y)v=0 for Y=0,2 do for X=0,2 do v=v+(t:getPixel(x+X,y+Y)*m[Y+1][X+1])end end V=0 for Y=0,2 do for X=0,2 do V=V+(t:getPixel(x+X,y+Y)*M[Y+1][X+1])end end h=v H=V v=q.max(q.min(q.sqrt(V^2+v^2),255),0)h=q.atan2(H,h)/q.pi*2 return T(h,1,v,255)end)g:encode('png',"S_".. A:gsub("(.*)%....","%1.png"))G=love.graphics.newImage(g)love.event.quit()


text:
Calculate the p-adic norm of a rational number
Calculate the p-adic norm of a rational number
Write a function or a program, that takes 3 integers m,n,p (where p is a positive prime) as input, that outputs the p-adic norm (denoted by |m/n|_p) as a (completely reduced) fraction. Fermat is known to have only very small margins, but what is rather unknown is that he only had a very small computer screen. So try to make the code as short as possible for it to fit on Fermat's screen!
Definition
Given a prime p, every fraction m/n can uniquely be written (ignoring the signs) as (a/b)* p^e such that e is a integer and p divides neither a nor b. The p-adic norm of m/n is p^-e. There is a special case, if the fraction is 0: |0|_p = 0.
The output format must be x/y (e.g. 1/3;  for integers both 10 or equivalently 10/1 is allowed, for negative numbers there must be a leading minus e.g. -1/3)
Details
The program must use stdin/stdout, or just consist of a function that returns the rational number or string. You have to assume that the input m/n is not fully reduced. You can assume that p is a prime. The program has to be able to process integers between -2^28 up to 2^28, and should not take more than 10 seconds.
Built in factorization and prime checking functionalities are not allowed, as well as built in base conversatio, and built in function that calculate the p-adic valuation or norm.
Examples (stolen from wikipedia):
x = m/n = 63/550 = 2^-1 * 3^2 * 5^-2 * 7 * 11^-1
|x|_2 = 2
|x|_3 = 1/9
|x|_5 = 25
|x|_7 = 1/7
|x|_11 = 11
|x|_13 = 1

Interesting trivia
(Not necessary to know/read for this challenge, but perhaps nice to read as a motivation.)
(Please correct me if I use the wrong words, or something else is wrong, I am not used to talking about this in english.)
If you consider the rational numbers as a field, then the p-adic norm induces the p-adic metric d_p(a,b) = |a-b|_p. Then you can complete this field with regard to this metric, that means you can construct a new field where all cauchy sequences converge, which is a nice topological property to have. (Which e.g. the rational numbers do not have, but the reals do.) These p-adic numbers are as you might have guessed, used a lot in number theory.
Another interesting result is Ostrowski's theorem which basically says, any absolut value (as defined below) on the rational numbers is one of the following three:

The trivial: |x|=0 iff x=0, |x|=1 otherwise
The standard (real): |x| = x if x>=0, |x| = -x if x<0
The p-adic (as we defined it).

An absolute value / a metric is just the generalization of what we consider a distance. A absolute value |.| satisfies following conditions:

|x| >= 0  and |x|=0 if x=0
|xy| = |x| |y|
|x+y| <= |x|+|y|

Note that you can easily construct metrics from absolute values and vice versa: |x| := d(0,x) or d(x,y) := |x-y|, so they are almost the same if you can add/substract/multiply (that is in integral domains). You can of course define a metric on more general sets, without this structure.

I assume Mathematica's PadicNorm function is also out? :P

You assume correct/ly. (which one is used here?)

Unless the Interesting Properties section is useful for completing the challenge, I'd say it's better to just link to that information for interested parties. Otherwise it unnecessarily clutters the post.

Just to be clear, output should be something like |x|_11 = 11, right? Or is just 11 fine? And does it have to handle the x=0 case?

@GlenO Correct, it does have to handle the x=0 case and for this example you can output 11 as well as 11/1, but you do not have to print |x|_11.

@AlexA. A PadicNorm function exists? I can't find it on Mma 10.1.

@legionmammal978 If it does not exist, this was clearly an innuendo on the fact that Mathematica has builtins for almost everything (no pun intended).

Julia, 94 80 75 bytes
f(m,n,p)=(k=gcd(m,n)
g(m)=m%p>0?g(m÷p)p:1
m!=0?print(g(n÷k),/,g(m÷k)):0)

Note: using linefeeds in place of semicolons for readability - will work same either way.
This is quite simple - the g(m,n) function uses recursion and remainder (%) to extract the p^n factor from input m, with n=1 as default and then multiplied by p on each step of the recursion, so that the output will be p^n. The code applies that to n/gcd(m,n), and then to m/gcd(m,n) to obtain the appropriate expression. k=gcd(m,n) is used to avoid calculating the gcd(m,n) twice, to save characters. m!=0 is a test to handle the case where x=0.
The output is of the form N/1 or 1/N as appropriate, where N is p^e.

J, 35 34 bytes
(,'/'&,)&":/@(%+./)@(]<.^+.|.@])x:

This is a binary verb that takes the prime p as its left argument, and the array m n as its right argument.
It always prints the slash /, and returns 0/1 if m = 0.
Use it like this:
  f =: (,'/'&,)&":/@(%+./)@(]<.^+.|.@])x:
  5 f 63 550
25/1

Explanation
The x: turns on extended precision, since we're handling very large numbers.
The rest of the code works as follows:
(,'/'&,)&":/@(%+./)@(]<.^+.|.@])
                        ^         Power: this gives the array p^n p^m
                         +.       Take element-wise GCD with
                           |.@]   the rotated array n m; this gives
                                  the largest powers of p that divide n and m
                      <.          Take element-wise minimum with
                     [            The array m n to handle the m=0 case correctly
              %+./                Divide this array by its GCD to get it to lowest terms
        &":/                      Convert both elements to strings
 ,'/'&,                           Insert the slash '/' between them

CJam, 42 bytes
q~)\_:*g_sW<o@*28#f{{{_@\%}h;}:G~}_~Gf/'/*

THis finishes with an error (after printing 0) for input 0. Try it online in the CJam interpreter.

Stax, 32 bytes
éE▌ΦΔΘao£╙)ΩuÅI~AAε3∞xC█&½╤%╩▌ïö

Run and debug it
Should be able to make it shorter. The native support for fraction by Stax is quite neat.
ASCII equivalent:
hY{y:+y|aEGsG-ys|**}0?}0{^scxHY%Cy/sWd