For building the encrypted string:Take every 2nd char from the string, then the other chars, that are not every 2nd char, and concat them as new String.
Do this n times!

Examples:
```
"This is a test!", 1 -> "hsi  etTi sats!"
"This is a test!", 2 -> "hsi  etTi sats!" -> "s eT ashi tist!"
```

Write two methods:
```python
def encrypt(text, n)
def decrypt(encrypted_text, n)
```

```Fsharp
let encrypt (str:string) (n:int) -> string
let decrypt (str:string) (n:int) -> string
```

For both methods:
If the input-string is null or empty return exactly this value!
If n is <= 0 then return the input text.

This kata is part of the Simple Encryption Series:
Simple Encryption #1 - Alternating Split
Simple Encryption #2 - Index-Difference
Simple Encryption #3 - Turn The Bits Around
Simple Encryption #4 - Qwerty

Have fun coding it and please don't forget to vote and rank this kata! :-)

Difficulty: EASY
Tags: String algorithms

Fundamentals

Data structures
Skill types: Data structures

Starter code:
def decrypt(text, n):
	

Solutions:
def decrypt(text, n):
	if text in ('', None):
		return text
	ndx = len(text) // 2
	for i in range(n):
		a = text[:ndx]
		b = text[ndx:]
		text = ''.join((b[i:i + 1] + a[i:i + 1] for i in range(ndx + 1)))
	return text

def encrypt(text, n):
	for i in range(n):
		text = text[1::2] + text[::2]
	return text


def decrypt(s, n):
	if not s:
		return s
	(o, l) = (len(s) // 2, list(s))
	for _ in range(n):
		(l[1::2], l[::2]) = (l[:o], l[o:])
	return ''.join(l)

def encrypt(s, n):
	if not s:
		return s
	for _ in range(n):
		s = s[1::2] + s[::2]
	return s


def decrypt(text, n):
	if not text:
		return text
	half = len(text) // 2
	arr = list(text)
	for _ in range(n):
		(arr[1::2], arr[::2]) = (arr[:half], arr[half:])
	return ''.join(arr)

def encrypt(text, n):
	for i in range(n):
		text = text[1::2] + text[::2]
	return text


def encrypt_once(s):
	(h, t) = ('', '')
	for i in range(len(s)):
		if i % 2 == 0:
			h += s[i]
		else:
			t += s[i]
	return t + h

def decrypt_once(s):
	i = len(s) // 2
	j = 0
	result = ''
	for k in range(len(s)):
		if k % 2 == 0:
			result += s[i]
			i += 1
		else:
			result += s[j]
			j += 1
	return result

def decrypt(text, n):
	if not text or len(text) == 0 or n <= 0:
		return text
	for i in range(n):
		text = decrypt_once(text)
	return text

def encrypt(text, n):
	if not text or len(text) == 0 or n <= 0:
		return text
	for i in range(n):
		text = encrypt_once(text)
	return text


def decrypt(encrypted_text, n):
	if n < 1:
		return encrypted_text
	half_len = len(encrypted_text) // 2
	(left, right) = (encrypted_text[:half_len], encrypted_text[half_len:])
	encrypted_text = [''.join(i) for i in zip(right, left)]
	if len(right) > half_len:
		encrypted_text += right[-1]
	return decrypt(''.join(encrypted_text), n - 1)

def encrypt(text, n):
	if n < 1:
		return text
	for _ in range(n):
		text = text[1::2] + text[0::2]
	return text


def decrypt(text, n):
	if text:
		mid = len(text) // 2
		for _ in range(n):
			text = ''.join(sum(zip(text[mid:], list(text[:mid]) + ['']), ()))
	return text

def encrypt(text, n):
	if text:
		for _ in range(n):
			text = text[1::2] + text[::2]
	return text


def decrypt(text, n):
	if text == None:
		return text
	decodeList = encrypt(list(range(len(text))), n)
	return ''.join((text[decodeList.index(i)] for i in range(len(text))))

def encrypt(text, n):
	if text == None:
		return text
	return encrypt(text[1::2] + text[0::2], n - 1) if n > 0 else text


from itertools import zip_longest

def encrypt(text, n):
	s = text
	if s:
		for _ in range(n):
			s = s[1::2] + s[::2]
	return s

def decrypt(encrypted_text, n):
	s = encrypted_text
	if s:
		m = len(s) // 2
		for _ in range(n):
			s = ''.join((c for s in zip_longest(s[m:], s[:m], fillvalue='') for c in s))
	return s


def encrypt(text, n):
	print('dasd')
	if n <= 0:
		return text
	new_str = text
	temp_str = ''
	for x in range(n):
		if len(new_str) % 2 == 1:
			iter_for_array_1 = 1
			iter_for_array_2 = 0
			temp_str = ''
			for z in range(int(len(new_str) / 2)):
				temp_str += new_str[iter_for_array_1]
				iter_for_array_1 += 2
			for z in range(int(len(new_str) / 2) + 1):
				temp_str += new_str[iter_for_array_2]
				iter_for_array_2 += 2
			new_str = temp_str
		else:
			iter_for_array_1 = 1
			iter_for_array_2 = 0
			temp_str = ''
			for z in range(int(len(new_str) / 2)):
				temp_str += new_str[iter_for_array_1]
				iter_for_array_1 += 2
			for z in range(int(len(new_str) / 2)):
				temp_str += new_str[iter_for_array_2]
				iter_for_array_2 += 2
			new_str = temp_str
	return new_str

def decrypt(encrypted_text, n):
	print(1)
	if n <= 0 or encrypted_text == '':
		return encrypted_text
	new_str = encrypted_text
	for x in range(n):
		a = int(len(encrypted_text) / 2)
		str1 = new_str[:a]
		str2 = new_str[a:]
		new_str = ''
		for new_X in range(a):
			new_str += str2[new_X]
			new_str += str1[new_X]
		if len(encrypted_text) % 2 == 1:
			new_str += str2[-1]
	return new_str