Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Next Article in Journal
Standard and Specific Compression Techniques for DNA Microarray Images
Next Article in Special Issue
Any Monotone Function Is Realized by Interlocked Polygons
Previous Article in Journal
Compression-Based Tools for Navigation with an Image Database
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

How to Solve the Torus Puzzle

by
Kazuyuki Amano
1,
Yuta Kojima
2,
Toshiya Kurabayashi
2,
Keita Kurihara
1,
Masahiro Nakamura
2,
Ayaka Omi
2,
Toshiyuki Tanaka
1 and
Koichi Yamazaki
1,*
1
Department of Computer Science, Gunma University, 1-5-1 Tenjin-cho, Kiryu, Gunma 376-8515, Japan
2
Kiryu High School, 1-39 Miharacho, Kiryu, Gunma 376-0025, Japan
*
Author to whom correspondence should be addressed.
Algorithms 2012, 5(1), 18-29; https://doi.org/10.3390/a5010018
Submission received: 27 December 2011 / Revised: 30 December 2011 / Accepted: 30 December 2011 / Published: 13 January 2012
(This article belongs to the Special Issue Puzzle/Game Algorithms)

Abstract

:
In this paper, we consider the following sliding puzzle called torus puzzle. In an m by n board, there are m n pieces numbered from 1 to m n . Initially, the pieces are placed in ascending order. Then they are scrambled by rotating the rows and columns without the player’s knowledge. The objective of the torus puzzle is to rearrange the pieces in ascending order by rotating the rows and columns. We provide a solution to this puzzle. In addition, we provide lower and upper bounds on the number of steps for solving the puzzle. Moreover, we consider a variant of the torus puzzle in which each piece is colored either black or white, and we present a hardness result for solving it.

1. Introduction

In this paper, we address m by n torus puzzle which is similar to sliding puzzles such as the 15 puzzle. The m × n torus puzzle consists of m n pieces numbered from 1 to m n , and the pieces are placed on a board of m rows by n columns. Initially, for each r { 1 , , m n } , the piece numbered r is placed at the pth row and qth column, where p = r / n and r q ( mod n ) . In the puzzle, there are four basic operations, N, S, E, and W (these stand for north, south, east and west). The N (respectively, S) operation shifts the pieces in a column upward (respectively, downward). That is, by applying the N (respectively, S) operation to a column r = ( p 1 , p 2 , , p m 1 , p m ) t r , r is changed into ( p 2 , p 3 , , p m , p 1 ) t r (respectively, ( p m , p 1 , , p m 2 , p m 1 ) t r ), where A t r denotes the transpose of a matrix A . Similarly, the E (respectively, W) operation rotates a row ( p 2 , p 3 , , p n , p 1 ) into ( p 1 , p 2 , , p n 1 , p n ) (respectively, ( p n , p 1 , , p n 2 , p n 1 ) ). After performing a sequence of the basic operations, the configuration of the board would differ considerably from the initial configuration. The objective of the torus puzzle is to restore the initial configuration from the scrambled configuration (see Figure 1).
Although the 15 puzzle can be intuitively modified into the torus puzzle, the torus puzzle is relatively less popular. This is possibly because it is not easy to implement the torus puzzle on a board, unlike the 15 puzzle. However, the torus puzzle is now gaining popularity owing to the proliferation of touch-panel devices. In fact, the torus puzzle has already been implemented as an application called RotSquare on Mac OS (and is now an iPhone app).
The torus puzzle has not been investigated extensively thus far. In Section 4 in [1], the number of steps for randomizing the configurations of an n by n board is discussed. In [2], it is shown that an n by n board for every even number n, any configuration can be obtained from the initial configuration by showing that any two adjacent pieces can be reversed without disturbing the positions of the others. In this paper, we study the complexity of solving the torus puzzle (and its variant). The remainder of this paper is organised as follows. Section 2 is devoted to a solution of the torus puzzle. After introducing some definitions and notations, we provide the basic tools for solving the torus puzzle, and then we show how the torus puzzle is solved with the basic tools. In Section 3, we discuss the upper and lower bounds on the number of “steps” for obtaining the initial configuration from a scrambled configuration, where successive identical operations applied to a row/column, such as E ( r ) · · E ( r ) for some row r , are counted as one step. This form of counting is intuitive when the torus puzzle is implemented on a touch-panel device. The lower bound can be obtained by a standard argument. In Section 4, we consider a variant of the torus puzzle in which the pieces are colored white or black. For the variant, we address the hardness in estimating the minimum number of steps for reaching a given goal configuration from a given start configuration. Unfortunately, we have not determined the hardness for the torus puzzle thus far (it is known that finding the shortest solution for an N × N extension of the 15 puzzle is NP-hard [3]).

