human
Give me a code to count number of ways to cover a distance and the other steps required given the following:
Count number of ways to cover a distance | A Dynamic Programming based C ++ program to count number of ways.
Create the array of size 3..
Initialize the bases cases.
Run a loop from 3 to n Bottom up approach to fill the array.
driver program"
Solution in Python:
assistant
#Here is code to count number of ways to cover a distance and the other steps required.
 def prCountDP ( dist ) :
	ways = [ 0 ] * 3
	n = dist
	ways [ 0 ] = 1
	ways [ 1 ] = 1
	ways [ 2 ] = 2
	for i in range ( 3 , n + 1 ) :
		ways [ i % 3 ] = ways [ ( i - 1 ) % 3 ] + ways [ ( i - 2 ) % 3 ] + ways [ ( i - 3 ) % 3 ]
	return ways [ n % 3 ]
dist = 4
print ( prCountDP ( dist ) )