Organic Compounds (rules)

can someone explain why in the fifth test the compound is valid?

CH2(2)CH0(1)CH1(2)CH0(1)CH3
(1) (1)
CH0 CH1(1)CH2(1)CH3
(3) (1)
CH1 CH3

The very first hydrocarbon has 5 bonds!?!?!? :thinking::roll_eyes:

That’s 5 lines of input, not 5 bonds.

The very first carbon CH2(2) has 4 bonds. 2 bonds with 2 individual H and 2 bonds with the neighboring carbon CH0.

All carbons have 4 bonds … unless … we are going into detail that isn’t necessary for solving this problem.

Doesn’t the first bond on line 2 means that there’s a bond between the first HC in line 1 and the first HC in line 3? If it’s so, the first C in line 1 would have 5 Hs (2 from itself, 2 from the next HC on line 1 and 1 from the first HC on line 3).

Sorry, can’t insert an image to explain.

Thank you for the attention.

You might be ignoring empty spaces.

There’s some empty space before the first (1) on line 2 for example. With that the bond ends up right where it belongs.

Bond #1 on line 2 is between CH0 on 1st line and CH0 on line 3.

One detail you might be confused by is the really stupid CH0 notation. It should have been C on its own and not CH0 or CFe0Mg0Cl0H0Al0Na0Se0Si0

So where you see H0 ignore it, it stands for zero hydrogen atoms.

1 Like

Oh, my… Youre tottaly correct and Im an idiot. I was stripping my input lines. I did it in the beginning, before undestanding that spaces are important for the problem.

Again, thank you very much for your help.

Mauro Crispim

Actually as I am getting all the numbers through a regex, the CH0 notation is really useful for not having a too complex regex. So I like it that way :slight_smile: Furthermore, I think the “real” notation is not the “real” part of the problem here.

Hi all,
I’m having trouble passing the validator 8, “Cyclic Hydrocarbon with substituents”.
I get all the IDE tests right, and I’m clueless about what went wrong in that validator.
Thanks for your help!