text:
Preparing a multiple choice test
Introduction
Note: this is not some kind of method to encourage cheating. As Cᴏɴᴏʀ O'Bʀɪᴇɴ already said, studying is the best solution for passing a test :3.
Consider the following answers to the multiple choice test:
ABCBCAAB

Here is a table which indicates whether the answers match:
    A B C B C A A B

A   1 0 0 0 0 1 1 0
B   0 1 0 1 0 0 0 1
C   0 0 1 0 1 0 0 0

This gives us the following numbers:
10000110, 01010001, 00101000

The challenge is to print these binary numbers. But it is important to see which letters are used in the multiple choice test. For example:
ABCDCDBCDABC

This highest letter is D, which is the 4th letter in the alphabet. Therefore, we need to output 4 different binary numbers. Namely:
100000000100, 010000100010, 001010010001, 000101001000

Note that you have to look at the highest letter. Consider the following example:
AACCACAC

Although the B is not used, we need to output the binary result for B. That means, the answer would be:
11001010, 00000000, 00110101

Task
Given the answers to a multiple choice test, output the binary numbers. You may assume that the input will be non-empty and only containing the letters [A-Z]
. Instead of ones and zeroes, you may also use true and false.

Test cases:
Input: ABBBABABA
Output: 100010101, 011101010

Input: AAAAAAAAA
Output: 111111111

Input: AFGHEEHFD
Output: 100000000 000000000 000000000 000000001 000011000 010000010 001000000 000100100

Input: Z
Output: 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1

Input: ABCDCDBCDABC
Output: 100000000100, 010000100010, 001010010001, 000101001000

This is code-golf, so the submission with the least amount of bytes wins!

Can we use [a-z] instead?

@FryAmTheEggman Of course :)

Related

there are no rules for the output specified, is a 2D array of bools allowed?

that seems kinda unreasonable but works for me as well^^

Pyth, 12 bytes
mqLdzfsgRTzG

Outputs as a nested array of booleans.
                Implicit: z=input
m               Map lambda d:
 qLdz            map equal-to-d over z
     f           over all letters T in the
           G     lowercase alphabet for which
      s           At least one char in z
       gRTz       >= T.

Try it here.

Python 3, 71
Saved 22 bytes thanks to Ogaday.
Saved 3 bytes thanks to DSM.
Saved a bunch of bytes thanks to an array of bools being valid.
*k,=map(ord,input())
x=65
while x<=max(k):print([v==x for v in k]);x+=1

Takes uppercase command line input.

Use extended iterable unpacking: *k,=map(ord,input())

An array of bools is now also possible, if that helps.

PowerShell, 95 94 73 bytes
param([char[]]$a)0..(($a|sort)[-1]-65)|%{$d=$_;-join($a|%{+!($_-$d-65)})}

