Geek is very fond of patterns. Once, his teacher gave him a pattern to solve. He gave Geek an integer n and asked him to build a pattern.
Help Geek to build the pattern.
 
Example 1:
Input: 5
Output:
**********
****  ****
***    ***
**      **
*        *
*        *
**      **
***    ***
****  ****
**********
Your Task:
You don't need to input anything. Complete the function printTriangle() which takes  an integer n  as the input parameter and print the pattern.
Constraints:
	1<= N <= 20

Source: geeksforgeeks | Difficulty: EASY

Starter code: #User function Template for python3



class Solution:

    def printTriangle(self, N):

        # Code here

Solutions:
class Solution:

	def printTriangle(self, n):
		for i in range(n):
			for j in range(n - i):
				print('*', end='')
			for j in range(2 * i):
				print(' ', end='')
			for j in range(n - i):
				print('*', end='')
			print()
		for i in range(n):
			for j in range(i + 1):
				print('*', end='')
			for j in range(2 * (n - i - 1)):
				print(' ', end='')
			for i in range(i + 1):
				print('*', end='')
			print()


class Solution:

	def printTriangle(self, N):
		for i in range(N):
			for j in range(0, N - i):
				print('*', end='')
			for k in range(0, 2 * i):
				print(' ', end='')
			for l in range(0, N - i):
				print('*', end='')
			print('')
		for i in range(N):
			for j in range(0, i + 1):
				print('*', end='')
			for k in range(0, 2 * (N - (i + 1))):
				print(' ', end='')
			for l in range(0, i + 1):
				print('*', end='')
			print('')


class Solution:

	def printTriangle(self, N):
		spaces = 0
		for i in range(N):
			for j in range(N - i):
				print('*', end='')
			for j in range(spaces):
				print(' ', end='')
			for j in range(N - i):
				print('*', end='')
			spaces += 2
			print()
		for i in range(1, N + 1):
			for j in range(1, i + 1):
				print('*', end='')
			for j in range(2 * N - 2 * i):
				print(' ', end='')
			for j in range(1, i + 1):
				print('*', end='')
			print()


class Solution:

	def printTriangle(self, N):
		for i in range(2 * N):
			if i < N:
				for j in range(N - i - 1, -1, -1):
					print('*', end='')
				for j in range(N - i, N + i):
					print(' ', end='')
				for j in range(N - i - 1, -1, -1):
					print('*', end='')
				print('')
			else:
				for j in range(0, i - N + 1):
					print('*', end='')
				for j in range(i - N + 1, 2 * N - (i - N) - 1):
					print(' ', end='')
				for j in range(0, i - N + 1):
					print('*', end='')
				print('')


class Solution:

	def printTriangle(self, N):
		for k in range(N + 1, 1, -1):
			for i in range(k - 1):
				print('*', end='')
			for i in range(N - k + 1):
				print(' ', end='')
			for i in range(N - k + 1):
				print(' ', end='')
			for i in range(k - 1):
				print('*', end='')
			print('')
		for k in range(1, N + 1, 1):
			for i in range(k):
				print('*', end='')
			for i in range(N - k):
				print(' ', end='')
			for i in range(N - k):
				print(' ', end='')
			for i in range(k):
				print('*', end='')
			print('')


class Solution:

	def printTriangle(self, N):
		space = 0
		star = N
		for i in range(1, 2 * N + 1):
			for j in range(star):
				print('*', end='')
			for k in range(space):
				print(' ', end='')
			for j in range(star):
				print('*', end='')
			if i < N:
				space += 2
				star -= 1
			elif i == N:
				print('')
				continue
			else:
				space -= 2
				star += 1
			print('')


class Solution:

	def printTriangle(self, N):
		i = 0
		while i < N:
			stars = 0
			while stars < N - i:
				print('*', end='')
				stars += 1
			spaces = 0
			while spaces < 2 * i:
				print(' ', end='')
				spaces += 1
			stars = 0
			while stars < N - i:
				print('*', end='')
				stars += 1
			print()
			i += 1
		j = 0
		while j < N:
			stars = 0
			while stars <= j:
				print('*', end='')
				stars += 1
			spaces = 0
			while spaces < 2 * (N - j - 1):
				print(' ', end='')
				spaces += 1
			stars = 0
			while stars <= j:
				print('*', end='')
				stars += 1
			print()
			j += 1


class Solution:

	def printTriangle(self, n):
		spaces = -2
		for i in range(1, 2 * n + 1):
			if i <= n:
				stars = n - i + 1
				spaces += 2
			else:
				stars = i - n
			for j in range(stars):
				print('*', end='')
			for j in range(spaces):
				print(' ', end='')
			for j in range(stars):
				print('*', end='')
			if i > n:
				spaces -= 2
			print()