2. Preliminary

In this section, first we give some definitions and notation, then provide basic tools to solve the torus puzzle, and finally show how to solve the torus puzzle with the basic tools.

2.1. Definitions and Notation

This subsection introduces definitions, notation, and conventions. Let O be an operation in { N , S , E , W } . We denote by O i ( v ) the execution of i consecutive O operations on v , where v is a row (respectively, column) of the board if O { E , W } (respectively, O { N , S } ). We simply write O ( v ) as O 1 ( v ) . We call O i ( · ) for some i and O { E , W } (respectively, O { N , S } ) a row (respectively, column) operation. It is easy to see that N i ( · ) (respectively, E i ( · ) ) is the same action as S m i ( · ) (respectively, W n i ( · ) ).
In this paper, a configuration means a placement of the pieces on the board. We will refer to the following configuration as initial configuration and denote it by A : the piece numbered ( i 1 ) n + j is placed at the ith row and the jth column for each 1 i m and 1 j n . There are two ways to refer a piece in a configuration. One is by its number and the other is by its position on the board: The piece having number r is referred to as “the piece numbered r”, and the piece placed at the ith row and the jth column in a configuration is called “the piece placed at ( i , j ) ” in the configuration.
Let M m , n denote the set of configurations of the m by n board (a configuration of the board can be considered as an m by n matrix in which the pieces are numbered bijectively from { 1 , 2 , , m n } ). We say that the board has a configuration X = ( x i , j ) M m , n if the piece placed at ( i , j ) has number r iff x i , j = r for each 1 i m and 1 j n . The symbol r k (respectively, c k ) is used to refer to the kth row (respectively, column). We say that the piece numbered r is at its right position in X if x p , q = r , where p = r / n and r q ( m o d n ) . For X , Y M m , n , we write X { N , S , E , W } Y , or simply X Y , if Y can be obtained from X by performing a sequence of the basic operations { N , S , E , W } . We thus also write X   { N , S , E , W } Y , or simply X   Y , if there is no sequence S of the basic operations such that Y can be obtained from X by applying S .
Let S = O 1 k 1 ( · ) , O 2 k 2 ( · ) , , O k ( · ) be a sequence of the basic operations, where O j { N , S , E , W } for 1 j and we are assuming that O j O j + 1 . The integer and the value i = 1 k i are referred to as drag number and push number of the sequence S , respectively. We denote the drag and push numbers of S by d n ( S ) and p n ( S ) , respectively. For configurations X and Y , we denote the values min S d n ( S ) and min S p n ( S ) by d n ( X , Y ) and p n ( X , Y ) , respectively, where both minimums are taken over all sequences deriving Y from X . Specially, in the case where Y is the initial configuration A , we simply write d n ( X ) and p n ( X ) instead of d n ( X , A ) and p n ( X , A ) . The value d n ( X ) and p n ( X ) are both natural values to measure how far X is from the initial configuration A . In a situation where the torus puzzle is implemented on a touch-panel device, it would be natural to consider a consecutive iterations of the same operation as a single step. In this paper, we use d n ( X ) , that is, for each O { N , S , W , E } O k ( · ) is counted as one step, not k steps.

2.2. A Basic Tool: Three Elements Rotations

