human
Count of possible permutations of a number represented as a sum of 2 ' s , ▁ 4' s and 6 's only | Returns number of ways to reach score n.
table [ i ] will store count of solutions for value i ..
Initialize all table values as 0.
Base case ( If given value is 0 , 1 , 2 , or 4 ).
Driver Code"
How can the above be solved in Python?
assistant
#Here is code to count of possible permutations of a number represented as a sum of 2 ' s , ▁ 4' s and 6 's only and the other steps required.
 def count ( n ) :
	if ( n == 2 ) :
		return 1 ;
	elif ( n == 4 ) :
		return 2 ;
	elif ( n == 6 ) :
		return 4 ;
	table = [ 0 ] * ( n + 1 ) ;
	for i in range ( n + 1 ) :
		table [ i ] = 0 ;
	table [ 0 ] = 0 ;
	table [ 2 ] = 1 ;
	table [ 4 ] = 2 ;
	table [ 6 ] = 4 ;
	for i in range ( 8 , n + 1 , 2 ) :
		table [ i ] = table [ i - 2 ] + table [ i - 4 ] + table [ i - 6 ] ;
	return table [ n ] ;
if __name__ == " _ _ main _ _ " :
	n = 8 ;
	print ( count ( n ) ) ;