Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for Network Attack by TovarischZhukov
# migrated from python 2.7
def capture(matrix):
count = 0
k = {0:0}
while len(k)0):
keys = list(k.keys())
checked=[]
for i in keys:
if k[i]==0 and i not in checked:
for j in range(0, len(matrix)):
if matrix[i][j]==1 and j!= i:
if matrix[j][j] and (j not in checked):
matrix[j][j]-=1
k[j]=matrix[j][j]
checked.append(j)
count+=1
return count
Dec. 25, 2015