In this section, we introduce a basic tool called three elements rotation, which plays a fundamental role in the solution.
Consider the the following eight patterns of four consecutive operations. Figure 2 is used for showing how the eight patterns work. In Figure 2, there are five points: (the ith row, the jth column), (the i ± p th row, the jth column), (the ith row, the j ± q th column), and there are four triangles consisting of three of these points: A, B, C, and D. It is a routine to check that each pattern makes a clockwise or counterclockwise rotation of the three corners of a triangle A, B, C, or D without other changes of piece positions.
1.
W q ( r i ) , S p ( c j ) , E q ( r i ) , N p ( c j ) → clockwise on A,
2.
S p ( c j ) , W q ( r i ) , N p ( c j ) , E q ( r i ) → counterclockwise on A,
3.
N p ( c j ) , W q ( r i ) , S p ( c j ) , E q ( r i ) → clockwise on B,
4.
W q ( r i ) , N p ( c j ) , E q ( r i ) , S p ( c j ) → counterclockwise on B,
5.
E q ( r i ) , N p ( c j ) , W q ( r i ) , S p ( c j ) → clockwise on C,
6.
N p ( c j ) , E q ( r i ) , S p ( c j ) , W q ( r i ) → counterclockwise on C,
7.
S p ( c j ) , E q ( r i ) , N p ( c j ) , W q ( r i ) → clockwise on D,
8.
E q ( r i ) , S p ( c j ) , W q ( r i ) , N p ( c j ) → counterclockwise on D.
These patterns are referred to as “triangle rotations”.
By combining two triangle rotations, a useful rotation can be built as follows. Let X = ( x i , j ) be a configuration in M m , n . Let Y be the configuration obtained from X by applying basic operations to the board in the following order: S ( c j ) , E q ( r i ) , N ( c j ) , W q + p ( r i ) , S ( c j ) , E p ( r i ) , N ( c j ) for p < j and q n j (see Figure 3).
It is easy to see that the only difference between X and Y is the ith row, and the ith row in Y is:
( x i , 1 , , x i , j p 1 n o c h a n g e , x i , j , x i , j p + 1 , , x i , j 1 n o c h a n g e , x i , j + q , x i , j + 1 , , x i , j + q 1 n o c h a n g e , x i , j p , x i , j + q + 1 , , x i , m n o c h a n g e )
That is, only the part ( x i , j p , x i , j , x i , j + q ) of the ith row is changed (rotated) into ( x i , j , x i , j + q , x i , j p ) . We will refer to this change as three elements rotation on ( ( i , j ) , p, q, west) (the east version can be defined similarly). Specially, we denote the three elements rotation on ( ( i , j ) , 1, 1, west) by T W ( i , j ) (the corresponding east version is denoted by T E ( i , j ) ). For example, T W ( i , 1 ) results in ( x i , 2 , x i , n , x i , 3 , x i , 4 , , x i , n 2 , x i , n 1 , x i , 1 ) .

2.3. Solution

