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: 4
Output:
   A
  ABA
 ABCBA
ABCDCBA
Your Task:
You don't need to input anything. Complete the function printTriangle() which takes an integer n  as the input parameter and prints 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):
			num = 0
			for j in range(n - i - 1):
				print(' ', end='')
			for j in range(i + 1):
				print(chr(65 + num), end='')
				num = num + 1
			p = num - 2
			for j in range(i):
				print(chr(65 + p), end='')
				p = p - 1
			print()


class Solution:

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


class Solution:

	def printTriangle(self, N):
		for i in range(N):
			for j in range(N - i - 1):
				print(' ', end='')
			ch = 'A'
			breakpoint = (2 * i + 1) // 2
			for j in range(2 * i + 1):
				print(ch, end='')
				if j < breakpoint:
					ch = chr(ord(ch) + 1)
				else:
					ch = chr(ord(ch) - 1)
			for j in range(N - i - 1):
				print(' ', end='')
			print()


class Solution:

	def printTriangle(self, N):
		for i in range(N):
			value = ord('A')
			value1 = ord('A') + i - 1
			for j in range(N - i - 1):
				print(' ', end='')
			for k in range(i + 1):
				print(chr(value), end='')
				value += 1
			for l in range(i):
				print(chr(value1), end='')
				value1 -= 1
			print()


class Solution:

	def printTriangle(self, N):
		for i in range(N):
			for j in range(N - i - 1):
				print(' ', end='')
			c = ord('A')
			for j in range(2 * i + 1):
				if j < i + 1:
					print(chr(c), end='')
					c += 1
				if j == i + 1:
					c = c - 2
					print(chr(c), end='')
				if j > i + 1:
					c -= 1
					print(chr(c), end='')
			print('')


class Solution:

	def printTriangle(self, N):
		import string
		l = string.ascii_uppercase
		for i in range(1, N + 1, 1):
			for space in range(N - i):
				print(' ', end='')
			for j in range(i):
				print(l[j], end='')
			count = i - 2
			for k in range(i - 1):
				print(l[count], end='')
				count = count - 1
			print()


class Solution:

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


class Solution:

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


class Solution:

	def printTriangle(self, N):
		i = 0
		while i < N:
			spaces = 0
			while spaces < N - i - 1:
				print(' ', end='')
				spaces += 1
			m = 0
			while m <= i:
				print(chr(ord('A') + m), end='')
				m += 1
			n = i - 1
			while n >= 0:
				print(chr(ord('A') + n), end='')
				n -= 1
			print()
			i += 1


class Solution:

	def printTriangle(self, N):
		for i in range(1, N + 1):
			k = ord('A')
			for j in range(N - i):
				print(' ', end='')
			idx = 2 * i - 1
			for j in range(idx):
				if j < idx // 2:
					print(chr(k), end='')
					k += 1
				else:
					print(chr(k), end='')
					k -= 1
			print()


class Solution:

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


class Solution:

	def printTriangle(self, N):
		s = 65
		for i in range(N):
			for j in range(N - i - 1):
				print(' ', end='')
			for k in range(i + 1):
				print(chr(65 + k), end='')
				f = 65 + k
			for l in range(i):
				print(chr(f - l - 1), end='')
			print()


class Solution:

	def printTriangle(self, N):
		char = 64
		for i in range(1, N + 1):
			for j in range(N - i, 0, -1):
				print(' ', end='')
			for j in range(1, i + 1):
				print(chr(char + j), end='')
			for j in range(i - 1, 0, -1):
				print(chr(char + j), end='')
			print()


class Solution:

	def printTriangle(self, N):
		for i in range(0, N):
			count = 0
			for j in range(0, N + i):
				if j in range(N - 1 - i, N + i):
					if j < N:
						print(chr(65 + count), end='')
						count = count + 1
					elif j == N:
						count = count - 2
						print(chr(65 + count), end='')
					else:
						count = count - 1
						print(chr(65 + count), end='')
				else:
					print(' ', end='')
			print('\n', end='')


class Solution:

	def printTriangle(self, N):
		for x in range(1, N + 1):
			for m in range(N - x):
				print(' ', end='')
			for y in range(x):
				print(chr(65 + y), end='')
			for z in range(x - 2, -1, -1):
				print(chr(65 + z), end='')
			print()
		return


class Solution:

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


class Solution:

	def printTriangle(self, N):
		a = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
		for i in range(N):
			print(' ' * (N - i - 1), end='')
			print(*a[:i], sep='', end='')
			print(*a[i::-1], sep='')


class Solution:

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


class Solution:

	def printTriangle(self, N):
		for i in range(1, N + 1):
			char1 = 'A'
			for j in reversed(range(1, N + 1)):
				if j <= i:
					print(char1, end='')
					char1 = chr(ord(char1) + 1)
				else:
					print(end=' ')
			char1 = chr(ord(char1) - 1)
			for j in range(1, N + 1):
				if j < i:
					char1 = chr(ord(char1) - 1)
					print(char1, end='')
				else:
					print(end='')
			print()


class Solution:

	def printTriangle(self, N):
		letter = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
		for i in range(1, N + 1):
			for s in range(1, N - i + 1):
				print(' ', end='')
			for j in range(1, i + 1):
				print(letter[j - 1], end='')
			for k in range(i - 1, 0, -1):
				print(letter[k - 1], end='')
			print('')


