From d250a8a6764bb71b35f0799a1381725e93ea1485 Mon Sep 17 00:00:00 2001 From: Hao Zhang Date: Wed, 26 Nov 2025 13:25:21 +0800 Subject: [PATCH] Update docs, add sudoku as an example. --- docs/examples/Sudoku.ejs | 144 ++++++++++ docs/examples/Sudoku.vue | 393 +++++++++++++++++++++++++++ docs/examples/{index.md => basic.md} | 2 +- docs/examples/sudoku.md | 27 ++ mkdocs.yml | 3 +- 5 files changed, 567 insertions(+), 2 deletions(-) create mode 100644 docs/examples/Sudoku.ejs create mode 100644 docs/examples/Sudoku.vue rename docs/examples/{index.md => basic.md} (99%) create mode 100644 docs/examples/sudoku.md diff --git a/docs/examples/Sudoku.ejs b/docs/examples/Sudoku.ejs new file mode 100644 index 0000000..7e9ad11 --- /dev/null +++ b/docs/examples/Sudoku.ejs @@ -0,0 +1,144 @@ +<%# 等价关系 %> + +<% +for (let i = 1; i <= 9; i++) { + for (let j = 1; j <= 9; j++) { + if (i === j) { +%> +<%- `(${i} = ${j})` %> +<% +} else { +%> +<%- `(${i} != ${j})` %> +<% +} +} +} +%> + +<%# 相等与不等 %> + +((Cell `x `y) = (Literal `a)) +(`a != `b) +---------- +((Cell `x `y) != (Literal `b)) + +<% +for (let i = 1; i <= 9; i++) { + for (let j = 1; j <= 9; j++) { + if (i !== j) { +-%> +<%- `((Cell \`x \`y) != (Literal ${j}))` %> +<% +} +} +-%> +-------------------------------------- +<%- `((Cell \`x \`y) = (Literal ${i}))` %> + +<% +} +%> + +<%# 数独行列 %> + +((Cell `x `y) = `n) +(`x != `x') +--------------------- +((Cell `x' `y) != `n) + +((Cell `x `y) = `n) +(`y != `y') +--------------------- +((Cell `x `y') != `n) + +<% +for (let i = 1; i <= 9; i++) { + for (let j = 1; j <= 9; j++) { + if (i !== j) { +-%> +<%- `((Cell \`x ${j}) != \`n)` %> +<% +} +} +-%> +------------------------------------- +<%- `((Cell \`x ${i}) = \`n)` %> + +<% +} +%> + +<% +for (let i = 1; i <= 9; i++) { + for (let j = 1; j <= 9; j++) { + if (i !== j) { +-%> +<%- `((Cell ${j} \`y) != \`n)` %> +<% +} +} +-%> +------------------------------------- +<%- `((Cell ${i} \`y) = \`n)` %> + +<% +} +%> + +<%# 数独分块 %> + +<% +for (let ib = 1; ib <= 3; ib++) { + for (let jb = 1; jb <= 3; jb++) { + for (let it = 1; it <= 3; it++) { + for (let jt = 1; jt <= 3; jt++) { + const xt = (ib - 1) * 3 + it; + const yt = (jb - 1) * 3 + jt; + for (let i = 1; i <= 3; i++) { + for (let j = 1; j <= 3; j++) { + const x = (ib - 1) * 3 + i; + const y = (jb - 1) * 3 + j; + if (i !== it || j !== jt) { +%> +<%- `((Cell ${x} ${y}) = \`n)` %> +------------------------------------ +<%- `((Cell ${xt} ${yt}) != \`n)` %> +<% +} +} +} +} +} +} +} +%> + +<% +for (let ib = 1; ib <= 3; ib++) { + for (let jb = 1; jb <= 3; jb++) { + for (let it = 1; it <= 3; it++) { + for (let jt = 1; jt <= 3; jt++) { + const xt = (ib - 1) * 3 + it; + const yt = (jb - 1) * 3 + jt; + for (let i = 1; i <= 3; i++) { + for (let j = 1; j <= 3; j++) { + const x = (ib - 1) * 3 + i; + const y = (jb - 1) * 3 + j; + if (i !== it || j !== jt) { +-%> +<%- `((Cell ${x} ${y}) != \`n)` %> +<% +} +} +} +-%> +-------------------------------------- +<%- `((Cell ${xt} ${yt}) = \`n)` %> + +<% +} +} +} +} +%> diff --git a/docs/examples/Sudoku.vue b/docs/examples/Sudoku.vue new file mode 100644 index 0000000..9e8eeb3 --- /dev/null +++ b/docs/examples/Sudoku.vue @@ -0,0 +1,393 @@ + + + + + diff --git a/docs/examples/index.md b/docs/examples/basic.md similarity index 99% rename from docs/examples/index.md rename to docs/examples/basic.md index 829acaf..850c57a 100644 --- a/docs/examples/index.md +++ b/docs/examples/basic.md @@ -1,4 +1,4 @@ -# Examples +# Basic Examples This section contains examples demonstrating the DS deductive system in various languages. diff --git a/docs/examples/sudoku.md b/docs/examples/sudoku.md new file mode 100644 index 0000000..a038fc7 --- /dev/null +++ b/docs/examples/sudoku.md @@ -0,0 +1,27 @@ +# Sudoku + +
+ + diff --git a/mkdocs.yml b/mkdocs.yml index 6db0f83..e103476 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -60,7 +60,8 @@ nav: - Python API: api/python.md - C++ API: api/cpp.md - Examples: - - examples/index.md + - Basis Examples: examples/basic.md + - Sudoku: examples/sudoku.md plugins: - offline