Driver code
var R = 40 , B = 10 , W = 4 ; var dp = Array ( RUNMAX ) . fill ( ) . map ( ( ) => Array ( BALLMAX ) . fill ( ) . map ( ( ) => Array ( WICKETMAX ) . fill ( 0 ) ) ) ; for ( i = 0 ; i < RUNMAX ; i ++ ) for ( j = 0 ; j < BALLMAX ; j ++ ) for ( k = 0 ; k < WICKETMAX ; k ++ ) dp [ i ] [ j ] [ k ] = - 1 ; document . write ( CountWays ( 0 , 0 , 0 , R , B , W , dp ) ) ;