Skip to main content
explanation
Source Link
Adám
  • 31.1k
  • 3
  • 124
  • 287

APL (Dyalog), 43 bytes

Requires ⎕IO←0 which is default on many systems.

'#',{6⍴(≢⍵)⊃'0'⍵, ⍵(2/⍵)(∊⍵,¨⊃⌽⍵)(⍵,⌽⍵)⍵}1↓⍞

Try it online!Try it online!

1↓⍞ drop the first character (the hash)

{ apply the following anonymous function

(≢⍵)⊃ use the length of the argument to pick one of the following seven values:
'0' a zero
 the argument
 the argument
2/⍵ two (2) of each (/) of the argument ()
∊⍵,¨⊃⌽⍵ the flattened () argument () followed each () by the first () of the reversed () argument ()
⍵,⌽⍵ the argument () prepended (,) to the reversed () argument ()
 the argument

6⍴ repeat elements from that until a length of six is achieved

} end of anonymous function

'#', prepend a hash to that

APL (Dyalog), 43 bytes

'#',{6⍴(≢⍵)⊃'0'⍵,⍵(2/⍵)(∊⍵,¨⊃⌽⍵)(⍵,⌽⍵)⍵}1↓⍞

Try it online!

APL (Dyalog), 43 bytes

Requires ⎕IO←0 which is default on many systems.

'#',{6⍴(≢⍵)⊃'0'⍵ ⍵(2/⍵)(∊⍵,¨⊃⌽⍵)(⍵,⌽⍵)⍵}1↓⍞

Try it online!

1↓⍞ drop the first character (the hash)

{ apply the following anonymous function

(≢⍵)⊃ use the length of the argument to pick one of the following seven values:
'0' a zero
 the argument
 the argument
2/⍵ two (2) of each (/) of the argument ()
∊⍵,¨⊃⌽⍵ the flattened () argument () followed each () by the first () of the reversed () argument ()
⍵,⌽⍵ the argument () prepended (,) to the reversed () argument ()
 the argument

6⍴ repeat elements from that until a length of six is achieved

} end of anonymous function

'#', prepend a hash to that

Source Link
Adám
  • 31.1k
  • 3
  • 124
  • 287

APL (Dyalog), 43 bytes

'#',{6⍴(≢⍵)⊃'0'⍵,⍵(2/⍵)(∊⍵,¨⊃⌽⍵)(⍵,⌽⍵)⍵}1↓⍞

Try it online!