0
0
mirror of https://github.com/tursodatabase/libsql.git synced 2025-06-08 01:24:21 +00:00
Files
.cargo
.github
bindings
bottomless
bottomless-cli
docker-compose
docs
libsql
libsql-ffi
libsql-hrana
libsql-replication
libsql-server
libsql-shell
libsql-sqlite3
art
autoconf
contrib
crates
doc
ext
async
crr
expert
fts3
fts5
icu
jni
libsql-wasi
lsm1
misc
rbu
recover
repair
rtree
session
udf
userauth
vwal
wasi
wasm
SQLTester
api
common
fiddle
jaccwabyt
sql
000-mandelbrot.sql
001-sudoku.sql
tests
EXPORTED_FUNCTIONS.fiddle.in
GNUmakefile
README-dist.txt
README.md
batch-runner.html
batch-runner.js
c-pp.c
demo-123-worker.html
demo-123.html
demo-123.js
demo-jsstorage.html
demo-jsstorage.js
demo-worker1-promiser.html
demo-worker1-promiser.js
demo-worker1.html
demo-worker1.js
dist.make
example_extra_init.c
fiddle.make
index-dist.html
index.html
module-symbols.html
scratchpad-wasmfs.html
scratchpad-wasmfs.mjs
speedtest1-wasmfs.html
speedtest1-wasmfs.mjs
speedtest1-worker.html
speedtest1-worker.js
speedtest1.html
split-speedtest1-script.sh
test-opfs-vfs.html
test-opfs-vfs.js
tester1-worker.html
tester1.c-pp.html
tester1.c-pp.js
wasmfs.make
README.md
mptest
src
test
tool
vsixtest
.gitignore
Dockerfile-wasm-udf
LIBSQL_VERSION
LICENSE.md
Makefile.in
Makefile.linux-gcc
Makefile.msc
README-SQLite.md
VERSION
aclocal.m4
config.guess
config.sub
configure
configure.ac
install-sh
libsql.pc.in
ltmain.sh
magic.txt
main.mk
manifest
manifest.uuid
spec.template
sqlite.pc.in
sqlite3.1
sqlite3.pc.in
sqlite_cfg.h.in
libsql-sys
tools
vendored
xtask
.dockerignore
.env
.gitignore
.gitmodules
CODE_OF_CONDUCT.md
Cargo.lock
Cargo.toml
Dockerfile
Dockerfile.dev
LICENSE.md
README-libsql.md
README.md
docker-entrypoint.sh
fly.toml
rust-toolchain.toml
libsql/libsql-sqlite3/ext/wasm/sql/001-sudoku.sql
2023-10-16 13:58:16 +02:00

29 lines
892 B
SQL

WITH RECURSIVE
input(sud) AS (
VALUES('53..7....6..195....98....6.8...6...34..8.3..17...2...6.6....28....419..5....8..79')
),
digits(z, lp) AS (
VALUES('1', 1)
UNION ALL SELECT
CAST(lp+1 AS TEXT), lp+1 FROM digits WHERE lp<9
),
x(s, ind) AS (
SELECT sud, instr(sud, '.') FROM input
UNION ALL
SELECT
substr(s, 1, ind-1) || z || substr(s, ind+1),
instr( substr(s, 1, ind-1) || z || substr(s, ind+1), '.' )
FROM x, digits AS z
WHERE ind>0
AND NOT EXISTS (
SELECT 1
FROM digits AS lp
WHERE z.z = substr(s, ((ind-1)/9)*9 + lp, 1)
OR z.z = substr(s, ((ind-1)%9) + (lp-1)*9 + 1, 1)
OR z.z = substr(s, (((ind-1)/3) % 3) * 3
+ ((ind-1)/27) * 27 + lp
+ ((lp-1) / 3) * 6, 1)
)
)
SELECT s FROM x WHERE ind=0;