-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSudokuSolver.java
30 lines (24 loc) · 1.18 KB
/
SudokuSolver.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import java.util.Scanner; // Import the Scanner class
import java.util.ArrayList; // Import ArrayList class
class SudokuSolver {
public static void main(String[] args) {
// Request the name of the puzzle
Scanner myObj = new Scanner(System.in);
System.out.println("Enter file name of sudoku puzzle: ");
String puzzleFileName = myObj.nextLine();
// Request the name the user would like to give the file
// of the solution
Scanner secondObj = new Scanner(System.in);
System.out.println("What would you like to name the file of the solution? ");
String solutionFileName = secondObj.nextLine();
// Create an object of the ManageFiles class
FileManager fileManager = new FileManager(puzzleFileName, solutionFileName);
// Retrieve puzzle
ArrayList<ArrayList<Integer>> puzzle = fileManager.getPuzzle();
// Retrieve the solution, and create and write to a file
Puzzle puzzleSolver = new Puzzle();
ArrayList<ArrayList<Integer>> completedPuzzle = puzzleSolver.solvePuzzle(puzzle, 0, 0);
fileManager.createFile();
fileManager.writeToFile(completedPuzzle);
}
}