Business Management Dynamics Vol.6, No.5, Nov. 2016, pp.21-29

A Mathematical Model of Sam Loyd’s Mars Canals Mike C. Patterson1 and Daniel D. Friesen2

Abstract Key words: , recreational In this paper we solve a classic from recreational mathematics: Sam programming, Sam Loyd, Loyd’s Canals of Mars. The solution method makes use of Excel’s ability to optimization, Excel optimize mathematical models, in this case, a modification of the well-known travelling salesman problem. The solution time using the genetic algorithm Available online available in Excel is very short, approximately three seconds. www.bmdynamics.com ISSN: 2047-7031

INTRODUCTION Recreational mathematics is the term frequently used to describe mathematical games, and . The best known publication devoted to recreational mathematics is the American Mathematical Monthly (Mathematical Association of America, n.d.). Some of the better known writers in the field include H. E. Dudeney, Sam Loyd, Raymond Smullyan, and Charles Lutwidge Dodgson, better known as Lewis Carrol, author of Alice’s Adventures in Wonderland. The purpose of this paper is to illustrate how to use Excel to build and optimize a classic recreational mathematical model, the for a maze.

LITERATURE REVIEW While the venerable Journal of Recreational Mathematics focused on the subject of puzzles and games, many journals give some passing attention to the subject, often through dedicated columns. For example, Communications of the ACM regularly publishes a column named “last byte” (Winkler, 2012). Alexander Dewdney wrote a “famous section” in Scientific American during the 1980s, as did Gardner for over twenty-four years prior. Dewdney’s column was named “Computer Recreations” while Gardener’s column was named “Mathematical Games” (Jimenez & Munoz, 2011). The column “Classroom Capsules” appears in The College Mathematics Journal and a brief survey shows that problems and puzzles often appear in the column for the purpose of providing “effective teaching strategies for college mathematics instruction (Alfaro, 2008).” In his remembrance of Martin Gardner, Rowe (2011) notes the membership of Gardner, Dodgson, and Hermann Schubert in the family of recreational mathematicians. Rowe also notes some famous scientists who appreciated the occasional “dabble” into intellectual puzzles, including Albert Einstein. Recreational mathematics communicates the “unlikely idea that doing mathematics can be fun.” Further, the case of Einstein allows us to consider the relationship between the stuff of recreational mathematics and the stuff of genius. Silva (2011) indicates that the “oldest book on recreational mathematics” is De viribus quantitatis, created circa 1500 by Luca Pacioli. Clearly, neither Einstein nor Pacioli invented puzzles and games. The game of “Go” is said by some to be four thousand years old. These entertainments have been enjoyed for several millennia! In defining “recreational programming,” Jimenez and Munoz (2011) refer to the practice as one of studying computer programming by solving problems of a playful nature. They describe the discipline as “similar to recreational mathematics.” Further, the disciplines are sometimes confused, possibly owing to their mutually enriching interaction. By their definition, the subject of this paper is recreational

1 Dillard College of Business, Midwestern State University, 3410 Taft, Wichita Falls, TX, 76308 Telephone 940-397-4710 E-mail: [email protected] Fax 940 397-4280 2 University of North Texas at Dallas, 7300 University Hills, Dallas, TX, 75241

©Society for Business and Management Dynamics

Business Management Dynamics Vol.6, No.5, Nov. 2016, pp.21-29 programming. Kino and Uno (2012) briefly discuss the incorporation of computers into the study of games and puzzles, and the reasons therefore. They modelled the game Tantrix using an interger programming formulation and solved it with an IBM software product. In the next section, we introduce Sam Loyd’s Canals of Mars puzzle. A discussion of modelling the puzzle using Excel follows. Salient figures showing Excel configuration and solutions are provided. A summary concludes the paper.

