Check if it is possible to move from ( 0 , 0 ) to ( X , Y ) in exactly K steps | Function that returns true if it is possible to move from ( 0 , 0 ) to ( x , y ) in exactly k moves ; Minimum moves required ; If possible ; Driver code
function isPossible ( x , y , k ) { var minMoves = Math . abs ( x ) + Math . abs ( y ) ; if ( k >= minMoves && ( k - minMoves ) % 2 == 0 ) return true ; return false ; } var x = 5 , y = 8 , k = 20 ; if ( isPossible ( x , y , k ) ) document . write ( " " ) ; else document . write ( " " ) ;