Airbus interview question

Asked to solve balancing equations coding challenge