Takes input as an uppercase string, but immediately casts it [char[]]. We then loop from 0.. to the maximal value of $a taken alphabetically (hence the -65 to convert from ASCII). For example, with ADCEB, this can be thought of as looping from A to E.
Each iteration, we set a helper variable $d equal to the current alphabetical (not ASCII) value. We then loop through all of $a, each time putting either 0 or 1 on the pipeline, based on whether $_-$d-65 is truthy or falsey (i.e., whether we're in the right "slot"). This works because any non-zero value in PowerShell is truthy, meaning if our current letter $_ doesn't "equal" what slot we're in $d, then the ! of that is $false, or 0.
Each of those arrays of 0s and 1s is then -joined together and re-put on the pipeline. When the outer loop ends, we have an array of strings, which will print one string per line.
Examples
PS C:\Tools\Scripts\golfing> .\preparing-a-multiple-choice-test.ps1 ABCDEFGH
10000000
01000000
00100000
00010000
00001000
00000100
00000010
00000001

PS C:\Tools\Scripts\golfing> .\preparing-a-multiple-choice-test.ps1 AFGHEEHFD
100000000
000000000
000000000
000000001
000011000
010000010
001000000
000100100

Edit 1 -- saved a byte by using Boolean-not instead of -eq
Edit 2 -- saved another 21 bytes by eliminating the extra array $b

An array of bools is now also possible, if that helps.

LabVIEW, 30 22 20 LabVIEW Primitives
Goes through from a-z until the sum of all bools is equal to the input lenght. then Transforms the bools to numbers.
Now directly takes the max instead of checking the bool sum.
Since 2D bools are viable now im saving 2 Primitives by outputting the green wire in front of ?1:0 could redo it but im too lazy...

An array of bools is now also possible, if that helps.

Pyth, 20 19 17 15 14  bytes
VhxGeSzmq@GNdz

Explanation:
               - autoassign z = input()
V              - For N in range(V)
 hxGeSz
    eSz        - max(z)
  xG           - lowercase_alphabet.index(^)
 h             - +1
       mq@GNdz
       m     z - [V for d in z]
         @GN   - lowercase_alphabet[N]
        q   d  - is_equal(^, ^^)
               - print "".join(^)

Outputs a 2D array of bools
Try it here

Cjam, 25 bytes
l{'A-i}%_:e>),\f{f=", "}

Sigh,
Explanation
l{'A-i}%_:e>),\f{f=", "}
l                        e# get the input
 {'A-i}%                 e# get the normalized array
        _:e>             e# get the maximum value
            ),           e# create the array from 1..N
              \f{      } e# map over the created array
                 f=      e# 1 if match, 0 if not
                   ", "  e# add separator

Congrats on 1k rep BTW!

An array of bools is now also possible, if that helps.

Haskell, 46 34 bytes
g x=(<$>x).(==)<$>['A'..maximum x]

Usage example: g "ACDC"-> [[True,False,False,False],[False,False,False,False],[False,True,False,True],[False,False,True,False]].
How it works:
        <$>['A'..maximum x]   -- for every letter from A to the highest letter in x
<$>x                          -- loop over x and
      ==                      -- compare the letter with the current element in x
                              -- which results in a boolean

Octave, 19 bytes
@(s)s==[65:max(s)]'

Uses Octave's automatic broadcasting over the range A to the max element in the input to produce 2d boolean array of matching elements.
Example:
Key = ABCDCDBCDABC

ans =

   1   0   0   0   0   0   0   0   0   1   0   0
   0   1   0   0   0   0   1   0   0   0   1   0
   0   0   1   0   1   0   0   1   0   0   0   1
   0   0   0   1   0   1   0   0   1   0   0   0

Try it here on ideone.

ES6, 92 bytes
s=>[..."ABCDEFGHIJKLMNOPQRSTUVWXYZ"].map(c=>[...s].map(m=>m==c&&!!(l=n),n++),n=0).slice(0,l)

Returns an array of arrays of falses and trues. If you prefer an array of strings of zeros and ones, then for 97 bytes:
s=>[..."ABCDEFGHIJKLMNOPQRSTUVWXYZ"].map(c=>s.replace(/./g,m=>m==c?(l=n,1):0,n++),n=0).slice(0,l)

Lua, 208 189 Bytes
That was tricky in lua, as usual, we have to do everything from scratch, and it takes a lot of place !
This program takes a string as argument, and print out the result :).
Edit: @Adnan told me we're now allowed to return a matrix of booleans, so here's a new version! It is now a function that takes a string of capitalised character and return the matrix :).
function f(x)a={}b={}for i=1,#x do a[i]=x:sub(i,i)end table.sort(a)for i=1,a[#a]:byte()-64 do b[i]={}end x:gsub(".",function(c)for i=1,#b do z=b[i]z[#z+1]=i+64==c:byte()end end)return b end

Old 208 Byte version
This is the one that works with argument and print results.

a={}b={}x=arg[1]for i=1,#x do a[i]=x:sub(i,i)end table.sort(a)for i=1,a[#a]:byte()-64 do b[i]=""end x:gsub(".",function(c)for i=1,#b do b[i]=b[i]..(i+64==c:byte()and"1"or"0")end end)print(table.concat(b,","))

Ungolfed and explanations
function f(x)
a={}                   -- We need 2 arrays, and while b=a would have been shorter
b={}                   -- arrays in lua are passed by pointer, so it wouldn't have worked

for i=1,#x             -- iterate over the inpute to transform the string
do                     -- into an array
  a[i]=x:sub(i,i)      -- with each cells containing a characyer
end
table.sort(a)          -- sort the array/string

for i=1,               -- iterate n times were n is the place in the alphabet
       a[#a]:byte()-64 -- of the last element of the (sorted) array a
do
  b[i]={}              -- initialise cells in b up to n with empty arrays
end                    -- a cell's index is the position of a letter in the alphabet

x:gsub(".",function(c) -- for each character in the input
  for i=1,#b           -- iterate over each cells in b
  do
    z=b[i]             -- define z pointing on the array b[i]
    z[#z+1]=           -- insert into b[i] the result of the
       i+64==c:byte()  -- comparison of the current char, and the answer
  end
end)
return b
end

Trying to print an array in Lua would result in printing its address and concatenating bools is impossible. So here's a function that will help you if you want to test this submission
function f(x)a={}b={}for i=1,#x do a[i]=x:sub(i,i)end table.sort(a)for i=1,a[#a]:byte()-64 do b[i]={}end x:gsub(".",function(c)for i=1,#b do z=b[i]z[#z+1]=i+64==c:byte()end end)return b end

function printBooleanMatrix(m)
  s="{"
  for i=1,#m
  do
    s=s.."{"
    for j=1,#m[i]
    do
      s=s..(m[i][j]and"1"or"0")..(j==#m[i]and""or",")
    end
    s=s.."}"..(i==#m and""or",\n")
  end
  print(s.."}")
end

printBooleanMatrix(f("ABBCCDDC"))

An array of bools is now also possible, if that helps.

@Adnan well, it allows me to drop a lot of bytes. I'm writing a function to have a clear output for testing purpose, then post a revised version :)

Perl, 84 bytes
$\="\n";@i=split//,<>;pop@i;for$c('a'..(reverse sort@i)[0]){print map{/$c/?1:0}@i;}

Oh dear, I seem to have broken the highlighter.
Ungolfed version:
# output formatting
$\ = "\n";
# get input chars as array
@i = split //, <>;
# lose the newline
pop @i;
# iterate over characters up to the max
for $c ('a'..(reverse sort @i)[0]) {
    # print 1 for each match, 0 otherwise
    print map { /$c/ ? 1 : 0 } @i;
}

PHP, 106 92 90 87 bytes
Uses Windows-1252 encoding.
for($x=A;$x++<=max($z=str_split($argv[1]));print~Ó)for(;$c=$z[+$$x++];)echo+(++$c==$x);

Run like this (-d added for aesthetics only):
php -d error_reporting=30709 -r 'for($x=A;$x++<=max($z=str_split($argv[1]));print~Ó)for(;$c=$z[+$$x++];)echo+(++$c==$x); echo"\n";' ABCDDHFHUYFSJGK

Saved 14 bytes by nesting the loops the other way around
Saved 2 bytes by using variable variables to prevent $i=0
Saved a byte by inverting string and dropping string delimiters
Saved a byte by moving the echo (changed to a print to fit) inside the first for loop and dropping curly braces
Saved a byte by incrementing $x somewhere else, and incrementing $c to compensate

Ruby, 53 bytes
->s{(?A..s.chars.max).map{|c|s.gsub(/./){c==$&?1:0}}}

Attempt This Online!

Japt, 13 bytes
;m!aB
rÔò@®¥X

Try it
Input as an array of uppercase letters
;m!aB
;       # B = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
 m      # For each character:
  !a    #  Find its index in
    B   #  B
        # Store as U

rÔò@®¥X
rÔ      # Find the maximum value in U
  ò@    # For each value X in the range [0...maximum]:
    ®   #  For each value Z in U:
     ¥X #   True when Z == X

Alternate version in one line is 2 bytes longer, unless it can output with rows and columns transposed.
Taking input as a string in either case requires 1 additional byte (¬ before the m)

Vyxal r, 7 bytes
øA:Gɾv=

Try it Online! (test suite) Input and output as a list of characters of [A-Z] and list of booleans respectively.
øA:Gɾv= # whole program

øA      # convert each char to its alphabetical index (1-indexing)
  :     # duplicate
   G    #                                maximum
    ɾ   # convert into a range from 1 to         inclusive
     v= # for each num in the range, check if each converted chars == num
        #   (doubly vectorises)
        #   (the r flag swaps the arguments, giving the resulting command)
        # implicitly output

Factor, 52 bytes
[ 65 over supremum [a..b] swap [ = ] cartesian-map ]

C#, 68 bytes
c=>Enumerable.Range(65,c.Max()-64).Select(x=>c.Select(y=>x==y?1:0));

Run in C# Pad
This anonymous function takes a char[] as input and outputs an IEnumerable<IEnumerable<int>>, with only 0's and 1's.

k, 15 bytes
{x=/:65_!|/1+x}

Try it online!


text:
Illustrate football team formations on a pitch
Football is the sport where players kick the ball, not carry it. Some confused individuals might call this soccer.

A football team has one goalkeeper, and 10 players out on the pitch. There are many formations used in football, that dictates where each player should be (the player of course moves around, but it's the base position).
The most common formation is 4-4-2, which means that there are 4 defenders, 4 midfielders and two attackers. Other formations are ("defenders, midfielders, attackers" or "defenders, midfielders, midfielders, attackers"):

4-4-2
4-3-3
5-3-2
3-4-3
3-5-2
4-5-1
5-4-1
4-4-1-1
4-3-1-2
4-1-2-3
4-1-3-2
4-3-2-1
3-4-1-2
3-3-3-1

The challenge is to take two inputs, one for each of the two teams and output a overview of the players on the field.
In general: Most information about the layout of the ASCII-art can be found in the figures (a picture says more than 1000 words). Only the way to place the 10 players on the field is explained in detail:

The keeper and the penalty area takes up 3 rows of ASCII-characters

Layout and number of spaces can be found in the figure below

There is no empty row between the penalty area and the defenders
If there are 3 numbers in the formation (e.g. 4-4-2, 4-3-3 etc. Not 4-3-2-1):

There is no empty row between the defenders and the midfielders
There is one empty row between the midfielders and the attackers

If there are 4 numbers in the formation (e.g. 4-3-2-1, 3-3-3-1 etc. Not 4-4-2):

There is no empty row between the defender and the first row of midfielders
There is no empty row between the first row of midfielders and the second
There is no empty row between the second row of midfielders and the attackers

There is no empty rows between the attackers and the center line
The team on the upper half are marked as x, and the team on the second half are marked as o.
Each row of players shall be distributed on the pitch as shown in the figures below. The number of spaces can be seen in the figure.

The following figure does not represent a valid formation, but is used to illustrate the layout and number of required spaces between each player. The input for this would be 2 3 4 5 and 5 4 2:
+-----------------+
|     |  x  |     |
|     +-----+     |
|     x     x     |
|    x   x   x    |
|  x   x   x   x  |
|  x  x  x  x  x  |
+-----------------+
|     o     o     |
|                 |
|  o   o   o   o  |
|  o  o  o  o  o  |
|     +-----+     |
|     |  o  |     |
+-----------------+

Valid examples:
Input:
4 4 2, 5 3 1 1

+-----------------+
|     |  x  |     |
|     +-----+     |
|  x   x   x   x  |
|  x   x   x   x  |
|                 |
|     x     x     |
+-----------------+
|        o        |
|        o        |
|    o   o   o    |
|  o  o  o  o  o  |
|     +-----+     |
|     |  o  |     |
+-----------------+

Input:
3 5 2, 4 4 1 1

+-----------------+
|     |  x  |     |
|     +-----+     |
|    x   x   x    |
|  x  x  x  x  x  |
|                 |
|     x     x     |
+-----------------+
|        o        |
|        o        |
|  o   o   o   o  |
|  o   o   o   o  |
|     +-----+     |
|     |  o  |     |
+-----------------+

Rules:

Input can be on any convenient format, separated however you want. Format can be a single string (5311), comma separated digits (5,3,1,1), etc.

The input should not contain any other information than the two formations

The output should look exactly as the sample figures, but trailing spaces and newlines are OK.
You can assume only valid input is given (only formations in the list will be used).
Full program or function

This is code golf, so the shortest code in bytes win.

Football's the one with the sticks, right?

No, that's shuffleboard. You want the one with ponies.

No, that's dressage. You want the one with goals.

Im still confused by the 15 players of team x in the first pitch, but I guess that does not play a role in this challenge.

@DenkerAffe, it was to show the spaces between the players. It was to have all the layout information in one single image. I made a small edit explaining it better (I hope)

What! No middle-field circle?

@LuisMendo, just assume it's a rainy day in Stoke! The middle-field circle is often hard to find =P

A common formation that doesn't appear in your examples is 4-2-3-1

JavaScript (ES6), 258 262
Anonymous function, taking 2 parameters as numeric arrays
(a,b,H=f=>(f[3]||f.push(0,f.pop()),[z='+-----------------+',...[6,7,...f].map(x=>`|${'98,8o8,5o5o5,4o3o3o4,2o3o3o3o2,2o2o2o2o2o2,5|2o2|5,5+-----+5'.replace(/\d/g,x=>' '.repeat(x)).split`,`[x]}|`),'']))=>H(a).join`
`.replace(/o/g,'x')+z+H(b).reverse().join`
`

Test

F=(a,b,
   H=f=>(
    f[3]||f.push(0,f.pop()),
    [z='+-----------------+',...[6,7,...f].map(x=>`|${'98,8o8,5o5o5,4o3o3o4,2o3o3o3o2,2o2o2o2o2o2,5|2o2|5,5+-----+5'.replace(/\d/g,x=>' '.repeat(x)).split`,`[x]}|`),'']
   )
)=>
  H(a).join`\n`.replace(/o/g,'x')+z+H(b).reverse().join`\n`

function test() {
  var f1=F1.value.match(/\d+/g),f2=F2.value.match(/\d+/g)
  O.textContent=F(f1,f2)
}

test()
x <input id=F1 value='4,4,2' oninput='test()'>

o <input id=F2 value='4,3,1,2' oninput='test()'>

Python 2, 401 377 bytes
def g(x,o):
 r=lambda r:["|"+"  x"*5+"  |","|        x        |","|     x     x     |","|    x   x   x    |","|  x   x   x   x  |"][r%5];d="+"+"-"*17+"+";h=[d,"|     |  x  |     |","|     +-----+     |"]+map(r,x);b=map(lambda r:r.replace("x","o"),[s for s in h[:3]]+map(r,o))[::-1];e="|"+" "*17+"|"
 if len(x)-4:h.insert(5,e)
 if len(o)-4:b.insert(1,e)
 print"\n".join(h+[d]+b)

Ungolfed version with test environment here!
Function that takes two lists of the format [defenders, midfielders, midfielders, attackers] while the one midfielder number is optional. Team X (top) comes first, team O (bottom) second.

there is a useless space in one of your lambda lambda a:r(a), x) ^^

@Erwan Thanks, good catch!

i think it's worst to define  t=lambda a:r(a)  as you use it 2 times

better solution remove all occurence of lambda a:r(a) replace it by just r

@Erwan Thanks, missed that too!

Perl, 360 332 324 bytes
sub f{$q="";($_,$p)=@_;@x=/\S+/g;splice@x,2,0,0if@x<4;for(@x) {$s=(17-$_)/($_+1);$s=$=+1if($s!=($==$s));$x=$"x$=;@a=();push@a,$p for 1..$_;$q.=$_==0?"|$u$u$u  |\n":"|$x".join($"x$s,@a)."$x|\n"}$q}($k,$j)=<>;$u=$"x5;$^="-"x17;$i="|$u+-----+$u|";say"x$^x\n|$u|  x  |$u|\n$i\n".f($k,x)."+$^+".(reverse f$j,o)."\n$i\n|$u|  o  |$u|\nx$^x"

Requires -E|-M5.010:
$ echo $'4 4 2\n4 4 1 1' | perl -M5.010 football.pl
x-----------------x
|     |  x  |     |
|     +-----+     |
|  x   x   x   x  |
|  x   x   x   x  |
|                 |
|     x     x     |
+-----------------+
|        o        |
|        o        |
|  o   o   o   o  |
|  o   o   o   o  |
|     +-----+     |
|     |  o  |     |
x-----------------x

Somewhat ungolfed:
sub f{
    $q="";
    ($_,$p)=@_;
    @x=/\S+/g;
    splice@x,2,0,0if@x<4;
    for(@x) {
        $s=(17-$_)/($_+1);
        $s=$=+1if($s!=($==$s));
        $x=" "x$=;
        @a=();
        push@a,$p for 1..$_;
        $q.=$_==0?"|$u$u$u  |\n":"|$x".join(" "x$s,@a)."$x|\n"
    }
    $q
}

($k,$j)=<>;
$u=" "x5;
$^="-"x17;
$i="|$u+-----+$u|";
say"x$^x\n|$u|  x  |$u|\n$i\n".f($k,x)."+$^+".(reverse f$j,o)."\n$i\n|$u|  o  |$u|\nx$^x"

@edc65 It's just my example output that is wrong :S

source: Stack Exchange

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

sort: votes


text:
Hollow out an array
The task
This challenge is very simple.
Your input is a rectangular 2D array of integers, sized at least 1×1.
It can be taken in any reasonable format.
Your output shall be the input array, but with all entries not on the first or last row or column set to 0.
It must be in the same format as the input.
For example, if the input array is
67  4 -8  5 13
 9 13 42  4 -7
 1  1  3 -9 29
16 99  8 77  0

then the correct output is
67  4 -8  5 13
 9  0  0  0 -7
 1  0  0  0 29
16 99  8 77  0

Rules and scoring
You can write a full program or a function, and functions are allowed to modify the input in place instead of returning it.
The lowest byte count wins, and standard loopholes are disallowed.
Test cases
These are formatted as nested lists to make copy-pasting easier.
[[3]] -> [[3]]
[[7,2,8]] -> [[7,2,8]]
[[3],[5],[12],[-6]] -> [[3],[5],[12],[-6]]
[[99,98,97],[88,87,86]] -> [[99,98,97],[88,87,86]]
[[6,7],[8,9],[10,11]] -> [[6,7],[8,9],[10,11]]
[[-1,-2,-3],[1,2,3],[5,5,5]] -> [[-1,-2,-3],[1,0,3],[5,5,5]]
[[67,4,-8,5,13],[9,13,42,4,-7],[1,1,3,-9,29],[16,99,8,77,0]] -> [[67,4,-8,5,13],[9,0,0,0,-7],[1,0,0,0,29],[16,99,8,77,0]]
[[0,1,0,1,0],[1,0,1,0,1],[0,1,0,1,0],[1,0,1,0,1],[0,1,0,1,0]] -> [[0,1,0,1,0],[1,0,0,0,1],[0,0,0,0,0],[1,0,0,0,1],[0,1,0,1,0]]

Leaderboard
Here is a Stack Snippet to generate both a regular leaderboard and an overview of winners by language.
To make sure that your answer shows up, please start your answer with a headline, using the following Markdown template:
## Language Name, N bytes

If you want to include multiple numbers (e.g. because you've improved your score or you want to list interpreter flags separately), make sure that the actual score is the last number in the header:
## Perl, <s>50</s> 43 + 2 (-p flag) = 45 bytes

You can also make the language name a link which will then show up in the leaderboard snippet:
## [><>](http://esolangs.org/wiki/Fish), 121 bytes

var QUESTION_ID=71591,OVERRIDE_USER=32014;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="
"+e.body.replace(OVERRIDE_REG,"")+"
")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;
body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}
 <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">

Leaderboard

	Author	Language	Size

Winners by Language

Language	User	Score

{{PLACE}}	{{NAME}}	{{LANGUAGE}}	{{SIZE}}	Link

{{LANGUAGE}}	{{NAME}}	{{SIZE}}	Link

MATL, 9 bytes
0HJ_ht4$(

Input is in the format
[67  4 -8  5 13;  9 13 42  4 -7;  1  1  3 -9 29; 16 99  8 77  0]

EDIT (June 12, 2016): to adapt to changes in the language, the link below has _ replaced by q.
Try it online!
0           % Push a 0: value that will be assigned into the array
HJ_h        % Vector [2, -1j]: this corresponds to index 2:end-1 for rows
t           % Duplicate: same index for columns
4$(         % Assignment indexing with 4 inputs: array, new value, row and col indices
            % Since the first input (array) to this function is currently missing, it's
            % implicitly taken at this point from stdin
            % Implicitly display stack contents, which is the modified array

Nice! I knew MATL would be in the running. :D

Jelly, 18 17 15 9 bytes
0W&ṖZ
ÇÇ^

Try it online! or verify all test cases.
Background
This approach is based on @Sp3000's Jelly answer, specifically on his idea to take advantage of vectorized operations between lists of different lengths.
We start by taking the bitwise AND of 0 and every integer in the first row of the input. Due to automatic vectorization, this can be achieved by taking the bitwise AND of [0] and the input without its last row. 0 is paired with the first row, resulting in a row of zeroes. Since the remaining rows have no counterpart in [0], they are left untouched.
Now we transpose the result, apply the above transformation once again (effectively removing the last column and zeroing out the first), and transpose again.
For the input
 67   4  -8   5  13
  9  13  42   4  -7
  1   1   3  -9  29
 16  99   8  77   0

this results in
  0   0   0   0
  0  13  42   4
  0   1   3  -9

Now, we take the bitwise XOR of this result and the original matrix. XORing an integer with itself yields 0. XORing an integer with 0 (or not XORing it at all) yields the same integer. This hollows the matrix out.
How it works
0W&ṖZ    Helper link. Argument: M (matrix)

0W       Yield [0].
   Ṗ     Yield M, without its last row.
  &      Take the bitwise AND of both.
    Z    Zip the result.

ÇÇ^      Main link. Input: A (matrix)

Ç        Call the helper link on A.
 Ç       Call the helper link on the result.
  ^      Take the bitwise XOR of the result and A.

Java 7, as a fully named function: 85
void f(int[][]a){for(int i=0,j;++i<a.length-1;)for(j=1;j<a[i].length-1;)a[i][j++]=0;}

You could lambda this down in Java 8 to remove a few bytes, but I don't really do that.

Could you save space by using Arrays.fill(a[i],1,a[i].length-1,0);? It's only 36 bytes instead of 37. =)

@corsiKa It would be nice, but I'd have to import or fully qualify it :/

Just out of curiosity, why do you have both loops different? Why not for(int i=0,j;++i<a.length-1;)for(j=0;++j<a[i].length-1;)a[i][j]=0;? It doesn't save any bytes, but it's more consistent with both loops being the same. :)

Mathematica, 27 bytes
(a=#;a[[2;;-2,2;;-2]]=0;a)&

Impressive.  Now, would you please explain it?  It looks like you are re-assigning inner cells to zero and the -2s denote second the second-last column or row.

How simple it is!

R, 33 48 bytes
I know, R isn't made for golfing. But it is made for positional indexing... Loading up an example;
a <- matrix(c(67,4,-8,5,13,9,13,42,4,-7,1,1,3,-9,29,16,99,8,77,0), ncol=5, byrow=TRUE)
a
#      [,1] [,2] [,3] [,4] [,5]
# [1,]   67    4   -8    5   13
# [2,]    9   13   42    4   -7
# [3,]    1    1    3   -9   29
# [4,]   16   99    8   77    0

Replace the value at any position not on the edge row or column, with 0:
x <- function(a){a[-c(1,nrow(a)),-c(1,ncol(a))]<-0;a}

x(a)
#      [,1] [,2] [,3] [,4] [,5]
# [1,]   67    4   -8    5   13
# [2,]    9    0    0    0   -7
# [3,]    1    0    0    0   29
# [4,]   16   99    8   77    0

Also checking a 2-column test:
b <- matrix(c(99,98,97,88,87,86), ncol=2, byrow=TRUE)
b
#     [,1] [,2]
#[1,]   99   98
#[2,]   97   88
#[3,]   87   86

x(b)
#     [,1] [,2]
#[1,]   99   98
#[2,]   97   88
#[3,]   87   86

Posterity: previous attempt
# a[2:(nrow(a)-1),2:(ncol(a)-1)]<-0 # previous attempt

Testing all examples:
tests <- read.table(text="[[3]] -> [[3]]
                          [[7,2,8]] -> [[7,2,8]]
                          [[3],[5],[12],[-6]] -> [[3],[5],[12],[-6]]
                          [[99,98,97],[88,87,86]] -> [[99,98,97],[88,87,86]]
                          [[6,7],[8,9],[10,11]] -> [[6,7],[8,9],[10,11]]
                          [[-1,-2,-3],[1,2,3],[5,5,5]] -> [[-1,-2,-3],[1,0,3],[5,5,5]]
                          [[67,4,-8,5,13],[9,13,42,4,-7],[1,1,3,-9,29],[16,99,8,77,0]] -> [[67,4,-8,5,13],[9,0,0,0,-7],[1,0,0,0,29],[16,99,8,77,0]]
                          [[0,1,0,1,0],[1,0,1,0,1],[0,1,0,1,0],[1,0,1,0,1],[0,1,0,1,0]] -> [[0,1,0,1,0],[1,0,0,0,1],[0,0,0,0,0],[1,0,0,0,1],[0,1,0,1,0]]")
tests$cols <- c(1,3,1,3,2,3,5,5)
tests$V1 <- gsub("\\[|\\]","",tests$V1)
tests$V1 <- paste0("c(",tests$V1,")")
tests$V3 <- gsub("\\[|\\]","",tests$V3)
tests$V3 <- paste0("c(",tests$V3,")")

testfn <- function(testno) {
  intest <- matrix(eval(parse(text=tests$V1[testno])), ncol=tests$cols[testno], byrow=TRUE)
  intest <- x(intest)
  outtest <- matrix(eval(parse(text=tests$V3[testno])), ncol=tests$cols[testno], byrow=TRUE)
  return(identical(intest, outtest))
}

sapply(seq_len(nrow(tests)), testfn)
# [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE

What happens with a 1 or 2 row or column matrix?

Good point, first attempt fails the 2-column test and deletes the middle row. I'll update.

Welcome to Programming Puzzles & Code Golf! We require all submissions to be either full programs or functions. In this case, your scored code is just a snippet, since it assumes that the variable a exists. To be in compliance with our rules, you could make it a function that takes a matrix, like function(a){a[-c(1,nrow(a)),-c(1,ncol(a))]=0;a} for 47 bytes.

GNU Sed, 31

Thanks to @manatwork for saving 4 bytes.

Version 4.2.2 or earlier, prior to this commit (discussion).
Score includes +1 for -r option.
Input rows are newline separated.  Elements on each row are single-line separated.
1n
$n
:
s/ -?\w+ / : /
t
y/:/0/

Explanation
1n                   # 1st line: print unchanged, then load next line
$n                   # last line: print unchanged, then load next line (i.e. EOF and stop)
:                    # unnamed label
s/ -?\w+ / : /       # substitute a number in spaces with a `:` in spaces
t                    # If the above matched, jump back to the label and try again
y/:/0/;              # transliterate `:` to `0`

Try it online.

Oh i see, it's a "fancy" way to get around no lookaheads, and thanks!

Too many braces: 1n;$n;:;s/ -?\w+ / : /;t;y/:/0/.

Can you include the information about the commit that makes your answer work in a quote block, the site is really slow and takes 1 minute to fully load

@manatwork Thanks -  saved 4 bytes!

@Ferrybig Added another link to the dev discussion on this topic.

Octave, 34 bytes
function h(M) M(2:end-1,2:end-1)=0

Note that the input requires semicolons to separate array rows:
h([[3];[5];[12];[-6]])

Explanation:
Octave (and MATLAB) array indices are 1-based. Specifying a range of Array(1:end) will give you all elements of the (one-dimensional, in this example) array. Array(2:end-1) will give you all of the elements except the first and last.
M(2:end-1,2:end-1)=0

sets to 0 all elements not in the first or last row or column:
>> A = [[-1,-2,-3];[1,2,3];[5,5,5]]
A =

  -1  -2  -3
   1   2   3
   5   5   5

>> h(A)
M =

  -1  -2  -3
   1   0   3
   5   5   5

If one of the dimensions is less than or equal to 2, the range end-1 is less than 2, therefore the end of the range (2:end-1) is less than the beginning. In this case, Octave ignores the range and does nothing. This is analogous to the for loop:
for (int i=2; i < 2; i++) {...}

The stop condition is true on the first iteration, so we fall out of the loop.
>> A = [[6,7];[8,9];[10,11]]
A =

    6    7
    8    9
   10   11

>> h(A)
M =

    6    7
    8    9
   10   11

Mathematica 81 76 bytes
(d=Dimensions@m;q=MemberQ;m Boole@Array[{1,d[[1]]}~q~#||{1,d[[2]]}~q~#2&,d])&

How it works
Assume that the input array is stored in m.
The dimensions of m are {4,5}`
(m={{67,4,-8,5,13}, {9,13,42,4,-7}, {1,1,3,-9,29}, {16,99,8,77,0}})//MatrixForm

Each cell in the following array, a, is True if the cell is either  in the first or (||) in last row or in the first or last column; otherwise it is False.
(d=Dimensions@m;a=Array[MemberQ[{1,d[[1]]},#]||MemberQ[{1,d[[2]]},#2]&,d])&[m]//MatrixForm

Applying the function Boole to the array converts True to 1 and False to 0.
b = Boole[a]

Multiply the matrix m by b. This multiplies each cell in m by the corresponding cell in b.
m b

You can use || as your OR to save a couple of bytes, and I can see a few  other bytes you can save too!

A Simmons, Thanks for the suggestion.

#-Unitize@ArrayFilter[Det,Array[Norm@*List,Dimensions@#],1]#&

@njpipeorgan,  I suggest you submit it. (And hopefully explain how it works!)

@DavidC I have posted my answer

Jelly, 12 bytes
ZṖṖ1;¥€
¬ÇÇ×

I think this works, still wrapping my head around Jelly. Try it online!
(Thanks to @Dennis for -2 bytes)
Works by multiplying the input array by an arrays of 1s and 0s one dimension smaller each way. For example, for [[67,4,-8,5,13],[9,13,42,4,-7],[1,1,3,-9,29],[16,99,8,77,0]] we multiply element-wise by
1 1 1 1
1 0 0 0
1 0 0 0

Full explanation
[Helper link - argument is a matrix]
Z           Zip
 ṖṖ         Pop last two elements, or [:-2]
   1;¥€     Append a 1 in front of every row

[Main link]
¬           Not, turning 0s to 1s and everything else to 0s. Even though some zeroes
            turn into 1s, it's fine because we multiply element-wise at the end,
            and 0*1 = 0
 ÇÇ         Perform helper link twice
   ×        Multiply element-wise

ES6, 52 48 46 bytes
f=a=>a.map((b,i)=>i&&a[i+1]+.5?b.map?f(b):0:b)

Edit: Saved 4 bytes thanks to @user81655. Saved a further 2 bytes thanks to @ETHproductions.

Clever! Here's a very similar approach without g which saves a few bytes: f=a=>a.map((b,i)=>i&&a[i+1]!=a.x?b.map?f(b):0:b)

Nice job! I count 48 bytes (perhaps you forgot to count the f=), but you can get it down to 46: f=a=>a.map((b,i)=>i&&a[i+1]+.5?b.map?f(b):0:b)

@ETHproductions Yes, I did forget to count the f=. Also I'm slightly surprised +.5 works but I see it does a string addition in the other call.

Julia, 50 35 bytes
A->A[2:size(A,1)-1,2:size(A,2)-1]=0

This is an anonymous function that accepts an array and modifies it in place. To call it, assign it to a variable.
The approach here is quite simple: For the n by m input array A, we assign Aij = 0 for all i = 2, ..., n-1 and j = 2, ..., m-1 by constructing ranges of indices. The ranges may be empty, like if n or m = 1, in which case no replacement is done.
Try it online
Saved 15 bytes thanks to Dennis!

Javascript, 62 59 56 bytes
s=>s.replace(/(^.*|\n\s*\S+)|\S+(?= .*\n)/g,(a,b)=>b||0)

This approach expects an string as argument. You can see what the regex do here: https://regex101.com/r/kC6xA8/3

C, 62 bytes
y;f(a,b,c)int **a;{for(b--;b-->1;)for(y=1;y<c-1;)a[b][y++]=0;}

Hope it's ok to take in array length/width as parameters.  I played around with memset/bzero a little bit, but multiplying by sizeof(int) drastically increased the code size.
EDIT: 55 bytes if we can further bend the rules and store our array as characters since the input is only a single digit each.
x;
#define f(a,b,c) for(x=1;x operator ;)

Mathematica, 55 bytes
#-Unitize@ArrayFilter[Det,Power~Array~Dimensions@#,1]#&

Test case
%[RandomInteger[9,{5,5}]]
(*
  {{8,8,3,6,5},
   {7,0,0,0,4},
   {2,0,0,0,7},
   {3,0,0,0,5},
   {8,6,1,0,8}}
*)

Explanation
The main idea of this answer is the same as DavidC's answer (first construct a mask matrix, and then multiply it to the original matrix), but the construction of mask matrix is different.
ArrayFilter[f,list,r] maps f onto every element of list within a radius of r.
ArrayFilter[f,{1,2,3,4,5},1]
(* { f[{1,1,2}], f[{1,2,3}], f[{2,3,4}], f[{3,4,5}], f[{4,5,5}] } *)

Note that boundary elements are duplicated where there are insufficient neighbors. When list is of 2-dimensions, this feature works well together with Det to give the desired result, since duplicated columns or rows on four boundaries vanish the determinants.
ArrayFilter[Det,Power~Array~{4,4},1]
(*
  {{0, 0,  0,    0},
   {0, 12, 72,   0},
   {0, 48, 1152, 0},
   {0, 0,  0,    0}}
*)

where Power~Array~{4,4} guarantees the determinants on inner positions to be non-zero. And
1-Unitize@%
(*
  {{1,1,1,1},
   {1,0,0,1},
   {1,0,0,1},
   {1,1,1,1}}
*)

gives the mask matrix.

Python, 50 bytes
def f(a):
 for l in a[1:-1]:l[1:-1]=[0]*(len(l)-2)

Accepts a list of lists, and modifies it in place. Python's slice syntax is not inconvenient for this task.
I learned that multiplying a list by a negative number results in an empty list, which allows the above code to work on small inputs.

Java 8, as a lambda function: 82 83 95 chars/bytes
Lambda Signature: int[][] -> (void) (i.e. Consumer<int[][]>)
(a)->{int[]v={1,1};while(++v[0]<a.length){while(++v[1] [[3],],
  [[7,2,8],] => [[7,2,8],],
  [[3],[5],[12],[-6]] => [[3],[5],[12],[-6]],
  [[99,98,97],[88,87,86]] => [[99,98,97],[88,87,86]],
  [[6,7],[8,9],[10,11]] => [[6,7],[8,9],[10,11]],
  [[ -1,-2,-3],[1,2,3],[5,5,5]] => [[ -1,-2,-3],[1,0,3],[5,5,5]],
  [[67,4,-8,5,13],[9,13,42,4,-7],[1,1,3,-9,29],[16,99,8,77,0]] => [[67,4,-8,5,13],[9,0,0,0,-7],[1,0,0,0,29],[16,99,8,77,0]],
  [[0,1,0,1,0],[1,0,1,0,1],[0,1,0,1,0],[1,0,1,0,1],[0,1,0,1,0]] => [[0,1,0,1,0],[1,0,0,0,1],[0,0,0,0,0],[1,0,0,0,1],[0,1,0,1,0]],
);

use Test;
plan +@test-cases;

for @test-cases {
  my $k = .key;
  {.[1..*-2]»[1..*-2] »=»0}( $k ); # <==
  ok $k eqv .value
}

1..8
ok 1 -
ok 2 -
ok 3 -
ok 4 -
ok 5 -
ok 6 -
ok 7 -
ok 8 -

{.[1..*-2]»[1..*-2]X=0} saves 2 bytes

@raiph it doesn't appear to work for the last two cases

JavaScript ES6, 69 66 57 bytes
Y=>Y.map((X,y)=>X.map((N,x)=>x*y&&X[x+1]+.5&&Y[y+1]?0:N))

How it works
This solution maps through each y-index y and x-index x in the input and decides whether or not to throw it out based on these two indices. There are four cases which we need to keep:

x is 0
y is 0
x equals the length of the inner array, minus 1
y equals the length of the outer array, minus 1

We can take care of the first two with a little multiplication: x*y returns 0 iff either x or y are 0, and a positive integer otherwise. Now for the third: we could check if X.length>x+1, but that takes a lot of bytes. Another way to do this is to check if the item ahead is falsy, namely undefined, which is what you get when trying to access a non-existent item. However, this also matches if the next item is 0, so we add 0.5 to make sure that doesn't happen:
1 + 0.5 = 1.5 (truthy)
0 + 0.5 = 0.5 (truthy)
-1 + 0.5 = -0.5 (truthy)
undefined + 0.5 = NaN (falsy)

Finally, the fourth point: since the outer array has only arrays inside, and any array is truthy, we can just check Y[y+1]. Now with ?0:N, we convert it to 0 if all of the above turned out truthy; N otherwise. And that's it!

Retina, 31 24 22
(?<=¶.+ )\S+(?= .*¶)
0

Saved 2 bytes thanks to randomra
Try it online!
There is probably a better way to do it, as this is just a pretty basic multi-line replacement. Essentially we find each number that is preceded by a newline, some number of characters and a space, and is immediately followed by a space and then and is eventually followed by a newline. These numbers are then all replaced with 0.
This will not preserve column padding, but I don't think that's a problem.

Haskell, 59 58 bytes
k _[x]=[x]
k f(x:y)=x:(f<$>init y)++[last y]
f=k(k(\_->0))

Expanded
onInner :: (a -> a) -> [a] -> [a]
onInner _ [x]    = [x]
onInner f (x:xs) = x : map f (init xs) ++ [last xs]

hollowOut :: [[Int]] -> [[Int]]
hollowOut =
   onInner       -- leave first and last line alone
     (onInner    -- leave first and last entry per line
       (const 0) -- replace entries by 0
     )

You should be able to turn ++[last y] into :(last y) or :last y

@HEGX64: No, wrong type. x : map f (…) is already of type [a], and last y has type a, whereas (:) :: a -> [a] -> [a]. Adding an element at the end of a list in Haskell kind of sucks, since those lists are single-linked forward lists.

Opps. I knew I should have tried it myself before posting :)

You can turn k into an infix operator, let's say # and flip the arguments to save one byte: [x]#_=..., (x:y)#f=..., f=(#(# \_->0)) and you can drop the name of your main function, i.e. f= for another two bytes.

Groovy, 70 bytes
This isn't very creative, but it's short!
g={a->for(i=1;i<a.size()-1;i++)for(j=1;j

Iterate over the inner array, skipping the first and last elements
for(i=1;i<a.size()-1;i++)

Iterate over middle items in the inner array
for(j=1;j<a[i].size()-1;)

Set the elements to 0 and return a
a[i][j++]=0;a}

Tests
assert g([[3]]) == [[3]]
assert g([[7, 2, 8]]) == [[7, 2, 8]]
assert g([[3], [5], [12], [-6]]) == [[3], [5], [12], [-6]]
assert g([[99, 98, 97], [88, 87, 86]]) == [[99, 98, 97], [88, 87, 86]]
assert g([[6, 7], [8, 9], [10, 11]]) == [[6, 7], [8, 9], [10, 11]]
assert g([[-1, -2, -3], [1, 2, 3], [5, 5, 5]]) == [[-1, -2, -3], [1, 0, 3], [5, 5, 5]]
assert g([[67, 4, -8, 5, 13], [9, 13, 42, 4, -7], [1, 1, 3, -9, 29], [16, 99, 8, 77, 0]]) == [[67, 4, -8, 5, 13], [9, 0, 0, 0, -7], [1, 0, 0, 0, 29], [16, 99, 8, 77, 0]]
assert g([[0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0]]) == [[0, 1, 0, 1, 0], [1, 0, 0, 0, 1], [0, 0, 0, 0, 0], [1, 0, 0, 0, 1], [0, 1, 0, 1, 0]]

Pyth, 18 bytes
Qjbm:dSttld0P.Qe.Q

Explanation
                   - autoassign Q=eval(input())
                   - autoassign .Q = map(eval, rest_of_input)
Q                  - imp_print(Q)
   m        P.Q    -  [V for d in .Q[:-1]]
      Sttld        -     range(1, len(d)-2+1)
    :d     0       -    assign_indexes(d, ^, 0)
 jb                - "\n".join(^)
               e.Q - imp_print(.Q[-1])

Input arrays are separated by newlines
Try it here

R, 71 64 57 Bytes
function(m){if(all((y<-dim(m)-1)>1))m[2:y[1],2:y[2]]=0;m}

edit -7 bytes by explicitly dealing with <2-row or <2-column matrices explicitly
edit2 -7 bytes by assigning dimensions of matrix while checking the size

C++, 80 79 bytes
Expects the array as int** with given sizes n and k:
void p(int**c,int n,int k){for(int j,i=1;1+i<n;++i)for(j=1;j+1<k;)c[i][j++]=0;}

An alternative that works for any type that has size() and value_type & operator[](int) (98 bytes):
template<class C>void p(C&c){for(int j,i=1;1+i<c.size();++i)for(j=1;j+1<c[i].size();)c[i][j++]=0;}

Expanded version
template <class Container>
void hollowOut(Container & ctn){
    const auto size = ctn.size();

    for(typename Container::size_type i = 1; i + 1 < size; ++i) {
        const auto inner_size = ctn[i].size();

        for(decltype(inner_size) j = 1; j + 1 < inner_size; ++j) {
            ctn[i][j] = 0;
        }
    }
}

Seem like adding matrix dimensions to the input is a standard loophole

PHP, 82 81 80 71 bytes
function(&$z){for(;$z[++$i+1];)for(;0 .$z[0][++$$i+1];)$z[$i][$$i]=0;};

Run like this:
php -r '$f = function(&$z){for(;$z[++$i+1];)for(;0 .$z[0][++$$i+1];)$z[$i][$$i]=0;};   $z=[[1,2,3,4],[5,6,7,8],[9,10,11,12],[13,14,15,16]]; $f($z); print_r($z);'

Saved a byte by assuming constant size rows (thx to manatwork)
Saved a byte by making it an anonymous function
Saved 7 bytes by using truthyness of next array item, preventing calls to count, which is a way too long name for codegolf

As processing a matrix, all sub-arrays should be the same length. So in the inner for is safe to always iterate up to count($z[0])-1 to spare 1 character.

APL, 17 bytes 15 bytes
{⍵×(⌽∨⊖)1∊¨⍳⍴⍵}

How it works

⍳⍴⍵ generates a 2D array where all the cells contain the coordinates of all the cells of the argument.
1∊¨ searches in each such cell if there's a 1 and returns a 1 if so, or 0 otherwise. This builds a matrix where the first row and the first column are 1s and all the rest are 0.
(⌽∨⊖) combines with logical "or" two version of the matrix, one reversed along the first and one reversed along the last axis.
⍵× is the standard multiplication.

You can substitute (⊣∨⊖∘⌽) with (⊖∨⌽), two bytes less

Brilliant! Let me do that!

APL (Dyalog Classic), 12 bytes
⊢-(⍉0⍪1↓⌽)⍣4

Try it online!
⍉⌽⍵ is normally rotation (reverse horizontally and transpose)
here we combine it with 0⍪1↓⍵ which replaces the first row with zeroes (drop one row, then concatenate 0 on top) into a single train: ⍉0⍪1↓⌽
⍣4 repeats 4 times
⊢- subtracts from the original matrix

05AB1E, 11 bytes
4FøεNĀ*}R}^

Try it online or verify all test cases.
Explanation:
4F       }    # Loop 4 times:
  ø           #  Transpose/zip; swapping rows/columns
   ε   }      #  Map over the matrix (takes the input implicitly in the first iteration)
    NĀ        #   Trutify the index (0 remains 0; everything else becomes 1)
      *       #   Multiply all values in the current row of the matrix with it
        R     #  Reverse the matrix
          ^   # Bitwise-XOR the resulting matrix with the (implicit) input-matrix
              # (and output implicitly)

Example run:
Input:       [[67,4,-8,5,13],[9,13,42,4,-7],[1,1,3,-9,29],[16,99,8,77,0]]

Iteration 1:
 Zip:         [[67,9,1,16],[4,13,1,99],[-8,42,3,8],[5,4,-9,77],[13,-7,29,0]]
 Map:         [[0,0,0,0],[4,13,1,99],[-8,42,3,8],[5,4,-9,77],[13,-7,29,0]]
 Reverse:     [[13,-7,29,0],[5,4,-9,77],[-8,42,3,8],[4,13,1,99],[0,0,0,0]]

Iteration 2:
 Zip:         [[13,5,-8,4,0],[-7,4,42,13,0],[29,-9,3,1,0],[0,77,8,99,0]]
 Map:         [[0,0,0,0,0],[-7,4,42,13,0],[29,-9,3,1,0],[0,77,8,99,0]]
 Reverse:     [[0,77,8,99,0],[29,-9,3,1,0],[-7,4,42,13,0],[0,0,0,0,0]]

Iteration 3:
 Zip:         [[0,29,-7,0],[77,-9,4,0],[8,3,42,0],[99,1,13,0],[0,0,0,0]]
 Map:         [[0,0,0,0],[77,-9,4,0],[8,3,42,0],[99,1,13,0],[0,0,0,0]]
 Reverse:     [[0,0,0,0],[99,1,13,0],[8,3,42,0],[77,-9,4,0],[0,0,0,0]]

Iteration 4:
 Zip:         [[0,99,8,77,0],[0,1,3,-9,0],[0,13,42,4,0],[0,0,0,0,0]]
 Map:         [[0,0,0,0,0],[0,1,3,-9,0],[0,13,42,4,0],[0,0,0,0,0]]
 Reverse:     [[0,0,0,0,0],[0,13,42,4,0],[0,1,3,-9,0],[0,0,0,0,0]]

Bitwise-XOR:  [[67,4,-8,5,13],[9,0,0,0,-7],[1,0,0,0,29],[16,99,8,77,0]]

Perl, 34 + 2 = 36 bytes
next if$.==1||eof;s/ .+?(?= )/ 0/g

Requires the -p flag:
$ perl -pE'next if$.==1||eof;s/ .+?(?= )/ 0/g' <<< $'1 2 3\n4 5 6\n7 8 9'
1 2 3
4 0 6
7 8 9

How it works:
# '-p' Read each line into `$_` and auto prints
next if$.==1||eof; # `$.` is set to to the current line in file (1, 2, ..., n)
                   # and `eof` is true if its the last line
s/ .+?(?= )/ 0/g

Lua, 69 bytes
function f(a)for i=2,#a-1 do
for o=2,#a[i]-1 do
a[i][o]=0
end
end end

If only I had curly braces instead of dos and ends...

SmileBASIC, 69 51 bytes
DEF H A,W,H
FOR I=1TO H-2FILL A,0,W*I+1,W-2NEXT
END

Filling a 2D area in an array usually would require using FILL in a loop. But it's much easier to work with 2D data on the graphics page, so first the array is copied there.
Aww I thought I was so clever using graphics commands... but it turns out calling FILL a bunch of times is actually shorter.
Anyway, function inputs are the array and width/height (This is standard in Smilebasic because there's no way to check the dimensions of an array.)

Python 3, 106 bytes
lambda a:[[a[x][y]*(not(0<x<len(a)-1and 0<y<len(a[0])-1))for y in range(len(a[0]))]for x in range(len(a))]

Perl 6, 70 bytes
Whole program that reads columns separated by a space and rows separated by newline. Inplace replacement humbly stolen from b2gills.
my @a=lines.map:{[.split(' ')]};{.[1..*-2]»[1..*-2] »=»0}(@a);dd @a

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

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


text:
Generating the alphabet in JavaScript
I'm pretty sure there's not a better way to do this but figured it couldn't hurt to ask.
I'm tired of typing out a='abcdefghijklmnopqrstuvwxyz'.
Cool languages have Range('a'..'z') or similar
What can we come up with with JS that's as short as possible??
for(i=97,a='';i<123;){a+=String.fromCharCode(i++)}

is longer than just the alphabet - but guarantees I don't screw up somewhere.
I'm hoping there's a nasty bit-shifty way to produce a-z in less than 50 characters.
I messed around with i=97;Array(26).map(x=>String.fromChar....i++
but it was always way longer by the time I joined then split the array(26) to be useable

Edit: I've gotten it down to
[...Array(26)].reduce(a=>a+String.fromCharCode(i++),'',i=97)

60 bytes

@muddyfish, LuisMendo: This is on-topic per meta.

[...Array(26)].map((q,w)=>String.fromCharCode(w+97)) is 52 bytes and add another 7 for the .join\``

Related: http://stackoverflow.com/questions/3895478/does-javascript-have-a-method-like-range-to-generate-an-array-based-on-suppl

@dev-null a='';i=97;[...Array(26)].map(b=>a+=String.fromCharCode(i++)) is 60 but takes care of the join
how are you doing join in 7 without getting commas in the result?

@CharlieWynn [...Array(26)].map((q,w)=>String.fromCharCode(w+97)).join\``

@dev-null join`` is new to me!

Alternative to String.fromCharCode
... if you are happy with a lowercase only alphabet.
for(i=9,a='';++i<36;)a+=i.toString(36) // 38, cannot be used in an expression
[...Array(26)].map(_=>(++i).toString(36),i=9).join`` // 52 directly returnig the string desired
[...Array(26)].map(_=>a+=(++i).toString(36),a='',i=9) // 53 assign to a variable
(i=9,[for(_ of Array(26))(++i).toString(36)].join``) // 52 ES7 direct return
i=9,a='',[for(_ of Array(26))a+=(++i).toString(36)] // 51 ES7 assign to a variable

Oh dang, that is clever.  So it's starting with 10, converting to base 36 and printing it? so a-z!

Are those a='' and i=9 arguments of map function call? Checked Array.prototype.map() on mdn and it doesn't look like map support such arguments..

@JaySomedon those are argument for map function call, in a way, Javascript functions tipically don't care and discard parameters they do not expect. So I initialize a variable I need, while adding a parameter that is of no use for the called function

@JaySomedon see also this answer and related comments https://codegolf.stackexchange.com/a/2684/21348

@edc65 aha I see! That's neat! So here, when javascript evaluates arguments like i=9 in map(), it actually creates a global variable i then assigns 9 to that?

@JaySomedon correct

@edc65 One more thing, are these same: var a = [...Array(26)], var b = Array(26), var c = new Array(26)? In console, a prints [undefined, undefined..] and b and c print [empty slots...] but all a[0]``b[0]``c[0] evaluate to undefined. But only calling map on [...Array(26)] gives me alphabets, calling on the other two give me nothing, wonder why. Also on mdn, I can't find any example about Array(n), so I wonder how Array(n) and new Array(n) are related with each other?

Note: All of these techniques assign the alphabet string to variable a.

I am 99% certain that the shortest way to achieve this in JavaScript is indeed:
a="abcdefghijklmnopqrstuvwxyz" // 30 bytes

But there are several other interesting methods. You can use string compression:
a=btoa`i·?yø!?9%?z)ª»-ºü1`+'yz' // 31 bytes; each ? represents an unprintable

You can get the compressed string from atob`abcdefghijklmnopqrstuvwx`. The 'yz' must be added manually because if you compress the whole string, while the result is only 27 bytes, it will turn out as abcdefghijklmnopqrstuvwxyw==.
I believe the shortest way to do it programmatically is also the method you suggested:
for(i=97,a='';i<123;)a+=String.fromCharCode(i++) // 48 bytes

You can do it with ES6 features (template strings ``, spread operator ...) if you want:
a=[...Array(26)].map(_=>String.fromCharCode(i++),i=97).join`` // 61 bytes
a=[...Array(26)].map((_,i)=>String.fromCharCode(i+97)).join`` // also 61 bytes
a=[...Array(i=26)].map(_=>String.fromCharCode(++i+70)).join`` // again, 61 bytes

You can do one better with a variable instead of .join``:
[...Array(26)].map(_=>a+=String.fromCharCode(i++),i=97,a='') // all 60 bytes
[...Array(26)].map((_,i)=>a+=String.fromCharCode(i+97),a='')
[...Array(i=26)].map(_=>a+=String.fromCharCode(++i+70),a='')

Or ES7 with array comprehensions, which is another byte shorter:
a=[for(_ of Array(i=26))String.fromCharCode(++i+70)].join`` // 59 bytes

Creating the variable beforehand saves yet another byte:
a='',[for(_ of Array(i=26))a+=String.fromCharCode(++i+70)] // 58 bytes

Also, String.fromCharCode accepts multiple arguments and will automatically join them. So we can golf each ES6 version down to 57 bytes:
a=String.fromCharCode(...[...Array(26)].map(_=>i++,i=97)) // all 57 bytes
a=String.fromCharCode(...[...Array(26)].map((_,i)=>i+97))
a=String.fromCharCode(...[...Array(i=26)].map(_=>++i+70))

And the ES7 one down to 55:
a=String.fromCharCode(...[for(_ of Array(i=26))++i+70]) // 55 bytes

If you'd like to learn more about golfing ranges, check out this set of tips. There's also one about ES7's array comprehensions.
EDIT: As edc65 has pointed out, most of these become shorter using i.toString(36) instead of String.fromCharCode(i):
for(i=9,a='';++i<36;)a+=i.toString(36) // 38 bytes
a=[...Array(26)].map(_=>(++i).toString(36),i=9).join`` // 54 bytes
[...Array(26)].map(_=>a+=(++i).toString(36),i=9,a='') // 53 bytes
i=9,a=[for(_ of Array(26))(++i).toString(36)].join`` // 52 bytes
i=9,a='',[for(_ of Array(26))a+=(++i).toString(36)] // 51 bytes

I believe this one is the shortest possible that can be called as a function return value:
eval("for(i=9,a='';++i<36;)a+=i.toString(36)") // 46 bytes

It's three bytes shorter than manually returning it from a function:
x=>eval("for(i=9,a='';++i<36;)a+=i.toString(36)") // 49 bytes
x=>{for(i=9,a='';++i<36;)a+=i.toString(36);return a} // 52 bytes

Of course, x=>"abcdefghijklmnopqrstuvwxyz" still beats everything else.

I really like where this is going - just wish I could ES7 in chrome :(

@CharlieWynn Yes, it's a shame that not all browsers support all the latest features. But after all, Chrome wasn't built in a day... ;)

Most of these solution can be shortened using .toString instead of String,.fromCharCode. See my answer

@CharlieWynn I think Chrome Beta now supports all of ES7 and all of ES6 except modules and tail call optimisation.

Here's a 42-byter that can be called as a function return value:  (f=(i=9)=>++i<36?i.toString(36)+f(i):'')()

@ETHproductions for this code [...Array(26)].map(_=>String.fromCharCode(i++),i=97).join() how is i iterating? It's not even declared? Even if it were how is it that it's not set back to 97 each loop? I'm really confused. I looked at documentation but I must be missing something.

@zfrisch It's declared as the second argument to map (which doesn't affect anything): i=97. Then each time the function _=>String.fromCharCode(i++), it's incremented by 1.

@ETHproductions cool! I would've expected, since the second parameter looks like it's a this context, that if it wasn't a valid this context that it would have just thrown an error. The more you know.

Here's another approach, a 51 byte ES6 expression:
String.fromCharCode(...Array(123).keys()).slice(97)

50 bytes in upper case of course.

For upper case: String.fromCharCode(...Array(91).keys()).slice(65)

(36n**26n*351n/1225n-1n).toString(36)

37 bytes, as an expression. Uses the same base-36 method as many others, but further,  obtaining all the letters from a single number. Requires BigInt support.

36 bytes, using a trick I just learned about (from this post: https://codegolf.stackexchange.com/a/176496/64538):
for(i=9;++i<36;)name+=i.toString(36)

window.name is an empty string by default.
Of course, this is even less practical than the 38-byte solution since it uses a longer variable name.

Using what may or may not be defined at global scope
39 bytes for object properties to array matching a-z
a=`${Object.keys(top)}`.match(/[a-z]/g)

48 bytes for an unsorted Set
a=new Set(`${Object.keys(top)}`.match(/[a-z]/g))

55 bytes for a sorted Set
a=new Set(`${Object.keys(top)}`.match(/[a-z]/g).sort())

67 bytes for a sorted string
a=[...new Set(`${Object.keys(top)}`.match(/[a-z]/g).sort())].join``

\${Object.keys(top)}`.match(/([a-z])(?!.*\1)/g).sort().join``` is still shorter.

I like this answer from above, but just throwing this small addition out there:
const alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');

The other answers are great but consider this example:
const excelSheet = sheet('whatever.csv')
const headers = excelSheet.meta.headers // ['First Name', 'Last Name']
headers.map((header, i) => {
    console.log(`${header} is column ${alphabet[i]}`)
})

// First Name is column A
// Last Name is column B

It's more usable and readable for beginner/intermediate JavaScript developers. But this is code golf so I understand if this gets downvoted.

If you want an array, [...'ABCDEFGHIJKLMNOPQRSTUVWXYZ'] is shorter than 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.split(''). And although getting the column names from Excel is original, it's indeed far from shorter.

@KevinCruijssen I learned something new, thank you! Humbly noted.

The excel headers is extremely clever!


text:
Tips for golfing in Retina
What general tips do you have for golfing in Retina? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Retina (e.g. "remove comments" is not an answer). Please post one tip per answer.
For reference, the online compiler is here.
@Sp3000 pointed out there is also Tips for Regex Golf. Answers here should focus specifically on Retina features and not on general regex golfing tips.

Related: Tips for regex golf

Hmmm, I've been holding off posting this because Retina is still much in development and I was afraid most answers would end up being plain regex golfing tips, not very specific to Retina. But we might as well give it a go, I guess... :)

@MartinBüttner You and some others have given me a lot of good tips and hints since I started looking at Retina, so I think its probably about time for this.  I added a clarification that general regex tips should go to the linked question.

@MartinBüttner Here is as good a place as any to ask - I've been wondering for a while - out of curiosity what is the inspiration for the name "Retina"?  I assume the "Re" part is for Regular Expression, but what about the "tina"?

@DigitalTrauma I was trying to come up with a nice word that would work as an acronym, but failed. The word "retina" was quite close to some of the attempts, and I liked the word. I never managed to retcon it into an acronym though and have since given up on that. So yeah the "re" is sort of for "regular expressions" and maybe the "n" for ".NET", but ultimately it's just a word that sounded nice.

Combine loops if possible
In non-trivial computations you'll often find yourself using several loops to process data:
+`stage1
+`stage2
+`stage3

So this runs stage1 until the output converges, then stage2 until the output converges and then stage3 until the output converges.
However, it's always worth examining the stages in detail. Sometimes it's possible to run the loop in an interleaved fashion as stage1, stage2, stage3, stage1, stage2, stage3, ... instead (this depends a lot on what the stages actually do, but sometimes they make completely orthogonal changes or work well as a pipeline). In this case you can save bytes by wrapping them in a single loop:
{`stage1
stage2
}`stage3

If stage1 is the first stage or stage3 is the last stage of the program you can then even omit on of those parentheses as well (which means this can already save bytes for a loop of two stages).
A recent use of this technique can be seen in this answer.

Splitting strings into chunks of equal length n
As in most "normal" languages TMTOWTDI (there's more than one way to do it). I'm assuming here that the input doesn't contain linefeeds, and that "splitting" means splitting it into lines. But there are two quite different goals: if the length of the string isn't a multiple of the chunk length, do you want to keep the incomplete trailing chunk or do you want to discard it?
Keeping an incomplete trailing chunk
In general, there are three ways to go about the splitting in Retina. I'm presenting all three approaches here, because they might make a bigger difference when you try to adapt them to a related problem. You can use a replacement and append a linefeed to each match:
.{n}
$&¶

That's 8 bytes (or a bit less if n = 2 or n = 3 because then you can use .. or ... respectively). This has one issue though: it appends an additional linefeed if the string length is a multiple of the chunk length.
You can also use a split stage, and make use of the fact that captures are retained in the split:
S_`(.{n})

The _ option removes the empty lines that would otherwise result from covering the entire string with matches. This is 9 bytes, but it doesn't add a trailing linefeed. For n = 3 it's 8 bytes and for n = 2 it's 7 bytes. Note that you can save one byte overall if the empty lines don't matter (e.g. because you'll only be processing non-empty lines and getting rid of linefeeds later anyway): then you can remove the _.
The third option is to use a match. With the ! option we can print all the matches. However, to include the trailing chunk, we need to allow for a variable match length:
M!`.{1,n}

This is also 9 bytes, and also won't include a trailing linefeed. This also becomes 8 bytes for n = 3 by doing ..?.?. However note that it reduces to 6 bytes for n = 2 because now we only need ..?. Also note that the M can be dropped if this is the last stage in your program, saving one byte in any case.
Discarding an incomplete trailing chunk
This gets really long if you try to do it with a replacement, because you need to replace the trailing chunk with nothing (if it exists) and also with a split. So we can safely ignore those. Interestingly, for the match approach it's the opposite: it gets shorter:
M!`.{n}

That's 7 bytes, or less for n = 2, n = 3. Again, note that you can omit the M if this is the last stage in the code.
If you do want a trailing linefeed here, you can get that by append |$ to the regex.
Bonus: overlapping chunks
Remember that M has the & option which returns overlapping matches (which is normally not possible with regex). This allows you to get all overlapping chunks (substrings) of a string of a given length:
M!&`.{n}

Is it somehow possible to split a string exactly in halve with variable length? So 123456 becomes 123\n456 and 1234567890 becomes 12345\n67890?

@KevinCruijssen I don't think I added any specific feature for that. You'll probably have to use balancing groups: https://tio.run/##K0otycxLNPyvquGe8D/YIEHD3sZWQ09TW1PD3hbI1jW0A3JUNP//NzQyNjE144JQ5haWBgA If you don't mind a trailing linefeed, you can omit the ?=.

I was able to complete the challenge where I thought I needed it differently, but the balancing groups is indeed very useful! I knew it had to be something along those lines, but my regex/Retina skills are not nearly good enough. Thanks for answering! :)

Horizontal or Vertical Mirroring in Retina 0.8.2
If the amount of mirroring is a constant, then it's easy enough: duplicate the string, then reverse the appropriate half. For instance, suppose the buffer is known to contain 10 characters, and you want to mirror them about the last character:
saippuakiv

The following program would then achieve that:
.$
$&$`
10>O$^`.

Try it online! Explanation: The first stage copies the first 9 characters to the end of the line, then the second stage reverses the characters after the first 10. Note that the second stage consists of two lines but the second (empty) line may be omitted if it's the last stage.
If you want to mirror to the left, then you can prepend the suffix and sort the first 9 characters instead.
^.
$'$&
9O$^`.

Try it online! (Mirrors vikauppias to the left.)
Similarly, you can mirror a fixed number of lines. Suppose for instance you wanted a mirror copy of all three lines:
| | | | |
=~=~=~=~=
#########

The following program would then achieve that:
$
¶$`
3>O$^`

Try it online! Explanation: The first stage duplicates the entire buffer, while the second stage reverses the lines after the first three.
If you want to mirror up, then remove the >, so the first 3 lines are reversed instead.
If the amount of mirroring is a variable, then it might still be possible, but you would need to use .NET balancing groups to ensure that only the characters or lines that need to be reversed are processed by the O command.
Horizontal Mirroring in Retina 1
Horizontal mirroring is straightforward in Retina 1: simply use the $^ function to reverse a substitution. For instance, to horizontally mirror saippuakiv as above:
.$
$&$^$`

Try it online! Explanation: The reversed prefix of the input is appended to it, thus mirroring the input. (The code would be even simpler if the last character could be duplicated as well.)
Vertical Mirroring of Horizontally Mirrored Text in Retina 1
If you are mirroring horizontally mirrored text, then a very similar approach will allow you to vertically mirror the whole text.
$
¶$^$`

Try it online! Explanation: The whole buffer is duplicated, but the second copy is reversed. This only works because the horizontal mirroring turns the string reversal into a line reversal.
Both of these examples are readily adapted to mirror to the left or up.
If the text is not already horizontally mirrored then you will need to adapt the Retina 0.8.2 examples (note that the limits syntax changes so that 3> is now 3, and 3 is now ,2). You can use the V command instead to avoid the second line of the stage: 3,V0^ instead of 3,O$^ (the 0 is needed to avoid reversing the characters of the lines).

Arithmetic in Retina 1
In Retina you need to do your arithmetic in unary. However, Retina 1 makes things slightly easier for you in certain cases, principally because of two constructs:

The repetition operator * accepts an expression as its RHS, whereas the $* operator in Retina 0.8.2 only accepted a character as its RHS
Retina 1 now includes a $(...) grouping construct, which accepts the length modifier $.(...)

It thus becomes possible to perform some arithmetic operations in both unary or decimal, depending on which is convenient. In particular, the group length construct $.(...) calculates the sum of the lengths of its contents, taking any products using arbitrary precision integers, so it's not limited in value.
Addition
This is straightforward.

Convert any decimal numbers to unary using *_
Concatenate the numbers to give a unary result
Group the sum using $(...) if you intend to multiply it or $.(...) to convert it to decimal

2-argument examples:

Unary + Unary = Unary: $1$2
Unary + Unary = Decimal: $.($1$2)
Unary + Decimal = Unary: $1$2*_
Unary + Decimal = Decimal: $.($1$2*) (see below)
Decimal + Decimal = Unary: $1*_$2*_
Decimal + Decimal = Decimal: $.($1*_$2*)

Multiplication
Note that * normally takes one decimal and one unary parameter and returns a unary result.

If the numbers are all decimal, add an extra unary parameter of 1
Convert all but one number to decimal using the length modifier
Take the product to give a unary result
Convert the product to decimal by enclosing in $.(...) if desired

2-argument examples:

Unary * Unary = Unary: $.1*$2
Unary * Unary = Decimal: $.($.1*$2)
Decimal * Unary = Unary: $1*$2
Decimal * Unary = Decimal: $.($1*$2)
Decimal * Decimal = Unary: $1*$2*_
Decimal * Decimal = Decimal: $.($1*$2*) (see below)

A Retina replacement string to take the cube of a matched decimal number would be $.(*** (see below).
Further savings

Only the first non-negative integer contained in the the LHS of a * operator is significant; there is no limit on junk characters (including -s). In particular this makes it easier to use $&.
If the LHS of a * is indeed $&, then it is not necessary at the start of a $( construct or replacement string or after another *. Example: $.(*__)
The _ after a * is not necessary at the end of a $( construct or replacement string. Example: $.($1*_$2*)
It is not necessary to close your $( constructs if they end at the end of the replacement string. Example: $.($1$2
When adding the constant values 1 or 2 it is shorter to express them in unary.

(remark: there are some answers to divide two numbers in retina under the corresponding challenge. https://codegolf.stackexchange.com/questions/114719/divide-one-number-by-another#comment279775_114719)

@user202729 This tip is about the new opportunities to perform decimal-based arithmetic possible in Retina 1, which don't apply to division.

Using balancing groups to capture the same count twice.
Occasionally you need to capture a balancing group twice, such as to match the substring nice when the letters are equally spaced in the input. The naive approach is to capture the characters between n and i twice, and then use balancing groups to ensure that the same number of character exist between i and c and c and e, like this:
n((.))*i(?<-1>.)*(?(1)^)c(?<-2>.)*(?(2)^)e

However, you can capture into capture group 2 while popping from capture group 1, allowing you to then pop the same count from capture group 2 later, saving a byte:
n(.)*i(?<2-1>.)*(?(1)^)c(?<-2>.)*(?(2)^)e

(Normally you would use (?!) to force the match to fail if the count is too low but obviously in code golf we just use the shortest regex that we know will fail; ^ usually works.)

Actualising a transliteration pattern in Retina 0.8.2
In Retina 1, it's easy to produce the contents of a transliteration pattern, here the 64 characters used by MIME Base-64:

    64*
    Y`\_`Lld+/

Try it online! Explanation: The first stage inserts 64 _s, and the second stage cyclically transliterates _s to the 64 base 64 characters in turn. You can also cyclically extend the string should you want, say, 10 copies of each of the digits; just cyclically translate 100 _s into digits.
But it turns out not to be that difficult in Retina 0.8.2. Here is the required program:
T`Lld+/`_o
}`$
/

Try it online! Explanation: Each pass through the loop, the characters in the string get transliterated through the contents of the pattern, with the first character of the pattern being deleted, and a new copy of the last character is appended.
The loop becomes idempotent when the buffer equals the contents of the pattern, as then the deletion of the first character and the append of the last character is balanced by the transliteration of the intervening characters.
You can generate a prefix of a pattern by using the appropriate ending character in the append stage.
The code as shown is designed to be used to produce input as part of a larger program, which is why it does not begin with a loop block; it would need an extra { if it was embedded within a larger program. If the code actually appears at the end, or it is the desired program, then you can go on to remove the trailing loop block instead, saving a byte.
Note that when embedded within a larger program the code will normally delete any other copies of the output pattern present within the work buffer while appending a copy of the output pattern. You may be able to avoid the deletion by use of a suitable pattern to restrict the scope of the transliteration. It is also possible to adapt the code to prefix rather than append the desired output.


text:
Help recalculate your rep!
A couple months ago, we had a discussion on meta about increasing the reputation awarded for upvotes on questions. Here's the basics of our current reputation system for votes:1

A question upvote U is worth 5 reputation.
An answer upvote u is worth 10 reputation.
A question or answer downvote d is worth -2 reputation.

There have been many different suggestions for a new system, but the current most popular is identical to the above, but with question upvotes scaled to +10 rep. This challenge is about calculating how much more rep you would earn if this system were put into place.
Let's look at an example. If the voting activity was UUUUuuuuUUUUUduuudUU, then you'd earn 121 under the current system:
U x 4 x  5 =  20 =  20
u x 4 x 10 =  40 =  60
U x 5 x  5 =  25 =  85
d x 1 x -2 =  -2 =  83
u x 3 x 10 =  30 = 113
d x 1 x -2 =  -2 = 111
U x 2 x  5 =  10 = 121
Total:             121

But the same activity would earn 176 under the new system:
U x 4 x 10 =  40 =  40
u x 4 x 10 =  40 =  80
U x 5 x 10 =  50 = 130
d x 1 x -2 =  -2 = 128
u x 3 x 10 =  30 = 158
d x 1 x -2 =  -2 = 156
U x 2 x 10 =  20 = 176
Total:             176

You would gain 55 rep from this scenario.
So far, calculating the changed rep isn't that hard; just count the number of Us and multiply by 5. Fortunately, the rep system isn't that simple: there is also a rep cap, which is the most reputation you can earn from votes in one UTC day. This is set to 200 on all sites.
Also, the rep cap applies in real time: if you have already earned 196 rep and you receive an answer upvote, you will now have 200 rep. If you get a downvote right after that, the 2 rep will be subtracted from 200, so you will have 198 rep.
With the voting activity UUUuuuuUUUUuuuuUUUUUUUd, you would earn 148 rep under the current system:
U x 3 x  5 =  15 =  15
u x 4 x 10 =  40 =  55
U x 4 x  5 =  20 =  75
u x 4 x 10 =  40 = 115
U x 7 x  5 =  35 = 150
d x 1 x -2 =  -2 = 148
Total:             148

But you would earn 198 under the new system:
U x 3 x 10 =  30 =  30
u x 4 x 10 =  40 =  70
U x 4 x 10 =  40 = 110
u x 4 x 10 =  40 = 150
U x 7 x 10 =  70 = 200 (rep capped)
d x 1 x -2 =  -2 = 198
Total:             198

Thus, the increase is 50 rep.
Challenge
Your challenge is to write a program or function that takes in a multi-line string and outputs the total rep that would be gained with the above algorithm. Each line counts as 1 UTC day, so the rep cap only applies once per line.
Test cases
(One or more lines of input, followed by the output integer.)
UUUuudd
15

UUUuUUUUuUuuUUUUudUUUUuU
57

UUUuUUUUuUuuUUUUudUUUUuU
UUUuudd
72

uuuuuuu
uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu
uuuuuuuuuuuuuuuuuuuu
UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU
UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU
0

UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU
5

(empty string)
0

UUUuuuuuUUUuuUUUUUUuuuUUUuuUUUUuuuuUUUdddddddUU
4

UUUuuuuuUUUuuUUUUUUuuuUUUuuUUUUuuuuUUUdddddddUU
UuuUUUudUU
UUUUUUUUUuuuuuuUUUUUUuuUUUUUUuuuuuUUUUUUUUuUUUuuuuUUUUuuuUUUuuuuuuUUUUUUUUuuUUUuuUU
UUu
U
d
UU
UUUUUUUUUUUU
119

This is code golf, so shortest code in bytes wins.
Related challenges: Calculate the bounded cumulative sum of a vector, Calculate your stack exchange reputation
1 This is a highly simplified version of the system. You also lose 1 rep for downvoting an answer, and there exist unupvotes, which are weird and follow rules of their own; and undownvotes, which don't even have rules to follow.

Nice challenge. Too bad it's not likely to happen...

¹ You don't lose rep for downvoting questions; just answers. Trust me :P

@Mego Possible, but I see the following differences: A) The full cumulative array isn't needed, just the last term. B) There is no lower bound, and the upper bound is fixed. C) The input is a string, as opposed to an array of numbers. D) Arbitrary amounts of these strings, separated by newlines, must be each run through separately and summed to get the result.

@ETHproductions All of those except B are I/O differences. The core problem is still the same.

Perl, 104 91 + 2 = 93 bytes
sub f{200*$.>$_[0]?$_[0]:200*$.}for(/./g){$a=/d/?-2:10;$s=f$s+$a;$o=f$o+$a-5*/U/}}{$_=$s-$o

Requires the -p flag:
$ echo UUUuUUUUuUuuUUUUudUUUUuU | perl -p recalc.pl
57
$ echo "UUUuUUUUuUuuUUUUudUUUUuU
UUUuudd" | perl -p recalc.pl
72

Breakdown:
sub f {
  # '$.' contains the line number (1, 2, ... n)
  200*$. > $_[0] ? $_[0] : 200*$.
}
for(/./g){
  $a= /d/ ? -2  : 10;
  $s=f( $s + $a );
  # /U/ returns `1` if true
  $o=f( $o + $a - 5*/U/ )
}
}{ # Eskimo exit while loop (do this after the outer (from -p) iteration)
$_=$s-$o

Haskell, 98 93 bytes
Thanks to BlackCap to golf this further. Now, I think to try lambda in later challenges, now.
x#'U'=x
_#'u'=10
_#'d'=(-2)
a&b=foldl1(\d g->min 200$d+a#g)
g=sum.map(\x->(10&x)-(5&x)).lines

The first 3 lines is the scoring, a&b is is the score, f is the difference and the g is the function sastifying the specification.
Usage:
g"UUUuuuuuUUUuuUUUUUUuuuUUUuuUUUUuuuuUUUdddddddUU" -- 4

You can merge the two last lines and earn 1 byte: g=sum.map(\x->(10&x)-(5&x)).lines
You can also remove the parentheses for another four bytes: g=sum.map(\x->10&x-5&x).lines

And 3 more bytes if you merge the map and the fold: a&b=foldl(\d g->min 200$d+a#g)0b

ES6, 104 bytes
s=>s.split`
`.map(l=>(g=U=>[...l].map(c=>(r+=eval(c))>200?r=200:0,r=0)|r,t+=g(10)-g(5)),u=10,d=-2,t=0)|t

Calculates the before and after rep for each line. My first use of eval!

Lua, 196 Bytes
This program takes a single multi-line argument as input, and print the total difference in rep'
e,f,a=0,0,{u=10,U=10,d=-2}arg[1]:gsub(".-\n",function(s)x=0 y=0 s:gsub("[^\n]",function(c)t=x+a[c]x,t=t>199 and 200 or t,y+a[c]-(c<"V"and 5 or 0)y=t>199 and 200 or t end)e=e+x f=f+y end)print(e-f)

I assumed I am allowed to ask for a trailing new line in the input, if I'm not, here's a 204 Bytes solution that doesn't need it.
e,f,a=0,0,{u=10,U=10,d=-2}(arg[1].."\n"):gsub(".-\n",function(s)x=0 y=0 s:gsub("[^\n]",function(c)t=x+a[c]x,t=t>199 and 200 or t,y+a[c]-(c<"V"and 5 or 0)y=t>199 and 200 or t end)e=e+x f=f+y end)print(e-f)

Ungolfed and explanations
a={u=10,U=10,d=-2}            -- define the table containing the vote values
e,f=0,0                       -- initialize the total sums of rep'

arg[1]:gsub(".-\n",function(s)-- iterate over each line
  x=0                         -- score by the new scoring method for this UTC day
  y=0                         -- score by the old method
  s:gsub("[^\n]",function(c)  -- iterate over each non new-line character
    t=x+a[c]                  -- new score for today
    x=t>199 and 200 or t      -- reduce it to 200 if >=200
                        -- Do the same thing with the old scoring method
    t=y+a[c]-(c<"V"and 5 or 0)-- if c=="U", this question vote gives only 5
    y=t>199 and 200 or t
  end)
  e=e+x f=f+y                 -- sum the scores over multiple days
end)
print(e-f)                    -- output the difference


text:
Tips for Golfing in Vitsy
While there are only a few users of the Vitsy programming language right now, I wish to create a place for tips for golfing in Vitsy.
What general tips do you have for golfing in Vitsy? I'm looking for ideas that can be applied to code golf problems in general that are at least somewhat specific to Vitsy (e.g. "remove NOPs" is not an answer). Please post one tip per answer.
For reference, the online interpreter is here, the esolang page is here, and you can receive answer-per-answer help here.

Do not doubt the power of m
Background: Fm calls the a specified line index in the current Vitsy class. (F is the line index you seek).
The m command (method) has saved me literally hundreds of bytes in the past. Any algorithm that uses repeated steps, or a common character sequence (such as D1M- (floor algorithm)).
This is extremely helpful in repetitive kolmogorov complexity challenges.
Instead of:
WD1M-(something else here)WD1M-(something different)WD1M-l\[NaO]
Use:
1m(something else here)1m(something different)1ml\[NaO]
WD1M-
(floor(prompt))
Also, you can return from method statements with ;, allowing for looping until condition(s) (over the general [  ] syntax, which isn't as powerful):
1mN
<;)
(loops through code until finding non-zero, popping it from the stack and returning to first line)

Since many people here don't know vitsy, perhaps briefly explain what m does?

@Cyoce Yes, sorry. c: Corrected.

Remember that \[] always runs at least once
Even if the top item of the stack is zero or less, \[] always runs. Think of it more as a do{}for(); loop. This has caught me off more than once, but it is important.

Filling Zeroes on an Empty Stack
Normally, to fill up the stack with a number, you would do something like this:
a\a

This fills up the stack with 10 10s, by pushing 10 10 times. However, if you wanted to push 10 0s, you'd do this:
a\0

After a recent update, however, the stack will attempt to fix for IndexOutOfBoundsExceptions by pushing 0s to a possibly empty stack, meaning that, if on an empty stack, you can do:
a%

Since % calls multistack, it tries to access every member between the top item (which is nothing after it pops 10) and the index you specify. Therefore, you get a stack with 10 0s when this is called. You can use this trick up to approximately 11380, although, annoyingly, it doesn't always go to a specific point...
UNKNOWN:Desktop addisonc17$ vitsy --code "2d^2b^+2a^+26^+25^+24^+5+%lNaO"
java.lang.StackOverflowError thrown in [command line] at command #0,25: %
UNKNOWN:Desktop addisonc17$ vitsy --code "2d^2b^+2a^+26^+25^+24^+5+%lNaO"
11381

Past that, you'll have to use the normal duplication method.


text:
Challenge about advacado
Inspired by this. No avocados were harmed in the making of this challenge.
Hello I have challenge I need help juic an avocado so I need program to tell me how long to juic avocad for
Observe this ASCII art avocado:
    ######
   #      #
   # #### #
  #  # p# #
  ## #### #
   #      #
    ######

This avocado consists of an exterior of #s (specifically the first and last sequences of #s on each line) and a pit (a shape of #s in the avocado that does not touch the avocado exterior).
Through rigorous experiments on these ASCII art avocados I have discovered the following:
avocado juice in fluid ounces = number of spaces inside avocado but outside pit (the pit is marked with a p in the example) + 2 * number of spaces inside pit

time to juice avocado in minutes = 13 * number of spaces inside pit

For example, this avocado will take 26 (2 spaces inside pit * 13) minutes to juice and will give 23 (19 spaces inside avocado but outside pit + 2 * 2 spaces inside pit) fl oz of juice.
Challenge
Given an input of exactly one ASCII art avocado such as the one above that consists of only # and whitespace, output the amount of time in minutes it will take to juice it and the amount of juice it will produce in any order.
You may assume that the input avocado will always have exactly one pit and both the avocado and the pit will always be closed. The pit and avocado will always be connected, and any subset of the pit will be connected as well. The avocado and the pit will always be convex. Note that the avocado exterior may be arbitrarily thick.
Sample Inputs and Outputs
    ######
   #      #
   # #### #
  #  #  # # -> 26 23
  ## #### #
   #      #
    ######

   #######
  #       #
  #  ###   ##
  #  #  #   # -> 26 35
  #   ##   #
  #        #
  ##########

This is code-golf, so shortest code in bytes wins.

Possible duplicate of Are you in the biggest room?

@Mego I talked with people in chat and we decided it was sufficiently different due to the avocado pit.

I still think it's a dupe.

@DigitalTrauma Fixed.

Will the avacado always be roundish? Like could it be in a H shape?

@user81655 The avocado will always be closed, so no it could not be in the of an H. It does not have to be round however; it could be a rectangle.

I mean like an outline of a H, U, or some other odd shape which is closed.

@user81655 Oh sorry. Yes it could be like that (as long as a non-empty pit is in it).

@quartata like this?  That invalidates my answer :(

@DigitalTrauma Hmm... handling that kind of shape seems too complicated. I'll edit the challenge.

Still seems quite unclear what the set of valid inputs is.

@randomra Yes, fixed. (I'm not sure why I described it like that....)

time to juice avocado in minutes = 13 * number of spaces inside pit I SEE WHAT YOU DID THERE!

Pyth, 59 51 bytes
*Ksm/.s.s.sd\ \#\ \ fq4l:T"#+"4.z13+-/s.sR\ .zdK*2K

Try it here!
Outputs the time to juic the advacado (totally correct english) first and on the next line the amount of juic.
Explanation
Code - Overview

*Ksm/.s.s.sd\ \#\ \ fq4l:T"#+"4.z13+-/s.sR\ .zdK*2K # .z=list of all input lines

                    fq4l:T"#+"4.z                   # Get the pit-lines
   m/.s.s.sd\ \#\ \                                 # Map the pit-lines to the whitespace amount
 Ks                                                 # Sum the amount of pit-spaces and assign to K
*                                13                 # Print the juic time
                                     /s.sR\ .zd     # Count all whitespaces in the advacado
                                    -          K    # Subtract the pit size from it
                                   +            *2K # Do the Rest of the amount calcluation and print it

Detailed explanations of the size calculation parts see below.
Getting the advacado size
Let's look at this one:

    ######
   #      #
   # #### #
  #  #  # #
  ## #### #
   #      #
    ######

First the leading and trailing whitespaces get removed. After that we wrap everything in one line, which results in this string:
#######      ## #### ##  #  # ### #### ##      #######

This contains all whitespaces in the advacado, so we just have to count them (the advacado will always be convex, so this works for all valid inputs). This number still contains the spaces in the pit, but for the juic amount calculation we only need the spaces in the fruit without the pit-spaces. So we need to calculate them too.
The code for that explained in detail:

/s.sR\ .zd   # .z=list of all input lines

  .sR\ .z    # strip spaces from every input line
 s           # Concatenate all lines
/        d   # Count all spaces

Getting the pit size
This is a bit trickier. First we remove the lines which don't contribute to the pit size. This is done by filtering out all lines that have less than 4 groups of hashes (using the regex #+ and counting its matches). In the example above only one line will survive this process:
  #  #--# #

The spaces I marked with a - here are the ones we need to count. So we just strip spaces, then hashes and then spaces again which leaves us with this:
#  #

There we just have to count the spaces. We do all that for every line which survived the filtering process, sum everything and we are done. The rest is trivial math.
The code for that explained in detail:

sm/.s.s.sd\ \#\ \ fq4l:T"#+"4.z   # .z=list of all input lines

                  f          .z   # filter the input
                     l:T"#+"4     # length of the matches for the regex `#+`
                   q4             # if there are 4 groups of hashes its a pit line
 m                                # map the pit lines to...
  /             \                 # The occurences of spaces in..
   .s.s.sd\ \#\                   # ...the stripped pit line (see explanation above)
s                                 # Sum all amounts of spaces in the pits

Retina, 70

25 bytes saved thanks to @FryAmTheEggman and @randomra

T` `i`(?<=# +#+) *(?=#+ +#)
T` `f`# +#
i
13$*iff
((i)|(f)|\W)+
$#2 $#3

Try it online.

Dunno if it'll help but I got 90 bytes using $*... still feels really golfable though...

@FryAmTheEggman Ohh, you can use literals with $*_? That's nice. I managed to get 70 bytes.

@randomra yeah, it will actually use any "token", and very nice! I had tried to come up with a similar scheme, but I kept getting stuck with having to do additional parsing, reusing f is very clever! It's too bad though that the right "argument" of $* can only be a character and not a token... maybe another kind of replacement for the future? :0

@randomra very cool - thanks!

Python, 141 119 bytes
import sys
s=str.strip;l=len;o=i=0
for x in sys.stdin:x=s(s(x),'#');y=s(x);o+=l(x)-l(y);i+=l(s(y,'#'))
print o+2*i,13*i

Welcome to Programming Puzzles & Code Golf! If you define s with s=str.strip, the loop body can become x=s(s(x),'#');y=s(x);o+=l(x)-l(y);i+=l(s(y,'#')). Also, there's a non-functional space on the last line.

ahh i didn't even know you could do that, thanks :)

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