text:
Calculating waves
I've been scrolling around this site for a while, but just recently got really interested in actually trying out some of the challenges. I was intending to try my hand at some of the existing code-golf topics, but I didn't have Internet access for a while yesterday, and in the meantime, I thought up my own challenge.
Your task is to create a program or function that takes an array of Floats a and an integer n, then sets each value in a to the average of the two beside it, n times. When repeatedly used with increasing values of n, this generates a wave-like motion:

Specifics:

If there happens to be only one item in a, or if n is 0 or less, the program should return the original array.
Inputs and outputs can be in any format you desire, as long as they are visibly separated.

For each step:

The first item in a should become the average of itself and the next item.
The last item in a should become the average of itself and the previous item.
Any other item in a should become the average of the previous item and the next item.
Make sure you are calculating off the previous step's array and not the current one!

Test cases: NOTE: Your inputs/outputs do not have to be in this format!
[0, 0, 1, 0, 0], 1          -> [0, 0.5, 0, 0.5, 0]
[0, 0, 1, 0, 0], 2          -> [0.25, 0, 0.5, 0, 0.25]
[0, 0, 1, 0, 0], 0          -> [0, 0, 1, 0, 0]
[0, 0, 1, 0, 0], -39        -> [0, 0, 1, 0, 0]
[0, 16, 32, 16, 0], 1       -> [8, 16, 16, 16, 8]
[0, 1, 2, 3, 4, 5], 1       -> [0.5, 1, 2, 3, 4, 4.5]
[0, 64], 1                  -> [32, 32]
[0], 482                    -> [0]
[32, 32, 32, 16, 64, 16, 32, 32, 32], 4 -> [33, 27, 40, 22, 44, 22, 40, 27, 33]

This is code-golf, so shortest answer in bytes wins. The winner will be chosen in one week (on August 1). Good luck!
Edit: Congrats to the winner, @issacg, with a whopping 18 bytes!

My advice to improving this challenge is to get rid of the n is not supplied and a is not supplied cases - they don't really add much.

I believe the final test case is incorrect. n should be 4, not 5.

@isaacg: Yeah, now that I look at it again, those cases don't seem that important. I've changed that, and fixed the incorrect example as well. Thanks for pointing those things out!

If you really want it to handle empty lists, you may want to add it to the list of test cases. I just noticed that my solution fails for that case. Personally, I'm not a big fan of problems where a large part of the solution is for handling special cases.

@RetoKoradi Sorry, I had forgotten to remove the "empty list" case from the rules when I removed it from the examples. Thanks for the notice!

Pyth, 46 18 bytes
ucR2sV+hGGt+GeG.*Q

This code expects input in the form iterations, [wave1, wave2, wave3 ...], as seen at the first link below.
Demonstration. Test Harness.
The program works by applying the code within the reduce (u) function to the input list, as many times as the number of iterations.
I will demonstrate the wave propagation function on the list [0, 1, 2, 3, 4, 5], which is in G:
+hGG prepends G's first element to G, forming [0, 0, 1, 2, 3, 4, 5].
t+GeG appends G's last element to G and removes its first element, forming [1, 2, 3, 4, 5, 5].
sV first forms pairs from the lists, giving [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 5]] with the final element of the first list truncated away. Then, the pairs are summed via the s function, giving [1, 2, 4, 6, 8, 9].
cR2 uses floating point division to divide all of the numbers by 2, giving the desired result, [0.5, 1.0, 2.0, 3.0, 4.0, 4.5].

