Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
brute force solution in Clear category for Nonogram Row by flpo
from itertools import groupby
def combine(candidates):
return ''.join(x.pop() if len(x) == 1 else '?' for x in map(set, zip(*candidates)))
def nonogram_row(row, clues):
clues = list(filter(None, clues))
def match(r):
return clues == [len(list(y)) for x, y in groupby(r) if x == 'O']
def infer(r):
if '?' not in r:
return {r} if match(r) else set()
i = r.index('?')
return infer(r[:i] + 'X' + r[i + 1:]) | infer(r[:i] + 'O' + r[i + 1:])
return combine(infer(row)) or None
Feb. 18, 2018
Comments: