Lay out the Carpet












23












$begingroup$


Inspired by this SO question.



Challenge:



Input:




  • A string $s$

  • A character $c$


Output:



Create a diamond-square ASCII art of the string in all four directions, with the first character of the string in the center and going outwards. Which is inside a square ASCII-art carpet, with the character as filler. This may sound pretty vague, so here an example:



Input: $s$ = string, $c$ = .

Output:



..........g..........
........g.n.g........
......g.n.i.n.g......
....g.n.i.r.i.n.g....
..g.n.i.r.t.r.i.n.g..
g.n.i.r.t.s.t.r.i.n.g
..g.n.i.r.t.r.i.n.g..
....g.n.i.r.i.n.g....
......g.n.i.n.g......
........g.n.g........
..........g..........


Challenge rules:




  • Input-string may also be a list of characters

  • Output may also be a list of string-lines or matrix of characters

  • Input-string and character are guaranteed to be non-empty

  • The string is guaranteed to not contain the character

  • Both string and character will only be printable ASCII (unicode range [32,126], space ' ' to and including tilde '~')


General rules:




  • This is code-golf, so shortest answer in bytes wins.

    Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.


  • Standard rules apply for your answer with default I/O rules, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return-type, full programs. Your call.


  • Default Loopholes are forbidden.

  • If possible, please add a link with a test for your code (i.e. TIO).

  • Also, adding an explanation for your answer is highly recommended.


Test cases:



Input: $s$ = 11111, $c=$ = 0

Output:



00000000100000000
00000010101000000
00001010101010000
00101010101010100
10101010101010101
00101010101010100
00001010101010000
00000010101000000
00000000100000000


Input: $s$ = 12345ABCDEF, $c$ = #

Output:



####################F####################
##################F#E#F##################
################F#E#D#E#F################
##############F#E#D#C#D#E#F##############
############F#E#D#C#B#C#D#E#F############
##########F#E#D#C#B#A#B#C#D#E#F##########
########F#E#D#C#B#A#5#A#B#C#D#E#F########
######F#E#D#C#B#A#5#4#5#A#B#C#D#E#F######
####F#E#D#C#B#A#5#4#3#4#5#A#B#C#D#E#F####
##F#E#D#C#B#A#5#4#3#2#3#4#5#A#B#C#D#E#F##
F#E#D#C#B#A#5#4#3#2#1#2#3#4#5#A#B#C#D#E#F
##F#E#D#C#B#A#5#4#3#2#3#4#5#A#B#C#D#E#F##
####F#E#D#C#B#A#5#4#3#4#5#A#B#C#D#E#F####
######F#E#D#C#B#A#5#4#5#A#B#C#D#E#F######
########F#E#D#C#B#A#5#A#B#C#D#E#F########
##########F#E#D#C#B#A#B#C#D#E#F##########
############F#E#D#C#B#C#D#E#F############
##############F#E#D#C#D#E#F##############
################F#E#D#E#F################
##################F#E#F##################
####################F####################


Input: $s$ = @+-|-o-|-O, $c$ = :

Output:



::::::::::::::::::O::::::::::::::::::
::::::::::::::::O:-:O::::::::::::::::
::::::::::::::O:-:|:-:O::::::::::::::
::::::::::::O:-:|:-:|:-:O::::::::::::
::::::::::O:-:|:-:o:-:|:-:O::::::::::
::::::::O:-:|:-:o:-:o:-:|:-:O::::::::
::::::O:-:|:-:o:-:|:-:o:-:|:-:O::::::
::::O:-:|:-:o:-:|:-:|:-:o:-:|:-:O::::
::O:-:|:-:o:-:|:-:+:-:|:-:o:-:|:-:O::
O:-:|:-:o:-:|:-:+:@:+:-:|:-:o:-:|:-:O
::O:-:|:-:o:-:|:-:+:-:|:-:o:-:|:-:O::
::::O:-:|:-:o:-:|:-:|:-:o:-:|:-:O::::
::::::O:-:|:-:o:-:|:-:o:-:|:-:O::::::
::::::::O:-:|:-:o:-:o:-:|:-:O::::::::
::::::::::O:-:|:-:o:-:|:-:O::::::::::
::::::::::::O:-:|:-:|:-:O::::::::::::
::::::::::::::O:-:|:-:O::::::::::::::
::::::::::::::::O:-:O::::::::::::::::
::::::::::::::::::O::::::::::::::::::


Input: $s$ = AB, $c$ = c

Output:



ccBcc
BcAcB
ccBcc


Input: $s$ = ~, $c$ = X

Output:



~


Input: $s$ = /^/, $c$ = X

Output:



XXXXXXXXXXXXXXXX
XXXXXXX/XXXXXXX
XXXXX/X^X/XXXXX
XXX/X^XX^X/XXX
X/X^XX/XX^X/X
XXX/X^XX^X/XXX
XXXXX/X^X/XXXXX
XXXXXXX/XXXXXXX
XXXXXXXXXXXXXXXX









share|improve this question











$endgroup$












  • $begingroup$
    Can the string contain spaces?
    $endgroup$
    – Emigna
    17 hours ago






  • 1




    $begingroup$
    @Emigna Yes, all printable ASCII (unicode range [32,126]) are valid input-characters.
    $endgroup$
    – Kevin Cruijssen
    17 hours ago








  • 1




    $begingroup$
    This becomes wonderful to debug if you use characters that visually look like a single character, e.g. ()()().
    $endgroup$
    – Filip Haglund
    16 hours ago










  • $begingroup$
    What should happen if $s$ is empty?
    $endgroup$
    – Solomon Ucko
    7 hours ago










  • $begingroup$
    @SolomonUcko From the rules section: "Input-string and character are guaranteed to be non-empty" :)
    $endgroup$
    – Kevin Cruijssen
    6 hours ago


















23












$begingroup$


Inspired by this SO question.



Challenge:



Input:




  • A string $s$

  • A character $c$


Output:



Create a diamond-square ASCII art of the string in all four directions, with the first character of the string in the center and going outwards. Which is inside a square ASCII-art carpet, with the character as filler. This may sound pretty vague, so here an example:



Input: $s$ = string, $c$ = .

Output:



..........g..........
........g.n.g........
......g.n.i.n.g......
....g.n.i.r.i.n.g....
..g.n.i.r.t.r.i.n.g..
g.n.i.r.t.s.t.r.i.n.g
..g.n.i.r.t.r.i.n.g..
....g.n.i.r.i.n.g....
......g.n.i.n.g......
........g.n.g........
..........g..........


Challenge rules:




  • Input-string may also be a list of characters

  • Output may also be a list of string-lines or matrix of characters

  • Input-string and character are guaranteed to be non-empty

  • The string is guaranteed to not contain the character

  • Both string and character will only be printable ASCII (unicode range [32,126], space ' ' to and including tilde '~')


General rules:




  • This is code-golf, so shortest answer in bytes wins.

    Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.


  • Standard rules apply for your answer with default I/O rules, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return-type, full programs. Your call.


  • Default Loopholes are forbidden.

  • If possible, please add a link with a test for your code (i.e. TIO).

  • Also, adding an explanation for your answer is highly recommended.


Test cases:



Input: $s$ = 11111, $c=$ = 0

Output:



00000000100000000
00000010101000000
00001010101010000
00101010101010100
10101010101010101
00101010101010100
00001010101010000
00000010101000000
00000000100000000


Input: $s$ = 12345ABCDEF, $c$ = #

Output:



####################F####################
##################F#E#F##################
################F#E#D#E#F################
##############F#E#D#C#D#E#F##############
############F#E#D#C#B#C#D#E#F############
##########F#E#D#C#B#A#B#C#D#E#F##########
########F#E#D#C#B#A#5#A#B#C#D#E#F########
######F#E#D#C#B#A#5#4#5#A#B#C#D#E#F######
####F#E#D#C#B#A#5#4#3#4#5#A#B#C#D#E#F####
##F#E#D#C#B#A#5#4#3#2#3#4#5#A#B#C#D#E#F##
F#E#D#C#B#A#5#4#3#2#1#2#3#4#5#A#B#C#D#E#F
##F#E#D#C#B#A#5#4#3#2#3#4#5#A#B#C#D#E#F##
####F#E#D#C#B#A#5#4#3#4#5#A#B#C#D#E#F####
######F#E#D#C#B#A#5#4#5#A#B#C#D#E#F######
########F#E#D#C#B#A#5#A#B#C#D#E#F########
##########F#E#D#C#B#A#B#C#D#E#F##########
############F#E#D#C#B#C#D#E#F############
##############F#E#D#C#D#E#F##############
################F#E#D#E#F################
##################F#E#F##################
####################F####################


Input: $s$ = @+-|-o-|-O, $c$ = :

Output:



::::::::::::::::::O::::::::::::::::::
::::::::::::::::O:-:O::::::::::::::::
::::::::::::::O:-:|:-:O::::::::::::::
::::::::::::O:-:|:-:|:-:O::::::::::::
::::::::::O:-:|:-:o:-:|:-:O::::::::::
::::::::O:-:|:-:o:-:o:-:|:-:O::::::::
::::::O:-:|:-:o:-:|:-:o:-:|:-:O::::::
::::O:-:|:-:o:-:|:-:|:-:o:-:|:-:O::::
::O:-:|:-:o:-:|:-:+:-:|:-:o:-:|:-:O::
O:-:|:-:o:-:|:-:+:@:+:-:|:-:o:-:|:-:O
::O:-:|:-:o:-:|:-:+:-:|:-:o:-:|:-:O::
::::O:-:|:-:o:-:|:-:|:-:o:-:|:-:O::::
::::::O:-:|:-:o:-:|:-:o:-:|:-:O::::::
::::::::O:-:|:-:o:-:o:-:|:-:O::::::::
::::::::::O:-:|:-:o:-:|:-:O::::::::::
::::::::::::O:-:|:-:|:-:O::::::::::::
::::::::::::::O:-:|:-:O::::::::::::::
::::::::::::::::O:-:O::::::::::::::::
::::::::::::::::::O::::::::::::::::::


Input: $s$ = AB, $c$ = c

Output:



ccBcc
BcAcB
ccBcc


Input: $s$ = ~, $c$ = X

Output:



~


Input: $s$ = /^/, $c$ = X

Output:



XXXXXXXXXXXXXXXX
XXXXXXX/XXXXXXX
XXXXX/X^X/XXXXX
XXX/X^XX^X/XXX
X/X^XX/XX^X/X
XXX/X^XX^X/XXX
XXXXX/X^X/XXXXX
XXXXXXX/XXXXXXX
XXXXXXXXXXXXXXXX









share|improve this question











$endgroup$












  • $begingroup$
    Can the string contain spaces?
    $endgroup$
    – Emigna
    17 hours ago






  • 1




    $begingroup$
    @Emigna Yes, all printable ASCII (unicode range [32,126]) are valid input-characters.
    $endgroup$
    – Kevin Cruijssen
    17 hours ago








  • 1




    $begingroup$
    This becomes wonderful to debug if you use characters that visually look like a single character, e.g. ()()().
    $endgroup$
    – Filip Haglund
    16 hours ago










  • $begingroup$
    What should happen if $s$ is empty?
    $endgroup$
    – Solomon Ucko
    7 hours ago










  • $begingroup$
    @SolomonUcko From the rules section: "Input-string and character are guaranteed to be non-empty" :)
    $endgroup$
    – Kevin Cruijssen
    6 hours ago
















23












23








23





$begingroup$


Inspired by this SO question.



Challenge:



Input:




  • A string $s$

  • A character $c$


Output:



Create a diamond-square ASCII art of the string in all four directions, with the first character of the string in the center and going outwards. Which is inside a square ASCII-art carpet, with the character as filler. This may sound pretty vague, so here an example:



Input: $s$ = string, $c$ = .

Output:



