text:
Find the powertrain!
The winner (pretty obviously) is Dennis ♦, who used Jelly with 10 bytes!
This challenge will still be up here, however results won't be taken anymore.

The powertrain of a number is a concept by John Conway (who is also notable for making Conway's Game of Life, but that's not the point). It is defined as so:
For any number ..., the powertrain of the number is ... (i.e. every 2nd digit, from left to right, is a power of the digit before that). This process is repeated until the result is a single digit.
EXAMPLES:
2592 => (2^5)(9^2) = 2592 <= Cannot be further decomposed
 135 => (1^3)5 = 5
 1234 => (1^2)(3^4) = 81 => (8^1) = 8
 1100 => (1^1)(0^0) = 1 # (0^0) = 1
 -42 => -42 # Negative numbers output the input
Your challenge is, for any number n in the input, return powertrain(n) (i.e. n after the powertrain decomposition is finished) as output.
This is code golf, so shortest amount of bytes wins.
DISCLAIMER-THINGS:

You can have an odd number of digits in the input, the last digit just won't have a power.
0^0 is 1, because if it was 0, then a lot of numbers would instantly collapse to 0 or 1.
If the number is indestructible in any part of the computation process (e.g. if it ends up with 2592), then you can just output the number.
If the input is < 10 (i.e. all single digit numbers and negatives), output the input.

I'll probably announce a winner after a few hours days.
Current leaderboard:

Jelly (Dennis ♦): 10
Pyth (DenkerAffe): 16
MATL (Don Muesli): 21
Perl (Ton Hospel): 42
Haskell (Damien): 64
Javascript ES6 (edc65): 71
Mathematica (murphy): 74
Mathematica (LegionMammal978) and Haskell (Renzeee): 77
Python 2 (mathmandan): 111
Python 3 (Erwan): 161
Java 8 (Blue): 229
Oracle SQL 11.2 (Jeto): 456
Befunge '93 (Lex): 490

Some more test cases would be appreciated.

So the input will have 4 digits max?

@DenkerAffe No, there is no bound to the digits. They can be as long as you want. The examples were just for simplicity (because I can't be bothered to work out really long ones).

What if a cycle is reached, but the period of the cycle is not 1, or the input number is not part of the cycle?

You can output the repeating number. For loops of numbers, I'm certain there aren't any within the realms of feasibility, so you can output whatever, really. Also, it's left to right - I am such an idiot, it's actually not funny.

"I'm certain there aren't any within the realms of feasibility". Can we assume it will never happen? I.e. allowing the loop to go on forever if a cycle of period > 1 is reached?

@StewieGriffin There haven't been any found so far. Then again, Google gives results of motor vehicles when I search up "powertrain", so... you can assume it never happens.

Proposed test cases: 1100 and -42 It's easy to miss rules about edge cases if the do not show up in the test cases.

What exactly is powertrain(n)? Is it a number, a list of numbers, or a sequence of computations? The output format is unclear from the spec.

@Zgarb It's just the number going through the powertrain. I couldn't think of a better way to describe it, but it's not a function or anything.

24547284284866560000000000 also has a period of 1.

But 24547284284866560000000000 is so unfeasibly large that no language has the capacity to do that (also, that is why I put the 0^0 = 1 rule, coincidentally).

Jelly, 15 14 12 10 bytes
Ds2*/€Pµ³¡

Try it online!
How it works
Ds2*/€Pµ³¡  Main link. Argument: n

D           Convert n into the array of its decimal digits.
 s2         Split into pairs of digits.
   */€      Reduce each pair by exponentiation.
      P     Take the product of the resulting powers.
       µ    Push the preceding chain as a link, and start a new one.
        ³¡  Execute the link n times and return the last result.

This could be made shorter by simply iterating n times, but I don't have a proof that it works for all possible inputs.

You should be ok for any reasonable number. In fact you are almost certainly ok for ANY number using 16 iterations: https://oeis.org/A133503

@Dennis Hm, that's what I do in my answer

@DonMuesli And now that I've thought about it, it probably works. The odds of getting a 0 and an odd index are overwhelming...

In modern Jelly, this could be done in 7 bytes: D*2/Pµ¡

Haskell, 67 64 bytes
(>>=(==))>>=until$p.show is an unnamed function taking an integer as input and returning its powertrain.
Saved 3 bytes thanks to Zgarb
p(x:y:r)=p[x]^p[y]*p r;p[]=1;p x=read x
(>>=(==))>>=until$p.show

((==)=<<g) saves two bytes over (\n->g n==n).

Wow, I'm not familiar with the ((->) r) instance of Monad. Thanks for the trick.

This barrage of punctuation marks (>>=(==))>>= really looks like a train!

Perl, 42 48 bytes
Include +2 for -lp (you can drop the -l too but I like newlines)
Run with input on STDIN, e.g.
perl -lp powertrain.pl <<< 1234

powertrain.pl:
s/\B/1&pos?"**":"*"/eg until++$.>($_=eval)

(on older perls you can also drop the space between the regex and until)
This won't be able to handle the fixed point 24547284284866560000000000 but that large a value won't work anyways because by that time perl switched to exponential notation.
The above version is will in fact work fast (at most 2592 loops) for all numbers that perl can represent without using exponential notation since it is proven that there are no fixed points between 2592 and 24547284284866560000000000 (https://oeis.org/A135385)
This does however assume something as yet unproven. In principle there could be a reduction that takes more than X=10^7 steps (it is conjectured that no non-fixed point takes more than 16 steps, https://oeis.org/A133503) whose value dips below X (but above 10^7) and then goes up again. If that is the case I must fall back to:
s/\B/1&pos?"**":"*"/eg until$s{$_=eval}++||/-/

Explanation
The code works by putting ** and * (alternating) between the digits
s/\B/1&pos?"**":"*"/eg

so 2592 becomes 2**5*9**2 and 12345 becomes 1**2*3**4*5. These are
valid perl expressions that can be evaluated with
$_ = eval

(0**0 is 1 in perl). Then just put a loop around that with a counter that makes it expire. Since except for the fixed points the values go down extremely quickly the powertrain series converges before the counter gets a chance to really get going

Pyth, 25 18 11 16 bytes
?<Q0Qu*F^McjGT2Q

Try it here!
7 14 bytes saved with help from @Jakube
Explanation

?<Q0Qu*F^McjGT2Q   # Q = eval(input)

?<Q0Q              # If input is negative return Q
     u         Q   # apply the following function until we reach a cycle
                   # starting value is Q and the current value is in G
           jGT     # split input into a list of digits
          c   2    # split into pairs of 2
        ^M         # compute the power for every pair
      *F           # compute the product of all powers

Is Pyth basically just a golfed version of Python, except with minor changes?

@Jakube Thanks for the hints! :) Still early in the morning for me...

@DerpfacePython Yea, kinda. Have a look at the docs if you wanna learn about it.

No problem. ;-)

This looks buggy for cases where the input is negative.

@PeterTaylor Fixed!

@DerpfacePython Pyth started out as just "shortened Python", but to call it that now would be disingenuous. Pyth has significantly diverged from Python.

Python 2, 111 bytes
def p(n,b=0,o=''):
 if n<1:return n
 for c in str(n):o+=c+'**'[b:];b=~b
 j=eval(o+'1');return p(j)if j-n else j

The idea is to make a string where the digits of n are separated by operations which alternate between * and **, and then eval that string. (Other solutions use this same idea; see for example Ton Hospel's Perl answer.)
So, the operation switches back and forth between '**'[0:], which is **, and '**'[-1:], which is just *.
However, by the end of the for-loop, the string ends with an operation (one or the other), so we either need to drop the last operation, or else add another digit, in order for the string to make sense.
Fortunately, appending a 1 on the end will work no matter which operation is last. (If you like, 1 is a one-sided identity from the right, for both multiplication and exponentiation. Another way of saying this is that powertrain(n) == powertrain(10*n + 1) for all n>0.)
Finally, if the result of the eval happens to be the same as the input (as in a length-1 cycle), the function terminates.  Otherwise, the function calls itself on the result.  (It will hang forever on any cycle of length > 1, but according to the OP's comments I am allowed to assume there are no such cycles.)
(Note: the above explanation works for single-digit positive integers, since a single-digit input n will be completed to n**1 which will result in a 1-cycle. However, we also need to accept non-positive input, so there's a condition at the beginning that short-circuits if the input is less than 1. We could eliminate that line, and save 17 bytes, if the input were guaranteed to be non-negative.)

This sounds biased, but... upvote for being Python 2. And it has an explanation.

@DerpfacePython Thanks! (I guess this would work just as well in Python 3...)

Java 8, 265 244 229 bytes
This is my first answer, but I have been reading this site for a while and think I know what I'm doing. At least it beats befunge and SQL...
Unfortunately, like other answers, this one does not work for 24547284284866560000000000 due to java'a built in restrictions on how large integers can get.
Saved 36 bytes thanks to @JackAmmo
public int p(int n){if(n<10)return n;int i=1,t=1,s=(int)Math.log10(n)+1,r[]=new int[s];for(;i<=s;){int a=(int)Math.pow(10,i);r[s-i++]=n%a/(a/10);}for(i=0;i<s-1;i++)t*=Math.pow(r[i],r[++i]);if(s%2==1)t*=r[s-1];return n==t?n:p(t);}

Ungolfed Explanation
public int powertrain(int input){
    //handles negative and 1-digit cases
    if(input<10)return input;
    //initialize output variable
    int total=1;
    // get "length" of number. Shorter than getting length of string representation
    int size=(int)Math.log10(input)+1;
    //initialize array to store digits
    int[] array=new int[size];
    //Now, because Java doesn't have support
    // for the "**" operation, and the way of turning
    // an integer into a string takes too many bytes,
    // I decided just to put every digit into an array with
    // math and iterate from there
    for(int i=1;i<=size;){
        int place=(int)Math.pow(10,i);
        //crazy math. Saved 1 byte by incrementing i when accessed
        array[size-i++]=input%place/(place/10);
    }
    for(int i=0;i<size-1;i++)
        //This is where the train happens.
        //Saved 1 byte by incrementing while accessing
        //again, instead of i+=2 and i+1
        total*=Math.pow(array[i],array[++i]);
    //Make sure last number isn't left out if size is odd
    if(size%2==1)
        total*=array[size-1];
    //if we end up with same number, stop.
    //otherwise, keep recurring
    return input==total?input:powertrain(total);
}

In your first if...else if(n<10)return n;else{...} the else is unneccessary since logically everything in that else block would only run anyway when n<10 is false. Removing the else and the 2 matching braces will save you 6 bytes.  There's a similar situation with your last if...else if(n==t)return n;else return p(t); remove the else and the space after it to save another 5 bytes. In fact you can shorten it even further if you use the triadic operator instead of the if...else like so return n==t?n:p(t);

you can save a few more bytes (17 i think) by declaring t,s,r, and the for loop's i together int t=i=1,s=(int)Math.log10(n)+1,r[]=new int[s];for(;i<=s;){...}for(i=0;...)...

@JackAmmo I wasn't aware variables could be declared like that, I'll have to try it. Thanks for your help!

yeah, you just have to be careful with the order of declaring them if you're using one to initialize another (like how r uses s to define it's length)

for arbitrary large numbers, you should look into java's BigInteger class http://docs.oracle.com/javase/8/docs/api/java/math/BigInteger.html

@JackAmmo unfortunately, code golf

JavaScript (ES6) 71
A recursive function, stopping when a repetition is found. This could not work for longer loops (2 or more value repeating) but it seems this could not happen, at least in the limited range of javascript number precision (17 digits)
f=n=>[...n+'1'].map((c,i)=>i&1?r*=Math.pow(d,c):d=c,r=1)&&n-r?f(r):n

Test

f=n=>[...n+'1'].map((c,i)=>i&1?r*=Math.pow(d,c):d=c,r=1)&&n-r?f(r):n

function go()
{
  v=+I.value
  R.textContent=f(v)
}

go()
<input id=I value="1234"><button onclick="go()">Go</button>

Nice of that +'1' to kill two birds with one stone!

I don't know whether you'd investigated it already but the best I could do with replace was 1 byte longer: f=n=>`${n}1`.replace(/../g,([x,y])=>r*=Math.pow(x,y),r=1)&&n-r?f(r):n

@Neil I tried hard too, but that template string is a new idea ...

Haskell, 100 79 77 bytes
g x|x==h x=x|1<2=g$h x;h=i.map(read.(:[])).show;i[]=1;i[a]=a;i(a:b:c)=a^b*i c

Not golfed:
g x|x==h x=x|1<2=g$h x
h=i.map(read.(:[])).show
i[]=1
i[a]=a
i(a:b:c)=a^b*i c

This function splits the input into digits and does the trick via i.
EDIT: Thanks to nimi for some tips.

A few tips: a) i(a:[])=a is i[a]=a, b) no need for max 1, because 0^0 = 1 in Haskell, c) replace (:[]) with pure, d) move the let within g into a separate function and replace the if ... then ... else with guards: h=i.map(read.pure).show ; g x|x==h x=x|1<2=h x

