Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Bisect solution in Clear category for Network Attack by Talim42
from bisect import insort_left
def capture(matrix):
""" Use insort from bisect module enables naive solution. It's fast too. """
infected, history = [(0, 0)], {0}
for time, carrier in infected:
for i, v in enumerate(matrix[carrier]):
if i not in history and v:
insort_left(infected, (time + matrix[i][i], i))
history.add(i)
return infected[-1][0]
June 27, 2014
Comments: