Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Mono Captcha by LexCavalera
FONT = ("01100010011101110101011100110111011100110"
"01010110000100010101010001000001010101010"
"01010010001100100111011001110010011101110"
"01010010010000010001000101010100010100010"
"00110010011101110001011000110100011101100")
def checkio(image):
digits_number = (len(image[0]) - 1) / 4
font_len = len(FONT) / 5
result = ''
for index in range(digits_number):
for digit in range(10):
diffs = 0
for row in range(5):
for column in range(1, 4):
if str(image[row][column + index * 4]) != \
FONT[row * font_len + digit * 4 + column]:
diffs += 1
if diffs < 2:
result += str(digit)
continue
return int(result)
if __name__ == '__main__':
assert checkio([[0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0],
[0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],
[0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0],
[0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0],
[0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0]]) == 394, "394 clear"
assert checkio([[0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0],
[0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],
[0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0],
[0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0],
[0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0]]) == 394, "again 394 but with noise"
March 4, 2014