Reconstruct a Text Rectangle from Diagonal Strips

CJam, 23 20 bytes

{_z,,Nf*W%\.+zW%sN%}

Try it here.


Python 2, 84

L=[]
for w in input():
 i=0;L+=[''][:len(w)-len(L)]
 for c in w:i-=1;L[i]+=c
print L

Input and output are lists of strings.

input: ['A','EB','IFC','JGD','KH','L']
output: ['ABCD', 'EFGH', 'IJKL']

The list of lines L to output is built up as we read the input. Each new character is appended to a line, starting from the last line i=-1 and progressing towards the front.

Whenever the new line to add is too long for the list, a new empty line is appended: L+=[''][:len(w)-len(L)]. I'm hoping for a way to shorten this part.

Tags:

Code Golf