How to optimally solve the flood fill puzzle?

后端 未结 10 1026
Happy的楠姐
Happy的楠姐 2020-12-12 15:35

I like playing the puzzle game Flood-It, which can be played online at:

https://www.lemoda.net/javascript/flood-it/game.html

It\'s also available as an iGoog

10条回答
  •  遥遥无期
    2020-12-12 16:24

    Smashery's answer can be slightly tweaked. For the total number of moves estimate, if there are 'k' colors at maximum distance, add 'k-1' to the number of moves estimate.

    More generally, for each color, consider the maximum distance at which the color can be cleared. This gives us a dictionary mapping some maximum distances to a non-zero number of colors that can be cleared at that distance. Sum value-1 across the keys and add this to the maximum distance to get a number of moves estimate.

    Also, there are certain free cases. If at any point we can clear a color in one move, we can take that move without considering the other moves.

提交回复
热议问题