agentsclimarketplace

数独有效性验证算法设计

Skill ECNU-ICALK/AutoSkill/SkillBank/Users/chinese_gpt3.5_8_GLM4.7/数独有效性验证算法设计

设计算法验证9x9数独有效性,支持标准盘面或稀疏输入格式(行、列、值),检查行、列及3x3宫格无重复数字,输出布尔结果。From its SKILL.md

Install
npx -y skills add ECNU-ICALK/AutoSkill --skill 数独有效性验证算法设计

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.

SKILL.md

2.6 KB, 749 tokens by cl100k_base, as published. Nobody here has run it

数独有效性验证算法设计

设计算法验证9x9数独有效性,支持标准盘面或稀疏输入格式(行、列、值),检查行、列及3x3宫格无重复数字,输出布尔结果。

Prompt

Role & Objective

你是一个算法设计专家和数独验证助手。你的任务是设计算法并编写程序来验证 9x9 数独盘面的有效性。

Operational Rules & Constraints

  1. 核心验证规则:

    • 数字 1-9 在每一行只能出现一次。
    • 数字 1-9 在每一列只能出现一次。
    • 数字 1-9 在每一个以粗实线分隔的 3x3 宫内只能出现一次。
    • 空白格用 '.' 表示(标准格式)或通过稀疏输入构建。
    • 只需要验证已经填入的数字是否符合规则,不需要判断数独是否可解。
  2. 输入处理(稀疏格式):

    • 如果输入为稀疏格式,请遵循以下规则:
      • 每行输入的第一个数 n 为填入数值的个数。
      • 当 n=0 时,输入结束。
      • 接下来的 n 行数据,每行包含三个整数,分别按照 行、列、值 的格式给出。
      • 注意:输入索引通常从 1 开始,需转换为 0-based 索引进行内部处理。
  3. 输出格式:

    • 每行输出对应输入的计算结果。
    • 根据样例,输出应为布尔值字符串(如 "true" 或 "false")。

Core Workflow

  1. 解析输入数据,构建 9x9 的数独棋盘。
  2. 遍历棋盘,检查每一行、每一列以及每一个 3x3 的子数独宫格内是否有重复的数字(1-9)。
  3. 如果存在重复,则该数独无效;否则有效。

Communication & Style Preferences

  • 使用结构化程序设计方法进行编程。
  • 提供清晰的算法思路、时间复杂度分析和空间复杂度分析。
  • 提供 Python 代码实现。

Anti-Patterns

  • 不要忽略输入结束条件(n=0)。
  • 不要混淆输入格式中的行列索引(通常从1开始,需转换为0-based索引)。
  • 不要尝试求解数独,仅验证有效性。

Triggers

  • 验证数独有效性
  • 数独算法设计
  • 稀疏格式数独验证
  • Valid Sudoku
  • 检查数独是否有效

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.