Sudoku
Overview
Fetch, render, and reveal Sudoku puzzles. Use sudoku.py to get new puzzles from sudokuonline.io, generate printable PDFs or images, and reveal solutions.
For details on the saved JSON format, see DATA_FORMAT.md.
Available Puzzle Types
- *
kids4n: Kids 4x4 - INLINECODE3 : Kids 4x4 with Letters
- INLINECODE4 : Kids 6x6
- INLINECODE5 : Kids 6x6 with Letters
- INLINECODE6 : Classic 9x9 (Easy)
- INLINECODE7 : Classic 9x9 (Medium)
- INLINECODE8 : Classic 9x9 (Hard)
- INLINECODE9 : Classic 9x9 (Evil)
Setup / Requirements
- - Binaries: INLINECODE10
- Python libs:
CODEBLOCK0
Get a Puzzle
Fetches a new puzzle and stores it as JSON. Output is JSON by default (use --text for human-readable output).
Use --count N to fetch/store multiple puzzles in one call. If a batch does not contain enough unseen puzzles, the command will fetch additional batches until it has enough.
Use --id <fragment> to select a specific source puzzle by matching any unique part of its UUID. If multiple IDs match, the command errors and lists candidates.
Get a Classic Easy puzzle:
CODEBLOCK1
Get multiple new puzzles at once (e.g. 4 easy 9x9):
CODEBLOCK2
Get a Kids 6x6 puzzle:
CODEBLOCK3
Render Puzzle
Render a puzzle as an image, PDF, or minimal HTML.
Render latest puzzle as A4 PDF (for printing):
CODEBLOCK4
Render latest puzzle as clean PNG (for viewing):
CODEBLOCK5
Render a specific previous puzzle by short ID:
CODEBLOCK6
Render minimal HTML (square cells + bold box lines):
CODEBLOCK7
Reveal Solution
Reveal the solution for the latest or specific puzzle. Use --id <short_id> (e.g., a09f3680) to target a specific puzzle.
Reveal full solution as printable PDF:
CODEBLOCK8
Reveal full solution for a specific ID:
CODEBLOCK9
Reveal full solution as PNG image:
CODEBLOCK10
Reveal a single cell (row 3, column 7):
CODEBLOCK11
Reveal a specific 3x3 box (index 5):
CODEBLOCK12
Share Link
Generate a share link for a stored puzzle. Targets the latest puzzle by default; use --id <short_id> for a specific one.
Generate a SudokuPad share link (default):
CODEBLOCK13
Generate link for specific ID:
CODEBLOCK14
Generate an SCL share link:
CODEBLOCK15
Telegram Formatting Tip:
Format links as a short button-style link and hide the full URL: [Easy Classic \[<id>\]](<url>).
数独
概述
获取、渲染和揭示数独谜题。使用 sudoku.py 从 sudokuonline.io 获取新谜题,生成可打印的 PDF 或图片,并显示答案。
关于保存的 JSON 格式详情,请参阅 DATA_FORMAT.md。
可用谜题类型
- * kids4n:儿童 4x4
- kids4l:儿童 4x4 字母版
- kids6:儿童 6x6
- kids6l:儿童 6x6 字母版
- easy9:经典 9x9(简单)
- medium9:经典 9x9(中等)
- hard9:经典 9x9(困难)
- evil9:经典 9x9(极难)
设置/依赖
bash
python3 -m pip install requests Pillow lzstring
获取谜题
获取新谜题并以 JSON 格式存储。默认输出为 JSON(使用 --text 可输出人类可读格式)。
使用 --count N 可在一次调用中获取/存储多个谜题。如果一批数据中没有足够的新谜题,命令将自动获取更多批次直至满足数量。
使用 --id <片段> 可通过匹配 UUID 的唯一部分来选择特定源谜题。如果多个 ID 匹配,命令将报错并列出候选。
获取经典简单谜题:
bash
./scripts/sudoku.py get easy9
一次获取多个新谜题(例如 4 个简单 9x9):
bash
./scripts/sudoku.py get easy9 --count 4
获取儿童 6x6 谜题:
bash
./scripts/sudoku.py get kids6
渲染谜题
将谜题渲染为图片、PDF 或最小化 HTML。
将最新谜题渲染为 A4 PDF(用于打印):
bash
./scripts/sudoku.py render --pdf
将最新谜题渲染为清晰 PNG(用于查看):
bash
./scripts/sudoku.py render
通过短 ID 渲染特定历史谜题:
bash
./scripts/sudoku.py render --id a09f3680
渲染最小化 HTML(方形单元格 + 粗体框线):
bash
./scripts/sudoku.py html --id a09f3680
揭示答案
揭示最新或特定谜题的答案。使用 --id <短ID>(例如 a09f3680)定位特定谜题。
将完整答案揭示为可打印 PDF:
bash
./scripts/sudoku.py reveal --pdf
揭示特定 ID 的完整答案:
bash
./scripts/sudoku.py reveal --id a09f3680 --image
将完整答案揭示为 PNG 图片:
bash
./scripts/sudoku.py reveal
揭示单个单元格(第 3 行,第 7 列):
bash
./scripts/sudoku.py reveal --cell 3 7
揭示特定 3x3 宫格(索引 5):
bash
./scripts/sudoku.py reveal --box 5
分享链接
为已存储的谜题生成分享链接。默认针对最新谜题;使用 --id <短ID> 指定特定谜题。
生成 SudokuPad 分享链接(默认):
bash
./scripts/sudoku.py share
为特定 ID 生成链接:
bash
./scripts/sudoku.py share --id a09f3680
生成 SCL 分享链接:
bash
./scripts/sudoku.py share --type scl
Telegram 格式提示:
将链接格式化为短按钮式链接并隐藏完整 URL:[简单经典 \[\]]()