Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics

Dashboard
Notifications
Mark all as read
Challenges

Create an Alphabet Diamond

+6
−0

Challenge

Output the following text:

                         A
                        ABA
                       ABCBA
                      ABCDCBA
                     ABCDEDCBA
                    ABCDEFEDCBA
                   ABCDEFGFEDCBA
                  ABCDEFGHGFEDCBA
                 ABCDEFGHIHGFEDCBA
                ABCDEFGHIJIHGFEDCBA
               ABCDEFGHIJKJIHGFEDCBA
              ABCDEFGHIJKLKJIHGFEDCBA
             ABCDEFGHIJKLMLKJIHGFEDCBA
            ABCDEFGHIJKLMNMLKJIHGFEDCBA
           ABCDEFGHIJKLMNONMLKJIHGFEDCBA
          ABCDEFGHIJKLMNOPONMLKJIHGFEDCBA
         ABCDEFGHIJKLMNOPQPONMLKJIHGFEDCBA
        ABCDEFGHIJKLMNOPQRQPONMLKJIHGFEDCBA
       ABCDEFGHIJKLMNOPQRSRQPONMLKJIHGFEDCBA
      ABCDEFGHIJKLMNOPQRSTSRQPONMLKJIHGFEDCBA
     ABCDEFGHIJKLMNOPQRSTUTSRQPONMLKJIHGFEDCBA
    ABCDEFGHIJKLMNOPQRSTUVUTSRQPONMLKJIHGFEDCBA
   ABCDEFGHIJKLMNOPQRSTUVWVUTSRQPONMLKJIHGFEDCBA
  ABCDEFGHIJKLMNOPQRSTUVWXWVUTSRQPONMLKJIHGFEDCBA
 ABCDEFGHIJKLMNOPQRSTUVWXYXWVUTSRQPONMLKJIHGFEDCBA
ABCDEFGHIJKLMNOPQRSTUVWXYZYXWVUTSRQPONMLKJIHGFEDCBA
 ABCDEFGHIJKLMNOPQRSTUVWXYXWVUTSRQPONMLKJIHGFEDCBA
  ABCDEFGHIJKLMNOPQRSTUVWXWVUTSRQPONMLKJIHGFEDCBA
   ABCDEFGHIJKLMNOPQRSTUVWVUTSRQPONMLKJIHGFEDCBA
    ABCDEFGHIJKLMNOPQRSTUVUTSRQPONMLKJIHGFEDCBA
     ABCDEFGHIJKLMNOPQRSTUTSRQPONMLKJIHGFEDCBA
      ABCDEFGHIJKLMNOPQRSTSRQPONMLKJIHGFEDCBA
       ABCDEFGHIJKLMNOPQRSRQPONMLKJIHGFEDCBA
        ABCDEFGHIJKLMNOPQRQPONMLKJIHGFEDCBA
         ABCDEFGHIJKLMNOPQPONMLKJIHGFEDCBA
          ABCDEFGHIJKLMNOPONMLKJIHGFEDCBA
           ABCDEFGHIJKLMNONMLKJIHGFEDCBA
            ABCDEFGHIJKLMNMLKJIHGFEDCBA
             ABCDEFGHIJKLMLKJIHGFEDCBA
              ABCDEFGHIJKLKJIHGFEDCBA
               ABCDEFGHIJKJIHGFEDCBA
                ABCDEFGHIJIHGFEDCBA
                 ABCDEFGHIHGFEDCBA
                  ABCDEFGHGFEDCBA
                   ABCDEFGFEDCBA
                    ABCDEFEDCBA
                     ABCDEDCBA
                      ABCDCBA
                       ABCBA
                        ABA
                         A

Notes

  • You can have any amount of leading and trailing whitespace on all directions, as long as all non-whitespace characters are properly aligned to make the diamond shape.
  • A multiline string, character matrix, list of strings, list of lists of characters, and equivalent are acceptable outputs.
  • Shortest answer per language, scored in bytes, wins!
Why does this post require moderator attention?
You might want to add some details to your flag.
Why should this post be closed?

0 comments

6 answers

+4
−0

Brain-Flak, 250 bytes

((((()()()){}){}){}()){(({})[()])}{}(<>)<>{({}<>)<>}<>{(({})[()])}([]){{}([(({}))](((()()()){}){}){}()){({}[()])<>((((()()()()){}){}){})<>}{}<>(((((()()()()){}){}){}){}())<>{({}[()])<>(({})())<>}{}{({}[()])<>(({})[()])<>}{}<>((()()()()()){})<>([])}<>

Try it online!

Readable, commented version:

