当前位置: 首页>>代码示例>>Python>>正文


Python Solver.showSolutions方法代码示例

本文整理汇总了Python中solver.Solver.showSolutions方法的典型用法代码示例。如果您正苦于以下问题:Python Solver.showSolutions方法的具体用法?Python Solver.showSolutions怎么用?Python Solver.showSolutions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在solver.Solver的用法示例。


在下文中一共展示了Solver.showSolutions方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: answer

# 需要导入模块: from solver import Solver [as 别名]
# 或者: from solver.Solver import showSolutions [as 别名]
	#Sort the array by number of bricks and get the biggest one, make that the puzzle board.
	pieceCollection.sort(key=lambda x: x.size)
	puzzle = pieceCollection[-1]
	pieceCollection.pop()

	#Give each piece a unique number so that the solver won't pick the same piece placed in a different location
	# as part of the answer (assumption is that a piece can only be placed once.)
	# solver does this by creating a column for each pieces identity.
	for i in range (0, len(pieceCollection)):
		pieceCollection[i].setIdentity(i)

	showPieces()
	showPuzzle()
	#Instantiate a solver
	solver = Solver(pieceCollection, puzzle)
	#Build a list of every valid placement of a piece on an empty puzzle board.
	solver.getAllPositions(pieceCollection, puzzle)

	print "\nSearching for solutions... \n"
	solver.buildColumnDictionary()
	dictionaries = solver.buildRowDictionary()
	solutions = solver.solve(dictionaries[0], dictionaries[1])
	solver.showSolutions(list(solutions))






开发者ID:nathanalooney,项目名称:AlgorithmX,代码行数:25,代码来源:index.py


注:本文中的solver.Solver.showSolutions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。