You will write a few functions for the cages of carbon. They count bonds and hexagons, test Euler's rule and work out the size of a cage from its number of hexagons.
The idea. A cage with atoms has bonds and hexagons, and always 12 pentagons. For a closed cage, .
Your tasks.
bonds(n) so that it returns the number of bonds.hexagons(n) so that it returns the number of hexagons.euler(n) so that it returns for the cage.atoms(h) so that it returns the number of carbon atoms in a cage with h hexagons.Have you tried it?
Do the tasks in the editor first, and run the checker after each one. Its hints help when a check fails. When you are ready, compare your code with this solution.
Log in to join the discussion.
Loading…