Your friend Rick is trying to send you a message, but he is concerned that it would get intercepted by his partner. He came up with a solution:

1) Add digits in random places within the message.

2) Split the resulting message in two. He wrote down every second character on one page, and the remaining ones on another. He then dispatched the two messages separately.

Write a function interweave(s1, s2) that reverses this operation to decode his message!

Example 1: interweave("hlo", "el") -> "hello"
Example 2: interweave("h3lo", "el4") -> "hello"

Rick's a bit peculiar about his formats. He would feel ashamed if he found out his message led to extra white spaces hanging around the edges of his message...

Source: codewars | Difficulty: EASY
Tags: Fundamentals

Starter code: def interweave(s1, s2):
	

Solutions:
def interweave(s1, s2):
	s = [''] * (len(s1) + len(s2))
	(s[::2], s[1::2]) = (s1, s2)
	return ''.join((c for c in s if not c.isdigit())).strip()


from itertools import chain, zip_longest

def interweave(s1, s2):
	return ''.join((char for char in chain.from_iterable(zip_longest(s1, s2, fillvalue='')) if not char.isdigit()))


import re

def interweave(s1, s2):
	z = ''.join([x + y for (x, y) in zip(s1, s2 + ' ')])[:-1]
	return re.sub('[0-9]', '', z)


def interweave(s1, s2):
	result = ''
	i = 0
	while i < len(s1) or i < len(s2):
		if i < len(s1) and (not s1[i].isdigit()):
			result += s1[i]
		if i < len(s2) and (not s2[i].isdigit()):
			result += s2[i]
		i += 1
	return result


def interweave(s1, s2):
	return ''.join((y for x in zip(s1, s2 + '0') for y in x if not y.isdigit()))


from itertools import zip_longest

def interweave(*args):
	return ''.join((''.join((b for b in a if not b.isdigit())) for a in zip_longest(*args, fillvalue=''))).rstrip()


import re

def interweave(s1, s2):
	return re.sub('\\d', '', ''.join((a + b for (a, b) in zip(s1, s2.ljust(len(s1), ' '))))).strip()


def interweave(s1, s2):
	s = ''
	for i in range(len(s2)):
		if not s1[i].isdigit():
			s += s1[i]
		if not s2[i].isdigit():
			s += s2[i]
	return s if len(s1) == 0 or s1[-1].isdigit() else s + s1[-1]


from itertools import chain, zip_longest

def interweave(s1, s2):
	return ''.join([c for c in chain.from_iterable(zip_longest(s1, s2)) if c and (not c.isdigit())])