diff options
author | Camil Staps | 2016-02-12 15:01:00 +0100 |
---|---|---|
committer | Camil Staps | 2016-02-12 15:01:00 +0100 |
commit | efd533331d6a7f0c51ef857af448a6c84c3084ed (patch) | |
tree | 7f28f4e20a215784f27643ad49029332204528b2 /Assignment 5/2a.py | |
parent | Makefile (diff) |
Removed spaces in path
Diffstat (limited to 'Assignment 5/2a.py')
-rw-r--r-- | Assignment 5/2a.py | 14 |
1 files changed, 0 insertions, 14 deletions
diff --git a/Assignment 5/2a.py b/Assignment 5/2a.py deleted file mode 100644 index 0b55cee..0000000 --- a/Assignment 5/2a.py +++ /dev/null @@ -1,14 +0,0 @@ -import random, hashlib, collections - -def duplicates(table): - return [key for key, values in table.items() if len(values) > 1] - -def hash(msg): # we use only the first 3 bytes, as a toy example - return hashlib.md5(str(msg).encode('utf-8')).digest()[:3] - -lookup = collections.defaultdict(list) # lookup table -while duplicates(lookup) == []: # as long as there are no duplicates - input = random.getrandbits(64) # 64 bits is sufficient to assume no input occurs twice - lookup[hash(input)].append(input) - -print(len(lookup))
\ No newline at end of file |