43
\$\begingroup\$

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.

\$\endgroup\$
13
  • 40
    \$\begingroup\$ Seriously, another alphabet challenge? \$\endgroup\$ Aug 9, 2016 at 23:33
  • 6
    \$\begingroup\$ @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.) \$\endgroup\$ Aug 9, 2016 at 23:34
  • 14
    \$\begingroup\$ 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. \$\endgroup\$
    – Dennis
    Aug 9, 2016 at 23:35
  • 9
    \$\begingroup\$ @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. \$\endgroup\$ Aug 9, 2016 at 23:40
  • 16
    \$\begingroup\$ It's clear there's no more demand for alphabet challenges - only 39 people answered in the first 15 hours... \$\endgroup\$ Aug 10, 2016 at 15:23

95 Answers 95

2
\$\begingroup\$

jq -nr, 41 bytes

range(26)|[(.+range(26)%2)%26+65]|implode

Try it online!

\$\endgroup\$
1
\$\begingroup\$

MATLAB, 47 38 bytes

a=(65:90)';char(repmat([a a([2:end 1])],1,13))

char(repmat([65:90;[66:90 65]]',1,13))

The first makes a column array of the alphabet in ASCII, appends a shifted copy as a column to its right, replicates the resulting 26*2 array 13 times columnwise, casts to a character array and prints by default.

The second makes a 2*26 array of alphabet and shifted alphabet, transposes it then continues as above.

\$\endgroup\$
2
  • \$\begingroup\$ You can save one byte using [... ''] instead of char(...). \$\endgroup\$
    – pajonk
    Aug 10, 2016 at 15:56
  • \$\begingroup\$ And you can use simply [65:90;66:90 65] saving two bytes. \$\endgroup\$
    – pajonk
    Aug 10, 2016 at 16:02
1
\$\begingroup\$

Neoscript, 59 bytes

a=('A:[]:'Z)+'Aeach n=0:[]:25console:log((a[n]+a[n+1])*13);
\$\endgroup\$
1
\$\begingroup\$

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

enter image description here

\$\endgroup\$
1
\$\begingroup\$

PHP, 102 bytes

<?php $a='ABCDEFGHIJKLMNOPQRSTUVWXYZA';$i=-1;while($i++<25){echo str_repeat(substr($a,$i,2),13)."\n";}
\$\endgroup\$
1
  • \$\begingroup\$ You can remove the quotes from the Alphabet string. Replace \n with an actual enter instead of \n. Stole that idea from @insertusernamehere. So check his answer for what I mean. Edit: Also use the short-tag notation <?. You also do not need a space after <?. So <?$a='ABC' also works. \$\endgroup\$
    – Jeroen
    Aug 15, 2016 at 10:40
1
\$\begingroup\$

Ruby, 41 bytes

26.times{|i|puts [*?A..?Z,?A][i,2]*''*13}
\$\endgroup\$
1
\$\begingroup\$

PHP, 65 bytes

Well, this is pretty straight forward:

for(;$i<26;)echo str_repeat(chr(65+$i).chr(65+(++$i%26)),13)."
";
\$\endgroup\$
1
\$\begingroup\$

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.

\$\endgroup\$
1
\$\begingroup\$

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.

\$\endgroup\$
4
  • 1
    \$\begingroup\$ Did it save you four bytes yesterday? \$\endgroup\$
    – Leaky Nun
    Aug 10, 2016 at 0:51
  • 1
    \$\begingroup\$ _=>[...s="ABCDEFGHIJKLMNOPQRSTUVWXYZ"].map((c,i)=>(c+s[-~i%26]).repeat(13)).join`\n` \$\endgroup\$
    – Leaky Nun
    Aug 10, 2016 at 0:52
  • \$\begingroup\$ @LeakyNun No, just two, I'm afraid: codegolf.stackexchange.com/a/89297/17602 \$\endgroup\$
    – Neil
    Aug 10, 2016 at 7:57
  • 2
    \$\begingroup\$ The (c,i,a) is watching you. \$\endgroup\$
    – gcampbell
    Aug 10, 2016 at 8:18
1
\$\begingroup\$

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!

\$\endgroup\$
1
\$\begingroup\$

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));
    }
  }
}
\$\endgroup\$
1
\$\begingroup\$

Python 2 53 bytes

i=0;exec'print(chr(i+65)+chr(-~i%26+65))*13;i+=1;'*26
\$\endgroup\$
1
\$\begingroup\$

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"
\$\endgroup\$
1
\$\begingroup\$

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
\$\endgroup\$
1
\$\begingroup\$

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!

\$\endgroup\$
1
\$\begingroup\$

c64 basic v2, 95 93 85 83 77 bytes

0fOy=65to90:l$="":a$=cH(y)+cH(y+1+(y=90)*26)
1fOx=0to12:l$=l$+a$:nE:?l$:nE

Screenshot:

enter image description here

Trial instructions are in my previous answer.

\$\endgroup\$
2
  • \$\begingroup\$ 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? \$\endgroup\$
    – mkst
    Sep 13, 2017 at 21:25
  • 1
    \$\begingroup\$ @streetster Thanks! And I switched to conditional operator to avoid the if-then! :-) It is already 85. Screenshot follows. \$\endgroup\$
    – peterh
    Sep 13, 2017 at 21:34
