You are given a number N. You need to print the pattern for the given value of N.
For N = 2 the pattern will be 
2 2 1 1
2 1
For N = 3 the pattern will be 
3 3 3 2 2 2 1 1 1
3 3 2 2 1 1
3 2 1
Note: Instead of printing a new line print a "$" without quotes. After printing the total output, end of the line is expected.
Example 1:
Input: 2
Output:
2 2 1 1 $2 1 $
Example 2:
Input: 3
Output:
3 3 3 2 2 2 1 1 1 $3 3 2 2 1 1 $3 2 1 $
Your Task:
Since this is a function problem, you don't need to worry about the test cases. Your task is to complete the function printPat() which takes one argument 'N' denoting the length of the pattern.
Constraints:
1 <= N <= 40

Source: geeksforgeeks | Difficulty: EASY

Starter code: def printPat(n):

    #Code here

Solutions:
def printPat(n):
	for k in range(0, n):
		for i in range(n, 0, -1):
			for j in range(0, n - k):
				print(i, end=' ')
		print('$', end='')
	if i == 1:
		print()


def printPat(n):
	import math
	s = ''
	for i in range(n, 0, -1):
		for j in range(n * i, 0, -1):
			x = math.ceil(j / i)
			if n * i == j:
				s = s + str(x)
			else:
				s = s + ' ' + str(x)
		s = s + ' ' + '$'
	print(s)


def printPat(n):
	a = [i for i in range(1, n + 1)]
	res = []
	for i in range(1, n + 1):
		ans = []
		for j in range(i):
			ans.extend(a)
		ans.sort()
		res.append(ans[:])
	result = ''
	res[0].insert(0, '$')
	res = res[::-1]
	for i in range(1, len(res)):
		res[i][-1] = '$' + str(res[i][-1])
	k = []
	for i in res:
		k.extend(i[::-1])
	print(*k)


def printPat(n):
	word = ''
	for j in range(n, 0, -1):
		for i in range(n, 0, -1):
			word += (str(i) + ' ') * j
		word += '$'
	print(word)


def printPat(n):
	count = n
	while count > 0:
		updatedNum = n
		while updatedNum > 0:
			for i in range(count):
				print(updatedNum, end=' ')
			updatedNum -= 1
		print('$', end='')
		count -= 1
	print()


def printPat(n):
	s = ''
	a = list(range(1, n + 1))
	i = n
	j = []
	while i >= 1:
		p = i * a
		p.sort()
		p.reverse()
		j = j + p
		i = i - 1
		j = j + ['$']
	for i in range(len(j)):
		if j[i] != '$':
			s = s + str(j[i]) + ' '
		elif j[i] == '$':
			s = s + str(j[i])
	print(s)


def printPat(n):
	s = ''
	a = n
	for i in range(n):
		j = n
		while j != 0:
			x = str(j) + ' '
			s += a * x
			j -= 1
		s += '$'
		a -= 1
	print(s)


def printPat(n):
	result = ''
	if n > 1:
		for i in range(n, 0, -1):
			for j in range(n, 0, -1):
				for k in range(i):
					result = result + str(j) + ' '
			result = result + '$'
	elif n == 1:
		result = '1 $'
	print(result)


def printPat(n):
	res = ''
	m = n
	while m > 0:
		for int in range(n, 0, -1):
			res = res + (str(int) + ' ') * m
		res = res + '$'
		m -= 1
	print(res)


def printPat(n):
	k = ''
	for i in range(n, 0, -1):
		temp = ''
		for j in range(n):
			temp = temp + (str(n - j) + ' ') * i
		k = k + temp + '$'
	print(k)


def printPat(n):
	for i in range(n, 0, -1):
		for j in range(n, 0, -1):
			s = str(j) + ' '
			print(i * s, end='')
		print('$', end='')
	if i == 1:
		print()
	return 0


def printPat(n):
	for p in range(n, 0, -1):
		for q in range(n, 0, -1):
			for o in range(p):
				print(q, end=' ')
		print('$', end='')
		if p == 1:
			print()


def printPat(n):
	m = n
	for i in range(n):
		for j in range(n, 0, -1):
			c = 0
			while c != m:
				print(j, end=' ')
				c += 1
		m -= 1
		print('$', end='')
	print('')


def printPat(n):
	m = n
	l = ''
	while m > 0:
		a = n
		while a > 0:
			for _ in range(m):
				l += str(a) + ' '
			a -= 1
		l += '$'
		m -= 1
	print(l)


def printPat(n):
	ans = ''
	for i in range(n, 0, -1):
		part = ''
		for j in range(n, 0, -1):
			part += (str(j) + ' ') * i
		ans += part + '$'
	print(ans)


def printPat(n):
	if not n < 1 and (not n > 40):
		string = ''
		for i in range(n, 0, -1):
			arr = list(range(1, n + 1)) * i
			arr.sort(reverse=True)
			arr = ' '.join((str(x) for x in arr))
			string += arr + ' $'
	print(string)


def printPat(n):
	output = ''
	for i in range(n):
		for j in range(n):
			for k in range(n - i):
				output += str(n - j) + ' '
		output += '$'
	print(output)


def printPat(n):
	word = str()
	for i in range(n, 0, -1):
		for x in range(n, 0, -1):
			y = str(x)
			word += (y + ' ') * i
		word += '$'
	print(word)


def printPat(n):
	arr = []
	for i in range(n, 0, -1):
		arr.append(str(i))
	res = ''
	for i in range(n, 0, -1):
		temp = ''
		for ele in arr:
			temp += (ele + ' ') * i
		temp += '$'
		res += temp
	print(res)


def printPat(n):
	for i in range(n):
		for j in range(n):
			print((str(n - j) + ' ') * (n - i), end='')
		print('$', end='')
	print()


def printPat(n):
	input = n
	for countdown in range(input, 0, -1):
		for number in range(input, 0, -1):
			print((str(number) + ' ') * countdown, end='')
		print('$', end='')
	print()


def printPat(n):
	res = ''
	for i in range(n, 0, -1):
		for j in range(n, 0, -1):
			res += i * (str(j) + ' ')
		res += '$'
	return print(res)


def printPat(n):
	res = ''
	l_two_range = n + 1
	for main_loop in range(n):
		l_two_range = l_two_range - 1
		for l_one in range(n):
			for l_two in range(l_two_range):
				res = res + str(n - l_one) + ' '
		res = res + '$' + ''
	print(res)


import itertools

def printPat(n):
	res = ''
	for i in range(n, 0, -1):
		for j in range(n, 0, -1):
			res += i * (str(j) + ' ')
		res += '$'
	print(res)


def printPat(n):
	output = ''
	counter = n
	while counter > 0:
		printer = n
		for i in range(1, counter * n + 1):
			output += str(printer) + ' '
			if i % counter == 0:
				printer -= 1
		output += '$'
		counter -= 1
	print(output)


def printPat(n):
	printText = ''
	for i in range(n * -1, 0):
		positiveI = i * -1
		printNumber = n
		for j in range(positiveI * n):
			if positiveI != n and j == 0:
				printText += '$' + str(printNumber)
			else:
				printText += str(printNumber)
			printText += ' '
			if (j + 1) % positiveI == 0:
				printNumber -= 1
	printText += '$'
	print(printText)


def printPat(n):
	if n == 1:
		print('1 $')
	elif n == 2:
		print('2 2 1 1 $2 1 $')
	else:
		res = ''
		for i in range(n):
			for j in range(n, 0, -1):
				res += (n - i) * (str(j) + ' ')
			res += '$'
		print(res)