A straight-chain alk*ne is defined as a sequence of carbon atoms connected by single (alkane), double (alkene), or triple bonds (alkyne), (implicit hydrogens are used.) Carbon atoms can only form 4 bonds, so no carbon atom may be forced to have more than four bonds. A straight-chain alk*ne can be represented as a list of its carbon-carbon bonds.
These are some examples of valid straight-chain alk*nes:
 CH4 Methane  CH3-CH3 Ethane  CH2=CH2 Ethene  CH≡CH Ethyne [1,1] CH3-CH2-CH3 Propane [1,2] CH3-CH=CH2 Propene [1,3] CH3-C≡CH Propyne [2,1] CH2=CH-CH3 Propene [2,2] CH2=C=CH2 Allene (Propadiene) [3,1] CH≡C-CH3 Propyne [1,1,1] CH3-CH2-CH2-CH3 Butane ...
While these are not, as at least one carbon atom would have more than 4 bonds:
[2,3] [3,2] [3,3] ...
Your task is to create a program/function that, given a positive integer
n, outputs/returns the number of valid straight-chain alk*nes of exactly
n carbon atoms in length. This is OEIS A077998.
- You must handle
1correctly by returning
- Alk*nes like
[2,1]are considered distinct.
- Output is the length of a list of all the possible alk*nes of a given length.
- You do not have to handle 0 correctly.
1 => 1 2 => 3 3 => 6 4 => 14
This is code golf, so lowest byte count wins!