SAM LOYD’S CANALS OF MARS American Sam Loyd (1841-1911) was a player, puzzle author and recreational mathematician. Perhaps his best known work, Cyclopedia of Puzzles (Loyd, 1914), was published after his death. He is one of the best known writers in the field of recreational mathematics. The maze puzzle selected to illustrate how to model such a problem appears in the Cyclopedia of Puzzles and is re-printed below (Loyd, 1914). The puzzle also appears in Mathematical Puzzles of Sam Loyd, edited by Martin Gardner (1959). From Sam Loyd (1914): “Here is a map of the newly discovered cities and waterways on our nearest neighbor planet, Mars. Start at the city marked T, at the South Pole, and see if you can spell a complete English sentence by making a tour of all the cities, visiting each city only once, and returning to the starting point.”

Figure 1 Sam Loyd’s Canals of Mars

©Society for Business and Management Dynamics

Business Management Dynamics Vol.6, No.5, Nov. 2016, pp.21-29

MODEL OF CANALS OF MARS The basic problem is to determine if there exists at least one path which starts with T, located at the South Pole, ends with the same T and visits each location only once. The problem is essentially a modified traveling salesman problem, which is one of the better known operations research models (Barlow, 2005; Taha, 1987). Stage 1 of the model-building procedure is to determine which locations are connected by the canals. Since we are not trying to minimize the total distance of the tour, the distance between connected locations can be assumed to be the same value, in our example 1. For locations which are not connected we used a relatively large number, 9999. This “distance table” is displayed in cells D4:W24 of the spreadsheet shown in Table 1. Row 4 and column C display the respective locations. Column X displays the sequential numbers 1-20. Column Y, likewise initially holds the same values. These cells, upon optimization, will hold the numeric sequence for the tour. Column Z will display the optimal sequence by location letter for the round trip tour through the Mars Canals. Solver is the Excel add-in software tool utilized to solve the model. As cited on the web-page of Frontline Systems (Solver.com, n.d.), the developer of Solver software, the alldifferent constraint and the genetic and evolutionary solution algorithms provided with Solver are required for solving tour problems such as the traveling salesman problem. Figure 2 displays the Platform parameters for the model. Cells D5:W24 are named mileage. Cells B5:C24 are named cityname. Table 2 displays the formula view of the spreadsheet model. Table 3 displays the final optimal solution provided by Solver. Excel provided a solution in approximately 3 seconds; however, larger travelling salesman problems require significantly more solution time. The ultimate goal of the puzzle is to spell a complete sentence; such a goal can only be assessed by careful examination of the result. Starting with cell Z25 (Location T) and reading from bottom to top, the suggested tour is T, H, E, R, E, I, S, N, O, P, O, S, S, I, B, L, E, W, A, Y , with the return back to the starting location at the South Pole T. This is indicated in cells Z5:Z25 in Table 3. Loyd was a cunning puzzle writer. This is apparent, not only in the sense of humor demonstrated, but also by the fact that there is only a single independent solution to the puzzle. The Excel model will spell the sentence in reverse order, depending on starting state. Figure 3 displays a graphical solution to Loyd’s Mars Canals tour.

©Society for Business and Management Dynamics

