Cody

Problem 496. Oxidation State

Solution 2203161

Submitted on 10 Apr 2020
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Pass
x='sulphuric acid H2SO4'; y = 0-(2*1+4*-2); assert(isequal(y,oxno(x)))

aa = 'H2SO4' ans = 'H' d = 2 y = 2 ans = '2' ans = 'S' ans = 'O' d = 4 y = -6 ans = '4'

2   Pass
x='sodium hydroxide NaOH'; y = 0-(-2+1); assert(isequal(y,oxno(x)))

aa = 'NaOH' ans = 'N' ans = 'a' ans = 'O' y = -2 ans = 'H' y = -1

3   Pass
x='methane CH4'; y = 0-(4*1); assert(isequal(y,oxno(x)))

aa = 'CH4' ans = 'C' ans = 'H' d = 4 y = 4 ans = '4'

4   Pass
x='ethane C2H6'; y = 0-(6*1)/2; assert(isequal(y,oxno(x)))

aa = 'C2H6' ans = 'C' ans = '2' ans = 'H' d = 6 y = 6 ans = '6'

5   Pass
x='acetylene C2H2'; y = 0-(2*1)/2; assert(isequal(y,oxno(x)))

aa = 'C2H2' ans = 'C' ans = '2' ans = 'H' d = 2 y = 2 ans = '2'

6   Pass
x='hypophosphorous acid H3PO2'; y = 1; assert(isequal(y,oxno(x)))

aa = 'H3PO2' ans = 'H' d = 3 y = 3 ans = '3' ans = 'P' ans = 'O' d = 2 y = -1 ans = '2'

7   Pass
x='(ortho)phosphorous acid H3PO3'; y = 3; assert(isequal(y,oxno(x)))

aa = 'H3PO3' ans = 'H' d = 3 y = 3 ans = '3' ans = 'P' ans = 'O' d = 3 y = -3 ans = '3'

8   Fail
x='pyrophosphoric acid H4P2O7'; y = 5; assert(isequal(y,oxno(x)))

aa = 'H4P2O7' ans = 'H' d = 4 y = 4 ans = '4' ans = 'P' ans = '2' ans = 'O' d = 7 y = -10 ans = '7'

Assertion failed.