..........g..........
........g.n.g........
......g.n.i.n.g......
....g.n.i.r.i.n.g....
..g.n.i.r.t.r.i.n.g..
g.n.i.r.t.s.t.r.i.n.g
..g.n.i.r.t.r.i.n.g..
....g.n.i.r.i.n.g....
......g.n.i.n.g......
........g.n.g........
..........g..........


Challenge rules:




  • Input-string may also be a list of characters

  • Output may also be a list of string-lines or matrix of characters

  • Input-string and character are guaranteed to be non-empty

  • The string is guaranteed to not contain the character

  • Both string and character will only be printable ASCII (unicode range [32,126], space ' ' to and including tilde '~')


General rules:




  • This is code-golf, so shortest answer in bytes wins.

    Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.


  • Standard rules apply for your answer with default I/O rules, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return-type, full programs. Your call.


  • Default Loopholes are forbidden.

  • If possible, please add a link with a test for your code (i.e. TIO).

  • Also, adding an explanation for your answer is highly recommended.


Test cases:



Input: $s$ = 11111, $c=$ = 0

Output:



00000000100000000
00000010101000000
00001010101010000
00101010101010100
10101010101010101
00101010101010100
00001010101010000
00000010101000000
00000000100000000


Input: $s$ = 12345ABCDEF, $c$ = #

Output:



####################F####################
##################F#E#F##################
################F#E#D#E#F################
##############F#E#D#C#D#E#F##############
############F#E#D#C#B#C#D#E#F############
##########F#E#D#C#B#A#B#C#D#E#F##########
########F#E#D#C#B#A#5#A#B#C#D#E#F########
######F#E#D#C#B#A#5#4#5#A#B#C#D#E#F######
####F#E#D#C#B#A#5#4#3#4#5#A#B#C#D#E#F####
##F#E#D#C#B#A#5#4#3#2#3#4#5#A#B#C#D#E#F##
F#E#D#C#B#A#5#4#3#2#1#2#3#4#5#A#B#C#D#E#F
##F#E#D#C#B#A#5#4#3#2#3#4#5#A#B#C#D#E#F##
####F#E#D#C#B#A#5#4#3#4#5#A#B#C#D#E#F####
######F#E#D#C#B#A#5#4#5#A#B#C#D#E#F######
########F#E#D#C#B#A#5#A#B#C#D#E#F########
##########F#E#D#C#B#A#B#C#D#E#F##########
############F#E#D#C#B#C#D#E#F############
##############F#E#D#C#D#E#F##############
################F#E#D#E#F################
##################F#E#F##################
####################F####################


Input: $s$ = @+-|-o-|-O, $c$ = :

Output:



::::::::::::::::::O::::::::::::::::::
::::::::::::::::O:-:O::::::::::::::::
::::::::::::::O:-:|:-:O::::::::::::::
::::::::::::O:-:|:-:|:-:O::::::::::::
::::::::::O:-:|:-:o:-:|:-:O::::::::::
::::::::O:-:|:-:o:-:o:-:|:-:O::::::::
::::::O:-:|:-:o:-:|:-:o:-:|:-:O::::::
::::O:-:|:-:o:-:|:-:|:-:o:-:|:-:O::::
::O:-:|:-:o:-:|:-:+:-:|:-:o:-:|:-:O::
O:-:|:-:o:-:|:-:+:@:+:-:|:-:o:-:|:-:O
::O:-:|:-:o:-:|:-:+:-:|:-:o:-:|:-:O::
::::O:-:|:-:o:-:|:-:|:-:o:-:|:-:O::::
::::::O:-:|:-:o:-:|:-:o:-:|:-:O::::::
::::::::O:-:|:-:o:-:o:-:|:-:O::::::::
::::::::::O:-:|:-:o:-:|:-:O::::::::::
::::::::::::O:-:|:-:|:-:O::::::::::::
::::::::::::::O:-:|:-:O::::::::::::::
::::::::::::::::O:-:O::::::::::::::::
::::::::::::::::::O::::::::::::::::::


Input: $s$ = AB, $c$ = c

Output:



ccBcc
BcAcB
ccBcc


Input: $s$ = ~, $c$ = X

Output:



~


Input: $s$ = /^/, $c$ = X

Output:



XXXXXXXXXXXXXXXX
XXXXXXX/XXXXXXX
XXXXX/X^X/XXXXX
XXX/X^XX^X/XXX
X/X^XX/XX^X/X
XXX/X^XX^X/XXX
XXXXX/X^X/XXXXX
XXXXXXX/XXXXXXX
XXXXXXXXXXXXXXXX









share|improve this question











$endgroup$




Inspired by this SO question.



Challenge:



Input:




  • A string $s$

  • A character $c$


Output:



Create a diamond-square ASCII art of the string in all four directions, with the first character of the string in the center and going outwards. Which is inside a square ASCII-art carpet, with the character as filler. This may sound pretty vague, so here an example:



Input: $s$ = string, $c$ = .

Output:



..........g..........
........g.n.g........
......g.n.i.n.g......
....g.n.i.r.i.n.g....
..g.n.i.r.t.r.i.n.g..
g.n.i.r.t.s.t.r.i.n.g
..g.n.i.r.t.r.i.n.g..
....g.n.i.r.i.n.g....
......g.n.i.n.g......
........g.n.g........
..........g..........


Challenge rules:




  • Input-string may also be a list of characters

  • Output may also be a list of string-lines or matrix of characters

  • Input-string and character are guaranteed to be non-empty

  • The string is guaranteed to not contain the character

  • Both string and character will only be printable ASCII (unicode range [32,126], space ' ' to and including tilde '~')


General rules:




  • This is code-golf, so shortest answer in bytes wins.

    Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.


  • Standard rules apply for your answer with default I/O rules, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return-type, full programs. Your call.


  • Default Loopholes are forbidden.

  • If possible, please add a link with a test for your code (i.e. TIO).

  • Also, adding an explanation for your answer is highly recommended.


Test cases:



Input: $s$ = 11111, $c=$ = 0

Output:



00000000100000000
00000010101000000
00001010101010000
00101010101010100
10101010101010101
00101010101010100
00001010101010000
00000010101000000
00000000100000000


Input: $s$ = 12345ABCDEF, $c$ = #

Output:



####################F####################
##################F#E#F##################
################F#E#D#E#F################
##############F#E#D#C#D#E#F##############
############F#E#D#C#B#C#D#E#F############
##########F#E#D#C#B#A#B#C#D#E#F##########
########F#E#D#C#B#A#5#A#B#C#D#E#F########
######F#E#D#C#B#A#5#4#5#A#B#C#D#E#F######
####F#E#D#C#B#A#5#4#3#4#5#A#B#C#D#E#F####
##F#E#D#C#B#A#5#4#3#2#3#4#5#A#B#C#D#E#F##
F#E#D#C#B#A#5#4#3#2#1#2#3#4#5#A#B#C#D#E#F
##F#E#D#C#B#A#5#4#3#2#3#4#5#A#B#C#D#E#F##
####F#E#D#C#B#A#5#4#3#4#5#A#B#C#D#E#F####
######F#E#D#C#B#A#5#4#5#A#B#C#D#E#F######
########F#E#D#C#B#A#5#A#B#C#D#E#F########
##########F#E#D#C#B#A#B#C#D#E#F##########
############F#E#D#C#B#C#D#E#F############
##############F#E#D#C#D#E#F##############
################F#E#D#E#F################
##################F#E#F##################
####################F####################


Input: $s$ = @+-|-o-|-O, $c$ = :

Output:



::::::::::::::::::O::::::::::::::::::
::::::::::::::::O:-:O::::::::::::::::
::::::::::::::O:-:|:-:O::::::::::::::
::::::::::::O:-:|:-:|:-:O::::::::::::
::::::::::O:-:|:-:o:-:|:-:O::::::::::
::::::::O:-:|:-:o:-:o:-:|:-:O::::::::
::::::O:-:|:-:o:-:|:-:o:-:|:-:O::::::
::::O:-:|:-:o:-:|:-:|:-:o:-:|:-:O::::
::O:-:|:-:o:-:|:-:+:-:|:-:o:-:|:-:O::
O:-:|:-:o:-:|:-:+:@:+:-:|:-:o:-:|:-:O
::O:-:|:-:o:-:|:-:+:-:|:-:o:-:|:-:O::
::::O:-:|:-:o:-:|:-:|:-:o:-:|:-:O::::
::::::O:-:|:-:o:-:|:-:o:-:|:-:O::::::
::::::::O:-:|:-:o:-:o:-:|:-:O::::::::
::::::::::O:-:|:-:o:-:|:-:O::::::::::
::::::::::::O:-:|:-:|:-:O::::::::::::
::::::::::::::O:-:|:-:O::::::::::::::
::::::::::::::::O:-:O::::::::::::::::
::::::::::::::::::O::::::::::::::::::


Input: $s$ = AB, $c$ = c

Output:



ccBcc
BcAcB
ccBcc


Input: $s$ = ~, $c$ = X

Output:



~


Input: $s$ = /^/, $c$ = X

Output:



XXXXXXXXXXXXXXXX
XXXXXXX/XXXXXXX
XXXXX/X^X/XXXXX
XXX/X^XX^X/XXX
X/X^XX/XX^X/X
XXX/X^XX^X/XXX
XXXXX/X^X/XXXXX
XXXXXXX/XXXXXXX
XXXXXXXXXXXXXXXX






code-golf string ascii-art






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 17 hours ago







Kevin Cruijssen

















asked 17 hours ago









Kevin CruijssenKevin Cruijssen

41.6k567215




41.6k567215












  • $begingroup$
    Can the string contain spaces?
    $endgroup$
    – Emigna
    17 hours ago






  • 1




    $begingroup$
    @Emigna Yes, all printable ASCII (unicode range [32,126]) are valid input-characters.
    $endgroup$
    – Kevin Cruijssen
    17 hours ago








  • 1




    $begingroup$
    This becomes wonderful to debug if you use characters that visually look like a single character, e.g. ()()().
    $endgroup$
    – Filip Haglund
    16 hours ago










  • $begingroup$
    What should happen if $s$ is empty?
    $endgroup$
    – Solomon Ucko
    7 hours ago










  • $begingroup$
    @SolomonUcko From the rules section: "Input-string and character are guaranteed to be non-empty" :)
    $endgroup$
    – Kevin Cruijssen
    6 hours ago




















  • $begingroup$
    Can the string contain spaces?
    $endgroup$
    – Emigna
    17 hours ago






  • 1




    $begingroup$
    @Emigna Yes, all printable ASCII (unicode range [32,126]) are valid input-characters.
    $endgroup$
    – Kevin Cruijssen
    17 hours ago








  • 1




    $begingroup$
    This becomes wonderful to debug if you use characters that visually look like a single character, e.g. ()()().
    $endgroup$
    – Filip Haglund
    16 hours ago










  • $begingroup$
    What should happen if $s$ is empty?
    $endgroup$
    – Solomon Ucko
    7 hours ago










  • $begingroup$
    @SolomonUcko From the rules section: "Input-string and character are guaranteed to be non-empty" :)
    $endgroup$
    – Kevin Cruijssen
    6 hours ago


















$begingroup$
Can the string contain spaces?
$endgroup$
– Emigna
17 hours ago




$begingroup$
Can the string contain spaces?
$endgroup$
– Emigna
17 hours ago




1




1




$begingroup$
@Emigna Yes, all printable ASCII (unicode range [32,126]) are valid input-characters.
$endgroup$
– Kevin Cruijssen
17 hours ago






$begingroup$
@Emigna Yes, all printable ASCII (unicode range [32,126]) are valid input-characters.
$endgroup$
– Kevin Cruijssen
17 hours ago






1




1




$begingroup$
This becomes wonderful to debug if you use characters that visually look like a single character, e.g. ()()().
$endgroup$
– Filip Haglund
16 hours ago




$begingroup$
This becomes wonderful to debug if you use characters that visually look like a single character, e.g. ()()().
$endgroup$
– Filip Haglund
16 hours ago












