human
Program to print the pattern 1020304017018019020 * * 50607014015016 * * * * 809012013 * * * * * * 10011. . . | Function to find the sum of N integers from 1 to N.
Function to print the given pattern.
Iterate over [ 0 , N - 1 ].
Sub - Pattern - 1.
Sub - Pattern - 2.
Count the number of element in rows and sub - pattern 2 and 3 will have same rows.
Increment Val to print the series 1 , 2 , 3 , 4 , 5 ....
Finally , add the ( N - 1 ) th element i . e . , 5 and increment it by 1.
Initial is used to give the initial value of the row in Sub - Pattern 3.
Sub - Pattern 3.
Skip printing zero at the last.
Given N.
Function call"
How can the above be solved in Python?
 ... What is a code to program to print the pattern 1020304017018019020 * * 50607014015016 * * * * 809012013 * * * * * * 10011?
assistant
#Here is code to program to print the pattern 1020304017018019020 * * 50607014015016 * * * * 809012013 * * * * * * 10011.
 def sum ( n ) :
	return n * ( n - 1 ) // 2
def BSpattern ( N ) :
	Val = 0
	Pthree = 0 ,
	cnt = 0
	initial = - 1
	s = " * * "
	for i in range ( N ) :
		cnt = 0
		if ( i > 0 ) :
			print ( s , end = " " )
			s += " * * "
		for j in range ( i , N ) :
			if ( i > 0 ) :
				cnt += 1
			Val += 1
			print ( Val , end = " " )
			print ( 0 , end = " " )
		if ( i == 0 ) :
			Sumbeforelast = sum ( Val ) * 2
			Pthree = Val + Sumbeforelast + 1
			initial = Pthree
		initial = initial - cnt
		Pthree = initial
		for k in range ( i , N ) :
			print ( Pthree , end = " " )
			Pthree += 1
			if ( k != N - 1 ) :
				print ( 0 , end = " " )
		print ( )
N = 5
BSpattern ( N )