Asmuth-bloom algorithm in Python