In this section, we show how to solve the torus puzzle by considering the two cases where m n is even and m n is odd. Not surprisingly, there is a difference between the even case and the odd case. In the even case, for any  X M m , n , X can be changed into the initial configuration A by applying a sequence of the basic operations. But this is not true for the odd case. (A similar thing happened for the 15 puzzle [4].) To describe our solution of the torus puzzle, we need the following lemmas.
Lemma 1.
Suppose that n 2 is an even integer. For any two consecutive pieces x p , q 1 and x p , q in a row of a configuration X = ( x i , j ) M m , n , we can swap the positions of two pieces without causing any other change of position by applying a sequence of basic operations. More precisely, it holds that X Y ( = ( y i , j ) ) , where y p , q = x p , q + 1 , y p , q + 1 = x p , q , and y i , j = x i , j for ( i , j ) { ( p , q + 1 ) , ( p , q ) } .
Proof. 
Suppose n 4 (the case of n = 2 is trivial). It is sufficient to show that there is a sequence of basic operations which changes the first row ( x 1 , 1 , x 1 , 2 , x 1 , 3 , , x 1 , n ) into ( x 1 , 2 , x 1 , 1 , x 1 , 3 , , x 1 , n ) . Apply T W ( 1 , 2 ) , T W ( 1 , 4 ) , T W ( 1 , 6 ) , , T W ( 1 , n ) in this order, then the first row becomes ( x 1 , 1 , x 1 , 3 , , x 1 , n , x 1 , 2 ) . Finally, execute E ( t h e 1 s t r o w ) , then we have the desired result. □
The next lemma is inspired by an argument on the parity of permutations in [4].
Lemma 2.
Suppose that m n is an odd integer. For any two consecutive pieces x p , q 1 and x p , q in a row of a configuration X = ( x i , j ) M m , n , we cannot swap the positions of two pieces without causing any other change of position. More precisely, it holds that X ¬ Y ( = ( y i , j ) ) , where y p , q = x p , q + 1 , y p , q + 1 = x p , q , and y i , j = x i , j for ( i , j ) { ( p , q + 1 ) , ( p , q ) } .
Proof. 
Suppose not, then there is a sequence S of basic operations which swaps the positions. Let h (respectively, v) be the number of row (respectively, column) operations in S , Then, S has h permutations of n elements and v permutations of m elements (i.e., h cycles of length n and v cycles of length m). As any permutation of k 2 elements can be represented by the production of k 1 transpositions, S can be represented with h · ( n 1 ) + v · ( m 1 ) transpositions. This, however, means that S is even permutation, since both m 1 and n 1 are even. However, S should be odd permutation, a contradiction. □
We are now ready to demonstrate our solution. Let A = ( a i , j ) be the initial configuration. We first show how to obtain a configuration Y = ( y i , j ) from any configuration X = ( x i , j ) M m , n such that y i , j = a i , j for 1 i m 1 , 1 j n , i.e., Y achieves the initial configuration except for the bottom row. Suppose that the pieces numbered 1, , r 1 are already at their right positions. Let p and q be the integers such that p = r / n and r q ( mod n ) . We now wish to have a configuration in which the pieces numbered 1, , r are at their right positions. Let ( s , t ) be the position of the piece numbered r in the current configuration. We will refer to the outside of the region placed the pieces numbered 1, , r 1 as work space. By proper choice of a third corner ( u , v ) (from work space) and executing a proper triangle rotation on the three corners ( p , q ) , ( s , t ) , and ( u , v ) , we can have the desired configuration. Note that, because of the work space, we can take a third corner properly (see Figure 4).
We now show how to achieve the initial configuration from the configuration Y . First, consider the case where m n is even. Without loss of generality, we may assume that n is even. Since the case of n = 2 is easy, we assume n 4 . By applying three elements rotation as many times as necessary, the piece numbered ( m 1 ) n + 1 can be replaced at its right position ( m , 1 ) . We repeat this process for pieces numbered ( m 1 ) n + 2 , , m n 2 . By Lemma 1, we can swap the positions of pieces numbered m n 1 and m n if necessary (i.e., if the last row is ( m 1 ) n + 1 , , m n 2 , m n , m n 1 ) . Then, we have the initial configuration A .
Now consider the case where m n is odd. In a similar fashion as above, the last row in Y can be changed into ( m 1 ) n + 1 , , m n 2 , x , y ) by applying three elements rotation as many times as necessary. If we assume that X A (i.e., Y A ), then, by Lemma 2, it is impossible to be ( x , y ) = ( m n , m n 1 ) . Thus, ( x , y ) should be ( m n 1 , m n ) , which means that we have already had the desired result.

3. Upper and Lower Bounds of diam ( M m , n )

In this section, we consider the following problem: How many steps are enough to derive a configuration Y M m , n from a configuration X M m , n . That is, we try to evaluate the value max X , Y M m , n d n ( X , Y ) . We call the value the diameter of M m , n and denote it by diam ( M m , n ) . Next theorem gives simple upper and lower bounds for diam ( M m , n ) . (For pebble games which are generalization of the 15 puzzle, a similar study can be found in [5].)
Theorem 1.
The following statements hold:
1.
For any configurations X , Y M m , n with X Y , d n ( X , Y ) 4 m n + c · max { m , n } for some constant c.
2.
For a given 0 < ε < 1 , there are integers m and n such that for any configuration X M m , n there is a configurations Y M m , n for which d n ( X , Y ) ε m n .
Proof. 
We first show the first statement. Since triangle rotation and three elements rotation take four and seven steps, respectively, according to our solution described in the previous section, we can have an upper bound: diam ( M m , n ) 4 m n + c · max { m , n } for some constant c.
We now show the second statement. Let us consider first the case where m n is even. Note that { Y : Y X } = M m , n . For a configuration P in M m , n , let N ( P ) denote the set of configurations Q obtained from P by executing one row or column operation (namely, Q can be obtained from P by applying O k for O { N , S , E , W } and some integer k). Let d = max W M m , n d n ( X , W ) . Since | N ( P ) | is at most 2 m n , | M m , n | is at most ( 2 m n ) d + 1 1 2 m n 1 (see Figure 5). Hence, as | M m , n | = ( m n ) ! , ( m n ) ! ( 2 m n ) d + 1 1 2 m n 1 holds. Since n m e m n < ( m n ) ! ( 2 m n ) d + 1 1 2 m n 1 ( 2 m n ) d + 1 , it follows that m n log ( m n ) 1 log 2 + log ( m n ) 1 < d . This completes the proof of the even case for the second statement.
Let us consider now the case where m n is odd. The second statement holds also for the odd case. This can be proved by the almost same way. The difference is the number of configurations obtained from X , that is, | { Y : Y X } | = | M m , n | / 2 holds for the odd case. Clearly, the difference does not affect the result of calculation. □
By applying a similar argument to evaluating the push number, we have that p n ( X , Y ) is O ( m n · max { m , n } ) for any pair ( X , Y ) with X Y , and for any X there is Z such that p n ( X , Z ) is m n ( 1 o ( 1 ) ) .

