# Print an alphabet wave

You are to print this exact text:

ABABABABABABABABABABABABAB
BCBCBCBCBCBCBCBCBCBCBCBCBC
CDCDCDCDCDCDCDCDCDCDCDCDCD
DEDEDEDEDEDEDEDEDEDEDEDEDE
EFEFEFEFEFEFEFEFEFEFEFEFEF
FGFGFGFGFGFGFGFGFGFGFGFGFG
GHGHGHGHGHGHGHGHGHGHGHGHGH
HIHIHIHIHIHIHIHIHIHIHIHIHI
IJIJIJIJIJIJIJIJIJIJIJIJIJ
JKJKJKJKJKJKJKJKJKJKJKJKJK
KLKLKLKLKLKLKLKLKLKLKLKLKL
LMLMLMLMLMLMLMLMLMLMLMLMLM
MNMNMNMNMNMNMNMNMNMNMNMNMN
NONONONONONONONONONONONONO
OPOPOPOPOPOPOPOPOPOPOPOPOP
PQPQPQPQPQPQPQPQPQPQPQPQPQ
QRQRQRQRQRQRQRQRQRQRQRQRQR
RSRSRSRSRSRSRSRSRSRSRSRSRS
STSTSTSTSTSTSTSTSTSTSTSTST
TUTUTUTUTUTUTUTUTUTUTUTUTU
UVUVUVUVUVUVUVUVUVUVUVUVUV
VWVWVWVWVWVWVWVWVWVWVWVWVW
WXWXWXWXWXWXWXWXWXWXWXWXWX
XYXYXYXYXYXYXYXYXYXYXYXYXY
YZYZYZYZYZYZYZYZYZYZYZYZYZ
ZAZAZAZAZAZAZAZAZAZAZAZAZA


# Specs

• You can print all lowercase instead of all uppercase. However, case must be consistent throughout the output.
• You may print one extra trailing linefeed.

# Scoring

Since this is an alphabet wave that fluctuates to a small extent, your code should also be small in terms of byte-count. In fact, the smallest code in terms of byte-count wins.

• Seriously, another alphabet challenge? – Nathan Merrill Aug 9 '16 at 23:33
• @NathanMerrill As numerous as they are, I don't think they are worthy of downvotes. (I do not imply you downvoted, I am merely saying.) – Conor O'Brien Aug 9 '16 at 23:34
• As long as the patterns are sufficiently different, I don't think it matters if we use the alphabet, decimal digits, asterisks and underscore, etc. – Dennis Aug 9 '16 at 23:35
• @Dennis regardless of the characters used, its these type of "pattern" challenges that are getting overused, IMO. I don't think its offtopic, but I would enjoy some fresh air. – Nathan Merrill Aug 9 '16 at 23:40
• It's clear there's no more demand for alphabet challenges - only 39 people answered in the first 15 hours... – trichoplax Aug 10 '16 at 15:23

# PHP, 65 bytes

Well, this is pretty straight forward:

