29
\$\begingroup\$

Challenge :

Given an integer n as input. Create a diamond that is 2x the given number n.

Input :

Input is integer n and 2 < n ≤ 3000.

Output :

Output will be a string and it will be in form of a diamond consisting of + with an addition line at the start showing n using +

Examples :

D(3) :

+++
  +
 +++
+++++
+++++
 +++
  +

D(5) :

+++++
    +
   +++
  +++++
 +++++++
+++++++++
+++++++++
 +++++++
  +++++
   +++
    +

D(6) : 

++++++
     +
    +++
   +++++
  +++++++
 +++++++++
+++++++++++
+++++++++++
 +++++++++
  +++++++
   +++++
    +++
     +

Winning Criteria :

This is so shortest code in bytes for each programming language wins.

\$\endgroup\$
13
  • 1
    \$\begingroup\$ May we take n in unary? \$\endgroup\$
    – Adám
    Apr 19, 2018 at 7:16
  • 4
    \$\begingroup\$ … using + as tally mark? \$\endgroup\$
    – Adám
    Apr 19, 2018 at 7:17
  • 1
    \$\begingroup\$ Can you add a test case where n is even? \$\endgroup\$
    – Shaggy
    Apr 19, 2018 at 10:09
  • 2
    \$\begingroup\$ @Shaggy : sure why not. I will add that right away. Thanks \$\endgroup\$ Apr 19, 2018 at 10:11
  • 2
    \$\begingroup\$ This is a grenade. \$\endgroup\$ Apr 21, 2018 at 23:12

50 Answers 50

36
\$\begingroup\$

brainfuck, 151 139 bytes

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

Try it online!

Takes input via unary, with +s as tally marks (allowed by the poster). Decided to rework this, as I thought the old one was a bit longer than it could be (though this one is too!).

Old Version (151 bytes):

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

Try it online!

Takes input as the starting cell. I couldn't think of a way to leverage the first half to help with the second, so there's a loop for each of them.

How It Works:

 >--[>+<++++++]  Create 43 ('+') two space to the left of n
 <[->+>.<<]      Print n '+'s while preserving n
 ++++++++[-<+<++++>>]<++  Create 32 (' ') and 10 ('\n')
                         Tape: 32 10 0 n 43 t
 >>
 [ Loop over the first half of the diamond
   <<.>>         Print a newline
   -[-<+<<.>>>]  Decrement n and print n spaces
   <[->+<]       Restore n
   >>>+[-<.>>+<] Increment t and print t '+'s
   >+[-<+>]<<<   Increment t again and restore it
]>>
[ Loop over the second half
  <<<<.>>        Print a newline
  [-<+<<.>>>]<   Print n spaces
  [->+<]>+       Restore and increment n
  >>-[-<.>>+<]   Decrement t and print t '+'s
  >-[-<+>]<      Decrement t again and restore it
]

And just for fun:

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

Try it online!

\$\endgroup\$
1
  • 3
    \$\begingroup\$ You got my vote for the just for the fun thing. Cool answer \$\endgroup\$ Apr 20, 2018 at 11:32
16
\$\begingroup\$

Canvas, 9 bytes

+×O{+×]±╪

Try it here!

Explanation (some characters have been replaced to look monospace):

+×O{+×]±╪
+×         repeat "+" input times
  O        output that
   {  ]    map over 1..input
    +×       repeat "+" that many times
       ±   interpret the array as a 2D string, and reverse it
        ╪  quad-palindromize with 1 horizontal overlap and 0 vertical overlap
\$\endgroup\$
0
13
\$\begingroup\$

Python 3, 95 94 75 bytes

def f(n):a=[' '*(n+~i)+'+'*(i-~i)for i in range(n)];return['+'*n]+a+a[::-1]

Try it online!


My first attempt at some golfing, any suggestions for improvement are welcome.

EDIT: saved 1 byte thanks to Kevin Cruijssen

EDIT: removed misunderstanding about byte count

EDIT: Saved many more bytes thanks to Jo King and user202729

