fork download
  1. def imp(a, b):
  2. return not a or b
  3.  
  4. rows = [(0,'?',0,0,0,1), (0,0,0,'?',0,'?'), (0,1,1,'?','?',0)]
  5.  
  6. for a in 'xyzw':
  7. for b in 'xyzw':
  8. for c in 'xyzw':
  9. for d in 'xyzw':
  10. if len({a, b, c, d}) < 4:
  11. continue
  12. ok = True
  13. for row in rows:
  14. found = False
  15. for n in range(16):
  16. v = {'x': n >> 3 & 1, 'y': n >> 2 & 1, 'z': n >> 1 & 1, 'w': n & 1}
  17. x, y, z, w = v['x'], v['y'], v['z'], v['w']
  18. t = [v[a], v[b], v[c], v[d],
  19. int(imp(w, y) == imp(z, x)),
  20. int(imp(w, y) and (not x) == z)]
  21. match = True
  22. for i in range(6):
  23. if row[i] != '?' and row[i] != t[i]:
  24. match = False
  25. if match:
  26. found = True
  27. if not found:
  28. ok = False
  29. if ok:
  30. print(a + b + c + d)
Success #stdin #stdout 0.02s 9408KB
stdin
Standard input is empty
stdout
yzxw