Input a String and surround it with a rounded rectangle of alternating "friendliness pellets".(0
)
Idea originally from Lyxal.
Challenge
Given a single line non-empty String of length \$<100\$, print the string with a rounded rectangle of alternating pellets(0
) around it.
The rectangle must be 11 lines in height.
The first line of the rectangle must have at least 1 pellet.
The middle line of the rectangle must be at least 13 characters long. There must be a padding of one space on each side of the text.
Strings smaller than 9 characters must be padded with spaces equally on both sides to fit the above specification. The right side is allowed to have one extra space if the string is of even length.
The template for the output is as follows:
00000..... 6 spaces
0 4 spaces
0 2 spaces
0 1 space
0 no spaces
If the string's length is greater than or equal to 9; the first line must have \$\text{length}-8\$ pellets.
Example Input and Output
Input:
Hello World!
Output:
0000
0 0
0 0
0 0
0 0
0 Hello World! 0
0 0
0 0
0 0
0 0
0000
Input
0
Output
0
0 0
0 0
0 0
0 0
0 0 0
0 0
0 0
0 0
0 0
0
Input
The quick brown fox
Output
00000000000
0 0
0 0
0 0
0 0
0 the quick brown fox 0
0 0
0 0
0 0
0 0
00000000000
Input
In this world, it's KILL or BE killed
Output
00000000000000000000000000000
0 0
0 0
0 0
0 0
0 In this world, it's KILL or BE killed 0
0 0
0 0
0 0
0 0
00000000000000000000000000000
Input
hi there
Output
0
0 0
0 0
0 0
0 0
0 hi there 0
0 0
0 0
0 0
0 0
0
Example code in Ruby
a=[4,2,1,0] # space length to create circle
str=gets.chomp;
l = str.length;
# print first line of pellets
print " "*6
if l<=9 then puts "0" else puts "0"*(l-8) end
# initial pattern
for n in a do
print " "*n +"0"+" "*(5-n)
print " " if l<=9
print " "*(l-8) if l>9
puts " "*(5-n) +"0"
end
# display string with spaces
if l<9 then puts "0"+" "*((11-l)/2).floor + str + " "*((12-l)/2).ceil + "0" else puts "0 #{str} 0" end
#initial pattern but reversed
for n in a.reverse do
print " "*n +"0"+" "*(5-n)
print " " if l<=9
print " "*(l-8) if l>9
puts " "*(5-n) +"0"
end
# last line(same as first line)
print " "*6
if l<=9 then puts "0" else puts "0"*(l-8) end
Scoring
This is code-golf. Shortest answer in each language wins.