Function to return the number of ways to reach ( X , Y ) in a matrix with the given moves starting from the origin
def ways ( x , y ) : NEW_LINE INDENT factorialfun ( ) ; NEW_LINE modinversefun ( ) ; NEW_LINE if ( ( 2 * x - y ) % 3 == 0 and ( 2 * y - x ) % 3 == 0 ) : NEW_LINE INDENT m = ( 2 * x - y ) // 3 ; NEW_LINE n = ( 2 * y - x ) // 3 ; NEW_LINE return binomial ( n + m , n ) ; NEW_LINE DEDENT DEDENT