Created
April 8, 2011 03:03
-
-
Save taboularasa/909209 to your computer and use it in GitHub Desktop.
compare sample to patterns and find closest match
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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