#!/usr/bin/python def is_equal(s1, s2): ''' Returns true if the strings s1 and s2 encode the same information. ''' if len(s1) != len(s2): return False result = 0 for (x,y) in zip(s1,s2): result |= ord(x) ^ ord(y) return result == 0 target, strs = "abc", [ "ab", "abc", "abcd", "bbc", "abe" ] for s in strs: print("{} == {} ? {}".format(target,s,is_equal(target,s)))