human
Print all sequences of given length | A utility function that prints a given arr [ ] of length size.
The core function that recursively generates and prints all sequences of length k.
A function that uses printSequencesRecur ( ) to prints all sequences from 1 , 1 , . .1 to n , n , . . n.
Driver Code"
How can the above be solved in Python?
assistant
#Here is code to print all sequences of given length and the other steps required.
 def printArray ( arr , size ) :
	for i in range ( size ) :
		print ( arr [ i ] , end = " ▁ " ) ;
	print ( " " ) ;
	return ;
def printSequencesRecur ( arr , n , k , index ) :
	if ( k == 0 ) :
		printArray ( arr , index ) ;
	if ( k > 0 ) :
		for i in range ( 1 , n + 1 ) :
			arr [ index ] = i ;
			printSequencesRecur ( arr , n , k - 1 , index + 1 ) ;
def printSequences ( n , k ) :
	arr = [ 0 ] * n ;
	printSequencesRecur ( arr , n , k , 0 ) ;
	return ;
n = 3 ;
k = 2 ;
printSequences ( n , k ) ;