f=lambda s:s and s[:1]+f(s[1:]+[s[1:]][:s>""])or""
A recursive function that takes a list of strings and returns a string. Try it online!
We're going to build the interleaved string one character at a time. There are several cases to consider:
- Is the first string in the list nonempty? Take its first character, move the rest of it to the end of the list, and recurse.
- Is the first string in the list empty? Remove it from the list and recurse.
- Is the list of strings empty? Then we're done. Return empty string.
The implementation goes as follows:
f = lambda s: s and ... or ""
f to be a function of one argument,
s, which is a list of strings. If
s is nonempty, do the
... part (see below); otherwise, return
s[:1] + f(...)
Since we now know
s is nonempty, we can refer to its first element,
s. We don't know yet whether
s is empty, though. If it isn't, we want to concatenate its first character to a recursive call; if it is, we can concatenate the empty string to a recursive call. Slicing everything left of index 1 works in both cases.
s[1:] + ...
The argument to the recursive call is going to be all but the first element of
s, concatenated to either a 1-element list (the rest of
s if it was nonempty) or an empty list (if
s was empty).
[s[1:]][:s > ""]
s[1:] (the part of
s after the first character, which is the empty string if
s is empty) into a singleton list and then take a slice of that list. If
s is empty,
s > "" is
False, which is treated as
0 in a slice; thus, we slice from index 0 to index 0--an empty slice. If
s is not empty,
s > "" is
True, which is treated as
1; thus, we slice from index 0 to index 1--the whole 1-element list.
If lists of single-character strings can be used in place of strings, this solution can be 54 bytes:
f=lambda s:s and s[:1]+f(s[1:]+(sand[s[1:]]))
Try it online!