class Solution:

	def printTriangle(self, n):
		for i in range(1, n + 1):
			st = n - i + 1
			sp = 2 * i - 2
			print('*' * st + ' ' * sp + '*' * st)
		for i in range(1, n + 1):
			st = i
			sp = 2 * n - 2 * i
			print('*' * st + ' ' * sp + '*' * st)


class Solution:

	def printTriangle(self, N):
		for i in range(N):
			a = (N - i) * '*' + 2 * i * ' ' + (N - i) * '*'
			print(a)
		for i in range(N):
			b = (i + 1) * '*' + 2 * (N - i - 1) * ' ' + (i + 1) * '*'
			print(b)


class Solution:

	def printTriangle(self, N):
		for i in range(N, 0, -1):
			for x in range(i):
				print('*', end='')
			for y in range(2 * N - 2 * i):
				print(' ', end='')
			for x in range(i):
				print('*', end='')
			print()
		for i in range(1, N + 1):
			for x in range(i):
				print('*', end='')
			for y in range(2 * N - 2 * i):
				print(' ', end='')
			for x in range(i):
				print('*', end='')
			print()
		return


class Solution:

	def printTriangle(self, N):
		for i in range(N, 0, -1):
			s = '*' * i + ' ' * 2 * (N - i) + '*' * i
			print(s)
		for i in range(1, N + 1):
			s = '*' * i + ' ' * 2 * (N - i) + '*' * i
			print(s)


class Solution:

	def printTriangle(self, N):
		for i in range(1, N + 1):
			ast = '*' * (N - i + 1)
			space = ' ' * (2 * (i - 1))
			print(ast + space + ast, end='')
			print()
		for i in range(1, N + 1):
			ast = '*' * i
			space = ' ' * (2 * (N - i))
			print(ast + space + ast, end='')
			print()


class Solution:

	def printTriangle(self, N):
		for i in range(N):
			for x in range(N - i):
				print('*', end='')
			for y in range(2 * i):
				print(' ', end='')
			for z in range(N - i):
				print('*', end='')
			print()
		for i in range(1, N + 1):
			for x in range(i):
				print('*', end='')
			for y in range(2 * (N - i)):
				print(' ', end='')
			for z in range(i):
				print('*', end='')
			print()


class Solution:

	def printTriangle(self, N):
		star = N
		empty = 0
		for i in range(1, 2 * N + 1):
			for j in range(star):
				print('*', end='')
			for s in range(empty):
				print(' ', end='')
			for j in range(star):
				print('*', end='')
			if i < N:
				empty += 2
				star -= 1
			elif i == N:
				print('')
				continue
			else:
				empty -= 2
				star += 1
			print('')


class Solution:

	def printTriangle(self, N):
		for i in reversed(range(1, N + 1)):
			for j in range(1, N + 1):
				if j <= i:
					print('*', end='')
				else:
					print(end=' ')
			for j in reversed(range(1, N + 1)):
				if j <= i:
					print('*', end='')
				else:
					print(end=' ')
			print()
		for i in range(1, N + 1):
			for j in range(1, N + 1):
				if j <= i:
					print('*', end='')
				else:
					print(end=' ')
			for j in reversed(range(1, N + 1)):
				if j <= i:
					print('*', end='')
				else:
					print(end=' ')
			print()


class Solution:

	def printTriangle(self, N):
		y = []
		for i in range(0, N):
			s = ''
			for j in range(0, N - i):
				s = s + '*'
			s = s + i * ' '
			r = s[::-1]
			s = s + r
			y.append(s)
		y = y + y[::-1]
		for i in y:
			print(i)


class Solution:

	def printTriangle(self, N):
		for i in range(N):
			stars = '*' * (N - i)
			spaces = ' ' * 2 * i
			print(stars + spaces + stars)
		for j in range(1, N + 1):
			stars = '*' * j
			spaces = ' ' * 2 * (N - j)
			print(stars + spaces + stars)


class Solution:

	def printTriangle(self, n):
		for i in range(1, 2 * n + 1):
			x = abs(i - n - 1)
			y = i
			if i > n:
				x = abs(i - n)
				y = abs(2 * n - i + 1)
			for j in range(x):
				print('*', end='')
			for j in range(y - 1):
				print(' ', end=' ')
			for j in range(x):
				print('*', end='')
			print(' ')


class Solution:

	def printTriangle(self, N):
		l = []
		for j in range(N):
			s = '*' * (N - j) + ' ' * (2 * j) + '*' * (N - j)
			l.append(s)
			print(s)
		for j in range(N - 1, -1, -1):
			print(l[j])


class Solution:

	def printTriangle(self, N):
		n = N - 1
		for i in range(0, N):
			for j in range(0, N - i):
				print('*', end='')
			for k in range(0, i * 2):
				print(' ', end='')
			for l in range(0, N - i):
				print('*', end='')
			print()
		for f in range(0, N):
			for m in range(0, f + 1):
				print('*', end='')
			for p in range(0, (n - f) * 2):
				print(' ', end='')
			for q in range(0, f + 1):
				print('*', end='')
			print()