$begingroup$
What should happen if $s$ is empty?
$endgroup$
– Solomon Ucko
7 hours ago




$begingroup$
What should happen if $s$ is empty?
$endgroup$
– Solomon Ucko
7 hours ago












$begingroup$
@SolomonUcko From the rules section: "Input-string and character are guaranteed to be non-empty" :)
$endgroup$
– Kevin Cruijssen
6 hours ago






$begingroup$
@SolomonUcko From the rules section: "Input-string and character are guaranteed to be non-empty" :)
$endgroup$
– Kevin Cruijssen
6 hours ago












15 Answers
15






active

oldest

votes


















4












$begingroup$


Python 2, 97 96 90 84 bytes





def f(s,c):r=range(len(s));return[c.join(c*i+s[:i:-1]+s[i:]+c*i)for i in r[:0:-1]+r]


Try it online!






share|improve this answer











$endgroup$





















    4












    $begingroup$


    R, 118 bytes





    function(a,d,n=length(a))for(i in c(n:1,1:n)[-n])cat(z<-rep(d,2*i-2),paste(c(a[n:i],a[0:-i]),collapse=d),z,'
    ',sep='')


    Try it online!



    Thanks to Giuseppe for locating and fixing an error.






    share|improve this answer











    $endgroup$













    • $begingroup$
      I guess I need to drop my aversion to for loops in R, at least for golfing.
      $endgroup$
      – Aaron Hayman
      10 hours ago










    • $begingroup$
      @Giuseppe, thanks, I shouldn't be so lazy about inclusion of extra test cases!
      $endgroup$
      – Kirill L.
      10 hours ago



















    3












    $begingroup$


    Japt, 15 bytes



    Returns an array of lines



    Ôå+ ®¬qV êÃûV ê


    Try it



    Ôå+ ®¬qV êÃûV ê     :Implicit input of strings U=s & V=c
    Ô :Reverse U
    å+ :Prefixes
    ® :Map
    ¬ : Split
    qV : Join with V
    ê : Palindromise
    Ã :End map
    ûV :Centre pad each string with V, to the length of the longest
    ê :Palindromise





    share|improve this answer









    $endgroup$





















      3












      $begingroup$


      05AB1E, 15 11 bytes



      .sûsζøsýí€û


      Try it online!
      or as a Test Suite



      Explanation



      .s            # push suffixes of input
      û # palendromize this list
      sζ # transpose using the second input as filler
      ø # transpose back
      sý # merge each on the second input
      í # reverse each row
      €û # palendromize each row





      share|improve this answer











      $endgroup$













      • $begingroup$
        I'm afraid the reflects cause the last test case /^/ to fail, since the becomes / and vice-versa.
        $endgroup$
        – Kevin Cruijssen
        16 hours ago








      • 1




        $begingroup$
        @KevinCruijssen: Yeah. Fortunately it didn't cost any bytes to fix it. I still feel as if there should be a better way of doing this though, so I'll keep looking.
        $endgroup$
        – Emigna
        16 hours ago










      • $begingroup$
        "Output may also be a list of string-lines or matrix of characters", so you can move the » to the footer. :)
        $endgroup$
        – Kevin Cruijssen
        15 hours ago










      • $begingroup$
        @KevinCruijssen Ah right. I glanced over that part. Thanks :)
        $endgroup$
        – Emigna
        14 hours ago



















      3












      $begingroup$


      R, an ugly 118 bytes version



      By letting the input be a vector of single characters, and outputting a matrix instead of printing nice ascii art.





      function(s,C,l=length(s),L=4*l-3,k=2*l-1,y=abs(rep(1:k,L)-l)+abs(rep(1:L,e=k)-k)/2+1)matrix(ifelse(y%%1|y>l,C,s[y]),k)


      Try it online!




      R, 161 157 bytes



      saved 4 bytes by using ifelse instead of conditionally modifying y



      function(S,C,l=nchar(S),L=4*l-3,k=2*l-1,y=abs(rep(1:L,k)-k)/2+abs(rep(1:k,e=L)-l)+1)cat(rbind(matrix(ifelse(y%%1|y>l,C,el(strsplit(S,''))[y]),L),'
      '),sep='')


      Try it online!



      ungolfed and commented



      function(S,C){
      s=el(strsplit(S,''))
      l=nchar(S)
      L=4*l-3
      k=2*l-1
      y=abs(rep(1:L,k)-k)/2+abs(rep(1:k,e=L)-l)+1 # distance from centre
      y[!!y%%1]=l+1 # set non integers to one more than length of string
      y[y>l]=l+1 # set number beyond length of string to one more than length of string
      M = rbind(matrix(c(s,C)[y],L),'n') # build matrix and add line returns
      cat(M,sep='') # print the matrix as a string
      }


      hmmm, seems like the longest answer so far!






      share|improve this answer











      $endgroup$













      • $begingroup$
        Oh dear, should have looked at the question better
        $endgroup$
        – Aaron Hayman
        13 hours ago








      • 1




        $begingroup$
        @KevinCruijssen I have fixed it now
        $endgroup$
        – Aaron Hayman
        12 hours ago






      • 1




        $begingroup$
        for +15 bytes, you can make your ugly answer ascii-art: Try it online!
        $endgroup$
        – Giuseppe
        9 hours ago



















      2












      $begingroup$


      Charcoal, 15 bytes



      UBηEθ✂θκ‖O↑←UE¹


      Try it online! Link is to verbose version of code. Originally submitted as a comment on the now deleted sandbox post. Explanation:



      UBη


      Set the background to the second input c.



      Eθ✂θκ


      Map over the first input s to generate all suffixes and implicitly print them on separate lines.



      ‖O↑←


      Reflect horizontally and vertically.



      UE¹


      Add extra space horizontally.






      share|improve this answer









      $endgroup$





















        2












        $begingroup$


        Japt, 16 bytes



        Note: I'll golf it :)



        Ôå+ ®¬qVÃùV mê ê


        Try it online!






        share|improve this answer









        $endgroup$













        • $begingroup$
          It's fairly similar to the other Japt answer, but in a different order, isn't it? I don't know Japt, but I see similar characters in both answers. ;)
          $endgroup$
          – Kevin Cruijssen
          14 hours ago










        • $begingroup$
          @KevinCruijssen Yeah, both are almost the same, for now
          $endgroup$
          – Luis felipe De jesus Munoz
          14 hours ago










        • $begingroup$
          @KevinCruijssen, Luis developed this independently from my solution.
          $endgroup$
          – Shaggy
          11 hours ago



















        2












        $begingroup$


        PowerShell, 120 bytes





        param($s,$c)($s,(($l=$s.length-1)..0+1..$l|%{($x=$c*(2*$_))+($s[($_,($l..$_+($_+1)..$l))[$_-ne$l]]-join$c)+$x}))[$l-gt0]


        Try it online!



        Some days, having index ranges instead of slices really hurts. Today is one of those days. Due to conjoined ranges messing up when dealing with single elements (e.g. returning 0..0+1..0), special-casing is used to avoid it altogether (at the cost of many bytes).






        share|improve this answer











        $endgroup$





















          2












          $begingroup$


          Jelly, 11 bytes



          jÐƤṚzṚŒḄZŒḄ


          Try it online!



          Left argument: $s$.

          Right argument: $c$ (as a single character, not as a string).

          Output: List of Jelly strings (appears as a list of lists of 1-char Python strings, replace ŒṘ with Y to see the n-joined output).






          share|improve this answer









          $endgroup$





















            2












            $begingroup$


            PowerShell, 82 83 bytes



            +2 bytes thanks Veskah: the single character case bug fixed



            -1 byte: The rule Input-string may also be a list of characters used





            $c,$s=$args
            ($s|%{(-join$s|% s*g $i)+$c*$i++})[($r=$i..0+1..$i)]|%{"$_"[$r]-join$c}


            Try it online!



            Less golfed:



            $c,$s=$args
            $southEast = $s|%{
            (-join$s|% substring $i) + $c*$i++
            }
            $range=$i..0+1..$i
            $southEast[$range]|%{
            "$_"[$range]-join$c
            }





            share|improve this answer











            $endgroup$









            • 1




              $begingroup$
              Looks like this breaks for the single character case. There's just an empty line in the TIO link for ~
              $endgroup$
              – Veskah
              9 hours ago












            • $begingroup$
              Indeed. Thanks!
              $endgroup$
              – mazzy
              6 hours ago



















            1












            $begingroup$


            Ruby, 95 84 75 bytes





            ->a,c{(1...2*z=a.size).map{|i|s=a[j=(z-i).abs,z]*c+c*2*j;s.reverse.chop+s}}


            Try it online!



            Takes input string as an array of chars. Returns an array of strings.






            share|improve this answer











            $endgroup$





















              1












              $begingroup$


              Wolfram Language (Mathematica), 121 bytes



              Join[q=Table[(v=Table[#2,2(l-k)])<>Riffle[Join[(h=Reverse)[n=(g=Take)[#,-k]],g[n,-k+1]],#2]<>v,{k,l=Length@#}],Rest@h@q]&


              Try it online!






              share|improve this answer









              $endgroup$





















                1












                $begingroup$


                J, 59 56 bytes



                ,{~[:((0-2*#)}.[:,0,:"0({:>:t)*t=:]+/<:)[:(|.@}.,])#@]


                Try it online!



                Too long solution for J ... (entirely my fault)






                share|improve this answer











                $endgroup$





















                  1












                  $begingroup$


                  Japt, 15 bytes



                  Ôå+ ê ®ê ¬qV
                  ûV


                  Try it






                  share|improve this answer











                  $endgroup$





















                    1












                    $begingroup$


                    Perl 5 with -lF, -M5.010, 71 bytes





                    $"=<>;$A=abs,$_="@F[$A..$#F]".$"x($A*2),/./,say reverse.$' for-$#F..$#F


                    Try it online!






                    share|improve this answer









                    $endgroup$













                      Your Answer





                      StackExchange.ifUsing("editor", function () {
                      return StackExchange.using("mathjaxEditing", function () {
                      StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
                      StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
                      });
                      });
                      }, "mathjax-editing");

                      StackExchange.ifUsing("editor", function () {
                      StackExchange.using("externalEditor", function () {
                      StackExchange.using("snippets", function () {
                      StackExchange.snippets.init();
                      });
                      });
                      }, "code-snippets");

                      StackExchange.ready(function() {
                      var channelOptions = {
                      tags: "".split(" "),
                      id: "200"
                      };
                      initTagRenderer("".split(" "), "".split(" "), channelOptions);

                      StackExchange.using("externalEditor", function() {
                      // Have to fire editor after snippets, if snippets enabled
                      if (StackExchange.settings.snippets.snippetsEnabled) {
                      StackExchange.using("snippets", function() {
                      createEditor();
                      });
                      }
                      else {
                      createEditor();
                      }
                      });

                      function createEditor() {
                      StackExchange.prepareEditor({
                      heartbeatType: 'answer',
                      autoActivateHeartbeat: false,
                      convertImagesToLinks: false,
                      noModals: true,
                      showLowRepImageUploadWarning: true,
                      reputationToPostImages: null,
                      bindNavPrevention: true,
                      postfix: "",
                      imageUploader: {
                      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                      allowUrls: true
                      },
                      onDemand: true,
                      discardSelector: ".discard-answer"
                      ,immediatelyShowMarkdownHelp:true
                      });


                      }
                      });














                      draft saved

                      draft discarded


















                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f182212%2flay-out-the-carpet%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown

























                      15 Answers
                      15






                      active

                      oldest

                      votes








                      15 Answers
                      15






                      active

                      oldest

                      votes









                      active

                      oldest

                      votes






                      active

                      oldest

                      votes









                      4












                      $begingroup$


                      Python 2, 97 96 90 84 bytes





                      def f(s,c):r=range(len(s));return[c.join(c*i+s[:i:-1]+s[i:]+c*i)for i in r[:0:-1]+r]


                      Try it online!






                      share|improve this answer











                      $endgroup$


















                        4












                        $begingroup$


                        Python 2, 97 96 90 84 bytes





                        def f(s,c):r=range(len(s));return[c.join(c*i+s[:i:-1]+s[i:]+c*i)for i in r[:0:-1]+r]


                        Try it online!






                        share|improve this answer











                        $endgroup$
















                          4












                          4








                          4





                          $begingroup$


                          Python 2, 97 96 90 84 bytes





                          def f(s,c):r=range(len(s));return[c.join(c*i+s[:i:-1]+s[i:]+c*i)for i in r[:0:-1]+r]


                          Try it online!






                          share|improve this answer











                          $endgroup$




                          Python 2, 97 96 90 84 bytes





                          def f(s,c):r=range(len(s));return[c.join(c*i+s[:i:-1]+s[i:]+c*i)for i in r[:0:-1]+r]


                          Try it online!







                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited 16 hours ago

























                          answered 17 hours ago









                          TFeldTFeld

                          16.1k21449




                          16.1k21449























                              4












                              $begingroup$


                              R, 118 bytes





                              function(a,d,n=length(a))for(i in c(n:1,1:n)[-n])cat(z<-rep(d,2*i-2),paste(c(a[n:i],a[0:-i]),collapse=d),z,'
                              ',sep='')


                              Try it online!



                              Thanks to Giuseppe for locating and fixing an error.






                              share|improve this answer











                              $endgroup$













                              • $begingroup$
                                I guess I need to drop my aversion to for loops in R, at least for golfing.
                                $endgroup$
                                – Aaron Hayman
                                10 hours ago










                              • $begingroup$
                                @Giuseppe, thanks, I shouldn't be so lazy about inclusion of extra test cases!
                                $endgroup$
                                – Kirill L.
                                10 hours ago
















                              4












                              $begingroup$


                              R, 118 bytes





                              function(a,d,n=length(a))for(i in c(n:1,1:n)[-n])cat(z<-rep(d,2*i-2),paste(c(a[n:i],a[0:-i]),collapse=d),z,'
                              ',sep='')


                              Try it online!



                              Thanks to Giuseppe for locating and fixing an error.






                              share|improve this answer











                              $endgroup$













                              • $begingroup$
                                I guess I need to drop my aversion to for loops in R, at least for golfing.
                                $endgroup$
                                – Aaron Hayman
                                10 hours ago










                              • $begingroup$
                                @Giuseppe, thanks, I shouldn't be so lazy about inclusion of extra test cases!
                                $endgroup$
                                – Kirill L.
                                10 hours ago














                              4












                              4








                              4





                              $begingroup$


                              R, 118 bytes





                              function(a,d,n=length(a))for(i in c(n:1,1:n)[-n])cat(z<-rep(d,2*i-2),paste(c(a[n:i],a[0:-i]),collapse=d),z,'
                              ',sep='')


                              Try it online!



                              Thanks to Giuseppe for locating and fixing an error.






                              share|improve this answer











                              $endgroup$




                              R, 118 bytes





                              function(a,d,n=length(a))for(i in c(n:1,1:n)[-n])cat(z<-rep(d,2*i-2),paste(c(a[n:i],a[0:-i]),collapse=d),z,'
                              ',sep='')


                              Try it online!



                              Thanks to Giuseppe for locating and fixing an error.







                              share|improve this answer














                              share|improve this answer



                              share|improve this answer








                              edited 10 hours ago

























                              answered 11 hours ago









                              Kirill L.Kirill L.

                              5,8431526




                              5,8431526












                              • $begingroup$
                                I guess I need to drop my aversion to for loops in R, at least for golfing.
                                $endgroup$
                                – Aaron Hayman
                                10 hours ago










                              • $begingroup$
                                @Giuseppe, thanks, I shouldn't be so lazy about inclusion of extra test cases!
                                $endgroup$
                                – Kirill L.
                                10 hours ago


















                              • $begingroup$
                                I guess I need to drop my aversion to for loops in R, at least for golfing.
                                $endgroup$
                                – Aaron Hayman
                                10 hours ago










                              • $begingroup$
                                @Giuseppe, thanks, I shouldn't be so lazy about inclusion of extra test cases!
                                $endgroup$
                                – Kirill L.
                                10 hours ago
















                              $begingroup$
                              I guess I need to drop my aversion to for loops in R, at least for golfing.
                              $endgroup$
                              – Aaron Hayman
                              10 hours ago




                              $begingroup$
                              I guess I need to drop my aversion to for loops in R, at least for golfing.
                              $endgroup$
                              – Aaron Hayman
                              10 hours ago












                              $begingroup$
                              @Giuseppe, thanks, I shouldn't be so lazy about inclusion of extra test cases!
                              $endgroup$
                              – Kirill L.
                              10 hours ago




                              $begingroup$
                              @Giuseppe, thanks, I shouldn't be so lazy about inclusion of extra test cases!
                              $endgroup$
                              – Kirill L.
                              10 hours ago











                              3












                              $begingroup$


                              Japt, 15 bytes



                              Returns an array of lines



                              Ôå+ ®¬qV êÃûV ê


                              Try it



                              Ôå+ ®¬qV êÃûV ê     :Implicit input of strings U=s & V=c
                              Ô :Reverse U
                              å+ :Prefixes
                              ® :Map
                              ¬ : Split
                              qV : Join with V
                              ê : Palindromise
                              Ã :End map
                              ûV :Centre pad each string with V, to the length of the longest
                              ê :Palindromise





                              share|improve this answer









                              $endgroup$


















                                3












                                $begingroup$


                                Japt, 15 bytes



                                Returns an array of lines



                                Ôå+ ®¬qV êÃûV ê


                                Try it



                                Ôå+ ®¬qV êÃûV ê     :Implicit input of strings U=s & V=c
                                Ô :Reverse U
                                å+ :Prefixes
                                ® :Map
                                ¬ : Split
                                qV : Join with V
                                ê : Palindromise
                                Ã :End map
                                ûV :Centre pad each string with V, to the length of the longest
                                ê :Palindromise





                                share|improve this answer









                                $endgroup$
















                                  3












                                  3








                                  3





                                  $begingroup$


                                  Japt, 15 bytes



                                  Returns an array of lines



                                  Ôå+ ®¬qV êÃûV ê


                                  Try it



                                  Ôå+ ®¬qV êÃûV ê     :Implicit input of strings U=s & V=c
                                  Ô :Reverse U
                                  å+ :Prefixes
                                  ® :Map
                                  ¬ : Split
                                  qV : Join with V
                                  ê : Palindromise
                                  Ã :End map
                                  ûV :Centre pad each string with V, to the length of the longest
                                  ê :Palindromise





                                  share|improve this answer









                                  $endgroup$




                                  Japt, 15 bytes



                                  Returns an array of lines



                                  Ôå+ ®¬qV êÃûV ê


                                  Try it



                                  Ôå+ ®¬qV êÃûV ê     :Implicit input of strings U=s & V=c
                                  Ô :Reverse U
                                  å+ :Prefixes
                                  ® :Map
                                  ¬ : Split
                                  qV : Join with V
                                  ê : Palindromise
                                  Ã :End map
                                  ûV :Centre pad each string with V, to the length of the longest
                                  ê :Palindromise






                                  share|improve this answer












                                  share|improve this answer



                                  share|improve this answer










                                  answered 17 hours ago









                                  ShaggyShaggy

                                  19k21667




                                  19k21667























                                      3












                                      $begingroup$


                                      05AB1E, 15 11 bytes



                                      .sûsζøsýí€û


                                      Try it online!
                                      or as a Test Suite



                                      Explanation



                                      .s            # push suffixes of input
                                      û # palendromize this list
                                      sζ # transpose using the second input as filler
                                      ø # transpose back
                                      sý # merge each on the second input
                                      í # reverse each row
                                      €û # palendromize each row





                                      share|improve this answer











                                      $endgroup$













                                      • $begingroup$
                                        I'm afraid the reflects cause the last test case /^/ to fail, since the becomes / and vice-versa.
                                        $endgroup$
                                        – Kevin Cruijssen
                                        16 hours ago








                                      • 1




                                        $begingroup$
                                        @KevinCruijssen: Yeah. Fortunately it didn't cost any bytes to fix it. I still feel as if there should be a better way of doing this though, so I'll keep looking.
                                        $endgroup$
                                        – Emigna
                                        16 hours ago










                                      • $begingroup$
                                        "Output may also be a list of string-lines or matrix of characters", so you can move the » to the footer. :)
                                        $endgroup$
                                        – Kevin Cruijssen
                                        15 hours ago










                                      • $begingroup$
                                        @KevinCruijssen Ah right. I glanced over that part. Thanks :)
                                        $endgroup$
                                        – Emigna
                                        14 hours ago
















                                      3












                                      $begingroup$


                                      05AB1E, 15 11 bytes



                                      .sûsζøsýí€û


                                      Try it online!
                                      or as a Test Suite



                                      Explanation



                                      .s            # push suffixes of input
                                      û # palendromize this list
                                      sζ # transpose using the second input as filler
                                      ø # transpose back
                                      sý # merge each on the second input
                                      í # reverse each row
                                      €û # palendromize each row





                                      share|improve this answer











                                      $endgroup$













                                      • $begingroup$
                                        I'm afraid the reflects cause the last test case /^/ to fail, since the becomes / and vice-versa.
                                        $endgroup$
                                        – Kevin Cruijssen
                                        16 hours ago








                                      • 1




                                        $begingroup$
                                        @KevinCruijssen: Yeah. Fortunately it didn't cost any bytes to fix it. I still feel as if there should be a better way of doing this though, so I'll keep looking.
                                        $endgroup$
                                        – Emigna
                                        16 hours ago










                                      • $begingroup$
                                        "Output may also be a list of string-lines or matrix of characters", so you can move the » to the footer. :)
                                        $endgroup$
                                        – Kevin Cruijssen
                                        15 hours ago










                                      • $begingroup$
                                        @KevinCruijssen Ah right. I glanced over that part. Thanks :)
                                        $endgroup$
                                        – Emigna
                                        14 hours ago














                                      3












                                      3








                                      3





                                      $begingroup$


                                      05AB1E, 15 11 bytes



                                      .sûsζøsýí€û


                                      Try it online!
                                      or as a Test Suite



                                      Explanation



                                      .s            # push suffixes of input
                                      û # palendromize this list
                                      sζ # transpose using the second input as filler
                                      ø # transpose back
                                      sý # merge each on the second input
                                      í # reverse each row
                                      €û # palendromize each row





                                      share|improve this answer











                                      $endgroup$




                                      05AB1E, 15 11 bytes



                                      .sûsζøsýí€û


                                      Try it online!
                                      or as a Test Suite



                                      Explanation



                                      .s            # push suffixes of input
                                      û # palendromize this list
                                      sζ # transpose using the second input as filler
                                      ø # transpose back
                                      sý # merge each on the second input
                                      í # reverse each row
                                      €û # palendromize each row






                                      share|improve this answer














                                      share|improve this answer



                                      share|improve this answer








                                      edited 14 hours ago

























                                      answered 16 hours ago









                                      EmignaEmigna

                                      47.2k433143




                                      47.2k433143












                                      • $begingroup$
                                        I'm afraid the reflects cause the last test case /^/ to fail, since the becomes / and vice-versa.
                                        $endgroup$
                                        – Kevin Cruijssen
                                        16 hours ago








                                      • 1




                                        $begingroup$
                                        @KevinCruijssen: Yeah. Fortunately it didn't cost any bytes to fix it. I still feel as if there should be a better way of doing this though, so I'll keep looking.
                                        $endgroup$
                                        – Emigna
                                        16 hours ago










                                      • $begingroup$
                                        "Output may also be a list of string-lines or matrix of characters", so you can move the » to the footer. :)
                                        $endgroup$
                                        – Kevin Cruijssen
                                        15 hours ago










                                      • $begingroup$
                                        @KevinCruijssen Ah right. I glanced over that part. Thanks :)
                                        $endgroup$
                                        – Emigna
                                        14 hours ago


















                                      • $begingroup$
                                        I'm afraid the reflects cause the last test case /^/ to fail, since the becomes / and vice-versa.
                                        $endgroup$
                                        – Kevin Cruijssen
                                        16 hours ago








                                      • 1




                                        $begingroup$
                                        @KevinCruijssen: Yeah. Fortunately it didn't cost any bytes to fix it. I still feel as if there should be a better way of doing this though, so I'll keep looking.
                                        $endgroup$
                                        – Emigna
                                        16 hours ago










                                      • $begingroup$
                                        "Output may also be a list of string-lines or matrix of characters", so you can move the » to the footer. :)
                                        $endgroup$
                                        – Kevin Cruijssen
                                        15 hours ago










                                      • $begingroup$
                                        @KevinCruijssen Ah right. I glanced over that part. Thanks :)
                                        $endgroup$
                                        – Emigna
                                        14 hours ago
















                                      $begingroup$
                                      I'm afraid the reflects cause the last test case /^/ to fail, since the becomes / and vice-versa.
                                      $endgroup$
                                      – Kevin Cruijssen
                                      16 hours ago






                                      $begingroup$
                                      I'm afraid the reflects cause the last test case /^/ to fail, since the becomes / and vice-versa.
                                      $endgroup$
                                      – Kevin Cruijssen
                                      16 hours ago






                                      1




                                      1




                                      $begingroup$
                                      @KevinCruijssen: Yeah. Fortunately it didn't cost any bytes to fix it. I still feel as if there should be a better way of doing this though, so I'll keep looking.
                                      $endgroup$
                                      – Emigna
                                      16 hours ago




                                      $begingroup$
                                      @KevinCruijssen: Yeah. Fortunately it didn't cost any bytes to fix it. I still feel as if there should be a better way of doing this though, so I'll keep looking.
                                      $endgroup$
                                      – Emigna
                                      16 hours ago












                                      $begingroup$
                                      "Output may also be a list of string-lines or matrix of characters", so you can move the » to the footer. :)
                                      $endgroup$
                                      – Kevin Cruijssen
                                      15 hours ago




                                      $begingroup$
                                      "Output may also be a list of string-lines or matrix of characters", so you can move the » to the footer. :)
                                      $endgroup$
                                      – Kevin Cruijssen
                                      15 hours ago












                                      $begingroup$
                                      @KevinCruijssen Ah right. I glanced over that part. Thanks :)
                                      $endgroup$
                                      – Emigna
                                      14 hours ago




                                      $begingroup$
                                      @KevinCruijssen Ah right. I glanced over that part. Thanks :)
                                      $endgroup$
                                      – Emigna
                                      14 hours ago











                                      3












                                      $begingroup$


                                      R, an ugly 118 bytes version



                                      By letting the input be a vector of single characters, and outputting a matrix instead of printing nice ascii art.





                                      function(s,C,l=length(s),L=4*l-3,k=2*l-1,y=abs(rep(1:k,L)-l)+abs(rep(1:L,e=k)-k)/2+1)matrix(ifelse(y%%1|y>l,C,s[y]),k)


                                      Try it online!




                                      R, 161 157 bytes



                                      saved 4 bytes by using ifelse instead of conditionally modifying y



                                      function(S,C,l=nchar(S),L=4*l-3,k=2*l-1,y=abs(rep(1:L,k)-k)/2+abs(rep(1:k,e=L)-l)+1)cat(rbind(matrix(ifelse(y%%1|y>l,C,el(strsplit(S,''))[y]),L),'
                                      '),sep='')


                                      Try it online!



                                      ungolfed and commented



                                      function(S,C){
                                      s=el(strsplit(S,''))
                                      l=nchar(S)
                                      L=4*l-3
                                      k=2*l-1
                                      y=abs(rep(1:L,k)-k)/2+abs(rep(1:k,e=L)-l)+1 # distance from centre
                                      y[!!y%%1]=l+1 # set non integers to one more than length of string
                                      y[y>l]=l+1 # set number beyond length of string to one more than length of string
                                      M = rbind(matrix(c(s,C)[y],L),'n') # build matrix and add line returns
                                      cat(M,sep='') # print the matrix as a string
                                      }


                                      hmmm, seems like the longest answer so far!






                                      share|improve this answer











                                      $endgroup$













                                      • $begingroup$
                                        Oh dear, should have looked at the question better
                                        $endgroup$
                                        – Aaron Hayman
                                        13 hours ago








                                      • 1




                                        $begingroup$
                                        @KevinCruijssen I have fixed it now
                                        $endgroup$
                                        – Aaron Hayman
                                        12 hours ago






                                      • 1




                                        $begingroup$
                                        for +15 bytes, you can make your ugly answer ascii-art: Try it online!
                                        $endgroup$
                                        – Giuseppe
                                        9 hours ago
















                                      3












                                      $begingroup$


                                      R, an ugly 118 bytes version



                                      By letting the input be a vector of single characters, and outputting a matrix instead of printing nice ascii art.





                                      function(s,C,l=length(s),L=4*l-3,k=2*l-1,y=abs(rep(1:k,L)-l)+abs(rep(1:L,e=k)-k)/2+1)matrix(ifelse(y%%1|y>l,C,s[y]),k)


                                      Try it online!




                                      R, 161 157 bytes



                                      saved 4 bytes by using ifelse instead of conditionally modifying y



                                      function(S,C,l=nchar(S),L=4*l-3,k=2*l-1,y=abs(rep(1:L,k)-k)/2+abs(rep(1:k,e=L)-l)+1)cat(rbind(matrix(ifelse(y%%1|y>l,C,el(strsplit(S,''))[y]),L),'
                                      '),sep='')


                                      Try it online!



                                      ungolfed and commented



                                      function(S,C){
                                      s=el(strsplit(S,''))
                                      l=nchar(S)
                                      L=4*l-3
                                      k=2*l-1
                                      y=abs(rep(1:L,k)-k)/2+abs(rep(1:k,e=L)-l)+1 # distance from centre
                                      y[!!y%%1]=l+1 # set non integers to one more than length of string
                                      y[y>l]=l+1 # set number beyond length of string to one more than length of string
                                      M = rbind(matrix(c(s,C)[y],L),'n') # build matrix and add line returns
                                      cat(M,sep='') # print the matrix as a string
                                      }


                                      hmmm, seems like the longest answer so far!






                                      share|improve this answer











                                      $endgroup$













                                      • $begingroup$
                                        Oh dear, should have looked at the question better
                                        $endgroup$
                                        – Aaron Hayman
                                        13 hours ago








                                      • 1




                                        $begingroup$
                                        @KevinCruijssen I have fixed it now
                                        $endgroup$
                                        – Aaron Hayman
                                        12 hours ago






                                      • 1




                                        $begingroup$
                                        for +15 bytes, you can make your ugly answer ascii-art: Try it online!
                                        $endgroup$
                                        – Giuseppe
                                        9 hours ago














                                      3












                                      3








                                      3





                                      $begingroup$


                                      R, an ugly 118 bytes version



                                      By letting the input be a vector of single characters, and outputting a matrix instead of printing nice ascii art.





                                      function(s,C,l=length(s),L=4*l-3,k=2*l-1,y=abs(rep(1:k,L)-l)+abs(rep(1:L,e=k)-k)/2+1)matrix(ifelse(y%%1|y>l,C,s[y]),k)


                                      Try it online!




                                      R, 161 157 bytes



                                      saved 4 bytes by using ifelse instead of conditionally modifying y



                                      function(S,C,l=nchar(S),L=4*l-3,k=2*l-1,y=abs(rep(1:L,k)-k)/2+abs(rep(1:k,e=L)-l)+1)cat(rbind(matrix(ifelse(y%%1|y>l,C,el(strsplit(S,''))[y]),L),'
                                      '),sep='')


                                      Try it online!



                                      ungolfed and commented



                                      function(S,C){
                                      s=el(strsplit(S,''))
                                      l=nchar(S)
                                      L=4*l-3
                                      k=2*l-1
                                      y=abs(rep(1:L,k)-k)/2+abs(rep(1:k,e=L)-l)+1 # distance from centre
                                      y[!!y%%1]=l+1 # set non integers to one more than length of string
                                      y[y>l]=l+1 # set number beyond length of string to one more than length of string
                                      M = rbind(matrix(c(s,C)[y],L),'n') # build matrix and add line returns
                                      cat(M,sep='') # print the matrix as a string
                                      }


                                      hmmm, seems like the longest answer so far!






                                      share|improve this answer











                                      $endgroup$




                                      R, an ugly 118 bytes version



                                      By letting the input be a vector of single characters, and outputting a matrix instead of printing nice ascii art.





                                      function(s,C,l=length(s),L=4*l-3,k=2*l-1,y=abs(rep(1:k,L)-l)+abs(rep(1:L,e=k)-k)/2+1)matrix(ifelse(y%%1|y>l,C,s[y]),k)


                                      Try it online!




                                      R, 161 157 bytes



                                      saved 4 bytes by using ifelse instead of conditionally modifying y



                                      function(S,C,l=nchar(S),L=4*l-3,k=2*l-1,y=abs(rep(1:L,k)-k)/2+abs(rep(1:k,e=L)-l)+1)cat(rbind(matrix(ifelse(y%%1|y>l,C,el(strsplit(S,''))[y]),L),'
                                      '),sep='')


                                      Try it online!



                                      ungolfed and commented



                                      function(S,C){
                                      s=el(strsplit(S,''))
                                      l=nchar(S)
                                      L=4*l-3
                                      k=2*l-1
                                      y=abs(rep(1:L,k)-k)/2+abs(rep(1:k,e=L)-l)+1 # distance from centre
                                      y[!!y%%1]=l+1 # set non integers to one more than length of string
                                      y[y>l]=l+1 # set number beyond length of string to one more than length of string
                                      M = rbind(matrix(c(s,C)[y],L),'n') # build matrix and add line returns
                                      cat(M,sep='') # print the matrix as a string
                                      }


                                      hmmm, seems like the longest answer so far!







                                      share|improve this answer














                                      share|improve this answer



                                      share|improve this answer








                                      edited 9 hours ago

























                                      answered 13 hours ago









                                      Aaron HaymanAaron Hayman

                                      3115




                                      3115












                                      • $begingroup$
                                        Oh dear, should have looked at the question better
                                        $endgroup$
                                        – Aaron Hayman
                                        13 hours ago








                                      • 1




                                        $begingroup$
                                        @KevinCruijssen I have fixed it now
                                        $endgroup$
                                        – Aaron Hayman
                                        12 hours ago






                                      • 1




                                        $begingroup$
                                        for +15 bytes, you can make your ugly answer ascii-art: Try it online!
                                        $endgroup$
                                        – Giuseppe
                                        9 hours ago


















                                      • $begingroup$
                                        Oh dear, should have looked at the question better
                                        $endgroup$
                                        – Aaron Hayman
                                        13 hours ago








                                      • 1




                                        $begingroup$
                                        @KevinCruijssen I have fixed it now
                                        $endgroup$
                                        – Aaron Hayman
                                        12 hours ago






                                      • 1




                                        $begingroup$
                                        for +15 bytes, you can make your ugly answer ascii-art: Try it online!
                                        $endgroup$
                                        – Giuseppe
                                        9 hours ago
















                                      $begingroup$
                                      Oh dear, should have looked at the question better
                                      $endgroup$
                                      – Aaron Hayman
                                      13 hours ago






                                      $begingroup$
                                      Oh dear, should have looked at the question better
                                      $endgroup$
                                      – Aaron Hayman
                                      13 hours ago






                                      1




                                      1




                                      $begingroup$
                                      @KevinCruijssen I have fixed it now
                                      $endgroup$
                                      – Aaron Hayman
                                      12 hours ago




                                      $begingroup$
                                      @KevinCruijssen I have fixed it now
                                      $endgroup$
                                      – Aaron Hayman
                                      12 hours ago




                                      1




                                      1




                                      $begingroup$
                                      for +15 bytes, you can make your ugly answer ascii-art: Try it online!
                                      $endgroup$
                                      – Giuseppe
                                      9 hours ago




                                      $begingroup$
                                      for +15 bytes, you can make your ugly answer ascii-art: Try it online!
                                      $endgroup$
                                      – Giuseppe
                                      9 hours ago











                                      2












                                      $begingroup$


                                      Charcoal, 15 bytes



                                      UBηEθ✂θκ‖O↑←UE¹


                                      Try it online! Link is to verbose version of code. Originally submitted as a comment on the now deleted sandbox post. Explanation:



                                      UBη


                                      Set the background to the second input c.



                                      Eθ✂θκ


                                      Map over the first input s to generate all suffixes and implicitly print them on separate lines.



                                      ‖O↑←


                                      Reflect horizontally and vertically.



                                      UE¹


                                      Add extra space horizontally.






                                      share|improve this answer









                                      $endgroup$


















                                        2












                                        $begingroup$


                                        Charcoal, 15 bytes



                                        UBηEθ✂θκ‖O↑←UE¹


                                        Try it online! Link is to verbose version of code. Originally submitted as a comment on the now deleted sandbox post. Explanation:



                                        UBη


                                        Set the background to the second input c.



                                        Eθ✂θκ


                                        Map over the first input s to generate all suffixes and implicitly print them on separate lines.



                                        ‖O↑←


                                        Reflect horizontally and vertically.



                                        UE¹


                                        Add extra space horizontally.






                                        share|improve this answer









                                        $endgroup$
















                                          2












                                          2








                                          2





                                          $begingroup$


                                          Charcoal, 15 bytes



                                          UBηEθ✂θκ‖O↑←UE¹


                                          Try it online! Link is to verbose version of code. Originally submitted as a comment on the now deleted sandbox post. Explanation:



                                          UBη


                                          Set the background to the second input c.



                                          Eθ✂θκ


                                          Map over the first input s to generate all suffixes and implicitly print them on separate lines.



                                          ‖O↑←


                                          Reflect horizontally and vertically.



                                          UE¹


                                          Add extra space horizontally.






                                          share|improve this answer









                                          $endgroup$




                                          Charcoal, 15 bytes



                                          UBηEθ✂θκ‖O↑←UE¹


                                          Try it online! Link is to verbose version of code. Originally submitted as a comment on the now deleted sandbox post. Explanation:



                                          UBη


                                          Set the background to the second input c.



                                          Eθ✂θκ


                                          Map over the first input s to generate all suffixes and implicitly print them on separate lines.



                                          ‖O↑←


                                          Reflect horizontally and vertically.



                                          UE¹


                                          Add extra space horizontally.







                                          share|improve this answer












                                          share|improve this answer



                                          share|improve this answer










                                          answered 16 hours ago









                                          NeilNeil

                                          82.1k745178




                                          82.1k745178























                                              2












                                              $begingroup$


                                              Japt, 16 bytes



                                              Note: I'll golf it :)



                                              Ôå+ ®¬qVÃùV mê ê


                                              Try it online!






                                              share|improve this answer









                                              $endgroup$













                                              • $begingroup$
                                                It's fairly similar to the other Japt answer, but in a different order, isn't it? I don't know Japt, but I see similar characters in both answers. ;)
                                                $endgroup$
                                                – Kevin Cruijssen
                                                14 hours ago










                                              • $begingroup$
                                                @KevinCruijssen Yeah, both are almost the same, for now
                                                $endgroup$
                                                – Luis felipe De jesus Munoz
                                                14 hours ago










                                              • $begingroup$
                                                @KevinCruijssen, Luis developed this independently from my solution.
                                                $endgroup$
                                                – Shaggy
                                                11 hours ago
















                                              2












                                              $begingroup$


                                              Japt, 16 bytes



                                              Note: I'll golf it :)



                                              Ôå+ ®¬qVÃùV mê ê


                                              Try it online!






                                              share|improve this answer









                                              $endgroup$













                                              • $begingroup$
                                                It's fairly similar to the other Japt answer, but in a different order, isn't it? I don't know Japt, but I see similar characters in both answers. ;)
                                                $endgroup$
                                                – Kevin Cruijssen
                                                14 hours ago










                                              • $begingroup$
                                                @KevinCruijssen Yeah, both are almost the same, for now
                                                $endgroup$
                                                – Luis felipe De jesus Munoz
                                                14 hours ago










                                              • $begingroup$
                                                @KevinCruijssen, Luis developed this independently from my solution.
                                                $endgroup$
                                                – Shaggy
                                                11 hours ago














                                              2












                                              2








                                              2





                                              $begingroup$


                                              Japt, 16 bytes



                                              Note: I'll golf it :)



                                              Ôå+ ®¬qVÃùV mê ê


                                              Try it online!






                                              share|improve this answer









                                              $endgroup$




                                              Japt, 16 bytes



                                              Note: I'll golf it :)



                                              Ôå+ ®¬qVÃùV mê ê


                                              Try it online!







                                              share|improve this answer












                                              share|improve this answer



                                              share|improve this answer










                                              answered 14 hours ago









                                              Luis felipe De jesus MunozLuis felipe De jesus Munoz

                                              5,69821671




                                              5,69821671












                                              • $begingroup$
                                                It's fairly similar to the other Japt answer, but in a different order, isn't it? I don't know Japt, but I see similar characters in both answers. ;)
                                                $endgroup$
                                                – Kevin Cruijssen
                                                14 hours ago










                                              • $begingroup$
                                                @KevinCruijssen Yeah, both are almost the same, for now
                                                $endgroup$
                                                – Luis felipe De jesus Munoz
                                                14 hours ago










                                              • $begingroup$
                                                @KevinCruijssen, Luis developed this independently from my solution.
                                                $endgroup$
                                                – Shaggy
                                                11 hours ago


















                                              • $begingroup$
                                                It's fairly similar to the other Japt answer, but in a different order, isn't it? I don't know Japt, but I see similar characters in both answers. ;)
                                                $endgroup$
                                                – Kevin Cruijssen
                                                14 hours ago










                                              • $begingroup$
                                                @KevinCruijssen Yeah, both are almost the same, for now
                                                $endgroup$
                                                – Luis felipe De jesus Munoz
                                                14 hours ago










                                              • $begingroup$
                                                @KevinCruijssen, Luis developed this independently from my solution.
                                                $endgroup$
                                                – Shaggy
                                                11 hours ago
















                                              $begingroup$
                                              It's fairly similar to the other Japt answer, but in a different order, isn't it? I don't know Japt, but I see similar characters in both answers. ;)
                                              $endgroup$
                                              – Kevin Cruijssen
                                              14 hours ago




                                              $begingroup$
                                              It's fairly similar to the other Japt answer, but in a different order, isn't it? I don't know Japt, but I see similar characters in both answers. ;)
                                              $endgroup$
                                              – Kevin Cruijssen
                                              14 hours ago












                                              $begingroup$
                                              @KevinCruijssen Yeah, both are almost the same, for now
                                              $endgroup$
                                              – Luis felipe De jesus Munoz
                                              14 hours ago




                                              $begingroup$
                                              @KevinCruijssen Yeah, both are almost the same, for now
                                              $endgroup$
                                              – Luis felipe De jesus Munoz
                                              14 hours ago












                                              $begingroup$
                                              @KevinCruijssen, Luis developed this independently from my solution.
                                              $endgroup$
                                              – Shaggy
                                              11 hours ago




                                              $begingroup$
                                              @KevinCruijssen, Luis developed this independently from my solution.
                                              $endgroup$
                                              – Shaggy
                                              11 hours ago











                                              2












                                              $begingroup$


                                              PowerShell, 120 bytes





                                              param($s,$c)($s,(($l=$s.length-1)..0+1..$l|%{($x=$c*(2*$_))+($s[($_,($l..$_+($_+1)..$l))[$_-ne$l]]-join$c)+$x}))[$l-gt0]


                                              Try it online!



                                              Some days, having index ranges instead of slices really hurts. Today is one of those days. Due to conjoined ranges messing up when dealing with single elements (e.g. returning 0..0+1..0), special-casing is used to avoid it altogether (at the cost of many bytes).






                                              share|improve this answer











                                              $endgroup$


















                                                2












                                                $begingroup$


                                                PowerShell, 120 bytes





                                                param($s,$c)($s,(($l=$s.length-1)..0+1..$l|%{($x=$c*(2*$_))+($s[($_,($l..$_+($_+1)..$l))[$_-ne$l]]-join$c)+$x}))[$l-gt0]


                                                Try it online!



                                                Some days, having index ranges instead of slices really hurts. Today is one of those days. Due to conjoined ranges messing up when dealing with single elements (e.g. returning 0..0+1..0), special-casing is used to avoid it altogether (at the cost of many bytes).






                                                share|improve this answer











                                                $endgroup$
















                                                  2












                                                  2








                                                  2





                                                  $begingroup$


                                                  PowerShell, 120 bytes





                                                  param($s,$c)($s,(($l=$s.length-1)..0+1..$l|%{($x=$c*(2*$_))+($s[($_,($l..$_+($_+1)..$l))[$_-ne$l]]-join$c)+$x}))[$l-gt0]


                                                  Try it online!



                                                  Some days, having index ranges instead of slices really hurts. Today is one of those days. Due to conjoined ranges messing up when dealing with single elements (e.g. returning 0..0+1..0), special-casing is used to avoid it altogether (at the cost of many bytes).






                                                  share|improve this answer











                                                  $endgroup$




                                                  PowerShell, 120 bytes





                                                  param($s,$c)($s,(($l=$s.length-1)..0+1..$l|%{($x=$c*(2*$_))+($s[($_,($l..$_+($_+1)..$l))[$_-ne$l]]-join$c)+$x}))[$l-gt0]


                                                  Try it online!



                                                  Some days, having index ranges instead of slices really hurts. Today is one of those days. Due to conjoined ranges messing up when dealing with single elements (e.g. returning 0..0+1..0), special-casing is used to avoid it altogether (at the cost of many bytes).







                                                  share|improve this answer














                                                  share|improve this answer



                                                  share|improve this answer








                                                  edited 12 hours ago

























                                                  answered 12 hours ago









                                                  VeskahVeskah

                                                  1,155214




                                                  1,155214























                                                      2












                                                      $begingroup$


                                                      Jelly, 11 bytes



                                                      jÐƤṚzṚŒḄZŒḄ


                                                      Try it online!



                                                      Left argument: $s$.

                                                      Right argument: $c$ (as a single character, not as a string).

                                                      Output: List of Jelly strings (appears as a list of lists of 1-char Python strings, replace ŒṘ with Y to see the n-joined output).






                                                      share|improve this answer









                                                      $endgroup$


















                                                        2












                                                        $begingroup$


                                                        Jelly, 11 bytes



                                                        jÐƤṚzṚŒḄZŒḄ


                                                        Try it online!



                                                        Left argument: $s$.

                                                        Right argument: $c$ (as a single character, not as a string).

                                                        Output: List of Jelly strings (appears as a list of lists of 1-char Python strings, replace ŒṘ with Y to see the n-joined output).






                                                        share|improve this answer









                                                        $endgroup$
















                                                          2












                                                          2








                                                          2





                                                          $begingroup$


                                                          Jelly, 11 bytes



                                                          jÐƤṚzṚŒḄZŒḄ


                                                          Try it online!



                                                          Left argument: $s$.

                                                          Right argument: $c$ (as a single character, not as a string).

                                                          Output: List of Jelly strings (appears as a list of lists of 1-char Python strings, replace ŒṘ with Y to see the n-joined output).






                                                          share|improve this answer









                                                          $endgroup$




                                                          Jelly, 11 bytes



                                                          jÐƤṚzṚŒḄZŒḄ


                                                          Try it online!



                                                          Left argument: $s$.

                                                          Right argument: $c$ (as a single character, not as a string).

                                                          Output: List of Jelly strings (appears as a list of lists of 1-char Python strings, replace ŒṘ with Y to see the n-joined output).







                                                          share|improve this answer












                                                          share|improve this answer



                                                          share|improve this answer










                                                          answered 10 hours ago









                                                          Erik the OutgolferErik the Outgolfer

                                                          32.8k429105




                                                          32.8k429105























                                                              2












                                                              $begingroup$


                                                              PowerShell, 82 83 bytes



                                                              +2 bytes thanks Veskah: the single character case bug fixed



                                                              -1 byte: The rule Input-string may also be a list of characters used





                                                              $c,$s=$args
                                                              ($s|%{(-join$s|% s*g $i)+$c*$i++})[($r=$i..0+1..$i)]|%{"$_"[$r]-join$c}


                                                              Try it online!



                                                              Less golfed:



                                                              $c,$s=$args
                                                              $southEast = $s|%{
                                                              (-join$s|% substring $i) + $c*$i++
                                                              }
                                                              $range=$i..0+1..$i
                                                              $southEast[$range]|%{
                                                              "$_"[$range]-join$c
                                                              }





                                                              share|improve this answer











                                                              $endgroup$









                                                              • 1




                                                                $begingroup$
                                                                Looks like this breaks for the single character case. There's just an empty line in the TIO link for ~
                                                                $endgroup$
                                                                – Veskah
                                                                9 hours ago












                                                              • $begingroup$
                                                                Indeed. Thanks!
                                                                $endgroup$
                                                                – mazzy
                                                                6 hours ago
















                                                              2












                                                              $begingroup$


                                                              PowerShell, 82 83 bytes



                                                              +2 bytes thanks Veskah: the single character case bug fixed



                                                              -1 byte: The rule Input-string may also be a list of characters used





                                                              $c,$s=$args
                                                              ($s|%{(-join$s|% s*g $i)+$c*$i++})[($r=$i..0+1..$i)]|%{"$_"[$r]-join$c}


                                                              Try it online!



                                                              Less golfed:



                                                              $c,$s=$args
                                                              $southEast = $s|%{
                                                              (-join$s|% substring $i) + $c*$i++
                                                              }
                                                              $range=$i..0+1..$i
                                                              $southEast[$range]|%{
                                                              "$_"[$range]-join$c
                                                              }





                                                              share|improve this answer











                                                              $endgroup$









                                                              • 1




                                                                $begingroup$
                                                                Looks like this breaks for the single character case. There's just an empty line in the TIO link for ~
                                                                $endgroup$
                                                                – Veskah
                                                                9 hours ago












                                                              • $begingroup$
                                                                Indeed. Thanks!
                                                                $endgroup$
                                                                – mazzy
                                                                6 hours ago














                                                              2












                                                              2








                                                              2





                                                              $begingroup$


                                                              PowerShell, 82 83 bytes



                                                              +2 bytes thanks Veskah: the single character case bug fixed



                                                              -1 byte: The rule Input-string may also be a list of characters used





                                                              $c,$s=$args
                                                              ($s|%{(-join$s|% s*g $i)+$c*$i++})[($r=$i..0+1..$i)]|%{"$_"[$r]-join$c}


                                                              Try it online!



                                                              Less golfed:



                                                              $c,$s=$args
                                                              $southEast = $s|%{
                                                              (-join$s|% substring $i) + $c*$i++
                                                              }
                                                              $range=$i..0+1..$i
                                                              $southEast[$range]|%{
                                                              "$_"[$range]-join$c
                                                              }





                                                              share|improve this answer











                                                              $endgroup$




                                                              PowerShell, 82 83 bytes



                                                              +2 bytes thanks Veskah: the single character case bug fixed



                                                              -1 byte: The rule Input-string may also be a list of characters used





                                                              $c,$s=$args
                                                              ($s|%{(-join$s|% s*g $i)+$c*$i++})[($r=$i..0+1..$i)]|%{"$_"[$r]-join$c}


                                                              Try it online!



                                                              Less golfed:



                                                              $c,$s=$args
                                                              $southEast = $s|%{
                                                              (-join$s|% substring $i) + $c*$i++
                                                              }
                                                              $range=$i..0+1..$i
                                                              $southEast[$range]|%{
                                                              "$_"[$range]-join$c
                                                              }






                                                              share|improve this answer














                                                              share|improve this answer



                                                              share|improve this answer








                                                              edited 6 hours ago

























                                                              answered 10 hours ago









                                                              mazzymazzy

                                                              2,9351317




                                                              2,9351317








                                                              • 1




                                                                $begingroup$
                                                                Looks like this breaks for the single character case. There's just an empty line in the TIO link for ~
                                                                $endgroup$
                                                                – Veskah
                                                                9 hours ago












                                                              • $begingroup$
                                                                Indeed. Thanks!
                                                                $endgroup$
                                                                – mazzy
                                                                6 hours ago














                                                              • 1




                                                                $begingroup$
                                                                Looks like this breaks for the single character case. There's just an empty line in the TIO link for ~
                                                                $endgroup$
                                                                – Veskah
                                                                9 hours ago












                                                              • $begingroup$
                                                                Indeed. Thanks!
                                                                $endgroup$
                                                                – mazzy
                                                                6 hours ago








                                                              1




                                                              1




                                                              $begingroup$
                                                              Looks like this breaks for the single character case. There's just an empty line in the TIO link for ~
                                                              $endgroup$
                                                              – Veskah
                                                              9 hours ago






                                                              $begingroup$
                                                              Looks like this breaks for the single character case. There's just an empty line in the TIO link for ~
                                                              $endgroup$
                                                              – Veskah
                                                              9 hours ago














                                                              $begingroup$
                                                              Indeed. Thanks!
                                                              $endgroup$
                                                              – mazzy
                                                              6 hours ago




                                                              $begingroup$
                                                              Indeed. Thanks!
                                                              $endgroup$
                                                              – mazzy
                                                              6 hours ago











                                                              1












                                                              $begingroup$


                                                              Ruby, 95 84 75 bytes





                                                              ->a,c{(1...2*z=a.size).map{|i|s=a[j=(z-i).abs,z]*c+c*2*j;s.reverse.chop+s}}


                                                              Try it online!



                                                              Takes input string as an array of chars. Returns an array of strings.






                                                              share|improve this answer











                                                              $endgroup$


















                                                                1












                                                                $begingroup$


                                                                Ruby, 95 84 75 bytes





                                                                ->a,c{(1...2*z=a.size).map{|i|s=a[j=(z-i).abs,z]*c+c*2*j;s.reverse.chop+s}}


                                                                Try it online!



                                                                Takes input string as an array of chars. Returns an array of strings.






                                                                share|improve this answer











                                                                $endgroup$
















                                                                  1












                                                                  1








                                                                  1





                                                                  $begingroup$


                                                                  Ruby, 95 84 75 bytes





                                                                  ->a,c{(1...2*z=a.size).map{|i|s=a[j=(z-i).abs,z]*c+c*2*j;s.reverse.chop+s}}


                                                                  Try it online!



                                                                  Takes input string as an array of chars. Returns an array of strings.






                                                                  share|improve this answer











                                                                  $endgroup$




                                                                  Ruby, 95 84 75 bytes





                                                                  ->a,c{(1...2*z=a.size).map{|i|s=a[j=(z-i).abs,z]*c+c*2*j;s.reverse.chop+s}}


                                                                  Try it online!



                                                                  Takes input string as an array of chars. Returns an array of strings.







                                                                  share|improve this answer














                                                                  share|improve this answer



                                                                  share|improve this answer








                                                                  edited 16 hours ago

























                                                                  answered 16 hours ago









                                                                  Kirill L.Kirill L.

                                                                  5,8431526




                                                                  5,8431526























                                                                      1












                                                                      $begingroup$


                                                                      Wolfram Language (Mathematica), 121 bytes



                                                                      Join[q=Table[(v=Table[#2,2(l-k)])<>Riffle[Join[(h=Reverse)[n=(g=Take)[#,-k]],g[n,-k+1]],#2]<>v,{k,l=Length@#}],Rest@h@q]&


                                                                      Try it online!






                                                                      share|improve this answer









                                                                      $endgroup$


















                                                                        1












                                                                        $begingroup$


                                                                        Wolfram Language (Mathematica), 121 bytes



                                                                        Join[q=Table[(v=Table[#2,2(l-k)])<>Riffle[Join[(h=Reverse)[n=(g=Take)[#,-k]],g[n,-k+1]],#2]<>v,{k,l=Length@#}],Rest@h@q]&


                                                                        Try it online!






                                                                        share|improve this answer









                                                                        $endgroup$
















                                                                          1












                                                                          1








                                                                          1





                                                                          $begingroup$


                                                                          Wolfram Language (Mathematica), 121 bytes



                                                                          Join[q=Table[(v=Table[#2,2(l-k)])<>Riffle[Join[(h=Reverse)[n=(g=Take)[#,-k]],g[n,-k+1]],#2]<>v,{k,l=Length@#}],Rest@h@q]&


                                                                          Try it online!






                                                                          share|improve this answer









                                                                          $endgroup$




                                                                          Wolfram Language (Mathematica), 121 bytes



                                                                          Join[q=Table[(v=Table[#2,2(l-k)])<>Riffle[Join[(h=Reverse)[n=(g=Take)[#,-k]],g[n,-k+1]],#2]<>v,{k,l=Length@#}],Rest@h@q]&


                                                                          Try it online!







                                                                          share|improve this answer












                                                                          share|improve this answer



                                                                          share|improve this answer










                                                                          answered 15 hours ago









                                                                          J42161217J42161217

                                                                          13.5k21252




                                                                          13.5k21252























                                                                              1












                                                                              $begingroup$


                                                                              J, 59 56 bytes



                                                                              ,{~[:((0-2*#)}.[:,0,:"0({:>:t)*t=:]+/<:)[:(|.@}.,])#@]


                                                                              Try it online!



                                                                              Too long solution for J ... (entirely my fault)






                                                                              share|improve this answer











                                                                              $endgroup$


















                                                                                1












                                                                                $begingroup$


                                                                                J, 59 56 bytes



                                                                                ,{~[:((0-2*#)}.[:,0,:"0({:>:t)*t=:]+/<:)[:(|.@}.,])#@]


                                                                                Try it online!



                                                                                Too long solution for J ... (entirely my fault)






                                                                                share|improve this answer











                                                                                $endgroup$
















                                                                                  1












                                                                                  1








                                                                                  1





                                                                                  $begingroup$


                                                                                  J, 59 56 bytes



                                                                                  ,{~[:((0-2*#)}.[:,0,:"0({:>:t)*t=:]+/<:)[:(|.@}.,])#@]


                                                                                  Try it online!



                                                                                  Too long solution for J ... (entirely my fault)






                                                                                  share|improve this answer











                                                                                  $endgroup$




                                                                                  J, 59 56 bytes



                                                                                  ,{~[:((0-2*#)}.[:,0,:"0({:>:t)*t=:]+/<:)[:(|.@}.,])#@]


                                                                                  Try it online!



                                                                                  Too long solution for J ... (entirely my fault)







                                                                                  share|improve this answer














                                                                                  share|improve this answer



                                                                                  share|improve this answer








                                                                                  edited 13 hours ago

























                                                                                  answered 13 hours ago









                                                                                  Galen IvanovGalen Ivanov

                                                                                  7,27211034




                                                                                  7,27211034























                                                                                      1












                                                                                      $begingroup$


                                                                                      Japt, 15 bytes



                                                                                      Ôå+ ê ®ê ¬qV
                                                                                      ûV


                                                                                      Try it






                                                                                      share|improve this answer











                                                                                      $endgroup$


















                                                                                        1












                                                                                        $begingroup$


                                                                                        Japt, 15 bytes



                                                                                        Ôå+ ê ®ê ¬qV
                                                                                        ûV


                                                                                        Try it






                                                                                        share|improve this answer











                                                                                        $endgroup$
















                                                                                          1












                                                                                          1








                                                                                          1





                                                                                          $begingroup$


                                                                                          Japt, 15 bytes



                                                                                          Ôå+ ê ®ê ¬qV
                                                                                          ûV


                                                                                          Try it






                                                                                          share|improve this answer











                                                                                          $endgroup$




                                                                                          Japt, 15 bytes



                                                                                          Ôå+ ê ®ê ¬qV
                                                                                          ûV


                                                                                          Try it







                                                                                          share|improve this answer














                                                                                          share|improve this answer



                                                                                          share|improve this answer








                                                                                          edited 11 hours ago

























                                                                                          answered 11 hours ago









                                                                                          OliverOliver

                                                                                          5,3801832




                                                                                          5,3801832























                                                                                              1












                                                                                              $begingroup$


                                                                                              Perl 5 with -lF, -M5.010, 71 bytes





                                                                                              $"=<>;$A=abs,$_="@F[$A..$#F]".$"x($A*2),/./,say reverse.$' for-$#F..$#F


                                                                                              Try it online!






                                                                                              share|improve this answer









                                                                                              $endgroup$


















                                                                                                1












                                                                                                $begingroup$


                                                                                                Perl 5 with -lF, -M5.010, 71 bytes





                                                                                                $"=<>;$A=abs,$_="@F[$A..$#F]".$"x($A*2),/./,say reverse.$' for-$#F..$#F


                                                                                                Try it online!






                                                                                                share|improve this answer









                                                                                                $endgroup$
















                                                                                                  1












                                                                                                  1








                                                                                                  1





                                                                                                  $begingroup$


                                                                                                  Perl 5 with -lF, -M5.010, 71 bytes





                                                                                                  $"=<>;$A=abs,$_="@F[$A..$#F]".$"x($A*2),/./,say reverse.$' for-$#F..$#F


                                                                                                  Try it online!






                                                                                                  share|improve this answer









                                                                                                  $endgroup$




                                                                                                  Perl 5 with -lF, -M5.010, 71 bytes





                                                                                                  $"=<>;$A=abs,$_="@F[$A..$#F]".$"x($A*2),/./,say reverse.$' for-$#F..$#F


                                                                                                  Try it online!







                                                                                                  share|improve this answer












                                                                                                  share|improve this answer



                                                                                                  share|improve this answer










                                                                                                  answered 9 hours ago









                                                                                                  Dom HastingsDom Hastings

                                                                                                  14.9k33270




                                                                                                  14.9k33270






























                                                                                                      draft saved

                                                                                                      draft discarded




















































                                                                                                      If this is an answer to a challenge…




                                                                                                      • …Be sure to follow the challenge specification. However, please refrain from exploiting obvious loopholes. Answers abusing any of the standard loopholes are considered invalid. If you think a specification is unclear or underspecified, comment on the question instead.


                                                                                                      • …Try to optimize your score. For instance, answers to code-golf challenges should attempt to be as short as possible. You can always include a readable version of the code in addition to the competitive one.
                                                                                                        Explanations of your answer make it more interesting to read and are very much encouraged.


                                                                                                      • …Include a short header which indicates the language(s) of your code and its score, as defined by the challenge.



                                                                                                      More generally…




                                                                                                      • …Please make sure to answer the question and provide sufficient detail.


                                                                                                      • …Avoid asking for help, clarification or responding to other answers (use comments instead).





                                                                                                      draft saved


                                                                                                      draft discarded














                                                                                                      StackExchange.ready(
                                                                                                      function () {
                                                                                                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f182212%2flay-out-the-carpet%23new-answer', 'question_page');
                                                                                                      }
                                                                                                      );

                                                                                                      Post as a guest















                                                                                                      Required, but never shown





















































                                                                                                      Required, but never shown














                                                                                                      Required, but never shown












                                                                                                      Required, but never shown







                                                                                                      Required, but never shown

































                                                                                                      Required, but never shown














                                                                                                      Required, but never shown












                                                                                                      Required, but never shown







                                                                                                      Required, but never shown







                                                                                                      Popular posts from this blog

                                                                                                      Færeyskur hestur Heimild | Tengill | Tilvísanir | LeiðsagnarvalRossið - síða um færeyska hrossið á færeyskuGott ár hjá færeyska hestinum

                                                                                                      He _____ here since 1970 . Answer needed [closed]What does “since he was so high” mean?Meaning of “catch birds for”?How do I ensure “since” takes the meaning I want?“Who cares here” meaningWhat does “right round toward” mean?the time tense (had now been detected)What does the phrase “ring around the roses” mean here?Correct usage of “visited upon”Meaning of “foiled rail sabotage bid”It was the third time I had gone to Rome or It is the third time I had been to Rome

                                                                                                      Slayer Innehåll Historia | Stil, komposition och lyrik | Bandets betydelse och framgångar | Sidoprojekt och samarbeten | Kontroverser | Medlemmar | Utmärkelser och nomineringar | Turnéer och festivaler | Diskografi | Referenser | Externa länkar | Navigeringsmenywww.slayer.net”Metal Massacre vol. 1””Metal Massacre vol. 3””Metal Massacre Volume III””Show No Mercy””Haunting the Chapel””Live Undead””Hell Awaits””Reign in Blood””Reign in Blood””Gold & Platinum – Reign in Blood””Golden Gods Awards Winners”originalet”Kerrang! Hall Of Fame””Slayer Looks Back On 37-Year Career In New Video Series: Part Two””South of Heaven””Gold & Platinum – South of Heaven””Seasons in the Abyss””Gold & Platinum - Seasons in the Abyss””Divine Intervention””Divine Intervention - Release group by Slayer””Gold & Platinum - Divine Intervention””Live Intrusion””Undisputed Attitude””Abolish Government/Superficial Love””Release “Slatanic Slaughter: A Tribute to Slayer” by Various Artists””Diabolus in Musica””Soundtrack to the Apocalypse””God Hates Us All””Systematic - Relationships””War at the Warfield””Gold & Platinum - War at the Warfield””Soundtrack to the Apocalypse””Gold & Platinum - Still Reigning””Metallica, Slayer, Iron Mauden Among Winners At Metal Hammer Awards””Eternal Pyre””Eternal Pyre - Slayer release group””Eternal Pyre””Metal Storm Awards 2006””Kerrang! Hall Of Fame””Slayer Wins 'Best Metal' Grammy Award””Slayer Guitarist Jeff Hanneman Dies””Bullet-For My Valentine booed at Metal Hammer Golden Gods Awards””Unholy Aliance””The End Of Slayer?””Slayer: We Could Thrash Out Two More Albums If We're Fast Enough...””'The Unholy Alliance: Chapter III' UK Dates Added”originalet”Megadeth And Slayer To Co-Headline 'Canadian Carnage' Trek”originalet”World Painted Blood””Release “World Painted Blood” by Slayer””Metallica Heading To Cinemas””Slayer, Megadeth To Join Forces For 'European Carnage' Tour - Dec. 18, 2010”originalet”Slayer's Hanneman Contracts Acute Infection; Band To Bring In Guest Guitarist””Cannibal Corpse's Pat O'Brien Will Step In As Slayer's Guest Guitarist”originalet”Slayer’s Jeff Hanneman Dead at 49””Dave Lombardo Says He Made Only $67,000 In 2011 While Touring With Slayer””Slayer: We Do Not Agree With Dave Lombardo's Substance Or Timeline Of Events””Slayer Welcomes Drummer Paul Bostaph Back To The Fold””Slayer Hope to Unveil Never-Before-Heard Jeff Hanneman Material on Next Album””Slayer Debut New Song 'Implode' During Surprise Golden Gods Appearance””Release group Repentless by Slayer””Repentless - Slayer - Credits””Slayer””Metal Storm Awards 2015””Slayer - to release comic book "Repentless #1"””Slayer To Release 'Repentless' 6.66" Vinyl Box Set””BREAKING NEWS: Slayer Announce Farewell Tour””Slayer Recruit Lamb of God, Anthrax, Behemoth + Testament for Final Tour””Slayer lägger ner efter 37 år””Slayer Announces Second North American Leg Of 'Final' Tour””Final World Tour””Slayer Announces Final European Tour With Lamb of God, Anthrax And Obituary””Slayer To Tour Europe With Lamb of God, Anthrax And Obituary””Slayer To Play 'Last French Show Ever' At Next Year's Hellfst””Slayer's Final World Tour Will Extend Into 2019””Death Angel's Rob Cavestany On Slayer's 'Farewell' Tour: 'Some Of Us Could See This Coming'””Testament Has No Plans To Retire Anytime Soon, Says Chuck Billy””Anthrax's Scott Ian On Slayer's 'Farewell' Tour Plans: 'I Was Surprised And I Wasn't Surprised'””Slayer””Slayer's Morbid Schlock””Review/Rock; For Slayer, the Mania Is the Message””Slayer - Biography””Slayer - Reign In Blood”originalet”Dave Lombardo””An exclusive oral history of Slayer”originalet”Exclusive! Interview With Slayer Guitarist Jeff Hanneman”originalet”Thinking Out Loud: Slayer's Kerry King on hair metal, Satan and being polite””Slayer Lyrics””Slayer - Biography””Most influential artists for extreme metal music””Slayer - Reign in Blood””Slayer guitarist Jeff Hanneman dies aged 49””Slatanic Slaughter: A Tribute to Slayer””Gateway to Hell: A Tribute to Slayer””Covered In Blood””Slayer: The Origins of Thrash in San Francisco, CA.””Why They Rule - #6 Slayer”originalet”Guitar World's 100 Greatest Heavy Metal Guitarists Of All Time”originalet”The fans have spoken: Slayer comes out on top in readers' polls”originalet”Tribute to Jeff Hanneman (1964-2013)””Lamb Of God Frontman: We Sound Like A Slayer Rip-Off””BEHEMOTH Frontman Pays Tribute To SLAYER's JEFF HANNEMAN””Slayer, Hatebreed Doing Double Duty On This Year's Ozzfest””System of a Down””Lacuna Coil’s Andrea Ferro Talks Influences, Skateboarding, Band Origins + More””Slayer - Reign in Blood””Into The Lungs of Hell””Slayer rules - en utställning om fans””Slayer and Their Fans Slashed Through a No-Holds-Barred Night at Gas Monkey””Home””Slayer””Gold & Platinum - The Big 4 Live from Sofia, Bulgaria””Exclusive! Interview With Slayer Guitarist Kerry King””2008-02-23: Wiltern, Los Angeles, CA, USA””Slayer's Kerry King To Perform With Megadeth Tonight! - Oct. 21, 2010”originalet”Dave Lombardo - Biography”Slayer Case DismissedArkiveradUltimate Classic Rock: Slayer guitarist Jeff Hanneman dead at 49.”Slayer: "We could never do any thing like Some Kind Of Monster..."””Cannibal Corpse'S Pat O'Brien Will Step In As Slayer'S Guest Guitarist | The Official Slayer Site”originalet”Slayer Wins 'Best Metal' Grammy Award””Slayer Guitarist Jeff Hanneman Dies””Kerrang! Awards 2006 Blog: Kerrang! Hall Of Fame””Kerrang! Awards 2013: Kerrang! Legend”originalet”Metallica, Slayer, Iron Maien Among Winners At Metal Hammer Awards””Metal Hammer Golden Gods Awards””Bullet For My Valentine Booed At Metal Hammer Golden Gods Awards””Metal Storm Awards 2006””Metal Storm Awards 2015””Slayer's Concert History””Slayer - Relationships””Slayer - Releases”Slayers officiella webbplatsSlayer på MusicBrainzOfficiell webbplatsSlayerSlayerr1373445760000 0001 1540 47353068615-5086262726cb13906545x(data)6033143kn20030215029