一键导入
precompute-relationships
For static relationships: graph structure, grid neighbors, constraint peers. Calculate once at module load, reference throughout program.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
For static relationships: graph structure, grid neighbors, constraint peers. Calculate once at module load, reference throughout program.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Conducts iterative deep research on any topic using web search, progressive exploration, and structured synthesis. Use when asked for comprehensive research, deep investigation, thorough analysis, or multi-source exploration of any topic. Triggers: research, investigate, deep dive, comprehensive analysis, explore thoroughly, find everything about.
For cross-cutting concerns: add behavior without modifying functions, caching, timing, logging, validation wrappers.
For performance work: measure before changing, profile to find bottlenecks, compare before and after.
For symbolic computation: ASTs, mathematical expressions, code that manipulates code structure, expression transformations.
For ordered processing: A* search, Dijkstra, event simulation, task scheduling. Efficient min/max extraction with heap-based queue.
For dynamic programming: overlapping subproblems, recursive solutions with repeated computations, memoization to avoid redundant work.
| name | precompute-relationships |
| description | For static relationships: graph structure, grid neighbors, constraint peers. Calculate once at module load, reference throughout program. |
Compute all static relationships at module load time. Store in dicts for O(1) lookup.
# Define structure
rows = 'ABCDEFGHI'
cols = '123456789'
# Precompute all squares
squares = [r + c for r in rows for c in cols]
# Precompute all units (rows, cols, boxes)
unit_list = (
[[r + c for c in cols] for r in rows] + # Rows
[[r + c for r in rows] for c in cols] + # Columns
[[r + c for r in rs for c in cs] # Boxes
for rs in ['ABC', 'DEF', 'GHI']
for cs in ['123', '456', '789']]
)
# Precompute which units each square belongs to
units = {s: [u for u in unit_list if s in u] for s in squares}
# Precompute peers (squares that constrain this one)
peers = {s: set(sum(units[s], [])) - {s} for s in squares}
def cross(A, B):
"""Cross product of elements in A and B."""
return [a + b for a in A for b in B]
digits = '123456789'
rows = 'ABCDEFGHI'
cols = digits
# All 81 squares
squares = cross(rows, cols)
# All 27 units
unitlist = ([cross(rows, c) for c in cols] +
[cross(r, cols) for r in rows] +
[cross(rs, cs)
for rs in ('ABC', 'DEF', 'GHI')
for cs in ('123', '456', '789')])
# units[s] = list of 3 units containing square s
units = {s: [u for u in unitlist if s in u]
for s in squares}
# peers[s] = set of 20 squares that see square s
peers = {s: set(sum(units[s], [])) - {s}
for s in squares}
# Now constraint propagation is fast:
def eliminate(values, s, d):
for peer in peers[s]: # O(1) lookup!
eliminate(values, peer, d)
units[square] not find_units(square)