11

Recently, I came across this problem, a variation of towers of hanoi.

Problem statement:

Consider the folowing variation of the well know problem Towers of Hanoi:

We are given $n$ towers and m disks of sizes $1,2,3,\dots,m$ stacked on some towers. Your objective is to transfer all the disks to the $k^{\text{th}}$ tower in as few moves as you can manage, but taking into account the following rules:

  • moving only one disk at a time,
  • never moving a larger disk one onto a smaller one,
  • moving only between towers at distance at most $d$.

(Limits in the original problem: $3 \le n \le 1000$ and $m \le 100$. Number of test cases $\le 1000$. You can assume that all the problems can be solved in not more than $20000$ moves.)

It's an interesting one. The classic towers of hanoi problem has one source, destination and temporary tower that is used to move the disks from source to destination. The problem pitched on that site basically has an initial and final configuration.

How does one approach this problem?

Guy Coder
  • 5,181
  • 2
  • 30
  • 65
Null
  • 211
  • 1
  • 3

1 Answers1

2

The most succesful approach to deal with the original version of the Towers of Hanoi is using Pattern Databases (PDBs). The current state of the art is described in "Recent Progress in Heuristic Search: A Case Study of the Four-Peg Towers of Hanoi Problem"

Pattern Databases are an automated means for deriving admissible heuristics which are necessary in order to find optimal solutions (as your problem requires). In the particular case of the Towers of Hanoi, some discs are preserved while others are just ignored. This results in a smaller state space which can then be fully traversed with a backward breadt-first search algorithm. It is traversed with a breadth-first search to derive optimal lengths in this abstract state and it is traversed from the goal node $t$ (i.e., backwards), to ensure that the optimal lengths computed are relative to the goal. Since the abstract space is smaller, these distances are admissible estimates in the original state space.

This said, I would highly recommend using PDBs again for solving this particular problem since "moving only between towers at distance at most $d$" is trivial since pegs are not abstracted, only the discs.

I do not see, indeed, any reason to change the typical approach just in view of this particular constraint.

Hope this helps,

Carlos Linares López
  • 3,483
  • 17
  • 30