for(;$i<26;)echo str_repeat(chr(65+$i).chr(65+(++$i%26)),13)." ";  # Oracle SQL 11.2, 141 138 bytes SELECT LISTAGG(CHR(l+64)||CHR(MOD(l,26)+65))WITHIN GROUP(ORDER BY l)FROM(SELECT CEIL(LEVEL/13)l FROM DUAL CONNECT BY LEVEL<339)GROUP BY l;  Un-golfed SELECT LISTAGG(CHR(l+64)||CHR(MOD(l,26)+65))WITHIN GROUP(ORDER BY l) FROM ( SELECT CEIL(LEVEL/13)l FROM DUAL CONNECT BY LEVEL<339 -- 26*13+1 ) GROUP BY l  # C#, 107 bytes My first attempt at a submission to PPCG Golfed: var l="";int i=0,j=0;for(;i<26;i++){for(;j<26;j++)l+=(char)(((j%2)+i)%26+65);Console.WriteLine(l);l="";j=0;}  Ungolfed: var l=""; int i=0,j=0; for(;i<26;i++){ for(;j<26;j++)l+=(char)(((j%2)+i)%26+65); Console.WriteLine(l); l="";j=0; }  Pretty sure this adheres to standards! Would love to hear any potential improvements. ## JavaScript (ES6), 88 83 bytes _=>[..."ABCDEFGHIJKLMNOPQRSTUVWXYZ"].map((c,i,a)=>(c+a[-~i%26]).repeat(13)).join\n  Where \n represents the literal newline character. Writing the alphabet out saved me three bytes today, but @LeakyNun saved me another five bytes. • Did it save you four bytes yesterday? – Leaky Nun Aug 10 '16 at 0:51 • _=>[...s="ABCDEFGHIJKLMNOPQRSTUVWXYZ"].map((c,i)=>(c+s[-~i%26]).repeat(13)).join\n – Leaky Nun Aug 10 '16 at 0:52 • @LeakyNun No, just two, I'm afraid: codegolf.stackexchange.com/a/89297/17602 – Neil Aug 10 '16 at 7:57 • The (c,i,a) is watching you. – gcampbell Aug 10 '16 at 8:18 # C (86 bytes): for(int c=-11,n=-26;++n<1;){while(c++){printf("%c%c",90+n,n?91+n:65);}c=-11;puts("");}  My first attempt on a Code Golf challenge. Some answers are really impressive! # Java 7, 87 bytes void c(){for(int i=0;i<703;)System.out.print((char)(i++%27>0?65+(i/27+i%27%2)%26:10));}  Based on @orlp's amazing answer. Ungolfed & test code: Try it here. class Main { public static void main(String[]a){ c(); } static void c(){ for(int i=0; i<703;){ System.out.print((char)(i++%27 > 0 ? 65 + (i/27+i%27%2)%26 :10)); } } }  # Python 2 53 bytes i=0;exec'print(chr(i+65)+chr(-~i%26+65))*13;i+=1;'*26  # T-SQL 99 90 bytes Saved 9 bytes thanks to @t-clausen.dk DECLARE @ INT=65z:PRINT REPLICATE(CHAR(@)+CHAR(IIF(@=90,65,@+1)),13)SET @+=1IF @<=90GOTO z Ungolfed: DECLARE @CurrCharacter INT = 65; --ASCII decimal for 'A' WHILE (@CurrCharacter <=90) --ASCII decimal for 'Z' BEGIN PRINT REPLICATE( REPLACE(CHAR(@CurrCharacter)+CHAR(@CurrCharacter+1),'[','A') ,13); --Replicate the current character and its neighbor 13 times. If the neighbor is '[' (ASCII code 91) then replace it with 'A'. SET @CurrCharacter+=1; --Go to the next letter END  • That is very nice, you can save another 9 bytes like this – t-clausen.dk Aug 29 '16 at 9:16 # Common Lisp, SBCL, 86 bytes (dotimes(i 26)(format t"~13@{~a~:*~}~%"(subseq"ABCDEFGHIJKLMNOPQRSTUVWXYZA"i(+ i 2))))  ### Explanation (dotimes(i 26);loop from i=0 to i=25 (format t"~13@{~a~:*~}~%"(subseq"ABCDEFGHIJKLMNOPQRSTUVWXYZA"i(+ i 2)))) ;print 13 times pairs of "AB", "BC", ... , "ZA"  # SOGL V0.12, 8 bytes Z«Z¹'⁰∙I  Try it Here! Explanation: Z push the uppercase alphabet « put its first letter at the end Z push the alphabet once again ¹ wrap in array: ["BCDEFGHIJKLMNOPQRSTUVWXYZA", "ABCDEFGHIJKLMNOPQRSTUVWXYZ"] '⁰∙ multiply vertically 13 times I rotate clockwise  # Bash, 64 bytes f()(tr A-Z B-ZA|tee >(((i++<25))&&f);echo) printf ZA%.s {a..m}|f  Credit to seshoumara's sed answer for the idea of translating A-Z to B-ZA. Try it online! ### c64 basic v2, 95938583 77 bytes 0fOy=65to90:l$="":a$=cH(y)+cH(y+1+(y=90)*26) 1fOx=0to12:l$=l$+a$:nE:?l$:nE  Screenshot: Trial instructions are in my previous answer. • can you switch out 0..25 for 65..90 in the first line? e.g. 0fOy=65to90:l$="":a$=chr$(y):b$=chr$(1+y):ify=90tHb$="a" for -3 bytes? – streetster Sep 13 '17 at 21:25 • @streetster Thanks! And I switched to conditional operator to avoid the if-then! :-) It is already 85. Screenshot follows. – peterh - Reinstate Monica Sep 13 '17 at 21:34 # Julia, 51 bytes !()=join(["$x$(x+1-26(x>89))"^13for x='A':'Z']," ")  Initial golfing. # RETURN, 23 bytes 'A'[␊'B'[␊'A␈13␋␄'␊°␇␂,  Try it here. NOTE: Use the "Insert String" button and paste the above code in. # Explanation Basically generates A-Z and B-Z and A at the end on the stack. Then the stack is duplicated 13 times, transposed, joined with a newline, and outputted. Due to a bug that I just can't fix, 'A'[␊${25@}13␋␄'␊°␇␂, does not work.

