44
\$\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.

asked Aug 9, 2016 at 23:29
\$\endgroup\$
13
  • 40
    \$\begingroup\$ Seriously, another alphabet challenge? \$\endgroup\$ Commented 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\$ Commented 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\$ Commented 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\$ Commented 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\$ Commented Aug 10, 2016 at 15:23

99 Answers 99

2
\$\begingroup\$

jq -nr, 41 bytes

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

Try it online!

answered Sep 10, 2021 at 12:02
\$\endgroup\$
2
\$\begingroup\$

Java, 80 bytes

v->{for(int i=0;i<703;)System.out.printf("%c",i++%27>0?65+(i/27+i%27%2)%26:10);}

Based on @orlp's amazing answer, so also has a leading newline character.

Try it online.

Explanation:

v->{ // Method with empty unused parameter and no return
 for(int i=0;i<703;) // Loop `i` in the range [0,703):
 System.out.printf("%c", // Print a character with the following codepoint:
 i++%27>0? // If `i` is NOT divisible by 27:
 // (and increase `i` by 1 with `i++` afterwards)
 65+(i/27+i%27%2)%26 // The codepoint of the current letter to print
 : // Else:
 10);} // The codepoint of a newline character instead
answered Aug 22, 2016 at 12:54
\$\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.

answered Aug 10, 2016 at 9:40
\$\endgroup\$
2
  • \$\begingroup\$ You can save one byte using [... ''] instead of char(...). \$\endgroup\$ Commented Aug 10, 2016 at 15:56
  • \$\begingroup\$ And you can use simply [65:90;66:90 65] saving two bytes. \$\endgroup\$ Commented 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);
answered Aug 10, 2016 at 13:34
\$\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

answered Aug 10, 2016 at 14:46
\$\endgroup\$
1
\$\begingroup\$

PHP, 102 bytes

<?php $a='ABCDEFGHIJKLMNOPQRSTUVWXYZA';$i=-1;while($i++<25){echo str_repeat(substr($a,$i,2),13)."\n";}
answered Aug 10, 2016 at 15:50
\$\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\$ Commented Aug 15, 2016 at 10:40
1
\$\begingroup\$

Ruby, 41 bytes

26.times{|i|puts [*?A..?Z,?A][i,2]*''*13}
answered Aug 10, 2016 at 16:08
\$\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)."
";
answered Aug 10, 2016 at 19:04
\$\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.

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

answered Aug 10, 2016 at 18:47
\$\endgroup\$
1
\$\begingroup\$

Python 2 53 bytes

i=0;exec'print(chr(i+65)+chr(-~i%26+65))*13;i+=1;'*26
answered Aug 22, 2016 at 16:13
\$\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"
answered Feb 16, 2017 at 22:31
\$\endgroup\$
1
\$\begingroup\$

Bash + Unix utilities, (削除) 53 (削除ここまで) 52 bytes

dc "-e65[d257*1+16 52^65535/*POP1+d91>x]dsxx"|tr [ A

Try it online!

Test run:

dc "-e65[d257*1+16 52^65535/*POP1+d91>x]dsxx"|tr [ A
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
answered Feb 17, 2017 at 3:59
\$\endgroup\$
1
\$\begingroup\$

SOGL V0.12, 8 bytes

Z«Z1'0∙I

Try it Here!

Explanation:

Z push the uppercase alphabet
 « put its first letter at the end
 Z push the alphabet once again
 1 wrap in array: ["BCDEFGHIJKLMNOPQRSTUVWXYZA", "ABCDEFGHIJKLMNOPQRSTUVWXYZ"]
 '0∙ multiply vertically 13 times
 I rotate clockwise
answered Sep 13, 2017 at 21:00
\$\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!

answered Sep 13, 2017 at 21:13
\$\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.

answered Sep 13, 2017 at 20:52
\$\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\$ Commented 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\$ Commented 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!

answered Jan 31, 2018 at 19:08
\$\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!

answered Jan 31, 2018 at 19:10
\$\endgroup\$
1
\$\begingroup\$

uBASIC, 83 bytes

0ForI=1To26:ForJ=0To12:?Left$(Chr$(I+64),1)+Left$(Chr$(IMod26+65),1);:NextJ:?:NextI

Try it online!

answered Jan 31, 2018 at 19:14
\$\endgroup\$
1
\$\begingroup\$

PHP, (削除) 78, 72, (削除ここまで) 67 bytes

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

Try it online!

answered Jan 31, 2018 at 22:56
\$\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\$ Commented Jan 31, 2018 at 23:30
  • \$\begingroup\$ @Timtech good point, thank you, Sir :) \$\endgroup\$ Commented Jan 31, 2018 at 23:32
  • \$\begingroup\$ Glad to help you out @Link, keep it up:) \$\endgroup\$ Commented Jan 31, 2018 at 23:35
1
\$\begingroup\$

APL (Dyalog Unicode), 13 bytesSBCS

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

Try it online!

answered Feb 1, 2018 at 0:10
\$\endgroup\$
1
\$\begingroup\$

Charcoal, 15 bytes

E26⎇%ι2α+ΦαμA⟲6

Link is to verbose version of code.

Try it online!

answered Sep 15, 2020 at 9:03
\$\endgroup\$
1
\$\begingroup\$

Pip -n, 18 bytes

(z.z)@>_@<2X13M,26

Pip doesn't have transpose, so I just took two letter substrings and repeated them.

-n joins lists with newlines.

Try it online!

answered Sep 15, 2020 at 9:50
\$\endgroup\$
1
\$\begingroup\$

Jelly, 10 bytes

ØA,Ɲẋ13ドルj7

Try it online!

Noncompeting probably because some of the atoms are new.

answered Jan 7, 2021 at 8:13
\$\endgroup\$
1
\$\begingroup\$

Zsh, 46 bytes

p=A
for c ({B..Z} A)<<<${(el:52::$p$c:)}&&p=$c

Attempt This Online!

answered Jun 16, 2022 at 11:13
\$\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
answered Aug 4, 2022 at 19:20
\$\endgroup\$
1
\$\begingroup\$

Vyxal j, 7 bytes

kAǏz13*

Try it Online!

kA # uppercase alphabet
 Ǐ # Append the first letter
 z # Get overlapping pairs
 13* # Repeat each 13 times
 # (j flag) join by newlines
answered Sep 10, 2021 at 11:40
\$\endgroup\$
1
\$\begingroup\$

Japt (削除) -R (削除ここまで), (削除) 11 (削除ここまで) 9 bytes

;By@BéÓYv

Test it

;By@BéÓYv
;B :Uppercase alphabet
 y :Transpose
 @ :Pass each row through the following function and transpose back
 Bé : Rotate the alphabet right this many times
 Ó : Bitwise not of the negation of
 Y : 0-based index
 v : Parity
answered Sep 10, 2021 at 11:54
\$\endgroup\$
0
\$\begingroup\$

Julia, 51 bytes

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

Initial golfing.

answered Aug 10, 2016 at 2:13
\$\endgroup\$

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.