本文整理汇总了Python中sudoku.Sudoku.i2rc方法的典型用法代码示例。如果您正苦于以下问题:Python Sudoku.i2rc方法的具体用法?Python Sudoku.i2rc怎么用?Python Sudoku.i2rc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sudoku.Sudoku
的用法示例。
在下文中一共展示了Sudoku.i2rc方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _colouring
# 需要导入模块: from sudoku import Sudoku [as 别名]
# 或者: from sudoku.Sudoku import i2rc [as 别名]
def _colouring(s, poss, doubles, verbose=0):
changes = 0
group_a = []
group_b = []
for [d1, d2] in doubles:
if d1 in group_a:
group_b.append(d1)
group_a.append(d2)
elif d1 in group_b:
group_a.append(d1)
group_b.append(d2)
# for loc in set(group_a) & set(group_b):
# if poss in s.fields[loc]:
# changes += 1
# s.fields[loc].remove(poss)
# if changes:
# return changes
for group in (group_a, group_b):
rows = []
cols = []
for loc in group:
r, c = Sudoku.i2rc(loc)
if r in rows or c in cols:
changes += _eliminate_group(s, poss, group, verbose)
break
rows.append(r)
cols.append(c)
return changes