# An Integer Programming Approach to Solving Tantrix on Fixed Boards

^{1}

^{2}

^{*}

## Abstract

**:**

## 1. Introduction

## 2. Tantrix

- determine the number of tiles for the challenge (challenge number), which is greater than 2,
- prepare the tiles as many numbers as the challenge number consecutively starting from a tile with number 1 on its back (in case it is more than 10, start from 1 again),
- the designated color is the one in which the lowest digit of the challenge number is written (on the back of the tile),
- connect all the lines of the designated color (drawn on prepared tiles) so that they form a single loop,
- connect the lines of the other colors than the designated color so that their touching colors match.

## 3. A Problem Setting and Terminology for Formulations

#### 3.1. A Problem Setting for Solving Tantrix by a Computer

- Fixed_Board TANTRIXInput: a challenge number n and a board of size n that satisfies the rules of Tantrix,Question: a Tantrix solution if there is on the input board, or no, otherwise.

#### 3.2. Terminology and Definitions for IP Formulation

## 4. An Integer Programming Formulation

#### 4.1. Variables

#### 4.2. Constraints and an Objective Function

**Constraint 1**(C1). Exactly one tile is placed on each place.**Constraint 2**(C2). Each tile is used exactly once.**Constraint 3**(C3). The color of a line of an edge that is on the boundary of a board is not the designated color.**Constraint 4**(C4). The colors of lines whose corresponding edges are touching each other have to match.

#### 4.3. Elementary Experiments and the Results

#### 4.4. Subloop Elimination

**Constraint 5**(C5). Lines of the designated color cross the cut over which they do not cross.

## 5. Improvement for Larger Challenge Number

#### 5.1. Reduce Variables and Constraints

**Constraint ${\mathbf{2}}^{\prime}$**(C2${}^{\prime}$). Each tile i is used $\u2308{\textstyle \frac{n+1-i}{10}}\u2309$ times.

#### 5.2. Fix Tiles with a ${120}^{\circ}$ Line of the Designated Color

**Constraint 6**(C6). Only a tile that has a ${120}^{\circ}$ line of the designated color is placed if a place is adjacent only to two places in a board.

#### 5.3. Eliminate Short Subloops in Advance

**Constraint 7**(C7). There are no loops consists of 3 tiles.**Constraint 8**(C8). There are no loops consists of 4 tiles.**Constraint 9**(C9). There are no loops consists of 5 tiles.

#### 5.4. Further Challenge

## 6. Conclusions

## Acknowledgments

## References

