Simple nonogram solver in Python