# 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? Jul 26 '15 at 5:46
• @Winny There is no input. The output is fixed. In fact, that's the general idea of kolmogorov-complexity questions. Jul 26 '15 at 5:49
• This has been in the HNQ list consistently since you posted it. Nice work. :) Jul 30 '15 at 20:25
• You can find a reference ungolfed Python implementation here. -> link's broken Aug 11 '17 at 22:48
• Franck Dernoncourt's point still stands. The link is broken. Jul 25 '18 at 20:18

# 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? Jul 31 '15 at 16:31
• If only the uppercase alphabet is represented by a lowercase letter...
– user92069
Feb 28 '20 at 13:25

# 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! Jul 31 '15 at 20:03

# 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… Jul 27 '15 at 11:15
• @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. Jul 27 '15 at 17:48
• Always got to love the BF answers ;) Jul 28 '15 at 7:33
• You didn't write this code directly now did you?
– BAR
Jul 30 '15 at 22:32
• I'm ashamed to say I did! Jul 30 '15 at 22:40

# 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
ret

rcx
3e
w
q


# Ruby: 716865 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 Jul 26 '15 at 18:20 • Doh. I tried a couple of dumb ideas to optimize e's reuse, but of course not the right way. Thank you, @Ventero. Jul 27 '15 at 7:59 ## Matlab, 6058 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. Jul 30 '15 at 8:58 • Also end-1 is a rather verbose way to write 25! Jul 30 '15 at 8:59 • @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 :-) Jul 30 '15 at 9:19 # 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 10089 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.

# 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 ⇒??? Jul 27 '15 at 23:35
• Both are valid :) Jul 28 '15 at 4:29
• 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 Jul 29 '15 at 11:59

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. Jul 29 '15 at 15:38

# 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? Jul 26 '15 at 11:46
• @manatwork nope I didn't know that, but now I do thanks Jul 26 '15 at 12:46

# Pyth - 18 17 bytes

First pass, probably can be made much shorter. Uses X to substitute and r1 to capitalize.

V+KU26t_KXGNr@GN1


# 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!)
– Lynn
Jul 27 '15 at 12:45
• @Mauris Thanks, I haven't thought of using monad = here. It's very nice! Jul 27 '15 at 13:44

# 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! Jul 27 '15 at 13:31
• char(ones(26,1)*[97:122] -eye(26)*32) Jul 29 '15 at 17:17
• @user3528438 how do you handle the second half? The code only computes the first half of the wave. You need to compute the rest. Jul 29 '15 at 17:18
• @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 :) Jul 29 '15 at 17:34
• @rayryeng yeah, it suprises me that the second half is harder to handle, and also how to avoid the center duplicate. Jul 29 '15 at 17:47

# 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, 8771 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. Jul 26 '15 at 14:07 • That string subscript is not really optimal: $i<25?$i:25-($i-25)25-abs($i-25) Jul 26 '15 at 14:16 • 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.) Jul 26 '15 at 14:28
• @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. Jul 26 '15 at 16:40
• Your for loop can be optimised: for(;$L=range(a,z),$L[25-abs($i++-25)]^=' ',$i<52;)echo join($L).'↵'; (-2 bytes). Jul 27 '15 at 22:20 ## 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? Jul 19 '16 at 23:47 • I have implemented a TIS emulator for TIO, so you can now try it online! May 2 '18 at 19:54 # 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() <pre id="p"></pre> # 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.  # 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 Jul 26 '15 at 23:15 • Save 1 byte by using write: tio.run/##K/r/… Jun 7 '18 at 18:16 # 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. Jul 30 '15 at 17:00
• Interesting. Then from where would the alphabet appear? Jul 30 '15 at 17:19
• I couldn't tell you. The edit simply removed the printf call. I rejected the edit, so you can test it yourself. Jul 30 '15 at 17:24
• 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. :( Jul 30 '15 at 17:27

# 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
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 :) Jul 30 '15 at 5:18
• I know and I did just that. Look at my other post codegolf.stackexchange.com/a/53984/42642 :) Jul 30 '15 at 12:23
• Yeah, seen it, upvoted it. Didn't notice it was you too though. Jul 30 '15 at 15:34

# 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


# C#, 140139135 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; Jul 28 '15 at 8:39
• You can save 3 bytes by changing var d=1 to int d=1,i. Aug 1 '15 at 15:55

# 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. Jan 27 '19 at 19:11

# Sed: 135119116 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


# 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? Jul 28 '15 at 3:43
• Maybe because you technically have multiple answers in a single post? Hell if I know, good shaving, though! Jul 29 '15 at 20:22
• Also, I think you can shave off that last semi-colon Jul 29 '15 at 20:23
• Nope, I was incorrect Jul 29 '15 at 20:26

# 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. Jul 27 '15 at 10:14 • 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,$/} Jul 27 '15 at 10:38
• @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! Jul 29 '15 at 17:32