Python Challenge #2 =================== URL: http://www.pythonchallenge.com/pc/def/ocr.html Image of open book with blur texts. Caption: recognize the characters. maybe they are in the book, but MAYBE they are in the page source. Page Source: Message to "Find rare characters in the mess below" and then a jumble of characters. Solution: To extra data: import urllib lines = urllib.open(r'http://www.pythonchallenge.com/pc/def/ocr.html').readlines() input = ''.join(lines[37:-2]) Counting the number of occurrences of each character in string input, shows that a few alphabets occur 1 time only. But which order are they in? dct = {} order = [] for a in input: if not a in dct: dct[a] = 0 order.append(a) dct[a] += 1 The order in the dict (or a set if used) would be inpredictable. To get the right order, by order of occurrence, compare by position in the list order: ''.join(sorted([c for c in dct if dct[c] == 1], cmp=lambda x,y: order.index(x) - order.index(y))) gives ==> equality URL: http://www.pythonchallenge.com/pc/def/equality.html