Ram is very fond of patterns. Once, his teacher gave him a pattern to solve. He gave Ram an integer n and asked him to build a pattern.
Help Ram build a  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

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(2 * n):
			if i < n:
				for j in range(i + 1):
					print('*', end='')
				for j in range(2 * (n - i - 1)):
					print(' ', end='')
				for j in range(i + 1):
					print('*', end='')
				print()
			if i > n:
				for j in range(2 * n - i):
					print('*', end='')
				for j in range(2 * i - 2 * n):
					print(' ', end='')
				for j in range(2 * n - i):
					print('*', end='')
				print()


class Solution:

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


class Solution:

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


class Solution:

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


class Solution:

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


class Solution:

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


class Solution:

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


class Solution:

	def printTriangle(self, N):
		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('')
		for k in range(N, 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('')


class Solution:

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


class Solution:

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


class Solution:

	def printTriangle(self, N):
		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()
		for i in range(N - 1, 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()
		return


class Solution:

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


class Solution:

	def printTriangle(self, N):
		star = 1
		empty = 2 * (N - 1)
		for i in range(1, 2 * N):
			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
			else:
				empty += 2
				star -= 1
			print('')


class Solution:

	def printTriangle(self, N):
		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()
		for i in reversed(range(1, N)):
			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[::-1][:-1] + y
		for i in y:
			print(i)


class Solution:

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


class Solution:

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


class Solution:

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


class Solution:

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


class Solution:

	def printTriangle(self, n):
		space = 2 * (n - 1)
		space2 = 0
		for i in range(1, n):
			for j in range(i):
				print('*', end='')
			for j in range(space):
				print(' ', end='')
			space = space - 2
			for k in range(i):
				print('*', end='')
			print()
		for p in range(n, 0, -1):
			for q in range(p):
				print('*', end='')
			for r in range(space2):
				print(' ', end='')
			space2 = space2 + 2
			for s in range(p):
				print('*', end='')
			print()


class Solution:

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


class Solution:

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


class Solution:

	def printTriangle(self, N):
		spaces = N * 2 - 2
		if N > 20:
			return None
		for i in range(1, N + 1):
			print('*' * i + spaces * ' ' + '*' * i)
			spaces -= 2
		spaces = 2
		for i in range(N - 1, 0, -1):
			print('*' * i + spaces * ' ' + '*' * i)
			spaces += 2


class Solution:

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


class Solution:

	def printTriangle(self, N):
		for i in range(1, N + 1):
			for j in range(1, i + 1):
				print('*', end='')
				j += 1
			for k in range(1, N - i + 1):
				print(' ', end='')
				k += 1
			for l in range(1, N - i + 1):
				print(' ', end='')
				l += 1
			for m in range(1, i + 1):
				print('*', end='')
				m += 1
			print()
			i += 1
		for a in range(1, N):
			for b in range(1, N - a + 1):
				print('*', end='')
				b += 1
			for c in range(1, a + 1):
				print(' ', end='')
				c += 1
			for d in range(1, a + 1):
				print(' ', end='')
				d += 1
			for e in range(1, N - 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):
		for i in range(N):
			stars = i + 1
			space = 2 * N - 2 * (i + 1)
			self.printStars(stars, space)
		for i in range(N - 1, 0, -1):
			stars = i
			space = 2 * (N - i)
			self.printStars(stars, space)


class Solution:

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


class Solution:

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


class Solution:

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


class Solution:

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


class Solution:

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


class Solution:

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