fork download
  1. from itertools import *
  2.  
  3. f = lambda x, y, z, w: ((not w or y) == (not z or x), (not w or y) and (not x) == z)
  4. rows = [(0,'?',0,0,0,1), (0,0,0,'?',0,'?'), (0,1,1,'?','?',0)]
  5.  
  6. for p in permutations('xyzw'):
  7. if all(any(all(a in ('?', b) for a, b in zip(r, v + f(**dict(zip(p, v)))))
  8. for v in product((0, 1), repeat=4)) for r in rows):
  9. print(*p, sep='')
Success #stdin #stdout 0.07s 14212KB
stdin
Standard input is empty
stdout
yzxw