\$\endgroup\$
10
  • 6
    \$\begingroup\$ Welcome to PPCG! :) \$\endgroup\$
    – Shaggy
    Apr 19, 2018 at 7:36
  • 1
    \$\begingroup\$ Also, if you change to Python 2, print'\n'.join(['+'*n]+a+a[::-1]) can be used without parenthesis to save 2 more bytes. +1 from me though. Nice first answer. :) \$\endgroup\$ Apr 19, 2018 at 7:57
  • 1
    \$\begingroup\$ Submissions can be either a full program (nothing in header/footer) or a function (which must defines a function (or reference, in case of anonymous function such as lambda)). \$\endgroup\$
    – DELETE_ME
    Apr 19, 2018 at 14:28
  • 2
    \$\begingroup\$ And, 2*i+1 == i+i+1 == i-(-i-1) == i-~i. \$\endgroup\$
    – DELETE_ME
    Apr 19, 2018 at 14:30
  • 2
    \$\begingroup\$ Great first answer. well done. \$\endgroup\$
    – ElPedro
    Apr 19, 2018 at 19:10
9
\$\begingroup\$

05AB1E, 14 bytes

'+×sL·<'+×∊.c»

Try it online!

Explanation

'+×              # push "+" repeated <input> times
   sL            # push range [1 ... input]
     ·<          # multiply each element by 2 and decrement (x*2-1)
       '+×       # replace each number with the corresponding number of "+"'s
          ∊      # mirror vertically
           .c    # center
             »   # join with the "+"-row created at the start

Also 14 bytes: L‚˜'+×ćs.∞∊.c»

\$\endgroup\$
3
  • 1
    \$\begingroup\$ '+×s·ÅÉ'+×∊.C» using ÅÉ is another \$\endgroup\$ Apr 19, 2018 at 14:21
  • \$\begingroup\$ @MagicOctopusUrn: My initial thought was using ÅÉ but I discarded it because I didn't think of using · to make it work. \$\endgroup\$
    – Emigna
    Apr 19, 2018 at 15:36
  • \$\begingroup\$ sL can be ā for -1 \$\endgroup\$ Sep 15, 2021 at 7:00
5
\$\begingroup\$

Python 3, 79 78 bytes

def f(n):x=[('++'*i+'+').center(n*2)for i in range(n)];return[n*'+']+x+x[::-1]

Try it online!

Thanks to this Tips for golfing Python answer for informing me about the .center function. Returns a list of strings.

\$\endgroup\$
9
  • \$\begingroup\$ Isn't the footer included in the byte count? In that case, my solution is 58 bytes \$\endgroup\$
    – maxb
    Apr 19, 2018 at 9:12
  • \$\begingroup\$ @maxb If you're using a function, it is generally okay to return output as a list of lines \$\endgroup\$
    – Jo King
    Apr 19, 2018 at 11:08
  • \$\begingroup\$ @JoKing : Hum might wanna do a lil recheck ? TRY \$\endgroup\$ Apr 19, 2018 at 12:04
  • \$\begingroup\$ @JoKing : It fails. \$\endgroup\$ Apr 19, 2018 at 12:04
  • 1
    \$\begingroup\$ @MuhammadSalman 1. You’re testing my function for n=3 against the return for n=5, 2. You have a trailing newline in the test, and 3. My code has trailing spaces on each line. Maybe you should just look at the output next time \$\endgroup\$
    – Jo King
    Apr 19, 2018 at 12:16
4
\$\begingroup\$

R, 135 110 96 bytes

