Skip to content

A simple GUI app to visualize how the HanoiTower solving algorithm is working

License

Notifications You must be signed in to change notification settings

anatoly314/HanoiTower

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HanoiTower

A simple GUI app to visualize how HanoiTower solving algorithm is working

Preview

  • It can be invoked manually by adding all the steps:
public static void main(String[] args) {
		HanoiGame game = new HanoiGame(4);
		game.addStep(0, 1);
		game.addStep(0, 2);
		game.addStep(1, 2);
		game.addStep(0, 1);
		game.addStep(2, 0);
		game.addStep(2, 1);
		game.addStep(0, 1);
		game.addStep(0, 2);
	}
  • Or it can be invoked by your own algorithm which which calculate required steps:
    public static void main(String[] args) {
		HanoiGame game = new HanoiGame(4);
		solveHanoi(game, 4, 0, 1, 2);
	}
	
	public static void solveHanoi(HanoiGame game, int n, int start, int aux, int end){
		if(n == 1){
			game.addStep(start, end);
		}else{
			solveHanoi(game, n - 1, start, end, aux);
			game.addStep(start, end);
			solveHanoi(game, n - 1, aux, start, end);
		}
	}

About

A simple GUI app to visualize how the HanoiTower solving algorithm is working

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages