human
Count ways to reach a score using 1 and 2 with no consecutive 2 s | Bottom up approach for counting ways to reach a score using 1 and 2 with consecutive 2 allowed.
noOfWays [ i ] will store count for value i . 3 extra values are to take care of corner case n = 0.
Loop till " n + 1" to compute value for " n ".
number of ways if first run is 1 + number of ways if first run is 2 and second run is 1.
Driver Code"
Solution in Python:
 What is a code to count ways to reach a score using 1 and 2 with no consecutive 2 s and the other steps required?
assistant
#Here is code to count ways to reach a score using 1 and 2 with no consecutive 2 s and the other steps required.
 def CountWays ( n ) :
	noOfWays = [ 0 ] * ( n + 3 )
	noOfWays [ 0 ] = 1
	noOfWays [ 1 ] = 1
	noOfWays [ 2 ] = 1 + 1
	for i in range ( 3 , n + 1 ) :
		noOfWays [ i ] = noOfWays [ i - 1 ] + noOfWays [ i - 3 ]
	return noOfWays [ n ]
if __name__ == ' _ _ main _ _ ' :
	n = 5
	print ( CountWays ( n ) )