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

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.

answered Aug 10, 2016 at 14:21
\$\endgroup\$
2
  • \$\begingroup\$ A language using instead of a literal newline is weird... \$\endgroup\$ Commented 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\$ Commented Oct 1, 2016 at 13:57
0
\$\begingroup\$

Pyke, 13 bytes

GGt\a+]w-*,_X

Try it here!

answered Aug 10, 2016 at 14:52
\$\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();}
answered Aug 10, 2016 at 14:42
\$\endgroup\$
5
  • \$\begingroup\$ If you add A at the end of the alphabet you can change (i+1)%26 to i+1 \$\endgroup\$ Commented 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\$ Commented 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\$ Commented 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\$ Commented 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\$ Commented 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"))
answered Aug 10, 2016 at 14:50
\$\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

answered Aug 10, 2016 at 15:19
\$\endgroup\$
0
\$\begingroup\$

Perl 6, 50 bytes

say .join x 13 for flat('A'..'Z','A').rotor(2=>-1)
answered Aug 10, 2016 at 15:38
\$\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

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

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));}}
answered Aug 10, 2016 at 6:04
\$\endgroup\$
1
  • 1
    \$\begingroup\$ 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 \$\endgroup\$ Commented Aug 10, 2016 at 15:25
0
\$\begingroup\$

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).

answered Aug 10, 2016 at 16:08
\$\endgroup\$
0
\$\begingroup\$

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";
\$\endgroup\$
5
  • \$\begingroup\$ 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. \$\endgroup\$ Commented Aug 10, 2016 at 19:09
  • \$\begingroup\$ 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)."↵"; \$\endgroup\$ Commented Aug 10, 2016 at 19:20
  • \$\begingroup\$ @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"? \$\endgroup\$ Commented Aug 10, 2016 at 20:08
  • \$\begingroup\$ 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. \$\endgroup\$ Commented Aug 10, 2016 at 20:21
  • \$\begingroup\$ 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. \$\endgroup\$ Commented Aug 10, 2016 at 20:25
0
\$\begingroup\$

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]
answered Aug 10, 2016 at 19:10
\$\endgroup\$
0
\$\begingroup\$

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.

answered Aug 10, 2016 at 21:06
\$\endgroup\$
0
\$\begingroup\$

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);
answered Aug 10, 2016 at 10:01
\$\endgroup\$
2
  • \$\begingroup\$ console.log => alert. \$\endgroup\$ Commented Aug 10, 2016 at 21:27
  • \$\begingroup\$ 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! \$\endgroup\$ Commented Aug 10, 2016 at 22:08
0
\$\begingroup\$

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.

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

Scala, 64 bytes

Can anyone improve on this?

(('A'to'Z'):+'A').sliding(2).map(_.mkString*13).foreach(println)
answered Aug 11, 2016 at 4:50
\$\endgroup\$
0
\$\begingroup\$

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)
answered Aug 11, 2016 at 7:15
\$\endgroup\$
0
\$\begingroup\$

Vitsy, 29 bytes

So, instead of doing the typical thing, I used my two-dimensional stacking to generate the alphabets and then offset them by one from each other, alternating back and forth between them.

9a*d5*Hd\[:{:}]Y?y\[y\[O?]aO]
9a*d5*H Push an alphabet to the stack.
9a* Push 90 to the stack (character code 'Z')
 d5* Push 65 to the stack (character code 'A')
 H Pop a, b, push range (a, b)
 d\[:{:}] Establish the other stacks, while alternating.
 d\[ ] Do the bracketed code 13 times.
 : : Clone the stack.
 { Put the top item of the stack on the bottom.
 } Put the bottom item of the stack on the top.
 Y Discard a stack. (13*2+1-1 = 26)
 ? Rotate right a stack (we start on 'A' now)
 y\[y\[O?]aO] Output.
 y\[ ] Repeat the code in brackets number of stacks times (26).
 y\[ ] Repeat the code in brackets number of stack times (26).
 O Pop a, print a as a character.
 ? Go right a stack.
 aO Output a newline.

Try it online!

answered Aug 12, 2016 at 9:11
\$\endgroup\$
0
\$\begingroup\$

