{"data":{"kind":"file","path":"README.md","version_id":"gf5otq9xvzdi1q2770445gv9","entry":{"name":"README.md","path":"README.md","is_directory":false,"size":2589,"modified_at":"2026-08-24T14:18:07.308000","content_hash":"7e798e83fbff385ae619071dd508c6343bf81d86b485cdfcf867b25e8dd02fe8"},"entries":[],"content":"# Code Golf Optimizer\n\nTrain LLMs to write maximally concise, correct Python code. This environment evaluates the full code golf pipeline: **correctness** (does it work?), **efficiency** (how short is it?), and **technique** (does it use golf idioms?).\n\n## Overview\n\nCode golf is the art of solving programming challenges in the fewest bytes possible. This environment presents 12 classic algorithmic challenges where the model must balance brevity with correctness — a fundamentally different optimization target than typical code generation.\n\n### Reward Structure\n\n| Metric | Weight | Description |\n|--------|--------|-------------|\n| Correctness | 3.0 | Test case pass rate (gate metric) |\n| Length Efficiency | 2.0 | Sigmoid curve: shorter = better, scored against par |\n| Golf Techniques | 1.0 | Use of lambda, comprehensions, walrus, unpacking, ternary |\n| Syntax Validity | 1.0 | Valid Python syntax |\n| Explanation Quality | 0.5 | Byte count reporting, technique explanation |\n\n### Challenges\n\n12 tasks spanning string manipulation, math, data structures, and algorithms:\n\n- **FizzBuzz** (par: 85 bytes) — Classic conditional string mapping\n- **Fibonacci** (par: 45 bytes) — Iterative sequence generation\n- **Palindrome** (par: 68 bytes) — String normalization and comparison\n- **Flatten** (par: 78 bytes) — Recursive list processing\n- **Caesar Cipher** (par: 110 bytes) — Character arithmetic\n- **Matrix Transpose** (par: 38 bytes) — Zip unpacking\n- **Two Sum** (par: 82 bytes) — Hash map lookup\n- **Run-Length Encode** (par: 68 bytes) — Groupby iteration\n- **Prime Sieve** (par: 62 bytes) — Divisibility testing\n- **Spiral Order** (par: 58 bytes) — Matrix rotation\n- **Roman to Int** (par: 128 bytes) — Symbol mapping with subtraction rule\n- **Pascal Row** (par: 60 bytes) — Combinatorial computation\n\n### Key Design Decisions\n\n- **Sigmoid length scoring**: Avoids step-function exploitation. Score transitions smoothly from 1.0 (at par/2) to 0.5 (at par) to ~0 (at 2x par).\n- **Subprocess isolation**: Each solution runs in a separate process with timeout protection.\n- **Par bytes benchmarked**: Each task has a human-competitive par based on known golf solutions.\n- **Technique detection**: Rewards genuine golf idioms (walrus operator, star unpacking, lambda) over naive shortening.\n\n## Usage\n\n```python\nfrom code_golf_optimizer import load_environment\n\nenv = load_environment()\n# or with eval split:\nenv = load_environment(split=\"eval\")\n```\n\n## Evaluation\n\n```bash\nprime eval run OWNER/code-golf-optimizer -m Qwen/Qwen3.5-0.8B\n```\n\n## License\n\nMIT\n","encoding":"utf-8","truncated":false,"total_bytes":2589},"status":null}