MCPcopy Create free account
hub / github.com/PRIME-RL/PRIME / match_code

Function match_code

eval/Coding/leetcode/evaluate_leetcode.py:32–49  ·  view source on GitHub ↗
(s)

Source from the content-addressed store, hash-verified

30
31import re
32def match_code(s):
33 pattern = r'```python(.*?)```'
34 sol = re.findall(pattern, s, re.DOTALL)
35 if len(sol) > 0:
36 for code_block in reversed(sol):
37 if 'def ' in code_block:
38 return code_block
39 return sol[-1]
40
41 pattern = r'```(.*?)```'
42 sol = re.findall(pattern, s, re.DOTALL)
43 if len(sol) > 0:
44 for code_block in reversed(sol):
45 if 'def ' in code_block:
46 return code_block
47 return sol[-1]
48
49 return s.split('```')[0]
50
51
52def generate_sample_batch(question_list):

Callers 1

generate_sample_batchFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected