In the previous post, Decanting Problems and Dijkstra’s Algorithm, we presented some scipy hackery to solve the Die Hard puzzle:

Two men have a full eight-gallon jug of wine, and also two empty jugs of five and three gallons capacity, respectively. Is it possible (within the restrictions of our problem) to divide the wine equally so each men can have four gallons of wine?

In this post we replicate the same technique, but this time using Julia’s Graphs package. First of all, make sure you have the package installed. If this is not the case, issue in an Ijulia session the command Pkg.add("Graphs"). Once installed, the functions of the package can be readily called.

We are ready to fire Dijkstra’s algorithm on this graph now.

As in the previous solution, we found that the simplest way to divide the wine equally is in 7 steps as follows:

1. Pour 5 gallons of wine into the second jug. $$(3,5,0)$$
2. Pour 3 gallons from the second jug to the third. $$(3,2,3)$$
3. Pour 3 gallons from the third to the first. $$(6,2,0)$$
4. Pour all 2 gallons from the second to the third jug. $$(6,0,2)$$
5. Pour five gallons from the first to the second jug. $$(1,5,2)$$
6. Pour one gallon from the second to the third jug. $$(1,4,3)$$
7. We are technically done, but we may pour now all three gallons from the third jug to the first, for a convenient transportation of the wine. $$(4,4,0)$$
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 1, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.6296473741531372, "perplexity": 1158.6440599837424}, "config": {"markdown_headings": true, "markdown_code": false, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2018-51/segments/1544376825112.63/warc/CC-MAIN-20181213215347-20181214000847-00344.warc.gz"}