PHP, (削除) 70 (削除ここまで) (削除) 66 (削除ここまで) 64 Bytes

<?$a=A;$b=B;while($a!=AA)echo str_repeat($a++.($b++)[0],13)."
";

3 bytes short (if I would remove the <? as well) from @insertusernamehere answer. So close!

EDIT: Actually got it to 66 bytes (64 without the <?)! Doing A and B without quotes actually seem to work. Seems to be the shortest PHP one as time of write :D

EDIT 2: Also removed " " from AA. Still seems to be working.

answered Aug 15, 2016 at 10:31
\$\endgroup\$
0
\$\begingroup\$

Bash, (削除) 149 (削除ここまで), (削除) 115 (削除ここまで), (削除) 111 (削除ここまで), 106 bytes

for i in {0..25};{
printf $(printf %b%b \\`printf %o $[i+65]` \\`printf %o $[-~i%26+65]`)%.s {a..m};echo
}

(thanks @manatwork, saved (削除) 34 (削除ここまで), 4 more bytes)

Bash, 140 bytes

(thanks @steeldriver)

for i in {0..25}; do printf "$(printf '%b%b' \\$(printf '%03o' $((i+65))) \\$(printf '%03o' $((-~i%26+65))))%.0s" {1..13}; printf \\n; done

Save to <file> and run as: /bin/bash <file>

answered Aug 22, 2016 at 12:20
\$\endgroup\$
5
  • 1
    \$\begingroup\$ $((...))$[...], '%b%b'%b%b, printf \\necho, inner $(...)`...`, do ... done{ ... }, %.0s%.s, {1..13}{a..m}. (Some of those you may find in Tips for golfing in Bash.) \$\endgroup\$ Commented Aug 22, 2016 at 12:30
  • \$\begingroup\$ Sorry, but { and } need separators around them. But there are still single quotes to remove around printf's format strings and what I forgot earlier, no need for the double quotes either. pastebin.com/s1h75e5i \$\endgroup\$ Commented Aug 22, 2016 at 14:42
  • 1
    \$\begingroup\$ One more thing: 65..90 in octal is 101..132, so they take 3 digits anyway, so %03o%o. \$\endgroup\$ Commented Aug 22, 2016 at 14:55
  • \$\begingroup\$ Sorry, seems I not explained the error well enough. As the code you posted failed with "line 1: syntax error near unexpected token `{printf'", I edited it. Feel free to revert if you disagree. \$\endgroup\$ Commented Aug 22, 2016 at 15:38
  • \$\begingroup\$ @manatwork copy-paste error on my part, thanks (-: \$\endgroup\$ Commented Aug 22, 2016 at 17:44
0
\$\begingroup\$

GNU sed, 95 bytes

s,^,@@@@@@@@@@@@@,;s,@,AB,g
:;p
y,ABCDEFGHIJKLMNOPQRSTUVWXYZ,BCDEFGHIJKLMNOPQRSTUVWXYZA,
/^Z/!b

I wish the 'y' command had this syntax: y,A-Z,B-ZA,.

answered Sep 10, 2016 at 12:53
\$\endgroup\$
0
\$\begingroup\$

JavaScript, Z (90) bytes

for(i=65,b=66;i<91;++i,b=b<90?++b:65)console.log(Array(14).join(String.fromCharCode(i,b)))

To learn:

var start = 65,
 end = 90;
for (var i = start, b = i+1; i <= end; ++i) {
 var chars = String.fromCharCode(i, b);
 /* repeat chars 14 times */
 console.log(Array(14).join(chars));
}
answered Aug 10, 2016 at 20:27
\$\endgroup\$
2
  • \$\begingroup\$ What is that Z? \$\endgroup\$ Commented Sep 30, 2016 at 16:03
  • \$\begingroup\$ @EriktheGolfer You know, Z in ASCII is 90 bytes (\x5a) \$\endgroup\$ Commented Sep 30, 2016 at 16:42
0
\$\begingroup\$

Python, 56

for k in range(26):print(chr(k+65)+chr((k+1)%26+65))*13
answered Nov 11, 2016 at 13:29
\$\endgroup\$
1
  • \$\begingroup\$ Ah, I had a look at your answer, @Karl Napf. You used a sneaky method of golfing two bits away from my solution. Thank you for teaching me something new :] \$\endgroup\$ Commented Nov 11, 2016 at 13:42
0
\$\begingroup\$

PHP, 52 bytes

for($a=A;$a!=AA;)echo str_pad("\n",27,$a++.$a[0],0);

Can JavaScript beat this? Run with -r.

answered Nov 11, 2016 at 13:56
\$\endgroup\$
0
\$\begingroup\$

Windows batch, 155 bytes

@set s=ABCDEFGHIJKLMNOPQRSTUVWXYZA
@set/ac=-1
:L
@set/ac+=1
@call set t=%%s:~%c%,2%%
@for /l %%i in (1,1,13) do @cd|set/p=%t%
@echo(
@if %t% neq ZA @goto l
answered May 25, 2017 at 12:40
\$\endgroup\$
0
\$\begingroup\$

Javascript, 98 Bytes

for(var j=371,s="";j<1333;j+=37){for(i=0;i<13;i++)s+=j.toString(36).replace("100","za");s+="<br>"}

Try it here

Taylor Raine
8,9732 gold badges29 silver badges53 bronze badges
answered Feb 16, 2017 at 23:17
\$\endgroup\$
1
  • 1
    \$\begingroup\$ Is that a typo? This doesn't look like 12 bytes to me. (I think it's 98 bytes.) \$\endgroup\$ Commented Feb 17, 2017 at 4:02
0
\$\begingroup\$

Recursiva, 19 bytes

{B26'P*13Z~}+(C65;}

Try it online!

answered Sep 13, 2017 at 17:47
\$\endgroup\$
0
\$\begingroup\$

Pyth, 12 bytes

I haven't been there

VG*13+N@G=hZ

Explanation:

VG In the lowercase alphabet...
 *13 13 times...
 +N@G=hZ The current item concatenated with alphabet[++Z]

Try it online!

answered Sep 13, 2017 at 18:16
\$\endgroup\$
0
\$\begingroup\$

K (oK), 23 bytes

Solution:

`c65ドル+26#'a,'1_27#a:!26

Try it online!

Explanation:

`c65ドル+26#'a,'1_27#a:!26 / solution
 !26 / range 0..25
 a: / save as 'a'
 27# / 27 take, wraps to make ABC...XYZA
 1_ / 1 drop, take off leading A
 a,' / concatenate each element with each of a (AB,BC,etc)
 26#' / 26 take each, wraps to get ABABAB... BCBCBC... etc
 65+ / add 65, vectorised (65=A in ASCII)
`c$ / cast to characters

Bonus:

Here are a couple of other ways to get the result:

24 chars: Try it online!

`c65ドル++26#(!26;1_27#!26)

27 chars: Try it online!

26#'+0 1_'26 27#\:`c65ドル+!26
answered Sep 13, 2017 at 19:49
\$\endgroup\$
0
\$\begingroup\$

q/kdb+, 19 bytes

Solution:

26#'.Q.A,'1_27#.Q.A

Explanation:

Shorter and different to my oK solutions as we have a shortcut to the uppercase alphabet by means of .Q.A. As always, interpreted right-to-left

26#'.Q.A,'1_27#.Q.A / solution
 .Q.A / shortcut to uppercase alphabet, ABC..XYZ
 27# / 27 take, wraps to get ABC...XYZA
 1_ / 1 drop, drop first element to give BCD...XYZA
 .Q.A,' / concatenate each left/right lists, so AB, BC, CD etc
26#' / 26 take each, gives ABABA.. BCBCB... etc
answered Sep 13, 2017 at 19:54
\$\endgroup\$
0
\$\begingroup\$

Mathematica, 52 bytes

Column[""<>#~Table~13&/@Partition[Alphabet[],2,1,1]]

-1 byte from Martin Ender

answered Nov 30, 2017 at 12:24
\$\endgroup\$
1
  • \$\begingroup\$ Infix notation for Table saves a byte. \$\endgroup\$ Commented Nov 30, 2017 at 14:41

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.