• A language using ␊ instead of a literal newline is weird... – Erik the Outgolfer Sep 30 '16 at 16:01
• No, I'm just putting it there to avoid confusion; newlines are range commands, so having ␊ there emphasizes that. It's the same with the other unprintables. – Mama Fun Roll Oct 1 '16 at 13:57

# Javascript (using external library Enumerable) (84 bytes)

    n=>(w=_.Range(0,26)).WriteLine(x=>w.Write("",y=>String.fromCharCode((x+y%2)%26+65)))


Link to lib: https://github.com/mvegh1/Enumerable/

Code explanation: Create a range of ints starting at 0 for count of 26. Store into global variable w. For each, write a new line according to predicate. Predicate states to take "w" and write a joined string based off the passed predicate to Write. Predicate to Write uses an empty string as the join delimiter, and uses the current integer value from WriteLine ("x") and the current integer value from Write ("y") to calculate the correct string at that position

Edit: Removed extra parens to save 2 bytes

## Pyke, 13 bytes

GGt\a+]w-*,_X


Try it here!

# C# - 159 138 bytes

var a="ABCDEFGHIJKLMNOPQRSTUVWXYZA";for(int i=0;i<26;i++){for(int j=0;j<14;j++){Console.Write("{0}{1}",a[i],a[i+1]);}Console.WriteLine();}

• If you add A at the end of the alphabet you can change (i+1)%26 to i+1 – Emigna Aug 10 '16 at 14:49
• The alphabet can also be var and you don't need the .ToCharArray() as a string is already just that. – Emigna Aug 10 '16 at 14:53
• Oh, thank you! This was my first time code golfing, so I'm happy to learn more. – aphariel Aug 10 '16 at 14:56
• Creating the row in a variable and replacing the inner for with a while saves at least 13 additional bytes. – Emigna Aug 10 '16 at 15:08
• You can save a few bytes by using string interpolation like this: Console.Write($"{a[i]}{a[i+1]}") which makes it 135 bytes – Jamie Rees Aug 10 '16 at 15:42 # JAVA 9, 103 97 bytes it works on JShell, provided by Java9 SDK. for(int c=64,i;++c<91;)for(i=0;i<26;)System.out.print((char)((c-13+i%2)%26+65)+(i++<25?"":"\n"))  ## ListSharp, 236 bytes ROWS x=ROWSPLIT "A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,T,S,U,V,W,X,Y,Z,A" BY [","] [FOREACH NUMB IN 1 TO 26 AS i] { STRG t ="" [FOREACH NUMB IN 1 TO 13 AS j] { STRG e=GETLINE x [i] STRG r=GETLINE x [i+1] STRG t=t+e+r } ROWS s=s+t } SHOW=s  Feel free to comment if you want anything to be explained to you Execution screenshot: # Perl 6, 50 bytes say .join x 13 for flat('A'..'Z','A').rotor(2=>-1)  # C, 7774 71 bytes Basically the same as the Python answer inspired by LeakyNun, Thanks to owacoder for puts : f(i,j){for(i=0;++i<27;puts(""))for(j=13;--j;printf("%c%c",i+64,i%26+65));}  Usage: f();  While mathematically (26-n)%26 == (-n)%26, this is not true for C, otherwise these two bytes can be shaved off. Using a count up loop for i resolves the problem • You can save two bytes by counting from 64: f(i,j){for(i=64;++i<91;printf("\n"))for(j=13;--j;printf("%c%c",i,i%91+65));} – user54187 Aug 10 '16 at 8:33 • Use puts("") instead of printf("\n") for printing a newline. – owacoder Aug 10 '16 at 12:30 • @Advancid no you can't. that i%95 does not work – Karl Napf Aug 10 '16 at 15:39 • @owacoder Ah, good old puts. Only had putchar in mind. – Karl Napf Aug 10 '16 at 15:40 # Java 8, 139 137 bytes ()->{for(int i=65,j=1;;j++){if(j>25){j=++i<91?1:0;System.out.println(); if(j==0)break;}System.out.print((char)i+""+(char)(i>89?65:i+1));}}  • chaning j==26 to j>25 allow you to save 1 byte. using multiple print statements when you are golfing in java cost you badly, and you could refactor it to use single print statement – user902383 Aug 10 '16 at 15:25 # EXCEL: 53 bytes =REPT(CHAR(ROW(A1)+64)&CHAR(MOD(ROW(A1),26)+65),13)  Place in A1 and drag to desired length of wave (in this case, 26, one cell for each letter). Improving on @gabe3886's answer (new account and not able to comment) ## PHP 94 92 Bytes <?php for($i=0;$i<26;)echo str_repeat(substr('ABCDEFGHIJKLMNOPQRSTUVWXYZA',$i++,2),13)."\n";


