Skip to content

JoryAnderson/SudokuSATSolver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Team Members

  • Jory Anderson (V00843894)

  • Note: My original team of 3 disbanded due to the challenges presented by CoViD-19. I have decided to complete the project regardless.

Requirements

  • JDK 11 (Cannot guarantee successful compilation on other versions)
  • minisat (Available on UVic Linux machines)

Documentation / Building

  1. After extracting the contents of the tarball, compile all java files in the archive by performing the following in command line / terminal

     javac *.java
    
    • Ensure your working directory in terminal/cmd is set to the 'subid' folder of the submission (i.e., 'jba')
  2. Once completed, take a properly formatted puzzle.txt file (see project.pdf), and perform the following command:

     java sud2sat < puzzles/puzzle.txt > puzzle.cnf
    
    • Note: sud2satextended can be used in a manner identical to sud2sat. Simply substitute the command.

    This will use "puzzle.txt" as the input (i.e., the file containing the incomplete sudoku puzzle), and create a new file called "puzzle.cnf" as the output. This file contains the DIMACs-formatted file used with

    minisat 
    
  3. Using the newly created "puzzle.cnf" file, perform the following:

     minisat puzzle.cnf assign.txt > stat.txt
    

    After executing the above, you will receive two files, "assign.txt" and "stat.txt"

    • "assign.txt": A file generated by minisat. Contains one or two lines determining satisfiability.
    • "stat.txt": The output of minisat. Will contain statistics pertaining to solving.
  4. To solve, run the provided "sat2sud" command like so:

     java sat2sud < assign.txt > solution.txt
    

    sat2sud takes the file generated by minisat, formats the completed sudoku problem, and outputs it into solution.txt

Example Build / Execution (Simple)

    javac *.java
    java sud2sat < puzzles/puzzle.txt > puzzle.cnf
    minisat puzzle.cnf assign.txt > stat.txt
    java sat2sud < assign.txt > solution.txt

Example Build / Execution (Extended)

    javac *.java
    java sud2satextended < puzzles/hardPuzzle2.txt > puzzle.cnf
    minisat puzzle.cnf assign.txt > stat.txt
    java sat2sud < assign.txt > solution.txt

About

A self-project from my Foundations of Computer Science university course.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages