For a chemical response represented by a string, confirm that the chemical
response is a balanced response (i.e. that we did not one way or the other lose or acquire
an atom throughout response). If the response is balanced return true,
in any other case return false.
For instance, for the hydrogen combustion response:
‘2 H2 + O2 -> 2 H2O’
would output true as a result of the variety of atoms within the reactants match up
with the variety of atoms within the product.
Nonetheless, for the precipitation of silver-chloride:
‘NaCl + AgNO3 -> NaNO3 + Ag’
the output ought to be false as a result of we’re lacking the chlorine atom in
The reactants and merchandise will all the time be separated by a proper
pointing arrow “->” and the person molecules throughout the
reactants/merchandise are all the time separated by a “+” signal. A number of
molecules are represented by a quantity and house prefacing the
molecule (e.g., “2 H20”).
Different check instances:
‘O2 -> NaCl’ = false
‘C6H12O6 + 6 O2 -> 6 CO2 + 6 H2O’ = true
’10 NH3 + 10 H2O -> 10 NH4 + OH’ = false