Find the winner in nim | function to find winner of NIM - game ; case when Alice is winner ; when Bob is winner ; Driver Code
function findWinner ( A , n ) { let res = 0 ; for ( let i = 0 ; i < n ; i ++ ) res ^= A [ i ] ; if ( res == 0 n % 2 == 0 ) return " " ; else return " " ; } let A = [ 1 , 4 , 3 , 5 ] ; let n = A . length ; document . write ( " " + findWinner ( A , n ) ) ;