commit a8b7ca46b35cc82afa2b64fc2300047e5879836f parent d7d90bcadd056d7f56b7cc7ae4f863ad3d2331a3 Author: mpizzzle <michael.770211@gmail.com> Date: Sat, 7 Oct 2017 13:13:40 +0100 hamming distance function done Diffstat:
| M | set1/break_repeating_key_xor.py | | | 7 | +++++++ |
1 file changed, 7 insertions(+), 0 deletions(-)
diff --git a/set1/break_repeating_key_xor.py b/set1/break_repeating_key_xor.py @@ -0,0 +1,6 @@ +import sys + +def hamming_distance(str1, str2): + return ''.join([bin(ord(a) ^ ord(b)) for a, b in zip(str1, str2)]).count('1') + +print hamming_distance("this is a test", "wokka wokka!!!")+ \ No newline at end of file