Business Management Dynamics Vol.6, No.5, Nov. 2016, pp.21-29 Table 1 Initial Spreadsheet of Loyd’s Canals of Mars Maze 1\A B C D E F G H I J K L M N O P Q R S T U V W X Y Z AA 2 3 # 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 4 T H A Y O N R W E I I E L P E S S B O S 5 0 T 9999 1 9999 1 9999 9999 9999 9999 9999 9999 9999 9999 9999 9999 9999 9999 9999 9999 9999 9999 1 0 T 6 1 H 1 9999 9999 9999 1 1 9999 9999 9999 9999 1 1 9999 9999 9999 9999 9999 9999 9999 9999 2 1 H 1 7 2 A 9999 9999 9999 1 9999 9999 9999 1 9999 9999 9999 9999 9999 9999 9999 9999 9999 9999 9999 9999 3 2 A 9999 8 3 Y 1 9999 1 9999 9999 9999 9999 1 9999 1 9999 9999 9999 9999 9999 9999 9999 1 9999 9999 4 3 Y 1 9 4 O 9999 1 9999 9999 9999 1 9999 9999 9999 9999 9999 9999 9999 1 9999 9999 9999 9999 9999 9999 5 4 O 9999 10 5 N 9999 1 9999 9999 1 9999 9999 9999 9999 999 9999 9999 9999 1 9999 9999 1 9999 1 1 6 5 N 1 11 6 R 9999 9999 9999 9999 9999 9999 9999 9999 9999 9999 1 1 9999 9999 1 9999 9999 9999 9999 9999 7 6 R 9999 12 7 W 9999 9999 1 1 9999 9999 9999 9999 1 9999 9999 9999 1 9999 1 9999 9999 9999 9999 9999 8 7 W 9999 13 8 E 9999 9999 9999 9999 9999 9999 9999 1 999 9999 1 9999 1 9999 9999 9999 9999 9999 9999 9999 9 8 E 1 14 9 I 9999 9999 9999 1 9999 999 9999 9999 9999 9999 9999 9999 9999 9999 9999 1 9999 1 9999 9999 10 9 I 9999 15 10 I 9999 1 9999 9999 9999 9999 1 9999 1 9999 9999 1 9999 9999 1 9999 1 9999 9999 9999 11 10 I 9999 16 11 E 9999 1 9999 9999 9999 9999 1 9999 9999 9999 1 9999 9999 9999 9999 9999 9999 9999 9999 9999 12 11 E 1 17 12 L 9999 9999 9999 9999 9999 9999 9999 1 1 9999 9999 9999 9999 9999 9999 9999 9999 1 9999 9999 13 12 L 9999 18 13 P 9999 9999 9999 9999 1 1 9999 9999 9999 9999 9999 9999 9999 9999 9999 9999 9999 9999 1 9999 14 13 P 9999 19 14 E 9999 9999 9999 9999 9999 9999 1 1 9999 9999 1 9999 9999 9999 9999 9999 9999 9999 9999 9999 15 14 E 9999 20 15 S 9999 9999 9999 9999 9999 9999 9999 9999 9999 1 9999 9999 9999 9999 9999 9999 9999 1 9999 1 16 15 S 9999 21 16 S 9999 9999 9999 9999 9999 1 9999 9999 9999 9999 1 9999 9999 9999 9999 9999 9999 1 9999 9999 17 16 S 9999 22 17 B 9999 9999 9999 1 9999 9999 9999 9999 9999 1 9999 9999 1 9999 9999 1 1 9999 9999 1 18 17 B 1 23 18 O 9999 9999 9999 9999 9999 1 9999 9999 9999 9999 9999 9999 9999 1 9999 9999 9999 9999 9999 1 19 18 O 9999 24 19 S 9999 9999 9999 9999 9999 1 9999 9999 9999 9999 9999 9999 9999 9999 9999 1 9999 1 1 9999 20 19 S 1 25 0 T 9999 26 Sum 129994

©Society for Business and Management Dynamics

Business Management Dynamics Vol.6, No.5, Nov. 2016, pp.21-29

Figure 2 Solver Parameters for Loyd’s Canals of Mars Puzzle

©Society for Business and Management Dynamics

Business Management Dynamics Vol.6, No.5, Nov. 2016, pp.21-29 Table 2 Formula View of Loyd’s Canals of Mars Maze