However if you suppress notices, it's 92 90 bytes

<?php for(;@$i<26;)echo str_repeat(substr('ABCDEFGHIJKLMNOPQRSTUVWXYZA',@$i++,2),13)."\n";

• Welcome to PPCG. You can golf this down to 79 bytes: for(;$i<26;)echo str_repeat(substr(ABCDEFGHIJKLMNOPQRSTUVWXYZA,$i++,2),13)."↵";. Replace ↵ with an actual line break. As an additional note: You don't need to include the PHP opening tag and you don't need to handle notices. – insertusernamehere Aug 10 '16 at 19:09
• You can even save another 6 bytes, with a total of 73 bytes: for(;$i<26;)echo str_repeat(substr(implode(range(A,Z)).A,$i++,2),13)."↵"; – insertusernamehere Aug 10 '16 at 19:20
• @insertusernamehere: Thanks! I wasn't too clear on the rules for this exchange (IE: does it include just functional code (no <?php tag) and/or would warnings be considered part of the output). I noticed in your second comment that range(A,Z) don't have the A and Z characters quoted. Is that abusing another PHP "feature"? – Wes Aug 10 '16 at 20:08
• Yes, I've removed the quotes in both suggestions. When you run a string without quotes it should prompt something like Notice: Use of undefined constant which is fine here. But be careful, this won't work on strings with whitespaces or special characters etc. – insertusernamehere Aug 10 '16 at 20:21
• Right. I remember now. PHP will assume it's the literal character "A"(or "Z" or whatever), which is the same reason "foo \$bar[baz]" interpolation works without the curly braces. – Wes Aug 10 '16 at 20:25

# Logo, 93 bytes

Here's a non-graphical Logo solution. Try it online with Calormen.com's interpreter.

to m:c type char 65+modulo:c 26end
to b:a repeat 13[m:a-1 m:a] pr" end
repeat 26[b repcount]


VIM, 42

:h<_↵↵↵YZZP:s/./&\r/g↵^25↑y↑pG2↑aa↓^ggy13P


where:

• ↵ is return,
• ^ is ctrl + v
• ↑ is the up arrow
• ↓ is escape

I'm sure this can be golfed more. I'm new to VIM so any suggestions are appreciated.

## Javascript(ES5), 107 99 bytes

for(var s="",i=-1;++i<676;)i&&!(i%26)&&(s+="\n"),s+=String.fromCharCode((i/26+i%2)%26+65);alert(s);

• console.log => alert. – NoOneIsHere Aug 10 '16 at 21:27
• Thanks for pointing that out! Made another small change as well. This is the part I'd really like to change "i&&!(i%26)", surely there's a better way of doing both checks here at once, or at least in a more concise way! I'd love any suggestions here! – ajxs Aug 10 '16 at 22:08

python 3, 92 90 bytes

a=65
b=66
for i in range(312):
if a>89:b=65
print(chr(a)+chr(b),end="")
if (i+1)%12<1:
a+=1
b+=1
print()


python 2, 80 bytes

a=65
b=66
for i in range(312):
if a>89:b=65
print chr(a)+chr(b),
if (i+1)%12<1:
a+=1
b+=1
print


This program outputs AB AB AB AB... rather than ABABABAB... I'm not sure if this is allowed, but it's the best I can come up with.

EDIT:

Thanks @User902383 for you comment on @TAsk's post allowing me to shave off 2 bytes.

And thanks @NoOneIsHere for suggesting that I move to python 2 instead of 3, I've included a second program in python 2 with a new byte count.

• You can remove the soace before b=65. – NoOneIsHere Aug 11 '16 at 3:11
• Thanks, I think I already had mentally omitted that when I counted it, just not taken it out of the code. Thanks anyway though. – sonrad10 Aug 11 '16 at 3:16
• If you switch to python 2, you can replace print() with print, and print(...,end='') to print ..., (trailing comma). – NoOneIsHere Aug 11 '16 at 3:21

# Scala, 64 bytes

Can anyone improve on this?

(('A'to'Z'):+'A').sliding(2).map(_.mkString*13).foreach(println)


# Python 2.7, 65 bytes

Python 2 alternative using a recursive function

def l(a=0):
print(chr(a+65)+chr(-~a%26+65))*13
if a<25:l(-~a)