4. Hardness

In this section, we consider a variant of the torus puzzle in which the pieces are colored with white or black. The end of the variant is to derive from a given start configuration to a given goal configuration. For the variant, we show that the following problem is NP-hard by reduction from 3-PARTITION: For given a start configuration X , a goal configuration Y , and an integer k, whether or not d n ( X , Y ) k ? We will refer to this problem as BWP (Black & White Problem).
3-PARTITION
INSTANCE:
A bound B Z + , a set A = 1 , , 3 m of 3 m positive integers such that B / 4 < i < B / 2 for each 1 i 3 m , and i = 1 3 m i = m B .
QUESTION:
Can A be partitioned into m disjoint sets A 1 , , A m such that A i = B for each 1 i m ?
Since 3-PARTITION is strongly NP-complete [6], without loss of generality we can assume that each i is given in unary representation.
Observation 1.
Let r be a row in the board. If r has i black pieces, then, in order to make r so that r has i j black pieces, at least j column operations are needed. This is because that each column operation remove at most one black piece from r . For the same reason (just thought black piece as white and vice versa), if r has i black pieces, then in order to make r so that r has i + j black pieces, at least j column operations are needed. The same holds true for a column.
Theorem 2.
BWP is NP-hard.
Proof. 
For given an instance I = ( { 1 , 2 , , 3 m } , B ) of 3-PARTITION, we construct an instance G of BWP as follows: The start and goal configurations are illustrated in Figure 6 and Figure 7 and k = 3 m + m B . Without loss of generality, we may assume 1 2 3 m . The board in G has 9 m + 1 rows, 3 m + 3 ( m B + m 1 ) columns, and m B + m 1 black pieces. The ( 6 m + 1 ) th row plays an important role in this proof. As we shall show later, the m 1 black pieces in the ( 6 m + 1 ) th row in the start configuration cannot move both horizontally and vertically. The other m B black pieces initially placed at the upper left in the start configuration will be replaced in the ( 6 m + 1 ) th row in the goal configuration.
Let S be a sequence of row and column operations such that S derives the goal configuration from the start configuration. Let C be the set of configurations which appear during the steps derived by S .
[ I is a yes instance ⇒ G is a yes instance.]
Since I is a yes instance, there are m disjoint sets A 1 , , A m such that A i = B for each 1 i m . For each A i = { x , y , z } , first shift the black pieces corresponding x , y , z horizontally as shown in Figure 8. Then shift the black pieces corresponding x , y , z vertically. This can be done with 3 m + m B steps. Hence, G is a yes instance.
[ I is a yes instance ⇐ G is a yes instance.]
Since the first column has 3 m black pieces in the start configuration and no black piece in the goal configuration, by Observation 1, S has at least 3 m row operations. Similarly, as the ( 6 m + 1 ) th row has m 1 black pieces in the start configuration and m B + ( m 1 ) black pieces in the goal configuration, S has at least m B column operations. Thus, as d n ( S ) 3 m + m B , S has exactly 3 m row operations and m B column operations. Hence, each of the 3 m row operations should sweep out of a black piece from the first column, and each of m B column operations should bring a black piece into the ( 6 m + 1 ) th row. Furthermore, once a black piece is in the ( 6 m + 1 ) th row, the piece should be in the row during the steps derived by S , since S has exactly m B column operations.
Let c 1 , , c m 1 denote the black pieces in the ( 6 m + 1 ) th row and b 1 , , b m B denote the other black pieces in the start configuration. We now give the following claims. Note that each c i cannot be shifted vertically since a black piece is in the ( 6 m + 1 ) th row cannot swept out from the ( 6 m + 1 ) th row.
Claim 1.
For any configuration C C , in the ( 6 m + 1 ) th row in C , there is no two black pieces at least m B + m 1 column away from each other.
Proof. 
If not so, there are two black pieces at least m B + m 1 column away from each other. Since there are no such black pieces at least m B + m 1 column away from each other in the ( 6 m + 1 ) th row in the goal configuration, one of the two pieces should sweep out from the row. This, however, is not allowed as explained above, a contradiction. □
Claim 2.
In S , no operation is applied to the first column and also no operation is applied to the ( 6 m + 1 ) th row.
Proof. 
We first show that if the first column is shifted vertically at some step, then the ( 6 m + 1 ) th row has been shifted horizontally before that step. Suppose that, in S , there is a column operation applied to the first column. Note that, by this column operation, a black piece is placed at ( 6 m + 1 , 1 ) . From Claim 1, before applying this operation, c 1 (or c m 1 ) should be already in the jth column for some j R , where R = { i : 1 i m B + m 1 } { i : 3 m + 2 m B + 2 m i 3 m + 2 m B + 3 m 3 } . As each c i cannot move vertically, c 1 (or c m 1 ) should be moved by a row operation.
On the other hand, to apply a row operation to the ( 6 m + 1 ) th row, the piece placed at ( 6 m + 1 , 1 ) should be black, because a black piece in the first column must be swept out from the first column whenever a row operation is executed. However, in order to place a black piece at ( 6 m + 1 , 1 ) without applying a row operation to ( 6 m + 1 ) th row, the first column should be shifted vertically, so we have a deadlock. The deadlock completes the proof. □
We next show that each b i first move horizontally, then move vertically. Let I denote the set of indexes k such that 3 m + m B + m k 3 m + 2 m B + 2 m 2 and the kth column in the start configuration has no black piece. Note that | I | = m B . Since S has exactly m B column operations, by Claim 2 (i.e., the ( 6 m + 1 ) th row cannot shift horizontally), in S , each column c k with k I must be applied exactly one column operation. Similarly, since S has exactly 3 m row operations, by Claim 2 (i.e., the first column cannot shift vertically), in S , each row r k with 1 k 3 m must be applied exactly one row operation. Thus, b i first must move to a column c k with k I , then move vertically.
We now claim that in any configuration C C , each column c j with j I has at most one black piece. If not so, there is a column c j with j I such that c j has more than one black piece in a configuration C C . One of those black pieces must be swept out from c j by applying a row operation. Let p be such a black piece swept out from c j . Since p has two row operations, p moves first horizontally, second vertically, then horizontally (Recall that each row r k , 1 k 3 m , has exactly one row operation). Let O be the row operation for the second horizontal movement of p, and x the index such that O apply to the xth row r x . Then, x must be 3 m + 1 < x < 9 m + 1 , because p has moved vertically to a row between the ( 3 m + 2 ) th row and the 9 m th row. But, since row operations are applicable only to r k for 1 k 3 m , p now cannot move horizontally.
As a result, each b i first move to a column c k with k I , then move vertically to ( 6 m + 1 , k ) . Moreover, in any configuration in C , each column c k with 3 m + m B + m k 3 m + 2 m B + 2 m 2 has at most one black piece. This means that 1 , , 3 m must be able to partitioned into m groups that all have the same sum B. Therefore, I is a yes instance.

