code: def mkconstraints():
      
      constraints = []
  
      for j in range(1, 10):
          vars = ["%s%d" % (i, j) for i in uppercase[:9]]
          constraints.extend((c, const_different) for c in combinations(vars, 2))
  
      for i in uppercase[:9]:
          vars = ["%s%d" % (i, j) for j in range(1, 10)]
          constraints.extend((c, const_different) for c in combinations(vars, 2))
  
      for b0 in ['ABC', 'DEF', 'GHI']:
          for b1 in [[1, 2, 3], [4, 5, 6], [7, 8, 9]]:
              vars = ["%s%d" % (i, j) for i in b0 for j in b1]
              l = list((c, const_different) for c in combinations(vars, 2))
              constraints.extend(l)
  
      return constraints
docs: Make constraint list for binary constraint problem.