[Question]
  [
# How many atoms in the hydrocarbon?
A hydrocarbon is a chemical compound which consists of only hydrogen and carbon atoms. For this challenge, we will only consider the three simplest kinds of hydrocarbons: **alkanes**, **alkenes**, and **alkynes** with no branches.
An **alkane** with \$n\$ carbon atoms contains \$2n+2\$ hydrogen atoms. An **alkene** with \$n\$ carbon atoms contains \$2n\$ hydrogen atoms. An **alkyne** with \$n\$ carbon atoms contains \$2n-2\$ hydrogen atoms.
Each kind of hydrocarbon is named with a prefix indicating the number of carbon atoms it contains, followed by the suffix `ane`, `ene`, or `yne` if it is an alkane, alkene, or alkyne respectively. The numerical prefixes are as follows:
```
1  <-> meth
2  <-> eth
3  <-> prop
4  <-> but
5  <-> pent
6  <-> hex
7  <-> hept
8  <-> oct
9  <-> non
10 <-> dec
```
For example, we can see `propane` has 3 carbon and 8 hydrogen atoms, and `heptyne` has 7 carbon and 12 hydrogen atoms.
## Challenge
Your task is to write a function or program that receives a string or list of characters representing the name of a hydrocarbon, and produces or outputs the number of carbon and hydrogen atoms in a molecule of that hydrocarbon.
For each of the 30 hydrocarbon names, the code must accept at least one possible capitalization of that name. For example, it is fine if your code works for `mEthane` but not `methane`, and `ETHAnE` but not `ETHANE`, and `Propane` but not `propane`. The inputs `methene` and `methyne` may give undefined output since those are not real chemicals.
The input and output can be in any convenient format. You don't need to label which number represents carbon and which represents hydrogen, just keep the order of the numbers consistent.
You may assume the input will correspond to a valid hydrocarbon, and there are at most 10 carbon atoms.
## Examples
```
Possible Input -> Possible Output
Methane        -> 1 4
propane        -> 3 8
Heptyne        -> 7 12
Decene         -> 10 20
```
## Rules
* No standard loopholes.
* Shortest code in bytes wins.
  
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), ~~27 26~~ 24 bytes
*Saved 1 byte thanks to @KevinCruijssen*  
*Saved 2 bytes thanks to @Grimmy*
**Note:** This code was based on my understanding that only the capitalization of the first letter was customizable. It has since been clarified that it applies to *all* letters, leading to [this significantly shorter answer](https://codegolf.stackexchange.com/a/196708/58563) by Grimmy.
Expects `mEpBPhHond` for the capitalization of the first letter.
```
ćC•>·¿*•s÷θD>,₂I3(èH÷+·,
```
[Try it online!](https://tio.run/##yy9OTMpM/f//SLvzo4ZFdoe2H9qvBWQUH95@boeLnc6jpiZPY43DKzwOb9c@tF3n/3@P1IKSyrxUAA "05AB1E – Try It Online")
### How?
We define the following magic constant:
$$M=1902159854$$
The number of carbon atoms is given by:
$$c=\left(\left\lfloor\frac{M}{n}\right\rfloor\bmod 10\right)+1$$
where \$n\$ is the first character of the input turned into an 05AB1E code point (0-9, A-Z, a-z, ...).
```
 input |  n  | floor(M/n) | mod 10
-------+-----+------------+--------
 meth- |  48 |   39628330 |   0
 Eth-  |  14 |  135868561 |   1
 prop- |  51 |   37297252 |   2
 But-  |  11 |  172923623 |   3
 Pent- |  25 |   76086394 |   4
 hex-  |  43 |   44236275 |   5
 Hept- |  17 |  111891756 |   6
 oct-  |  50 |   38043197 |   7
 non-  |  49 |   38819588 |   8
 dec-  |  39 |   48773329 |   9
```
### Commented
```
                         # example input: 'Heptyne'
ć                        # extract the first character -> 'H'
 C                       # turn it into an integer -> 17
  •>·¿*•                 # push the magic constant 1902159854
        s÷               # swap + integer division -> 1902159854 / 17 = 111891756
          θ              # keep the last digit (therefore a modulo 10) -> 6
           D>            # duplicate and increment the copy
             ,           # print the number of carbon atoms
              ₂          # push 26
               I         # push the input string
                3(è      # extract the 3rd to last character -> 'y'
                   H     # parse it as base-36 -> 34
                    ÷    # integer division -> 26 / 34 = 0
                     +   # add to the number of carbon atoms - 1 -> 6
                      ·  # double
                       , # print the number of hydrogen atoms
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), ~~16~~ ~~12~~ 11 bytes
```
.uJ4ôCx<O1ǝ
```
[Try it online!](https://tio.run/##LcwxCsIwGMXxvaconVUQHMUiNSAObcAIOrYS0KGpaBUDXsVbeAMHjxXf@5rpDz8er7vVzdmG18PnWTpepFnut2Fy38y@n@I5r6a/dxiF1vZr72zCWqekdWmTyFEjXq6VprJklt7sejJCRWSsnJExKmOUflJ7MkJFBtRmUG0G1jKujvKMUBFi2bmDkyggsgSubMElwiWC5R8 "05AB1E – Try It Online")
This takes full advantage of the rule that only one possible capitilization has to be handled for each input. All inputs are at least 6 letters long, so we can store 6 bits of data in the capitilization. 4 of those bits are used to store the carbon count, and the remaining 2 store half of the extra hydrogen count (0 for alkynes, 1 for alkenes, 2 for alkanes).
```
.u             # uppercase? (returns a list of 0s and 1s)
  J            # join that list to a string
   4ô          # split in chunks of 4 digits
     C         # convert each chunk from binary
      x        # double each, without popping the original list
       <       # -1 from each
        O      # sum
         1ǝ    # replace the second element of the list with this sum
```
Alternative 11:
```
.u2β3‰<.¥¦ƶ
```
[Try it online!](https://tio.run/##Jc4xCsJAFIThPqcI1ppCWzEEXbB6BozFlht5EAt3RRNxwcLLaC0WHiCFpYfwIuu8pPoZvmbcyZQ7DtezTwfxaBYPUr8OSTP@via/23OatPf28XmHYdhzXWniSKpISZfGcoR4qyRM3TLAw9HlGihVtt8ZuGwKDS43NUMRI8hUe6CUqd8ZuFIXDUYUdSsDVpwXXhBl228DdvPCgxFlu5UB7YrkMiKPyVk5vOCtHEbkMILDfw)
[Answer]
# [R](https://www.r-project.org/), ~~96~~ ~~86~~ ~~82~~ 79 bytes
```
`!`=utf8ToInt;(5-rev(K<-!scan(,""))[3]%%16)/2*0:1+match(K[1],!"mepbPhHond")*1:2
```
[Try it online!](https://tio.run/##K/r/P0Exwba0JM0iJN8zr8Raw1S3KLVMw9tGV7E4OTFPQ0dJSVMz2jhWVdXQTFPfSMvAylA7N7EkOUPDO9owVkdRKTe1ICkgwyM/L0VJU8vQyuh/SmpyZV7qfwA "R – Try It Online")
Accepts the prefixes with capitalization `mepbPhHond` in order; returns `c(Carbon, Hydrogen)`.
`yea` for this answer.
Thanks to Robin Ryder for golfing down [4 bytes](https://tio.run/##K/r/P0Exwba0JM0iJN8zr8Ta21axODkxT0NHSUnTOlkjz0Y3N7EkOUPDO9owVkdRKTe1ICkgwyM/L0VJU8dIK09bw1S3KLVMw1sz2jhWVdXQTFPfSPN/SmpyZV7qfwA).
[Answer]
# JavaScript (ES6), 62 bytes
Similarly to other answers, expects all names in lowercase, except `Pent-` and `Hept-`. Returns `[carbon, hydrogen]`.
```
s=>[n='epbPhHond'.search(s[0])+2,n+/a/.test(s)-/y/.test(s)<<1]
```
[Try it online!](https://tio.run/##bcmxDsIgEADQ3R8BUgvVuTh37N50oHAVTb0jHDHp12Pi4GC6veQ93duxz49UWqQAdbWV7W1CKyAtYxwIg9AMLvsoeepm1VzP2BhndAEuklVr9p/7/jJXT8i0gd7oLlcpXlCiQxBKnf4mZUrHM0Aq@@EE8PCN@gE "JavaScript (Node.js) – Try It Online")
---
# JavaScript (ES6), ~~84~~ 79 bytes
A version where the capitalization doesn't matter. Returns `[carbon, hydrogen]`.
```
s=>[n=-~'519.80.76423'[parseInt(s[0]+s[2],28)%17],n+/a/.test(s)-/y/.test(s)<<1]
```
[Try it online!](https://tio.run/##bcm7CsIwFADQ3f@QJLRN2vpohdbJQQfBPWQI6a0PShJ6g9DFX4/i4CDdDpyHfmo0492HzLoOYt9GbPfSttmLbIodr3NebdflikivR4STDRRlrhKUpUrLmi2LSqU2EVrwAPhJlonp56YpVDTOohuAD@5Ke0rOEG7aAmFs8TeX0fn5OYIP0@wcwMA34hs "JavaScript (Node.js) – Try It Online")
## How?
### Carbon
We can concatenate the first and third characters of each prefix to build a unique string identifier.
*Example:* `meth` → `mt`
We can convert this string ID to an integer ID in \$[0..11]\$ (still unique) by parsing it as base-28 and applying a modulo \$17\$ (these values were found with a brute-force search).
Because the character set of base-28 is `'0'` to `'r'`, the parsing stops if a character above `'r'` is encountered.
*Example:* `mt` → `m` → \$22 \bmod 17=5\$
The results are summarized in the following table:
```
 input | key  | base 28 -> dec. | mod 17
-------+------+-----------------+--------
 meth- | 'm'  |        22       |    5
 eth-  | 'eh' |       409       |    1
 prop- | 'po' |       724       |   10
 but-  | 'b'  |        11       |   11
 pent- | 'pn' |       723       |    9
 hex-  | 'h'  |        17       |    0
 hept- | 'hp' |       501       |    8
 oct-  | 'o'  |        24       |    7
 non-  | 'nn' |       667       |    4
 dec-  | 'dc' |       376       |    2
```
### Hydrogen
Neither `'a'` nor `'y'` appears in any of the prefixes. Therefore, it is safe to test whether the suffix is `-ane` or `-yne` by looking for these letters in the entire input string.
The following expression:
```
/a/.test(s) - /y/.test(s)
```
evaluates to either \$-1\$ for `-yne`, \$0\$ for `-ene` or \$1\$ for `-ane`.
Given the number \$n\$ of carbon atoms, the number of hydrogen atoms is:
```
(n + /a/.test(s) - /y/.test(s)) << 1
```
(and because `<<` has a higher precedence than `+` and `-`, the parentheses can be omitted)
[Answer]
# [Pyth](https://github.com/isaacg1/pyth), 33 31 bytes
```
Kx"mepbPhHond"hQhKy+K/%CePPQ7 3
```
[Try it online!](https://tio.run/##K6gsyfj/37tCKTe1ICkgwyM/L0UpIzDDu1LbW1/VOTUgINBcwfj/f6Wk0pLKvFQlAA "Pyth – Try It Online")
Uses, as you can see, `mepbPhHond` capitalization. Probably can be golfed much further. Returns carbon, hydrogen on newlines
## How it works
```
Kx"mepbPhHond"hQhKy+K/%CePPQ7 3
 x            hQ    - The index of the first letter of the input
  "mepbPhHond"      - in "mepnPhHond"
K               hK  - Assign to K... and then print K+1
                       CePPQ       - The codepoint of the third last character 
                                       in the input (Q[:-1][:-1][-1])
                      /%     7 3    - Modulo 7 divided by 3 (ane, ene, yne -> 2, 1, 0)
                   +K               - ... plus K
                  y                 - ... times 2, and print implicitly
```
[Answer]
# [Python 3.8](https://docs.python.org/3.8/), 60 bytes
As other answers, all the names except for those starting with `Prop-` or `Hept-`, must be lowercase.
```
lambda x:(c:=' mePbphHond'.find(x[0]),c+'ea'.find(x[-3])<<1)
```
-4 bytes thanks to @Arnauld
[Try it online!](https://tio.run/##XcyxDoMgEADQvV/hBpfWpo1LY3R3dG8dEI5gUo4LYcCvx8HEgfUNj/fkAnUfjsWOv/JXfjWqyb3U/Sgaj/PKbgpkxNNuZGT@vhZ46LtAdUnbLTAMbygcN0rSSuExOUUoAG6XzTFwbRNy2iszqLEiRkq1OcznVg4)
---
### Fun fact:
Another interesting fact I observerd is the following one:
* \$ord(a)=97\to9-7=2\$ which is the number we have to add for alk**a**nes.
* \$ord(e)=101\to1-0-1=0\$ which is the number we have to add for alk**e**nes.
* \$ord(y)=121\to1-2-1=-2\$ which is the number we have to add for alk**y**nes.
I don't think that I can modify my answer using this way to be less bytes thank it is right now, but I thought it was worth mentioning and maybe another answer can use it effectively!
An implementation of the above idea is the [following one](https://tio.run/##XcwxC4MwEIbhvb8iW2KrpdSlCO6O7q2DJheMmOSIJ@ivt4qlQ258uPfDlXrv8heGTZefbWxtp1q2FEIWJWcW6g77yjvF79o4JZb3o0nS51XeAqhZgvgFJh0Kkw2pbVEYR@lEQfhw/Gd5kxx30cFbpmcnyftxYsaiD8TOmQ3DXgktuAXqWwd8D/5WB4@xVYC0RqZAQkQIjmLrYTnXti8):
```
lambda x:(c:=' mePbphHond'.find(x[0]),2*c+reduce(lambda i,j:i-j,map(int,str(ord(x[-3])))))
from functools import reduce
```
which obviously is much more bytes (119).
[Answer]
# [Python 2](https://docs.python.org/2/), 66 bytes
```
def f(s):n='mePbpHhond'.find(s[0]);return-~n,2*(n+ord(s[-3])%50%3)
```
[Try it online!](https://tio.run/##LY6xDoIwFEVn@Yq3kFIFQyAuGHZGdsKg9jUw8Nq0z0QWf70WYTu5Jzm5duXJUBWCQg0687KhVizYP20XdyWueiaV@aEc5d0hvx0VX8qrc0YX4zZR1KNMb2Vay8Do2UMLQwzw9CAUOYjeGXugRWLccULL644dfg6v8LXpMdHGAcNM8C82ycm6mRg4jw9ZJuEH "Python 2 – Try It Online")
Over thinking it a bit. Accepts only lower case, except for 'Prop' and 'Hept' (which must be capitalized). Returns (carbon, hydrogen).
# [Python 2](https://docs.python.org/2/), ~~84~~ 82 bytes
```
def f(s):n=int('8702563914'[hash(s[:-3])%876%10]);return n+1,2*(n+ord(s[-3])%50%3)
```
[Try it online!](https://tio.run/##LY45DoMwEADr8IptkO1AJI5whIiXIAoUFpkia8veFLzesUi6KWaksQdrQ1UIK26wSa8GGndiKfquqJq2fpR3MenFa@mn4VbPKu27Ni2LWT0d8scRUFbm1VVSZtwapdNpirRWgdGzhxEm8UbWC6HIQVhn7B81Wj5@uOILI83JZhww7ARnPCQX6@IOcB7nWCXhCw "Python 2 – Try It Online")
Only accepts lower case.
[Answer]
# [Ruby](https://www.ruby-lang.org/), ~~74~~ 67 bytes
```
->s{z="  etthroutenexepctonec".index s[1,2];[z/2,z-2*(s[-3]<=>?e)]}
```
[Try it online!](https://tio.run/##VdBBDoIwEIXhqzRdqQGNuFTwIE0XBR/BBW0DJamAZ0eMZRp3X/K/2Uw3lK@lzpe06Kcx54zBuaYzg4OGh62c0aj48akf8KwX5ySTVzGesmRMs8OuF@lF3vLijr18L4K3cI3S4AnjfwLp9ZPtjFWRiAyDcnCKBNJ2Dr3lLxEZBg28IoFE1ToVicgwMNXWV4EUqjZakUAK9YFKkUD6VnlslZ1mP1smfFILL9evfQA "Ruby – Try It Online")
Thanks @Value Ink for ~~golfing it for me. :-)~~ -7 bytes
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/mathematica/), ~~26~~ 25 bytes
```
Tally@*AtomList@*Molecule
```
Thanks to att for the byte reduction.
[![enter image description here](https://i.stack.imgur.com/XYCRy.png)](https://i.stack.imgur.com/XYCRy.png)
[Answer]
# [Python 3](https://docs.python.org/3/), 83 bytes
```
x=input();n=list('_mepbPhHond').index(x[0]);print(n,2*n+{'a':2,'e':0,'y':-2}[x[-3]])
```
[Try it online!](https://tio.run/##BcFRC4MgFAbQn3N1sxH2ZvTeY@8iw6GQsD4v5cCIfrs7h8@yZgyt1SmBf0XIEdM3HUXQe4v8WdY5I5B8JYRYRbW9kyPvCUVA6QeeF3kyWlEk0ys6yXT6ttV2g3OyNd4ze8Q/ "Python 3 – Try It Online")
-51 bytes thanks to 79037662
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 39 bytes
```
≔⊘⁺³⌕”↶↓>AkQN!{a⁶⟧”…θ⁻Ｌθ⁵ηＩ⟦η⊗⁻⁺η№θa№θy
```
[Try it online!](https://tio.run/##RY0xC8IwFIR3f8Uj0wvESZw6SUQcFLqLQ9o@mkB4SZO20F8fUx287Y777nprUh@ML@WSsxsZ78avNGDrl4wnBTfHAwogiKmDSBYsBWAYhAK99Z60DREnBU/HFXgQj7PFSSo4y10KrGwObXI8ozZ5xpdVcA1L5@vHj/k@1VSHpZbqlDBiB/9@q16@pWxKiSlEw1SOq/8A "Charcoal – Try It Online") Link is to verbose version of code. Takes input in lower case and outputs carbon and hydrogen atoms on separate lines. Explanation:
```
…θ⁻Ｌθ⁵
```
Remove the last 5 characters of the input.
```
⌕”↶↓>AkQN!{a⁶⟧”...
```
Search for the resulting prefix within the compressed string `e prb peh heo n d`. Note that there's a space before the `e`, so that the the prefixes are found at positions `-1` for me(th?ne), `1` for e(th?ne), `3` for pr(op?ne) etc.
```
≔⊘⁺³...η
```
Add 3 to the position, then halve and store the resulting number of carbon atoms.
```
Ｉ⟦η
```
Output the carbon atoms...
```
⊗⁻⁺η№θa№θy
```
... and adjust for whether there is an `a` or `y` in the input, before doubling to give the number of hydrogen atoms.
[Answer]
# [C# (Visual C# Interactive Compiler)](http://www.mono-project.com/docs/about-mono/releases/5.0.0/#csc), 65 bytes
```
x=>(l=" mepbPhHond".IndexOf(x[0]),~-l+x[x.Count-3]%7/3<<1);int l;
```
[Try it online!](https://tio.run/##bY1BC4IwGIbv/YoxCDZSKzx0cHoJwkCoQ9BBPNj81IFu4iasS399GR065OU9PA88L9c@18KdJslZJrRhvC3HxENESOOheWjSxM7GCelijHoYHtc2VbLCwVlWYC81sfmuoN7L7zY2t8FRTdL4YbE@bEPG9jSaE6iL3K@HaqLNKGSDBI2Thojgpj7PhNJodR@FgUxIIDXBPZi2lID/xDCqYVGkMJjnkqiAw5e7Nw "C# (Visual C# Interactive Compiler) – Try It Online")
[Answer]
# [GolfScript](http://www.golfscript.com/golfscript/), 32 30 bytes
Thanks to [this user](https://codegolf.stackexchange.com/users/89930/79037662) for pointing out that I forgot to account for -ane, -ene, -yne
```
.0="mepbPhHond"?).@-3=7%3/(+2*
```
[Try it online!](https://tio.run/##S8/PSStOLsosKPn/X8/AVik3tSApIMMjPy9FyV5Tz0HX2NZc1VhfQ9tI6/9/j9SCksq8VAA "GolfScript – Try It Online\"")
This uses the same concept as in [this answer](https://codegolf.stackexchange.com/a/196677/80383)
Explanation:
```
.0=                                 Make a copy of input and select first letter
   "mepbPhHond"?)                   Find index of letter and increase by one for number of carbons
                 .@                 Duplicate for number of hydrogens and bring input to top of stack
                   -3=              Get the a, e, or y in ane, ene, yne
                      7%3/          Ascii value mod 7 integer divide 3
                          (+        Decrement and add to number of carbons
                            2*      Double
```
Uses `mepbPhHond` capitalization.
Example Execution:
Input: propene
```
.0=                                 Stack: 'propene' 'p'
   "mepbPhHond"?)                   Stack: 'propene' 3
                 .@                 Stack: 3 3 'propene'
                   -3=              Stack: 3 3 'e'
                      7%3/          Stack: 3 3 1
                          (+        Stack: 3 3
                            2*      Stack: 3 6
```
]