Extract the code block from the text that contains the solution function. :param text: The text to search for the code block. :return: The extracted code block.
(text)
| 11 | |
| 12 | |
| 13 | def extract_python_block_with_solution(text): |
| 14 | """ |
| 15 | Extract the code block from the text that contains the solution function. |
| 16 | :param text: The text to search for the code block. |
| 17 | :return: The extracted code block. |
| 18 | """ |
| 19 | pattern = r'```python\n(.*?)def solution\(\):\n(.*?)```' |
| 20 | match = re.search(pattern, text, re.DOTALL) |
| 21 | if match: |
| 22 | return match.group(1) + 'def solution():\n' + match.group(2) |
| 23 | else: |
| 24 | return "" |
| 25 | |
| 26 | def load_data(args): |
| 27 | """ |