|
| 1 | +# 🧠 Competitive Programming Problem Solver with CAMEL Agents & Firecrawl |
| 2 | + |
| 3 | +This project enables users to input problems from competitive programming platforms (Codeforces or LeetCode) and receive AI-generated Python solutions. It integrates: |
| 4 | + |
| 5 | +- 🔍 Web scraping via Firecrawl |
| 6 | +- 🤖 Multi-agent reasoning with CAMEL AI |
| 7 | +- 🧪 Code execution and validation against sample tests |
| 8 | +- 🌐 Streamlit interface for user interaction |
| 9 | +- 🔄 Auto-fix functionality for Codeforces problems |
| 10 | + |
| 11 | +--- |
| 12 | + |
| 13 | +## 🚀 Features |
| 14 | + |
| 15 | +- **Multi-Platform Support**: Solves problems from both Codeforces and LeetCode |
| 16 | +- **Problem Retrieval**: Fetches problem statements using Firecrawl |
| 17 | +- **Sample Extraction**: Parses and extracts sample inputs/outputs from problem descriptions |
| 18 | +- **AI-Powered Solution**: Utilizes CAMEL AI agents to generate Python solutions |
| 19 | +- **Automated Testing**: Executes generated code against extracted samples |
| 20 | +- **Auto-Fix Capability**: Iteratively improves solutions for Codeforces problems |
| 21 | +- **Platform-Specific Handling**: Different solution approaches for Codeforces vs LeetCode |
| 22 | + |
| 23 | +--- |
| 24 | + |
| 25 | +## 📦 Requirements |
| 26 | + |
| 27 | +Install Python packages: |
| 28 | + |
| 29 | +```bash |
| 30 | +pip install -r requirements.txt |
| 31 | +``` |
| 32 | + |
| 33 | +--- |
| 34 | + |
| 35 | +## 🛠️ Setup |
| 36 | + |
| 37 | +1. **Clone the repository**: |
| 38 | + |
| 39 | + ```bash |
| 40 | + git clone https://github.com/camel-ai/camel.git |
| 41 | + cd examples/usecases/codeforces_question_solver |
| 42 | + ``` |
| 43 | + |
| 44 | +2. **Install dependencies**: |
| 45 | + |
| 46 | + ```bash |
| 47 | + pip install -r requirements.txt |
| 48 | + ``` |
| 49 | + |
| 50 | +3. **Configure environment variables**: |
| 51 | + |
| 52 | + Create a `.env` file in the root directory and add your API keys: |
| 53 | + |
| 54 | + ```env |
| 55 | + FIRECRAWL_API_KEY=your_firecrawl_api_key |
| 56 | + OPENAI_API_KEY=your_openai_api_key |
| 57 | + FIRECRAWL_API_KEY='your_firecrawl_key' |
| 58 | + ``` |
| 59 | + |
| 60 | +--- |
| 61 | + |
| 62 | +## 🧪 Run the App |
| 63 | + |
| 64 | +Start the Streamlit application: |
| 65 | + |
| 66 | +```bash |
| 67 | +streamlit run app.py |
| 68 | +``` |
| 69 | + |
| 70 | +Then, open the provided URL in your browser to interact with the app. |
| 71 | + |
| 72 | +--- |
| 73 | + |
| 74 | +## 📁 File Structure |
| 75 | + |
| 76 | +``` |
| 77 | +├── app.py # Main Streamlit application |
| 78 | +├── requirements.txt # Python dependencies |
| 79 | +├── .env # Environment variables |
| 80 | +└── README.md # Project documentation |
| 81 | +``` |
| 82 | + |
| 83 | +--- |
| 84 | + |
| 85 | +## 🧠 Powered By |
| 86 | + |
| 87 | +- [CAMEL AI](https://github.com/camel-ai/camel): Multi-agent reasoning framework |
| 88 | +- [Firecrawl](https://github.com/mendableai/firecrawl): Web scraping and data extraction |
| 89 | +- [Streamlit](https://streamlit.io/): Web application framework |
| 90 | + |
| 91 | +--- |
| 92 | + |
| 93 | +## 💬 Example Usage |
| 94 | + |
| 95 | +1. **Select Platform**: Choose Codeforces or LeetCode |
| 96 | +2. **Input Problem ID**: |
| 97 | + - For Codeforces: Enter problem ID (e.g., `2116B`) |
| 98 | + - For LeetCode: Enter problem slug (e.g., `reverse-integer`) |
| 99 | +3. **Process**: |
| 100 | + - Fetches problem statement using Firecrawl |
| 101 | + - Extracts sample inputs/outputs |
| 102 | + - Generates Python solution using CAMEL AI |
| 103 | + - For Codeforces: Optionally auto-fixes solution based on test failures |
| 104 | +4. **Output**: Displays generated code, and test results |
| 105 | + |
| 106 | +--- |
| 107 | + |
| 108 | +## 📌 Notes |
| 109 | + |
| 110 | +- Ensure your API keys are valid and have sufficient quota |
| 111 | +- Solution accuracy depends on problem complexity and AI capabilities |
| 112 | +- Always review generated code before using in competitions |
| 113 | +- Auto-fix is currently only available for Codeforces problems |
| 114 | + |
| 115 | +--- |
| 116 | + |
| 117 | +## 🙌 Acknowledgements |
| 118 | + |
| 119 | +- [CAMEL AI](https://github.com/camel-ai/camel) for multi-agent reasoning |
| 120 | +- [Firecrawl](https://github.com/mendableai/firecrawl) for web scraping |
| 121 | +- [Streamlit](https://streamlit.io/) for the web interface |
| 122 | + |
| 123 | +--- |
| 124 | + |
| 125 | +Feel free to contribute by submitting issues or pull requests! |
0 commit comments