Snowman 1.0.0, 219 chars
{vg" "aS:10sB;aM0aa,AAg**-:|al|'NdE'0nRal@(%}{->:1*?{0AaG;:?{;bI:dUNiNwR'NdEwRaC;aM(~:?{(()1wR]0wRaC*))#'wRaC|*#|(()#aLNdEdUNdEwR]wR]aCwR*))#aC;:0wRdUaCwR*?{#aC;#bI:*#0aA'|aa|'!*+'(()#1aA*))#|,aa|'*`nA2nD;aM|*0*;bR|tSsP

With linebreaks for "readability":
{vg" "aS:10sB;aM0aa,AAg**-:|al|'NdE'0nRal@(%}{->:1*?{0AaG;:?{;bI:dUNiNwR'NdEwRaC;
aM(~:?{(()1wR]0wRaC*))#'wRaC|*#|(()#aLNdEdUNdEwR]wR]aCwR*))#aC;:0wRdUaCwR*?{#aC;#
bI:*#0aA'|aa|'!*+'(()#1aA*))#|,aa|'*`nA2nD;aM|*0*;bR|tSsP

Ungolfed / unminified version:
{vg" "aS:10sB;aM  // input space-separated list of numbers
0aa,AAg           // get first element and array of all-but-first elements
**                // discard original input and the 0

// execute the following (input[0]) times
-:
    |al|'NdE'0nR               // get range from (0..input.length-1]
    al@(%}{->:1*?{0AaG;:?{;bI  // chop off first element if any
    :dUNiNwR'NdEwRaC;aM        // map n -> [n-1 n+1]
    // if the input consisted of a single element, append [0 0]
    // otherwise prepend [0 1] and append [len-2 len-1]
    (~:?{(()1wR]0wRaC*))#'wRaC|*#|(()#aLNdEdUNdEwR]wR]aCwR*))#aC;
        :0wRdUaCwR*?{#aC;#bI
    // map indeces to avg(input[i1], input[i2])
    :*#0aA'|aa|'!*+'(()#1aA*))#|,aa|'*`nA2nD;aM
    // replace old input, reset permavar
    |*0*
;bR

|tSsP  // output result

Sample I/O format:
llama@llama:...Code/snowman/ppcg53799waves$ snowman waves.snowman
4 32 32 32 16 64 16 32 32 32
[33 27 40 22 44 22 40 27 33]

This is horribly beautiful.

Pyth - 25 24 bytes
Uses enumerate, reduce to do iterations.
u.ecs@L++hGGeG,khhk2GvzQ

Try it online here.

Racket, 164 145 bytes
(define(f a n)(if(< n 1)a(f(let([l(length a)][r list-ref])(for/list([i(in-range l)])(/(+(r a(max(- i 1)0))(r a(min(+ i 1)(- l 1))))2)))(- n 1))))

Ungolfed
(define (f a n)
  (if (< n 1)
      a
      (f (let ([l (length a)] [r list-ref])
           (for/list ([i (in-range l)])
             (/ (+ (r a (max (- i 1) 0))
                   (r a (min (+ i 1) (- l 1))))
                2))) (- n 1))))

Note, you may need the #lang racket line to run this.

R, 109 bytes
function(x,n){l=length(x);t=if(l>2)c(.5,0,.5)else if(l==2)c(.5,.5)else 1;for(i in 1:n)x=filter(x,t,c=T);c(x)}

This creates an unnamed function that accepts a vector and an integer and returns a vector. The approach here is to treat the input as a univariate time series and apply a linear convolution filter.
Ungolfed + explanation:
f <- function(x, n) {
    # Define filter coefficients
    t <- if (length(x) > 2)
        c(0.5, 0, 0.5)
    else if (length(x) == 2)
        c(0.5, 0.5)
    else
        1

    # Apply the filter n times
    for (i in 1:n) {
        # The circular option wraps the filter around the edges
        # of the series, otherwise the ends would be set to NA.
        x <- filter(x, t, circular = TRUE)
    }

    # Returned the modified input, stripped of the extraneous
    # properties that the filter function adds.
    c(x)
}

Examples:
> f(c(32, 32, 32, 16, 64, 16, 32, 32, 32), 4)
[1] 33 27 40 22 44 22 40 27 33

> f(0, 482)
[1] 0

> f(c(0, 64), 1)
[1] 32 32

Haskell, 76 characters
The trick is to add the first number to the beginning of the list and the last one to the end of the list instead of dealing with the boundary conditions.
f a@(x:s)=(/2)<$>zipWith(+)(x:a)(s++[last s])
f x=x
a#n|n<1=a|n>0=f a#(n-1)

Tests:
λ: [0, 0, 1, 0, 0]#1
[0.0,0.5,0.0,0.5,0.0]
λ: [0, 0, 1, 0, 0]#2
[0.25,0.0,0.5,0.0,0.25]
λ: [0, 0, 1, 0, 0]#0
[0.0,0.0,1.0,0.0,0.0]
λ: [0, 0, 1, 0, 0]#(-39)
[0.0,0.0,1.0,0.0,0.0]
λ: [0, 16, 32, 16, 0]#1
[8.0,16.0,16.0,16.0,8.0]
λ: [0, 1, 2, 3, 4, 5]#1
[0.5,1.0,2.0,3.0,4.0,4.5]
λ: [0, 64]#1
[32.0,32.0]
λ: [0]#482
[0.0]
λ: [32, 32, 32, 16, 64, 16, 32, 32, 32]#4
[33.0,27.0,40.0,22.0,44.0,22.0,40.0,27.0,33.0]

You can save a few bytes by using infix operators for 2-argument functions and guards instead of if then else, i.e. c becomes a#n|n<1=a|1<2=iterate f a!!n and s becomes x!y=(x+y)/2 (and is called ...zipWith(!)(x:a)...).

Thanks! Didn't know how guards work in one-line expressions.

Another 2 bytes: make c an infix operator, say #: a#n|n<1=a|1<2=iterate f a!!n. Call it like [0, 0, 1, 0, 0] # 2.

Java, 181 bytes
Here's the golfed version:
float[]g(float[]i,int n){float[]c=i.clone();int l=c.length,s=1;if(n>0&&l>1){c[0]=(i[0]+i[1])/2f;c[--l]=(i[l]+i[l-1])/2f;while(s<l)c[s]=(i[s-1]+i[++s])/2f;return g(c,n-1);}return i;}

Ungolfed:
float[] g(float[] i, int n) {
    float[] c = i.clone();
    int l = c.length,s=1;
    if(n>0&&l>1) {
        c[0] = (i[0]+i[1])/2f;
        c[--l] = (i[l]+i[l-1])/2f;
        while(s<l)
            c[s] = (i[s-1] + i[++s]) / 2f;
        return g(c, n-1);
    }
    return i;
}

I tried to shorten assignments and conditionals as much as possible with Java. Improvements are welcome, of course.

JavaScript (ES6), 153 132 67 chars
I come back to my first answer 6 months later and what do I do? Golf off 50%, that's what. ;)
s=(a,n)=>n<1?a:s(a.map((j,i)=>(a[i&&i-1]+a[a[i+1]+1?i+1:i])/2),n-1)

This version calls itself repeatedly until n is less than 1, decrementing n by 1 each time.
A non-recursive solution (151 130 78 chars):
(a,n)=>n<1?a:eval("while(n--)a=a.map((j,i)=>(a[i&&i-1]+a[a[i+1]+1?i+1:i])/2)")

Ungolfed: (outdated)
Recursive:
s = function (a, n) {
  if (n < 1)
    return a;
  b = [];
  l = a.length;
  x = y = 0;
  for(var i = 0; i < l; i++) {
    x = a[(i < 1) ? 0 : i-1];
    y = a[(i > l-2) ? i : i+1];
    b[i] = (x + y)/2;
  }
  if (n > 2)
    return b;
  return s(b,n-1);
}

Non-recursive:
s = function (a, n) {
  if (n < 1)
    return a;
  b = [];
  l = a.length;
  x = y = 0;
  while(n-- > 0) {
    for(var i = 0; i < l; i++) {
      x = a[(i < 1) ? 0 : i-1];
      y = a[(i > l-2) ? i : i+1];
      b[i] = (x + y)/2;
      a = b.slice(0);   // setting a to a copy of b, for copyright reasons
    }
  return b;
}

if(n<2)return b;return s(b,n-1) could be reduced to return n<2?b:s(b,n-1)

@Cyoce Thanks, I've taken that into account, and then some...

CJam, 23 22 bytes
q~{_(@)@@+@@+.+.5f*}*`

Try it online
The input is in CJam list format, e.g. for the last example:
[32 32 32 16 64 16 32 32 32] 4

The output is also a CJam list:
[33.0 27.0 40.0 22.0 44.0 22.0 40.0 27.0 33.0]

The basic approach is that in each step, the vector is shifted one position to the left and one position to the right. Each of the two vectors is padded with the first/last element, and then the average of the two vectors is calculated.
Explanation:
q~    Get and interpret input.
{     Loop over repeat count.
  _     Copy list.
  (     Pop off left element.
  @     Get original list to top.
  )     Pop off right element.
  @@    Get first element and list with last element removed to top.
  +     Concatenate. This gives right-shifted list with first element repeated.
  @@    Get list with first element removed and last element to top.
  +     Concatenate. This gives left-shifted list with last element repeated.
  .+    Perform vector addition of two shifted lists.
  .5f*  Multiply sum by 0.5 to give average.
}*    End loop over repeat count.
`     Convert result array to string.

I'm not the OP, but "If there happens to be zero or one items in a, or if n is 0 or less, the program should return the original array.
"

Python 2, 98 Bytes
Took the straightforward approach, used exec to get out of using a while loop. I think there's a better way of doing the logic to figure out special case positions, but this works for now. Input should be formatted like [list], times.
b,c=input()
k=~-len(b)
exec'b=[(b[x-(0<x<k)]+b[x+(x<k)-(x==k)])/2.for x in range(-~k)];'*c
print b

Ungolfed:
BASE,TIME = input()
TEMP = [0]*len(BASE)                               # Temporary array as to not modify base.
while TIME:
    for x in xrange(len(BASE)):
        if x == 0:
            TEMP[x] = (BASE[x]   + BASE[x+1])/2.0  # First element special case.
        elif x == len(BASE)-1:
            TEMP[x] = (BASE[x]   + BASE[x-1])/2.0  # Last element special case.
        else:
            TEMP[x] = (BASE[x-1] + BASE[x+1])/2.0  # Every other element.
    BASE = TEMP                                    # Set base to temporary array.
    TEMP = [0]*len(BASE)                           # Reset temporary array to 0s.
    TIME = TIME - 1
print BASE

Java, 203 bytes
Trying my first put with Java.  Improvement tips are welcome:)
double[]f(double[]a,int n){int j,s,i=0;s=a.length-1;if(n<1||s<1)return a;double b[]=a;for(;i++<n;a=b.clone()){b[0]=.5*(a[0]+a[1]);b[s]=.5*(a[s]+a[s-1]);for(j=1;j<s;++j)b[j]=.5*(a[j-1]+a[j+1]);}return b;}

Pretty printed:
double[] g(double[] a, int n) {
  int j, s, i = 0;
  s = a.length - 1;
  if (n < 1 || s < 1)
     return a;
  double b[] = a;
  for (; i++ < n; a = b.clone()) {
     b[0] = .5 * (a[0] + a[1]);
     b[s] = .5 * (a[s] + a[s - 1]);
     for (j = 1; j < s; ++j)
        b[j] = .5 * (a[j - 1] + a[j + 1]);
  }
  return b;
}

Welcome to PPCG! I don't golf much in Java, but can you move the three assignments inside the outer for loop into the loop's increment statement? Like for(i=0;i<n;b[0]=...,b[s-1]=...,a=...,++i)for(...)b[j]=...;? Then you should be able to get rid of the braces.

Unfortunately they have to be repeated on each iteration, so they have to stay inside the braces.

The increment is also repeated each iteration, which is why you'd put them in the third slot (separated from the ++i and each other with commas instead of semicolons). Try it out. :)

I see where you're going, but I'm losing the update in the final iteration (unless there's a trick I don't know).  Still, able to shave a few bytes here and there by doing "ugly things":)

I don't think you are losing the update on the final iteration. f(a;b;c){d;e;} should be completely identical to f{a;b;}{d;e;c;}, and therefore also to f(a;b;e,c)d;. However, with your rearranged code that no longer works, because you can't move the for inside the other for, so I guess all of this no longer matters. ;)

Maybe I am wrong but int j,s,i=0;s=a.length-1; is the same as int j,s=a.length-1,i=0; except a bit shorter?  And could if (n < 1 || s < 1) return a; double b[] = a; be replaced by double b[] = a; if (n < 1 || s < 1) making the entire for conditional and using the return b; at the end instead?

Any particular reason you need to use doubles? float is one shorter.

Mathematica, 81 bytes
I have a feeling it could be golfed more if I could figure out a better way to handle the positivity condition.
f[l_,_]:=l;f[l_,n_/;n>0]:=Nest[.5{1,0,1}~ListConvolve~ArrayPad[#,1,"Fixed"]&,l,n]

Worth noting: Mathematica offers lots of potential built-in solutions in its range of list-processing and filter functions, as well as CellularAutomaton. I chose Nest[... ListConvolve ...] because it was the easiest way to work out the kinks at the ends of the list, but other angles might prove shorter.

Matlab , 109
function a=f(a,n)
if numel(a)>1&n>0
for k=1:n
a=[a(1)+a(2) conv(a,[1 0 1],'valid') a(end-1)+a(end)]/2;end
end

Examples:
>> f([0, 0, 1, 0, 0], 1)
ans =
         0    0.5000         0    0.5000         0

>> f([0, 0, 1, 0, 0], 2)
ans =
    0.2500         0    0.5000         0    0.2500

>> f([0, 0, 1, 0, 0], 0)
ans =
     0     0     1     0     0

>> f([0, 0, 1, 0, 0], -39)
ans =
     0     0     1     0     0

>> f([0], 482)
ans =
     0

>> f([], 10)
ans =
     []

Scala, 195 characters (186 with lazy output, i.e. Stream) 187 characters
(t:Seq[Float],n:Int)⇒t.size match{case 0|1⇒t;case 2⇒{val a=t.sum/2;Seq(a,a)};case i⇒(t/:(1 to n)){(s,_)⇒(s.take(2).sum/2)+:s.sliding(3).map(l=>(l(0)+l(2))/2).toList:+(s.drop(i-2).sum/2)}}

probably not optimal, mapping sliding(3) is very useful in this case.
tests:
scala> (t:Seq[Float],n:Int)⇒t.size match{case 0|1⇒t;case 2⇒{val a=t.sum/2;Seq(a,a)};case i⇒(t/:(1 to n)){(s,_)⇒(s.take(2).sum/2)+:s.sliding(3).map(l=>(l(0)+l(2))/2).toList:+(s.drop(i-2).sum/2)}}
res0: (Seq[Float], Int) => List[Float] = <function2>

scala> res0(Seq(0, 0, 1, 0, 0), 1)
res1: Seq[Float] = List(0.0, 0.5, 0.0, 0.5, 0.0)

scala> res0(Seq(0, 0, 1, 0, 0), 2)
res2: Seq[Float] = List(0.25, 0.0, 0.5, 0.0, 0.25)

scala> res0(Seq(0, 0, 1, 0, 0), 0)
res3: Seq[Float] = List(0.0, 0.0, 1.0, 0.0, 0.0)

scala> res0(Seq(0, 0, 1, 0, 0), -39)
res4: Seq[Float] = List(0.0, 0.0, 1.0, 0.0, 0.0)

scala> res0(Seq(0, 16, 32, 16, 0), 1)
res5: Seq[Float] = List(8.0, 16.0, 16.0, 16.0, 8.0)

scala> res0(Seq(1, 2, 3, 4, 5), 1)
res6: Seq[Float] = List(1.5, 2.0, 3.0, 4.0, 4.5)

scala> res0(Seq(0,64), 1)
res7: Seq[Float] = List(32.0, 32.0)

scala> res0(Seq(0), 482)
res8: Seq[Float] = List(0.0)

scala> res0(Seq(32, 32, 32, 16, 64, 16, 32, 32, 32), 4)
res9: Seq[Float] = List(33.0, 27.0, 40.0, 22.0, 44.0, 22.0, 40.0, 27.0, 33.0)

q (27 characters)
{avg x^/:1 -1 xprev\:x}/[;]

Examples
q)f:{avg x^/:1 -1 xprev\:x}/[;]
q)f[4;32 32 32 16 64 16 32 32 32]
33 27 40 22 44 22 40 27 33f
//1-length input
q)f[10;enlist 1]
,1f
//0-length input
q)f[10;`float$()]
`float$()

R, 93 Bytes
As an unnamed function
function(a,n){l=length(a);while((n=n-1)>=0)a<-colMeans(rbind(c(a[-1],a[l]),c(a[1],a[-l])));a}

Expanded
function(a,n){
    l=length(a);             # get the length of the vector
    while((n=n-1)>=0)        # repeat n times
        a<-colMeans(         # do the column means and assign to a
          rbind(             # create an array
            c(a[-1],a[l]),   # shift the vector left and duplicate last
            c(a[1],a[-l])    # shift the vector right and duplicate first
          )
        );
    a                        # return the vector
}

Tests
> f=function(a,n){l=length(a);while((n=n-1)>=0)a<-colMeans(rbind(c(a[-1],a[l]),c(a[1],a[-l])));a}
> f(c(0, 0, 1, 0, 0), 1)
[1] 0.0 0.5 0.0 0.5 0.0
> f(c(0, 0, 1, 0, 0), 2)
[1] 0.25 0.00 0.50 0.00 0.25
> f(c(0, 0, 1, 0, 0), 0)
[1] 0 0 1 0 0
> f(c(0, 0, 1, 0, 0), -39)
[1] 0 0 1 0 0
> f(c(0, 16, 32, 16, 0), 1)
[1]  8 16 16 16  8
> f(c(0, 1, 2, 3, 4, 5), 1)
[1] 0.5 1.0 2.0 3.0 4.0 4.5
> f(c(0, 64), 1)
[1] 32 32
> f(c(0), 482)
[1] 0
> f(c(32, 32, 32, 16, 64, 16, 32, 32, 32),4)
[1] 33 27 40 22 44 22 40 27 33
>

Japt, 39 37 bytes
I just wanted to see how well my golfing language could hold up to my first challenge.
Vm0 o r_£ZgY©Y-1 +ZgY>Zl -2?Y:°Y)/2}U

Try it online!
Vm0 o r_£ZgY©Y-1 +ZgY>Zl -2?Y:°Y)/2}U
Vm0 o      // Generate the range of integers [0, max(V,0)).
r_     }U  // Reduce it with this function, with a starting value of U:
£          //  Return the argument, with each item X, index Y, and the full array Z mapped by this function:
ZgY©Y-1 +  //   Return (Z[max(Y-1,0)] plus
ZgY>Zl -2? //    Z[Y > Z.length-2?
Y:°Y)      //      Y:--Y],)
/2         //   divided by two.
           // Implicit: output last expression

C++14, 158 bytes
#define D(a,b)d[i]=(c[a]+c[b])/2;
auto f(auto c,int n){while(n-->0&&c.size()>1){auto d{c};int i{};D(0,1)while(++i<c.size()-1)D(i-1,i+1)D(i,i-1)c=d;}return c;}

Requires input to be a container value_type==double, like vector<double>.
Ungolfed:
#define D(a,b) d[i] = (c[a]+c[b])/2;   //average
auto f(auto c, int n) {
  while(n-- > 0 && c.size() > 1) {     //breaks
    auto d{c};                         //copy container
    int i{};
    D(0,1)                             //left
    while(++i < c.size()-1)            //count up to right
      D(i-1,i+1)                       //interior
    D(i,i-1)                           //right
    c=d;                               //overwrite container
  }
  return c;
}

Racket 223 bytes
(let p((l l)(m 0)(g list-ref))(cond[(> n m)(let*((j(length l))(k(for/list((i j))(cond[(= i 0)(/(+(g l 0)(g l 1))2)]
[(= i(- j 1))(/(+(g l(- j 2))(g l(- j 1)))2)][else(/(+(g l(+ i 1))(g l(- i 1)))2)]))))(p k(+ 1 m) g))][l]))

Ungolfed:
(define(f l n)
  (let loop ((l l)
             (m 0)
             (lr list-ref))
    (cond
      [(> n m)
       (let* ((j (length l))
              (k (for/list ((i j))
                   (cond
                     [(= i 0)       (/ (+ (lr l 0)
                                          (lr l 1))
                                       2)]
                     [(= i (- j 1)) (/ (+ (lr l (- j 2))
                                          (lr l (- j 1)))
                                        2)]
                     [else          (/ (+ (lr l (+ i 1))
                                          (lr l (- i 1)))
                                       2)])
                   )))
         (loop k
               (+ 1 m)
               lr))]
      [else l]
      )))

Testing:
(f '[32 32 32 16 64 16 32 32 32] 4)

Output:
'(33 27 40 22 44 22 40 27 33)

Jelly, 14 bytes
.ịṚjṡ3 .ịⱮÆmµ¡

Try it online!
Full program.

C# (Visual C# Interactive Compiler), 160 144 bytes
float[]a(float[]b,int c)=>c>0&b.Length>1?a(b.Select((_,w)=>w<1?(b[w]+b[w+1])/2:w>b.Length-2?(b[w]+b[w-1])/2:(b[w-1]+b[w+1])/2).ToArray(),c-1):b;

Uses good ol' recursion.
Try it online!

136 bytes


text:
Enter your name via a D-pad
The puzzle:
Consider a console/hand-held game with a d-pad where you are required to enter a name of sorts. This appeared in many older games before the use of QWERTY was popularised in consoles (e.g. I believe the Wii uses a QWERTY keyboard layout for input). Typically, the on-screen keyboard looks to the effect of*:
Default:
0 1 2 3 4 5 6 7 8 9
A B C D E F G H I J
K L M N O P Q R S T
U V W X Y Z _ + ^ =

With the case switched:
0 1 2 3 4 5 6 7 8 9
a b c d e f g h i j
k l m n o p q r s t
u v w x y z - + ^ =

That is, all alphanumeric keys and the following:
_: A single space
-: A hyphen
+: Switch case for the next letter only
^: Toggle caps lock (that is, switch the case of all letters)
=: Enter, complete
*Obviously I replaced keys like "BKSP" and "ENTER" with shorter versions
And then the hardware would include a d-pad (or some form of control where you could go up, down, left and right)
The screen also typically let you move from one side directly to the other. That is, if you were focussed on the letter J, pressing right would allow you to move to the letter A.
Whenever I was entering my name, I'd always try to work out the quickest way to do so.
Goal:
Your program will take string input which may include any alphanumeric character including a space and hyphen, and your goal is to output the shortest amount of key presses on the d-pad to output the required string.
Considerations:
You do not need to include the key pressed for pressing the actual character.
Focus always starts at the A
Enter = must be pressed at the end
Example:
input: Code Golf
output: 43
Explained:
A -> C = 2
C -> ^ = 6 (moving to the left)
^ -> o = 5
o -> d = 2
d -> e = 1
e -> + = 5
+ -> _ = 1
_ -> + = 1
+ -> G = 3
G -> o = 3
o -> l = 3
l -> f = 5
f -> = = 6
Note that it is quicker to hit the + twice for a _ and a G than it is to hit ^ once, then swap back.
The winning submission (I'll allow at least 1w) will be the shortest solution (in bytes). As this is my first question, I hope this is clear and not too hard.

Nice challenge! Just one point, 48 hours is probably too little. That's how long it takes for bounties to be allowed, so it should be more around a week+.

@Maltysen thanks for the suggestion, I've updated the challenge

Can you wrap vertically, too, or just horizontally?

@AlexReinking that's a great point! Yes you can.

Great! My implementation does that, so I just wanted to double-check.

For those testing the hyphen: A-Z is 11

Sorry, but why did the bounty go to the Swift submission? Mine was 300 bytes shorter.

The problem of "finding the shortest path" is a good candidate for being solved with state space search, eg "A Star search" algorithm. Hipster4j is a great Java library for this.

Does + really switch the case for the next letter, even if you’re in Caps Lock mode? So I could type “STEvEN” by going “STE+vEN”?

@Timwi AFAIK that is correct.

Ruby (369 bytes)
Takes input from command line.
K="0123456789"+('A'..'Z').to_a.join+" +^="
Q=K.downcase.sub' ','-'
def d x,y
t,s=(x/10-y/10).abs,(x%10-y%10).abs
[t,4-t].min+[s,10-s].min
end
def v s,i,l,a
return l if s.empty?
c,r=s[0],s[1..-1]
j=K.index(c.upcase)||36
return v(r,j,l+d(i,j),a)if a.include?c
s,p=d(i,37)+d(37,j),d(i,38)+d(38,j)
[v(r,j,l+s,a),v(r,j,l+p,a==K ? Q : K)].min
end
puts v("#{ARGV[0]}=",10,0,K)

Saved a bunch of bytes thanks to @Charlie :)

j=(K.index(c.upcase) or 36) can be replaced with j=K.index(c.upcase)||36 to save 4 bytes.
def d(x,y) can replaced with def d x,y to save a byte, and same goes for def v.
v(...) if to v(...)if for another byte.
On the last line, v(...) can be replaced with v ... to save 1 byte, and true with !!0 to save another byte.

Thanks! I don't really know Ruby. I translated this from python...

I can also replace && with & and || with |.

Your first line (K=...) can be replaced with a range (K='0123456789'+('A'..'Z').to_a.join+' +^=')

Shaves another 2 off!

Swift 1.2, 812 588 670 bytes
Edit: Removed 224 bytes by replacing the large arrays of numbers with a Range and converting it to an Array instead.
Edit2: Added looping vertically
typealias S=String
typealias I=Int
var A:(I)->S={S(UnicodeScalar($0))},B:(I)->(I,I)={a in(a%10,a/10)},a=Array(48...57).map{A($0)},b=[a+(Array(65...90)+[32,43,94,61]).map{A($0)},a+(Array(97...122)+[45,43,94,61]).map{A($0)}],z=Process.arguments
z.removeAtIndex(0)
func C(e:I,f:I)->I{let(a,b)=B(e),(c,d)=B(f)
return min(abs(d-b), abs(4-(d-b)))+min(abs(c-a),abs(10-(c-a)))}
func D(c:S,_ e:I=10,_ f:Bool=false,_ g:Bool=false)->I{if count(c)==0{return C(e,39)}
let h=c.startIndex,i=c.endIndex,j=S(c[h])
if let k=find(b[f ?1:0],j){return C(e,k)+D(c[advance(h,1)..<i],k,(g ?(!f):f),false)}else{return min(C(e,37)+D(c,37,!f,true),C(e,38)+D(c,38,!f,false))}}
print(D(" ".join(z)))

To run, put the code in a .swift file and run it with swift <filename> <your name>

This uses the simple approach where the two 'keyboards' are stored as arrays.
B:(I)->(I,I)={a in(a%10,a/10)}
Converts an index from the array to an x,y position on the virtual keyboard.
func C(e:I,f:I)->I{let(a,b)=B(e),(c,d)=B(f)
 return abs(d-b)+min(abs(c-a),abs(10-(c-a)))} Takes a start/end index and returns the minimum number of moves to get from once to the other (accounting for horizontal wrap)
func D(c:S,_ e:I=10,_ f:Bool=false,_ g:Bool=false)->I Is the main recursive function that does most of the calculations.  It calculates the distance from the current position to the target character, unless the case should change, then it calculates both the shift and the caps lock methods and takes the smallest.
Running swift codegolf.swift Code Golf prints 43

Needs to account for vertical wrap.

Updated to account for vertical wrap too.

Python 679 661 619 602 589 576 539 520 496 482 Bytes
Run this and it will ask for a input (without prompt text). For the input Code Golf it prints 43.
a=input()+'=';b=0;c="0123456789abcdefghijklmnopqrstuvwxyz-+^=";d=0;e=[0,1];f='+';g='^';h=[i.isupper()or i==' 'for i in a];i=abs;p=lambda z:all([i==b for i in z]);q=0
def l(z):global s;k=c.index(z.lower().replace(' ','-'));s=[k%10,int(k/10)];m,n=s;return sum([min(i(m-e[0]),i(10-(m-e[0]))),min(i(n-e[1]),i(4-(n-e[1])))])
def o(z):global d,e;d+=l(z);e=s
for r in a:
 if p(h[q:q+3]):o(g);b^=1
 if p(h[q:q+2]):
  if l(f)<l(g):o(f)
  else:o(g);b^=1
 if p([h[q]]):o(f)
 o(r);q+=1
print(d)

Full program:
input = input() + '='
capsOn = False

keys = "0123456789abcdefghijklmnopqrstuvwxyz-+^="
totalKeys = 0
caret = [0, 1]

shiftKey = '+'
capsKey = '^'

cases = [char.isupper() or char == ' ' for char in input]

def locate(char):
    """
        Find the location of the char on the keyboard
        regardless of case
    """
    location = keys.find(char.replace(' ', '-').lower())
    return [location % 10, int(location / 10)]

def dist(key):
    """
        Calculate the min dist to a char
    """
    nx, ny = locate(key)
    return sum([min(abs(nx - caret[0]), abs(10 - (nx - caret[0]))), min(abs(ny - caret[1]), abs(4 - (ny - caret[1])))])

def moveTo(char):
    """
        Move the caret to the char, ignoring case and
        adds the dist to the tally
    """
    global totalKeys, caret
    totalKeys = totalKeys + dist(char)

    print(keys[caret[0] + caret[1] * 10], '->', char, '=', dist(char))

    caret = locate(char)

diffCase = lambda case: all([i == capsOn for i in case])

for ind, ch in enumerate(input):
    if diffCase(cases[ind:ind + 3]): # use caps
        moveTo(capsKey)
        capsOn ^= 1
    elif diffCase(cases[ind:ind + 2]): # use closest
        if dist(shiftKey) < dist(capsKey):
            moveTo(shiftKey)
        else:
            moveTo(capsKey)
            capsOn ^= 1
    elif diffCase([cases[ind]]): # use shift
        moveTo(shiftKey)

    moveTo(ch) # apply the move

print('Total:', totalKeys)

Extended output from the full program:
Code Golf
a -> C = 2
c -> ^ = 6
^ -> o = 5
o -> d = 2
d -> e = 1
e -> + = 5
+ -> _ = 1
- -> + = 1
+ -> G = 3
g -> o = 3
o -> l = 3
l -> f = 5
f -> = = 6
Total: 43

Saved a byte thanks to @justin https://codegolf.stackexchange.com/a/18983/42736
4 @xnor https://codegolf.stackexchange.com/a/40791/42736
19 thanks to @Alex

Any help is appreciated as I'm still learning python and this is my first code golf.

You can use a space instead of an underscore in your internal tables.

I hadn't thought of that, thanks ;)

C 675 Bytes
Takes input from command line argument. Uses recursive main:
#define Y(_) (!isdigit(_)?!isalpha(_)?3:1+(toupper(_)-65)/10:0)
#define X(_) (!isdigit(_)?!isalpha(_)?_-32&&_-45?_-43?9-(_==94):7:6:(toupper(_)-5)%10:_-48)
x,y,z;char*s;main(a,_,p,q,r){a<2?s[_]?!isdigit(s[_])&&((s[_]-32&&!isupper(s[_]))||!a)&&((s[_]-45&&!islower(s[_]))||a)?q=x,r=y,main(3,43),p=z,x=X(43),y=Y(43),main(3,s[_]),p+=z,x=X(s[_]),y=Y(s[_]),main(a,_+1),p+=z,x=q,y=r,main(3,94),q=z,x=X(94),y=Y(94),main(3,s[_]),q+=z,x=X(s[_]),y=Y(s[_]),main(!a,_+1),q+=z,z=(q<p?q:p):(main(3,s[_]),q=z,x=X(s[_]),y=Y(s[_]),main(a,_+1),z+=q):(main(3,61)):(a<3?s=((char**)_)[1],x=0,y=1,main(1,0),printf("%d",z):(x=X(_)-x,y=Y(_)-y,x+=10*(x<0),y+=4*(y<0),z=(x>5?10-x:x)+(y>2?4-y:y)));}

source: Stack Exchange

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

sort: votes


text:
CipherSaber encryption
Implement a CipherSaber encryption program, as described below. Guidelines:

The smallest entry, in bytes, wins.

However, in a departure from code-golf norms, you are welcome to post interesting entries, even if they aren't serious golf entries.

An entry would typically be a program that takes the plaintext from standard input, and writes the ciphertext to standard output, with the key specified (by the user) in some way you prefer.

However, if you wish to implement this as a procedure, that is fine too.

The IV must come from a cryptographically secure pseudorandom number generator. If your language doesn't support that, choose a different one. ;-)
Please do not use any crypto-specific libraries, system calls, or instructions (other than the PRNG, as stipulated above). Of course, generic low-level bitwise operations are okay.

CipherSaber is a variant of RC4/Arcfour, so I'll start by describing the latter, then the changes CipherSaber makes thereto.
0. RC4/Arcfour
Arcfour is fully specified elsewhere, but for completeness, I'll describe it here. (In case of any discrepancies between the Internet-draft and this description, the former is normative.)
Key setup
Set up two arrays, S and S2, both of length 256, where k_1 is the first byte of the key, and k_n is the last.
S = [0, ..., 255]
S2 = [k_1, ..., k_n, k_1, ...]

(S2 is filled with the bytes of the key, again and again, until all 256 bytes are filled up.)
Then, initialise j to 0, and shuffle 256 times:
j = 0
for i in (0 .. 255)
    j = (j + S[i] + S2[i]) mod 256
    swap S[i], S[j]
end

This completes key setup. The S2 array is no longer used here, and can be scrubbed.
Cipher stream generation
Initialise i and j to 0, then generate the key stream as follows:
i = 0
j = 0
while true
    i = (i + 1) mod 256
    j = (j + S[i]) mod 256
    swap S[i], S[j]
    k = (S[i] + S[j]) mod 256
    yield S[k]
end

Encrypting/decrypting data

To encrypt, XOR the keystream output with the plaintext
To decrypt, XOR the keystream output with the ciphertext

1. CipherSaber
CipherSaber (which is what we're implementing in this question) is a variation of RC4/Arcfour in two ways:
10-byte IV/nonce
When encrypting a message, 10 random bytes should be obtained, such as via /dev/urandom, and be written into the first 10 bytes of the encrypted output. When decrypting a message, the first 10 bytes of the input is the IV used to encrypt it.
The RC4/Arcfour key setup stage is run with passphrase || IV as the key, where passphrase is the user-specified passphrase, IV is as described above, and || is concatenation. So, a passphrase of "Hello, world!" and an IV of "supercalif" (however unlikely that is :-P) would result in a key of "Hello, world!supercalif".
Multiple iterations of key setup
In order to help prevent the vulnerability that made WEP encryption completely broken, the shuffling loop of the key setup stage of RC4 is run a user-specified number of times. The value of j should be retained between iterations.
2. Test vectors
Here are some test vectors you can use to test your programs. Furthermore, squeamish ossifrage created a CipherSaber encryption & decryption tool that you can use to validate your results.
You only need to implement the encryption program. You do not need to supply the decryption program, but your encryption program's output must roundtrip correctly to the original input when processed with a correctly-implemented decryption program using the correct key.

Pyth, 100 bytes
$import os$KsM$os.urandom(10)$JuuXN@LN,T=+Z+@NT@+CMzKT)bGQU=b256=Z0sCM+K.exCb@=XJ=N@LJ,hk=+Z@Jhk)sNw

This script uses the $ command, which allows executing Python code. To prevent executing malicious code on the server, the this command is disabled in the online compiler. You have to run it with the off-line compiler which you can find here.
The input is in the format:
secret key
5 (number of repeats)
secret message

The program outputs the encrypted string, which might contain unprintable chars. If you want to verify it using the CipherSaber Encryption & Decryption Tool, you can use the following code, which converts the string to a series of hexadecimal digits.
$import os$KsM$os.urandom(10)$JuuXN@LN,T=+Z+@NT@+CMzKT)bGQU=b256=Z0
jdm.[2.HCd`0
sCM+K.exCb@=XJ=N@LJ,hk=+Z@Jhk)sNw

Pyth doesn't support cryptographically secure pseudorandom numbers and importing them from Python costs 25 bytes. A shorter code, which uses Pyth's/Python's normar pseudorandom-number generator and also works in the online compiler is:
KmO=b256TJuuXN@LN,T=+Z+@NT@+CMzKT)bGQUb=Z0sCM+K.exCb@=XJ=N@LJ,hk=+Z@Jhk)sNw

Try it online: returning a string or a series of hexadecimal digits
The code is nothing special. Just a lot of dirty assignments and immediate reuses of computed results and applying twice the list-swap trick.
Explanation:
                                  implicit: z = 1st input (= key string)
                                  Q = 2nd input (number of repetitions)
$import os$KsM$os.urandom(10)$
$import os$                       import Python's os module
              $os.urandom(10)$    create 10 cryptographically secure
                                  pseudo-random bytes
            sM                    convert them to ints
           K                      store them in K

JuuXN@LN,T=+Z+@NT@+CMzKT)bGQU=b256
                             =b256assign b with 256
 u                         QUb    start with G = [0, 1, ..., 255],
                                  evaluate the following expression Q times and
                                  update G with the result each time:
  u                      bG         start with N = G,
                                    for each T in [0, 1, ..., 255] evaluate the
                                    following expression and update N each time:
                   CMz                convert key to list of ints
                  +   K               extend it with K
                 @     T              take the Tth element (modulo length)
              @NT                     take the Tth element of N
             +                        add these two values
           +Z                         add Z (with is initially 0)
          =                           and update Z with the result
        ,T  Z                         make the pair of indices [T, Z]
     @LN                              look-up their values in N
   XN                   )             and switch these two values in N
J                                 assign the result (the key setup) to J

=Z0                               set Z to 0

sCM+K.exCb@=XJ=N@LJ,hk=+Z@Jhk)sNw
                                w read a string from input (message)
     .e                           map each index k, char b in message to:
                         @Jhk       look-up the (k+1)th element in J
                      =+Z           add it to Z and update Z
                   ,hk  Z           make the pair of indices [k+1,Z]
                @LJ                 look-up their values in J
              =N                    assign the result to N
            XJ N             )      swap these values in J
           =                        and update J with the result
          @  J                sN    take the sum(N)th element of J
        Cb                          convert b to int
       x                            bitwise xor of these two elements
   +K                             insert K at the beginning
 CM                               convert each element to char
s                                 sum them (generate a string)
                                  implicitly print

Apparently, built-in Pyth functions don't have cryptographically secure pseudorandom numbers. You can keep your entry as is, and it won't qualify for the green tick, or you can make a version that uses urandom (which can be a separate entry if you like) if you care about "winning". :-)

@ChrisJester-Young Sorry about that. I didn't thought that Python's random-number generator is so insecure. Corrected it to a cost of 25 bytes.

Python 2 - 373 350 326 317 bytes
Pyth possibly coming later. Defines one function, c(p,d,r,m) which takes byte lists for passphrase and data, and int for repetitions and mode which encrypts when 1 and decrypts when 0. This is because the only difference in them is dealing with the IV. Returns byte list.
import os
B=256
def c(p,d,r,m):
    if m:v=map(ord,os.urandom(10))
    else:v,d=d[:10],d[10:]
    p+=v;S=range(B);T=(p*B)[:B];j=0;exec"for i in range(B):j=(j+S[i]+T[i])%B;S[i],S[j]=S[j],S[i]\n"*r;o=[];i=j=0
    for b in d:i=-~i%B;j=(j+S[i])%B;S[i],S[j]=S[j],S[i];k=(S[i]+S[j])%B;o+=[S[k]^b]
    return v+o if m else o

Here is some test code / Helper functions:
phrase = "hello"
text = "Mary had a little lamb, little lamb, little lamb"
N = 5

def make_bytes(string):
    return map(ord, string)

def make_string(bytes):
    return "".join(map(chr, bytes))

def make_hex(bytes):
    return " ".join("%02x" % i for i in bytes)

def from_hex(hex_str):
    return [int(i, 16) for i in hex_str.split()]

cipher = c(make_bytes(phrase), make_bytes(text), N, 1)
print make_hex(cipher)
plain = c(make_bytes(phrase), cipher, N, 0)
print make_string(plain)

You only need to write an encryption program. So you can remove the else:v,d=d[:10],d[10:]part.

Ruby - 263 chars
This is my Ruby answer to the original question on stackoverflow back in 2010! It is a encoder and decoder all in one program
Parameters are:
e or d (for encode or decode)
key
number of times
$ ruby saber.rb e gnibbler 10 < in.txt | ruby saber.rb d gnibbler 10

o,k,l=ARGV;print o<'e'?(v=STDIN.read(10))*0:v=(0..9).map{rand(256).chr}.join;j=0;E=255
S=Array 0..255;(S*l.to_i).each{|i|j=j+S[i]+((k+v)*E)[i].ord&E;S[i],S[j]=S[j],S[i]};i=j=0
STDIN.each_byte{|c|i=i+1&E;j=j+S[i]&E;S[i],S[j]=S[j],S[i];print (c^S[S[i]+S[j]&E]).chr}

C, 312 bytes
Accepts a key and key mixing iteration count on the command line, then encrypts everything on stdin to stdout. This uses the BSD/Darwin library function arc4random(), which is a PRNG based on RC4. It automatically seeds itself, so the results will be different every time.
unsigned char n,i,j,q,x,t,s[256],k[256];main(int c,char**v){for(strcpy(k,v[1]),n=strlen(k);x<10;x++)putchar(k[n++]=arc4random());do{s[i]=i;}while(++i);for(x=atoi(v[2]);x--;)do{t=s[i];s[i]=s[j+=s[i]+k[i%n]];s[j]=t;}while(++i);for(;(c=getchar())>0;){q+=s[++i];t=s[i];s[i]=s[q];s[q]=t;t=s[i]+s[q];putchar(c^s[t]);}}

Tidier version:
unsigned char n,i,j,q,x,t,s[256],k[256];
main(int c,char**v) {
  for (strcpy(k,v[1]),n=strlen(k);x<10;x++) putchar(k[n++]=arc4random());
  do {
    s[i]=i;
  }
  while(++i);
  for (x=atoi(v[2]);x--;) do {
    t=s[i];
    s[i]=s[j+=s[i]+k[i%n]];
    s[j]=t;
  }
  while (++i);
  for (;(c=getchar())>0;) {
    q+=s[++i];
    t=s[i];
    s[i]=s[q];
    s[q]=t;
    t=s[i]+s[q];
    putchar(c^s[t]);
  }
}

Example:
$ echo -n 'Ciphersaber' | ./csgolf 'hello' 20 | xxd -p
0f6257c330e5e01c3eab07bc9cb4ee4c3eaa514a85

279 bytes

Python - 266 chars
This is my Python answer to the original question on stackoverflow back in 2010! It is a encoder and decoder all in one program
Parameters are:
e or d (for encode or decode)
key
number of times
$ python saber.py e gnibbler 10 < in.txt | python saber.py d gnibbler 10

This version attempts to merge the 2 loops of the rc4 into one (saves 11 bytes so far...)
import os,sys;X,Y=sys.stdin.read,os.write;_,o,k,l=sys.argv;p='d'<o
V=(X,os.urandom)[p](10);Y(1,V*p);E,S=255,range(256)
for q in S*int(l),X():
 t=q<'';j=0;i=-t
 for c in q:i=i+1&E;j=j+S[i]+t*ord(((k+V)*E)[i])&E;S[i],S[j]=S[j],S[i];t or Y(1,chr(ord(c)^S[S[i]+S[j]&E]))

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


text:
Make the Mexican Wave
In as few bytes as possible, write a program or function that outputs the following:
Abcdefghijklmnopqrstuvwxyz
aBcdefghijklmnopqrstuvwxyz
abCdefghijklmnopqrstuvwxyz
abcDefghijklmnopqrstuvwxyz
abcdEfghijklmnopqrstuvwxyz
abcdeFghijklmnopqrstuvwxyz
abcdefGhijklmnopqrstuvwxyz
abcdefgHijklmnopqrstuvwxyz
abcdefghIjklmnopqrstuvwxyz
abcdefghiJklmnopqrstuvwxyz
abcdefghijKlmnopqrstuvwxyz
abcdefghijkLmnopqrstuvwxyz
abcdefghijklMnopqrstuvwxyz
abcdefghijklmNopqrstuvwxyz
abcdefghijklmnOpqrstuvwxyz
abcdefghijklmnoPqrstuvwxyz
abcdefghijklmnopQrstuvwxyz
abcdefghijklmnopqRstuvwxyz
abcdefghijklmnopqrStuvwxyz
abcdefghijklmnopqrsTuvwxyz
abcdefghijklmnopqrstUvwxyz
abcdefghijklmnopqrstuVwxyz
abcdefghijklmnopqrstuvWxyz
abcdefghijklmnopqrstuvwXyz
abcdefghijklmnopqrstuvwxYz
abcdefghijklmnopqrstuvwxyZ
abcdefghijklmnopqrstuvwxYz
abcdefghijklmnopqrstuvwXyz
abcdefghijklmnopqrstuvWxyz
abcdefghijklmnopqrstuVwxyz
abcdefghijklmnopqrstUvwxyz
abcdefghijklmnopqrsTuvwxyz
abcdefghijklmnopqrStuvwxyz
abcdefghijklmnopqRstuvwxyz
abcdefghijklmnopQrstuvwxyz
abcdefghijklmnoPqrstuvwxyz
abcdefghijklmnOpqrstuvwxyz
abcdefghijklmNopqrstuvwxyz
abcdefghijklMnopqrstuvwxyz
abcdefghijkLmnopqrstuvwxyz
abcdefghijKlmnopqrstuvwxyz
abcdefghiJklmnopqrstuvwxyz
abcdefghIjklmnopqrstuvwxyz
abcdefgHijklmnopqrstuvwxyz
abcdefGhijklmnopqrstuvwxyz
abcdeFghijklmnopqrstuvwxyz
abcdEfghijklmnopqrstuvwxyz
abcDefghijklmnopqrstuvwxyz
abCdefghijklmnopqrstuvwxyz
aBcdefghijklmnopqrstuvwxyz
Abcdefghijklmnopqrstuvwxyz

A trailing newline is permitted. You can find a reference ungolfed Python implementation here.

Is it safe to assume input is never upper case?

@Winny There is no input. The output is fixed. In fact, that's the general idea of [tag:kolmogorov-complexity] questions.

This has been in the HNQ list consistently since you posted it. Nice work. :)

You can find a reference ungolfed Python implementation here. -> link's broken

Franck Dernoncourt's point still stands. The link is broken.

Pyth, 12 bytes
V+Gt_GXGNrN1

Demonstration.
In Pyth, G is the lowercase alphabet. +Gt_G is abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba, the character that needs to be uppercased in each row.
V sets up a for loop over this string, with N as the loop variable.
In the body, XGNrN1 is a string translation function. X translates G, the alphabet, replacing N with rN1, the uppercase version of N. r ... 1 is the uppercase function. This gives the desired output.

Am I the only one who finds it funny that the lowercase alphabet is represented by an uppercase letter?

If only the uppercase alphabet is represented by a lowercase letter...

C,73
Sometimes the simplest approach is best: print every character one by one. this beats a lot of languages it really shouldn't.
i;f(){for(i=1377;i--;)putchar(i%27?123-i%27-32*!(i/702?i%28-4:i%26):10);}

explanation
i;f(){
   for(i=1377;i--;)
   putchar(i%27?                 //if I not divisible by 27
     123-i%27-                   //  print lowercase letter from ASCII 122 downards
       32*!(i/702?i%28-4:i%26)   //  subtract 32 to make it uppercase where necessary: above i=702, use i%28-4, below it use i%26
     :10);                       //if I divisible by 27 print a newline (10)
}

Python 2, 69 bytes
i=25
exec"L=range(97,123);L[~abs(i)]^=32;i-=1;print bytearray(L);"*51

Nice and simple, I think.

That's really clever. Loop unrolling!

Brainfuck (8bit), 231 bytes
++++++++++>++[>>+++++[-<+++++>]<[>>>>>[-]>[-]--[-----<+>]<----->[-]>----[----<+>]<++<<<+++++[-<<+++++>>]<<+>[>>>.+>+<<<<-<->]>>>+>.+<<<<<-[>>>>.+>+<<<<<-]<<<<[<+>>>>>>>>-<<<<<<<-]<[>+<-]>>>>>>>>+[<+<+>>-]<[>+<-]<<<<<.>>-]+<-<<++>>]

Ok, so it's never going to be the shortest, but it's the taking part that counts... right?!
Try it here (ensure to tick 'Dynamic memory')

If the goal was to be the longest possible code that is still completely indecipherable to the average human programmer…

@Caleb I think the BF code is some of the easiest code to understand in existence. It's the program/functionality that's hard to understand. Everyone should know that > shifts one cell to the right, for example.

Always got to love the BF answers ;)

You didn't write this code directly now did you?

I'm ashamed to say I did!

MS-DOS Binary, 61
This code does not have to be compiled, it will run in MS-DOS if you write it into a file called wave.com . The code in hex:
ba3d0189d7b91a00b061aa404975fbb00aaab00daab024aa31f6e8130046
83fe1a75f7be1800e807004e75fae80100c389d3802820b409cd21800020
c3

Or, if you prefer something more readable, here is how to produce it using debug.exe (the empty line after the code is important):
debug.exe wave.com
a
mov dx,13d
mov di,dx
mov cx,1a
mov al,61
stosb
inc ax
dec cx
jnz 10a
mov al,a
stosb
mov al,d
stosb
mov al,24
stosb
xor si,si
call 130
inc si
cmp si,1a
jnz 11a
mov si,18
call 130
dec si
jnz 126
call 130
ret
mov bx,dx
sub byte ptr [si+bx],20
mov ah,9
int 21
add byte ptr [si+bx],20
ret

rcx
3e
w
q

Ruby: 71 68 65 63 characters
puts f=(e=*?a..?z).map{|c|(e*"").tr c,c.upcase},f[0,25].reverse

Sample run:
bash-4.3$ ruby -e 'puts f=(e=*?a..?z).map{|c|(e*"").tr c,c.upcase},f[0,25].reverse' | head
Abcdefghijklmnopqrstuvwxyz
aBcdefghijklmnopqrstuvwxyz
abCdefghijklmnopqrstuvwxyz
abcDefghijklmnopqrstuvwxyz
abcdEfghijklmnopqrstuvwxyz
abcdeFghijklmnopqrstuvwxyz
abcdefGhijklmnopqrstuvwxyz
abcdefgHijklmnopqrstuvwxyz
abcdefghIjklmnopqrstuvwxyz
abcdefghiJklmnopqrstuvwxyz

63: puts f=(e=*?a..?z).map{|c|(e*"").tr c,c.upcase},f[0,25].reverse

Doh. I tried a couple of dumb ideas to optimize e's reuse, but of course not the right way. Thank you, @Ventero.

Matlab, 60 58 54 bytes
I=32*eye(26);[ones(51,1)*(97:122) '']-[I;I(25:-1:1,:)])

With thanks to Dennis Jaheruddin for saving me 4 bytes.

Here you can also use the typical trick to replace char(x) by [x ''] to save a byte.

Also end-1 is a rather verbose way to write 25!

@DennisJaheruddin Oops. Thanks for both! Actually the [x ''] trick is not usual at all for me. But now I remember seeing it in one of your anwers :-)

Haskell, 70 bytes
mapM putStrLn[[toEnum$x+sum[32|x+abs y/=90]|x<-[65..90]]|y<-[-25..25]]

I revisited this problem 6 years later and saved a bunch of bytes. Character growth!
Try it online!
Haskell, 81 bytes
Counting bytes the way @nimi did; f is an IO action that prints the desired output.
x!y|x==min(50-y)y=65|0<1=97
f=mapM putStrLn[[toEnum$x+x!y|x<-[0..25]]|y<-[0..50]]

Very elegant. Didn't know that guards can be used inline.

Scala 110 109 characters
val a=('a'to'z').map(c⇒('a'to'z').map(v⇒if(v==c)c.toUpper else v).mkString)
a++a.init.reverse foreach println

OMG in Scala ⇒ symbol is used? I mean not => but ⇒???

Both are valid :)

could shave off 1 byte if I change foreach println to mkString("\n"), and output a string as return value instead of printing it to the screen

SWI-Prolog, 136 bytes
a:-(R=0;R=1),between(1,26,I),(I=1,R=0;I\=1,nl),between(1,26,J),(R=0,L=I;R=1,L is 27-I),(J=L,K is J+64,put(K);J\=L,K is J+96,put(K)),\+!.

Abusing backtracking to loop...

Haskell 100 89 88 bytes
putStr$map toEnum.(\(h,c:t)->h++c-32:t++[10]).(`splitAt`[97..122]).(25-).abs=<<[-25..25]

The lambda helper function \(h,c:t) takes a pair of lists of ascii values and concatenates both, but with the first value of the second list capitalized. The main function splits the lowercase alphabet (given in ascii, 97..122) at every position 0,..,24,25,24,..,0 and calls the lambda in every step. Before printing each value is turned into the corresponding character.

Here's my approach: http://codegolf.stackexchange.com/a/53895/3852

SQL (postgreSQL), 107 101
Generate are series from -25 to 25 and use the absolute value to replace characters with their uppercase version.  Thanks to manatwork for the tip about the @ operator.
select replace('abcdefghijklmnopqrstuvwxyz',chr(122- @i),chr(90- @i))from generate_series(-25,25)a(i)

You know that PostgreSQL has a @ operator?

@manatwork nope I didn't know that, but now I do thanks

MATLAB - 58 bytes
char(bsxfun(@minus,97:122,32*[eye(25,26);rot90(eye(26))]))

Similar to Luis Mendo's solution, but using the broadcasting abilities of bsxfun.
Taking advantage that in ASCII, the difference between a capital and lower case character is exactly 32 values away from each other, we first generate lower case letters from ASCII codes 97 to 122 which are the ASCII codes from lowercase a to lowercase z respectfully, then create a 51 row matrix that contains the 26 ASCII codes from 97 to 122.  Therefore, each row of this matrix contains a numerical sequence of values from 97 to 122.  Next, we create another matrix where each ith row of this matrix contains a 32 in the ith column.  The first 26 rows of this matrix has this pattern, which is essentially the identity matrix multiplied by 32.  The function eye creates an identity matrix for you.  The last 25 rows of this matrix is the scaled identity matrix rotated 90 degrees.
By taking this custom weighted identity matrix and subtracting this with the first matrix, then converting the resulting ASCII codes into characters, the desired "Mexican Hat" sequence is produced.
Example Run
>> char(bsxfun(@minus,97:122,32*[eye(25,26);rot90(eye(26))]))

ans =

Abcdefghijklmnopqrstuvwxyz
aBcdefghijklmnopqrstuvwxyz
abCdefghijklmnopqrstuvwxyz
abcDefghijklmnopqrstuvwxyz
abcdEfghijklmnopqrstuvwxyz
abcdeFghijklmnopqrstuvwxyz
abcdefGhijklmnopqrstuvwxyz
abcdefgHijklmnopqrstuvwxyz
abcdefghIjklmnopqrstuvwxyz
abcdefghiJklmnopqrstuvwxyz
abcdefghijKlmnopqrstuvwxyz
abcdefghijkLmnopqrstuvwxyz
abcdefghijklMnopqrstuvwxyz
abcdefghijklmNopqrstuvwxyz
abcdefghijklmnOpqrstuvwxyz
abcdefghijklmnoPqrstuvwxyz
abcdefghijklmnopQrstuvwxyz
abcdefghijklmnopqRstuvwxyz
abcdefghijklmnopqrStuvwxyz
abcdefghijklmnopqrsTuvwxyz
abcdefghijklmnopqrstUvwxyz
abcdefghijklmnopqrstuVwxyz
abcdefghijklmnopqrstuvWxyz
abcdefghijklmnopqrstuvwXyz
abcdefghijklmnopqrstuvwxYz
abcdefghijklmnopqrstuvwxyZ
abcdefghijklmnopqrstuvwxYz
abcdefghijklmnopqrstuvwXyz
abcdefghijklmnopqrstuvWxyz
abcdefghijklmnopqrstuVwxyz
abcdefghijklmnopqrstUvwxyz
abcdefghijklmnopqrsTuvwxyz
abcdefghijklmnopqrStuvwxyz
abcdefghijklmnopqRstuvwxyz
abcdefghijklmnopQrstuvwxyz
abcdefghijklmnoPqrstuvwxyz
abcdefghijklmnOpqrstuvwxyz
abcdefghijklmNopqrstuvwxyz
abcdefghijklMnopqrstuvwxyz
abcdefghijkLmnopqrstuvwxyz
abcdefghijKlmnopqrstuvwxyz
abcdefghiJklmnopqrstuvwxyz
abcdefghIjklmnopqrstuvwxyz
abcdefgHijklmnopqrstuvwxyz
abcdefGhijklmnopqrstuvwxyz
abcdeFghijklmnopqrstuvwxyz
abcdEfghijklmnopqrstuvwxyz
abcDefghijklmnopqrstuvwxyz
abCdefghijklmnopqrstuvwxyz
aBcdefghijklmnopqrstuvwxyz
Abcdefghijklmnopqrstuvwxyz

You can also run this example using IDEone's online Octave environment. Octave is essentially MATLAB but free: http://ideone.com/PknMe0

rot90 -- well thought!

char(ones(26,1)*[97:122] -eye(26)*32)

@user3528438 how do you handle the second half? The code only computes the first half of the wave. You need to compute the rest.

@user3528438 - Also note that what you wrote is basically the first half of Luis Mendo's answer.  I decided to write something a bit different to achieve the same thing :)

@rayryeng yeah, it suprises me that the second half is harder to handle, and also how to avoid the center duplicate.

@user3528438 - Yup... the second half is what killed my byte count lol.

Pyth - 18 17 bytes
First pass, probably can be made much shorter. Uses X to substitute and r1 to capitalize.
V+KU26t_KXGNr@GN1

Try it online here.

J, 31 23 bytes
u:|:(97+i.26)-32*=|i:25

8 bytes saved thanks to @Mauris.
Try it online here.

I could get 23: u:|:(97+i.26)-32*=|i:25 (monad = is really useful here!)

@Mauris Thanks, I haven't thought of using monad = here. It's very nice!

Perl, 51 bytes
50 bytes code + 1 byte command line parameter
@a=a..z,@a[-1-abs]=uc@a[-1-abs],print@a for-25..25

Can be used as follows:
perl -le '@a=a..z,@a[-1-abs]=uc@a[-1-abs],print@a for-25..25'

Or online here (note I had to add ,"\n" to this as I couldn't add the -l arg).

Much longer method
Before the shortened version above, I tried a different method which ended up being pretty chunky. I've left it below anyway for reference.
86 bytes code + 1 byte command line arg
$_=join"",0,a..z,1;print s/1//r while s/(([A-Z])|0)(\D)|(.)((?2))(1)/\L\2\U\3\4\6\L\5/

First Perl I've ever golfed properly so I imagine there's a lot that can be done with it - please do suggest improvements!
Can be used as followed:
perl -le '$_=join"",0,a..z,1;print s/1//r while s/(([A-Z])|0)(\D)|(.)((?2))(1)/\L\2\U\3\4\6\L\5/'

Or online here (note I had to add ."\n" to this as I couldn't add the -l arg).
Explanation
General approach is to use regex substitution to do all the hard work. We start off with:
0abcdefghijklmnopqrstuvwxyz1

This matches (([A-Z])|0)(\D) and gets replaced with \U\3 (\U changes to uppercase) to give:
Abcdefghijklmnopqrstuvwxyz1

From this point onwards, we continue to match the same regex and replace with \L\2\U\3:
aBcdefghijklmnopqrstuvwxyz1
abCdefghijklmnopqrstuvwxyz1
...
abcdefghijklmnopqrstuvwxyZ1

Now the second alternation of the regex matches, (.)((?2))(1) (which is the same as (.)([A-Z])(1)). We replace with \U\4\6\L\5 to give:
abcdefghijklmnopqrstuvwxY1z

This continues to match and replace until we reach:
A1bcdefghijklmnopqrstuvwxyz

and there are no more regex matches.
At each point in the loop we strip off the '1' and print.

PHP, 87 71 69 bytes
Not the shortest one, but it works as intended.
Thanks to @manatwork for a few tips to reduce it's size by a lot.
And thanks to @Blackhole, the size was reduced by 2 bytes.
for(;$L=range(a,z),$L[25-abs($i++-25)]^=' ',$i<52;)echo join($L).'
';

Not exactly pretty, but works.

“glue   Defaults to an empty string.” – PHP documentation about join()'s first parameter.

That string subscript is not really optimal: $i<25?$i:25-($i-25) → 25-abs($i-25)

Given that you are already ignoring warnings (for the undefined constants a and z), you could ignore another one for the uninitialized $i. While touching $i, move its incrementation into the string subscript. for(;$i<51;){$L=range(a,z);$L[25-abs($i++-25)]^=" ";echo join($L),"↵";} (Just wrap the line where I used “↵” in the code.)

@manatwork Thanks a lot! I totally forgot that the \n was there. The initialization of $i was left as an accident. And thank you a lot for the 25-abs($i-25). I wouldn't get there by myself.

Your for loop can be optimised: for(;$L=range(a,z),$L[25-abs($i++-25)]^=' ',$i<52;)echo join($L).'↵'; (-2 bytes).

@Blackhole Thanks a lot for the suggestion. It really is a great idea! And it seems to work so far. Once again, thanks a lot for the tip.

PowerShell 3.0, 82 bytes
$(0..25)+$(24..0)|%{$i=$_;[string](@(97..122)|%{[char]@($_,($_-32))[$_-eq$i+97]})}

TIS Node Type T21 Architecture - 216 215 bytes

Watch it in action here! There's a DOWN in that video that I later golfed to ANY, but it's functionally identical.
This language has no concept of strings or characters, so I should point out that I'm using ASCII values, i.e. output begins 97, 66, 67...88, 89, 90, 10, 65, 98...
Here's the code in the format of TIS-100's save data, for the purposes of scoring:
@5
ADD 25
L:MOV 27 ANY
SUB 1
JGZ L
MOV 25 ANY
JRO -1
@6
JRO 2
S:MOV 10 ANY
ADD 65
MOV ACC ANY
SUB 90
JEZ S
ADD 26
@9
MOV 32 ANY
ADD UP
L:MOV 0 ANY
SUB 1
JGZ L
@10
MOV UP ACC
ADD ANY
SUB 42
D:JEZ D
ADD 42
MOV ACC ANY

Explanation

is this the first question in TIS-100 or what?

I have implemented a TIS emulator for TIO, so you can now try it online!

JavaScript ES6, 121 bytes
_=>Array(51).fill('abcdefghijklmnopqrstuvwxyz').map((e,i)=>e.replace(/./g,(f,j)=>j==i|i+j==50?f.toUpperCase():f)).join`
`

This is really long because it makes more sense to hardcode the alphabet than to use the absurdly long String.fromCharCode to generate the characters. Test it out below with the Stack snippet, which uses better-supported ES5 and below.

f=function(){
  return Array(51).fill('abcdefghijklmnopqrstuvwxyz').map(function(e,i){
    return e.replace(/./g,function(f,j){
      return j==i|i+j==50?f.toUpperCase():f
    })
  }).join('\n')
}

// Polyfill for ES6-only fill()
Array.prototype.fill = Array.prototype.fill || function(val){
  for(i=0;i<this.length;i++){
    this[i] = val
  }
  return this
}

document.getElementById('p').innerText=f()

R, 78 70
M=replicate(26,c(letters,"\n"));diag(M)=LETTERS;cat(M,M[,25:1],sep="")

Improved by @MickyT

Almost identical to one I came up with but put to one side.  I used M=replicate(26,c(letters,"\n")) rather than a matrix.  It will save you a few bytes

Save 1 byte by using write: https://tio.run/##K/r/39e2KLUgJzM5sSRVw8hMJye1pCS1qFiTKyUzMV3DV9PWxzUkxDUomKu8KBOoIlnDV8c3WsfI1MowVlPHUAeoQ0dJSfP/fwA

C#, 140 139 135 132
void f(){int d=1,i=0;var s="abcdefghijklmnopqrstuvwxyz\n";for(;i>=0;i+=d=i==25?-1:d)Console.Write(s.Replace(s[i],(char)(s[i]-32)));}

Expanded
void f()
{
    int d = 1, i =0;
    var s = "abcdefghijklmnopqrstuvwxyz\n";
    for (; i >= 0; i += d = i == 25 ? -1 : d)
        Console.Write(s.Replace(s[i], (char)(s[i] - 32)));
}

Saved 1 byte thanks to @Gunther34567 using a ternary instead of if
Saved 4 bytes then nesting that ternary inside the loop and moving the alphabet to the outside of the loop
Saved 3 bytes combining integer declarations thanks to @eatonphil

you could save 1 byte by changing if(i==25)d=-1; to d=i==25?-1:d;

You can save 3 bytes by changing var d=1 to int d=1,i.

Bash: 76 66 characters
printf -va %s {a..z}
for c in {a..z} {y..a};{ echo ${a/$c/${c^}};}

Sample run:
bash-4.3$ printf -va %s {a..z};for c in {a..z} {y..a};{ echo ${a/$c/${c^}};} | head
Abcdefghijklmnopqrstuvwxyz
aBcdefghijklmnopqrstuvwxyz
abCdefghijklmnopqrstuvwxyz
abcDefghijklmnopqrstuvwxyz
abcdEfghijklmnopqrstuvwxyz
abcdeFghijklmnopqrstuvwxyz
abcdefGhijklmnopqrstuvwxyz
abcdefgHijklmnopqrstuvwxyz
abcdefghIjklmnopqrstuvwxyz
abcdefghiJklmnopqrstuvwxyz

An anonymous user suggested that the first line is not necessary at all which would reduce the byte count to 45.

Interesting. Then from where would the alphabet appear?

I couldn't tell you. The edit simply removed the printf call. I rejected the edit, so you can test it yourself.

Yes, I saw. (The site notified me about the edit and its fate.) As without the 1st line which places the alphabet in variable a, the 2nd line can only print empty strings from variable a, I see no other resolution than rejecting it. :(

CJam, 23 bytes
51{25-z~'{,97>'[2$+tN}/

Try it online in the CJam interpreter.
How it works
51{                  }/ e# For I from 0 to 50:
   25-                  e#   Compute J := I - 25.
                        e#   This maps [0 ... 50] to [-25 ... 25].
      z                 e#   Compute K := abs(J).
                        e#   This maps [-25 ... 25] to [25 ... 0 ... 25].
       ~                e#   Compute L := ~K = -(K + 1).
                        e#   This maps [25 ... 0 ... 25] to [-26 ... -1 ... -26].
        '{,             e#   Push ['\0' ... 'z'].
           97>          e#   Discard the first 97. Pushes ['a' ... 'z'].
              '[2$+     e#   Add L to '['. Pushes 'A' for -26, 'Z' for -1.
                   t    e#   Set ['a' ... 'z'][L] to '[' + L.
                    N   e#   Push a linefeed.

x86 assembly for DOS, 41 Bytes compiled
Binary:
00000000  b9 e6 ff b3 61 b8 61 02  50 38 d8 75 02 24 df 88
00000010  c2 cd 21 58 40 3c 7b 75  ef b2 0a cd 21 41 79 02
00000020  43 43 4b 80 f9 19 75 dd  c3

Source code, save as "wave.asm", compile with "nasm -f bin -o wave.com wave.asm" and run with "dosbox wave.com"
org 100h
section .text
start:
mov cx,-26
mov bl,'a'
next_line:
mov ax, 0261h
next_char:
push ax
cmp al,bl
jnz lower_case
and al,255-32
lower_case:
mov dl,al
int 21h
pop ax
inc ax
cmp al,'z'+1
jnz next_char
mov dl,0ah
int 21h
inc cx
jns move_left
inc bx
inc bx
move_left:
dec bx
cmp cl,25
jnz next_line
ret

Linux Assembly, 289
Unfortunately not competitive with high level languages and probably far from optimal, but pretty straightforward. Run it using nasm -f elf64 -o a.o wave.S; ld -s -o a a.o; ./a (the resulting binary is just 568 bytes big):
section .data
s:db 'abcdefghijklmnopqrstuvwxyz',10
section .text
global _start
_start:
mov esi,0
a:call c
inc esi
cmp esi,26
jne a
mov esi,24
b:call c
dec esi
jnz b
call c
mov eax,1
call d
c:mov ecx,s
sub byte [ecx+esi],32
mov eax,4
mov edx,27
d:mov ebx,1
int 80h
add byte [ecx+esi],32
ret

Seems a waste of space to compile this to ELF (lots of bloating zeros there). It can be much reduced if done as a DOS's COM program. I guess it could then run in dosbox in Linux :)

I know and I did just that. Look at my other post http://codegolf.stackexchange.com/a/53984/42642 :)

Yeah, seen it, upvoted it. Didn't notice it was you too though.

Perl - 95 64 bytes
Takes advantage of the fact \u makes the next character printed an uppercase in Perl.
for$c(0..50){$n=1;print map{++$n==27-abs$c-25?"\u$_":$_}a..z,$/}

Thanks to manatwork for saving 31 bytes and fixing it (my previous code did not work.)

That \u seems to work in a separate sample, but not in your code. :( All characters stayed lowercase. Could you show us how your code should be executed? (I put it in a file then called perl passing it the file name, no switches.) By the way, I use perl 5.20.2.

By the way, it seems to work when \u is followed by the letter to transform in the same string literal: for$c(0..50){$n=1;print map{++$n==27-abs$c-25?"\u$_":$_}a..z,$/}

@manatwork Strange, it worked when I did it. (I use 5.18.) Your code works, and it cuts down the size significantly, so I'll use it. Thanks!

Javascript (ES6), 113 bytes
c=-1;while(c++<50){console.log('abcdefghijklmnopqrstuvwxyz'.replace(/./g,(x,i)=>i==c|i+c==50?x.toUpperCase():x))}

110 bytes
for(c=-1;c++<50;)console.log('abcdefghijklmnopqrstuvwxyz'.replace(/./g,(x,i)=>i==c|i+c==50?x.toUpperCase():x))

102 bytes
Old school is unbeatable unless we'll have range operator/function/generator/whatever in js
for(c=-1;c++<50;){for(s='',i=-1;i++<25;)s+=String.fromCharCode(i+(i==c|i+c==50?65:97));console.log(s)}

100 bytes
Unluckily Math.abs is too long
for(c=51;c--;){for(s='',i=26;i--;)s+=String.fromCharCode(c+i==25|c-i==25?90-i:122-i);console.log(s)}

96 94 bytes
Though I've beeing downvoted without explanation I continue my struggle
for(c=-26;c++<25;){for(s='',i=26;i--;)s+=String.fromCharCode(c*c-i*i?122-i:90-i);console.log(s)}

We can shave off a couple of bytes by rearranging loop instructions:
for(c=-26;c++<25;console.log(s))for(s='',i=26;i--;s+=String.fromCharCode(c*c-i*i?122-i:90-i));

Please explain downvotes. The output is wrong?

Maybe because you technically have multiple answers in a single post?  Hell if I know, good shaving, though!

Also, I think you can shave off that last semi-colon

Nope, I was incorrect

awk, 91 bytes
awk 'BEGIN{for(i=0;i<51;i++)for(j=0;j<27;j++)printf("%c",j>25?10:i==j||j==50-i?j+65:j+97)}'

Shave 3 bytes off by removing the i=0.

Sed: 135 119 116 111 characters
(109 character code + 1 character command line option + 1 character input.)
s/.*/abcdefghijklmnopqrstuvwxyz/
h;H;G;H;G;H;g;G
s/.{,28}/\u&/gp
s/$/\t/
:;s/(\w+\n?)\t(.*)/\t\2\1/;t
s/.*Z//

Sample run:
bash-4.3$ sed -rf mexican.sed <<< '' | head
Abcdefghijklmnopqrstuvwxyz
aBcdefghijklmnopqrstuvwxyz
abCdefghijklmnopqrstuvwxyz
abcDefghijklmnopqrstuvwxyz
abcdEfghijklmnopqrstuvwxyz
abcdeFghijklmnopqrstuvwxyz
abcdefGhijklmnopqrstuvwxyz
abcdefgHijklmnopqrstuvwxyz
abcdefghIjklmnopqrstuvwxyz
abcdefghiJklmnopqrstuvwxyz

Jelly, 12 bytes
ØaFŒu⁹¦¥ⱮJŒḄ

Try it online!
ØaFŒu⁹¦¥ⱮJŒḄ
Øa             Lower case alphabet
       ¥       Combine the last two links into a dyad:
  F              Flatten   (1st link)
      ¦          At index... (2nd link)
     ⁹             right argument to the dyad defined by ¥...
   Œu              Make upper case.
        Ɱ      Do the dyad defined by ¥ at each element of the right argument:
         J     [1...26] (len of the alphabet)
               This gives ["Abc..", "aBc...",... ,"...xyZ"]
          ŒḄ   Bounce. i.e. take the list above, remove the last element, reverse
               and append to the original argument.
               This leaves a list of lines which can be printed properly with Y.

How does this work?

@lirtosiast just added an explanation. Let me know if anything is unclear

jq -nr, 77 72 70 bytes
The first part up to min is taken from manatwork's answer
range(51)|[.,50-.]|min|[. as$i|range(26)|.+(.-$i|.?/.*97//65)]|implode

Try it online!
Some comments:
range(51)|[.,50-.]|min generates a sequence of the indices of uppercase letters
|[ ... ] maps the inner part for each index and collects the results in one array for each index:
. as$x store current uppercase index in $x
range(26) range from 0 to 25
.+(.-$i|try./.*97//65) get the codepoint for that alphabet index, uppercase if it matches $x, lowercase if not. try./.*97 returns empty for 0/0, which gets replaced with 65 by //65 (I think that's how that works)
|implode converts each array of codepoints into a string

Nice! Unfortunately, I can't award a +50 bounty for this as I've already answered this.

jq -nr, 58 bytes
range(51)-25|fabs as$a|[range(26)+97]|.[25-$a]-=32|implode

Try it online with .*.|sqrt instead of fabs, or try it on https://jqplay.org/ with input "" and Raw output.

Here's a jqplay link: https://jqplay.org/s/vyrOcN12Jp

Batch - 284 bytes
@!! 2>nul||cmd/q/v/c%0&&exit/b
set a=&for /l %%a in (65,1,90)do (set/aa+=1,b=0&cmd/cexit %%a&set c=!=exitCodeAscii!&for /L %%b in (97,1,122)do set/ab+=1&cmd/cexit %%b&if !a!==!b! (set %%a=!%%a!!c!)else set %%a=!%%a!!=exitCodeAscii!
echo !%%a!)
for /l %%a in (89,-1,65)do echo !%%a!

Ungolfed:
@echo off
setLocal enableDelayedExpansion
set a=0
for /l %%a in (65,1,90) do (
    set /a a+=1,b=0
    cmd /c exit %%a
    set c=!=exitCodeAscii!
    for /L %%b in (97,1,122) do (
        set /a b+=1
        cmd /c exit %%b
        if !a!==!b! (
            set %%a=!%%a!!c!
        ) else set %%a=!%%a!!=exitCodeAscii!
    )
    echo !%%a!
)
for /l %%a in (89,-1,65) do echo !%%a!

To get the alphabets, this uses the !=exitCodeAscii! variable generated from new CMD instances (knowing that 65 to 90 is A to Z, and 97 to 122 is a to z). Just hard-coding the alphabets could very well be shorter, but this is much cuter.

Python 3, 103
a,l='abcdefghijklmnopqrstuvwxyz',list(range(26))
for i in l+l[24::-1]:print(a[:i]+a[i].upper()+a[i+1:])

or, without hardcoding alphabet:
l,a=list(range(26)),''.join(chr(i+97)for i in l)
for i in l+l[24::-1]:print(a[:i]+a[i].upper()+a[i+1:])

jq: 99 characters
(96 characters code + 3 characters command line option.)
"abcdefghijklmnopqrstuvwxyz"as$a|range(51)|[.,50-.]|min|$a[:.]+($a[.:.+1]|ascii_upcase)+$a[.+1:]

Sample run:
bash-4.3$ jq -n -r '"abcdefghijklmnopqrstuvwxyz"as$a|range(51)|[.,50-.]|min|$a[:.]+($a[.:.+1]|ascii_upcase)+$a[.+1:]' | head
Abcdefghijklmnopqrstuvwxyz
aBcdefghijklmnopqrstuvwxyz
abCdefghijklmnopqrstuvwxyz
abcDefghijklmnopqrstuvwxyz
abcdEfghijklmnopqrstuvwxyz
abcdeFghijklmnopqrstuvwxyz
abcdefGhijklmnopqrstuvwxyz
abcdefgHijklmnopqrstuvwxyz
abcdefghIjklmnopqrstuvwxyz
abcdefghiJklmnopqrstuvwxyz

On-line test (Passing -r through URL is not supported – check Raw Output yourself.)

Groovy, 99 88 78 77 bytes
((a='a'..'z')+('y'..'a')).each{println a.join().replace(it,it.toUpperCase())}

Thanks to manatwork for helping me trim off 11 21 bytes.

With some usual golfing tricks applied: 51.times{println(('a'..'z').join().replace((char)it=25-Math.abs(25-it)+97,(char)it-32))}

I'm new to golfing. I never thought about reassigning 'it' before. Thanks!

78 characters: ((a='a'..'z')+('y'..'a')).each{println(a.join().replace(it,it.toUpperCase()))} (Watch out when copying code from a comment. The site seems to insert some invisible multibyte characters in them. My previous code was 88 characters, not 90.)

Awesome. Way more elegant and easy to read as well. I had no idea you could add ranges. Learning something every day! I removed the parenthesis around println to lower one more byte.

C (208 characters)
(my first try at Code Golf)
#include<stdio.h>
#define P printf
#define A(i) {for(l='a',p=0;l<='z';++l,++p){if(p==i)P("%c",l-32);else P("%c",l);}P("\n");}
int main(){int i,p;char l;for(i=0;i<26;++i)A(i);for(i=24;i>=0;--i)A(i);return 0;}

Can you remove the space after A(i)? I program Java, but it seems like you could.

@MCMastery I don't think so since it's in a #define. It's defining A(i) to hold the value {for...;}, and the statement needs the space to differentiate symbol from value. (I think that's right but I could be wrong.)

@AlexA. Yes, that's right. The preprocessor needs the space to delimit the macro name from its definition.

106 bytes

building on @ceilingcat 90 bytes

><>, 48 bytes
Just playing around with the . operator more than anything else.
"a"&"a"::&:&=84**-o1+:"{"=6$.
=?;&30.~ao&1+:"{"

Python 2, 121 bytes
f=[];x=0
for i in[map(chr,range(97,123))]*26:l=i[:];l[x]=l[x].upper();f+=[''.join(l)];x+=1
print'\n'.join(f[:-1]+f[::-1])

This was weird one because of the need to make a copy of i.
For reference, here's the output without making a copy of i:
Abcdefghijklmnopqrstuvwxyz
ABcdefghijklmnopqrstuvwxyz
ABCdefghijklmnopqrstuvwxyz
ABCDefghijklmnopqrstuvwxyz
ABCDEfghijklmnopqrstuvwxyz
ABCDEFghijklmnopqrstuvwxyz
ABCDEFGhijklmnopqrstuvwxyz
ABCDEFGHijklmnopqrstuvwxyz
ABCDEFGHIjklmnopqrstuvwxyz
ABCDEFGHIJklmnopqrstuvwxyz
ABCDEFGHIJKlmnopqrstuvwxyz
ABCDEFGHIJKLmnopqrstuvwxyz
ABCDEFGHIJKLMnopqrstuvwxyz
ABCDEFGHIJKLMNopqrstuvwxyz
ABCDEFGHIJKLMNOpqrstuvwxyz
ABCDEFGHIJKLMNOPqrstuvwxyz
ABCDEFGHIJKLMNOPQrstuvwxyz
ABCDEFGHIJKLMNOPQRstuvwxyz
ABCDEFGHIJKLMNOPQRStuvwxyz
ABCDEFGHIJKLMNOPQRSTuvwxyz
ABCDEFGHIJKLMNOPQRSTUvwxyz
ABCDEFGHIJKLMNOPQRSTUVwxyz
ABCDEFGHIJKLMNOPQRSTUVWxyz
ABCDEFGHIJKLMNOPQRSTUVWXyz
ABCDEFGHIJKLMNOPQRSTUVWXYz
ABCDEFGHIJKLMNOPQRSTUVWXYZ
ABCDEFGHIJKLMNOPQRSTUVWXYz
ABCDEFGHIJKLMNOPQRSTUVWXyz
ABCDEFGHIJKLMNOPQRSTUVWxyz
ABCDEFGHIJKLMNOPQRSTUVwxyz
ABCDEFGHIJKLMNOPQRSTUvwxyz
ABCDEFGHIJKLMNOPQRSTuvwxyz
ABCDEFGHIJKLMNOPQRStuvwxyz
ABCDEFGHIJKLMNOPQRstuvwxyz
ABCDEFGHIJKLMNOPQrstuvwxyz
ABCDEFGHIJKLMNOPqrstuvwxyz
ABCDEFGHIJKLMNOpqrstuvwxyz
ABCDEFGHIJKLMNopqrstuvwxyz
ABCDEFGHIJKLMnopqrstuvwxyz
ABCDEFGHIJKLmnopqrstuvwxyz
ABCDEFGHIJKlmnopqrstuvwxyz
ABCDEFGHIJklmnopqrstuvwxyz
ABCDEFGHIjklmnopqrstuvwxyz
ABCDEFGHijklmnopqrstuvwxyz
ABCDEFGhijklmnopqrstuvwxyz
ABCDEFghijklmnopqrstuvwxyz
ABCDEfghijklmnopqrstuvwxyz
ABCDefghijklmnopqrstuvwxyz
ABCdefghijklmnopqrstuvwxyz
ABcdefghijklmnopqrstuvwxyz
Abcdefghijklmnopqrstuvwxyz

q (37 characters)
A first cut
@[.Q.a;;upper]'[(raze(|:\)til 26)_26]

@[.Q.a;;upper]@'x,1_reverse x:til 26 for 36 bytes. Or @[.Q.a;;.q.upper]@'x,1_|x:!26 for 29 bytes in K4.

K5, 47 bytes
(`0:)'{`c$(97+!x),(x+65),97+1_x_l}'l,1_|(l:!26)

More golfing to come shortly.

R, 60 59
cat(intToUtf8(c(x<-rbind(97:122-diag(26)*32,10),x[,25:1])))

Improvement based on the comment by @JayCe.

Former version:
x=rbind(97:122-diag(26)*32,10)
cat(intToUtf8(c(x,x[,25:1])))

This is based on ASCII codes that are transformed to characters.

Very nice solution +1

You can save one byte on your awesome solution. https://tio.run/##K/r/PzmxRCMzryQkP7QkzUIjWaPCRrcoKTMvRcPS3MrQyEg3JTMxXcPITFPL2EjH0EBTpyJax8jUyjBWU1Pz/38A

@JayCe Thanks for pointing out!

C - 110 bytes
Golfed
void f(){int i,n=0,c=0;for(;n<51;n++){for(i=0;i<26;i++)putchar((i==c)?i+65:i+97);c+=(n>24?-1:1);putchar(10);}}

Ungolfed
void f()
{
    int i,n,c=0;
    for(n=0;n<51;n++)
    {
        for(i=0;i<26;i++)
            putchar((i==c)?i+'A':i+'a');
        c+=(n>24?-1:1);
        putchar(10);
    }
}

Unnecessary parens in (i==c)?: and c+=(); if you use global variables they are initialized to 0 automatically; int is implicit (also don't use void).

Also save 2 more bytes by moving i++ and n++ to other uses of the variable, gives me 91 bytes.

@o11c - thanks for these 2 tips I'd long since forgotten.

R 72
Since there are no R answers:
a=function(i){l=letters;l[i]=toupper(l[i]);l};for(i in c(1:26,25:1))cat(a(i),'\n',sep='')

There is already an R answer, but yours beats it if you make the function anonymous: for(i in c(1:26,25:1))cat(\[<-`(letters,i,LETTERS[i]),'\n',sep="")`

Short and sweet, very cool!

Scala - 103
(0.to(25)++24.to(0,-1))map{i⇒val a=(97+i)toChar;println('a'to('z')mkString("")replace(a,a.toUpper))}

Some fun postfix operator abuse.

Charcoal, 24 12 9 bytes
Ｅββ↑↗α‖Ｏ↑

-12 bytes thanks to @ASCII-only.
-3 bytes thanks to @Neil.
Try it online (verbose) or try it online (pure).
Explanation:
Print the lowercase alphabet with newline delimiter 26 times:
Print(Map(b, b));
Ｅββ

Move up once:
Move(:Up);
↑

Print the uppercase alphabet in an up-right direction:
Print(:UpRight, a);
↗α

Reflect everything upwards horizontally with one line overlap:
ReflectOverlap(:Up);
‖Ｏ↑

16 maybe?

13? 13 using for, also 13

12 :D

@ASCII-only I was just done editing the page, lol.. Here we go again. Thanks though! I knew this could be golfed by a lot, but you've just halved it. :D

My original attempt was 13 bytes but after seeing your answer I golfed it down to 9 bytes.

@Neil Thanks! Didn't even knew about Map and that it could be used like this.

Well, Map returns an array, and the default output for an array is each element on its own line, which saves on explicit newlines!

VIM, 37 35 bytes
↵ is the enter key
:h<_↵jjYZZ51P25@='vUlj'↵26@='vUjh'↵

Canvas, 9 bytes
Ｚ＼──ｌｚ＊；ｎ

Try it here!
This also works in the latest version, but didn't before this commit (..yes it was used), so the link is to an older version of Canvas.
Explanation:
Z\--lz*;n
Z          push the uppercase alphabet
 \         create a diagonal out of that
  --       palindromize vertically with 1 overlap
    l      get the height of that
     z*    and repeat the lowercase alphabet vertically that many times
       ;n  overlap the diagonals over the lowercase block of alphabet

unfortunately Ｚ＼─ｌｚ＊；ｎ doesn't work as Canvas is too smart and replaces the V in the upside down version with a ^..

Came up with a(longer) different version: Ｚ＼ｚ┌ｌ；┐＊；ｎ

@Razetime that doesn't do the vertical palendromizing. And you could've done ‾¶ instead of ┌ｌ；┐

works, but not palidromized

PowerShell, 53 bytes
0..25+24..0|%{($s=[char[]](97..122))[$_]-=32;-join$s}

Try it online!
Each iteration makes a fresh array of a-z, capitalizes the correct one by shifting its ASCII value, then joins it into a proper line

try this 0..25+24..0|%{([char[]]$s=97..122)[$_]-=32;-join$s} :)

@mazzy Your version doesn't capitalize the first A -- Try it online!

very interesting! Thanks. sceenshot from VS Code and Pure Powershell: https://photos.app.goo.gl/RycqsKGLJinRpnW68

Why? Any ideas?

ps5.1, pwsh 6.0.2, pwsh 6.1.0-preview4 for Linux, VS Code Integrated Console 6.0.2 doesn't capitalize the first A. Ok, assume it's special behavior of VS Code Integrated Console 5.1. Why they doesn't capitalize?

I've found a computer with Windows 7 PS2.0: It capitalize nothing. Curiouser and curiouser! cried Alice https://photos.app.goo.gl/L6L1627JAau9zNGe7

Well that's very bizarre to say the least.

C# (Visual C# Interactive Compiler), 81 bytes
int i,j;for(;i<1376;j=++i%27)Write((char)(j>25?10:j+(i/27==j|i/27==50-j?65:97)));

Try it online!
My answer uses a similar strategy to this C answer, but I came up with it independently.
For the heck of it, here is a solution that decrements the loop variable, (like the C solution), but it is not quite as short as the solution that increments.
C# (Visual C# Interactive Compiler), 86 bytes
for(int i=1377,j;i-->0;)Write((char)((j=i%27)<1?10:(i/27==j+24|i/27==26-j?91:123)-j));

Try it online!

Vimscript - 41 bytes/keystrokes
ia<Esc>qqylp<C-a>q24@qY51pk^qw~jq25@whqs~hjhq25@s

Make sure that alphabet increment is enabled:
set nrformats+=alpha

Explanation:
ia<Esc>qqylp<C-a>q24@q writes down the alphabets from 'a' to 'z'.
Y50p copies the line and paste it 50 times.
k^ moves cursor to letter 'a' on the first line.
qw~jq starts recording, changes the 'a' to uppercase moves the cursor down and stops recording
25@w replays the record 25 times
hqs~hjhq starts recording, moves the cursor to 'y', changes 'y' to uppercase moves the cursor down left and stops recording
25@s replays the record 25 times

Welcome to the site, and nice first answer! We typically score vim by keystrokes (counting e.g. <Esc> as 1 keystroke/byte) and by my count this is 41keystrokes. Also, check out our Tips for golfing in Vim page for ways you can golf your code

@cairdcoinheringaahing thank you for the feedback, I'll check out the tips too!

Vyxal j, 11 bytes
kaømƛ:⇧ka∇V

Try it Online!
ka          # Lowercase alphabet
  øm        # Palindromised
    ƛ       # Map...
     :   ∇V # Replace that character
      ⇧     # With its uppercase
       ka   # In the lowercase alphabet

jq -nr, 93 89 bytes
[range(26)+97]|. as$a|range(51)|[.,50-.]|min|$a[:.]+($a[.:.+1]|[.[]-32])+$a[.+1:]|implode

Try it online!
porting manatwork's idea.
-4 bytes from ovs.
jq -nr, 95 bytes
[range(26)+97]|implode|. as$i|./""|[.[]as$j|$i|sub($j;$j|ascii_upcase)]|.+reverse[1:]|join("
")

Try it online!
removing the variables might increase the size. Having explicit references is useful sometimes.
-n is for no input.
-r is to output the string raw. Otherwise it is printed with \n instead of actual newlines.

If you move implode to the end, can you save a few bytes by using .-32 instead of ascii_upcase? I couldn't get it to work but I have no experience with this language

i'm not perfect sure how manatwork's answer works myself. i will tell you if i manage to get it right

@ovs got it working!

Mathematica, 104 bytes
FromCharacterCode[#~Join~Rest@Reverse@#]<>""&[{##,10}&@@@(97~Range~122~Table~{26}-32IdentityMatrix@26)]

F# - 141
This is my first try in F#. I would love some feedback :)
[97..122]@List.rev [97..121]|>Seq.iter(fun x->[97..122]|>Seq.map(fun y->(char(y-if x=y then 32 else 0)))|>System.String.Concat|>printfn "%s")

CJam, 26 bytes
26,:L_W<W%+{L'af+\_'A+tN}/

Try it online
Explanation:
26,     Create sequence [0 .. 25].
:L      Store it in variable for later reuse.
_       Copy.
W<      Slice off last element to get [0 .. 24]
W%      Reverse it to get [24 .. 0]
+       Concatenate to get [0 .. 25 .. 0]
{       Loop over position list.
  L'af+   Build [a .. z] by adding 'a to previously saved [0 .. 25]
  \_      Pop position to top, and copy it.
  'A+     Calculate upper case letter by adding 'A to position.
  t       Store upper case letter in sequence.
  N       Add a newline.
}/      End loop over position list.

C++, 151 146 142
Golfed:
#include <iostream>
int main(){int a=1,b=0,j;while(b>-1){for(j=0;j<27;j++){std::cout<<(char)(j>25?'\n'j:j==b?'A'+j:'a'+j);}b+=a;b>24?a=-1:a;}}

Ungolfed:
int main(){
    int a=1,b=0,j;
    while(b>-1) {
        for(j=0;j<27;j++){
            std::cout << (char)(j>25?'\n':j==b?'A'+j:'a'+j);
        }
        b+=a;
        b>24?a=-1:a;
    }
}

Clojure, 125 (ugh)
(map println(map #(apply str(replace{(char(+ %(int\a)))(char(+ %(int\A)))}%2))(range 26)(repeat 26(map char(range 97 123)))))

F#: 114 characters
Simple, and a little naïve -- can't really think of any other way to shorten the technique I used here. I'm sure there's a different approach that would be shorter.
Seq.map(fun i->(for c in 97..122 do printf"%c"(char(if c=i then c-32 else c)));printfn"")<|[97..122]@[122..-1..97]

Explanation: iterate the alphabet twice (forward then backwards) with Seq.map ... [97..122]@[122..-1..97], the printing the alphabet each time but with the current character capitalized.

Java, 159 158 bytes
class A{public static void main(String[]a){for(int b=0;b++<51;)for(int c=70;c++<96;)System.out.print((char)(c+(96-Math.abs(b-26)==c?-6:26))+(c>95?"\n":""));}}

Online demo
Try it online
Explanation
class A {
    public static void main(String[] a) {
        // loop the alphabet two times (2 x 26)
        for (int b = 0; b++ < 51;) {
            // loop from lower character ASCII codes a (97) to z (122)
            // c will be from [71 to 96] (because of condition "c++" before the first iteration)
            for (int c = 70; c++ < 96;) {
                System.out.print(
                    // print character by ASCII code
                    (char)(c + (
                        // if character position matches the wave
                        96 - Math.abs(b - 26) == c
                        // substract 6, because 71 - 6 = 65 = 'A'
                        ? -6
                        // otherwise add 26, because 71 + 26 = 97 = 'a'
                        : 26)
                    ) +
                    // if current character is greater then the 'y' (ASCII 95), also print a new line
                    (c > 95 ? "\n" : "")
                );
            }
        }
    }
}

Perhaps there's too much math in this. Someone who can shorten this?

I know it's been almost three years, but you can golf 8 bytes like this: interface A{static void main(String[]a){for(int b=0,c;b++<51;)for(c=70;c++<96;)System.out.printf("%c%s",96-Math.abs(b-26)==c?c-6:c+26,c>95?"\n":"");}}. Summary of changes: class to interface so you can remove public; int b=0; and int c=70; to int b=0,c; and c=70;; System.out.print((char)(...)+(...)); to System.out.printf("%c%s",...,...);; c+(...?-6:26) to ...?c-6:c+26 to get rid of the parenthesis. Try it online: 150 bytes. nice answer though, +1 from me. :)

Kotlin, 121 bytes
Array(26){"abcdefghijklmnopqrstuvwxyz"}.mapIndexed{i,s->s.replace(s[i],s[i]-32)}.let{it+it.reversed()}.forEach(::println)

Try it online!
Generates array of alphabet string with alphabet size, and then replacing characters to uppercase characters, after concacts resulting list and its reversed version.

nice ::println

K (ngn/k), 27 26 bytes
-1 byte from using @ngn's approach
x,1_|x:`c$97++(!26)-32*=26

Try it online!

=26 build a 26-by-26 unit matrix (with 1's on the main diagonal)
+(!26)-32* convert to matrix of offsets from "a" (e.g. -32 => "A", 1 => "b", etc.)
`c$97+ convert offsets to actual characters
x,1_|x: "mirror" the result vertically

-1 byte: x,1_|x:`c$97++(!26)-32*=26

Python - 272 bytes
a=range(97,123)
d=False
i=0
while True:
    if d and i>24:
        i-=1
        continue
    for (x,l) in enumerate(a):
        print(chr(l) if x!=i else chr(l-32),end='')
    i-=1 if d else -1
    if i<0:
        break
    if i>26:
        i=25
        d=True
    print()

Try it online!
My first attempt at codegolf, so it definitely could be smaller.

Welcome to Code Golf! You may want to check out the Tips for golfing in Python.

Zsh, 48 bytes
b=({a..z})
for n ($b {y..a})<<<${(j::)b/$n/$n:u}

Try it online!
Similar to the bash solution but using zsh substitutions.

Vim, 33 bytes
:h<_
jjYZZ51Pqr~jq25@rqlh~hjq24@l

Try it online!
Explanation
More or less combines the approaches of the two existing Vim answers, saving a couple of bytes along the way.
:h<_
jjYZZ

Yank the lowercase alphabet from the help file.
51P

Paste it 51 times, leaving the buffer's original empty line at the end.
qr~jq

Record macro r: swap case of the current letter and move right (~), then move down one row (j).
25@r

Run macro r 25 more times.
qlh~hjq

Record macro l: move left (h), swap case of the current letter and move right (~), move left again (h), and move down one row (j).
24@l

Run macro l 24 more times.

Vyxal jr, 8 bytes
kA∞ƛ⇩kaV

Try it Online!

Dyalog APL, 23 bytes
↑{1⎕C@⍵⎕C⎕A}¨(⍳26),⌽⍳25

Attempt This Online!
                    ⍳25  integers from 1 to 25
                   ⌽     reverse
                  ,      join with
             (⍳26)       integers from 1 to 26
 {         }¨            for each integer n
         ⎕A               uppercase alphabet
       ⎕C                 casefold
  1⎕C                     convert to uppercase
     @                    at
      ⍵                   index n
↑                        convert nested vector to simple matrix

Java: 918 characters
public class Sample{

    public static int i;

    public static int j;

    public static int z;

    public static String[] k={"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};

public static void main(String args[]){
        for (i=0; i<k.length;i++){
            for(j=0 ;j<k.length;j++){
                if (i==j){
                System.out.print(k[j].toUpperCase());
                }
                else
                System.out.print(k[j].toLowerCase());
            }
            System.out.println();
            }
        for (i=1; i<k.length;i++){
            for(j=0 ;j<k.length;j++){
                if (i==(k.length-(j+1))){
                System.out.print(k[j].toUpperCase());
                }
                else
                System.out.print(k[j].toLowerCase());
            }
            System.out.println();
        }
        }
}

Welcome to PPCG! This is code golf, so the goal is to solve the problem with as few bytes of code as possible. For a start you could get rid of all the unnecessary whitespace amd braces.

ECMAScript 6 - 114 110 characters
(112 108 + 2 linebreaks)
b=(c,d)=>c<26?String.fromCharCode(c==d?c+65:c+97)+b(c+1,d):""
a=i=>b(0,i)+(i?"\n"+a(i-1)+"\n"+b(0,i):"")
a(25)

Two recursive functions a and b:

b creates an alphabet string with the letter at index d capitalized.  Doesn't take very much advantage of recursion, but fat arrows make this function just a tiny bit shorter than a loop.
a creates line by line anagrams (sort of) of the strings generated by b

EDIT:  Woops!  The capitalization is backwards ('z' is capitalized on the first and last line, 'a' in the middle)

Haskell 128 Bytes
import Data.Char
a c=take 701(cycle(toUpper:replicate c id))
f=zipWith($)(a 27++drop 27(a 25))$cycle(['a'..'z']++"\n")
g=f++"z"

Not as short as the others but a very different approach. Defines the constant g as the string. save to a file and open interactively using ghci <filename>. Then enter g to the repl.

Haskell, 78 bytes
mapM_ putStrLn[['a'..toEnum(x-2)]++toEnum(x-33):[toEnum(x)..'z']|x<-[98..123]]

This code takes for all 'numbers, x from 'a'(+1) to 'z'(+1):

the letters from a to the letter corresponding to x-2
the letter x-33 (x-1 uppercased)
the letters from the letter corresponding to x
It concatenes them. We have the list of the strings. We print it.

Python 3, 103 characters
a="abcdefghijklmnopqrstuvwxyz"
for i in range(51):
 x=25-abs(25-i)
 print(a.replace(a[x],a[x].upper()))

Why calculating len(abc) 3 times? It will be always 26. See Tips for golfing in Python for a couple of hints to reduce code size. (By the way, the code you posted has only 141 bytes according to UTF-8 string length & byte counter.)

You keep being one step behind yourself: you fixed the count as 141 and reduced your code to 121 characters.☺ Given that you use long variable name and unnecessarily deep indentation, Tips for golfing in  may also give you a few golfing hints. And one hint for this particular case: count from 0. That way you can use range(51) and x=25-abs(25-i), which are shorter.

manatwork, thanks for all the advice, i was taking the size displayed at the file system, instead of the character count.

Yabasic, 93 bytes
An anonymous function that takes no input and outputs to the console.
For i=-25To 25
For j=-25To 0
s$=Chr$(122+j)
If j=-abs(i)Then s$=Upper$(s$)Fi
?s$;
Next
?
Next

Try it online!

Alternate Solution, 93 bytes
For i=-25To 25
For j=-25To 0
s$=Chr$(122+j)
If j+abs(i)Then?s$;Else?Upper$(s$);Fi
Next
?
Next

Try it online!

dc, 83 bytes
97sj1sxBDsy[32-]sU[liddlj=UP1+dsiBD>I]sI[97silIxAPljlx+dsjly!=J]dsJx_1sx96syBBsjlJx

Try it online!
Bit chunkier than I would have liked. Ultimately we're going to use two macros, I and J, and they're going to use some counters, i and j. The counters are decimal values converted to ASCII for printing. Macro I  ([liddlj=UP1+dsiBD>I]sI)handles printing one line of the alphabet, letter at a time, checking each letter to see if it matches and running macro U ([32-]sU) to uppercase if need be. It runs until it hits 123, just past the letter 'z'. Macro J ([97silIxAPljlx+dsjly!=J]dsJx) resets i to the beginning of the alphabet, runs I, prints a linebreak (AP), adds the value of x to j, and keeps running as long as it doesn't match the value of y. The first time we run it, x is positive 1 and y is 123, so we increment until we're past the letter 'z'. After doing that, we put j back down to 121 (after ...xyZ we're supposed to print ...xYz and not a second ...xyZ), and set x to negative 1 and y to 96, running J with a decrement and lower bound just below the letter 'a'.

Japt v1.4.5 -R, 12 bytes
;C¬ê £CrX,_u

Try it online!
Somehow tied with top Pyth submission.
Unpacked & How it works
;Cq ê mX{CrX,Z{Zu
;                  Use alternative set of initial variables
 C                 "abc...z"
  q ê              Split into chars and palindromify [a,b,...,z,...,b,a]
      mX{          Map...
         CrX,Z{Zu    Replace the char X in C into uppercase

-R                 Join with newline

11 bytes

Alternative 11 bytes, if you want to stick with r.

Python 2, 107 bytes
a='abcdefghijklmnopqrstuvwxyz'
for c in range(51):
i=25-abs(25-c)
print a[:i]+a[i].upper()+a[i+1:]

the diagonals go forwards & back in the output. You're only outputting half of the required output.

Oh, My bad. Ill edit it

MS-SQL, 135 bytes
WITH t AS(SELECT-25n UNION ALL SELECT n+1FROM t WHERE n<25)SELECT
STUFF('abcdefghijklmnopqrstuvwxyz',26-ABS(n),1,CHAR(90-ABS(n)))FROM t

Inspired largely by MickyT's postgreSQL solution, but since we can't use generate_series, we use a CTE to create a number table, and use STUFF to replace each character.

Python 3, 88 bytes
a=list(range(26));[print(''.join([chr([97+x,65+x][x==i])for x in a]))for i in a+a[::-1]]

Try it online!

VBA, 80 bytes
A script that takes no input and outputs to the console.
For i=-25To 25:For j=-25To 0:s=Chr(122+j):?IIf(j+Abs(i),s,UCase(s));:Next:?:Next

Lua, 96 bytes
for j=1,51 do for i=1,26 do io.write(string.char(i+((j+i==52or i==j)and 64or 96)))end print()end

Try it online!

for j=1, 51 do -- a to z (26) + y to a (25), because the Z doesn't repeat
  for i=1, 26 do -- for each letter
     io.write(string.char(i+((j==52-i or j==i) and 64 or 96))) -- ↴
     io.write(string.char(i+(                               )) -- writes the character represented by the value i+(...) on the ASCII table
                             (j==52-i or j==i)                 -- if the uppercase letter is equal to i or to 52-i
                                               and 64 or 96    -- then sum 64 else sum 96 (because 'A' is 65 and 'a' is 97)
  end
  print() -- jumps to the next line
end

If you have any questions, feel free to ask!

Excel, 101 bytes
Using Immediate Window and Output in CellA1:A51
[A1:A51]="=SUBSTITUTE(""abcdefghijklmnopqrstuvwxyz"",CHAR(122-ABS(ROW()-26)),CHAR(90-ABS(ROW()-26)))"

05AB1E, 12 9 bytes
AûvAyDu:,

The existing 05AB1E answer got deleted for some reason, so I decided to post a new one.
-3 bytes thanks to @dzaima.
Try it online.
Explanation:
A           # Push the lowercase alphabet: "abcdefghijklmnopqrstuvwxyz"
 û          # Palindromize it: "abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba"
  v         # Loop over each of its characters `y`
   A        #  Push the lowercase alphabet
    y  :    #  Replace the current lowercase letter `y`,
     Du     #  with it's uppercase variant
        ,   #  Print the modified alphabet with trailing newline

Japt -R, 11 bytes
;C¬£ChYXuÃê

Test it

ARM Thumb-2 (with libc), 54 bytes
f7ff fffe is a 4 byte linker placeholder for puts.
Machine code:
b5fe 466f 241a 3c01 f104 0161 5539 d1fa
76bc 0038 0025 2d1a d009 bf88 f1c5 0533
5d46 f006 025f 5542 f7ff fffe 557e 3401
2c34 d3ee bdfe

Commented assembly:
        .thumb
        .arch armv6t2
        .globl main
        .thumb_func
main:
        // Create a 27 byte buffer on the stack by doing a massive push
        // 27 is for the buffer, 1 is padding, and the last is the link register
        // to return from main.
        push    {r1, r2, r3, r4, r5, r6, r7, lr}
        // Create a frame pointer in r7, since sp lacks narrow register offset
        // addressing.
        mov     r7, sp
        // Fill the stack buffer with "abcdefgh....\0"
        movs    r4, #26
.Lfill_loop:
        subs    r4, #1
        add.w   r1, r4, #'a' // wide
        strb    r1, [r7, r4]
        bne     .Lfill_loop
.Lfill_loop_end:
        // r4 is zero now. Serves as both a null terminator and a loop counter.
        // Null terminate the string.
        strb    r4, [r7, #26]
        // The print loop
.Lprint_loop:
        // Load buffer into r0 for puts
        movs    r0, r7
        // Make a copy of r4 into r5
        movs    r5, r4
        // Compare to 26.
        cmp     r5, #26
        // If equal, skip to prevent printing Z twice
        beq     .Lskip_double_Z
        // If r5 is > 26 change it to 51 - r5 to reverse the order.
        it      hi
        rsbhi   r5, #51 // wide
        // Load the byte from the stack
        ldrb    r6, [r0, r5]
        // toupper(r6) -> r6 & 0x5f
        and.w   r2, r6, #0x5f // wide
        strb    r2, [r0, r5]
        // Call puts on our modified buffer
        bl      puts
        // Reset the char we modified.
        strb    r6, [r7, r5]
.Lskip_double_Z:
        // Loop 52 times.
        adds    r4, #1
        cmp     r4, #52
        blo     .Lprint_loop
.Lloop_end:
        // restore stack (clobbering all registers but bionic libc seems to be
        // fine with this) and return by popping the link register into pc.
        pop     {r1, r2, r3, r4, r5, r6, r7, pc}

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