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.
-
40\$\begingroup\$ Seriously, another alphabet challenge? \$\endgroup\$Nathan Merrill– Nathan Merrill2016年08月09日 23:33:12 +00:00Commented 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\$Conor O'Brien– Conor O'Brien2016年08月09日 23:34:07 +00:00Commented 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– Dennis2016年08月09日 23:35:42 +00:00Commented 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\$Nathan Merrill– Nathan Merrill2016年08月09日 23:40:33 +00:00Commented 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\$trichoplax is on Codidact now– trichoplax is on Codidact now2016年08月10日 15:23:58 +00:00Commented Aug 10, 2016 at 15:23
99 Answers 99
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.
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
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.
-
\$\begingroup\$ You can save one byte using
[... '']instead ofchar(...). \$\endgroup\$pajonk– pajonk2016年08月10日 15:56:58 +00:00Commented Aug 10, 2016 at 15:56 -
\$\begingroup\$ And you can use simply
[65:90;66:90 65]saving two bytes. \$\endgroup\$pajonk– pajonk2016年08月10日 16:02:56 +00:00Commented Aug 10, 2016 at 16:02
Neoscript, 59 bytes
a=('A:[]:'Z)+'Aeach n=0:[]:25console:log((a[n]+a[n+1])*13);
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
PHP, 102 bytes
<?php $a='ABCDEFGHIJKLMNOPQRSTUVWXYZA';$i=-1;while($i++<25){echo str_repeat(substr($a,$i,2),13)."\n";}
-
\$\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– Jeroen2016年08月15日 10:40:49 +00:00Commented Aug 15, 2016 at 10:40
Ruby, 41 bytes
26.times{|i|puts [*?A..?Z,?A][i,2]*''*13}
PHP, 65 bytes
Well, this is pretty straight forward:
for(;$i<26;)echo str_repeat(chr(65+$i).chr(65+(++$i%26)),13)."
";
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.
-
1\$\begingroup\$ Did it save you four bytes yesterday? \$\endgroup\$Leaky Nun– Leaky Nun2016年08月10日 00:51:44 +00:00Commented Aug 10, 2016 at 0:51
-
1\$\begingroup\$
_=>[...s="ABCDEFGHIJKLMNOPQRSTUVWXYZ"].map((c,i)=>(c+s[-~i%26]).repeat(13)).join`\n`\$\endgroup\$Leaky Nun– Leaky Nun2016年08月10日 00:52:32 +00:00Commented Aug 10, 2016 at 0:52 -
\$\begingroup\$ @LeakyNun No, just two, I'm afraid: codegolf.stackexchange.com/a/89297/17602 \$\endgroup\$Neil– Neil2016年08月10日 07:57:27 +00:00Commented Aug 10, 2016 at 7:57
-
2\$\begingroup\$ The
(c,i,a)is watching you. \$\endgroup\$gcampbell– gcampbell2016年08月10日 08:18:22 +00:00Commented Aug 10, 2016 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!
Python 2 53 bytes
i=0;exec'print(chr(i+65)+chr(-~i%26+65))*13;i+=1;'*26
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"
Bash + Unix utilities, (削除) 53 (削除ここまで) 52 bytes
dc "-e65[d257*1+16 52^65535/*POP1+d91>x]dsxx"|tr [ A
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
SOGL V0.12, 8 bytes
Z«Z1'0∙I
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
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.
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:
Trial instructions are in my previous answer.
-
\$\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– mkst2017年09月13日 21:25:10 +00:00Commented 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– peterh2017年09月13日 21:34:05 +00:00Commented Sep 13, 2017 at 21:34
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
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
uBASIC, 83 bytes
0ForI=1To26:ForJ=0To12:?Left$(Chr$(I+64),1)+Left$(Chr$(IMod26+65),1);:NextJ:?:NextI
PHP, (削除) 78, 72, (削除ここまで) 67 bytes
<?php $s='A';while($s!='AA')echo str_repeat($s++.(--$s)[0],13)."
";
-
\$\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– Timtech2018年01月31日 23:30:19 +00:00Commented Jan 31, 2018 at 23:30
-
\$\begingroup\$ @Timtech good point, thank you, Sir :) \$\endgroup\$Link– Link2018年01月31日 23:32:08 +00:00Commented Jan 31, 2018 at 23:32
-
\$\begingroup\$ Glad to help you out @Link, keep it up:) \$\endgroup\$Timtech– Timtech2018年01月31日 23:35:02 +00:00Commented Jan 31, 2018 at 23:35
Knight, 34 bytes
;=a 65;W>90aO*+AaA=a+1a 13O*"ZA"13
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
Vyxal j, 7 bytes
kAǏz13*
kA # uppercase alphabet
Ǐ # Append the first letter
z # Get overlapping pairs
13* # Repeat each 13 times
# (j flag) join by newlines
Japt (削除) -R (削除ここまで), (削除) 11 (削除ここまで) 9 bytes
-R (削除ここまで);By@BéÓYv
;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
Julia, 51 bytes
!()=join(["$x$(x+1-26(x>89))"^13for x='A':'Z'],"
")
Initial golfing.
Explore related questions
See similar questions with these tags.