SlideShare a Scribd company logo
1 of 7
VeryUtils SudokuJS JavaScript Sudoku solver. VeryUtils SudokuJS has a step by step solver
that implements basic strategies, enough to solve (non evil) newspaper sudoku puzzles. The
solver is built to mimic humans in that it attempts strategies in order from easiest to most
difficult, in each step. So if you're stuck with a puzzle this solver will show you the minimal
next step to continue.
https://veryutils.com/sudokujs-javascript-sudoku-solver
VeryUtils SudokuJS comes with a basic GUI for the sudoku board - the board is rendered on
the screen, and the board cells listen for keyboard input from a user. VeryUtils SudokuJS can
generate sudoku puzzles of the same difficulties that it can solve, ranging from Easy to Very
hard. VeryUtils SudokuJS currently requires jQuery library.
### Run Demo Online
VeryUtils SudokuJS (4x4) - Introductory Sudoku : demo-board-size-4.html
VeryUtils SudokuJS (9x9) - Demo with controls: demo-edit-candidates.html
VeryUtils SudokuJS (9x9) - Demo with board generation: demo-generate-board.html
VeryUtils SudokuJS (9x9) - Simple demo: demo-simple.html
VeryUtils SudokuJS (9x9) - Demo with controls: demo-w-controls.html
VeryUtils SudokuJS (16x16) - Professional Sudoku : demo-board-size-16.html
### Usage
#### Initialization
[script src='VeryUtils SudokuJS.js'][/script]
[link rel='stylesheet' href='VeryUtils SudokuJS.css' /]
[div id='sudoku'][/div]
[script]
var myVeryUtils SudokuJS = $("#sudoku").VeryUtils SudokuJS({
difficulty: "medium" ("easy"|"medium"|"hard"|"very hard")
});
[/script]
You can also pass in your own board:
//array representing a standard sudoku puzzle of size 9
//use space for empty cells
var board = [
, , ,4, ,8, ,2,9
, , , , , , , , ,4
,8,5, , ,2, , , ,7
, , ,8,3,7,4,2, ,
, ,2, , , , , , ,
, , ,3,2,6,1,7, ,
, , , , ,9,3,6,1,2
,2, , , , , ,4, ,3
,1,3, ,6,4,2, ,7,undefined
]
//NOTE: if last cell of board is empty, 'undefined' has to be used as value!
var myVeryUtils SudokuJS = $("#sudoku").VeryUtils SudokuJS({
board: board
});
#### Solving
Let `VeryUtils SudokuJS` solve your puzzle - either step by step, or all in one go:
myVeryUtils SudokuJS.solveStep();
myVeryUtils SudokuJS.solveAll();
#### Analyzing the board
The solver can tell you info about the board.
var data = myVeryUtils SudokuJS.analyzeBoard();
//data.error -- board is incorrect
//data.finished === false -- board can't be solved because it requires more advanced
strategies
//if no error, and data.finished === true
//data.level -- "easy"|"medium"|"hard"
//data.score -- int [experimental]
//data.usedStrategies -- [{title, freq}, ..],ranked by difficulty, easiest first
#### Board Generation
`VeryUtils SudokuJS` generate new sudoku puzzles on init when no board is passed in, and
on `generateBoard` calls:
myVeryUtils SudokuJS.generateBoard('easy');
myVeryUtils SudokuJS.generateBoard('medium');
myVeryUtils SudokuJS.generateBoard('hard');
myVeryUtils SudokuJS.generateBoard('very hard');
The current implementation for board generation cannot guarantee hard or very hard
puzzles generated on every try, so instead it continues over and over until is has succeeded.
This means loading a very hard board can sometimes take up to a few seconds.
`generateBoard` accepts a `callback` function as a second parameter, that gets called when
the new board is ready.
#### Candidates
Candidates are hidden when a board loads. To show/hide candidates:
myVeryUtils SudokuJS.showCandidates();
myVeryUtils SudokuJS.hideCandidates();
VeryUtils SudokuJS automatically removes impossible candidates on showCandidates();
candidates that can be eliminated via visualElimination (number already exists in same
house).
Candidates can be edited on the board by setting VeryUtils SudokuJS to candidate editing
mode:
myVeryUtils SudokuJS.setEditingCandidates(true);
Input changes on board cells will now toggle the candidates rather than changes the value.
#### Clear board
Useful before entering new puzzle, if using keyboard input in the GUI.
myVeryUtils SudokuJS.clearBoard();
#### Get/Set board
Get the board and save it away if you want. Set a new board and play with that one instead.
Setting automatically resets everything back to init state.
myVeryUtils SudokuJS.getBoard();
var newBoard = [
...
]
myVeryUtils SudokuJS.setBoard(newBoard);
### Callbacks
#### boardUpdatedFn
Fires whenever the board is updated, whether by user or solver.
$("#sudoku").VeryUtils SudokuJS({
board: board
,boardUpdatedFn: function(data){
//data.cause: "user input" | name of strategy used
//data.cellsUpdated: [] of indexes for cells updated
alert("board was updated!");
}
});
#### boardFinishedFn
Fires when the board has been completed.
$("#sudoku").VeryUtils SudokuJS({
board: board
,boardFinishedFn: function(data){
//ONLY IF board was solved by solver:
//data.difficultyInfo {
// level: "easy", "medium", "hard"
// ,score: int [experimental]
//}
alert("board was finished!");
}
});
#### boardErrorFn
Fires whenever the board is found to be incorrect, f.e. if solver detects there is no solution to
board, or if passed in board is of invalid size.
$("#sudoku").VeryUtils SudokuJS({
board: board
,boardErrorFn: function(data){
//data.msg -- f.e. "board incorrect"
alert("board error!");
}
});
#### candidateShowToggleFn
The solver automatically switches to showing candidates when a solve step was invoked
which only updated the candidates on the board. To catch this change (for updating UI, etc),
there is a callback:
$("#sudoku").VeryUtils SudokuJS({
board: board
,candidateShowToggleFn: function(showingBoolean){
alert("candidates showing: " + showingBoolean); //true|false
}
}
### Extra
The solver is board size agnostic, so you can pass in any valid sudoku sized board (f.e. 4x4,
9x9, 16x16) - however the CSS included only handles 9x9 boards. Currently you can't change
boardSize after init.
### Changelog
* boardSize option, now working. Demos for board sizes
* Candidate editing mode
* Board generator, easy - very hard
* Simple UI and better interface
* Step by step sudoku solver

More Related Content

More from Lingwen1998

VeryUtils HTMLPrint to Any Converter Command Line is a versatile tool that st...
VeryUtils HTMLPrint to Any Converter Command Line is a versatile tool that st...VeryUtils HTMLPrint to Any Converter Command Line is a versatile tool that st...
VeryUtils HTMLPrint to Any Converter Command Line is a versatile tool that st...Lingwen1998
 
VeryUtils File Manager is a powerful file management tool that allows you to ...
VeryUtils File Manager is a powerful file management tool that allows you to ...VeryUtils File Manager is a powerful file management tool that allows you to ...
VeryUtils File Manager is a powerful file management tool that allows you to ...Lingwen1998
 
Convert SVG to PDF via CLI (command-line interface) and streamline your data ...
Convert SVG to PDF via CLI (command-line interface) and streamline your data ...Convert SVG to PDF via CLI (command-line interface) and streamline your data ...
Convert SVG to PDF via CLI (command-line interface) and streamline your data ...Lingwen1998
 
VeryUtils Java PDF Command Line SDK API for Developers Royalty Free.pdf
VeryUtils Java PDF Command Line SDK API for Developers Royalty Free.pdfVeryUtils Java PDF Command Line SDK API for Developers Royalty Free.pdf
VeryUtils Java PDF Command Line SDK API for Developers Royalty Free.pdfLingwen1998
 
VeryPDF .NET PDF Editor SDK for Developers Royalty Free _ VeryPDF Knowledge B...
VeryPDF .NET PDF Editor SDK for Developers Royalty Free _ VeryPDF Knowledge B...VeryPDF .NET PDF Editor SDK for Developers Royalty Free _ VeryPDF Knowledge B...
VeryPDF .NET PDF Editor SDK for Developers Royalty Free _ VeryPDF Knowledge B...Lingwen1998
 
VeryUtils BatchPrint is a batch printing software for Windows to batch print ...
VeryUtils BatchPrint is a batch printing software for Windows to batch print ...VeryUtils BatchPrint is a batch printing software for Windows to batch print ...
VeryUtils BatchPrint is a batch printing software for Windows to batch print ...Lingwen1998
 
VeryUtils PDF Command Line Tools and API for Java.docx
VeryUtils PDF Command Line Tools and API for Java.docxVeryUtils PDF Command Line Tools and API for Java.docx
VeryUtils PDF Command Line Tools and API for Java.docxLingwen1998
 
VeryUtils OCR to Any Converter SDK can be used to convert scanned PDF.docx
VeryUtils OCR to Any Converter SDK can be used to convert scanned PDF.docxVeryUtils OCR to Any Converter SDK can be used to convert scanned PDF.docx
VeryUtils OCR to Any Converter SDK can be used to convert scanned PDF.docxLingwen1998
 
VeryUtils JavaScript Bookshelf Slider is a jQuery Plugin.docx
VeryUtils JavaScript Bookshelf Slider is a jQuery Plugin.docxVeryUtils JavaScript Bookshelf Slider is a jQuery Plugin.docx
VeryUtils JavaScript Bookshelf Slider is a jQuery Plugin.docxLingwen1998
 
VeryUtils PHP Web File Manager is a best and useful file manager for web.docx
VeryUtils PHP Web File Manager is a best and useful file manager for web.docxVeryUtils PHP Web File Manager is a best and useful file manager for web.docx
VeryUtils PHP Web File Manager is a best and useful file manager for web.docxLingwen1998
 
VeryUtils EMF-Printer.docx
VeryUtils EMF-Printer.docxVeryUtils EMF-Printer.docx
VeryUtils EMF-Printer.docxLingwen1998
 
VeryUtils TIFF Toolkit is a powerful application tool which can compress TIFF...
VeryUtils TIFF Toolkit is a powerful application tool which can compress TIFF...VeryUtils TIFF Toolkit is a powerful application tool which can compress TIFF...
VeryUtils TIFF Toolkit is a powerful application tool which can compress TIFF...Lingwen1998
 
VeryUtils PDF to Word Converter SDK.docx
VeryUtils PDF to Word Converter SDK.docxVeryUtils PDF to Word Converter SDK.docx
VeryUtils PDF to Word Converter SDK.docxLingwen1998
 
VeryUtils QR code menu.docx
VeryUtils QR code menu.docxVeryUtils QR code menu.docx
VeryUtils QR code menu.docxLingwen1998
 
VeryUtils Online Survey Builder.docx
VeryUtils Online Survey Builder.docxVeryUtils Online Survey Builder.docx
VeryUtils Online Survey Builder.docxLingwen1998
 
VeryUtils HTML5 JavaScript Events Calendar Control is also an Events Schedule...
VeryUtils HTML5 JavaScript Events Calendar Control is also an Events Schedule...VeryUtils HTML5 JavaScript Events Calendar Control is also an Events Schedule...
VeryUtils HTML5 JavaScript Events Calendar Control is also an Events Schedule...Lingwen1998
 
VeryUtils HTML5 Excel is an Online Excel Application which written in JavaScr...
VeryUtils HTML5 Excel is an Online Excel Application which written in JavaScr...VeryUtils HTML5 Excel is an Online Excel Application which written in JavaScr...
VeryUtils HTML5 Excel is an Online Excel Application which written in JavaScr...Lingwen1998
 
VeryUtils PDF to HTML5 Form Filler for PHP does View.docx
VeryUtils PDF to HTML5 Form Filler for PHP does View.docxVeryUtils PDF to HTML5 Form Filler for PHP does View.docx
VeryUtils PDF to HTML5 Form Filler for PHP does View.docxLingwen1998
 
VeryUtils PDF to Word Converter SDK.docx
VeryUtils PDF to Word Converter SDK.docxVeryUtils PDF to Word Converter SDK.docx
VeryUtils PDF to Word Converter SDK.docxLingwen1998
 
VeryUtils Image to PDF Converter Command Line is a Windows Application which ...
VeryUtils Image to PDF Converter Command Line is a Windows Application which ...VeryUtils Image to PDF Converter Command Line is a Windows Application which ...
VeryUtils Image to PDF Converter Command Line is a Windows Application which ...Lingwen1998
 

More from Lingwen1998 (20)

VeryUtils HTMLPrint to Any Converter Command Line is a versatile tool that st...
VeryUtils HTMLPrint to Any Converter Command Line is a versatile tool that st...VeryUtils HTMLPrint to Any Converter Command Line is a versatile tool that st...
VeryUtils HTMLPrint to Any Converter Command Line is a versatile tool that st...
 
VeryUtils File Manager is a powerful file management tool that allows you to ...
VeryUtils File Manager is a powerful file management tool that allows you to ...VeryUtils File Manager is a powerful file management tool that allows you to ...
VeryUtils File Manager is a powerful file management tool that allows you to ...
 
Convert SVG to PDF via CLI (command-line interface) and streamline your data ...
Convert SVG to PDF via CLI (command-line interface) and streamline your data ...Convert SVG to PDF via CLI (command-line interface) and streamline your data ...
Convert SVG to PDF via CLI (command-line interface) and streamline your data ...
 
VeryUtils Java PDF Command Line SDK API for Developers Royalty Free.pdf
VeryUtils Java PDF Command Line SDK API for Developers Royalty Free.pdfVeryUtils Java PDF Command Line SDK API for Developers Royalty Free.pdf
VeryUtils Java PDF Command Line SDK API for Developers Royalty Free.pdf
 
VeryPDF .NET PDF Editor SDK for Developers Royalty Free _ VeryPDF Knowledge B...
VeryPDF .NET PDF Editor SDK for Developers Royalty Free _ VeryPDF Knowledge B...VeryPDF .NET PDF Editor SDK for Developers Royalty Free _ VeryPDF Knowledge B...
VeryPDF .NET PDF Editor SDK for Developers Royalty Free _ VeryPDF Knowledge B...
 
VeryUtils BatchPrint is a batch printing software for Windows to batch print ...
VeryUtils BatchPrint is a batch printing software for Windows to batch print ...VeryUtils BatchPrint is a batch printing software for Windows to batch print ...
VeryUtils BatchPrint is a batch printing software for Windows to batch print ...
 
VeryUtils PDF Command Line Tools and API for Java.docx
VeryUtils PDF Command Line Tools and API for Java.docxVeryUtils PDF Command Line Tools and API for Java.docx
VeryUtils PDF Command Line Tools and API for Java.docx
 
VeryUtils OCR to Any Converter SDK can be used to convert scanned PDF.docx
VeryUtils OCR to Any Converter SDK can be used to convert scanned PDF.docxVeryUtils OCR to Any Converter SDK can be used to convert scanned PDF.docx
VeryUtils OCR to Any Converter SDK can be used to convert scanned PDF.docx
 
VeryUtils JavaScript Bookshelf Slider is a jQuery Plugin.docx
VeryUtils JavaScript Bookshelf Slider is a jQuery Plugin.docxVeryUtils JavaScript Bookshelf Slider is a jQuery Plugin.docx
VeryUtils JavaScript Bookshelf Slider is a jQuery Plugin.docx
 
VeryUtils PHP Web File Manager is a best and useful file manager for web.docx
VeryUtils PHP Web File Manager is a best and useful file manager for web.docxVeryUtils PHP Web File Manager is a best and useful file manager for web.docx
VeryUtils PHP Web File Manager is a best and useful file manager for web.docx
 
VeryUtils EMF-Printer.docx
VeryUtils EMF-Printer.docxVeryUtils EMF-Printer.docx
VeryUtils EMF-Printer.docx
 
VeryUtils TIFF Toolkit is a powerful application tool which can compress TIFF...
VeryUtils TIFF Toolkit is a powerful application tool which can compress TIFF...VeryUtils TIFF Toolkit is a powerful application tool which can compress TIFF...
VeryUtils TIFF Toolkit is a powerful application tool which can compress TIFF...
 
VeryUtils PDF to Word Converter SDK.docx
VeryUtils PDF to Word Converter SDK.docxVeryUtils PDF to Word Converter SDK.docx
VeryUtils PDF to Word Converter SDK.docx
 
VeryUtils QR code menu.docx
VeryUtils QR code menu.docxVeryUtils QR code menu.docx
VeryUtils QR code menu.docx
 
VeryUtils Online Survey Builder.docx
VeryUtils Online Survey Builder.docxVeryUtils Online Survey Builder.docx
VeryUtils Online Survey Builder.docx
 
VeryUtils HTML5 JavaScript Events Calendar Control is also an Events Schedule...
VeryUtils HTML5 JavaScript Events Calendar Control is also an Events Schedule...VeryUtils HTML5 JavaScript Events Calendar Control is also an Events Schedule...
VeryUtils HTML5 JavaScript Events Calendar Control is also an Events Schedule...
 
VeryUtils HTML5 Excel is an Online Excel Application which written in JavaScr...
VeryUtils HTML5 Excel is an Online Excel Application which written in JavaScr...VeryUtils HTML5 Excel is an Online Excel Application which written in JavaScr...
VeryUtils HTML5 Excel is an Online Excel Application which written in JavaScr...
 
VeryUtils PDF to HTML5 Form Filler for PHP does View.docx
VeryUtils PDF to HTML5 Form Filler for PHP does View.docxVeryUtils PDF to HTML5 Form Filler for PHP does View.docx
VeryUtils PDF to HTML5 Form Filler for PHP does View.docx
 
VeryUtils PDF to Word Converter SDK.docx
VeryUtils PDF to Word Converter SDK.docxVeryUtils PDF to Word Converter SDK.docx
VeryUtils PDF to Word Converter SDK.docx
 
VeryUtils Image to PDF Converter Command Line is a Windows Application which ...
VeryUtils Image to PDF Converter Command Line is a Windows Application which ...VeryUtils Image to PDF Converter Command Line is a Windows Application which ...
VeryUtils Image to PDF Converter Command Line is a Windows Application which ...
 

Recently uploaded

Your Ultimate Web Studio for Streaming Anywhere | Evmux
Your Ultimate Web Studio for Streaming Anywhere | EvmuxYour Ultimate Web Studio for Streaming Anywhere | Evmux
Your Ultimate Web Studio for Streaming Anywhere | Evmuxevmux96
 
Weeding your micro service landscape.pdf
Weeding your micro service landscape.pdfWeeding your micro service landscape.pdf
Weeding your micro service landscape.pdftimtebeek1
 
Microsoft365_Dev_Security_2024_05_16.pdf
Microsoft365_Dev_Security_2024_05_16.pdfMicrosoft365_Dev_Security_2024_05_16.pdf
Microsoft365_Dev_Security_2024_05_16.pdfMarkus Moeller
 
Software Engineering - Introduction + Process Models + Requirements Engineering
Software Engineering - Introduction + Process Models + Requirements EngineeringSoftware Engineering - Introduction + Process Models + Requirements Engineering
Software Engineering - Introduction + Process Models + Requirements EngineeringPrakhyath Rai
 
The mythical technical debt. (Brooke, please, forgive me)
The mythical technical debt. (Brooke, please, forgive me)The mythical technical debt. (Brooke, please, forgive me)
The mythical technical debt. (Brooke, please, forgive me)Roberto Bettazzoni
 
Community is Just as Important as Code by Andrea Goulet
Community is Just as Important as Code by Andrea GouletCommunity is Just as Important as Code by Andrea Goulet
Community is Just as Important as Code by Andrea GouletAndrea Goulet
 
Navigation in flutter – how to add stack, tab, and drawer navigators to your ...
Navigation in flutter – how to add stack, tab, and drawer navigators to your ...Navigation in flutter – how to add stack, tab, and drawer navigators to your ...
Navigation in flutter – how to add stack, tab, and drawer navigators to your ...Flutter Agency
 
BusinessGPT - Security and Governance for Generative AI
BusinessGPT  - Security and Governance for Generative AIBusinessGPT  - Security and Governance for Generative AI
BusinessGPT - Security and Governance for Generative AIAGATSoftware
 
[GeeCON2024] How I learned to stop worrying and love the dark silicon apocalypse
[GeeCON2024] How I learned to stop worrying and love the dark silicon apocalypse[GeeCON2024] How I learned to stop worrying and love the dark silicon apocalypse
[GeeCON2024] How I learned to stop worrying and love the dark silicon apocalypseTomasz Kowalczewski
 
AzureNativeQumulo_HPC_Cloud_Native_Benchmarks.pdf
AzureNativeQumulo_HPC_Cloud_Native_Benchmarks.pdfAzureNativeQumulo_HPC_Cloud_Native_Benchmarks.pdf
AzureNativeQumulo_HPC_Cloud_Native_Benchmarks.pdfryanfarris8
 
Workshop: Enabling GenAI Breakthroughs with Knowledge Graphs - GraphSummit Milan
Workshop: Enabling GenAI Breakthroughs with Knowledge Graphs - GraphSummit MilanWorkshop: Enabling GenAI Breakthroughs with Knowledge Graphs - GraphSummit Milan
Workshop: Enabling GenAI Breakthroughs with Knowledge Graphs - GraphSummit MilanNeo4j
 
Encryption Recap: A Refresher on Key Concepts
Encryption Recap: A Refresher on Key ConceptsEncryption Recap: A Refresher on Key Concepts
Encryption Recap: A Refresher on Key Conceptsthomashtkim
 
OpenChain Webinar: AboutCode and Beyond - End-to-End SCA
OpenChain Webinar: AboutCode and Beyond - End-to-End SCAOpenChain Webinar: AboutCode and Beyond - End-to-End SCA
OpenChain Webinar: AboutCode and Beyond - End-to-End SCAShane Coughlan
 
Modern binary build systems - PyCon 2024
Modern binary build systems - PyCon 2024Modern binary build systems - PyCon 2024
Modern binary build systems - PyCon 2024Henry Schreiner
 
GraphSummit Milan - Visione e roadmap del prodotto Neo4j
GraphSummit Milan - Visione e roadmap del prodotto Neo4jGraphSummit Milan - Visione e roadmap del prodotto Neo4j
GraphSummit Milan - Visione e roadmap del prodotto Neo4jNeo4j
 
UNI DI NAPOLI FEDERICO II - Il ruolo dei grafi nell'AI Conversazionale Ibrida
UNI DI NAPOLI FEDERICO II - Il ruolo dei grafi nell'AI Conversazionale IbridaUNI DI NAPOLI FEDERICO II - Il ruolo dei grafi nell'AI Conversazionale Ibrida
UNI DI NAPOLI FEDERICO II - Il ruolo dei grafi nell'AI Conversazionale IbridaNeo4j
 
Wired_2.0_CREATE YOUR ULTIMATE LEARNING ENVIRONMENT_JCON_16052024
Wired_2.0_CREATE YOUR ULTIMATE LEARNING ENVIRONMENT_JCON_16052024Wired_2.0_CREATE YOUR ULTIMATE LEARNING ENVIRONMENT_JCON_16052024
Wired_2.0_CREATE YOUR ULTIMATE LEARNING ENVIRONMENT_JCON_16052024SimonedeGijt
 
[GRCPP] Introduction to concepts (C++20)
[GRCPP] Introduction to concepts (C++20)[GRCPP] Introduction to concepts (C++20)
[GRCPP] Introduction to concepts (C++20)Dimitrios Platis
 
GraphSummit Milan - Neo4j: The Art of the Possible with Graph
GraphSummit Milan - Neo4j: The Art of the Possible with GraphGraphSummit Milan - Neo4j: The Art of the Possible with Graph
GraphSummit Milan - Neo4j: The Art of the Possible with GraphNeo4j
 

Recently uploaded (20)

Your Ultimate Web Studio for Streaming Anywhere | Evmux
Your Ultimate Web Studio for Streaming Anywhere | EvmuxYour Ultimate Web Studio for Streaming Anywhere | Evmux
Your Ultimate Web Studio for Streaming Anywhere | Evmux
 
Weeding your micro service landscape.pdf
Weeding your micro service landscape.pdfWeeding your micro service landscape.pdf
Weeding your micro service landscape.pdf
 
Microsoft365_Dev_Security_2024_05_16.pdf
Microsoft365_Dev_Security_2024_05_16.pdfMicrosoft365_Dev_Security_2024_05_16.pdf
Microsoft365_Dev_Security_2024_05_16.pdf
 
Software Engineering - Introduction + Process Models + Requirements Engineering
Software Engineering - Introduction + Process Models + Requirements EngineeringSoftware Engineering - Introduction + Process Models + Requirements Engineering
Software Engineering - Introduction + Process Models + Requirements Engineering
 
The mythical technical debt. (Brooke, please, forgive me)
The mythical technical debt. (Brooke, please, forgive me)The mythical technical debt. (Brooke, please, forgive me)
The mythical technical debt. (Brooke, please, forgive me)
 
Community is Just as Important as Code by Andrea Goulet
Community is Just as Important as Code by Andrea GouletCommunity is Just as Important as Code by Andrea Goulet
Community is Just as Important as Code by Andrea Goulet
 
Navigation in flutter – how to add stack, tab, and drawer navigators to your ...
Navigation in flutter – how to add stack, tab, and drawer navigators to your ...Navigation in flutter – how to add stack, tab, and drawer navigators to your ...
Navigation in flutter – how to add stack, tab, and drawer navigators to your ...
 
BusinessGPT - Security and Governance for Generative AI
BusinessGPT  - Security and Governance for Generative AIBusinessGPT  - Security and Governance for Generative AI
BusinessGPT - Security and Governance for Generative AI
 
[GeeCON2024] How I learned to stop worrying and love the dark silicon apocalypse
[GeeCON2024] How I learned to stop worrying and love the dark silicon apocalypse[GeeCON2024] How I learned to stop worrying and love the dark silicon apocalypse
[GeeCON2024] How I learned to stop worrying and love the dark silicon apocalypse
 
Abortion Clinic In Pongola ](+27832195400*)[ 🏥 Safe Abortion Pills In Pongola...
Abortion Clinic In Pongola ](+27832195400*)[ 🏥 Safe Abortion Pills In Pongola...Abortion Clinic In Pongola ](+27832195400*)[ 🏥 Safe Abortion Pills In Pongola...
Abortion Clinic In Pongola ](+27832195400*)[ 🏥 Safe Abortion Pills In Pongola...
 
AzureNativeQumulo_HPC_Cloud_Native_Benchmarks.pdf
AzureNativeQumulo_HPC_Cloud_Native_Benchmarks.pdfAzureNativeQumulo_HPC_Cloud_Native_Benchmarks.pdf
AzureNativeQumulo_HPC_Cloud_Native_Benchmarks.pdf
 
Workshop: Enabling GenAI Breakthroughs with Knowledge Graphs - GraphSummit Milan
Workshop: Enabling GenAI Breakthroughs with Knowledge Graphs - GraphSummit MilanWorkshop: Enabling GenAI Breakthroughs with Knowledge Graphs - GraphSummit Milan
Workshop: Enabling GenAI Breakthroughs with Knowledge Graphs - GraphSummit Milan
 
Encryption Recap: A Refresher on Key Concepts
Encryption Recap: A Refresher on Key ConceptsEncryption Recap: A Refresher on Key Concepts
Encryption Recap: A Refresher on Key Concepts
 
OpenChain Webinar: AboutCode and Beyond - End-to-End SCA
OpenChain Webinar: AboutCode and Beyond - End-to-End SCAOpenChain Webinar: AboutCode and Beyond - End-to-End SCA
OpenChain Webinar: AboutCode and Beyond - End-to-End SCA
 
Modern binary build systems - PyCon 2024
Modern binary build systems - PyCon 2024Modern binary build systems - PyCon 2024
Modern binary build systems - PyCon 2024
 
GraphSummit Milan - Visione e roadmap del prodotto Neo4j
GraphSummit Milan - Visione e roadmap del prodotto Neo4jGraphSummit Milan - Visione e roadmap del prodotto Neo4j
GraphSummit Milan - Visione e roadmap del prodotto Neo4j
 
UNI DI NAPOLI FEDERICO II - Il ruolo dei grafi nell'AI Conversazionale Ibrida
UNI DI NAPOLI FEDERICO II - Il ruolo dei grafi nell'AI Conversazionale IbridaUNI DI NAPOLI FEDERICO II - Il ruolo dei grafi nell'AI Conversazionale Ibrida
UNI DI NAPOLI FEDERICO II - Il ruolo dei grafi nell'AI Conversazionale Ibrida
 
Wired_2.0_CREATE YOUR ULTIMATE LEARNING ENVIRONMENT_JCON_16052024
Wired_2.0_CREATE YOUR ULTIMATE LEARNING ENVIRONMENT_JCON_16052024Wired_2.0_CREATE YOUR ULTIMATE LEARNING ENVIRONMENT_JCON_16052024
Wired_2.0_CREATE YOUR ULTIMATE LEARNING ENVIRONMENT_JCON_16052024
 
[GRCPP] Introduction to concepts (C++20)
[GRCPP] Introduction to concepts (C++20)[GRCPP] Introduction to concepts (C++20)
[GRCPP] Introduction to concepts (C++20)
 
GraphSummit Milan - Neo4j: The Art of the Possible with Graph
GraphSummit Milan - Neo4j: The Art of the Possible with GraphGraphSummit Milan - Neo4j: The Art of the Possible with Graph
GraphSummit Milan - Neo4j: The Art of the Possible with Graph
 

VeryUtils SudokuJS JavaScript Sudoku solver.docx

  • 1. VeryUtils SudokuJS JavaScript Sudoku solver. VeryUtils SudokuJS has a step by step solver that implements basic strategies, enough to solve (non evil) newspaper sudoku puzzles. The solver is built to mimic humans in that it attempts strategies in order from easiest to most difficult, in each step. So if you're stuck with a puzzle this solver will show you the minimal next step to continue. https://veryutils.com/sudokujs-javascript-sudoku-solver VeryUtils SudokuJS comes with a basic GUI for the sudoku board - the board is rendered on the screen, and the board cells listen for keyboard input from a user. VeryUtils SudokuJS can generate sudoku puzzles of the same difficulties that it can solve, ranging from Easy to Very hard. VeryUtils SudokuJS currently requires jQuery library. ### Run Demo Online VeryUtils SudokuJS (4x4) - Introductory Sudoku : demo-board-size-4.html VeryUtils SudokuJS (9x9) - Demo with controls: demo-edit-candidates.html VeryUtils SudokuJS (9x9) - Demo with board generation: demo-generate-board.html VeryUtils SudokuJS (9x9) - Simple demo: demo-simple.html
  • 2. VeryUtils SudokuJS (9x9) - Demo with controls: demo-w-controls.html VeryUtils SudokuJS (16x16) - Professional Sudoku : demo-board-size-16.html ### Usage #### Initialization [script src='VeryUtils SudokuJS.js'][/script] [link rel='stylesheet' href='VeryUtils SudokuJS.css' /] [div id='sudoku'][/div] [script] var myVeryUtils SudokuJS = $("#sudoku").VeryUtils SudokuJS({ difficulty: "medium" ("easy"|"medium"|"hard"|"very hard") }); [/script] You can also pass in your own board: //array representing a standard sudoku puzzle of size 9 //use space for empty cells var board = [ , , ,4, ,8, ,2,9 , , , , , , , , ,4 ,8,5, , ,2, , , ,7 , , ,8,3,7,4,2, , , ,2, , , , , , , , , ,3,2,6,1,7, , , , , , ,9,3,6,1,2 ,2, , , , , ,4, ,3 ,1,3, ,6,4,2, ,7,undefined
  • 3. ] //NOTE: if last cell of board is empty, 'undefined' has to be used as value! var myVeryUtils SudokuJS = $("#sudoku").VeryUtils SudokuJS({ board: board }); #### Solving Let `VeryUtils SudokuJS` solve your puzzle - either step by step, or all in one go: myVeryUtils SudokuJS.solveStep(); myVeryUtils SudokuJS.solveAll(); #### Analyzing the board The solver can tell you info about the board. var data = myVeryUtils SudokuJS.analyzeBoard(); //data.error -- board is incorrect //data.finished === false -- board can't be solved because it requires more advanced strategies //if no error, and data.finished === true //data.level -- "easy"|"medium"|"hard" //data.score -- int [experimental] //data.usedStrategies -- [{title, freq}, ..],ranked by difficulty, easiest first #### Board Generation `VeryUtils SudokuJS` generate new sudoku puzzles on init when no board is passed in, and on `generateBoard` calls: myVeryUtils SudokuJS.generateBoard('easy'); myVeryUtils SudokuJS.generateBoard('medium');
  • 4. myVeryUtils SudokuJS.generateBoard('hard'); myVeryUtils SudokuJS.generateBoard('very hard'); The current implementation for board generation cannot guarantee hard or very hard puzzles generated on every try, so instead it continues over and over until is has succeeded. This means loading a very hard board can sometimes take up to a few seconds. `generateBoard` accepts a `callback` function as a second parameter, that gets called when the new board is ready. #### Candidates Candidates are hidden when a board loads. To show/hide candidates: myVeryUtils SudokuJS.showCandidates(); myVeryUtils SudokuJS.hideCandidates(); VeryUtils SudokuJS automatically removes impossible candidates on showCandidates(); candidates that can be eliminated via visualElimination (number already exists in same house). Candidates can be edited on the board by setting VeryUtils SudokuJS to candidate editing mode: myVeryUtils SudokuJS.setEditingCandidates(true); Input changes on board cells will now toggle the candidates rather than changes the value. #### Clear board Useful before entering new puzzle, if using keyboard input in the GUI. myVeryUtils SudokuJS.clearBoard(); #### Get/Set board
  • 5. Get the board and save it away if you want. Set a new board and play with that one instead. Setting automatically resets everything back to init state. myVeryUtils SudokuJS.getBoard(); var newBoard = [ ... ] myVeryUtils SudokuJS.setBoard(newBoard); ### Callbacks #### boardUpdatedFn Fires whenever the board is updated, whether by user or solver. $("#sudoku").VeryUtils SudokuJS({ board: board ,boardUpdatedFn: function(data){ //data.cause: "user input" | name of strategy used //data.cellsUpdated: [] of indexes for cells updated alert("board was updated!"); } }); #### boardFinishedFn Fires when the board has been completed. $("#sudoku").VeryUtils SudokuJS({ board: board ,boardFinishedFn: function(data){
  • 6. //ONLY IF board was solved by solver: //data.difficultyInfo { // level: "easy", "medium", "hard" // ,score: int [experimental] //} alert("board was finished!"); } }); #### boardErrorFn Fires whenever the board is found to be incorrect, f.e. if solver detects there is no solution to board, or if passed in board is of invalid size. $("#sudoku").VeryUtils SudokuJS({ board: board ,boardErrorFn: function(data){ //data.msg -- f.e. "board incorrect" alert("board error!"); } }); #### candidateShowToggleFn The solver automatically switches to showing candidates when a solve step was invoked which only updated the candidates on the board. To catch this change (for updating UI, etc), there is a callback: $("#sudoku").VeryUtils SudokuJS({ board: board ,candidateShowToggleFn: function(showingBoolean){ alert("candidates showing: " + showingBoolean); //true|false }
  • 7. } ### Extra The solver is board size agnostic, so you can pass in any valid sudoku sized board (f.e. 4x4, 9x9, 16x16) - however the CSS included only handles 9x9 boards. Currently you can't change boardSize after init. ### Changelog * boardSize option, now working. Demos for board sizes * Candidate editing mode * Board generator, easy - very hard * Simple UI and better interface * Step by step sudoku solver