-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.py
34 lines (24 loc) · 816 Bytes
/
run.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# Modules >>>
from src.Utils.assembler import assemble_formula
from src.Utils.check_cf import check_formula
from src.decomposer import decompose_formula
from src.balancer import balance_formula
# Main >>>
def chem_balance():
# Get the formula
formula = input("Formula: ")
# Remove spaces
formula = formula.replace(" ", "")
# Check if the formula is valid
check_formula(formula, raise_error=True)
# Decompose the formula
decomposed_formula = decompose_formula(formula)
# Balance the formula
balanced_formula = balance_formula(decomposed_formula)
# Assemble the balanced formula
balanced_formula_str = assemble_formula(balanced_formula)
# Print the balanced formula
print(balanced_formula_str)
# Start >>>
if __name__ == "__main__":
chem_balance()