function(n){cat("+"<n,"
",sep="")
for(i in c(1:n,n:1))cat(" "<n-i,"+"<2*i-1,"
",sep="")}
"<"=rep

Try it online!

@JayCe with the final cut.

The rep function is assigned to an existing infix operator, such as < or ^ so that rep("+", n) is equivalent to "<"("+", n) which can be written out using < as an infix operator as in "+" < n and shortened to "+"<n.

\$\endgroup\$
4
  • 1
    \$\begingroup\$ Save 25 bytes and make it a function. \$\endgroup\$
    – JayCe
    May 2, 2018 at 2:16
  • \$\begingroup\$ So totally your answer :) Great original code! \$\endgroup\$
    – JayCe
    May 2, 2018 at 23:06
  • \$\begingroup\$ There's some whitespace here that can be removed, and using "+" directly instead of saving it as z saves some bytes! Try it here \$\endgroup\$
    – Giuseppe
    May 5, 2018 at 12:28
  • 1
    \$\begingroup\$ @ngm @Giuseppe On top of Giuseppe's improvement, substitute < for rep to get under 100 chars! Here \$\endgroup\$
    – JayCe
    May 16, 2018 at 16:22
3
\$\begingroup\$

Charcoal, 15 bytes

G→→↙N+↓‖M↑×⊕ⅈ+‖

Try it online! Link is to verbose version of code. Explanation:

G→→↙N+

Print an inverted triangle of +s the height of the input and almost twice the width.

Move the cursor down so it lands on the additional line after the reflection.

‖M↑

Make a mirror image of the triangle.

×⊕ⅈ+

Draw the additional line using the current column to avoid having to read the input again.

Reflect the output so that the additional line points to the left.

\$\endgroup\$
3
\$\begingroup\$

Stax, 11 bytes

ñ1┌╙@↔g+┤a☻

Run and debug it

\$\endgroup\$
3
\$\begingroup\$

Python 3, 76 75 bytes

lambda n:['+'*n]+[' '*(n+~i)+'+'*(i-~i)for i in[*range(n),*range(n)[::-1]]]

Try it online!

\$\endgroup\$
3
\$\begingroup\$

QB64, 82 79 bytes

INPUT n
?STRING$(n,43):FOR a=1TO 2*n:d=a-(a>n)*2*(n-a):?SPC(n-d);STRING$(2*d-1,43):NEXT
\$\endgroup\$
1
  • 3
    \$\begingroup\$ Welcome to PPCG! This is a great first submission, and I've added it to the list of solutions posted while QBasic is Language of the Month. If you like, you can improve this answer by adding a short explanation. Enjoy your time here! \$\endgroup\$
    – DLosc
    Jun 1, 2018 at 22:43
3
\$\begingroup\$

J, 29 22 bytes

-7 bytes thanks to Jonah!

' +'{~#&1,]>:[:+/~|@i:

Try it online!

Original solution:

J, 29 bytes

'+'(,]\(}:@|."1,.])@,]\.)@$~]

Try it online!

Explanation:

'+'$~] - generates the line at the start, which is a seed for the diamond:

   '+'$~]  3
+++

]\,]\. - finds the prefixes (]\) and suffixes (]\.) of the line, making "half" the diamond 

   '+'(]\,]\.)@$~] 3
+  
++ 
+++
+++
++ 
+  

}:@|."1,.] - makes the other "half" of the diamond by reversing each line (|."1)
and dropping its last '+' (}:) and stitches the first half to it (,.])

 '+'(]\(}:@|."1,.])@,]\.)@$~] 3
  +  
 +++ 
+++++
+++++
 +++ 
  +  

, - prepends the initial line to the diamond

'+'(,]\(}:@|."1,.])@,]\.)@$~] 3
+++  
  +  
 +++ 
+++++
+++++
 +++ 
  +  
\$\endgroup\$
3
  • 1
    \$\begingroup\$ 25 - ' +'{~1"+@i.,]>:[:+/~|@i: - Try it online! \$\endgroup\$
    – Jonah
    Mar 25, 2021 at 18:32
  • 1
    \$\begingroup\$ @Jonah Thanks! I have forgotten this one... \$\endgroup\$ Mar 25, 2021 at 18:51
  • 1
    \$\begingroup\$ Just popped in my feed. Also, just realized we can go to 22: Try it online! \$\endgroup\$
    – Jonah
    Mar 25, 2021 at 20:45
3
\$\begingroup\$

Scala, 95 94 bytes

saved 1 byte(s) thanks to the comment.


Golfed version. Try it online!

def f(n:Int)={val a=(0 until n).map(i=>" "*(~i+n)+"+"*(2*i+1)).toSeq;Seq("+"*n)++a++a.reverse}

Ungolfed version.

object Main {
  def f(n: Int): Array[String] = {
    val a = (0 until n).map(i => " "*(n-1-i) + "+"*(2*i+1)).toArray
    Array("+"*n) ++ a ++ a.reverse
  }

  def main(args: Array[String]): Unit = {
    val result = f(10)
    println(result.mkString("\n"))
  }
}

\$\endgroup\$
1
  • \$\begingroup\$ n-1-i can be ~i+n for -1 byte. \$\endgroup\$ Apr 20 at 10:12
2
\$\begingroup\$

JavaScript (Node.js), 106 105 bytes

  • thanks to @Kevin Cruijssen for reducing by 1 byte
n=>[...Array(n*2+1)].map((_,i)=>" ".repeat(i?i>n?i+~n:n-i:0)+"+".repeat(i?i>n?4*n-2*i+1:i*2-1:n)).join`
`

Try it online!

________________________________________________

Second approach

JavaScript (Node.js), 105 100 99 98 bytes

  • thanks to @Kevin Cruijssen for reducing by 1 byte
  • thanks to @ovs for reducing by 1 byte
n=>[X="+"[r="repeat"](n),...x=[...X].map((_,i)=>" "[r](n+~i)+"+"[r](i-~i)),...x.reverse()].join`
`

Try it online!

\$\endgroup\$
1
  • 2
    \$\begingroup\$ Just as a matter of convention, you should have your shortest submission at the top of your post if you have multiple approaches within it. This allows for other people to easily attempt the challenge, search for their language, and see how they compare to your best answer (and is needed for scoreboards to work properly on challenges that have scoreboards) \$\endgroup\$ May 18, 2018 at 16:20
2
\$\begingroup\$

Japt -R, 18 17 bytes

õÈ+Y î+Ãû ê1 iUî+

Try it online!

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

PowerShell, 55 bytes

param($l)'+'*$l;1..$l+$l..1|%{" "*($l-$_)+'+'*($_*2-1)}

Try it online!

\$\endgroup\$
2
  • 1
    \$\begingroup\$ Great answer but the character should be + instead of x. Also you can make your response a bit more community friendly by using Try it online! and adding a link to your answer \$\endgroup\$ Apr 19, 2018 at 21:38
  • 1
    \$\begingroup\$ Derp - can't believe I didn't see that. Thanks! \$\endgroup\$
    – Tor
    Apr 19, 2018 at 21:48
2
\$\begingroup\$

Haskell, 85 82 bytes

Saved 3 bytes thanks to nimi!

n!c=[1..n]>>c
f n|x<-[(n-i)!" "++(i*2-1)!"+"|i<-[1..n]]=unlines$n!"+":x++reverse x

Try it online!

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

Python 3, 98 bytes

def d(s):print("+"*s);t=[("+"*i).center(2*s-1)for i in range(1,2*s,2)];print("\n".join(t+t[::-1]))

Try it online!

Readable version:

def diamond(size):
    print(size * "+")
    top = [("+" * i).center(2*size - 1) for i in range(1, 2*size, 2)]
    print("\n".join(top))
    print("\n".join(reversed(top)))
\$\endgroup\$
1
  • \$\begingroup\$ Much better :) I formatted your entry so that it looks like other answers. You want want to visit tio.run it formats your answer for you and makes it easy for others to reproduce your code. \$\endgroup\$
    – JayCe
    May 16, 2018 at 22:35
2
\$\begingroup\$

05AB1E, 9 8 bytes

Dη€û.C∊»

Try it online! Takes input in unary with + as a tally mark; allowed as per OP's comment.

Dη€û.C∊»  # full program
       »  # join...
D         # implicit input...
       »  # and...
 η        # prefixes of...
D         # implicit input...
  €       # with each element...
   û      # concatenated with...
          # (implicit) current element in list...
   û      # reversed excluding the first character...
    .C    # with...
          # (implicit) each element...
    .C    # centered by spaces to length of longest element in this list (extra space on the left if unequal spaces)...
      ∊   # mirrored vertically...
       »  # by a newline
          # implicit output
