24
\$\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\$
  • \$\begingroup\$ Related, Related \$\endgroup\$ – FantaC Jan 13 '18 at 23:18
  • \$\begingroup\$ BTW if I see an amazing answer I will bounty it 50 rep \$\endgroup\$ – FantaC Jan 13 '18 at 23:26
  • 13
    \$\begingroup\$ The leading A really messes things up for me... \$\endgroup\$ – ETHproductions Jan 13 '18 at 23:38
  • 2
    \$\begingroup\$ Some people simply don't like these kind of challenges I think. \$\endgroup\$ – Jonathan Allan Jan 14 '18 at 0:10
  • 1
    \$\begingroup\$ @ETHproductions It simplifies things for me! \$\endgroup\$ – Neil Jan 14 '18 at 0:17

47 Answers 47

1
\$\begingroup\$

brainfuck, 96 bytes

+++++[->+++++>++>+++++++++++++>+++++++++++++<<<<]>>>.<.<[->>>+>+[-<<.+>.>>+<]>[-<+<<->>>]<<<<.<]

Try it online!

Tape Layout:

[Init] [Line Count] [newline] [Growing Ascii] [Repeated Ascii] [Loop 1] [Loop 2]

Explanation:

+++++[->+++++>++                      Sets Line counter and newline cell
    >+++++++++++++>+++++++++++++<<<<] Sets Ascii cells to 65 ('A')
>>>.<.<                               Prints first "A" and moves to Line loop
  [->>>+>+                            Increment Repeated Ascii cell in outer loop
      [-<<.+>.>>+<]>                  Increment Growing Ascii cell in inner loop,
                                         Prints both Ascii cells and Sets Loop 2
      [-<+<<->>>]                     Resets Growing cell and Loop 1
  <<<<.<]                             Prints newline and moves to next Line
\$\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\$

brainfuck, 81 bytes

+++[[->++<<+>]>]<<,<[----<<+>>]<+<+.<+<--.>[>+>>+[-<.+<.>>>+<]>[-<+<->>]<<<<<.>-]

Try it online!

Prints in lowercase

Explanation:

+++[[->++<<+>]>]  Sets up the tape as 3*2^n (3,6,12,24,48,96,192,128)
<<,               Removes excess 128
<[----<<+>>]      Adds 196/4 to 48 resulting in 96
<+<+.             Add 1 to both 96s and print A
<+<--.            Add 1 to 25, subtract 2 from 12 to print a newline
                  Tape: 3 6 10 25 96 96 0 0
>[ Start loop
   >+>>+          Add one to the unchanging ASCII and the inner loop counter
   [-<.+<.>>>+<]  Print row while preserving counter
   >[-<+<->>]     Undo changes to changing ASCII and return inner loop counter to its cell
   <<<<<.>-       Print newline and decrement loop counter
]
\$\endgroup\$
  • \$\begingroup\$ This is really short but needs a specific interpreter with the following features: - negative pointer or pointer wrapping - cell wrapping - cell size 8 bits - end of input = 0 If the interpreter doesn't support any of these, it will produce garbish \$\endgroup\$ – Dorian Jul 13 '18 at 9:52
  • \$\begingroup\$ @Dorian Generally, any type of interpreter that exists is valid on this site (though most I've seen have used the described specifications) . I will be sure to include which interpreter type I'm using in future answers though thanks \$\endgroup\$ – Jo King Jul 13 '18 at 12:40
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\$

brainfuck, 88 bytes

++++++++[->+++>+>++++++++>++++++++<<<<]>+>++>+.<.<[->>+>>+[-<+.<.>>>+<]>[-<+<->>]<<<<.<]

Try it online!

should run on all brainfuck interpreters. No wrapping or negative values, no undefined input behaviour, values between 0 and 90.

How it works

Initialize tape: 25(row count) 10(lf) 64(row letter) 64(col letter) 0(col count) 0(temp)
++++++++[->+++>+>++++++++>++++++++<<<<]>+>++ 

>+.<.            print "A" and lf
<[               for each letter count
  -                decrement letter count
  >>+              increment row letter
  >>+              increment col count
  [                do col count times
    -                decrement col count
    <+.              increment and print col letter
    <.               print row letter
    >>>+             move col count to temp
    <                return to colcount
  ]
  >[-<+<->>]       move value from temp back to col count and set col letter back to "A" minus 1
  <<<<.            print lf
  <                return to row count
]
\$\endgroup\$
1
\$\begingroup\$

Perl 5, 39 38 bytes

@DomHastings shaved off a byte

say$.=A;say map$_.$.,A..$.++while$.!~Z

Try it online!

\$\endgroup\$
  • \$\begingroup\$ Nice solution, I've played with this a bit and managed to get a slightly different approach, but with this, you can save 1 cheeky byte using $.!~Z vs. $.ne Z! \$\endgroup\$ – Dom Hastings Jul 13 '18 at 12:03
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\$

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

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

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

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.