human
Find the probability of reaching all points after N moves from point N | Function to calculate the probabilities.
Array where row represent the pass and the column represents the points on the line.
Initially the person can reach left or right with one move.
Calculate probabilities for N - 1 moves.
When the person moves from ith index in right direction when i moves has been done.
When the person moves from ith index in left direction when i moves has been done.
Print the arr.
Driver code"
Solution in Python:
 ... Write me a code to find the probability of reaching all points after N moves from point N and the other steps required?
assistant
#Here is code to find the probability of reaching all points after N moves from point N and the other steps required.
 def printProbabilities ( n , left ) :
	right = 1 - left ;
	arr = [ [ 0 for j in range ( 2 * n + 1 ) ] for i in range ( n + 1 ) ]
	arr [ 1 ] [ n + 1 ] = right ;
	arr [ 1 ] [ n - 1 ] = left ;
	for i in range ( 2 , n + 1 ) :
		for j in range ( 1 , 2 * n + 1 ) :
			arr [ i ] [ j ] += ( arr [ i - 1 ] [ j - 1 ] * right ) ;
		for j in range ( 2 * n - 1 , - 1 , - 1 ) :
			arr [ i ] [ j ] += ( arr [ i - 1 ] [ j + 1 ] * left ) ;
	for i in range ( 2 * n + 1 ) :
		print ( " { :5.4f } ▁ " . format ( arr [ n ] [ i ] ) , end = ' ▁ ' ) ;
if __name__ == " _ _ main _ _ " :
	n = 2 ;
	left = 0.5 ;
	printProbabilities ( n , left ) ;