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\$
    – trichoplax
    Aug 10, 2016 at 15:23

94 Answers 94

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\$ 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\$ 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\$
    – Wes
    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\$ 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\$
    – Wes
    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]
\$\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.

\$\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);
\$\endgroup\$
2
  • \$\begingroup\$ console.log => alert. \$\endgroup\$ 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\$
    – ajxs
    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.

\$\endgroup\$
3
  • \$\begingroup\$ You can remove the soace before b=65. \$\endgroup\$ 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\$
    – sonrad10
    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\$ 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)
\$\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)
\$\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!

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

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

\$\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\$
    – manatwork
    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\$
    – manatwork
    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\$
    – manatwork
    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\$
    – manatwork
    Aug 22, 2016 at 15:38
  • \$\begingroup\$ @manatwork copy-paste error on my part, thanks (-: \$\endgroup\$
    – KM.
    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,.

\$\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));
}
\$\endgroup\$
2
  • \$\begingroup\$ What is that Z? \$\endgroup\$ Sep 30, 2016 at 16:03
  • \$\begingroup\$ @EriktheGolfer You know, Z in ASCII is 90 bytes (\x5a) \$\endgroup\$
    – user48510
    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
\$\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\$
    – Lord Ratte
    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.

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

tcl, 80

time {puts [string repe [format %c%c [expr [incr i]+64] [expr $i%26+65]] 13]} 26

demo


tcl, 86

while {[incr i]<27} {puts [string repe [format %c%c [expr $i+64] [expr $i%26+65]] 13]}

demo

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

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Is that a typo? This doesn't look like 12 bytes to me. (I think it's 98 bytes.) \$\endgroup\$ Feb 17, 2017 at 4:02
0
\$\begingroup\$

Recursiva, 19 bytes

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

Try it online!

\$\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!

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

K (oK), 23 bytes

Solution:

`c$65+26#'a,'1_27#a:!26

Try it online!

Explanation:

`c$65+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!

`c$65++26#(!26;1_27#!26)

27 chars: Try it online!

26#'+0 1_'26 27#\:`c$65+!26
\$\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
\$\endgroup\$
0
\$\begingroup\$

Mathematica, 52 bytes

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

-1 byte from Martin Ender

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

Excel VBA, 50 Bytes

Anonymous VBE immediate window function that takes no input and outputs a wave to the range [A1:Z26] on the ActiveSheet object

[A1:Z26]="=Char(Mod(Row()+IsEven(Column()),26)+64)
\$\endgroup\$
0
\$\begingroup\$

Yabasic, 69 bytes

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

Try it online!

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

uBASIC, 83 bytes

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

Try it online!

\$\endgroup\$
0
\$\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
0
\$\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!

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

Jelly, 10 bytes

ØA,Ɲẋ€13j⁷

Try it online!

Noncompeting probably because some of the atoms are new.

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

Vyxal j, 10 bytes

kA:ǓZv∑13*

Try it Online!

kA         # Uppercase alphabet
  :ǓZ      # Zip with a copy  rotated one to the left
     v∑    # Sum each
       13* # Repeat each 13x
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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