- Gardner, M. Mathematical Games: The Entire Collection of His Scientific American Columns; The Mathematical Association of America: Washington, DC, USA, 2005. [Google Scholar]
- Felgenhauer, B.; Jarvis, F. Sudoku enumeration problems. Available online: http://www.afjarvis.staff.shef.ac.uk/sudoku/ (accessed on 15 March 2012).
- Lichtenstein, D.; Sipser, M. GO is polynomial-space hard. J. ACM
**1980**, 27, 393–401. [Google Scholar] [CrossRef] - Rokicki, T.; Kociemba, H.; Davidson, M.; Dethridge, J. God’s Number is 20. 2010. Available online: http://cube20.org/ (accessed on 15 March 2012).
- Rosenbloom, P.S. A world-championship-level Othello program. Artif. Intell.
**1982**, 19, 279–320. [Google Scholar] [CrossRef] - Shanon, C.E. Programming a computer for playing Chess. Philos. Mag.
**1950**, 41, 256–275. [Google Scholar] [CrossRef] - Albert, M.H.; Nowakowski, R.J.; Wolfe, D. Lessons in Play: An Introduction to Combinatorial Game Theory; A K Peters Ltd.: Wellesley, MA, USA, 2007. [Google Scholar]
- Demaine, E.D. Playing Games with Algorithms: Algorithmic Combinatorial Game Theory. In Proceedings of the 26th Symposium on Mathematical Foundations in Computer Science (MFCS ’01), Marianske Lazne, Czech Republic, 27–31 August 2001; Volume 2136, pp. 18–32. [Google Scholar]
- Hearn, R.A.; Demaine, E.D. Games, Puzzles, and Computation; A K Peters Ltd.: Wellesley, MA, USA, 2009. [Google Scholar]
- Lee, M.K. The graph for the Tower of Hanoi with four pegs. Pythagoras
**2003**, 57, 27–31. [Google Scholar] - McGuire, G.; Tugemann, B.; Civario, G. There is no 16-clue sudoku: Solving the sudoku minimum number of clues problem. arXiv
**2012**, arXiv:1201.0749v1. [Google Scholar] - Demaine, E.D.; Demaine, M.L.; Uehara, R.; Uno, T.; Uno, Y. UNO Is Hard, Even for a Single Player. In Proceedings of the 5th International Conference on Fun with Algorithms (FUN ’10), Ischia, Italy, 2–4 June 2010; Volume 6099, pp. 133–144. [Google Scholar]
- Tantrix Japan Official Homepage (in Japanese). Available online: http://www.tantrix.jp/ (accessed on 15 March 2012).
- Tantrix.com (a Tantrix website in New Zealand). Available online: http://www.tantrix.com/ (accessed on 15 March 2012).
- Tantrix in the UK and Ireland (a Tantrix website in the United Kingdom). Available online: http://www.tantrix.co.uk/ (accessed on 15 March 2012).
- Pataki, G. Teaching integer programming formulations using the traveling salesman problem. SIAM Rev.
**2003**, 45, 116–122. [Google Scholar] [CrossRef] - Wolsey, L.A. Integer Programming; Wiley Interscience: Hoboken, NJ, USA, 1999. [Google Scholar]
- Tantrix UK Ltd. Tantrix teacher/parent guide. 2010. Available online: http://www.tantrix.co.uk/ (accessed on 15 March 2012).
- IBM ILOG CPLEX Optimizer (a website in IBM). Available online: http://www-01.ibm.com/software/integration/optimization/cplex-optimizer/ (accessed on 15 March 2012).
- Applegate, D.L.; Bixby, R.E.; Chvátal, V.; Cook, W.J. The Traveling Salesman Problem—A Computational Study; Saunders Publishing: Philadelphia, PA, USA, 2006. [Google Scholar]
- Cook, W.J.; Cunningham, W.H.; Pulleyblank, W.R.; Schrijver, A. Combinatorial Optimization; Wiley Interscience: Hoboken, NJ, USA, 1997. [Google Scholar]
- Holzer, M.; Holzer, W. Tantrix rotation puzzles are intractable. Discret. Appl. Math.
**2004**, 144, 345–358. [Google Scholar] [CrossRef]

**Figure 1.**(

**a**) Tops of 10 sorts of tiles (with their orientations 1), and (

**b**) their corresponding backs.

**Figure 2.**Examples of “uncleared” arrangements although they satisfy rules from 1 to 5: (

**a**) there is a hole; and (

**b**) a line of the designated color (red) is not a part of a loop.

**Figure 4.**A place (left) and an example of a board (of size 5) (right) on a hexagonal lattice plane.

**Figure 9.**The solution for challenge number 10, where we use a board in Figure 6.

**Figure 10.**(

**a**) A board of size 20 used for challenge number 20; (

**b**) a solution obtained by solving a formulation using C1–C4; including 2 subloops of its designated color blue, where an orange line is a cut defined by them; and (

**c**) a final solution obtained by solving a formulation by adding C5.

**Figure 11.**A place where only a tile that has a ${120}^{\circ}$ line of the designated color can be placed.

**Figure 12.**Solutions obtained by solving IP formulations using C1, C2${}^{\prime}$, C3, C4 and C6 for challenge number 40: after (

**a**) 3rd, (

**b**) 7th and (

**c**) 14th iterations, respectively.

**Figure 13.**Forbidden arrangements of lines of the designated color for challenge number greater than 5. These will force subloops consist of (

**a**) 3, (

**b**) 4 and (

**c**) 5 tiles, respectively.

**Table 1.**Computational time (s) of solving IP formulations using constraints C1, C2, C3 and C4, and the number of loops in each solution.

constraints challenge# | C1, C2, C3, C4 | |
---|---|---|

