# Zippered Paragraph

(Inspired by this challenge)

Given two input strings, one of which is exactly one character longer than the other, arrange the strings into ASCII art as if they are two halves of a zipper that is only halfway zippered. The longer word forms the bottom of the zipper, and is the first and last character of the combined zippered portion. Since that paragraph is hard to understand, take a look at some examples:

zippered
paragraph

z
i
p
p
gerraepdh
a
r
a
p


Note how paragraph (the longer word) forms the bottom zipper, and the g r a p h portion encapsulates the e r e d portion of zippered, and the z i p p and p a r a portions are offset from each other.

## Input

• Two ASCII strings in any convenient format, with one guaranteed to be even in length and the other exactly one character longer.
• Neither string will contain whitespace, but may contain any other printable ASCII value.
• You can take the input in either order. Please state in your submission the input order.

## Output

The resulting ASCII art representation of the zippered words, as described above, again in any convenient format.

## Rules

• Leading or trailing newlines or whitespace are all optional, so long as the characters themselves line up correctly.
• Either a full program or a function are acceptable. If a function, you can return the output rather than printing it.
• If possible, please include a link to an online testing environment so other people can try out your code!
• Standard loopholes are forbidden.
• This is so all usual golfing rules apply, and the shortest code (in bytes) wins.

## Examples

ppcg
tests

p
p
sctgs
e
t

string
strings

s
t
r
iinnggs
r
t
s

• May we assume the input does not contain whitespace? – DJMcMayhem Aug 1 '17 at 17:33
• @DJMcMayhem Yeah, that's a fair assumption. – AdmBorkBork Aug 1 '17 at 17:38
• @Titus one guaranteed to be even in length and the other exactly one character longer. The shorter string is always even – Baldrickk Aug 2 '17 at 9:25

# Japt, 31 28 bytes

N®¬£ç iXYm½*Ul
uUo mw
y c ·y


Test it online! Takes the shorter string first.

### Explanation

N®¬£ç iXYm½*Ul    First line: Set U to the result.
N®                Map each item (there's exactly 2 of them) in the input to
¬                 the item split into chars,
£                with each item X and index Y mapped to
ç                 the first input filled with spaces,
iX              with X inserted at index
Ym½*Ul          min(Y, 0.5 * U.length).
At the end each input is an array like
["p    ", " p   ", "  c  ", "  g  "]
["t    ", " e   ", "  s  ", "  t  ", "  s  "]

uUo mw    Second line: Set V to the result (though that's not important).
Uo       Pop the last item (the array representing the second string) from U.
m     Map each item by
w      reversing.
u         Push the result to the beginning of U.
At the end we have e.g.
["    t", "   e ", "  s  ", "  t  ", "  s  "]
["p    ", " p   ", "  c  ", "  g  "]

y c ·y    Last line: Output the result of this line.
y         Transpose: map [[A,B,C,...],[a,b,c,...]] to [[A,a],[B,b],[C,c],...].
c       Flatten into one array. [A,a,B,b,C,c,...]
·     Join on newlines. Now we have the output transposed.
y    Transpose rows with columns.


# Charcoal, 33 31 bytes

→Ｆ²«ＦＬθ«§θκ→¿‹κ÷Ｌθ²¿ι↑↓»Ｊ⁰ＬθＡηθ


Try it online! Link is to verbose version of code. Takes the shorter string first. Edit: Saved 2 bytes by tweaking the midpoint detection. Explanation:

→Ｆ²«


Loop over each string in turn.

ＦＬθ«


Loop over each character of the string in turn.

§θκ→


Print the character and move an extra square to the right.

¿‹κ÷Ｌθ²¿ι↑↓»


For the first half of the string, also move the cursor down or up as appropriate.

Ｊ⁰ＬθＡηθ


After printing the first string, jump to the second string's starting point, and replace the first string with the second, so that it gets printed for the second loop. (The code runs on both loops, but the second time it's a no-op.)

# Pyth, 35 bytes

AQj.t.e+*d+lG*<klH*^_1k/h-lGk2b.iHG


Try it online!

• That was speedy fast! – AdmBorkBork Aug 1 '17 at 16:22
• @AdmBorkBork You can expect that to happen multiple times, especially from this answerer. – Erik the Outgolfer Aug 1 '17 at 17:15

# Jelly,  27  26 bytes

-1 byte thanks to Erik the Outgolfer (use repeat, ¡, to replace if, ?, and a passed else clause ¹)

JCḂ¡€ṚH
żµL⁶ẋ;Ð€Fṙ"ÇZṙÇṀ$Y  A full program that prints the result with leading white-space, as allowed in the question (or a dyadic link returning a list of characters). Try it online! ### How? JCḂ¡€ṚH - Link 1, get rotations: list p e.g.: ["a1","b2","c3","d4","e5","f6","g"] J - range of length of p [ 1, 2, 3, 4, 5, 6, 7] € - for €ach: ¡ - repeat link: Ḃ - ...# of times: modulo 2 1 0 1 0 1 0 1 C - ...link: complement (1-x) 0 2 -2 4 -4 6 -6 Ṛ - reverse [-6, 6,-4, 4,-2, 2, 0] H - halve [-3, 3,-2, 2,-1, 1, 0] żµL⁶ẋ;Ð€Fṙ"ÇZṙÇṀ$Y - Main link: longer (odd length); shorter (even length)
-                           e.g.: "abcdefg", "123456"
ż                  - zip them together               ["a1","b2","c3","d4","e5","f6","g"]
µ                 - monadic chain separation, call that p
L                - length of p                     7
⁶               - literal space character         ' '
ẋ              - repeat                          "       "
F          - flatten p                       "a1b2c3d4e5f"
Ð€           - map with:
;             -   concatenation                 ["       a","       1","       b","       2","       c","       3","       d","       4","       e","       5","       f","       6","       g"]
Ç       - call last link (1) as a monad with argument p
"        - zip with (no action on left by trailing values of right):
ṙ         -   rotate left by                ["  a     ","    1   "," b      ","     2  ","c       ","      3 ","       d","       4","       e","       5","       f","       6","       g"]
Z      - transpose                       ["    c        ","  b          ","a            ","             "," 1           ","   2         ","     3       ","      d4e5f6g"]
")$r[$w*($x&1?$y-1:$e-$y+=$y<$e/2)+$x]=$argv[2-$x%2][$i];echo$r;  Run with -nr or try it online. # Perl 5, 163 bytes @a=map{$s=.5*length;[/./g]}<>;say(($"x(2*$_)).$a[0][$_])for 0..$s-1;print$"x(2*$s);print$a[0][$_].$a[1][$_]for$s..@{$a[1]};print$/.($"x(1+2*$s)).$a[1][$s]while\$s--


Try it online!

Takes the longer string first.