2 3 # 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 4 T H A Y O N R W E I I E L P E S S B O S 5 0 T 9999 1 9999 1 9999 9999 9999 9999 9999 9999 9999 9999 9999 9999 9999 9999 9999 9999 9999 9999 1 0 =VLOOKUP(Y5,cityname,2) 6 1 H 1 9999 9999 9999 1 1 9999 9999 9999 9999 1 1 9999 9999 9999 9999 9999 9999 9999 9999 2 1 =VLOOKUP(Y6,cityname,2) =INDEX(mileage,Y5+1,Y6+1) 7 2 A 9999 9999 9999 1 9999 9999 9999 1 9999 9999 9999 9999 9999 9999 9999 9999 9999 9999 9999 9999 3 2 =VLOOKUP(Y7,cityname,2) =INDEX(mileage,Y6+1,Y7+1) 8 3 Y 1 9999 1 9999 9999 9999 9999 1 9999 1 9999 9999 9999 9999 9999 9999 9999 1 9999 9999 4 3 =VLOOKUP(Y8,cityname,2) =INDEX(mileage,Y7+1,Y8+1) 9 4 O 9999 1 9999 9999 9999 1 9999 9999 9999 9999 9999 9999 9999 1 9999 9999 9999 9999 9999 9999 5 4 =VLOOKUP(Y9,cityname,2) =INDEX(mileage,Y8+1,Y9+1) 10 5 N 9999 1 9999 9999 1 9999 9999 9999 9999 999 9999 9999 9999 1 9999 9999 1 9999 1 1 6 5 =VLOOKUP(Y10,cityname,2) =INDEX(mileage,Y9+1,Y10+1) 11 6 R 9999 9999 9999 9999 9999 9999 9999 9999 9999 9999 1 1 9999 9999 1 9999 9999 9999 9999 9999 7 6 =VLOOKUP(Y11,cityname,2) =INDEX(mileage,Y10+1,Y11+1) 12 7 W 9999 9999 1 1 9999 9999 9999 9999 1 9999 9999 9999 1 9999 1 9999 9999 9999 9999 9999 8 7 =VLOOKUP(Y12,cityname,2) =INDEX(mileage,Y11+1,Y12+1) 13 8 E 9999 9999 9999 9999 9999 9999 9999 1 999 9999 1 9999 1 9999 9999 9999 9999 9999 9999 9999 9 8 =VLOOKUP(Y13,cityname,2) =INDEX(mileage,Y12+1,Y13+1) 14 9 I 9999 9999 9999 1 9999 999 9999 9999 9999 9999 9999 9999 9999 9999 9999 1 9999 1 9999 9999 10 9 =VLOOKUP(Y14,cityname,2) =INDEX(mileage,Y13+1,Y14+1) 15 10 I 9999 1 9999 9999 9999 9999 1 9999 1 9999 9999 1 9999 9999 1 9999 1 9999 9999 9999 11 10 =VLOOKUP(Y15,cityname,2) =INDEX(mileage,Y14+1,Y15+1) 16 11 E 9999 1 9999 9999 9999 9999 1 9999 9999 9999 1 9999 9999 9999 9999 9999 9999 9999 9999 9999 12 11 =VLOOKUP(Y16,cityname,2) =INDEX(mileage,Y15+1,Y16+1) 17 12 L 9999 9999 9999 9999 9999 9999 9999 1 1 9999 9999 9999 9999 9999 9999 9999 9999 1 9999 9999 13 12 =VLOOKUP(Y17,cityname,2) =INDEX(mileage,Y16+1,Y17+1) 18 13 P 9999 9999 9999 9999 1 1 9999 9999 9999 9999 9999 9999 9999 9999 9999 9999 9999 9999 1 9999 14 13 =VLOOKUP(Y18,cityname,2) =INDEX(mileage,Y17+1,Y18+1) 19 14 E 9999 9999 9999 9999 9999 9999 1 1 9999 9999 1 9999 9999 9999 9999 9999 9999 9999 9999 9999 15 14 =VLOOKUP(Y19,cityname,2) =INDEX(mileage,Y18+1,Y19+1) 20 15 S 9999 9999 9999 9999 9999 9999 9999 9999 9999 1 9999 9999 9999 9999 9999 9999 9999 1 9999 1 16 15 =VLOOKUP(Y20,cityname,2) =INDEX(mileage,Y19+1,Y20+1) 21 16 S 9999 9999 9999 9999 9999 1 9999 9999 9999 9999 1 9999 9999 9999 9999 9999 9999 1 9999 9999 17 16 =VLOOKUP(Y21,cityname,2) =INDEX(mileage,Y20+1,Y21+1) 22 17 B 9999 9999 9999 1 9999 9999 9999 9999 9999 1 9999 9999 1 9999 9999 1 1 9999 9999 1 18 17 =VLOOKUP(Y22,cityname,2) =INDEX(mileage,Y21+1,Y22+1) 23 18 O 9999 9999 9999 9999 9999 1 9999 9999 9999 9999 9999 9999 9999 1 9999 9999 9999 9999 9999 1 19 18 =VLOOKUP(Y23,cityname,2) =INDEX(mileage,Y22+1,Y23+1) 24 19 S 9999 9999 9999 9999 9999 1 9999 9999 9999 9999 9999 9999 9999 9999 9999 1 9999 1 1 9999 20 19 =VLOOKUP(Y24,cityname,2) =INDEX(mileage,Y23+1,Y24+1) 25 =Y5 =VLOOKUP(Y5,cityname,2) =INDEX(mileage,Y24+1,Y5+1) 26 Sum =SUM(AA6:AA25)

