You will be given a string. 

You need to return an array of three strings by gradually pulling apart the string.

You should repeat the following steps until the string length is 1:

a) remove the final character from the original string, add to solution string 1.
b) remove the first character from the original string, add to solution string 2.

The final solution string value is made up of the remaining character from the original string, once originalstring.length == 1.

Example:

"exampletesthere"
becomes:
["erehtse","example","t"]

The Kata title gives a hint of one technique to solve.

Source: codewars | Difficulty: EASY
Tags: String algorithms

Fundamentals

Data structures

Starter code: def pop_shift(s):
	

Solutions:
def pop_shift(s):
	l1 = list(s)
	l2 = []
	l3 = []
	while len(l1) > 1:
		l2.append(l1.pop())
		l3.append(l1.pop(0))
	return [''.join(l2), ''.join(l3), ''.join(l1)]


def pop_shift(s):
	(il, ir) = (len(s) // 2, (len(s) + 1) // 2)
	return [s[:ir - 1:-1], s[:il], s[il:ir]]


def pop_shift(s):
	(half, odd_len) = divmod(len(s), 2)
	return [s[half + odd_len:][::-1], s[:half], s[half] if odd_len else '']


def pop_shift(string):
	mid = len(string) // 2
	return [string[::-1][:mid], string[:mid], string[mid:len(string) - mid]]


def pop_shift(s):
	i = len(s) // 2
	return [s[-1:-i - 1:-1], s[:i], s[i:i + len(s) % 2]]


def pop_shift(s):
	(i, j) = divmod(len(s), 2)
	return [s[i + j:][::-1], s[:i], s[i:i + j]]


def pop_shift(stg):
	(d, m) = divmod(len(stg), 2)
	return [stg[:d + m - 1:-1], stg[:d], stg[d] if m else '']


def pop_shift(strn):
	s2 = ''.join((strn[-i - 1] for i in range(len(strn) // 2)))
	s1 = ''.join((strn[i] for i in range(len(strn) // 2)))
	s0 = ''.join(strn[len(s1):-len(s1)])
	if len(strn) == 1:
		s0 = strn
	return [s2, s1, s0]


def pop_shift(input):
	input = list(input)
	(x, y) = (list(), list())
	while len(input) > 1:
		x.append(input.pop())
		y.append(input.pop(0))
	return [''.join(x), ''.join(y), ''.join(input)]


def pop_shift(str):
	l = len(str)
	return [str[::-1][:l // 2], str[:l // 2], str[l // 2] * (l % 2)]