A*算法的简单运用

来源:互联网 发布:如何删除mac版office 编辑:程序博客网 时间:2024/05/29 05:04
1、 Problem Description
This is a problem that is prominently featured in the lm Die Hard With a Vengeance. You have a
3-gallon and a 5-gallon jug that you can ll from a fountain of water. The problem is to ll one of
the jugs with exactly 4 gallons of water. How do you do it?
This is the solution (not the only solution):
1. Fill up the 3-gallon jug
2. Transfer to the 5-gallon jug
3. Fill up the 3-gallon jug again
4. Transfer water to ll up the 5-gallon jug, leaving 1 gallon in the 3-gallon jug
5. Empty out the 5-gallon jug
6. Transfer the 1 gallon to the 5-gallon jug
7. Fill up the 3-gallon jug and transfer that to the 5-gallon jug
8. The 5-gallon jug contains 4 gallons of water
The sequence here is:
(0; 3)