5. Discussion

In this paper, we showed that 1 lim n diam ( M n , n ) n 2 4 . It would be interesting to improve the lower or upper bounds, especially the lower bound. One way to obtain upper bounds is to find integers p, q, d 1 , d 2 , b, and a “potential" function ϕ : M n , n { 0 , 1 , 2 , } satisfying the following conditions: (1) ϕ ( X ) = 0 iff X = A (the potential of the initial configuration is zero), (2) X A with ϕ ( X ) b , Y such that [ d n ( X , Y ) d 1 ] and [ ϕ ( X ) ϕ ( Y ) q ] (if the potential is at least some threshold, say b, then one can decrease it by q using at most d 1 steps.), (3) if ϕ ( X ) < b , then d n ( X , A ) d 2 (if the potential is less than b, then we can always reach A within d 2 steps.), and (4) ϕ ( Y ) p for every Y (the maximum potential is p.) This would imply that the upper bound of d n ( M n , n ) p b q d 1 + d 2 . Actually, our upper bound was obtained in this manner by setting ϕ ( X ) = r iff the pieces numbered q r are placed at their right positions and the piece numbered r + 1 is not placed at its right position. We believe that our upper bound can still be improved to 3, even if one uses the same ϕ . However, we suspect that more sophisticated ϕ will be needed to find a better upper bound. On the other hand, our lower bound was obtained by considering the graph G = ( M m , n , { { X , Y } Y N ( X ) } ) . It would be interesting to improve the lower bound by using the structural information of G.
It would also be interest to determine diam ( M n , n ) , even if n is 4 or 5. This is because 4 by 4 or 5 by 5 may be popular sizes when playing the torus puzzle on touch-panel devices. We performed computer experiments on diam ( M m , n ) for small values of m and n: diam ( M 2 , 3 ) = 7 , diam ( M 2 , 4 ) = 8 , diam ( M 2 , 5 ) = 12 , diam ( M 2 , 6 ) = 14 , diam ( M 3 , 3 ) = 8 , and diam ( M 3 , 4 ) = 13 .