©Society for Business and Management Dynamics

Business Management Dynamics Vol.6, No.5, Nov. 2016, pp.21-29 Table 3 Optimal Solution to Loyd’s Canals of Mars Maze 1\A B C D E F G H I J K L M N O P Q R S T U V W X Y Z AA 2 3 # 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 4 T H A Y O N R W E I I E L P E S S B O S 5 0 T 9999 1 9999 1 9999 9999 9999 9999 9999 9999 9999 9999 9999 9999 9999 9999 9999 9999 9999 9999 1 0 T 6 1 H 1 9999 9999 9999 1 1 9999 9999 9999 9999 1 1 9999 9999 9999 9999 9999 9999 9999 9999 2 3 Y 1 7 2 A 9999 9999 9999 1 9999 9999 9999 1 9999 9999 9999 9999 9999 9999 9999 9999 9999 9999 9999 9999 3 2 A 1 8 3 Y 1 9999 1 9999 9999 9999 9999 1 9999 1 9999 9999 9999 9999 9999 9999 9999 1 9999 9999 4 7 W 1 9 4 O 9999 1 9999 9999 9999 1 9999 9999 9999 9999 9999 9999 9999 1 9999 9999 9999 9999 9999 9999 5 8 E 1 10 5 N 9999 1 9999 9999 1 9999 9999 9999 9999 999 9999 9999 9999 1 9999 9999 1 9999 1 1 6 12 L 1 11 6 R 9999 9999 9999 9999 9999 9999 9999 9999 9999 9999 1 1 9999 9999 1 9999 9999 9999 9999 9999 7 17 B 1 12 7 W 9999 9999 1 1 9999 9999 9999 9999 1 9999 9999 9999 1 9999 1 9999 9999 9999 9999 9999 8 9 I 1 13 8 E 9999 9999 9999 9999 9999 9999 9999 1 999 9999 1 9999 1 9999 9999 9999 9999 9999 9999 9999 9 15 S 1 14 9 I 9999 9999 9999 1 9999 999 9999 9999 9999 9999 9999 9999 9999 9999 9999 1 9999 1 9999 9999 10 19 S 1 15 10 I 9999 1 9999 9999 9999 9999 1 9999 1 9999 9999 1 9999 9999 1 9999 1 9999 9999 9999 11 18 O 1 16 11 E 9999 1 9999 9999 9999 9999 1 9999 9999 9999 1 9999 9999 9999 9999 9999 9999 9999 9999 9999 12 13 P 1 17 12 L 9999 9999 9999 9999 9999 9999 9999 1 1 9999 9999 9999 9999 9999 9999 9999 9999 1 9999 9999 13 4 O 1 18 13 P 9999 9999 9999 9999 1 1 9999 9999 9999 9999 9999 9999 9999 9999 9999 9999 9999 9999 1 9999 14 5 N 1 19 14 E 9999 9999 9999 9999 9999 9999 1 1 9999 9999 1 9999 9999 9999 9999 9999 9999 9999 9999 9999 15 16 S 1 20 15 S 9999 9999 9999 9999 9999 9999 9999 9999 9999 1 9999 9999 9999 9999 9999 9999 9999 1 9999 1 16 10 I 1 21 16 S 9999 9999 9999 9999 9999 1 9999 9999 9999 9999 1 9999 9999 9999 9999 9999 9999 1 9999 9999 17 14 E 1 22 17 B 9999 9999 9999 1 9999 9999 9999 9999 9999 1 9999 9999 1 9999 9999 1 1 9999 9999 1 18 6 R 1 23 18 O 9999 9999 9999 9999 9999 1 9999 9999 9999 9999 9999 9999 9999 1 9999 9999 9999 9999 9999 1 19 11 E 1 24 19 S 9999 9999 9999 9999 9999 1 9999 9999 9999 9999 9999 9999 9999 9999 9999 1 9999 1 1 9999 20 1 H 1 25 0 T 1 26 Sum 20