class Solution:

	def printTriangle(self, N):
		for row in range(N):
			for col in range(N - row):
				print('*', end='')
			for col in range(2 * row):
				print(' ', end='')
			for col in range(N - row):
				print('*', end='')
			print()
		for row in range(N):
			for col in range(row + 1):
				print('*', end='')
			for col in range(2 * N - 2 - 2 * row):
				print(' ', end='')
			for col in range(row + 1):
				print('*', end='')
			print()


class Solution:

	def printTriangle(self, N):
		space1 = 0
		space2 = 2 * (N - 1)
		for i in range(0, N):
			for j in range(N - i):
				print('*', end='')
			for k in range(space1):
				print(' ', end='')
			space1 = space1 + 2
			for j in range(N - i):
				print('*', end='')
			print()
		for p in range(0, N):
			for k in range(p + 1):
				print('*', end='')
			for l in range(space2):
				print(' ', end='')
			space2 = space2 - 2
			for m in range(p + 1):
				print('*', end='')
			print()


class Solution:

	def printTriangle(self, N):
		for row in range(N * 2):
			if row < N:
				num_stars = N - row
				num_spaces = N - (N - row)
			elif row == N:
				num_stars = 1
				num_spaces = N - 1
			else:
				num_stars = row - N + 1
				num_spaces = 2 * N - row - 1
			for star in range(num_stars):
				print('*', end='')
			for space in range(num_spaces):
				print(' ' * 2, end='')
			for star in range(num_stars):
				print('*', end='')
			print()


class Solution:

	def printTriangle(self, n):
		ispace = 0
		for i in range(n):
			for star in range(n - i):
				print('*', end='')
			for space in range(ispace):
				print(' ', end='')
			ispace += 2
			for star in range(n - i):
				print('*', end='')
			print()
		ispace = 2 * n - 2
		for i in range(n):
			for star in range(i + 1):
				print('*', end='')
			for space in range(ispace):
				print(' ', end='')
			ispace -= 2
			for star in range(i + 1):
				print('*', end='')
			print()


class Solution:

	def printTriangle(self, N):
		for i in range(1, N + 1):
			for j in range(1, N - i + 2):
				print('*', end='')
				j += 1
			for k in range(1, i):
				print(' ', end='')
				k += 1
			for l in range(1, i):
				print(' ', end='')
				l += 1
			for m in range(1, N - i + 2):
				print('*', end='')
				m += 1
			print()
			i += 1
		for a in range(1, N + 1):
			for b in range(1, a + 1):
				print('*', end='')
				b += 1
			for c in range(1, N - a + 1):
				print(' ', end='')
				c += 1
			for d in range(1, N - a + 1):
				print(' ', end='')
				d += 1
			for e in range(1, a + 1):
				print('*', end='')
				e += 1
			print()
			a += 1


class Solution:

	def printStars(self, stars, space):
		for j in range(stars):
			print('*', end='')
		for j in range(space):
			print(' ', end='')
		for j in range(stars):
			print('*', end='')
		print()

	def printTriangle(self, N):
		totalStars = 2 * N
		for i in range(N):
			space = i * 2
			stars = N - i
			self.printStars(stars, space)
		for i in range(N):
			space = 2 * N - 2 * (i + 1)
			stars = i + 1
			self.printStars(stars, space)


class Solution:

	def printTriangle(self, N):
		for i in reversed(range(N)):
			spaces = N - i - 1
			starsString = i + 1
			print(starsString * '*' + spaces * '  ' + starsString * '*')
		for i in range(N):
			spaces = N - i - 1
			starsString = i + 1
			print(starsString * '*' + spaces * '  ' + starsString * '*')


class Solution:

	def printTriangle(self, a):
		z = 0
		for i in range(a, 0, -1):
			print('*' * i + ' ' * z + '*' * i)
			z = z + 2
		l = (a - 1) * 2
		for i in range(1, a + 1):
			print('*' * i + ' ' * l + '*' * i)
			l -= 2


class Solution:

	def printTriangle(self, N):
		for i in range(N):
			print('*' * (N - i), ' ' * 2 * i, '*' * (N - i), sep='')
		for i in range(N - 1, -1, -1):
			print('*' * (N - i), ' ' * 2 * i, '*' * (N - i), sep='')


class Solution:

	def printTriangle(self, n):
		for i in range(n):
			white = i * 2
			for k in range(n - i):
				print('*', end='')
			for l in range(white):
				print(' ', end='')
			for m in range(n - i):
				print('*', end='')
			print()
		for i in range(n):
			white = (i + 1) * 2
			for k in range(i + 1):
				print('*', end='')
			for l in range(n * 2 - white):
				print(' ', end='')
			for m in range(i + 1):
				print('*', end='')
			print()