pure is not in Prelude, but the rest of the tips work, thanks. I was trying to do it with guards, but ended up using ; before the guard and that didn't work, but now I know how it should work.

pure is in the Prelude that comes with base-4.8.2.0. Don't know when it was introduced. You don't need the ( ) in i([a])=a.

MATL, 21 bytes
tt0>*:"V!UtQgv9L2#)^p

It may take a few seconds to produce the output.
EDIT (July 30, 2016): the linked code replaces 9L by 1L to adapt to recent changes in the language.
Try it online!
This uses the following two tricks to reduce byte count at the expense of code efficiency:

Iterate n times instead of waiting until a cycle is found. This is acceptable as per OP's comments.
For an odd number of digits a final 1 would have to be appended to complete the final power operation. Instead of that, the number of added 1 is the number of digits. This ensures an even number, so all power operations can be done (even if the last ones are unnecessary 1^1 operations).

Code:
t         % implicitly take input x. Duplicate
t0>*      % duplicate. Is it greater than 0? Multiply. This gives 0 if input is negative,
          % or leaves the input unchanged otherwise
:         % Generate array [1,2,...,x]
"         % for each (repeat x times)
  V       %   convert x to string
  !       %   transpose into column char array
  U       %   convert each char into number
  tQg     %   duplicate. Add 1 so that no entry is zero. Convert to logical: gives ones
  v       %   concatenate vertically
  9L2#)   %   separate odd-indexed and even-indexed entries
  ^       %   element-wise power
  p       %   product of all entries
          % implicitly end for each
          % implicitly display

Uh... heh heh heh... when I said "loops of numbers", I meant numbers that went like this - a, b, a, b ad infinitum (more than one term). If one term is repeated, then you should output that number. Sorry if that wasn't really clear.

If one term is repeated, I'm outputting that number. I output the result after many iterations

Oh, I understand now... just asking, how many iterations would it be (approx.)? Because when I type in 2592 into the input, it doesn't seem to output anything for quite a while.

The number of iterations is the input number, so 2592 in that case. Yes, it takes a while

Mathematica, 77 bytes
Times@@(If[#2<1,1,#^#2]&)@@@Partition[IntegerDigits@#,2,2,1,1]&~FixedPoint~#&

Anonymous function. Not too complicated.

Even so, can I still have an explanation?

Befunge 720 490 bytes
Couldn't resist to do one more after the Never tell me the odds thing. So, I've optimized the "ASCII-fier" of the previous one. In this case I saw no need to let the instruction pointer run over the digits to read them, so I haven't taken the effort to make them human readable. So it's more of a digitifier, now.
Again, if you guys want an explanation, let me know in the comments, I'll try to create some helpful descriptions. You can copy paste the code into the interpreter. I've found that the example 24547284284866560000000000 outputs 0, but that seems to be a problem with getting such a large value from a point on the grid, as you can clearly see the correct value being stored in the final steps.
v                                                    //top row is used for "variables"
>&:0`#v_.@                                           //initialize the counter
v     <                           g01_v#-p01:  <     //on our way back to the digitifier, check if we're done
>::>210p>55+%:10g0p-55+/:v            >10g.@         //digitifier, creates a series of ASCII characters at the top line, one for each digit in the source
        ^p01+1g01    _v#:<
v1$$                  <                              //forget some remainders of the digitifier, put 1 on the stack as a base of calculation
                      v p0-1g01-1g0-1g01*g0g01<      //taking powers of each pair of digit
>10g2-!#v_10g1-!#v_  1>                10g1-0g|
^                                  p01-2g01  *<
        >10g0g*  >                             ^     //extra multiplication with last digit if the number of digits was odd

This version also supports negative input. It's a great improvement on the previous version, if I say so myself. At least 1 bug was fixed and the size was reduced greatly.

How many bytes more will it take for the thing to input negative numbers?

I'm not sure to be honest. I had some problems with negative numbers and writing them somewhere in the grid. I'll try it again.

I just found another bug, too. I did manage to add support for negative numbers. I'll post an update soon! It'll probably be the same amount of bytes, since I count the entire grid.

Mathematica, 74 bytes
0~f~0=f[]=1
f@n_=n
f[a_,b_,c___]:=f[c]a^b
#//.i_/;i>0:>f@@IntegerDigits@i&

Explanation
This solution uses a helper function f, which takes the digits of the number as arguments and applies one iteration of the power train operation. The last line is a pure function that is crafted to exploit the ReplaceRepeated function (or //. for short), which applies a rule to an expression (in this case the argument # of the pure function) until it doesn't change anymore.
The rule i_/;i>0:>f@@IntegerDigits@i replaces anything non-negative with the function f applied to its decimal digits.

Line 2 doesn't work (use :=)

Explanation, please?

@CatsAreFluffy I don't see your problem with line 2. It works fine for me!

SetDelayed::write: Tag Times in n f[a_,b_,c___] is Protected. >>, Set::write: Tag Times in 1 f[n_] is Protected. >> The second error disappears when i use :=vs=.

Sorry, can't reproduce that error. But your output indicates that the line-breaks are part of the problem. Please try the version with ;s instead of the line-breaks: 0~f~0=f[]=1;f@n_=n;f[a_,b_,c___]:=f[c]a^b;#//.i_/;i>0:>f@@IntegerDigits@i&

Python 3, 169 161 bytes
def f(s):
 o=[['1',s]['-'in s]]
 while s not in o:
  o+=[s];s+='1'*(len(s)%2==1);r=1;
  for i,j in zip(s[::2],s[1::2]):r*=int(i)**int(j);s=str(r);
 return o[-1]

Ungoldfed
def f(s):
 o=[['1',s]['-'in s]]
 while s not in o:
  o+=[s]
  s+='1'*(len(s)%2==1)
  r=1
  for i,j in zip(s[::2],s[1::2]):
   r*=int(i)**int(j)
  s=str(r)
 return o[-1]

Results
>>> [f(i) for i in ['135', '1234', '642', '2592', '-15']]
['5', '8', '2592', '2592', '-15']

@PeterTaylor Fixed!

You can put multiple statements in one line if you seperate them with a ; This way you saves you the intendation whitespaces. Also you can put the body of the for loop on that same line.

Suggested golfing:def f(s,o=[['1',s]["-"in s]],n=int): while s not in o: o+=[s];s+=1*(len(s)%2<1);r=1 for i,j in zip(s[::2],s[1::2]):r*=n(i)**n(j) s=str(r) return o[-1]

@CatsAreFluffy o=[['1',s]["-"in s]] in default argument don't work for me it raise a error  s not defined

Oops, move o to the next line.

Oracle SQL 11.2, 456 bytes
WITH v(n,c,i,f,t)AS(SELECT:1+0,CEIL(LENGTH(:1)/2),1,'1',0 FROM DUAL UNION ALL SELECT DECODE(SIGN(c-i+1),-1,t,n),DECODE(SIGN(c-i+1),-1,CEIL(LENGTH(t)/2),c),DECODE(SIGN(c-i+1),-1,1,i+1),DECODE(SIGN(c-i+1),-1,'1',RTRIM(f||'*'||NVL(POWER(SUBSTR(n,i*2-1,1),SUBSTR(n,i*2,1)),SUBSTR(n,i*2-1,1)),'*')),DECODE(SIGN(c-i+1),-1,0,TO_NUMBER(column_value))FROM v,XMLTABLE(f)WHERE i<=c+2 AND:1>9)CYCLE n,c,i,f,t SET s TO 1 DEFAULT 0SELECT NVL(SUM(n),:1) FROM v WHERE s=1;

Un-golfed
WITH v(n,c,i,f,t) AS
(
  SELECT :1+0,CEIL(LENGTH(:1)/2),1,'1',0 FROM DUAL
  UNION ALL
  SELECT DECODE(SIGN(c-i+1),-1,t,n),
         DECODE(SIGN(c-i+1),-1,CEIL(LENGTH(t)/2),c),
         DECODE(SIGN(c-i+1),-1,1,i+1),
         DECODE(SIGN(c-i+1),-1,'1',RTRIM(f||'*'||NVL(POWER(SUBSTR(n,i*2-1,1),SUBSTR(n,i*2,1)),SUBSTR(n,i*2-1,1)),'*')),
         DECODE(SIGN(c-i+1),-1,0,TO_NUMBER(column_value))
  FROM v,XMLTABLE(f) WHERE i<=c+2 AND :1>9
)
CYCLE n,c,i,f,t SET s TO 1 DEFAULT 0
SELECT NVL(SUM(n),:1) FROM v WHERE s=1;

v is a recursive view, parameters are
n : number to split in 2 digits parts
c : number of 2 digits parts
i : current 2 digits part to compute
f : string concatenating the powers with * as separator
t : evaluation of f
The DECODEs switch to the next number to split and compute when all the parts of the current number are done.
XMLTABLE(f) takes an expression an evaluates it, putting the result in the pseudo column "column_value".
It's the golfed version of http://tkyte.blogspot.fr/2010/04/evaluating-expression-like-calculator.html
CYCLE is the oracle build in cycle detection and is used as the exit condition.
Since the result for :1<10 is :1 and v returns no row for those cases, SUM forces a row with NULL as the value.
NVL returns :1 as the result if the row is null.

Where's the explanation?

Husk, 10 bytes
ωöΠmF`^C2d

Try it online!
Explanation
ωöΠmF`^C2d
ωö         apply the following functions till a fixed point is reached:
         d get base-10 digits
       C2  split into groups of two
   mF`^    map each pair to power
  Π        multiply all the powers.

Japt, 13 bytes
Èì ò ®rpÃ×}gN

Try it


text:
PPCG Senior Prank
We're graduating to a full site soon, and there's only one thing left to do before graduation: pull a senior prank! I think we should do a variation on the classic "fill a hallway with cups of water" gag.
Challenge
Your program will read in text and output that text, covered in upside-down cups of water. An upside-down cup of water looks like this: /~\
These cups can only be placed in whitespace in the input, and can only be placed so that all three characters of the cup are directly above a non-whitespace character (otherwise the water would spill out!). Cups cannot be stacked on top of other cups. Cups must be placed in every available opening, and it is assumed that every input is surrounded by an infinite field of whitespace.
You may assume that the input is padded to a rectangle with spaces.
We need to pull the prank off quickly and without anyone noticing, so fewest bytes in each language wins.
Test Cases
Input:
     ____________________________________________
    /   ___    /   ___    /   ______/   ________/
   /   /__/   /   /__/   /   /     /   /_______
  /   _______/   _______/   /     /   //__    /
 /   /      /   /      /   /_____/   /___/   /
/___/      /___/      /_________/___________/

Output:
     /~\/~\/~\/~\/~\/~\/~\/~\/~\/~\/~\/~\/~\/~\
     ____________________________________________
    /   ___    /   ___    /   ______/   ________/
   /   /__//~\/   /__//~\/   /     /   /_______
  /   _______/   _______/   //~\  /   //__    /
 //~\/      //~\/      //~\/_____//~\/___//~\/
/___/      /___/      /_________/___________/

Input:
 L
LOL  ROFL:ROFL:LOL:ROFL:ROFL
 L\\        ____I____
    ========    |  |[\
            \___O==___)
            ___I_I__/

Output:
 L   /~\/~\/~\/~\/~\/~\/~\
LOL  ROFL:ROFL:LOL:ROFL:ROFL
 L\\/~\/~\  ____I____
    ========/~\ |  |[\
            \___O==___)
            ___I_I__/

This might be the time to resurrect some of those 2D pattern matching languages...

Retina, 41 bytes
Byte count assumes ISO 8859-1 encoding.
(?<=(.)*)(?=.*¶(?>(?<-1>.)*)\S{3})
/~\

Note that the first line has three trailing spaces.
Requires the input to be padded to a rectangle.
Try it online!
Explanation
This is fairly standard vertical matching:
(?<=(.)*)

This counts the characters preceding the match by capturing that many characters into group 1.
(?=.*¶(?>(?<-1>.)*)\S{3})

This checks that there are three non-space characters on at the same position in the next line. This is done by popping from group 1 until its empty with (?<-1>.)* and preventing backtracking with the atomic group (?>...).
Finally we match the actual spaces. Those are simply replaced with the literal string /~\. Conveniently, matches are found from left to right and cannot overlap.

JavaScript (ES6), 163 bytes
a=>(z=a.split`
`,z.unshift(z[0].replace(/./g,' ')),z).map((b,i)=>b.replace(/   /g, (c,j)=>(!z[i+1]||!z[i+1][j+2]||/ /.test(z[i+1].slice(j,j+3))?c:'/~\\'))).join`
`

Quickly hacked together solution, can definitely be golfed down. Adds a blank line above, finds triple spaces, and replaces with a cup if the next line does not contain any spaces. Makes the allowed assumption that input will be rectangular. Any backspaces in the input need escaping (as one would expect with JS).

I think this returns the wrong output for a test.

JavaScript (ES6), 109 bytes
s=>s.replace(/.*\n/,m=>(t=m).replace(/./g,' ')+m).replace(eval(`/   (?=[^]{${t.length-3}}[^ ]{3})/g`),"/~\\")

As well as requiring rectangular input, also assumes the first line ends with a newline, even if it is the only line of input. Uses a dynamically generated lookahead to ensure that it finds three spaces "above" three non-spaces, so as not to get confused by holes.

source: Stack Exchange

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

sort: votes


text:
Cities: Sightlines
I'm at position (0, 0) of an infinite two-dimensional city, which is perfectly divided into blocks centered at each lattice point, some of which contain buildings. A building at a certain point (x, y) takes up the entire square with opposite corners at (x-.5, y-.5) and  (x+.5, y+.5), including its border. A building is visible iff there is some line segment from (0, 0) to a point in the building which does not intersect any other building.
For example, I (the @) can see 6 buildings (*) in the following city:
  *
 *
*
*@
x**
 *  y

I can't see the building marked with an x, at (-1, -1) because it's obstructed by the two adjacent to it; or the one marked with a y at (3, -2) because it's obstructed by the edge of the (1, -1) building.
Input
A multiline string, or list of lines, optionally padded with spaces into a rectangle. It will contain only:

a single @ (my position)
Spaces
*, which represent buildings.

There will always be at least one building, and therefore at least one visible building.
Output
The number of visible buildings.
Test cases
*@
1

* *******
 @     *
7

*****
**@**
*****
4

   *
  **
@ **
2

*      *
 *    *
@
4

@
 *
  ***
1

Thanks to @Geobits for the title.

Related.

About test case 3, it's surrounded by 8 * but the result is 4.  But those corners don't seem to be blocked by other buildings. Is there a rule not to include corners?

@LukStorms Imagine each of the stars are actually cubes, like in minecraft. If you were standing in the middle of that, you would only be able to see 4 blocks

Would you be so kind to wait before I enter my golfed solution (very soon) before awarding the bounty? :)

