MCPcopy Create free account
hub / github.com/MolinDeng/Princeton-algs4 / main

Method main

LabEnv/04Lab/Solver.java:88–109  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

86 }
87
88 public static void main(String[] args) {
89 // create initial board from file
90 In in = new In(args[0]);
91 int n = in.readInt();
92 int[][] tiles = new int[n][n];
93 for (int i = 0; i < n; i++)
94 for (int j = 0; j < n; j++)
95 tiles[i][j] = in.readInt();
96 Board initial = new Board(tiles);
97
98 // solve the puzzle
99 Solver solver = new Solver(initial);
100
101 // print solution to standard output
102 if (!solver.isSolvable())
103 StdOut.println("No solution possible");
104 else {
105 StdOut.println("Minimum number of moves = " + solver.moves());
106 for (Board board : solver.solution())
107 StdOut.println(board);
108 }
109 }
110}

Callers

nothing calls this directly

Calls 3

isSolvableMethod · 0.95
movesMethod · 0.95
solutionMethod · 0.95

Tested by

no test coverage detected