Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
  <head>
<script src="http://code.jquery.com/jquery-2.0.3.min.js"></script>
    <meta charset="utf-8">
    <title>JS Bin</title>
  </head>
  <body>
    <div id="output"></div>
  </body>
</html>
 
var matrix1 = [[0,1,1,1,0,0,0],  
               [0,0,1,0,0,1,0],
               [0,0,0,0,1,1,0],
               [0,0,0,0,1,0,1],
               [0,0,0,0,0,1,1],
               [0,0,0,0,0,0,1],
               [0,0,0,0,0,0,0]];
var matrix2 = [[0,1,1,0,0,0,0],
               [1,0,0,1,1,0,0],
               [1,0,0,0,1,1,1],
               [0,1,0,0,1,0,0],
               [0,1,1,1,0,0,0],
               [0,0,1,0,0,0,0],
               [0,0,1,0,0,0,0]];
var matrix3 = [[0,1,1,0,0],
               [0,0,1,0,0],
               [0,0,0,0,0],
               [0,0,1,0,1],
               [0,0,0,0,0]];
var matrix4 = [[0,1,0,1],
               [1,0,1,1],
               [0,1,0,1],
               [1,1,1,0]];
function tops(matrix,visited){
    if ( visited.indexOf(0) === -1 ){
      return ;
    }
  else{
    for ( var i = 0 ; i < matrix.length ; i++ ){
      
          // remove the row
          visited[i] = 1 ; 
          // recursive call
          tops(matrix,visited);
          // print i
          console.log(visited);
        }
      }
    }
  }
}
function zeros(array,exclude){
  for ( var k = 0 ; k < array.length ; k++ ){
    if ( array[k] !== 0 && exclude.indexOf(array[k])===-1 ) return false;
  }
  return true ; 
}
var visited = [] ; 
for ( var i = 0 ; i < matrix3.length ; i++ ) visited[i] = 0 ;
tops(matrix3,visited);
Output 300px

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
kizzlebotpro
0viewers