Permalink
Browse files

Small bug fixed related to solving already solved puzzle

  • Loading branch information...
mariuszgromada committed Apr 19, 2016
1 parent ae42ca8 commit bc2f6c47c5db6112900986cfe1c8e630e22f0e5f
@@ -1,6 +1,8 @@
Janet Sudoku - Sudoku Solver & Sudoku Generator
powerful and flexible library for JAVA, Android, .NET, MONO (C# .NET CLS Compliant)
v.1.1.1 (2016-04-18): Small bug fixed related to solving already solved puzzle :-)
v.1.1.0 (2016-04-16): Initial release providing
* Sudoku Solver API
@@ -29,5 +29,5 @@
// Build Number
// Revision
//
[assembly: AssemblyVersion("1.1.0.0")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyVersion("1.1.1.0")]
[assembly: AssemblyFileVersion("1.1.1.0")]
@@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.1.0.0")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyVersion("1.1.1.0")]
[assembly: AssemblyFileVersion("1.1.1.0")]
@@ -1,5 +1,5 @@
/*
* @(#)SudokuSolver.cs 1.0.0 2016-03-19
* @(#)SudokuSolver.cs 1.1.1 2016-04-18
*
* You may use this software under the condition of "Simplified BSD License"
*
@@ -68,7 +68,7 @@ namespace org.mariuszgromada.math.janetsudoku {
* <a href="http://bitbucket.org/mariuszgromada/janet-sudoku" target="_blank">Janet Sudoku on BitBucket</a><br>
* <a href="http://github.com/mariuszgromada/MathParser.org-mXparser" target="_blank">mXparser-MathParser.org on GitHub</a><br>
*
* @version 1.0.0
* @version 1.1.1
*/
[CLSCompliant(true)]
public class SudokuSolver {
@@ -944,9 +944,16 @@ public class SudokuSolver {
sortEmptyCells(0, emptyCellsNumber - 1);
boardState = BOARD_STATE_READY;
} else {
addMessage("(findEmptyCells) No cells to solve - check Sudoku board definition.", MSG_ERROR);
boardState = BOARD_STATE_ERROR;
return BOARD_STATE_ERROR;
if (SudokuStore.checkSolvedBoard(sudokuBoard) == true) {
addMessage("(findEmptyCells) Puzzle already solved. Marking as solved, but no path leading to the solution.", MSG_INFO);
boardState = BOARD_STATE_READY;
solvingState = SOLVING_STATE_SOLVED;
solvedBoard = SudokuStore.boardCopy(sudokuBoard);
} else {
addMessage("(findEmptyCells) No cells to solve + board error.", MSG_ERROR);
boardState = BOARD_STATE_ERROR;
return BOARD_STATE_ERROR;
}
}
if (SudokuStore.checkPuzzle(sudokuBoard) != true) {
@@ -1,5 +1,5 @@
/*
* @(#)SudokuStore.cs 1.1.0 2016-04-09
* @(#)SudokuStore.cs 1.1.1 2016-04-18
*
* You may use this software under the condition of "Simplified BSD License"
*
@@ -67,14 +67,14 @@ namespace org.mariuszgromada.math.janetsudoku {
* <a href="http://bitbucket.org/mariuszgromada/janet-sudoku" target="_blank">Janet Sudoku on BitBucket</a><br>
* <a href="http://github.com/mariuszgromada/MathParser.org-mXparser" target="_blank">mXparser-MathParser.org on GitHub</a><br>
*
* @version 1.1.0
* @version 1.1.1
*/
[CLSCompliant(true)]
public sealed class SudokuStore {
/**
* Sudoku solver version.
*/
public const String JANET_SUDOKU_VERSION = "1.1.0";
public const String JANET_SUDOKU_VERSION = "1.1.1";
/**
* Sudoku solver name.
*/
@@ -1,5 +1,5 @@
/*
* @(#)JanetSudoku.cs 1.0.0 2016-04-15
* @(#)JanetSudoku.cs 1.1.1 2016-04-18
*
* You may use this software under the condition of "Simplified BSD License"
*
@@ -66,14 +66,14 @@ namespace org.mariuszgromada.math.janetsudoku.demoapp {
* <a href="http://bitbucket.org/mariuszgromada/janet-sudoku" target="_blank">Janet Sudoku on BitBucket</a><br>
* <a href="http://github.com/mariuszgromada/MathParser.org-mXparser" target="_blank">mXparser-MathParser.org on GitHub</a><br>
*
* @version 1.0.0
* @version 1.1.1
*/
[CLSCompliant(true)]
public class JanetSudoku {
/**
* Demo app version.
*/
public const String VERSION = "1.1.0";
public const String VERSION = "1.1.1";
/**
* Internal solver.
*/
@@ -534,7 +534,7 @@ public class JanetSudoku {
JanetConsole.println("Path leading to the solution:");
JanetConsole.println(solver.solutionPathToString());
JanetConsole.println(">>>>> Computing time: " + solver.getComputingTime() + " s.");
JanetConsole.println(">>>>> Closed routes: " + solver.getClosedRoutesNumber() + " s.");
JanetConsole.println(">>>>> Closed routes: " + solver.getClosedRoutesNumber());
} else {
JanetConsole.println(solver.getMessages());
}
@@ -0,0 +1,23 @@
# Sudoku puzzle
+-------+-------+-------+
| 8 . . | . . . | . . . |
| . . 3 | 6 . . | . . . |
| . 7 . | . 9 . | 2 . . |
+-------+-------+-------+
| . 5 . | . . 7 | . . . |
| . . . | . 4 5 | 7 . . |
| . . . | 1 . . | . 3 . |
+-------+-------+-------+
| . . 1 | . . . | . 6 8 |
| . . 8 | 5 . . | . 1 . |
| . 9 . | . . . | 4 . . |
+-------+-------+-------+
# One line definition:
# 8..........36......7..9.2...5...7.......457.....1...3...1....68..85...1..9....4..
# 800000000003600000070090200050007000000045700000100030001000068008500010090000400
# Janet-Sudoku-v.1.1.0, 2016-04-18 00:52:48
@@ -4,6 +4,6 @@ Specification-Title: Janet Sudoku - Android .NET Sudoku Generator / Sudoku Solve
Specification-Version: 1.1
Specification-Vendor: Mariusz Gromada, MariuszGromada.org
Implementation-Title: org.mariuszgromada.math.janetsudoku
Implementation-Version: 1.1.0
Implementation-Version: 1.1.1
Implementation-Vendor: Mariusz Gromada, MariuszGromada.org
Main-Class: org.mariuszgromada.math.janetsudoku.demoapp.JanetSudoku
@@ -1,5 +1,5 @@
/*
* @(#)SudokuSolver.java 1.0.0 2016-04-16
* @(#)SudokuSolver.java 1.1.1 2016-04-18
*
* You may use this software under the condition of "Simplified BSD License"
*
@@ -69,7 +69,7 @@
* <a href="http://bitbucket.org/mariuszgromada/janet-sudoku" target="_blank">Janet Sudoku on BitBucket</a><br>
* <a href="http://github.com/mariuszgromada/MathParser.org-mXparser" target="_blank">mXparser-MathParser.org on GitHub</a><br>
*
* @version 1.0.0
* @version 1.1.1
*/
public class SudokuSolver {
/**
@@ -945,9 +945,16 @@ private int findEmptyCells() {
sortEmptyCells(0, emptyCellsNumber - 1);
boardState = BOARD_STATE_READY;
} else {
addMessage("(findEmptyCells) No cells to solve - check Sudoku board definition.", MSG_ERROR);
boardState = BOARD_STATE_ERROR;
return BOARD_STATE_ERROR;
if (SudokuStore.checkSolvedBoard(sudokuBoard) == true) {
addMessage("(findEmptyCells) Puzzle already solved. Marking as solved, but no path leading to the solution.", MSG_INFO);
boardState = BOARD_STATE_READY;
solvingState = SOLVING_STATE_SOLVED;
solvedBoard = SudokuStore.boardCopy(sudokuBoard);
} else {
addMessage("(findEmptyCells) No cells to solve + board error.", MSG_ERROR);
boardState = BOARD_STATE_ERROR;
return BOARD_STATE_ERROR;
}
}
if (SudokuStore.checkPuzzle(sudokuBoard) != true) {
@@ -1,5 +1,5 @@
/*
* @(#)SudokuStore.java 1.1.0 2016-04-16
* @(#)SudokuStore.java 1.1.1 2016-04-18
*
* You may use this software under the condition of "Simplified BSD License"
*
@@ -69,13 +69,13 @@
* <a href="http://bitbucket.org/mariuszgromada/janet-sudoku" target="_blank">Janet Sudoku on BitBucket</a><br>
* <a href="http://github.com/mariuszgromada/MathParser.org-mXparser" target="_blank">mXparser-MathParser.org on GitHub</a><br>
*
* @version 1.1.0
* @version 1.1.1
*/
public final class SudokuStore {
/**
* Sudoku solver version.
*/
public static final String JANET_SUDOKU_VERSION = "1.1.0";
public static final String JANET_SUDOKU_VERSION = "1.1.1";
/**
* Sudoku solver name.
*/
@@ -1,5 +1,5 @@
/*
* @(#)JanetSudoku.java 1.1.0 2016-04-16
* @(#)JanetSudoku.java 1.1.1 2016-04-18
*
* You may use this software under the condition of "Simplified BSD License"
*
@@ -73,13 +73,13 @@
* <a href="http://bitbucket.org/mariuszgromada/janet-sudoku" target="_blank">Janet Sudoku on BitBucket</a><br>
* <a href="http://github.com/mariuszgromada/MathParser.org-mXparser" target="_blank">mXparser-MathParser.org on GitHub</a><br>
*
* @version 1.1.0
* @version 1.1.1
*/
public class JanetSudoku {
/**
* Demo app version.
*/
public static final String VERSION = "1.1.0";
public static final String VERSION = "1.1.1";
/**
* Internal solver.
*/
@@ -546,7 +546,7 @@ private void solveFindFirst() {
JanetConsole.println("Path leading to the solution:");
JanetConsole.println(solver.solutionPathToString());
JanetConsole.println(">>>>> Computing time: " + solver.getComputingTime() +" s.");
JanetConsole.println(">>>>> Closed routes: " + solver.getClosedRoutesNumber() +" s.");
JanetConsole.println(">>>>> Closed routes: " + solver.getClosedRoutesNumber());
} else {
JanetConsole.println(solver.getMessages());
}

0 comments on commit bc2f6c4

Please sign in to comment.