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]
- After solving, write the result to
/root/output.txtrather than only stating it in the chat response. - Verify the file contains exactly one line in this format:
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.txtbefore doing any chemistry reasoning; extract and use the exact molecular formula found there, not an example formula from the skill or a remembered nearby case - Parse that exact formula into element counts and classify the formula pattern when helpful
- For a small, common formula with a reliable well-known constitutional-isomer count, prefer the shortest reliable path: use the direct known result or concise family enumeration instead of unnecessary 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
- If planning to use a chemistry toolkit or external library for enumeration or canonicalization, first confirm it is available in the environment; otherwise use a pure-Python graph-enumeration approach
- 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
- Before finishing, confirm the count corresponds to the exact input formula and to constitutional isomers only
- Write exactly one line to
/root/output.txtasNumber of isomers: [count]with no extra commentary, names of isomers, or extra whitespace - Verify
/root/output.txtcontains exactly that one required line
Tips
- Use combinatorial enumeration
- Check valency rules for each atom type
- Handle common formulas (alkanes, alcohols, etc.)