class Solution:

	def printTriangle(self, N):
		for i in range(N):
			for j in range(N - i - 1):
				print(end=' ')
			val = 'A'
			loop_count = 2 * i + 1
			for j in range(int(loop_count / 2 + 1)):
				print(val, end='')
				val = chr(ord(val) + 1)
			val = chr(ord(val) - 2)
			for j in range(int(loop_count - loop_count / 2)):
				print(val, end='')
				val = chr(ord(val) - 1)
			for j in range(N - i - 1):
				print(end=' ')
			print()


class Solution:

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


import math

class Solution:

	def printTriangle(self, N):
		for i in range(N):
			for j in range(N - i - 1, 0, -1):
				print(end=' ')
			char = 'A'
			n = 1
			for j in range(2 * i + 1, 0, -1):
				print(char, end='')
				if n >= (2 * i + 1) / 2:
					char = chr(ord(char) - 1)
				else:
					char = chr(ord(char) + 1)
				n += 1
			print()


class Solution:

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


class Solution:

	def printTriangle(self, N):
		for i in range(1, N + 1):
			n = 64
			for j in range(N - i):
				print(' ', end='')
			for _ in range(i):
				n += 1
				print(chr(n), end='')
			for _ in range(1, i):
				n -= 1
				print(chr(n), end='')
			print()


class Solution:

	def printTriangle(self, N):
		c = 'A'
		ch = c
		for i in range(N, 0, -1):
			for j in range(i, 1, -1):
				print(' ', end='')
			for k in range(N - (i - 1)):
				print(ch, end='')
				ch = chr(ord(ch) + 1)
			ch = chr(ord(ch) - 1)
			for l in range(N - i):
				ch = chr(ord(ch) - 1)
				print(ch, end='')
			print()
			ch = c


class Solution:

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


class Solution:

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


import string

class Solution:

	def printTriangle(self, N):
		alphabets = list(string.ascii_uppercase)
		for i in range(0, N):
			count = 0
			for j in range(0, N + i):
				if j in range(N - 1 - i, N + i):
					if j < N:
						print(alphabets[count], end='')
						count = count + 1
					elif j == N:
						count = count - 2
						print(alphabets[count], end='')
					else:
						count = count - 1
						print(alphabets[count], end='')
				else:
					print(' ', end='')
			print('\n', end='')


class Solution:

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


class Solution:

	def printTriangle(self, N):
		ascii_value = ord('A')
		prev_str = ''
		prev_str_rev = ''
		for i in range(1, N + 1):
			current_str = chr(ascii_value)
			ascii_value += 1
			leading_spaces = ' ' * (N - i)
			print(leading_spaces + prev_str + current_str + prev_str_rev)
			prev_str = prev_str + current_str
			prev_str_rev = current_str + prev_str_rev


class Solution:

	def printTriangle(self, N):
		for i in range(1, N + 1):
			x = N - i
			for j in range(x):
				print('', end=' ')
			for j in range(i):
				print(chr(ord('A') + j), end='')
			for j in range(1, i):
				print(chr(ord('A') + i - j - 1), end='')
			print()


class Solution:

	def printTriangle(self, N):
		s = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
		for j in range(0, N):
			k = s[0:j + 1]
			print(' ' * (N - j - 1) + k + k[::-1][1:])


class Solution:

	def printTriangle(self, N):
		c = 65
		d = 65
		f = 0
		for i in range(0, N):
			c = 65
			d = 65
			for k in range(0, N - i - 1):
				print(' ', end='')
			for j in range(0, i + 1):
				print(chr(c), end='')
				c += 1
			e = d + i - 1
			for l in range(0, i):
				print(chr(e), end='')
				e -= 1
			print()


class Solution:

	def printTriangle(self, N):
		for row in range(N):
			for col in range(N - row - 1):
				print(' ', end='')
			val = 65
			half = (2 * row + 1) // 2
			for col in range(2 * row + 1):
				print(chr(val), end='')
				if col >= half:
					val -= 1
				else:
					val += 1
			for col in range(N - row - 1):
				print(' ', end='')
			print()


class Solution:

	def printTriangle(self, N):
		for row in range(N):
			num_spaces = N - row - 1
			print(' ' * num_spaces, end='')
			for col in range(row + 1):
				print(chr(65 + col), end='')
			if row > 0:
				for col in range(row - 1, -1, -1):
					print(chr(65 + col), end='')
			print()


class Solution:

	def printTriangle(self, N):
		for i in range(1, N + 1):
			a = 65
			for j in range(1, N + 1):
				if i + j >= N + 1:
					print(chr(a), end='')
					a += 1
				else:
					print(' ', end='')
			a = a - 1
			for i in range(1, i):
				a -= 1
				print(chr(a), end='')
			print()


class Solution:

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


class Solution:

	def printTriangle(self, N):
		c = 65
		spaces = N - 1
		for i in range(N):
			for j in range(spaces):
				print(' ', end='')
			for j in range(i + 1):
				print(chr(c), end='')
				c += 1
			c -= 1
			for j in range(i):
				c -= 1
				print(chr(c), end='')
			spaces -= 1
			print()


class Solution:

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


class Solution:

	def printTriangle(self, N):
		num = 64
		for i in range(N):
			for j in range(N - (i + 1), 0, -1):
				print(' ', end='')
			for k in range(i + 1):
				a = num + (k + 1)
				print(chr(a), end='')
			for z in range(i, 0, -1):
				a = num + z
				if a > 64:
					print(chr(a), end='')
			print()


import string

class Solution:

	def printTriangle(self, N):
		alp = list(string.ascii_uppercase)
		for i in range(N):
			for j in range(N - i, 1, -1):
				print(' ', end='')
			for j in range(i + 1):
				print(alp[j], end='')
			for j in range(i):
				print(alp[i - j - 1], end='')
			print()