VSEPR Strikes Back! [Revamped Again] (Note: I know that the VSEPR method fails sometimes, and that there are exceptional molecules. The challenge is about the molecules which conform.)  

Most people who have taken an introductory chemistry course know about molecules, and (probably) the VSEPR theory of chemical bonding. Basically, the theory predicts the shape of a molecule given three main properties:  


A: The central atom. You may assume this is the first element appearing in the chemical formula; for example, in CH4, you may assume the central atom is C. 
X: The number of atoms bonded to the central atom A.
E: The number of "lone electron pairs" on the central atom. For the purposes of this challenge, the number of outer electrons A has is given by the last digit of the element's column number on the periodic table.


If A is bonded to an element X in column 17 of the periodic table, there will be a mutual sharing of electrons, so that A effectively has one additional electron for each atom of X attached to it. (This does not apply for elements such as O or S in column 16.)



Each bond requires two of these electrons. Leftover electrons not used in bonding with other atoms are found in pairs of two, called lone pairs. So E is the number of electrons not used in bonding by the central atom A divided by 2. (It may be assumed that input will always lead to A having an even number of electrons.)

For example, a molecule which has 1 lone pair and 3 atoms bonded to the main atom is AX3E1, which is the trigonal pyramidal configuration. (There is always only 1 central atom, so A never has a subscript.)

The Challenge

Your job is, given a string representing a covalent chemical compound, to output the shape of that molecule. "But wait!", exclaim the exasperated programmers, "you can't expect us to input all of the molecular data for every element!" Of course we can, but as that wouldn't be fun, we'll only consider the compounds formed by the following 7 elements: 

Carbon    C
Sulfur    S
Oxygen    O
Nitrogen  N
Chlorine  Cl
Bromine   Br
Fluorine  F


The input is any molecule composed of the above 7, such as CO2 or SF4, that is in the form AXN, where A and X are each one of the above seven element symbols, X is not C or N, and N is a number between 2 and 6 inclusive.

The output should be the name of the geometric shape of the molecule, for example "linear".

The following (don't get scared, I swear they're less than they seem!) is a list of all possible configurations along with their AXE number and a drawing of how they look (adapted from Wikipedia's nifty table):



Test Cases


  CO2: CO2 -> linear
  OF2: OF2 -> bent
  CCl2: CCl2 -> bent
  BrF3: BrF3 -> T-shaped
  SF4: SF4 -> seesaw  


Notes:
 - We won't consider compounds in which the first element has a subscript other than 1, such as C2H4.
 - Standard loopholes apply.
 - This is a code golf, so the shortest answer wins (obviously)
Ruby, 250
s=gets
e=7-&quot;FBOSN C&quot;.index(s[0])/2+(s[1]==?l?3:0)
x=s.reverse!.to_i
e+=&quot;Frl&quot;.index(s[2])?x:0
t=&quot;trigonal &quot;
puts [[&quot;linear&quot;,b=&quot;bent&quot;,b],[t+&quot;planar&quot;,t+p=&quot;pyramidal&quot;,&quot;T-shaped&quot;],[&quot;tetr&quot;+h=&quot;ahedral&quot;,&quot;seesaw&quot;],[t+&quot;bi&quot;+p,&quot;square &quot;+p],[&quot;oct&quot;+h]][x-2][e/2-x]

Note that with the rules as they are, AX2E3 and AX4E2 are not possible with the given elements, so they are not supported. All test cases passed.
with comments
s=gets                                     #get input with newline attached
e=7-&quot;FBOSN C&quot;.index(s[0])/2+(s[1]==?l?3:0) #calculate the number of electrons (not lone pairs) from A. Note the addition required to differentiate C and Cl.
x=s.reverse!.to_i                          #reverse the input string so the number is at the beginning (after the newline) and evaluate the string as a number to get X.
e+=&quot;Frl&quot;.index(s[2])?x:0                   #if the character after the number is in &quot;Frl&quot; we have a halogen so increment number of electrons accordingly.
t=&quot;trigonal &quot;                              #as &quot;trigonal &quot; goes at the beginning of the string, we cannot define it on the fly, it is defined as a constant here.
                                           #array of outputs below. note the subscripts at the end: x-2 to put it in the range 0..4 and e/2-x to convert e into the actual number of lone pairs.
puts [[&quot;linear&quot;,b=&quot;bent&quot;,b],[t+&quot;planar&quot;,t+p=&quot;pyramidal&quot;,&quot;T-shaped&quot;],[&quot;tetr&quot;+h=&quot;ahedral&quot;,&quot;seesaw&quot;],[t+&quot;bi&quot;+p,&quot;square &quot;+p],[&quot;oct&quot;+h]][x-2][e/2-x]