Skip to content

Instantly share code, notes, and snippets.

@taboularasa
Created April 8, 2011 03:03
Show Gist options
  • Save taboularasa/909209 to your computer and use it in GitHub Desktop.
Save taboularasa/909209 to your computer and use it in GitHub Desktop.
compare sample to patterns and find closest match
def compare():
results = []
results['attack'] = distance(test, attack)
results['scan'] = distance(test, scan)
results['build'] = distance(test,build)
return min(results, key = lambda x: results.get(x))
def distance(a,b):
total = 0
for i in range(len(a)):
for j in range(len(a)):
for k in range(len(a)):
total += abs( a[i,j,k] - b[i,j,k] )
return total
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment