Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

Required fields*

Print this diamond

This question has been spreading like a virus in my office. There are quite a variety of approaches:

Print the following:

        1
       121
      12321
     1234321
    123454321
   12345654321
  1234567654321
 123456787654321
12345678987654321
 123456787654321
  1234567654321
   12345654321
    123454321
     1234321
      12321
       121
        1

Answers are scored in characters with fewer characters being better.

Answer*

Cancel
4
  • \$\begingroup\$ This doesn't work for me in Dyalog? The ,⍨\1↓⎕d looks right, but adding the mix just results in 1. If I enclose before mixing, I get something closer, but it's still printed all on one line... \$\endgroup\$ Commented Mar 6, 2024 at 2:26
  • \$\begingroup\$ @MarkReed what's your ⎕ml? \$\endgroup\$ Commented Mar 6, 2024 at 9:55
  • \$\begingroup\$ My comment disappeared and I thought it hadn't gone through, or I would have deleted it. Sorry! I thought I had tried different ⎕ml values, but it seems that my first attempt was under ⎕ml = 3; it works under lower levels. \$\endgroup\$ Commented Mar 6, 2024 at 19:02
  • \$\begingroup\$ Well, it works under ⎕ml = 1; it also fails under ⎕ml = 2. \$\endgroup\$ Commented Mar 6, 2024 at 19:08