1
\$\begingroup\$

Visual Basic .NET (Mono), 140 bytes

Module M
Sub Main
Dim I,J,S
For I=1To 26
S=""
For J=0To 11
S+=Chr$(I+64)+Chr$(I Mod 26+65)
Next
Console.WriteLine(S)
Next
End Sub
End Module

Try it online!

\$\endgroup\$
1
\$\begingroup\$

MY-BASIC, 77 bytes

For I=1 To 26
For J=0 To 12
Print Chr(I+64)+Chr(I Mod 26+65)
Next
Print;
Next

Try it online!

\$\endgroup\$
1
\$\begingroup\$

PHP, 78, 72, 67 bytes

<?php $s='A';while($s!='AA')echo str_repeat($s++.(--$s)[0],13)."
";

Try it online!

\$\endgroup\$
3
  • \$\begingroup\$ Instead of striking out old answers, just keep their bytecount in the header and strike those out. The revision history is sufficient in case you want to see older solutions. \$\endgroup\$
    – Timtech
    Jan 31, 2018 at 23:30
  • \$\begingroup\$ @Timtech good point, thank you, Sir :) \$\endgroup\$
    – Link
    Jan 31, 2018 at 23:32
  • \$\begingroup\$ Glad to help you out @Link, keep it up:) \$\endgroup\$
    – Timtech
    Jan 31, 2018 at 23:35
1
\$\begingroup\$

APL (Dyalog Unicode), 13 bytesSBCS

⍉(⎕a⌽⍨2|⊢)⌸⎕a

Try it online!

\$\endgroup\$
1
\$\begingroup\$

Charcoal, 15 bytes

E²⁶⎇﹪ι²α⁺ΦαμA⟲⁶

Link is to verbose version of code.

Try it online!

\$\endgroup\$
1
\$\begingroup\$

Knight, 34 bytes

;=a 65;W>90aO*+AaA=a+1a 13O*"ZA"13

Try it online!

Expanded code:

;=a 65
;WHILE > 90 a
  OUTPUT * (+(ASCII a) (ASCII (= a(+ 1 a)))) 13 
OUTPUT (* "ZA" 13)

There's probably a better way to deal with the last row, but I don't know it.

Another 34-byte solution:

;=a 0W>26aO*+A+65aA+65%=a+1a 26 13
\$\endgroup\$
0
\$\begingroup\$

Julia, 51 bytes

!()=join(["$x$(x+1-26(x>89))"^13for x='A':'Z'],"
")

Initial golfing.

\$\endgroup\$
0
\$\begingroup\$

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.

\$\endgroup\$
2
  • \$\begingroup\$ A language using instead of a literal newline is weird... \$\endgroup\$ Sep 30, 2016 at 16:01
  • \$\begingroup\$ 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. \$\endgroup\$ Oct 1, 2016 at 13:57
0
\$\begingroup\$

Pyke, 13 bytes

GGt\a+]w-*,_X

Try it here!

\$\endgroup\$
0
\$\begingroup\$

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();}
\$\endgroup\$
5
  • \$\begingroup\$ If you add A at the end of the alphabet you can change (i+1)%26 to i+1 \$\endgroup\$
    – Emigna
    Aug 10, 2016 at 14:49
  • \$\begingroup\$ The alphabet can also be var and you don't need the .ToCharArray() as a string is already just that. \$\endgroup\$
    – Emigna
    Aug 10, 2016 at 14:53
  • \$\begingroup\$ Oh, thank you! This was my first time code golfing, so I'm happy to learn more. \$\endgroup\$
    – aphariel
    Aug 10, 2016 at 14:56
  • \$\begingroup\$ Creating the row in a variable and replacing the inner for with a while saves at least 13 additional bytes. \$\endgroup\$
    – Emigna
    Aug 10, 2016 at 15:08
  • \$\begingroup\$ You can save a few bytes by using string interpolation like this: Console.Write($"{a[i]}{a[i+1]}") which makes it 135 bytes \$\endgroup\$
    – Jamie Rees
    Aug 10, 2016 at 15:42
0
\$\begingroup\$

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"))
\$\endgroup\$
0
\$\begingroup\$

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: Execution screenshot

\$\endgroup\$
0
\$\begingroup\$

Perl 6, 50 bytes

say .join x 13 for flat('A'..'Z','A').rotor(2=>-1)
\$\endgroup\$
0
\$\begingroup\$

C, 77 74 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

\$\endgroup\$
4
  • \$\begingroup\$ 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));} \$\endgroup\$
    – user54187
    Aug 10, 2016 at 8:33
  • \$\begingroup\$ Use puts("") instead of printf("\n") for printing a newline. \$\endgroup\$
    – owacoder
    Aug 10, 2016 at 12:30
  • \$\begingroup\$ @Advancid no you can't. that i%95 does not work \$\endgroup\$
    – Karl Napf
    Aug 10, 2016 at 15:39
  • \$\begingroup\$ @owacoder Ah, good old puts. Only had putchar in mind. \$\endgroup\$
    – Karl Napf
    Aug 10, 2016 at 15:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.