File size: 296 Bytes
1b74191
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
import re

sqrt_pattern = r"√(?:\\*\{|\()([^{}()]+)(?:\\*\}|\))"

def answer_transformation_fn(
    ans: str,  # The answer to be transformed
) -> bool:
    
    # Check if gt or pred contains "√{*}" and convert to "\sqrt{*}"
    ans = re.sub(sqrt_pattern, r"\\sqrt{\1}", ans)
    return ans