©Society for Business and Management Dynamics

Business Management Dynamics Vol.6, No.5, Nov 2016, pp.13-20

Figure 3 Graphical Solution to Sam Loyd’s Canals of Mars

SUMMARY have been a popular sub-field of recreational mathematics for many years. When viewed as a modification to the popular and much studied operations research problem known as the traveling salesman problem, mazes can be formulated as a mathematical model. One of the best known maze puzzles was written by Sam Loyd about a century ago. It utilizes the deep straight channels of Mars, which had been identified by the Italian astronomer Giovanni Schiaparelli (The Internet Encyclopedia of Science, n.d.). This paper presents a mathematical spreadsheet approach to modeling and solving this maze puzzle.

REFERENCES Barlow, John F. Excel Models for Business and Operations Management. 2nd Edition. 2005. John Wiley & Sons. Jimenez, B. C. R. & Munoz, R. R. (2011). From recreational mathematics to recreational programming and back. International Journal of Mathematical Education in Science and Technology, 42(6), 775-787. Kino, F. & Uno, Y. (2012). An integer programming approach to solving tantrix on fixed boards. Algorithms, 5, 158-175.

©Society for Business and Management Dynamics Business Management Dynamics Vol.6, No.5, Nov 2016, pp.13-20

Loyd, S. (1914). Cyclopedia of puzzles. Self-published. Loyd, S. (1959). Mathematical puzzles of Sam Loyd. M. Gardner (Ed.). Mineola, New York: Thomas Dover Publications. Loyd, S. (1960). Mathematical puzzles of Sam Loyd, Volume 2. M. Gardner (Ed.). New York: Dover. (Also published in the same year as More mathematical puzzles of Sam Loyd.) Mathematical Association of America,(n.d.). Downloaded on June 2, 2016 from http://www.maa.org/press/periodicals/american-mathematical-monthly. O’Shea, O. (2008). Sam Loyd’s courier problem with Diophantus, Pythagoras, and Martin Gardner. Classroom Capsules in The College Mathematics Journal, 39(5), 387-391. Rowe, D. E. (2011). Puzzles and paradoxes and their (sometimes) profounder implications. Mathematical Intelligencer, 33(1), 55-60. Silva, J. N. (2011). On mathematical games. BSHM Bulletin, 26, 80-104. Solver.com. (n.d.) Downloaded on June 4, 2016 from http://www.solver.com/gabasics.htm. Taha, Hamdy A. Operations Research: An Introduction. 4th Edition. 1985. Macmillan Publishing Company. The Internet Encyclopedia of Science. (n.d.) “Schiaparelli, Giovanni Virginio (1835-1910). Downloaded on June 7, 2016 from http://www.daviddarling.info/encyclopedia /S/Schiaparelli.html Winkler, P. (2012). Puzzled: Find the magic set. Communications of the ACM, 55(8), 120.

©Society for Business and Management Dynamics