time | #loops | |

5 | 0.02 | 1 |

10 | 0.06 | 1 |

15 | 0.27 | 1 |

20 | 2.23 | 2 |

25 | 2.28 | 2 |

30 | 98.88 | 1 |

35 | 12,944.06 | 2 |

**Table 2.**Computational time (s) of solving IP formulations using C1–C4 with adding C5 for challenge numbers 20, 25 and 35.

constraints #iterations | C1, C2, C3, C4 + C5 | ||
---|---|---|---|

challenge# | |||

20 | 25 | 35 | |

0 | 2.23 | 2.28 | 12,944.06 |

1 | 0.61 | 1.27 | 740.72 |

2 | — | 0.97 | — |

total | 2.84 | 4.52 | 13,684.78 |

**Table 3.**Computational time (s) of solving IP formulations using C1, C2${}^{\prime}$, C3 and C4 for challenge numbers 25, 30 and 35.

constraints #iterations | C1, C2${}^{\prime}$, C3, C4 | ||
---|---|---|---|

challenge# | |||

25 | 30 | 35 | |

0 | 0.53 | 9.67 | 4.02 |

1 | 0.33 | — | 1,298.86 |

2 | — | — | 29.19 |

3 | — | — | 15.18 |

4 | — | — | 2.77 |

5 | — | — | 44.06 |

6 | — | — | 54.91 |

total | 0.86 | 9.67 | 1,448.99 |

**Table 4.**Computational time (s) of solving IP formulations using C1, C2${}^{\prime}$, C3, C4 and C6 for challenge numbers 30, 35 and 40; and IP formulations adding C7, C8 and C9 to them as well for challenge number 40 (rightmost column).

constraints #iterations | C1, C2${}^{\prime}$, C3, C4, C6 | +C7, 8, 9 | ||
---|---|---|---|---|

challenge# | ||||

30 | 35 | 40 | ||

0 | 1.86 | 18.09 | 28.39 | 9.39 |

1 | — | 3.30 | 35.72 | 29.69 |

2 | — | 17.94 | 322.17 | — |

3 | — | 142.78 | 3.56 | — |

4 | — | — | 81.48 | — |

5 | — | — | 8.23 | — |

6 | — | — | 121.92 | — |

7 | — | — | 65.13 | — |

8 | — | — | 82.80 | — |

9 | — | — | 145.37 | — |

10 | — | — | 27.38 | — |

11 | — | — | 156.00 | — |

12 | — | — | 6.95 | — |

13 | — | — | 59.45 | — |

14 | — | — | 16.88 | — |

total | 1.86 | 182.11 | 1,161.43 | 39.08 |

**Table 5.**Computational time (s) for challenge numbers 45, 50, 55 and 60 under our current best formulation.

#iterations | challenge# | |||
---|---|---|---|---|

45 | 50 | 55 | 60 | |

0 | 8,945.70 | 73.23 | 23,785.33 | 1,331.17 |

1 | — | 68.94 | — | 2,030.33 |

2 | — | 302.33 | — | 2,574.87 |

3 | — | 359.49 | — | 270.05 |

4 | — | 200.16 | — | 506.83 |

5 | — | 816.75 | — | — |

total | 8,945.70 | 1,820.90 | 23,785.33 | 6,713.25 |

© 2012 by the authors. licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution license (http://creativecommons.org/licenses/by/3.0/.)

## Share and Cite

**MDPI and ACS Style**

Kino, F.; Uno, Y.
An Integer Programming Approach to Solving Tantrix on Fixed Boards. *Algorithms* **2012**, *5*, 158-175.
https://doi.org/10.3390/a5010158

**AMA Style**

Kino F, Uno Y.
An Integer Programming Approach to Solving Tantrix on Fixed Boards. *Algorithms*. 2012; 5(1):158-175.
https://doi.org/10.3390/a5010158

**Chicago/Turabian Style**

Kino, Fumika, and Yushi Uno.
2012. "An Integer Programming Approach to Solving Tantrix on Fixed Boards" *Algorithms* 5, no. 1: 158-175.
https://doi.org/10.3390/a5010158