(answer, pi)
| 107 | |
| 108 | |
| 109 | def normalize(answer, pi) -> str: |
| 110 | # checking if answer is $<number> and removing $ in that case to compare |
| 111 | if isinstance(answer, str) and bool(re.match(r'\$\d+(\.\d+)?', answer)): |
| 112 | return answer[1:] |
| 113 | |
| 114 | # checking if answer is <number>% or <number>\\% and removing % |
| 115 | if isinstance(answer, str) and ( |
| 116 | bool(re.match(r'^\d+(\.\d+)?%$', answer)) or bool(re.match(r'^\d+(\.\d+)?\\%$', answer)) |
| 117 | ): |
| 118 | return answer.replace("\\%", "").replace("%", "") |
| 119 | |
| 120 | # handle base |
| 121 | answer = handle_base(answer) |
| 122 | |
| 123 | # handle pi |
| 124 | answer = handle_pi(answer, pi) |
| 125 | |
| 126 | return answer |
| 127 | |
| 128 | def handle_base(x) -> str: |
| 129 | if isinstance(x, str) and "_" in x: |
no test coverage detected