Imported from XuShuwenn/RedAct (
data/skills/trace2skill/skills_rewritten/error_only/isomer-counting/SKILL.md). Install upstream withnpx skills add XuShuwenn/RedAct --skill isomer-counting. Copyright stays with the author.
Structural Isomer Counting
When to Use
- Count constitutional isomers for a molecular formula
- Solve chemistry combinatorics problems
- Enumerate possible chemical structures
Input Format
File /root/input.txt with molecular formula (e.g., C4H10)
- Read
/root/input.txtfirst and base all reasoning on the exact formula found there. - Do not assume an example formula is the task input.
Output Format
To /root/output.txt:
Number of isomers: [count]
Write exactly one line to /root/output.txt with no extra text:
Number of isomers: [count]
Key Concepts
- Structural/constitutional isomers: same formula, different connectivity
- NOT stereoisomers (different spatial arrangements)
- Example: C4H10 → 2 isomers (butane, isobutane)
Approach
- Read
/root/input.txtfirst and parse the molecular formula actually provided - Parse the formula into element counts and classify the formula pattern when helpful
- For small common formulas with reliable well-known constitutional-isomer counts, use direct chemistry knowledge or direct enumeration of distinct connectivity families instead of unnecessary full exhaustive generation
- Otherwise, separate hydrogens from heavy atoms, assign standard valences, and enumerate heavy-atom bond graphs whose degrees and bond-order totals can satisfy the formula
- Prune partial candidates early using valence limits, remaining bond total, and connectivity feasibility
- Convert valid heavy-atom graphs to implied hydrogen counts and keep only exact formula matches
- Deduplicate by canonicalizing only within identical-element groups, then count unique constitutional isomers
- Exclude stereoisomers and conformations; count connectivity differences only
- Write the result to
/root/output.txtexactly asNumber of isomers: [count]
Tips
- Use combinatorial enumeration
- Check valency rules for each atom type
- Handle common formulas (alkanes, alcohols, etc.)
