If you convert a chemical formula to lower case, it may become ambiguous: co can be both CO or Co.
Given an input consisting of a-z0-9, where 0 can only stand behind 0-9. Check whether it's ambiguous, unambiguous, or impossible. Return 3 different values for them. Shortest code wins.
Examples:
co - ambiguous 2h83o6 - unambiguous li - unambiguous l - impossible cli - ambiguous c10h7o - unambiguous One-sentence meaning: Is there zero, one or multiple ways to split input into concatenation of the following strings, case insensitive:
0,1,2,3,4,5,6,7,8,9,H,He,Li,Be,B,C,N,O,F,Ne,Na,Mg,Al,Si,P,S,Cl,Ar,K,Ca,Sc,Ti,V,Cr,Mn,Fe,Co,Ni,Cu,Zn,Ga,Ge,As,Se,Br,Kr,Rb,Sr,Y,Zr,Nb,Mo,Tc,Ru,Rh,Pd,Ag,Cd,In,Sn,Sb,Te,I,Xe,Cs,Ba,La,Ce,Pr,Nd,Pm,Sm,Eu,Gd,Tb,Dy,Ho,Er,Tm,Yb,Lu,Hf,Ta,W,Re,Os,Ir,Pt,Au,Hg,Tl,Pb,Bi,Po,At,Rn,Fr,Ra,Ac,Th,Pa,U,Np,Pu,Am,Cm,Bk,Cf,Es,Fm,Md,No,Lr,Rf,Db,Sg,Bh,Hs,Mt,Ds,Rg,Cn,Nh,Fl,Mc,Lv,Ts,Og Notes
- You need to code the table into your program, since as I searched there was no question requiring an unordered chemical element table.
a-z0-9~> So the input may containjorqeven if they're not used in any symbol, right? \$\endgroup\$2h83o6unambiguous in the test cases? Surely this could be decomposed to2h83o6or2h83o6or2h83o6? \$\endgroup\$2H8 3O6? \$\endgroup\$2h83o6could possibly be reordered to have2h83o6in the chemical formula instead of the other forms. Basically, is a multi-digit number ambiguous? (e.g. 83 could be split 8 and 3) \$\endgroup\$