摩天大楼拼图算法摩天大楼、拼图、算法

由网友(一身坏脾气)分享简介:我在写一个算法来解决摩天大楼谜题的:I'm writing an algorithm to solve skyscrapers puzzles:摩天大楼拼图数独相结合的行和列的约束与重新想象号的每一行或列作为一个完整的不同高度的摩天大楼路外部线索值。数值越大,再present更高层的楼宇。Skyscraper pu...

我在写一个算法来解决摩天大楼谜题的:

I'm writing an algorithm to solve skyscrapers puzzles:

摩天大楼拼图数独相结合的行和列的约束与重新想象号的每一行或列作为一个完整的不同高度的摩天大楼路外部线索值。数值越大,再present更高层的楼宇。

Skyscraper puzzles combine the row and column constraints of Sudoku with external clue values that re-imagine each row or column of numbers as a road full of skyscrapers of varying height. Higher numbers represent higher buildings.

要解决一个谜题的摩天大楼,你必须将1至5或1到任何拼图的大小,每一次到每行和列,同时还解决每个给定的摩天大楼线索。

To solve a Skyscraper puzzle you must place 1 to 5, or 1 to whatever the size of the puzzle is, once each into every row and column, while also solving each of the given skyscraper clues.

要理解摩天大楼的困惑,你必须想象你放入网格重$ P $每个值psents的楼层数的摩天大楼。所以1是1楼的摩天大楼,而4是一个4层楼的摩天楼。现在想象一下你去站在电网所在的线索号码之一就是外面看回电网。这一线索数字告诉你,你可以有多少摩天大楼从这一点看,只有看沿行或​​列中的线索,并从来看线索的地步。更高的建筑总是默默无闻较低的建筑物,所以换句话说,更高的数字总是难掩较低的数字。

To understand Skyscraper puzzles, you must imagine that each value you place into the grid represents a skyscraper of that number of floors. So a 1 is a 1-floor skyscraper, while a 4 is a 4-floor skyscraper. Now imagine that you go and stand outside the grid where one of the clue numbers is and look back into the grid. That clue number tells you how many skyscrapers you can see from that point, looking only along the row or column where the clue is, and from the point of view of the clue. Taller buildings always obscure lower buildings, so in other words higher numbers always conceal lower numbers.

所有的基本技术实现和工作,但我已经意识到,有更大的困惑(5×5>)我需要某种形式的递归算法的。我找到了一个体面的工作 python脚本的,但我没有真正下它实际上没有超出解决基本线索。

All the basic techniques are implemented and working, but I've realized that with bigger puzzles (5x5>) I need some sort of recursive algorithm. I found a decent working python script, but I'm not really following what it actually does beyond solving basic clues.

有谁知道解决这些难题的正确方法或任何人都可以显示在code中的必需品上面?

Does anyone know the proper way of solving these puzzles or can anyone reveal the essentials in the code above?

推荐答案

米沙显示你的蛮力方式。一种快得多的递归算法可以根据约束传播进行。彼得·诺维格(头谷歌研究)写href="http://norvig.com/sudoku.html" rel="nofollow">有关如何使用这种技术来解决数独与Python优秀的文章的

阅读全文

相关推荐

最新文章