Unity + C#, 589 bytes
This is probably the worst language to do a code golf in (read: worse than Java), but Unity comes with a lot a helpful features for this challenge.
EDIT: missed a couple of spaces, returns list length, not counter
Golfed:
using UnityEngine;using System.Collections;public class c:MonoBehaviour{public int h(string[]i){ArrayList k=new ArrayList();for(int y=0;y<i.Length;y++){char[]l=i[y].ToCharArray();int x=0;foreach(char c in l){if(c=='*'){GameObject b=GameObject.CreatePrimitive(PrimitiveType.Cube);b.transform.position=new Vector3(x,y);}if(c=='@')transform.position=new Vector3(x,y);x++;}}for(int n=0;n<3600;n++){RaycastHit h;Physics.Raycast(transform.position,Quaternion.Euler(0,0,n/10)*Vector3.up,out h);if(h.collider!=null){GameObject o=h.collider.gameObject;if(!k.Contains(o))k.Add(o);}}return k.Count;}}

Ungolfed:
using UnityEngine;
using System.Collections;

public class citiessightlines : MonoBehaviour {

    public ArrayList todelete;   // Anything concerning this array just has to do with cleanup of
                                 //objects for testing, and doesn't contribute to the byte count.
    void Start()
    {
        todelete = new ArrayList();
    }
    public int calcSight(string[]input)
    {
        todelete = new ArrayList();
        int total = 0;
        ArrayList check = new ArrayList();
        for (int y=0;y < input.Length; y++)
        {
            char[] line = input[y].ToCharArray();
            for (int x = 0; x < line.Length; x++)
            {
                char c = line[x];
                if (c == '*')
                {
                    GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
                    cube.transform.position = new Vector3(x, y);
                    todelete.Add(cube);
                }
                if (c == '@')
                {
                    transform.position = new Vector3(x, y);
                }
            }
        }
        for (int angle=0; angle < 3600; angle++)
        {
            RaycastHit hit;
            Physics.Raycast(transform.position, Quaternion.Euler(0, 0, angle/10) * Vector3.up, out hit);
            if (hit.collider!=null)
            {
                GameObject hitObject = hit.collider.gameObject;
                if (!check.Contains(hitObject)&&hitObject!=this)
                {
                    total += 1;
                    check.Add(hitObject);
                }
           }
        }
        return total;
    }
}

I used 3600 raycasts because it fails the 5th test case with lower. It still might fail for even larger/more precise test cases.
Unfortunately, both webgl and desktop builds seem to break, so all I have is the source code to test with on github.

read: worse than Java This is 383 bytes shorter than the Java solution!

@dorukayhan I mean that by most of the built-ins are more verbose than Java

I don't know about C# but couldn't you replace total+=1 with total++? I think another way to save some characters is to create the cube of the building and setting it's position in one statement. You don't seem to reuse the cube variable anywhere.

@Frozn I'm not actually doing that in my golfed code

Just looked at the code and saw that you changed the counting there. I always assume that the golfed version is just a whitespace-stripped version of the longer one, but that's obviously not the case here. Regarding the second part: I think you do. It's GameObject b=GameObject.CreatePrimitive(PrimitiveType.Cube);b.transform.position=new Vector3(x,y);. I don't know whether it's possible in C# but in Java one could write GameObject.CreatePrimitive(PrimitiveType.Cube).transform.position=new Vector3(x,y); instead.

Java 8 lambda, 1506 1002 972 942 characters
I wanted to beat this challenge, as it is very interesting. The result (not very golfy) can be seen here:
import java.util.*;f->{Set<double[]>B=new HashSet(),r,n;double a,M,m,P=Math.PI*2,z=.5;int x=0,y,v=0,i,j,c[],p,q,l=g.length;for(;x<l;x++)for(y=0;y<g[x].length;y++)if(g[x][y]>63)for(;;){c=new int[]{-1};M=2e31-1;for(i=0;i<l;i++)for(j=0;j<g[i].length;j++)if(g[i][j]==42)if((m=(p=x-i)*p+(q=y-j)*q)<M){M=m;c=new int[]{i,j};}if(c[0]<0)break;g[c[0]][c[1]]=0;double[]A={(a=Math.atan2((c[1]-=y)-z,(c[0]-=x)-z))<0?a+P:a,(a=Math.atan2(c[1]+z,c[0]-z))<0?a+P:a,(a=Math.atan2(c[1]+z,c[0]+z))<0?a+P:a,(a=Math.atan2(c[1]-z,c[0]+z))<0?a+P:a};r=new HashSet();M=-P;m=P;for(double d:A){M=d>M?d:M;m=d<m?d:m;}r.add(new double[]{m,M});for(double[]t:B){n=new HashSet();for(double[]h:r)for(double[]u:t[0]<h[0]?t[1]<h[0]?new double[][]{h}:t[1]<h[1]?new double[][]{{t[1],h[1]}}:new double[0][]:t[0]>h[1]?new double[][]{h}:t[1]>h[1]?new double[][]{{h[0],t[0]}}:new double[][]{{h[0],t[0]},{t[1],h[1]}})if(u[0]<u[1])n.add(u);r=n;}B.addAll(r);if(!r.isEmpty())v++;}return v;}

Of course this also exists in the ungolfed version:
import java.util.*;

public class AngleCheck {

    static int getViewableBuildingsC(char[][] grid) {

        Set<double[]> blocked = new HashSet(), ranges, newRanges;

        double angle, max, min, PI2 = Math.PI * 2, half = 0.5;

        int x = 0, y, viewable = 0, i, j, building[], dX, dY, length = grid.length;

        for (; x < length; x++) {
            for (y = 0; y < grid[x].length; y++) {
                if (grid[x][y] > 63) {
                    for (;;) {
                        building = new int[]{-1};
                        max = 2e31-1;
                        for (i = 0; i < length; i++) {
                            for (j = 0; j < grid[i].length; j++) {
                                if (grid[i][j] == 42) {
                                    if ((min = (dX = x - i) * dX + (dY = y - j) * dY) < max) {
                                        max = min;
                                        building = new int[]{i, j};
                                    }
                                }
                            }
                        }

                        if (building[0] < 0)
                            break;

                        grid[building[0]][building[1]] = 0;
                        double[] angles = {
                                        (angle = Math.atan2((building[1] -= y) - half, (building[0] -= x) - half)) < 0 ? angle + PI2 : angle,
                                        (angle = Math.atan2(building[1] + half, building[0] - half)) < 0 ? angle + PI2 : angle,
                                        (angle = Math.atan2(building[1] + half, building[0] + half)) < 0 ? angle + PI2 : angle,
                                        (angle = Math.atan2(building[1] - half, building[0] + half)) < 0 ? angle + PI2 : angle};

                        ranges = new HashSet();

                        max = -PI2;
                        min = PI2;
                        for (double d : angles) {
                            max = d > max ? d : max;
                            min = d < min ? d : min;
                        }

                        ranges.add(new double[]{min, max});

                        for (double[] reference : blocked) {
                            newRanges = new HashSet();
                            for (double[] currentRange : ranges) {
                                for (double[] subRange : reference[0] < currentRange[0] ?
                                            reference[1] < currentRange[0] ?
                                                // whole range after referencerange
                                                new double[][]{currentRange}
                                            :
                                                reference[1] < currentRange[1] ?
                                                    // lower bound inside referencerange, but upper bound outside
                                                    new double[][]{{reference[1], currentRange[1]}}
                                                :
                                                    // whole range inside referencerange -> nothing free
                                                    new double[0][]
                                        :
                                            // greater or equal lower bound
                                            reference[0] > currentRange[1] ?
                                                // whole range before referencerange
                                                new double[][]{currentRange}
                                            :
                                                // ranges overlap
                                                reference[1] > currentRange[1] ?
                                                    // range starts before and ends in reference range
                                                    new double[][]{{currentRange[0], reference[0]}}
                                                :
                                                    // referencerange is in the range -> two free parts, one before, one after this
                                                    new double[][]{{currentRange[0], reference[0]}, {reference[1], currentRange[1]}}) {
                                    if (subRange[0] < subRange[1])
                                        newRanges.add(subRange);
                                }
                            }
                            ranges = newRanges;
                        }

                        blocked.addAll(ranges);
                        if (!ranges.isEmpty()) {
                            viewable++;
                        }
                    }
                }
            }
        }
        return viewable;
    }
}

So it looks very difficult but it's way easier than one might think. My first idea was to use some intersection algorithm to check whether a line from my position to the building can be made without any intersections. To do this I decided to use the Cohen-Sutherland algorithm and draw lines to all four corners of the building. This worked pretty well for the first tests, but the last one failed. I soon found out, that it's a case where you can't see the corners but a part of an edge. So I thought about some sort of ray casting like @Blue did it. I put that challenge away, as I didn't got some progress. Then I saw Blue's answer and the following simple idea came to my mind: Each building blocks some angle in which nothing else can be seen. I just need to keep track of what can be seen and what is already hidden by other buildings. That's it!
The algorithm works as follows: It determines the building with the smallest distance to the person. Then we imagine four lines drawn from the person to the corners of the building. Two of these have an extreme value: The minimum and maximum angle in which the building can be seen. We take them as a range and compare them with other buildings of which we know that they can be seen (none at the beginning). The ranges may overlap, include each other or don't touch at all. I compare the ranges and get some new ranges of the building which aren't hidden by the viewable buildings. If there is something remaining after comparing it with the buildings in-sight the building is also viewable. We add the remaining angle range to the list of ranges to compare to and start off with the next building with the next longer distance.
Sometimes the ranges may overlap in a way that I end up with a range of 0 degrees. These ranges will be filtered to don't mistakenly add a building that isn't even viewable.
I hope someone understood this explanation :)
I know this code isn't golfed very much, I'll do this asap.
That was a really challenging task. You thought you found a solution that works but instead you are far away still. I think this solution works pretty good. It isn't very fast but at least it works ;) Thanks for that puzzle!

Update
I found the time to golf the whole thing down into a single function, which thus can be turned into a lambda. All functions were only called once and thus can be put into one method. I switched from lists to sets as this saves some additional characters. The declarations have been put together. The comparisons have been put together and characters were replaced by there ascii value. The range comparing can be expressed as many ternaries. Some tricks here and there to prevent long expressions like Double.NEGATIVE_INFINITY got done. Where possible inline assigments are done. To save a bit more I switched from comparing the angles in degrees to comparing the radians. The whole change saved over 500 characters, I hope to get it all under 1000 though ;)
I removed the generics where possible and shortened the return comparison by creating an one element array and check it's value instead. I also replaced the Double.NEGATIVE_INFINITY with PI2 and -PI2 as these are the upper and lower bounds of the angles. Now it's finally under 1000 chars long!
I merged the loops for finding the persons location and the building iterator to save some characters. Unfortunately this requires us to move the return out of the loop and still use a break but this time without a label. I merged max and distanceSquared and min and newDistanceSquared as they aren't required at the same time. I changed Integer.MAX_VALUE to 2e31-1. Also I created a constant half = 0.5 which is used to calculate the corners of the building. This is shorter in the golfed version. Overall we saved another 30 characters!