\$\endgroup\$
2
  • \$\begingroup\$ 8 bytes with vertical mirror . \$\endgroup\$
    – ovs
    Mar 25, 2021 at 18:31
  • \$\begingroup\$ @ovs Thanks! Added \$\endgroup\$
    – Makonede
    Mar 25, 2021 at 18:32
1
\$\begingroup\$

Ruby, 71 61 bytes

->n{[?+*n]+(a=(1..n).map{|x|?\s*(n-x)+?+*(x+x-1)})+a.reverse}

Try it online!

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

PHP, 103 bytes

for(;$i++<$argn;$s.="
".str_pad(str_pad("",$i*2-1,"+",2),$argn*2-1," ",2))echo"+";echo"$s
",strrev($s);

Run as pipe with `-nR´ or try it online.

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

PowerShell, 58 bytes

param($n)'+'*$n;1..$n+$n..1|%{" "*($n-$_)+"+"*$_+"+"*--$_}

Try it online!

Simply a loop-up and -down, each iterating outputting the appropriate number of spaces and then the appropriate number of plus signs. Ho-hum.

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

F# (Mono), 123 bytes

let d n=
 let t n=String('+',n)
 let s n=t(n*2-1)
 [1..n]@[n.. -1..1]|>Seq.fold(fun a x->a+sprintf"\n%*s"(n+x-1)(s x))(t n)

Try it online!

\$\endgroup\$
9
  • 4
    \$\begingroup\$ Welcome to PPCG. \$\endgroup\$ Apr 19, 2018 at 15:09
  • \$\begingroup\$ This doesn't appear to work. Also, input should be taken from STDIN, a file, or a function argument. We don't allow pre-assigned variables as input. \$\endgroup\$
    – mbomb007
    Apr 19, 2018 at 15:23
  • \$\begingroup\$ @mbomb007 Can you approve it now? \$\endgroup\$
    – user80007
    Apr 19, 2018 at 15:32
  • \$\begingroup\$ @HenrikHansen : Why is this giving an error ? /home/runner/code.fs(2,10): error FS0039: The value or constructor 'String' is not defined. Cannot open assembly 'code.exe': No such file or directory. \$\endgroup\$ Apr 19, 2018 at 15:44
  • 1
    \$\begingroup\$ @HenrikHansen : I suggested an edit. Take a look \$\endgroup\$ Apr 19, 2018 at 16:06
1
\$\begingroup\$

PHP 102 bytes

for($r=str_pad;$i++<$a;$s.="\n".$r($r("",$i*2-1,"+",2),$a*2-1," ",2))echo"+";echo"$s\n",strrev($s);

Ik know it can be much smaller than this ;) Greetz mangas

\$\endgroup\$
4
  • \$\begingroup\$ Welcome to PPCG! \$\endgroup\$ Apr 19, 2018 at 16:40
  • \$\begingroup\$ Your code seems to produce an error when I try to run it? \$\endgroup\$ Apr 19, 2018 at 16:44
  • \$\begingroup\$ Why did you suggest this as a separate edit? It makes no sense. \$\endgroup\$
    – Nissa
    Apr 19, 2018 at 17:08
  • \$\begingroup\$ @StephenLeppik : Oops , probably a mistake on my part. Soory \$\endgroup\$ Apr 19, 2018 at 17:21
1
\$\begingroup\$

sed 4.2.2, 69

Score includes +1 for the -r option to sed.

h
y/1/+/
p
x
s/1\B/ /g
y/1/+/
p
:
s/ \+/+++/p
t
p
:a
s/\+\+/ /p
ta
d

Try it online!

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

Ruby, 59 bytes

->i{[?+*i,b=(1..i).map{|c|' '*(i-c)+?+*(2*c-1)},b.reverse]}

Try it online!

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

Yabasic, 102 bytes

An anonymous function that takes input as a unary number with + tally marks and outputs to the console.

Input""s$
n=Len(s$)
?s$
For i=-n To n
j=Abs(i)
If i For k=2To j?" ";Next:?Mid$(s$+s$,1,2*(n-j)+1)
Next

Try it online!

Alternate Version, 117 bytes

An anonymous function answer that takes input as a decimal integer and outputs to the console.

Input""n
For i=1To n s$=s$+"+"Next
?s$
For i=-n To n
j=Abs(i)
If i For k=2To j?" ";Next:?Mid$(s$+s$,1,2*(n-j)+1)
Next

Try it online!

\$\endgroup\$
2
  • \$\begingroup\$ Anonymous functions? They look like whole programs to me... \$\endgroup\$ May 18, 2018 at 16:10
  • \$\begingroup\$ @ØrjanJohansen this term, for Yabasic, only means that they are not wrapped as a user defined subroutine, are not part of any library and thus cannot be called discretely like builtin functions can be (eg. Abs(x)) . You can read a bit more about this here if you like. \$\endgroup\$ May 18, 2018 at 18:10
1
\$\begingroup\$

JavaScript (Node.js), 183 bytes

a=x=>{g='\n';r=(m,n)=>String.prototype.repeat.call(m,n);k='+';l=r(k,x)+g;c=d='';for(i=0;i++<x;c+=r(' ',x-i)+r(k,i)+r(k,i-1)+g,d+=r(' ',i-1)+r(k,x+1-i)+r(k,x-i)+g);console.log(l+c+d);}

Try it online!

Updated my answer thanks to @JoKing

\$\endgroup\$
2
  • \$\begingroup\$ @JoKing sorry, my mistake, I just update my answer, thank you my friend. \$\endgroup\$
    – NTCG
    May 15, 2018 at 9:04
  • \$\begingroup\$ @JoKing, thank you for your time \$\endgroup\$
    – NTCG
    May 15, 2018 at 23:47
1
\$\begingroup\$

APL (Dyalog Unicode), 25 bytesSBCS

⍪∘⊖⍨c,⍨⌽1↓[2]c←↑,\⎕←⎕/'+'

Try it online!

Explanation:

⍪∘⊖⍨c,⍨⌽1↓[2]c←↑,\⎕←⎕/'+'  ⍝ Full program
                       ⎕/'+'  ⍝ Get input from user as N, replicate '+' N times
                    ⎕←        ⍝ Print above string
                  ,\           ⍝ Find all prefixes of above string, e.g. '+','++','+++' etc.
                 ↑             ⍝ Mix the above into a matrix - right-pads with spaces as needed
               c←              ⍝ Assign above matrix to 'c' for 'corner'
          1↓[2]                ⍝ Drop the first column
        ⌽                     ⍝ Reverse the resulting matrix
     c,⍨                      ⍝ Append 'c' to above - this gives us the top half
⍪∘⊖⍨                         ⍝ Take the above, flip it about the horizontal axis,
                              ⍝ and append it to itself
\$\endgroup\$
1
  • \$\begingroup\$ 1↓[2] -> 0 1↓ or even better: c,⍨⌽1↓[2]c← -> ⍉(⊖⍪1↓⊢)⍉ \$\endgroup\$
    – ngn
    Mar 11, 2019 at 7:36
1
\$\begingroup\$

Canvas (v8), 8 5 bytes

[]↔╪∔

Try it here!

Takes input as unary using + as tally.

The other Canvas answer here uses v2.

\$\endgroup\$
2
  • \$\begingroup\$ Seems to be the exact same algorithm as my answer! D, η»[], €û.C∊↔╪. \$\endgroup\$
    – Makonede
    Mar 25, 2021 at 21:45
  • \$\begingroup\$ @Makonede I grabbed the prefixes idea from your answer actually, but the rest I'll call convergent evolution ;) \$\endgroup\$
    – hakr14
    Mar 25, 2021 at 23:00
1
\$\begingroup\$

Vyxal j, 6 bytes

¦ʁøĊmJ

Try it Online!

How?

¦ʁøĊmJ
¦      # Prefixes of implicit input
 ʁ     # Palindromize each
  øĊ   # Center
    m  # Mirror each
     J # Join the (implicit) input with this
\$\endgroup\$
2

Your Answer

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

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