29
\$\begingroup\$

Given no input, output this interesting alphabet pattern in either case (the case has to be consistent) via an accepted output method:

A
AB
ACBC
ADBDCD
AEBECEDE
AFBFCFDFEF
AGBGCGDGEGFG
AHBHCHDHEHFHGH
AIBICIDIEIFIGIHI
AJBJCJDJEJFJGJHJIJ
AKBKCKDKEKFKGKHKIKJK
ALBLCLDLELFLGLHLILJLKL
AMBMCMDMEMFMGMHMIMJMKMLM
ANBNCNDNENFNGNHNINJNKNLNMN
AOBOCODOEOFOGOHOIOJOKOLOMONO
APBPCPDPEPFPGPHPIPJPKPLPMPNPOP
AQBQCQDQEQFQGQHQIQJQKQLQMQNQOQPQ
ARBRCRDRERFRGRHRIRJRKRLRMRNRORPRQR
ASBSCSDSESFSGSHSISJSKSLSMSNSOSPSQSRS
ATBTCTDTETFTGTHTITJTKTLTMTNTOTPTQTRTST
AUBUCUDUEUFUGUHUIUJUKULUMUNUOUPUQURUSUTU
AVBVCVDVEVFVGVHVIVJVKVLVMVNVOVPVQVRVSVTVUV
AWBWCWDWEWFWGWHWIWJWKWLWMWNWOWPWQWRWSWTWUWVW
AXBXCXDXEXFXGXHXIXJXKXLXMXNXOXPXQXRXSXTXUXVXWX
AYBYCYDYEYFYGYHYIYJYKYLYMYNYOYPYQYRYSYTYUYVYWYXY
AZBZCZDZEZFZGZHZIZJZKZLZMZNZOZPZQZRZSZTZUZVZWZXZYZ

Trailing spaces and newlines are acceptable, standard loopholes are disallowed, and this happens to be , so the shortest answer in bytes wins!

\$\endgroup\$
8
  • \$\begingroup\$ Related, Related \$\endgroup\$
    – qqq
    Commented Jan 13, 2018 at 23:18
  • \$\begingroup\$ BTW if I see an amazing answer I will bounty it 50 rep \$\endgroup\$
    – qqq
    Commented Jan 13, 2018 at 23:26
  • 14
    \$\begingroup\$ The leading A really messes things up for me... \$\endgroup\$ Commented Jan 13, 2018 at 23:38
  • 2
    \$\begingroup\$ Some people simply don't like these kind of challenges I think. \$\endgroup\$ Commented Jan 14, 2018 at 0:10
  • 1
    \$\begingroup\$ @ETHproductions It simplifies things for me! \$\endgroup\$
    – Neil
    Commented Jan 14, 2018 at 0:17

56 Answers 56

1
2
1
\$\begingroup\$

Python 2, 92 86 79 75 64 bytes

s=map(chr,range(65,91))
for d in s:print d.join(s[:ord(d)-65])+d

Try it online!

11 bytes thx to Rod.

\$\endgroup\$
1
1
\$\begingroup\$

APL+WIN, 51 bytes

⍎∊'a←⎕av[65+⍳26]⋄a[n←1]',25⍴⊂'⋄,⊃a[⍳n-1],¨a[n←n+1]'

Explanation:

a←⎕av[65+⍳26] create a vector of upper case letters

a[n←1] first A

25⍴⊂'⋄,⊃a[⍳n-1],¨a[n←n+1]' create an implicit loop to concatenate subsequent letters
\$\endgroup\$
1
\$\begingroup\$

><>, 47 bytes

d2*:1-v
-&$:?!\$:&$:1
1-:?!v\69*-$1-:
+*88~< 1o

Try it online!

How It Works:

d2*:1-v Initialise the stack with 26 (outer loop counter) and 26-1 (inner loop counter)
....
....
....

....
-&$:?!\$:&$:1 Repeatedly make copies of both counters
....          And decrement the inner loop counter
....          Go to third line when inner loop counter is 0

....            Add -54 to the stack (for the newline) and decrement the outer loop counter
....            Initialise the inner loop counter as outer-1
1-:?!v\69*-$1-: If the inner counter is 0, go to the fourth line, else back to the second.
....

....
....      
....      Transform numbers and -54s into letters and newlines by adding 64
+*88~< 1o Output each character until it runs out of stack and errors
\$\endgroup\$
1
\$\begingroup\$

Canvas, 11 10 bytes

Z{Z²╷m¹*×]

Try it here!

\$\endgroup\$
1
\$\begingroup\$

GNU M4, 119 bytes

The worst so far. Well, time's already spent…

define(f,`ifelse($1,$2,,`format(%c%c,$1,$2)`'f(incr($1),$2)')')define(g,`f(65,$1)ifelse($1,90,,`
g(incr($1))')')A
g(66)
\$\endgroup\$
1
\$\begingroup\$

J, 38, 33 30 bytes

-5 bytes thanks to Bolce Bussiere

-3 bytes thanks to FrownyFrog

'A ',}.(}:,@,.{:)\(65+i.26){a.

How?

(65+i.26){a. - uppercase alphabet

\ - prefixes

(}:,@,.{:) - drops the last letter from each prefix and inserts it between the remaining letters

}. drops the leading row since it's empty (not "A")

, - append

'A ' - "A"

Try it online!

\$\endgroup\$
7
  • 1
    \$\begingroup\$ You can use (,.'A') instead of ('A',49$' ') :) \$\endgroup\$ Commented Jan 15, 2018 at 5:13
  • \$\begingroup\$ @Bolce Bussiere Thanks, it's much better now! \$\endgroup\$ Commented Jan 15, 2018 at 7:42
  • 1
    \$\begingroup\$ Just append 'A ' TIO \$\endgroup\$
    – FrownyFrog
    Commented Jan 15, 2018 at 8:47
  • \$\begingroup\$ @FrownyFrog Thanks! I didn't know it works. Only the space is used as a fill? \$\endgroup\$ Commented Jan 15, 2018 at 8:52
  • \$\begingroup\$ @GalenIvanov The space is the default fill, it doesn’t come from the 'A '. \$\endgroup\$
    – FrownyFrog
    Commented Jan 15, 2018 at 9:03
1
\$\begingroup\$

Husk, 13 bytes

Γ·:mhSzJḣ…"AZ

Try it online!

Explanation

This leading A really messes things up -.-

          "AZ  -- string literal: "AZ"
         …     -- fill gaps: "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
     S         -- with alphabet and
        ḣ      -- | alphabet rangified: ["A","AB","ABC",…,"AB……XYZ"]
      zJ       -- : zipWith join: ["A","ABB","ACBCC","ADBDCDD",…,"AZB……ZYZZ"]
Γ              -- pattern match (x:xs) with the following function (x is "A" and xs ["ABB","ACBCC",…,"A……ZYZZ"]
 · mh          -- | drop the last element of each element of xs: ["AB","ACBC",…,"A……ZYZ"]
  :            -- | cons (construct list): ["A","AB","ACBC",…,"A……ZYZ"]
               -- : strings are printed implicitly
\$\endgroup\$
1
\$\begingroup\$

Java 8, 121 bytes

I know there are better approaches but wanted to try it :)

q->{String s="";for(int i=0;i<26;i++){for(int j=0;j<((i<1)?1:i*2);j++){s+=(char)((j%2!=0?i:j/2)+65);}s+="\n";}return s;}

ungolfed:

static String d(){
    String s="";
    for(int i=0;i<26;i++){      //Loop for each line
        for(int j=0;j<((i<1)?1:i*2);j++){ //Loop to create the "word"
            s+=(char)((j%2!=0?i:j/2)+65);
        }
        s+="\n";
    }
    return s;
}
\$\endgroup\$
1
1
\$\begingroup\$

Red, 130 122 bytes

prin"A"repeat n 26[b: copy/part"ABCDEFGHIJKLMNOPQRSTUVWXYZ"n
foreach d copy/part b back tail b[prin d prin last b]print""]

Try it online!

\$\endgroup\$
1
\$\begingroup\$

F# (.NET Core), 132 bytes

let x=['A'..'Z']|>Seq.map(fun c->(+)(['A'..'Z']|>Seq.take((int c)-65)|>Seq.map(fun s->string s)|>String.concat(string c))(string c))

Try it online!

A naive port of my C# answer

\$\endgroup\$
1
\$\begingroup\$

Perl 6, 51 bytes

.say for 'A',{join |('A'..'Z')[++$,^++$ ],''}.../Z/

Try it

Expanded:

.say     # print with trailing newline

  for    # each of the following

    # start the sequence
    'A',

    # code used to generate the rest of the sequence
    {
      join
        | # flatten arguments

        ( 'A' .. 'Z' )[  # Range of characters
          ++$,           # auto incrementing anon state var (value used to join)
          ^++$           # Range upto an incrementing anon
        ],
        ''               # an empty string so that the joiner is added to end
    }

    ...  # keep doing that until
    /Z/  # there is a "Z" in the value
\$\endgroup\$
1
\$\begingroup\$

uBASIC, 80 bytes

Anonymous function that takes no input and outputs to the console

0?"A":ForI=65To89:ForJ=65ToI:?Left$(Chr$(J),1)+Left$(Chr$(I+1),1);:NextJ:?:NextI

Try it online!

\$\endgroup\$
1
\$\begingroup\$

Visual Basic .NET (Mono), 134 bytes

Declared function that takes no input and outputs to the console

Module M
Sub Main
Dim S,I,J
S="A"
For I=65To 90
Console.WriteLine(S)
S=""
For J=65To I
S+=Chr(J)+Chr(I+1)
Next
Next
End Sub
End Module

Try it online!

\$\endgroup\$
1
\$\begingroup\$

MY-BASIC, 77 bytes

Anonymous function that takes no input and outputs to the console.

Print"A";
For I=65 To 89
For J=65 To I
Print Chr(J)+Chr(I+1)
Next
Print;
Next

Try it online!

\$\endgroup\$
1
\$\begingroup\$

Yabasic, 60 bytes

?"A"
For I=65To 89
For J=65To I?Chr$(J)+Chr$(I+1);Next
?Next

Try it online!

\$\endgroup\$
1
\$\begingroup\$

QBasic 1.1, 62 bytes

Takes no input and outputs to the STDIN

?"A"
FOR i=65TO 89
FOR j=65TO i
?CHR$(j)CHR$(i+1);
NEXT
?
NEXT
\$\endgroup\$
1
\$\begingroup\$

Kotlin, 76 bytes

{for(l in 'A'..'Z'){for(c in 'A'..l){print(c)
if(c+1<l)print(l)}
println()}}

Try it online!

\$\endgroup\$
1
\$\begingroup\$

Perl 5, 35 bytes

@a=A..$_,$"=pop@a,say"@a$_"for A..Z

Try it online!

I managed to get frustratingly close for 23 bytes, but the above is the shortest valid solution I've managed so far:

$,=$_,say A..$,for A..Z

Try it online!

\$\endgroup\$
1
\$\begingroup\$

Julia 1.0, 40 bytes

!_=["A";'B':'Z'.|>i->join(('A':i-1).*i)]

Try it online!

function taking an unused argument and ouputing an array of strings

\$\endgroup\$
1
\$\begingroup\$

Zsh, 40 bytes

for c ({A..Z})<<<${(pj:$c:)s}$c&&s+=($c)

Try it online!

for c ({A..Z})             # for each character
    <<< ${(pj:$c:)s}$c &&  # print line
    #   ${(p     ) }       # - enable simple $parameters inside PE flags
    #   ${( j:$c:) }       # - join with $c
    #   ${        s}$c     # - concatenate $s with $c
    s+=($c)                # add $c to the end of the list $s
\$\endgroup\$
1
\$\begingroup\$

Vyxal j, 7 bytes

n¦ƛṫ~jp

Try it Online!

Explained

n¦ƛṫ~jp­⁡​‎‎⁡⁠⁡‏⁠‎⁡⁠⁢‏‏​⁡⁠⁡‌⁢​‎‎⁡⁠⁣‏‏​⁡⁠⁡‌⁣​‎‎⁡⁠⁤‏‏​⁡⁠⁡‌⁤​‎‎⁡⁠⁢⁡‏⁠‎⁡⁠⁢⁢‏‏​⁡⁠⁡‌⁢⁡​‎‎⁡⁠⁢⁣‏‏​⁡⁠⁡‌­
n¦       # ‎⁡Prefixes of the alphabet
  ƛ      # ‎⁢To each prefix:
   ṫ     # ‎⁣  push prefix[:-1], prefix[-1]
    ~j   # ‎⁤  without popping anything, join the long string on the short string
      p  # ‎⁢⁡  and append prefix[-1]
💎

Created with the help of Luminespire.

\$\endgroup\$
1
\$\begingroup\$

Setanta, 100 bytes

S:=scriobh S("A")s:="ABCDEFGHIJKLMNOPQRSTUVWXYZ"le i idir(0,26){t:=""le j idir(0,i)t+=s[j]+s[i]S(t)}

try-setanta.ie link

Explanation

S:=scriobh S("A")s:="ABCDEFGHIJKLMNOPQRSTUVWXYZ"le i idir(0,26){t:=""le j idir(0,i)t+=s[j]+s[i]S(t)}­⁡​‎‎⁡⁠⁡‏⁠‎⁡⁠⁢‏⁠‎⁡⁠⁣‏⁠‎⁡⁠⁤‏⁠‎⁡⁠⁢⁡‏⁠‎⁡⁠⁢⁢‏⁠‎⁡⁠⁢⁣‏⁠‎⁡⁠⁢⁤‏⁠‎⁡⁠⁣⁡‏⁠‎⁡⁠⁣⁢‏⁠‎⁡⁠⁣⁣‏⁠‎⁡⁠⁣⁤‏⁠‎⁡⁠⁤⁡‏⁠‎⁡⁠⁤⁢‏⁠‎⁡⁠⁤⁣‏⁠‎⁡⁠⁤⁤‏⁠‎⁡⁠⁢⁡⁡‏‏​⁡⁠⁡‌⁢​‎‎⁡⁠⁢⁡⁢‏⁠‎⁡⁠⁢⁡⁣‏⁠‎⁡⁠⁢⁡⁤‏⁠‎⁡⁠⁢⁢⁡‏⁠‎⁡⁠⁢⁢⁢‏⁠‎⁡⁠⁢⁢⁣‏⁠‎⁡⁠⁢⁢⁤‏⁠‎⁡⁠⁢⁣⁡‏⁠‎⁡⁠⁢⁣⁢‏⁠‎⁡⁠⁢⁣⁣‏⁠‎⁡⁠⁢⁣⁤‏⁠‎⁡⁠⁢⁤⁡‏⁠‎⁡⁠⁢⁤⁢‏⁠‎⁡⁠⁢⁤⁣‏⁠‎⁡⁠⁢⁤⁤‏⁠‎⁡⁠⁣⁡⁡‏⁠‎⁡⁠⁣⁡⁢‏⁠‎⁡⁠⁣⁡⁣‏⁠‎⁡⁠⁣⁡⁤‏⁠‎⁡⁠⁣⁢⁡‏⁠‎⁡⁠⁣⁢⁢‏⁠‎⁡⁠⁣⁢⁣‏⁠‎⁡⁠⁣⁢⁤‏⁠‎⁡⁠⁣⁣⁡‏⁠‎⁡⁠⁣⁣⁢‏⁠‎⁡⁠⁣⁣⁣‏⁠‎⁡⁠⁣⁣⁤‏⁠‎⁡⁠⁣⁤⁡‏⁠‎⁡⁠⁣⁤⁢‏⁠‎⁡⁠⁣⁤⁣‏⁠‎⁡⁠⁣⁤⁤‏‏​⁡⁠⁡‌⁣​‎‎⁡⁠⁤⁡⁡‏⁠‎⁡⁠⁤⁡⁢‏⁠‎⁡⁠⁤⁡⁣‏⁠‎⁡⁠⁤⁡⁤‏⁠‎⁡⁠⁤⁢⁡‏⁠‎⁡⁠⁤⁢⁢‏⁠‎⁡⁠⁤⁢⁣‏⁠‎⁡⁠⁤⁢⁤‏⁠‎⁡⁠⁤⁣⁡‏⁠‎⁡⁠⁤⁣⁢‏⁠‎⁡⁠⁤⁣⁣‏⁠‎⁡⁠⁤⁣⁤‏⁠‎⁡⁠⁤⁤⁡‏⁠‎⁡⁠⁤⁤⁢‏⁠‎⁡⁠⁤⁤⁣‏⁠‎⁡⁠⁤⁤⁤‏⁠‎⁡⁠⁢⁣⁡⁤‏‏​⁡⁠⁡‌⁤​‎‎⁡⁠⁢⁡⁢⁢‏⁠‎⁡⁠⁢⁡⁢⁣‏⁠‎⁡⁠⁢⁡⁢⁤‏⁠‎⁡⁠⁢⁡⁣⁡‏⁠‎⁡⁠⁢⁡⁣⁢‏⁠‎⁡⁠⁢⁡⁣⁣‏⁠‎⁡⁠⁢⁡⁣⁤‏⁠‎⁡⁠⁢⁡⁤⁡‏⁠‎⁡⁠⁢⁡⁤⁢‏⁠‎⁡⁠⁢⁡⁤⁣‏⁠‎⁡⁠⁢⁡⁤⁤‏⁠‎⁡⁠⁢⁢⁡⁡‏⁠‎⁡⁠⁢⁢⁡⁢‏⁠‎⁡⁠⁢⁢⁡⁣‏‏​⁡⁠⁡‌⁢⁡​‎‎⁡⁠⁢⁡⁡⁡‏⁠‎⁡⁠⁢⁡⁡⁢‏⁠‎⁡⁠⁢⁡⁡⁣‏⁠‎⁡⁠⁢⁡⁡⁤‏⁠‎⁡⁠⁢⁡⁢⁡‏⁠‎⁡⁠⁢⁢⁡⁤‏⁠‎⁡⁠⁢⁢⁢⁡‏⁠‎⁡⁠⁢⁢⁢⁢‏⁠‎⁡⁠⁢⁢⁢⁣‏⁠‎⁡⁠⁢⁢⁢⁤‏⁠‎⁡⁠⁢⁢⁣⁡‏⁠‎⁡⁠⁢⁢⁣⁢‏⁠‎⁡⁠⁢⁢⁣⁣‏⁠‎⁡⁠⁢⁢⁣⁤‏⁠‎⁡⁠⁢⁢⁤⁡‏⁠‎⁡⁠⁢⁢⁤⁢‏⁠‎⁡⁠⁢⁢⁤⁣‏‏​⁡⁠⁡‌⁢⁢​‎‎⁡⁠⁢⁢⁤⁤‏⁠‎⁡⁠⁢⁣⁡⁡‏⁠‎⁡⁠⁢⁣⁡⁢‏⁠‎⁡⁠⁢⁣⁡⁣‏‏​⁡⁠⁡‌­
S:=scriobh S("A")                                                                                     # ‎⁡Prints "A"
                 s:="ABCDEFGHIJKLMNOPQRSTUVWXYZ"                                                      # ‎⁢Assigns "ABC...XYZ" to s (since Setanta doesn’t have a chr function)
                                                le i idir(0,26){                                   }  # ‎⁣For i in [0, 26)...
                                                                     le j idir(0,i)                   # ‎⁤For j in [0, i)...
                                                                t:=""              t+=s[j]+s[i]       # ‎⁢⁡Appends s[j] + s[i] to the string
                                                                                               S(t)   # ‎⁢⁢Prints the string
💎

Created with the help of Luminespire.

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

Clean, 74 72 bytes

import StdEnv
Start=("A",[(zip2['A'..s-one][s,s..],'
')\\s<-['A'..'Z']])

Try it online!

This actually doesn't print a String, but rather a bare (String, [([(Char, Char)], Char)]), which is functionally the same. Unless you grab the output from this with another Clean program.

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

C (gcc), 77 bytes

f(i,j){for(i=0;i<26;puts("A"+!!i++))for(j=0;j<i;)printf("%c%c",j+++65,i+65);}

Try it online!

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

VBA, 60 Bytes

Anonymous VBE immediate window that takes no input and outputs to the VBE immediate window

?"A":For i=65To 89:For j=65To i:?Chr(j)Chr(i+1);:Next:?:Next
\$\endgroup\$
0
\$\begingroup\$

Easyfuck, 36 bytes

\ùòGEPAí½xÑZG×í½x¹ZG˯ÝzSHYòGËPM<¿v␄␘6Å␀ÿ

due to lack of unicode representations for c1 control characters, they have been replaced by their superscripted abbreviations

Decompressed:

.>>$<_[=<4+$>_[=<.+$>._]=+>$>.<<_]@AA[␊

Explanation:

.>>$<_[=<4+$>_[=<.+$>._]=+>$>.<<_]@AA[␊
.>>$<                                   print the initial A
     _[=                        _]      loop until 2nd cell is equal to 3rd
        <4+$>                           set first cell to A
             _[=      _]=               loop until 1st cell is equal to 2nd
                <.+$>.                  print 1st cell and increment it, then print 2nd
                         +>$>.<<        increment 2nd cell and print 4th
                                  @     return
                                   AA[␊ initializer data
\$\endgroup\$
1
2

Your Answer

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

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