This is a simple bracket pairing porject by Python 3.
- Use python 3 to compile the file
python3 BracketPairing.py
-
Input the file name that you want to check (eg.
i1
) -
Then the program will output a List
eg.
For input file
i1
)((hello (world )( ni(hao)
we will have the result:
[[(-1, -1), (1, 2), (1, 3), (1, 10), (2, 2), (3, 3)], [(1, 1), (-1, -1), (-1, -1), (2, 1), (-1, -1), (3, 7)]]
The result is composed of 2 parts: Left brackets' postions + Right ones' positions, which are respectively ordered.
If any of the brackets are not pairing, then the missing ones' positions will be
(-1,-1)