37
\$\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\$
  • 39
    \$\begingroup\$ Seriously, another alphabet challenge? \$\endgroup\$ – Nathan Merrill Aug 9 '16 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 Aug 9 '16 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 '16 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 Aug 9 '16 at 23:40
  • 13
    \$\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 '16 at 15:23

83 Answers 83

1 2
3
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!

|improve this answer|||||
\$\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.

|improve this answer|||||
\$\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>

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

|improve this answer|||||
\$\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));
}
|improve this answer|||||
\$\endgroup\$
  • \$\begingroup\$ What is that Z? \$\endgroup\$ – Erik the Outgolfer Sep 30 '16 at 16:03
  • \$\begingroup\$ @EriktheGolfer You know, Z in ASCII is 90 bytes (\x5a) \$\endgroup\$ – Hydroper Sep 30 '16 at 16:42
0
\$\begingroup\$

Python, 56

for k in range(26):print(chr(k+65)+chr((k+1)%26+65))*13
|improve this answer|||||
\$\endgroup\$
  • \$\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 '16 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.

|improve this answer|||||
\$\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
|improve this answer|||||
\$\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
|improve this answer|||||
\$\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

|improve this answer|||||
\$\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

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

Recursiva, 19 bytes

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

Try it online!

|improve this answer|||||
\$\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!

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

Mathematica, 52 bytes

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

-1 byte from Martin Ender

|improve this answer|||||
\$\endgroup\$
  • \$\begingroup\$ Infix notation for Table saves a byte. \$\endgroup\$ – Martin Ender Nov 30 '17 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)
|improve this answer|||||
\$\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!

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

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

|improve this answer|||||
\$\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!

|improve this answer|||||
\$\endgroup\$
0
\$\begingroup\$

APL (Dyalog Unicode), 13 bytesSBCS

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

Try it online!

|improve this answer|||||
\$\endgroup\$
-1
\$\begingroup\$

PHP, 78, 72, 67 bytes

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

Try it online!

|improve this answer|||||
\$\endgroup\$
  • \$\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 '18 at 23:30
  • \$\begingroup\$ @Timtech good point, thank you, Sir :) \$\endgroup\$ – Link Jan 31 '18 at 23:32
  • \$\begingroup\$ Glad to help you out @Link, keep it up:) \$\endgroup\$ – Timtech Jan 31 '18 at 23:35
1 2
3

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.