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 a star pattern.
 
Example 1:
Input: 5
Output:
1 
0 1 
1 0 1
0 1 0 1 
1 0 1 0 1
 
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(0, N):
			if i % 2 == 0:
				start = 1
			else:
				start = 0
			for j in range(0, i + 1):
				print(start, end=' ')
				start = 1 - start
			print()


class Solution:

	def printTriangle(self, n):
		s = 1
		for i in range(n):
			if i % 2 == 0:
				s = 1
			else:
				s = 0
			for j in range(i + 1):
				print(s, end=' ')
				s = 1 - s
			print()


class Solution:

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


class Solution:

	def printTriangle(self, N):
		start = 1
		for x in range(1, N + 1):
			if x % 2 == 0:
				start = 0
			else:
				start = 1
			for y in range(1, x + 1):
				print(start, end=' ')
				start = 1 - start
			print()


class Solution:

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


class Solution:

	def printTriangle(self, N):
		i = 0
		while i < N:
			j = 0
			while j <= i:
				if (i + j) % 2 == 0:
					print(1, end=' ')
				else:
					print(0, end=' ')
				j += 1
			print()
			i += 1


class Solution:

	def printTriangle(self, N):
		for i in range(N):
			if i % 2 == 0:
				k = 0
				for j in range(i + 1):
					print(int(not k), end=' ')
					k = int(not k)
			else:
				k = 1
				for j in range(i + 1):
					print(int(not k), end=' ')
					k = int(not k)
			print('')


class Solution:

	def printTriangle(self, N):
		a = '1'
		print(a)
		for i in range(1, N):
			if i % 2 == 0:
				a = '1 ' + a
			else:
				a = '0 ' + a
			print(a)


class Solution:

	def printTriangle(self, N):
		arr = ['']
		for i in range(0, N):
			if i % 2 == 1:
				arr.append('0 ' + arr[i])
			elif i % 2 == 0:
				arr.append('1 ' + arr[i])
		arr.remove('')
		for item in arr:
			print(item)


class Solution:

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


def convert(a):
	m = ''
	for x in a:
		if x == '0':
			m += '1'
		else:
			m += '0'
	m += '1'
	return m

class Solution:

	def printTriangle(self, N):
		y = '1'
		print(y)
		i = 0
		while i < N - 1:
			a = convert(y)
			y = a
			for x in a:
				print(x, end=' ')
			print()
			i += 1
		return


class Solution:

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


class Solution:

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


class Solution:

	def printTriangle(self, N):
		lis = [i & 1 for i in range(N)]
		for i in range(1, N + 1):
			[print(i + lis[j] & 1, end=' ') for j in range(i)]
			print()


class Solution:

	def printTriangle(self, N):
		horizontal = 1
		vertical = 1
		for i in range(N):
			for j in range(i + 1):
				print(horizontal, end=' ')
				horizontal = 1 if horizontal == 0 else 0
			print()
			vertical = 1 if vertical == 0 else 0
			horizontal = vertical


class Solution:

	def printTriangle(self, N):
		for i in range(1, N + 1):
			for j in range(1, N + 1):
				if j <= i:
					if i & 1 and j & 1 or (not i & 1 and (not j & 1)):
						print('1', end=' ')
					else:
						print('0', end=' ')
			print('')