Slowly turn a string into another
V, 14 bytes
òYp$xhòjòÄ$xhh
Try it online!
Explanation:
ò ò "Recursively:
Yp " Yank the current line and paste it
$ " Move to the end of the current line
x " Delete one character
h " Move One character to the right.
" Because of the way loops work in V, this will throw an error if there
" Is only one character on the current line.
Now, the buffer looks like this:
0123456789
012345678
01234567
0123456
012345
01234
0123
012
01
0
We just need to do the same thing in reverse for the next line:
j "Move down one line
ò ò "Recursively (The second ò is implicit)
Ä " Duplicate this line up
$ " Move to the end of the current line
x " Delete one character
hh " Move two characters to the right.
" Because of the way loops work in V, this will throw an error if there
" Is only two characters on the current line.
More interesting alternate solution:
òÄ$xhòç^/:m0
ddGp@qd
Pyth, 9 bytes
j+_._Et._
A program that takes the second string, and then the first string, as quoted strings on STDIN and prints the result.
Try it online
How it works
j+_._Et._ Program. Inputs: Q, E
._E Yield prefixes of E as a list
_ Reverse the above
._ Yield prefixes of Q as a list (implicit input fill)
t All but the first element of above
+ Merge the two lists
j Join on newlines
Implicitly print
Python, 93 bytes
f=lambda a,b,r='',i=2:a and f(a[:-1],b,r+a+'\n')or(len(b)>=i and f(a,b,r+b[:i]+'\n',i+1)or r)
Starts with the empty string r
, adds a
and a newline and removes the last character from a
until a
is empty then adds the required portions of b
and a newline by keeping a counter, i
, which starts at 2
until the length of b
is exceeded, then returns r
. Has a trailing newline.
All tests are on ideone