# Push 25
((((()()()){}){}){}())

# Push range(25, 1)
{
    (({})[()])
}
{}

# Push a 0 on to the alternate stack and return to main stack
(<>)<>

# Reverse values onto other stack
{
    ({}<>)
    <>
}
<>

# Push range(25, 0)
{
    (({})[()])
}

# Push the stack height.
([])

# At this point, the stack has 0, 1, 2... 23, 24, 25, 24, 23... 2, 1, 0
# Go through each number of these numbers, and call it N
{
    # Pop the stack height counter
    {}

    # Push (25 - N), and underneath it push N an additional time
    ([(({}))](((()()()){}){}){}())

    # That many times...
    {
        # Decrement
        ({}[()])

        <>

        # Push a space onto the ascii-art stack
        ((((()()()()){}){}){})

        <>
    }
    {}

    # on the ascii-art stack, push the letter A
    <>
    (((((()()()()){}){}){}){}())
    <>

    # N times...
    {
        # Decrement N
        ({}[()])

        # Push "The last character + 1"
        <>
        (({})())
        <>
    }
    {}

    # N times...
    {
        # Decrement N
        ({}[()])

        # Push "The last character - 1"
        <>
        (({})[()])
        <>
    }
    {}

    <>
    # Push a newline
    ((()()()()()){})
    <>

    ([])
}<>
Why does this post require moderator attention?
You might want to add some details to your flag.

0 comments

+3
−0

JavaScript (Node.js), 78 bytes

(m=(a,b=26,c=a(--b))=>b?[c,...m(a,b),c]:[c])=>m(a=>m(b=>(c=25-a-b)<0?32:c+65))

Try it online!

Why does this post require moderator attention?
You might want to add some details to your flag.

0 comments

+3
−0

Canvas, 10 7 6 bytes

Z[]/┼┼

Try it here!

Creates the top portion, centers it, and mirrors it.

-3 bytes from dzaima's hint.

-1, found the 6 byter!

Explanation

Z[]/++
Z          push the alphabet
 []        get all prefixes
   /       diagonalize  by padding each line with one less than the previous
    ++     Quad palindromize, without reflecting letters
Why does this post require moderator attention?
You might want to add some details to your flag.

6 comments

Why does the canvas alphabet contain ^ instead of V? Quintec‭ 16 days ago

Oh, huh, mirroring is special for that character, I see Quintec‭ 16 days ago

Hint: all palindromization builtins repeated twice disables the fancy mirroring dzaima‭ 15 days ago

wow whut, is that documented anywhere? Razetime‭ 15 days ago

In an unfinished completely random file where it definitely doesn't deserve to be, with an unreadable description (where the described "basic overlap", "background overlap", and "mirror vertical" aren't even used by anything), yeah. (also, 6 bytes is possible) dzaima‭ 15 days ago

Show 1 more comments
+3
−0

V (vim), 21 bytes

¬AZ¬YA|òlÄ26|xx>>YGpH

Try it online!

Explanation:

¬AZ                     " Insert every character from A to Z
   ¬YA                  " Insert every character from Y to A
      |                 " Go back to the beginning of this line
       ò                " While True...
        l               "   Move to the right (if there is only one character
                        "   on this line, break the loop)
         Ä              "   Duplicate this line upwards
          26|           "   Go to the 26th character on this line
             xx         "   Delete two characters
               >>       "   Indent this line with one space
                 Y      "   Yank this line
                  G     "   Go to the last line
                   p    "   Paste the line that was just yanked downwards
                    H   "   Go back to the first line
                        " (Implicit) End loop

Hexdump:

00000000: ac41 5aac 5941 7cf2 6cc4 3236 7c78 783e  .AZ.YA|.l.26|xx>
00000010: 3e59 4770 48                             >YGpH
Why does this post require moderator attention?
You might want to add some details to your flag.

0 comments

+3
−0

Japt -R, 14 bytes

;Bãê kb"A" û ê

Takes all substrings of the alphabet, palindromizes them, and then takes only the ones starting with A and centers and mirrors that too.

Test it

Why does this post require moderator attention?
You might want to add some details to your flag.

1 comment

Once again, Japt beats V at an ASCII-art challenge. Sigh DJMcMayhem‭ 17 days ago

+3
−0

Stax, 12 bytes

ç ∩<▬%▌ê▓jFo

Run and debug it

Same method as the Canvas answer.

Why does this post require moderator attention?
You might want to add some details to your flag.

0 comments

Sign up to answer this question »

This community is part of the Codidact network. We have other communities too — take a look!

You can also join us in chat!

Want to advertise this community? Use our templates!