MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn moreOpportunities for recent engineering grads.

Apply TodayGiven a molecular equation string determine its atomic weight.

Limited atoms of C H O N and S where wts are rounded to [12 1 16 14 32].

Example molecules and wts:

CH4 16; CH3OH 32; O2 32; C6H6 78; H2SO4 98; radical SO4 96;

**Input:** Molecular Eqn [string with no spaces, all Caps]

**Output:** Molecular Wt [approx wt]

**Source:**

Saw this as a question on Matlab Answers.

26 correct solutions
8 incorrect solutions

Last solution submitted on Jun 28, 2014

4 players like this problem

1 player likes this solution

2 players like this solution

1 Comment

Richard Zapor
on 2 Sep 2013

Another astounding solution by Alfonso. A symbolic solution with regexprep using an expert logical twist to accommodate all molecules.

1 Comment