Acknowledgements

This research was supported by Super Science High School program launched by the Japanese Ministry of Education, Culture, Sports, Science and Technology. We thank Shin-ichi Nakano, Toru Araki, and Shingo Osawa for helpful discussion.

References

  1. Diaconis, P. Group Representations in Probability and Statistics. In IMS Lecture Notes-Monograph Series; Institute of Mathematical Statistics: Hayward, CA, USA, 1988; Volume 11. [Google Scholar]
  2. Bogomolny, A.; Greenwell, D. “Sliders”—Columns Cut the Knot! Available online: http://www.maa.org/editorial/knot/slider.html (accessed on 9 January 2012).
  3. Ratner, D.; Warmuth, M. The (n2 − 1)-puzzle and related relocation problems. J. Symb. Comput. 1990, 10, 111–137. [Google Scholar] [CrossRef]
  4. Johnson, W.; Story, W. Notes on the “15” Puzzle. Am. J. Math. 1879, 2, 397–404. [Google Scholar] [CrossRef]
  5. Kornhauser, D.; Miller, G.; Spirakis, P. Coordinating Pebble Motion On Graphs, The Diameter Of Permutation Groups, and Applications. In Proceedings of the 25th Annual Symposium on Foundations of Computer Science (SFCS ’84), Singer Island, FL, USA, 24–26 October 1984; pp. 241–250. [Google Scholar]
  6. Garey, M.; Johnson, D. Computers and Intractability: A Guide to the Theory of NP-Completeness; W. H. Freeman and Company: New York, NY, USA, 1979. [Google Scholar]
Figure 1. An example of play.
Figure 1. An example of play.
Algorithms 05 00018 g001
Figure 2. The eight rotations.
Figure 2. The eight rotations.
Algorithms 05 00018 g002
Figure 3. Three elements rotation.
Figure 3. Three elements rotation.
Algorithms 05 00018 g003
Figure 4. Work space and third corner
Figure 4. Work space and third corner
Algorithms 05 00018 g004
Figure 5. The relation between d and m n .
Figure 5. The relation between d and m n .
Algorithms 05 00018 g005
Figure 6. Start configuration.
Figure 6. Start configuration.
Algorithms 05 00018 g006
Figure 7. Goal configuration.
Figure 7. Goal configuration.
Algorithms 05 00018 g007
Figure 8. Procedure of move of the black pieces corresponding A i .
Figure 8. Procedure of move of the black pieces corresponding A i .
Algorithms 05 00018 g008
Publisher’s Note: MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affiliations.

Share and Cite

MDPI and ACS Style

Amano, K.; Kojima, Y.; Kurabayashi, T.; Kurihara, K.; Nakamura, M.; Omi, A.; Tanaka, T.; Yamazaki, K. How to Solve the Torus Puzzle. Algorithms 2012, 5, 18-29. https://doi.org/10.3390/a5010018

AMA Style

Amano K, Kojima Y, Kurabayashi T, Kurihara K, Nakamura M, Omi A, Tanaka T, Yamazaki K. How to Solve the Torus Puzzle. Algorithms. 2012; 5(1):18-29. https://doi.org/10.3390/a5010018

Chicago/Turabian Style

Amano, Kazuyuki, Yuta Kojima, Toshiya Kurabayashi, Keita Kurihara, Masahiro Nakamura, Ayaka Omi, Toshiyuki Tanaka, and Koichi Yamazaki. 2012. "How to Solve the Torus Puzzle" Algorithms 5, no. 1: 18-29. https://doi.org/10.3390/a5010018

Article Metrics

Back to TopTop