Commit Graph

16 Commits

Author SHA1 Message Date
9ee76b10fa Add USE_WORKER_THREADS environment var 2021-03-05 12:56:20 -07:00
15b69c510c Add solve endpoint
Also implement currently unused solveSync and generateSync methods,
useful for testing/debugging.

Add static get() to SudokuMath which returns cached SudokuMath
instances.
2021-03-05 12:32:02 -07:00
4e6cdab9ee Return blank array when requested clues == 0 2021-03-04 21:35:25 -07:00
8526dcd083 optimize generate()
Before we masked all except the removed cell rows, then unmasked all
rows on every removal attempt.

Now, we mask all except the removed cell rows once each attempt in an
order such that we can simply unmask the last (values - 1) rows to try
the next cell. An unmask/remask cycle is only required when a removal
attempt fails.
2021-03-03 23:15:55 -07:00
938954d621 Log the number of dancing link updates 2021-03-03 18:18:15 -07:00
058dc13c1c Simplified selectColumnSizeHeuristic 2021-02-25 11:30:20 -07:00
18e468b17f Update Dockerfile 2021-02-25 11:30:20 -07:00
24d8ab6763 Update all imports to .js for esm support, use threads.js
threads.js has better support for modules - no need to give a
project-relative path to the worker file, which complicated the build.

Add rudimentary thread pooling w/ execution timeout.
2021-02-25 11:30:20 -07:00
e54f4c42f1 Update tsconfig, package.json to run in full ESM mode 2021-02-25 00:30:09 -07:00
a66a20b647 Cell = number instead of object, return flat array 2021-02-23 18:19:57 -07:00
c16a68e796 Use 0 instead of null to represent no value 2021-02-23 16:50:17 -07:00
09f740f86a Add cors 2021-02-23 16:47:58 -07:00
8f3217f3cc Implement Algorithm X for solving and generating sudokus 2021-02-22 20:03:47 -07:00
7ac3e6ad06 Use worker threads for sudoku generation
Moves sudoku generation off of the main thread. Allows for multiple
generation requests (up to the number of physical CPU cores) to be
served in parallel. Uses the "physical-cpu-count" node package to
determine the numer of physical CPUs of the host.

Also introduces a timeout which causes too-difficult (or impossible)
generation requests to fail if they take more than 5 seconds to
complete. In effect soft-capping the complexity of generated puzzles.
2021-02-20 18:57:18 -07:00
7f9cffbfdd initial commit 2021-02-19 23:55:49 -07:00
e13b4d737b root commit 2021-02-19 18:29:51 -07:00