Nice Golf! I took an easier route with all the built-in raycasting, but its nice to know I helped! (BTW I will probably change to sets as well)

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


text:
Electoral votes from state name
Given a the name of a state of the United States as a string (with case), return the number of votes the state has in the Electoral College. Write a full program or function, and take input and output through any default I/O method.
A list of all inputs and outputs (source):
[['Alabama', 9], ['Alaska', 3], ['Arizona', 11], ['Arkansas', 6], ['California', 55], ['Colorado', 9], ['Connecticut', 7], ['Delaware', 3], ['Florida', 29], ['Georgia', 16], ['Hawaii', 4], ['Idaho', 4], ['Illinois', 20], ['Indiana', 11], ['Iowa', 6], ['Kansas', 6], ['Kentucky', 8], ['Louisiana', 8], ['Maine', 4], ['Maryland', 10], ['Massachusetts', 11], ['Michigan', 16], ['Minnesota', 10], ['Mississippi', 6], ['Missouri', 10], ['Montana', 3], ['Nebraska', 5], ['Nevada', 6], ['New Hampshire', 4], ['New Jersey', 14], ['New Mexico', 5], ['New York', 29], ['North Carolina', 15], ['North Dakota', 3], ['Ohio', 18], ['Oklahoma', 7], ['Oregon', 7], ['Pennsylvania', 20], ['Rhode Island', 4], ['South Carolina', 9], ['South Dakota', 3], ['Tennessee', 11], ['Texas', 38], ['Utah', 6], ['Vermont', 3], ['Virginia', 13], ['Washington', 12], ['West Virginia', 5], ['Wisconsin', 10], ['Wyoming', 3]]

Any other input is undefined behavior. This is code-golf, so the shortest solution in bytes wins.
Hint: You probably shouldn't store all of the state names.
If you're solving this challenge with a builtin, please also write a solution without, for the sake of an interesting answer.

There's probably a builtin in Mathematica for this

If this goes on further we need a tag for the US presidential election ^^

Haha lol no, there probably isn't a builtin for something as crazy as that.

The inputs and outputs need to be provided in this question, so that old answers do not become invalid after the next census.

Just mentioning for anyone else tripped up by this that DC is not in the above list, so it doesn't sum to 538.

Python 3, 137 bytes
lambda s:b"2F$&#+*&4#(#'*&$++&''0+)-/ &)$# #(0*W% *&4)$= ,   %.# = %#$"[sum(b'!!E$/!5.!!!&#"!!1_&!!$#<!./'[ord(c)%32]-32for c in s)-4]-32

Although not required by the challenge, this accepts case-insensitive state names. I computed parts of this hash function with GPerf.

Python 2, 289 bytes
c="las,De,Mo,Da,Ve,Wy 3 Ha,Id,ai,Rh 4 eb,xi,st 5 ka,Io,Ka,pp,ev,U 6 ct,Ok,go 7 Ke,ui 8 Al,ad,Sou 9 ry,ta,ou,Wi 10 iz,nd,tt,ee 11 sh 12 Vi 13 Je 14 ro 15 Ge,ch 16 Oh 18 ll,yl 20 Fl,Yo 29 xa 38 if 55"
f=0
u=input()
for i in c.split():
 if f:print i;break
 f=any(j in u for j in i.split(','))

Example
$ python2 test.py
"Tennessee"
11

$ python2 test.py
"California"
55

$ python2 test.py
"Rhode Island"
4

JavaScript (Node.js),  147 145  127 bytes
s=>Buffer("@>~;;F~<~;~?~~^~UL~~C~~?~<<@~EBB~B?~>~~~~AD>~A~=;~>=>H~~~C>A~BG<H;C<CoUJ~~=;L")[parseInt(s[8]+0+s,35)%561%263%80]-56

Try it online!
How?
Transforming the input string
In this paragraph, we temporarily assume that we're going to convert some transformation of the input string from base 36 to decimal.
We can't just pass the state name to parseInt() to turn it into a unique numeric identifier because some state names include a space that would cause the parsing to stop, whatever base is used. For instance, "North Carolina" and "North Dakota" would be both parsed as "north".
Possible solutions:

We could remove the space or replace it with another character. But this is a lengthy operation.

We could pick 3 arbitrary letters. Any permutation of either (s[2],s[4],s[6]) or (s[0],s[4],s[8]) would work. This is better but still a bit lengthy.

Another possible strategy is to prepend the 9th character to the full name. For instance, "North Carolina" is turned into "rNorth Carolina" and parsed as "rnorth", while "North Dakota" is parsed as "knorth".

The last strategy looks promising, but we have a problem with "Michigan" vs "Missouri". When the length of a state is less than 9, "undefined" is inserted instead, leading to a rather long string which is likely to cause a loss of precision. That's why "Michigan" and "Missouri" are both parsed as "undefinedmh000000", where mh000000 is the rounded value of mi.......
Fortunately, we can fix that by doing:
s[8] + 0 + s

This time, when the 9th character is missing, it is turned into undefined + 0 = NaN. So, "Michigan" is parsed as "nanmichiga8" and "Missouri" is parsed as "nanmissourk" (only the last 'digit' is rounded).
Choosing the base
With this transformation, we can use any base between 32 and 36. In base 32, the characters w, x, y and z cause the parsing to stop. But the states that contain these letters are still turned into unique values:
 State           | Turned into       | Parsed as
-----------------+-------------------+--------------
 "Arizona"       | "NaNArizona"      | "nanari"
 "Delaware"      | "NaNDelaware"     | "nandela"
 "Hawaii"        | "NaNHawaii"       | "nanha"
 "Iowa"          | "NaNIowa"         | "nanio"
 "Kentucky"      | "NaNKentucky"     | "nankentuck"
 "Maryland"      | "NaNMaryland"     | "nanmar"
 "New Hampshire" | "s0New Hampshire" | "s0ne"
 "New Jersey"    | "e0New Jersey"    | "e0ne"
 "New Mexico"    | "c0New Mexico"    | "c0ne"
 "New York"      | "NaNNew York"     | "nanne"
 "Pennsylvania"  | "a0Pennsylvania"  | "a0penns"
 "Texas"         | "NaNTexas"        | "nante"
 "Wyoming"       | "NaNWyoming"      | "nan"
 "West Virginia" | "g0West Virginia" | "g0"
 "Wisconsin"     | "n0Wisconsin"     | "n0"
 "Wyoming"       | "NaNWyoming"      | "nan"
 "Washington"    | "o0Washington"    | "o0"

See the full tables in base 32 to base 36
Choosing the hash function
We can now try to brute-force a hash function that leads to the shortest possible lookup table.
I've actually tried many different things, but the pattern that worked best was:
parseInt(s[8] + 0 + s, B) % M0 % M1 % M2

with 32 ≤ B ≤ 36, 50 ≤ M0 < 1000, 50 ≤ M1 < M0 and 50 ≤ M2 < M1.
This eventually led to:
parseInt(s[8] + 0 + s, 35) % 561 % 263 % 80

and a lookup string of 77 characters.

Great answer (and appropriate timing)!

@user Well, it's actually 6-month old and I forgot about it. Today, I looked for a challenge about the Electoral College, found this one ... and this answer of mine which I've just slightly improved.

Oh, I see, I thought you'd answered today instead of just edited it.

JavaScript (ES6) 333 331 329 223 characters
Many thanks to ETHproductions and Neil, 100+ characters thanks to both of you, and I haven't tried findIndex() yet :-)
s=>(d="0,;y\\>|Kb^6 |kn|xw|r?||8MD|hQ|EU|7|2||R|e||||F|||||||||G".split("|"),d[35]="",d[52]="3",d.map((a,j)=>{if(~a.indexOf(String.fromCharCode([...s].reduce((S,c)=>S*32+c.charCodeAt(),0)%153)))o=j}),o+3)

Expanded version
(With \0xx instead of characters)
s => (
    d = "0,;y\\>|Kb^6\t|kn\x1D|\x05\x7F\x84x\bw|r\x12?|\x07\x98|8MD|\x93h\x8E\x11Q|\x8FEU\x1B|7|2|\v|R|\x92e||\x19||\x04F|||||||||\x94G".split("|"),
    d[35] = "\x13",
    d[52] = "3",
    d.map(
        (a,j) => {
            if(~a.indexOf(
                String.fromCharCode([...s].reduce(
                    (S,c)=>S*32+c.charCodeAt(),0)%153)
                ))
                o = j
        }
    ),
    o+3
)

Approach:
Preprocessing:
Calculate an hash of each state name and store them in an array where one dimension is the number of votes the state has.
Processing:
Recalculate the hash and retrieve the information.
An hash of a state name is calculated with s.split('').reduce((S,c)=>S*32+c.charCodeAt(0),0)%153.
It transform "Iowa" in (32^3*'I' + 32^2*'o' + 32*'w' + 'a')%153 (with ascii value for characters).
Why 32 and 153? Because after a few empiric tests those values minimize hashes without collision between states that have different number of votes.
I don't believe that it will be hard to do something shorter with a better approach but since I spent a few time on it ;).

Nice! s.split('') can be changed to [...s]. You may also be able to save some bytes by formatting the list of lists as a string where each number is represented by its char code.

Drop the 0 from charCodeAt(). Also the a&& is unnecessary because map won't enumerate holes. You should also write your function as an expression to avoid the explicit return (use (,)s instead of {;}s).

findIndex might work out superior to map, especially if you can arrange to use its default value (i.e. drop the first element of the array and add an extra 1 at the end to compensate). I think I have it at 284 bytes.

Retina, 210 bytes
Wi|Min|Mar|ri$
10
G|J|Mas|^Vi|rth C|Oh|Wa|ch
1
Ari|In|Ten
11
F|Y|gt
2
lv|is$
20
las|D|Mo|T|(1)r|g$
$1 3
H|R|Ma|Id|rs
4
al|if|eb|(1)a|V|Mex
$1 5
Ar|gi?a|Io|Ka|pi|Nev|U
6
cu|O
7
[KLx]|io$
8
Al|do|id|rk| C
9
T`Ll

The last line has a trailing space. Output contains a trailing newline. If that's a problem, it'll be one more byte
Version for all states has m` in few places to make it work with multiple lines.
Try it online!
Try it online with all states!

Mathematica / Wolfram Language 235 bytes.
I use a built-in for state names.
f[x_] := Select[
   Transpose[{CountryData["UnitedStates",
       "AdministrativeDivisions"][[All, 2, 1]], {9, 3, 11, 6, 55, 9,
      7, 3, 0, 29, 16, 4, 4, 20, 11, 6, 6, 8, 8, 4, 10, 11, 16, 10, 6,
       10, 3, 5, 6, 4, 14, 5, 29, 15, 3, 18, 7, 7, 20, 4, 9, 3, 11,
      38, 6, 3, 13, 12, 5, 10, 3}}], #[[1]] == x &][[1, 2]]

This answer is valid now.

Ruby, 232 bytes
Uses an array of regular expressions that each represent one bit of the elector count.
r=[/[bzCDFYV]|om|e[tge]|Me|di|sk|Mo/,/[zkfDJOTU]..|o[nwtm].|[lai].s|[edy].a|rt/,/[fFHvJxYRUg]...|[hnIg]o|[srx].s|ct|M.i|r.*C/,/[zlLsYrtc]o.|se|ba|y$|ry|di|^Vir/,/[fFGYP]|Oh|ig|Il/,/xa|al/];h=->s{t=0;6.times{|i|s=~r[i]?t+=2**i :0};t}

C (gcc), 289 bytes
Truncates incoming string until it is found in lookup. Immediately preceding every partial state name is the number of electoral votes. Dual-word names are shortened to save some space on the pattern "Foo Bar" -> "FBar".
The average length of each entry is 2.3, and I had real trouble finding a good hash shorter than that.
Still, too many strX() calls lying around.
f(s){char*t=strdup(s),*p=strchr(t,32);for(p++&&memmove(t+1,p,strlen(p)+1);*t*!(p=strstr(")Alab#Alas+Ari&ArkWCa)Col'Con#D=F0G$H$Id4Il+In&Io&Ka(Ke(L$Mai*Mar+Mas0Mic*Min&Missi*Misso#Mo%Neb&Nev$NH.NJ%NM=NY/NC#ND2Oh'Ok'Or4P$R)SC#SD+TenFTex&U#Ve-Vi,Wa%WV*Wi#Wy",t));t[strlen(t)-1]=0);s=*--p-32;}

Try it online!

Suggest index(t,32);for(p++?bcopy(p,t+1,strlen(p)+1):0 instead of strchr(t,32);for(p++&&memmove(t+1,p,strlen(p)+1)

Ruby, 164 bytes
s=gets
g=9
41.times{|i|s[j=i/39,i/8+3].index('IndaMWictAbNekgKO
w ymuTxUSRPGLFvzfJYDHaip'[i,1+j])&&(g=":-1*1206))/5+,3,-8,+0).1L,/*:6.C,1]4C)**,"[i].ord-38)}
puts g

Try it online!
Explanation
I searched for a single character from the name to identify each state. This worked for about a third of the states, then I started truncating the names on the right hand side. This worked for all states except Maine (which is at the top of the list below and is identified by the string ai, along with Hawaii which has the same number of votes.) The program works in reverse, starting with the assumption that the state is Colorado, and revising to a different state each time a character is found. The state length is truncated to i/8+3 characters. A special consideration is given to Mississippi because its identifying character p is so far to the right that  it has to be checked at the end.
This is a full program, and input is expected to be newline terminated (as it would at the Ruby console.) This is important because the newline is used as the identifying character for Ohio (when this test is done the string is truncated to 5 characters, and Ohio is the only 4-letter state which does not have another test, so this identifies it.)
Data used to build the program
i=40 chars=8+1=9
ip['Mississippi', 6],
32..39=7
ai ['Maine', 4],  ['Hawaii', 4],
H['New Hampshire', 4],
D['North Dakota', 3], ['South Dakota', 3], ['Delaware', 3],
Y['New York', 29],
J['New Jersey', 14],
f['California', 55],
z['Arizona', 11],
v['Nevada', 6],
i=24..31 chars=6
F['Florida', 29],
L['Louisiana', 8],
G['Georgia', 16],
P['Pennsylvania', 20],
R['Rhode Island', 4],
S['South Carolina', 9],
U['Utah', 6],
x['Texas', 38]
i=16..23 chars=5
T['Tennessee', 11],
u['Kentucky', 8],
m ['Wyoming', 3]['Vermont', 3],
y['Maryland', 10],
SPACE['New Mexico', 5], ['West Virginia', 5],
w['Iowa', 6],
NEWLINE['Ohio', 18]
O['Oklahoma', 7], ['Oregon', 7],
i=8..15 chars=4
K['Kansas', 6],
g['Virginia', 13],
k['Arka', 6],
e['Nebr', 5],
N['Nort', 15],
b['Alab', 9],
A['Alas', 3],
t['Mont', 3],
i=0..7 chars=3
c['Mich', 16],
i['Minn', 10],  ['Miss', 10],  ['Wisc', 10],
W['Wash', 12],,
M['Mass', 11],
a['Idah', 4],
d['Indi', 11],
n['Conn', 7],
I['Illi', 20],
Initial guess
 ['Colo', 9],

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


text:
Calculate the volume of an object
You can determine the volume of objects based on a given set of dimensions:

The volume of a sphere can be determined using a single number, the radius (r)
The volume of a cylinder can be determined using two numbers, the radius (r) and the height (h)
The volume of a box can be determined using three numbers, the length (l), width (w) and the height (h)
The volume of an irregular triangular pyramid can be determined using four numbers, the side lengths (a, b, c)  and the height (h).

The challenge is to determine the volume of an object given one of the following inputs:

A single number (r) or (r, 0, 0, 0) => V = 4/3*pi*r^3
Two numbers (r, h) or (r, h, 0, 0) => V = pi*r^2*h
Three numbers (l, w, h) or (l, w, h, 0) => V = l*w*h
Four numbers (a, b, c, h) => V = (1/3)*A*h, where A is given by Heron's formula: A = 1/4*sqrt((a+b+c)*(-a+b+c)*(a-b+c)*(a+b-c))

Rules and clarifications:

The input can be both integers and/or decimals
You can assume all input dimensions will be positive
If Pi is hard coded it must be accurate up to: 3.14159.
The output must have at least 6 significant digits, except for numbers that can be accurately represented with fewer digits. You can output 3/4 as 0.75, but 4/3 must be 1.33333 (more digits are OK)

How to round inaccurate values is optional

Behaviour for invalid input is undefined
Standard rules for I/O. The input can be list or separate arguments

This is code golf, so the shortest solution in bytes win.
Test cases:
calc_vol(4)
ans =  268.082573106329

calc_vol(5.5, 2.23)
ans =  211.923986429533

calc_vol(3.5, 4, 5)
ans =  70

calc_vol(4, 13, 15, 3)
ans =  24

Related, but different.

Is the order of the dimensions required to be the order stated in the question?

Related

@Mego, you may choose...

@StewieGriffin Varargs and getting at dynamically sized arrays is a pain in my language (at least for me, a beginner at it). Can I provide four functions to handle each arg count?

You can have a fixed sized array with the last elements set to zero if need be. That should cover it I think? Or you can overload functions as in the Haskell answer. You can't have different functions with different names.

MATL, 57 53 51 44 bytes
3^4*3/YP*GpG1)*YP*GpG0H#)ts2/tb-p*X^3/*XhGn)

Input is an array with 1, 2, 3 or 4 numbers.
Try it online!
Explanation
Instead of using nested if loops, which is expensive in terms of bytes, this computes four possible results for any input, and then picks the appropriate result depending on input length.
When computing the results, even though only one of them needs to be valid, the others cannot give errors. This means for example that indexing the fourth element of the input is not allowed, because the input may have less than four elements.
                    % take input implicitly
3^4*3/YP*           % compute a result which is valid for length-1 input:
                    % each entry is raised to 3 and multiplied by 4/3*pi
G                   % push input
pG1)*YP*            % compute a result which is valid for length-2 input:
                    % product of all entries, times first entry, times pi
G                   % push input
p                   % compute a result which is valid for length-3 input:
                    % product of all entries
G                   % push input
0H#)ts2/tb-p*X^3/*  % compute a result which is valid for length-4 input:
                    % shorter version of Heron's formula applied on all
                    % entries except the last, times last entry, divided by 3
Xh                  % collect all results in a cell array
G                   % push input
n)                  % pick appropriate result depending on input length
                    % display implicitly

What rendition of Heron's formula are you using?

@CoolestVeto The one with the semiperimeter. First formula from here

Well done @DonMuesli. I managed it using "only" 34 bytes more in MATLAB =)

Vitsy, 49 bytes
I thought you handed this one to me on a plate, but I found an unresolved bug to work around. Didn't hurt me, though.
lmN
3^43/*P*
2^*P*
**
v:++2/uV3\[V}-]V3\*12/^v*3/

Basically, with the input being a certain length for different functions, you spoon feed me my method syntax for doing this stuff. So, yay, success!
Explanation, one line at a time:
lmN
l   Get the length of the stack.
 m  Go to the line index specified by the top item of the stack (the length).
  N Output as a number.

3^43/*P*
3^
          Put to the power of 3.
  43/*    Multiply by 4/3.
      P*  Multiply by π

2^*P*
2^     Put to the second power.
  *    Multiply the top two items.
   P*  Multiply by π

**
**     Multiply the top three items of the stack.

v:++2/uV3\[V}-]V3\*12/^v*3/
v                            Save the top item as a temp variable.
 :                           Duplicate the stack.
  ++                         Sum the top three values.
    2/                       Divide by two.
      u                      Flatten the top stack to the second to top.
       V                     Capture the top item of the stack (semiperimeter)
                             as a permanent variable.
        3\[   ]              Do the stuff in the brackets 3 times.
           V}-               Subtract the semiperimeter by each item.
               V             Push the global var again.
                3\*          Multiply the top 4 items.
                   12/^      Square root.
                       v*    Multiply by the temp var (the depth)
                         3/  Divide by three.

Input is accepted as command line arguments in the exact reverse as they appear in the question, with no trailing zeroes.
Try it online!
As an aside, here's something that's currently in development.
Java w/ Vitsy Package
Note that this package is work in progress; this is just to show how this will work in the future (documentation for this is not yet uploaded) and it is not golfed, and is a literal translation:
import com.VTC.vitsy;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;

public class Volume {
    public static void main(String[] args) {
        Vitsy vitsyObj = new Vitsy(false, true);
        vitsyObj.addMethod(new Vitsy.Method() {
            public void execute() {
                vitsyObj.pushStackLength();
                vitsyObj.callMethod();
                vitsyObj.outputTopAsNum();
            }
        });
        vitsyObj.addMethod(new Vitsy.Method() {
            public void execute() {
                vitsyObj.push(new BigDecimal(3));
                vitsyObj.powerTopTwo();
                vitsyObj.push(new BigDecimal(4));
                vitsyObj.push(new BigDecimal(3));
                vitsyObj.divideTopTwo();
                vitsyObj.multiplyTopTwo();
                vitsyObj.pushpi();
                vitsyObj.multiplyTopTwo();
            }
        });
        vitsyObj.addMethod(new Vitsy.Method() {
            public void execute() {
                vitsyObj.push(new BigDecimal(2));
                vitsyObj.powerTopTwo();
                vitsyObj.multiplyTopTwo();
                vitsyObj.pushpi();
                vitsyObj.multiplyTopTwo();
            }
        });
        vitsyObj.addMethod(new Vitsy.Method() {
            public void execute() {
                vitsyObj.multiplyTopTwo();
                vitsyObj.multiplyTopTwo();
            }
        });
        vitsyObj.addMethod(new Vitsy.Method() {
            public void execute() {
                vitsyObj.tempVar();
                vitsyObj.cloneStack();
                vitsyObj.addTopTwo();
                vitsyObj.addTopTwo();
                vitsyObj.push(new BigDecimal(2));
                vitsyObj.divideTopTwo();
                vitsyObj.flatten();
                vitsyObj.globalVar();
                vitsyObj.push(new BigDecimal(3));
                vitsyObj.repeat(new Vitsy.Block() {
                    public void execute() {
                        vitsyObj.globalVar();
                        vitsyObj.rotateRight();
                        vitsyObj.subtract();
                    }
                });
                vitsyObj.globalVar();
                vitsyObj.push(new BigDecimal(3));
                vitsyObj.repeat(new Vitsy.Block() {
                    public void execute() {
                        vitsyObj.multiplyTopTwo();
                    }
                });
                vitsyObj.push(new BigDecimal(1));
                vitsyObj.push(new BigDecimal(2));
                vitsyObj.divideTopTwo();
                vitsyObj.powerTopTwo();
                vitsyObj.tempVar();
                vitsyObj.multiplyTopTwo();
                vitsyObj.push(new BigDecimal(3));
                vitsyObj.divideTopTwo();
            }
        });
        vitsyObj.run(new ArrayList(Arrays.asList(args)));
    }
}

Definitely the right tool for the job

C, 100 97 bytes
#define z(a,b,c,d) d?d*sqrt(4*a*a*b*b-pow(a*a+b*b-c*c,2))/12:c?a*b*c:3.14159*(b?a*a*b:4/3.*a*a*a)

edit 1: remove unnecessary decimal ., thanks Immibis!

Can't 4./3. just be 4/3.? And can 2. and 12. just be 2 and 12?

You are absolutely correct.  Thanks!

JavaScript ES6, 129 126 125 116 114 90 bytes
Saved lots of bytes (9) with a wonderful formula, thanks to Stewie Griffin! Since input must be nonzero, variable? will suffice for a defining-check.
with(Math){(a,b,c,h,Z=a*a)=>h?sqrt(4*Z*b*b-(D=Z+b*b-c*c)*D)/4:c?a*b*c:b?PI*Z*b:4/3*PI*Z*a}

Test it out!

with(Math){Q = (a,b,c,h,Z=a*a)=>h?sqrt(4*Z*b*b-(D=Z+b*b-c*c)*D)/4:c?a*b*c:b?PI*Z*b:4/3*PI*Z*a}
console.log = x => o.innerHTML += x + "
";

testCases = [[4], [5.5, 2.23], [3.5, 4, 5], [4, 13, 15, 3]];
redo = _ => (o.innerHTML = "", testCases.forEach(A => console.log(`<tr><td>[${A.join(", ")}]` + "	 => 	" + Q.apply(window, A) + "
")));
redo();
b.onclick = _ => {testCases.push(i.value.split(",").map(Number)); redo();}
*{font-family:Consolas,monospace;}td{padding:0 10px;}
<input id=i><button id=b>Add testcase</button>

With math? Seems legit.

This errors on Chrome 48, Uncaught SyntaxError: Unexpected token = (referring to Z=a*a)

@PatrickRoberts Use Firefox. It allows for default parameters inside lambdas.

I can't seem to get the 4-arg version to work... and you never use the value of h, which seems a bit of an oversight.

@Neil Huh, true. I'll need to see that formula again, Stewie deleted his comment...

(Yeah, I hate it when people do that, especially after you've replied to it.) Maybe you can reverse engineer it from one of the other answers.

PowerShell, 165 161 bytes
param($a,$b,$c,$h)((($h/12)*[math]::Sqrt(($a+$b+$c)*(-$a+$b+$c)*($a-$b+$c)*($a+$b-$c))),(($a*$b*$c),((($p=[math]::PI)*$b*$a*$a),($p*$a*$a*$a*4/3))[!$b])[!$c])[!$h]

So ... Many ... Dollars ... (31 of the 161 characters are $, for 19.25% of the code) ... but, saved 4 bytes thanks to Stewie Griffin!
We take in four inputs, and then progressively index into pseudo-ternary statements based on them in reverse order. E.g., the outside (..., ...)[!$h] tests whether the fourth input is present. If so, the !$h will equal 0 and the first half is executed (the volume of an irregular triagonal pyramid). Otherwise, !$h with $h = $null (as it's uninitialized) will equal 1, so it goes to the second half, which itself is a pseudo-ternary based on [!$c] and so on.
This is likely close to optimal, since the supposedly-shorter formula that (e.g.) Cᴏɴᴏʀ O'Bʀɪᴇɴ is using is actually 2 bytes longer in PowerShell thanks to the lack of a ^ operator ... The only real savings comes from (1/3)*(1/4)*A*$h golfing to A*$h/12, and setting $p later to save a couple bytes instead of the lengthy [math]::PI call.

Haskell, 114 109 107 101 99 bytes
v[r]=4/3*pi*r^3
v[r,h]=pi*r^2*h
v[x,y,z]=x*y*z
v[a,b,c,h]=h/12*sqrt(4*a^2*b^2-(a^2+b^2-c^2)^2)

Takes a list of numbers and returns a volume. Call it like
v[7]

for a sphere, etc. The function is polymorphic for any type that implements sqrt (so, basically Float or Double).
It's not going to win any contests for brevity. But note how readable it is. Even if you don't really know Haskell, you can tell what it does quite easily. Haskell's pattern matching syntax makes it really easy to define strange functions that do something totally different depending on the shape of the input.

(1/3)*(1/4)*h,,, why not h/12? Saves you a lot of bytes!

Also, the variant of Heron's eq that Conor uses seems to be a lot shorter.

@StewieGriffin Apparently yes. :-}

Haskell is only readable for infix math, which I don't find readable. Then you get into . and # and $ and it becomes Mathematica Soup.

CJam, 67 66 bytes
q~0-_,([{~3#4*P*3/}{~\_**P*}{:*}{)\a4*(a\[1W1]e!..*+::+:*mq*C/}]=~

I will work on shortening it soon. Try it online!
Explanation to come.

Seriously, 65 59 55 bytes
`kd@;Σ½╗"╜-"£Mπ╜*√*3@/``kπ``ª*╦*``3;(^/4*╦*`k,;lD(E@i(ƒ

Try it online!
Explanation
This one is a doozy. I'm going to break the explanation into multiple parts.
Main body:
`...``...``...``...`k,;lD(E@i(ƒ
`...``...``...``...`k            push 4 functions to a list
                     ,;lD        push input, len(input)-1
                         (E      get the function at index len(input)-1
                           @i(   flatten the input list
                              ƒ  execute the function

Function 0:
3;(^/4*╦*
3;(^       push 3, r^3
    /      divide (r^3/3)
     4*    multiply by 4 (4/3*r^3)
       ╦*  multiply by pi (4/3*pi*r^3)

Function 1:
ª*╦*
ª     r^2
 *    multiply by h (r^2*h)
  ╦*  multiply by pi (pi*r^2*h)

Function 2:
kπ  listify, product (l*w*h)

Function 3 (21 bytes; nearly half the program length!)
kd@;Σ½╗"╜-"£Mπ╜*√*3@/
kd@                    listify, dequeue h, bring [a,b,c] back on top
   ;Σ½                       dupe, sum, half (semiperimeter)
      ╗                push to register 0
       "╜-"£M          map: push s, subtract (s-x for x in (a,b,c))
             π         product
              ╜*√      multiply by s, sqrt (Heron's formula for area of the base)
                 *3@/  multiply by h, divide by 3 (1/3*A*h)

Matlab, 78 bytes
@(a,b,c,d)pi*a^2*(4/3*a*~b+b*~c)+a*b*c*~d+d/12*(4*a^2*b^2-(a^2+b^2-c^2)^2)^.5;

Quite sure it can't get any shorter than this. ~b, ~c and ~d, are 0 if each of the dimensions are non-zero. A formula with a zero dimension will just give zero. That way, each of the formulas can simply be summed. No if and else required.
Call it like this (or try it online here):
g=@(a,b,c,d)pi*a^2*(4/3*a*~b+b*~c)+a*b*c*~d+d/12*(4*a^2*b^2-(a^2+b^2-c^2)^2)^.5;

g(4,0,0,0)
ans =  268.082573106329

g(5.5,2.23,0,0)
ans =  211.923986429533

g(3.5,4,5,0)
ans =  70

g(4,13,15,3)
ans =  24

What a madness of variables :-) Yes, this seems hard to shorten any further

Maybe add a link to try it online? http://ideone.com/6VZF9z

Python 3 2, 127 119 116 bytes
Credit to somebody and Mego for all their help with golfing. Credit also to Cᴏɴᴏʀ O'Bʀɪᴇɴ and Josh as I borrowed parts of their answers for this one.
def v(a,b,c,d):z=a*a;P=3.14159;print filter(int,[max(0,(4*z*b*b-(z+b*b-c*c)**2))**.5*d/12,a*b*c,P*z*b,P*z*a*4/3])[0]

Ungolfed:
def v(a, b, c, d):
    z = a*a
    p = 3.14159
    s = filter(int,[max(0,(4*z*b*b-(z+b*b-c*c)**2))**.5*d/12,a*b*c,P*z*b,P*z*a*4/3])
    print s[0]

Golfed more: def v(a,b,c,d):z=a*a;p=355/113;return[x for x in[(4*z*b*b-(z+b*b-c*c)**2)**.5*d/12,a*b*c,p*z*b,p*z*a*4/3]if x][0], assuming input is padded with 0s.

Also, if you use Python 2 instead, you can do def v(a,b,c,d):z=a*a;P=3.14159;return filter(int,[(4*z*b*b-(z+b*b-c*c)**2)**.5*d/12,a*b*c,P*z*b,P*z*a*4/3])[0]

Mathematica, 114 (103)
Pure function: 114
Which[(l=Length@{##})<2,4.Pi/3#1^3,l<3,#1^2.Pi#2,l<4,#1#2#3,l<5,(4#1^2#2^2-(#1^2+#2^2-#3^2)^2)^.5#4/12]~Quiet~All&

Ungolfed:
fun = Which[
  (l = Length@{##}) < 2,
    4. Pi/3 #1^3,
  l < 3,
    #1^2 Pi #2,
  l < 4,
    #1 #2 #3,
  l < 5,
    (4 #1^2 #2^2 - (#1^2 + #2^2 - #3^2)^2)^.5 #4/12
]~Quiet~All &

Usage:
fun[4]
268.083
fun[5.5, 2.23]
211.924
fun[3.5, 4, 5]
70.
fun[4, 13, 15, 3]
24.

If named functions are allowed: 103
f[r_]:=4.Pi/3r^3
f[r_,h_]:=r^2.Pi h
f[l_,w_,h_]:=l w h
f[a_,b_,c_,h_]:=(4a^2b^2-(a^2+b^2-c^2)^2)^.5h/12

Usage:
f[4]
268.083
f[5.5, 2.23]
211.924
f[3.5, 4, 5]
70.
f[4, 13, 15, 3]
24.

#1==#, I think Quiet[x_]:=Quiet[x,All] and π (Alt-P on a Mac) fits in extended ASCII.

Can't you replace #1 #2 #3 with 1##? Don't forget #==#1

Factor, 783 bytes
Well, this took forever.
USING: arrays combinators io kernel locals math math.constants math.functions quotations.private sequences sequences.generalizations prettyprint ;
: 1explode ( a -- x y ) dup first swap 1 tail ;
: 3explode ( a -- b c d ) 1explode 1explode 1explode drop ;
: spr ( r -- i ) first 3 ^ 4 3 / pi * swap * ;
: cyl ( r -- i ) 1explode 1explode drop 2 ^ pi swap * * ; : cub ( v -- i ) 1 [ * ] reduce ;
: A ( x a -- b d ) reverse dup dup dup 0 [ + ] reduce -rot 3explode neg + + -rot 3explode - + 3array swap 3explode + - 1array append 1 [ * ] reduce sqrt .25 swap * ;
: ilt ( a -- b c  ) V{ } clone-like dup pop swap A 1 3 / swap pick * * ;
: volume ( v -- e ) dup length { { [ 1 = ] [ spr ] } { [ 2 = ] [ cyl ] } { [ 3 = ] [ cub ] } { [ 4 = ] [ ilt ] } [ "bad length" throw ] } cond print ;

Call { array of numbers } volume .

@StewieGriffin :P I totally forgot to shorten the names of the functions. Won't help much, though.


text:
Rotate every 2x2 block in a matrix
The Challenge
Given a n x m matrix with n > 1 and m > 1  filled with integers

1 2 3
4 5 6

and a list of integers with exactly as many values as 2x2 blocks in the matrix ((n-1)*(m-1) if you need the exact number)

[1, 2]

Output the matrix with every 2x2 block rotated by the current value in the list in the given order. The example above would yield

4 6 2
5 3 1

The first block gets rotated one time to the right and the second block gets rotated two to the right.
Notes

A positive integer means you rotate right by that many steps.
A negative integer means you rotate left by that many steps.
A zero means that you don't rotate.
You rotate the blocks row-wise. That means that you start in the first row and go to the right. Once you rotated every block in that row you go to the next one. At the end every block was rotated exactly once.
Keep in mind that the blocks overlap each other. The first matrix above has the blocks [[1,2],[4,5]] and [[2,3],[5,6]] for example.
Each rotation of a block affects the rotation on the adjacent blocks. This is why you have to do the rotations in the pattern described above.

Rules

You may take the input in the most convenient format. Please specify in your answer which one you use. This does not allow you to read the matrix block-wise though.
Function or full program allowed.
Default rules for input/output.
Standard loopholes apply.
This is code-golf, so lowest byte-count wins. Tiebreaker is earlier submission.

Test cases
Input format here is a list of lists for the matrix and a normal list for the values.

[[1,2],[3,4]], [-3] -> [[4,1],[3,2]]
[[1,1,1],[1,1,1]], [-333, 666] -> [[1,1,1],[1,1,1]]
[[1,2,3],[4,5,6]], [1,2] -> [[4,6,2],[5,3,1]]
[[1,2,3],[4,5,6],[7,8,9]], [4,0,12,-20] -> [[1,2,3],[4,5,6],[7,8,9]]
[[1,2,3,4,5],[5,4,3,2,1],[1,2,3,4,5]], [2,-3,4,1,6,24,21,-5] -> [[4,1,5,2,4],[2,1,3,5,5],[3,2,4,3,1]]

Happy Coding!

first test wrong?

CJam (42 40 bytes)
{(\@2$,(/.{@a@a+z(\@.{4,={+2/zW%~}*}z~}}

Online demo
Basically this applies the same technique twice in order to fold the block
{4,={+2/zW%~}*}

which operates on a 2x2 matrix and a number of times to rotate.
[first row] [[second row] [third row] ... [last row]] [value_0 value_1 ... value_n]

can be processed with
.{block}

and has the effect of
[first row]
[second row] value_0 {block}~
[third row] value_1 {block}~
...

because . (like % in CJam) doesn't gather the results into an array until it's finished.

You can save a byte by using 4,= for correct modulo (unless your block needs to run at least once?).

Also what about zW% for the rotation?

@MartinBüttner, I thought the rotation seemed too long, but I couldn't remember the shorter one. Nice trick on the modulo.

APL (Dyalog Unicode), 37 35 bytes
{⌽∘⍉@⍺⊢⍵}/⌽(⊂,{(4|⎕)/,⊢∘⊂⌺2 2⍳⍴⍵})⎕

Try it online!
Switched to a more straightforward method after I realized @ also accepts a matrix of coordinates. Then we don't need to fiddle with the coordinate order; we extract the submatrix coordinates with ⊢∘⊂⌺2 2, and just rotate them directly using ⌽∘⍉.

APL (Dyalog Unicode), 37 bytes
{1⌽@⍺⊢⍵}/⌽(⊂,{(4|⎕)/,2,∘⌽/2,⌿⊂¨⍳⍴⍵})⎕

Try it online!
A full program that takes the matrix, then the vector of rotation amounts. Prints the resulting matrix with a leading space.
@ can extract the elements at certain positions, manipulate them, and place them back into the original matrix, which is great for 2×2 rotation. In particular, 1⌽@(1 1)(2 1)(2 2)(1 2) extracts the top left submatrix [a b][c d] into a vector a c d b, rotates once to the left (1⌽) into c d b a, then puts the values back so that the submatrix becomes [c a][d b]. This achieves rotating the submatrix exactly once.
{1⌽@⍺⊢⍵}/⌽(⊂,{(4|⎕)/,2,∘⌽/2,⌿⊂¨⍳⍴⍵})⎕

⍝ Read from right:
     ⎕  ⍝ Take the matrix from stdin
{...}   ⍝ Pass to the dfn as ⍵
          ⍳⍴⍵  ⍝ Matrix of 2D coordinates of ⍵
     2,⌿⊂¨     ⍝ Pair vertically adjacent coordinates
2,∘⌽/          ⍝ Catenate horizontally adjacent coordinate pairs,
               ⍝ flipping the right one so that it looks like (1 1)(2 1)(2 2)(1 2)
      ,  ⍝ Flatten the matrix of lists of coordinates
(4|⎕)/   ⍝ Copy each (Rotations modulo 4) times
⌽(⊂,...)  ⍝ Prepend the original matrix enclosed and reverse the entire array,
          ⍝ so that it is suitable for RTL reduce
{      }/  ⍝ RTL reduce by...
 1⌽@⍺⊢⍵    ⍝ Take the matrix ⍵ and rotate once at coordinates ⍺

a⊣⎕{a⊢←⌽∘⍉⍣⍺@⍵⊢a}¨,⊢∘⊂⌺2 2⍳⍴a←⎕

CJam, 65 63 60 55 bytes
There must be a better way to do this...
{_e_\z,:N(@/Ta*ee{~4,=,f{;1$,,\[XTN_)]f+_(+er\f=}~}/N/}

This is an unnamed function that expects the instructions and the matrix (in that order) on the stack and leaves the resulting matrix in their place.
Test it here.
Explanation
I don't feel like writing the full breakdown for the code right now, so here is a rough overview:

2D array manipulation is a pain in CJam, so I'm instead unrolling the matrix, compute each rotation as a permutation of the elements at specific positions and then split the array into rows again at the end. The width of the matrix is stored in N.
A rotation at position k in the unrolled array changes four indices: k <- k+1, k+1 <- k+1+N, k+N <- k, k+1+N <- k+1. For each index k along the instruction list, I compute a permutation corresponding to this, and apply it to the unrolled input array.
This leaves the problem, that in the linear array some rotations will be positioned with its top left corner in the last column of the input. To skip these, I riffle zeroes into the instruction list, such that these invalid 2x2 sub-blocks are technically processed, but with a no-op.

Python 2, 166 159 bytes
A,R=input();m=~-len(A[0])
for j,r in enumerate(R):exec r%4*"a,b,c,d=A[j/m][j%m:][:2]+A[j/m+1][j%m:][:2];A[j/m][j%m:j%m+2]=c,a;A[j/m+1][j%m:j%m+2]=b,d;"
print A

Try it online!

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


text:
How many steps did I walk?
A simple pedometer can be modeled by a pendulum with two switches on opposite sides—one at x=0 and one at x=l. When the pendulum contacts the far switch, the ambulator can be assumed to have taken half a step. When it contacts the near switch, the step is completed.
Given a list of integers representing positions of the pendulum, determine the number of full steps recorded on the pedometer.
Input

An integer l>0, the length of the track.

A list of integers representing the positions of the pedometer's pendulum at each time.

Output
The number of full steps measured. A step is taken when the pendulum contacts the far switch (x>=l) and then the near switch (x<=0).
Test cases
8, [8, 3, 0, 1, 0, 2, 2, 9, 4, 7]
1

The pendulum immediately makes contact with the far switch at x=8 at t=0. Then it touches the near switch at t=2 and t=4, completing one step. After that, it touches the far switch again at x=9 at t=8, but it never touches the near switch again.
1, [1, 5, -1, -4, -1, 1, -2, 8, 0, -4]
3

15, [10, -7, -13, 19, 0, 22, 8, 9, -6, 21, -14, 12, -5, -12, 5, -3, 5, -15, 0, 2, 11, -11, 12, 5, 16, 14, 27, -5, 13, 0, -7, -2, 11, -8, 27, 15, -10, -10, 4, 21, 29, 21, 2, 5, -7, 15, -7, -14, 13, 27]
7

7, [5, 4, 0]
0

7, [5, 8, 6, 1, 2]
0

What about 7, [5, 4, 0]? Is that 0 or 1?  That is - do you assume that a swing is always "full-length"?  Or 7, [5, 8, 6, 1, 2]?  Is that 0 or 1?

@NotthatCharles Added.

I assume a step always is: contact at far end, then near end. That is: near end, then far end is not a full step. So input 8,  [0 8 0 8] should give 1, not 2. Am I correct?

@DonMuesli Yes.

CJam, 27 24 bytes
l~:Xfe<0fe>_[XT]:Y--Y/,(

Input format is the list of pendulum positions followed by l on a single line.
Test it here.
Explanation
l~     e# Read and evaluate input.
:X     e# Store track length in X.
fe<    e# Clamp each position to X from above.
0f>    e# Clamp each position to 0 from below.
_      e# Duplicate.
[XT]   e# Push the array [X 0].
:Y     e# Store it in Y.
-      e# Set subtraction from the clamped input list. This gives all the
       e# intermediate values.
-      e# Another set subtraction. Remove intermediate values from input list.
Y/     e# Split remaining list around occurrences of ...X 0...
,(     e# Count them and decrement. This is the number of times the pendulum
       e# moved from X to 0.

MATL, 22 bytes
>~2G0>~-XzY'nw1)0<-H/k

This uses current version (14.0.0) of the language/compiler.
Inputs are in the same order and format as in the challenge, separated by a newline.
Try it online!
Explanation
>~     % take the two inputs implicitly. Generate an array that contains true
       % where the second input (array of positions) is >= the first input (l)
2G     % push second input (positions) again
0      % push a 0
>~     % true where the second input (array of positions) is <= 0
-      % subtract: array of 1, -1 or 0
Xz     % discard the 0 values
Y'     % run-length encoding: push values and number of repetitions
n      % length of the latter array: number of half-steps, perhaps plus 1
w1)    % swap. Get first element
0<     % true if that element is -1. We need to discard one half-step then
-      % subtract
H/k    % divide by 2 and round down

Javascript ES6 57 bytes
(t,a)=>a.map(a=>a<t?a>0?'':0:1).join``.split`10`.length-1

Thanks @NotThatCharles for -4

Why not split on /10/?

@NotthatCharles I was so sure that didn't work, just tried it and it's great! - thanks

One Charles to another ;)

Perl, 28 bytes
Includes +1 for -p
Run with the input as one long line of space separated integers on STDIN, the first number is the length:
perl -p steps.pl <<< "8 8 3 0 1 0 2 2 9 4 7"

steps.pl:
s; ;$'>=$_..$'<1;eg;$_=y;E;

Uses the perl flip-flop operator and counts the number of times it returns to false

Pyth, 18 bytes
/.:@J,Q0m@S+Jd1E2J

Test suite
Explanation:
/.:@J,Q0m@S+Jd1E2J
                      Implicit: Q is the length of the track.
    J,Q0              Set J to [Q, 0]
        m      E      Map over the list
           +Jd        Add the current element to J
          S           Sort
         @    1       Take the middle element.
                      This is the current element,
                      clamped above by Q and below by 0.
   @J                 Filter for presence in J.
 .:             2     Form 2 element substrings
/                J    Count occurrences of J.

Ruby, 42
->i,a{r=!0
a.count{|v|r^r=v>=i||r&&v>0}/2}

r starts as false. We toggle r at each end of the track, and add it to our count.  Then, halve the count (rounding down) to get the number of steps.

Python 3, 82
Saved 2 bytes thanks to DSM.
Not super golfed yet.
def f(x,s):
 c=l=0
 for a in s:
  if a>=x:l=x
  elif a<1:c+=l==x;l*=l!=x
 return c

Test cases:
assert f(8, [8, 3, 0, 1, 0, 2, 2, 9, 4, 7]) == 1
assert f(1, [1, 5, -1, -4, -1, 1, -2, 8, 0, -4]) == 3
assert f(15, [10, -7, -13, 19, 0, 22, 8, 9, -6, 21, -14, 12, -5, -12, 5, -3, 5, -15, 0, 2, 11, -11, 12, 5, 16, 14, 27, -5, 13, 0, -7, -2, 11, -8, 27, 15, -10, -10, 4, 21, 29, 21, 2, 5, -7, 15, -7, -14, 13, 27]) == 7

Retina, 34
-1*

^(1*)((?>.*?\1.*? \D))*.*
$#2

Try it online! or try it with decimal input.
Takes input in unary, negative unary numbers are treated as -111... and zero is the empty string. Counts the number of times that the first number appears followed by a zero. Uses an atomic group to guarantee that the matches are minimal (sadly atomic groups are non-capturing so it has to be wrapped in another group...).

Clojure, 64 bytes
#(count(re-seq #"10"(apply str(for[i %2](condp > i 1 0 %""1)))))

Maps values less-than-or-equal of zero to 0, larger-than-or-equal of length to 1 and others to an empty string "". This is then concatenated to a string and occurrences of "10" are counted.

APL (Dyalog Unicode), 17 bytesSBCS
Also known as "how much can I abuse iota-underbar?"

≢∘∪0~⍨(⍸≤)⍸(⍸0≥⊢)

Try it online!


text:
Implode the Box
ASCII boxes look like this:
++    +---+    +------+    +---+    +---+
++    |   |    |      |    |   |    |   |
      |   |    |      |    |   |    |   |
+-+   |   |    |      |    |   |    |   |
+-+   |   |    |      |    |   |    +---+
      +---+    |      |    |   |
+--+           |      |    |   |    ++
|  |           |      |    |   |    ||
|  |           +------+    |   |    ||
+--+                       |   |    ||
                           +---+    ||
                                    ||
                  +-----+           ||
+------------+    |     |           ++
|            |    |     |
|            |    |     |
+------------+    +-----+

Here are some examples of the same ASCII boxes, imploded:
++    +- -+    +-    -+    +- -+    +- -+
++    | - |    | -  - |    | - |    | - |
       | |      | -- |      | |      | |
+-+    | |       |  |        "      | - |
+-+   | - |       ||        | |     +- -+
      +- -+      |  |      |   |
+--+            | -- |      | |     ++
|  |           | -  - |      "      ||
|  |           +-    -+     | |     ||
+--+                       | - |   |  |
                           +- -+   |  |
      --                            ||
     -  -         +-   -+           ||
+-  -    -  -+    | - - |           ++
| --      -- |     | = |
| --      -- |    | - - |
+-  -    -  -+    +-   -+
     -  -
      --

Here is a link to all of these test case boxes in an easier-to-copy format. The order is all inputs followed by all outputs in the same order.
Your goal is to take an ASCII box as input, and return the imploded box. The rules of implosion are:

"+" never changes; neither do "-" or "|" directly adjacent to "+"
Starting from the corners, the "-" and "|" move inward by one space more than the same character closer to the corner did. If a "-" and "|" would ever move to the same spot, neither moves.
If a "-" and "-" move to the same spot, put a "=" in that spot. If a "|" and "|" move to the same spot, put a " in that spot. These count as two of their respective characters in the same spot moving in opposite directions.
Two "-" or two "|" can move past each other, as seen in the bottom left example.
If the box is skinny enough, it will start expanding outwards in the same way, always moving away from the side it started out part of.
The result should be symmetric across the center line in both the x and y directions (ignoring newlines); this includes spaces, so the result may need to be padded with spaces to satisfy that.

Rule Details:

This is code-golf, so shortest program in bytes wins.
Standard loopholes apply.
You can assume each line ends in a newline character.
The only characters in the input string will be "+", "-", "|", " ", and "\n" (newline), and your output string should follow the same rules, with the addition of "=" and " as possible characters.
You may optionally have a single trailing newline at the end of the last line.
The smallest ASCII box you need to handle is the top-left example. Every ASCII box will have exactly 4 "+"s, exactly at its corners.
You will need to handle boxes of size m x n for any integers m,n such that 2<=m,n<256 (largest possible string size of 255*(255+1))
You can assume you will always get a single valid ASCII box as input.

I think you forgot to add " as possible character in the output on numeral 4 of the Rule Details. Edit: Can we assume the input has no empty lines?

That 1x6 example is funky, why does it implode outward? I think one of those || in that example need to be a " or something...

@carusocomputing same as bottom left example, the walls move through each other (so the box volume is negative) -- rules 4 and 5.

@Lyth shouldn't there still be a " though? I guess the " only appears on 3-wide or greater?

@carusocomputing Consider this: Where would the " go? On the left, or on the right side? It can't be both, but it can't be either because the result is symmetrical.

@HyperNeutrino no idea how I missed that... damn I'm dumb sometimes.

Python 2, 591 555 545 527 525 496 436 351 334 333 303 bytes
s=input()
w=len(s[0])
h=len(s)
V=max(0,w/2-h)
H=max(0,h/2-w)
p=[[' ']*w]*V
q=[' ']*H
s=[q+k+q for k in p+s+p]
d,c=' -=',' |"'
exec"c,d,V,H,w,h=d,c,H,V,h,w;s=map(list,zip(*s))[::-1]\nfor j in range(h-4):q=s[V+j+2];q[H]=c[q[H]==c[2]];r=H+min(j+1,h-4-j);q[r]=c[1+(q[r]>' ')]\n"*4
for x in s:print''.join(x)

Try it online!
EDIT: My old method first imploded the top and bottom, and then the left and right. Instead, we can implode the top, rotate 90 degrees, and do that 4 times. Also, I was using the user-friendly code, this one requires input be in the form [['+', '-', '-', '-', '-', '-', '+'], ['|', ' ', ' ', ' ', ' ', ' ', '|'], ['|', ' ', ' ', ' ', ' ', ' ', '|'], ['|', ' ', ' ', ' ', ' ', ' ', '|'], ['+', '-', '-', '-', '-', '-', '+']] which is ugly but shorter for the program :P (Thanks to Phoenix for catching that)
Credits to Leaky Nun for the header code in the TIO link used for converting human-readable input into computer-readable input.
-85 bytes thanks to Leaky Nun!
-17 bytes by switching from top-implosion to left-implosion which allows the entire row to be stored into a variable and modified. Thanks to Leaky Nun for the suggestion!
-1 byte by switching things around to remove a space.
-30 bytes thanks to Leaky Nun!

Assign s[0] and S[0] to variables to save a few bytes

@Ilikemydog Oh, right. Thanks!

You can replace p=s[0] and P=S[0] with p=z(s[0]) and P=z(S[0]), respectively, and then replace all occurrences of z(p) with p and all z(P) with P to save 18 bytes.

You can also replace (z(s)-1)/2-p with z(s)/2-.5-p and (p-1)/2-z(s) with p/2-.5-z(s) to save 2 more bytes.

@R.Kap Oh okay. Thanks for both suggestions!

@R.Kap Unfortunately, your second suggestion actually doesn't work because then X and Y become floats, which doesn't work. Thanks though!

388 bytes

384 bytes (I changed the print statement.)

375 bytes I changed the code for the padding.

357 bytes I removed the lambda m.

351 bytes by realizing that l(s[0])-H*2 is basically w (or h when it is rotated).

328 bytes

326 bytes

303 bytes by realizing that zip essentially makes a deep copy for 2D arrays, hence reducing the need for p to be a lambda.

C (clang), 693 bytes
New lines added for readability. The first two are required but the rest are not.
#define P B[i][l]
#define m malloc(8)
I(B,h,V,S,J,Z,i,j,l,n,H,W,c,C,a,z,_,L,G,u,N,M)char**B,**Z;char*L,*G,*u;{
V=strlen(B[0]);
S=J=0;
Z=m;
for(i=0,j=h-1;i<h/2+h%2;i++,j--){
for(l=0,n=V-1;l<V/2+V%2;l++,n--){
if(P!=43&&((B[i][l-1]!=43&&i<1)||(B[i-1][l]!=43&&l<1))){
H=P==45;
W=P=='|';
P=B[j][l]=B[i][n]=B[j][n]=32;
if(H){
c=(N=i+l-1)==(M=j-l+1)?61:45;
if(M<0)L=m,sprintf(L,"%*s",V,""),L[l]=L[n]=c,Z[J]=L,J++;
else B[N][l]=B[N][n]=B[M][l]=B[M][n]=c;
}
if(W){
c=(N=l+i-1)==(M=n-i+1)?34:'|';
if(M<0)G=m,sprintf(G,"|%*s%s%*s|",i-n-2,"",B[i],i-n-2,""),B[i]=B[j]=G,S++;
else B[i][N]=B[j][N]=B[i][M]=B[j][M]=c;
}
}
}
}
for(a=-J+1;a<=h+J;u=a<1?Z[-a]:a<=h?B[a-1]:Z[a-h-1],C=S+1-strlen(u)/2,printf("%*s%s\n",C>0?C:0,"",u),a++);
}

Thanks for the great challenge! It was quite tricky but I still had a lot of fun.
This takes the input as command-line arguments and outputs to STDOUT a multi-line string of the imploded box. As always, golfing tips are very much appreciated.
Try it online!

590 bytes


text:
Volts, Amps, Watts and Ohms: given two, calculate the other two
Ohm's law tells us that the current (I) in amps flowing through a resistance (R) in Ohms when a voltage (V) is applied across it is given as follows:
V = I / R

Similarly the power (P) in watts dissipated by that resistance is given by:
P = V * I

By rearrangement and substitution, formulae may be derived for calculating two of these quantities when any of the other two is given.  These formulae are summarised as follows (note this image uses E instead of V for volts):

Given an input of any two of these quantities in a string, output the other two.

Input numbers will be decimals in whatever format is appropriate for your language.  Precision should be to at least 3 decimal places.  (IEEE 754-2008 binary32 floats are sufficient.)
Each input number will be suffixed with a unit.  This will be one of V A W R for Voltage, Amperage, Power and Resistance (or the equivalent lowercase).  Additionally, you may use Ω instead of R.  The units will not have any decimal prefixes (Kilo-, milli-, etc).
The two input quantities will be given in any order in one string, separated by a single space.
Input quantities will always be real numbers greater than 0.
Output will be in the same format as input.
Equation-solving builtins are disallowed.

Example Inputs
1W 1A
12V 120R
10A 10V
8R 1800W
230V 13A
1.1W 2.333V

Corresponding Outputs
1V 1R
0.1A 1.2W
1R 100W
120V 15A
2990W 17.692R
0.471A 4.948R

It should be noted that solutions to this challenge will effectively be self-inverses.  In other words if you apply a solution to input A B and get output C D, then apply a solution to input C D, then the output should be A B again, though possibly out of order and perturbed due to FP rounding.  So test inputs and outputs may be used interchangeably.

Can we output all 4 values?

@CatsAreFluffy No - input and output will always both be exactly 2 values.

This may actually be the most immediately descriptive title I've ever seen for a challenge.

@AlexA. yes, I was trying to think up something catchy and exciting - electrifying, if you will.  But I came up short - Captain Obvious won the day

Ruby 171 bytes
Input as function argument. Output to stdout with trailing space (can be revised if necessary.)
->s{a,b,c,d=s.split.map{|z|[z[-1],z.to_f]}.sort.flatten
%w{EA9.EAAVAA.WVA GS;.A?#WWV.RRR}.map{|w|m=w[n=(a+c+?!).sum%10].ord;print (b**(m%9-4)*d**(m/9-5))**0.5,w[n+7],' '}}

Explanation
All formulas can be expressed in the form b**x*d**y where b & d are the two input values and x & y are powers. For golfing reasons the expression (b**x*d**y)**0.5 was finally preferred as it means x and y become integers in the range -4 to 4.
The following table shows the required expressions (inputs are assumed sorted alphabetically) and the encoded values for the powers. Where x and y are the doubled powers, they are encoded as (x+4)+(y+4)*9+9 or equivalently (x+4)+(y+5)*9. This puts all encodings in the printable ASCII range. Power operators are omitted from the formulas for brevity.
n is a kind of checksum made from the input unit symbols; it can take the values 0,1,2,4,5,6 (3 is not used.)
n     formula 1 formula 2      formula 1                formula 2
value                      powers x+4 y+4 encoding   powers x+4 y+4 encoding

0      A*R=V    A2*R=W       1 1    6 6   69 E        2 1     8 6   71 G
1    R-1*V=A  R-1*V2=W      -1 1    2 6   65 A       -1 2     2 8   83 S
2 R-.5*W.5=A R.5*W.5=V     -.5 .5   3 5   57 9       .5 .5    5 5   59 ;
3          .         .                       .                         .
4      A*V=W   A-1*V=R       1 1    6 6   69 E       -1 1     2 6   65 A
5    A-1*W=V   A-2*W=R      -1 1    2 6   65 A       -2 1     0 6   63 ?
6    V-1*W=A  V2*W-1=R      -1 1    2 6   65 A        2 -1    8 2   35 #

Ungolfed in test program
f=->s{
  a,b,c,d=s.split.map{|z|[z[-1],z.to_f]}.        #split the input into an array [[symbol1,value1],[symbol2,value2]]
  sort.flatten                                   #sort alphabetically by symbol and flatten to assign the 4 objects to different variables
  n=(a+c+?!).sum%10                              #sum the ascii codes of the symbols (plus that of ! for good value distribution) and take mod 10. gives a number 0..6 (3 is not used)
  %w{EA9.EAAVAA.WVA GS;.A?#WWV.RRR}.             #for each of the outputs, there is a 14 character string. 1st 7 characters encode powers, 2nd 7 characters are output symbol
  map{|w|                                        #iterate through the 2 outputs
    m=w[n].ord                                   #select one character according to value of n and convert to a number encoding the powers to raise the two inputs to
    print (b**(m%9-4)*d**(m/9-5))**0.5,w[n+7],' '#decode the powers, evaluate the expression and output, append the unit symbol and a space
  }
}

f["6W 3A"]
puts
f["12V 120R"]
puts
f["10A 10V"]
puts
f["8R 1800W"]
puts
f["6W 2V"]
puts
f["2A 3R"]
puts

Output
2.0V 0.6666666666666666R
0.1A 1.2W
100.0W 1.0R
15.0A 120.0V
3.0A 0.6666666666666666R
6.0V 12.0W

Python 3, 193 187 190 bytes
import re
exec(re.sub('(.+?) (.)',r'\2=\1;',input()))
for s,r in zip('AVRW'*3,'V/R (W*R)**.5 V/A V*V/R W/V W/A V*V/W R*A*A (W/R)**.5 A*R W/A**2 V*A'.split()):
 try:print(eval(r),s)
 except:0

Try it online
Converts the input of the form <value> <unit> <value> <unit> into assignment statements. Then, use eval on every formula, with the try/except ignoring the errors from the ones for which the variables haven't been assigned.
Edit (190): Idk how the bug stayed in the program for 3 years, but I fixed the program giving some wrong answers. It was previously doing sqrt before dividing. The TIO program now runs all test cases at once.

Python 3, 329 347 343 339 326 305 267 251 249 245 237 bytes
This is pretty bloated. There is definitely still a lot of golfing to do.
Edit: Temporarily fixed the output. For some reason, return' '.join(str(eval(z[m][i]))+t[i]for i in range(2)) refuses to work properly.
Edit: Dropped eval.
This function now borrows parts of Level River St's answer. I changed the ops dictionary, first into a dictionary of modified exponents exponent*2+4 for b**((p-4)/2) * d**((q-4)/2), so that each p and q would be a one digit number. For example, b*d == b**1*d**1 == b**((6-4)/2)*d**((6-4)/2), and the result would be 66 in the dictionary.
Then, I turned the dictionary into a string z with those modified exponents and the units that are needed in a line and in a particular order. First, the ASCII value of each character in ARVW mod 10 is 5, 2, 6, 7. When any two of these values are added, they give a unique number mod 10. Thus, each two-character combination can be given a unique number with (ord(x[0]) + ord(y[10] + 3) % 10, giving AR: 0, AV: 4, AW: 5, RV: 1, RW: 2, VW: 6 (very similar to Lever River St's checksum). Arranging the modified exponents to be in this order, i.e. [AR] [RV] [RW] [blank] [AV] [AW] [VW], allows z to be accessed efficiently (in terms of bytes).
Edit: Golfed the list comprehension under return. Golfed the definition of m.
Code:
def e(s):x,y=sorted((i[-1],float(i[:-1]))for i in s.split());m=(ord(x[0])+ord(y[0])+3)%10*6;z="6686VW2628AW3555AV0000002666RW0626RV2682AR";return' '.join(str((x[1]**(int(z[m+i*2])-4)*y[1]**(int(z[m+i*2+1])-4))**.5)+z[m+i+4]for i in(0,1))

Ungolfed:
def electric(s):
    x, y = sorted((i[-1],float(i[:-1]))for i in s.split())
    m = (ord(x[0]) + ord(y[0]) + 3) % 10 * 6
    z = "6686VW2628AW3555AV0000002666RW0626RV2682AR"
    h = []
    for i in range(2):
         f = (x[1] ** (int(z[m*6+i*2])-4) * y[1] ** (int(z[m*6+i*2+1])-4)) ** 0.5
         h.append(str(f)+z[m*6+i+4])
    return ' '.join(h)