Given an odd length word your task is to complete the function printPattern that takes a string s as its argument and prints it from the middle of the word such that it follows the following pattern.
 
Input: PROGRAM 
Output:
G$ GR$ GRA$ GRAM$ 
GRAMP$ GRAMPR$ GRAMPRO$
Input: RAT
Output:
A$ AT$ ATR$
NOTE: 
Corresponding to each test case in a new 
line print the pattern in a  single 
line where each row of the pattern 
is separated by a "$" instead 
of a new line.
Constraints:
1 ≤ T ≤ 20
1<=size of string(s)<=20

Difficulty: EASY

Starter code:
# method prints the given pattern in a single line 
def printPattern(str):
    # Your code goes here

Solutions:
def printPattern(str):
	l = []
	s = ''
	length = len(str)
	for i in range(length // 2, length):
		s = s + str[i]
		print(s, end='$ ')
	for j in range(0, length // 2):
		s = s + str[j]
		print(s, end='$ ')
	print()


def printPattern(str):
	n = len(str)
	for i in range(n):
		if i <= n // 2:
			print(str[n // 2:n // 2 + 1 + i] + '$', end=' ')
		else:
			print(str[n // 2:] + str[:i - n // 2] + '$', end=' ')
	print()


def printPattern(str):
	middle = len(str) // 2
	for i in range(middle, len(str)):
		s = str[middle:i + 1]
		print(s + '$', end=' ')
	for i in range(0, middle):
		s += str[i:i + 1]
		print(s + '$', end=' ')
	print()


def printPattern(str):
	l = []
	k = len(str) // 2
	s = str[k:] + str[:k]
	for i in range(len(s)):
		l.append(s[:i + 1] + '$')
	print(*l)


def printPattern(str):
	a = str[len(str) // 2:] + str[:len(str) // 2]
	l = []
	for i in range(1, len(a) + 1):
		l.append(a[:i] + '$')
	print(*l)


def printPattern(str):
	mid = len(str) // 2
	st = ''
	for i in str[mid:]:
		st += i
		print(st, end='$ ')
	for j in str[:mid]:
		st += j
		print(st, end='$ ')
	print()


def printPattern(str):
	a = len(str) // 2
	x = '$'
	xx = str[a:len(str)] + str[0:a]
	for i in range(0, len(xx)):
		print(xx[0:i + 1] + x, end=' ')
	print()


def printPattern(s):
	t = len(s) // 2
	s = s[t:len(s)] + s[:t]
	v = ''
	for i in s:
		if v == '':
			v = i
			print(v + '$', end=' ')
		else:
			v = v + i
			print(v + '$', end=' ')
	print(' ')


def printPattern(str):
	arr = [i for i in str]
	length = len(arr)
	mid = length // 2
	k = 0
	for i in range(mid, length - 1):
		for j in range(mid, i + 1):
			print(arr[j], end='')
		print('$', end=' ')
	while k <= mid:
		for j in range(mid, length):
			print(arr[j], end='')
		for l in range(0, k):
			print(arr[l], end='')
		print('$', end=' ')
		k += 1
	print()


def printPattern(str):

	def ans(str):
		n = len(str)
		h = n // 2
		str1 = str[h:] + str[:h]
		for i in range(1, len(str1) + 1):
			print(str1[:i] + '$', end=' ')
		return ''
	print(ans(str))


def printPattern(stt):

	def kcpd(st):
		k = len(st) // 2
		l = st[k:] + st[:k]
		for i in range(1, len(l) + 1):
			op = l[:i]
			print(op + '$', end=' ')
		return ''
	print(kcpd(stt))


def printPattern(st):
	st = list(st)
	k = len(st) // 2
	st = st[k:] + st[:k]
	l = []
	ka = ''
	for i in range(1, len(st) + 1):
		k = st[:i]
		for i in k:
			ka += i
		ka += '$ '
	print(ka)


def printPattern(str):

	def ans(s):
		mid = len(str) // 2
		lis = str[mid:] + str[:mid]
		for i in range(len(str)):
			print(''.join(lis[:i + 1]) + '$', end=' ')
		return ''
	print(ans(str))


def printPattern(str):
	ind = len(str) // 2
	k = []
	for i in range(ind, len(str)):
		print(str[ind:i + 1], end='$ ')
		k = str[ind:i + 1]
	for i in range(ind):
		print(k + str[0:i + 1], end='$ ')
	print()


def printPattern(str):
	middle = len(str) // 2
	string = str[middle:] + str[:middle]
	for i in range(len(str)):
		print(string[:i + 1] + '$', end=' ')
	print()


def printPattern(str):
	n = len(str) // 2
	a = str[n:] + str[:n]
	for i in range(len(str)):
		print(a[:i + 1] + '$', end=' ')
	print()


def printPattern(str):
	mid = len(str) // 2
	c = str[mid:] + str[:mid]
	for i in range(len(str)):
		print(c[:i + 1] + '$', end=' ')
	print()


def printPattern(str):
	new_s = str[len(str) // 2:len(str)] + str[0:len(str) // 2]
	for i in range(1, len(new_s)):
		print(new_s[0:i] + '$', end=' ')
	print(new_s[:] + '$')


def printPattern(s):
	n = len(str) // 2
	new = str[n:] + str[:n]
	ans = ''
	for i in range(1, len(str) + 1):
		ans += new[:i] + '$'
		ans += ' '
	print(ans)


def printPattern(str):
	x = len(str) // 2
	new = str[x:] + str[:x]
	ans = ''
	for i in range(1, len(str) + 1):
		ans += new[:i] + '$'
		ans += ' '
	print(ans)


def printPattern(str):
	n = len(str) // 2
	li = []
	str = str[n:] + str[:n]
	for i in range(len(str)):
		li.append(str[:i + 1] + '$')
	print(*li)


def printPattern(str):
	input_value = str
	value_length = len(input_value)
	if value_length == 1:
		print(input_value + '$')
		return None
	middle_pos = value_length // 2
	changed_value = input_value[middle_pos:] + input_value[:middle_pos]
	result = ''
	for num in range(value_length):
		temp = changed_value[:num + 1] + '$'
		if num == 0:
			result += temp
		else:
			result += ' ' + temp
	print(result)


def printPattern(str):
	mid = int(len(str) / 2)
	for i in range(1, len(str) + 1):
		temp = mid
		for j in range(i, 0, -1):
			print(str[temp], end='')
			temp = (temp + 1) % len(str)
		print('$ ', end='')
	print()


def printPattern(str):
	mid = len(str) // 2
	new_str = ''
	new_str1 = ''
	for i in range(len(str)):
		if mid == len(str):
			mid = 0
		new_str += str[mid]
		new_str1 += new_str + '$ '
		mid += 1
	print(new_str1)


def printPattern(str):
	st = ''
	mid = len(str) // 2
	reach = mid
	a = str[mid:]
	l = 1
	for i in range(mid, len(str)):
		st += str[mid:i + 1] + '$' + ' '
		l += 1
	for j in range(0, mid):
		st += a + str[0:j + 1] + '$' + ' '
	print(st)


def printPattern(str):
	l = []
	n = len(str)
	x = n // 2
	for y in range(x + 1, n + 1):
		l.append(str[x:y])
	s = l[-1]
	for y in range(1, n // 2 + 1):
		l.append(s + str[0:y])
	for y in l:
		y += '$'
		print(y, end=' ')
	print()


def printPattern(s):
	n = len(s)
	if n == 1:
		print(s + '$')
		return
	mid = n // 2
	for i in range(mid, n):
		print(s[mid:i + 1] + '$', end=' ')
	for i in range(1, mid):
		print(s[mid:] + s[:i] + '$', end=' ')
	print(s[mid:] + s[:mid] + '$')


def printPattern(str1):
	start = len(str) // 2
	string = ''
	word = ''
	for i in range(0, start + 1):
		word = word + str1[start + i]
		string = string + word + '$ '
	for i in range(0, start):
		word = word + str[i]
		string = string + word + '$ '
	string = string[:-1]
	print(string)


def printPattern(s):
	mid = len(s) // 2
	o = ''
	for i in range(mid, len(s)):
		o += s[mid:i + 1]
		o += '$'
		o += ' '
	last = s[mid:]
	for i in range(0, mid):
		o += last
		o += s[0:i + 1]
		o += '$'
		o += ' '
	print(o)


def printPattern(str):
	index = len(str) // 2
	s = ''
	for i in range(len(str)):
		if index == len(str):
			index = 0
		s += str[index]
		index += 1
		print(s, end='$ ')
	print(end='\n')


def printPattern(str):
	length = len(str)
	for i in range(length):
		for j in range(i + 1):
			index = int(length / 2) + j
			if index >= length:
				index = index % length
			print(str[index], end='')
		print('$', end=' ')
	print()


def printPattern(string):
	mid = len(string) // 2
	index = mid
	while index < len(string):
		print(string[mid:index + 1], end='$ ')
		index += 1
	index = 0
	while index < mid:
		print(string[mid:], end='')
		print(string[:index + 1], end='$ ')
		index += 1
	print()
if __name__ == '__main__':
	n = int(input())
	for i in range(n):
		str = input().strip()
		printPattern(str)


def printPattern(str):
	length = len(str)
	for i in range(length):
		for j in range(i + 1):
			index = int(length / 2) + j
			if index >= length:
				index = index % length
			print(str[index], end='')
		print('$', end=' ')
	print()
if __name__ == '__main__':
	n = int(input())
	for i in range(n):
		str = input().strip()
		printPattern(str)


def printPattern(s):
	lst = list(s)
	result = ''
	res = lst[len(lst) // 2:]
	res.extend(lst[:len(lst) // 2])
	for itr in range(1, len(res) + 1):
		result = result + ''.join(res[:itr]) + '$ '
	print(result)
if __name__ == '__main__':
	n = int(input())
	for i in range(n):
		str = input().strip()
		printPattern(str)


def printPattern(str):
	l = len(str) // 2
	for i in range(l, len(str)):
		print(str[l:i + 1], end='$ ')
	for j in range(0, l):
		print(str[l:] + str[0:j + 1], end='$ ')
	print()
if __name__ == '__main__':
	n = int(input())
	for i in range(n):
		str = input().strip()
		printPattern(str)


import math

def printPattern(s):
	l = len(str) // 2
	for i in range(l, len(str)):
		print(str[l:i + 1], end='$ ')
	for j in range(0, l):
		print(str[l:] + str[0:j + 1], end='$ ')
	print()


import math

def printPattern(s):
	le = len(str)
	str2 = ''
	mid = le // 2
	i = 1
	while i <= le:
		if mid > le - 1:
			mid = 0
		str2 = str2 + str[mid]
		print(str2, end='$ ')
		mid = mid + 1
		i = i + 1
	print()
	str2 = ''
	return 0


def printPattern(str):
	le = len(str)
	str2 = ''
	mid = le // 2
	i = 1
	while i <= le:
		if mid > le - 1:
			mid = 0
		str2 = str2 + str[mid]
		print(str2, end='$ ')
		mid = mid + 1
		i = i + 1
	print()
	str2 = ''
	return 0


import sys

def substr(a, i, j):
	sub = ''
	for t in range(i, j):
		sub += a[t]
	return sub

def printPattern(str):
	k = len(str) // 2
	low = substr(str, 0, k)
	high = substr(str, k, len(str))
	high += low
	for i in range(0, len(str)):
		r = substr(high, 0, i + 1)
		sys.stdout.write(r + '$ ')
	print('')


def printPattern(str1):
	cd = ''
	ab = str1[len(str1) // 2:] + str1[:len(str1) // 2]
	for i in range(0, len(str1)):
		for j in range(0, i + 1):
			cd += ab[j]
		cd += '$ '
	print(cd)


def printPattern(str):
	n = len(str)
	k = n // 2 - 1
	str = str[k + 1:] + str[:k + 1]
	res = ''
	i = 0
	while i < n:
		res += str[i]
		print(res + '$', end=' ')
		i += 1
	print()


def printPattern(str):
	l = len(str) // 2
	for i in range(l, len(str)):
		print(str[l:i + 1], end='$ ')
	for j in range(0, l):
		print(str[l:] + str[0:j + 1], end='$ ')
	print()


def printPattern(str):
	m = len(str) // 2
	i = m
	s = ''
	l = []
	while str:
		s += str[i]
		v = s + '$'
		l.append(v)
		if i == len(str) - 1:
			break
		i += 1
	i = 0
	while i < m:
		s += str[i]
		v = s + '$'
		l.append(v)
		i += 1
	res = ''
	for i in l:
		res += i
		res += ' '
	print(res)


def printPattern(str):
	n = len(str)
	mid = n // 2
	strin = ''
	for i in range(mid, mid + n):
		for j in range(mid, i + 1):
			strin += str[j % n]
		strin += '$ '
	print(strin)


def printPattern(str):
	k = len(str)
	start = k // 2 - 1
	str = str[start + 1:] + str[:start + 1]
	s = ''
	start = 0
	while start < k:
		s += str[start]
		print(s + '$', end=' ')
		start += 1
	print()


def printPattern(str):
	mid = (0 + len(str)) // 2
	str_f = str[0:mid]
	str_s = str[mid:]
	new_s = str_s + str_f
	count = 0
	a = []
	for i in range(len(str)):
		if count != 0:
			b = ''
			for j in range(count + 1):
				b += new_s[j]
			a.append(b)
			count += 1
		else:
			a.append(new_s[0])
			count += 1
	print('$ '.join(a) + '$')


def printPattern(str):
	if len(str) % 2 == 1:
		midInd = int(len(str) / 2)
		for i in range(midInd, len(str)):
			print(str[midInd:i + 1] + '$ ', end='')
		temp = str[midInd:len(str)]
		for i in range(midInd):
			print(temp + str[:i + 1] + '$ ', end='')
		print('\n', end='')


def printPattern(str):
	result = ''
	str_len = len(str)
	str_div = len(str) // 2
	a = str[str_div:] + str[:str_div]
	for i in range(1, str_len + 1):
		result += a[:i] + '$ '
	result.strip()
	print(result)


def printPattern(str):
	res = []
	mid = len(str) // 2
	for i in range(mid + 1, mid + len(str) + 1):
		s = ''
		for j in range(mid, i):
			new = j % len(str)
			s += str[new]
		res.append(s)
	res.append('')
	print('$ '.join(res))


def printPattern(str):
	s = str + str
	m = int((len(str) + 1) / 2)
	n = int(m - 1)
	d = len(str)
	x = []
	for i in range(m - 1, d + d + 1 - m):
		e = s[m - 1:i]
		x.append(e)
	y = x[1:]
	f = ''
	for q in y:
		f = f + q + '$' + ' '
	print(f)


def printPattern(str):
	ans = []
	mid = len(str) // 2
	for i in range(mid, len(str)):
		a = ''
		a += str[mid:i + 1]
		a += '$'
		ans.append(a)
	for i in range(mid):
		a = ''
		a += str[mid:]
		a += str[:i + 1]
		a += '$'
		ans.append(a)
	print(*ans)


def printPattern(str):
	output_string = ''
	length_of_string = len(str)
	middle = length_of_string // 2
	for i in range(middle + 1, middle + length_of_string + 1):
		if i > length_of_string:
			output_string = output_string + str[middle:] + str[:i - length_of_string] + '$ '
		else:
			output_string = output_string + str[middle:i] + '$ '
	print(output_string)