(string)
| 14 | |
| 15 | |
| 16 | def last_boxed_only_string(string): |
| 17 | idx = string.rfind('\\boxed') |
| 18 | if idx < 0: |
| 19 | idx = string.rfind('\\fbox') |
| 20 | if idx < 0: |
| 21 | return None |
| 22 | |
| 23 | i = idx |
| 24 | right_brace_idx = None |
| 25 | num_left_braces_open = 0 |
| 26 | while i < len(string): |
| 27 | if string[i] == '{': |
| 28 | num_left_braces_open += 1 |
| 29 | if string[i] == '}': |
| 30 | num_left_braces_open -= 1 |
| 31 | if num_left_braces_open == 0: |
| 32 | right_brace_idx = i |
| 33 | break |
| 34 | i += 1 |
| 35 | |
| 36 | if right_brace_idx is None: |
| 37 | retval = None |
| 38 | else: |
| 39 | retval = string[idx:right_brace_idx + 1] |
| 40 | |
| 41 | return retval |
| 42 | |
| 43 | |
| 44 | def remove_boxed(s): |
no outgoing calls
no test coverage detected