Back to the chemistry class Introduction

One of the first things I learned in chemistry, was giving the formula for the combustion of alkanes. The most basic example was: 2CH4 + 4O2 &gt; 4H2O + 2CO2. Note that the equation could have been simplified by dividing every coefficient by 2, we would get CH4 + 2O2 &gt; 2H2O + CO2. To make things easier, we are going to ignore this step.

You can see that with the combustion of any alkane, oxygen is used. After the reaction, only CO2 and H2O are made.

The task:

Give a complete program that takes input from STDIN or the nearest possible equivalent, and outputs the total reaction using STDOUT or the nearest possible equivalent.

The input will always be in the form C(n)H(2n+2), with n &gt; 0. These are some example inputs:

CH4
C2H6
C3H8
C4H10
C5H12
C6H14

etc.


A useful tip:

Every alkane has a standard pattern in the combustion reaction:

2C(n)H(2n+2) + (3n+1)O2 &gt; (2n+2)H2O + (2n)CO2


e.g.

C4H10 gives the following equation: 2C(4)H(2*4+2) + (3*4+1)O2 &gt; (2*4+2)H2O + (2*4)CO2. After calculating everything, we get this final equation: 2C4H10 + 13O2 &gt; 10H2O + 8CO2

Examples:

input:  CH4
output: 2CH4 + 4O2 &gt; 4H2O + 2CO2

input:  C3H8
output: 2C3H8 + 10O2 &gt; 8H2O + 6CO2

input:  C4H10
output: 2C4H10 + 13O2 &gt; 10H2O + 8CO2

input:  C12H26
output: 2C12H26 + 37O2 &gt; 26H2O + 24CO2


Rules:


You need to provide a full program.
Your program needs to take input from STDIN, or the nearest equivalent if not possible.
Your program needs to output using STDOUT, or the nearest equivalent if not possible.
Note that I used spaces for the examples to increase readability, these are not necessary. 2CH4 + 4O2 &gt; 4H2O + 2CO2 and 2CH4+4O2&gt;4H2O+2CO2 are both valid outputs. However, if you consistently use spaces for the output, you get a -10% bonus
This is code-golf, so the program with the least amount of bytes wins!
Python 3, 86 * 0.9 = 77.4 bytes



s=input()
N=int(s.split('H')[1])
print("2%s + %dO2 &gt; %dH20 + %dCO2"%(s,N*1.5-2,N,N-2))


Extracts the number of H's rather than the number of C's from the input. This avoid special-casing CH4 and simplifies the output expressions in terms of N=2n+2.

The output has parameters plugged in via string formatting. The first summand is just the input string, and the rest have calculated numbers plugged in. Note that N*1.5-2 (same as N*3/2-2) gives a float, but the string formatting converts it to an int.