Case 989

Equal grams of hydrogen and oxygen were sixteen moles to one

equal_grams_of_hydrogen_and_oxygen_were_sixteen_moles_to_one.eml - A student running a small fuel cell feeds it 16 g of hydrogen and 16 g of oxygen, reasoning that equal amounts of the two reactants will be used up together and all 32 g will become water. How much water the cell can really make, and what is left over, is computed below.

ok: true — round-trip fixpoint reached (python1 == python2)updated 2026-09-24

EML

eml
# Self-authored for the EML case corpus (no external origin). A student running a
# small fuel cell feeds it 16 g of hydrogen and 16 g of oxygen, reasoning that
# equal amounts of the two reactants will be used up together and all 32 g will
# become water. How much water the cell can really make, and what is left over,
# is computed below.
#
# The reasoning is careful. Both gases really were weighed to the gram; mass
# really is conserved; the cell really makes nothing but water; and the intent
# is exactly 'use up both gases'.
#
# A reaction counts molecules, not grams: two molecules of hydrogen combine with
# one of oxygen, and an oxygen molecule weighs sixteen times a hydrogen one. So
# 16 g of hydrogen is 8 moles and 16 g of oxygen is half a mole - sixteen to one,
# where the reaction wants two to one. The oxygen runs out after 2 g of hydrogen
# has reacted: 18 g of water, and 14 g of hydrogen left unused.

16 => hydrogen_supplied_g
16 => oxygen_supplied_g
2 => hydrogen_molecule_g_per_mole
32 => oxygen_molecule_g_per_mole
18 => water_g_per_mole

int(hydrogen_supplied_g * 10 / hydrogen_molecule_g_per_mole) => hydrogen_supplied_tenths_of_a_mole
int(oxygen_supplied_g * 10 / oxygen_molecule_g_per_mole) => oxygen_supplied_tenths_of_a_mole
int(hydrogen_supplied_tenths_of_a_mole / oxygen_supplied_tenths_of_a_mole) => moles_of_hydrogen_per_mole_of_oxygen
2 * oxygen_supplied_tenths_of_a_mole => hydrogen_the_oxygen_can_take_tenths_of_a_mole
int(hydrogen_the_oxygen_can_take_tenths_of_a_mole * hydrogen_molecule_g_per_mole / 10) => hydrogen_used_g
hydrogen_supplied_g - hydrogen_used_g => hydrogen_left_over_g
int(hydrogen_the_oxygen_can_take_tenths_of_a_mole * water_g_per_mole / 10) => water_made_g
hydrogen_supplied_g + oxygen_supplied_g => mass_supplied_g
int(hydrogen_left_over_g * 1000 / hydrogen_supplied_g) => hydrogen_wasted_per_mille
int(hydrogen_supplied_tenths_of_a_mole / 2 * oxygen_molecule_g_per_mole / 10) => oxygen_needed_for_all_the_hydrogen_g

"hydrogen supplied               : " + str(hydrogen_supplied_g) + " g, " + str(hydrogen_supplied_tenths_of_a_mole) + " tenths of a mole" ^0
"oxygen supplied                 : " + str(oxygen_supplied_g) + " g, " + str(oxygen_supplied_tenths_of_a_mole) + " tenths of a mole" ^0
"moles of hydrogen per mole of oxygen : " + str(moles_of_hydrogen_per_mole_of_oxygen) + ", where the reaction takes 2" ^0
"" ^0
"hydrogen the oxygen can take    : " + str(hydrogen_the_oxygen_can_take_tenths_of_a_mole) + " tenths of a mole, " + str(hydrogen_used_g) + " g" ^0
"water made                      : " + str(water_made_g) + " g" ^0
"hydrogen left over              : " + str(hydrogen_left_over_g) + " g, " + str(hydrogen_wasted_per_mille) + " per mille of it" ^0
"oxygen needed to use it all     : " + str(oxygen_needed_for_all_the_hydrogen_g) + " g" ^0
"" ^0

# ---- what the student verified ----

"the equal-amounts reasoning" ^0
"  weighed : " + str(hydrogen_supplied_g) + " g of each, to the gram" ^0
"  mass : conserved" ^0
"  product : water and nothing else" ^0
"  intent : use up both gases" ^0
"  facts wrong : 0" ^0
"  verdict : ALL " + str(mass_supplied_g) + " G BECOME WATER" ^0
"" ^0
"  weighing both gases exactly is the part done right here, and" ^0
"  it is why " + str(hydrogen_supplied_g) + " g of each is exactly what went into the cell" ^0
"" ^0

# ---- what the reaction counts ----

"molecules, not grams" ^0
"  the reaction : two hydrogen molecules to one oxygen molecule" ^0
"  their weights : " + str(hydrogen_molecule_g_per_mole) + " and " + str(oxygen_molecule_g_per_mole) + " g a mole, sixteen to one" ^0
"  equal grams : " + str(hydrogen_supplied_tenths_of_a_mole) + " tenths of a mole of hydrogen against " + str(oxygen_supplied_tenths_of_a_mole) ^0
"    of oxygen, " + str(moles_of_hydrogen_per_mole_of_oxygen) + " to one" ^0
"  what runs out : the oxygen, after " + str(hydrogen_used_g) + " g of hydrogen" ^0
"  what is made : " + str(water_made_g) + " g of water" ^0
"  to use all the hydrogen : " + str(oxygen_needed_for_all_the_hydrogen_g) + " g of oxygen, eight times its mass" ^0
"" ^0

# ---- what the student got ----

"the cell" ^0
"  believed : " + str(mass_supplied_g) + " g of water, nothing left" ^0
"  actual : " + str(water_made_g) + " g of water and " + str(hydrogen_left_over_g) + " g of hydrogen still in the line" ^0
"  is the weighing wrong : no" ^0
"  is equal mass equal amount : not to a reaction, which counts" ^0
"    molecules" ^0
"" ^0

# ---- null control ----

# The same supply judged by moles instead of by grams.
32 => nc_water_read_from_the_combined_mass_g
18 => nc_water_read_from_the_limiting_gas_g
14 => nc_grams_the_mole_count_removes

"null control - count in moles" ^0
"  water, read from the combined mass : " + str(nc_water_read_from_the_combined_mass_g) + " g" ^0
"  water, read from the gas that runs out : " + str(nc_water_read_from_the_limiting_gas_g) + " g" ^0
"  grams the mole count removes : " + str(nc_grams_the_mole_count_removes) ^0
"  no gas and no cell changed; the reactants were counted the way" ^0
"  the reaction counts them" ^0
"" ^0

# ---- the rule ----

"what equal, exact weights of the two gases guarantee" ^0
"  " + str(hydrogen_supplied_g) + " g of each went in : exactly" ^0
"  both are used up together : not addressed; the reaction takes" ^0
"    molecules two to one, equal grams are " + str(moles_of_hydrogen_per_mole_of_oxygen) + " to one, and the" ^0
"    oxygen runs out with " + str(hydrogen_left_over_g) + " g of hydrogen unused" ^0
"" ^0

"a scale weighs and a reaction counts; equal on the one is lopsided on the" ^0
"other whenever the pieces are not the same weight" ^0
"" ^0

"Sixteen grams of each went in - weighed exactly. But a reaction counts" ^0
"molecules, and equal grams of hydrogen and oxygen are " + str(moles_of_hydrogen_per_mole_of_oxygen) + " moles to one where" ^0
"the reaction wants two to one, so the oxygen runs out at " + str(water_made_g) + " g of water with" ^0
"" + str(hydrogen_left_over_g) + " g of hydrogen left, until the gases are measured in moles rather than grams." ^0

Python (deterministic transpilation)

python
hydrogen_supplied_g = 16
oxygen_supplied_g = 16
hydrogen_molecule_g_per_mole = 2
oxygen_molecule_g_per_mole = 32
water_g_per_mole = 18
hydrogen_supplied_tenths_of_a_mole = int(hydrogen_supplied_g * 10 / hydrogen_molecule_g_per_mole)
oxygen_supplied_tenths_of_a_mole = int(oxygen_supplied_g * 10 / oxygen_molecule_g_per_mole)
moles_of_hydrogen_per_mole_of_oxygen = int(hydrogen_supplied_tenths_of_a_mole / oxygen_supplied_tenths_of_a_mole)
hydrogen_the_oxygen_can_take_tenths_of_a_mole = 2 * oxygen_supplied_tenths_of_a_mole
hydrogen_used_g = int(hydrogen_the_oxygen_can_take_tenths_of_a_mole * hydrogen_molecule_g_per_mole / 10)
hydrogen_left_over_g = hydrogen_supplied_g - hydrogen_used_g
water_made_g = int(hydrogen_the_oxygen_can_take_tenths_of_a_mole * water_g_per_mole / 10)
mass_supplied_g = hydrogen_supplied_g + oxygen_supplied_g
hydrogen_wasted_per_mille = int(hydrogen_left_over_g * 1000 / hydrogen_supplied_g)
oxygen_needed_for_all_the_hydrogen_g = int(hydrogen_supplied_tenths_of_a_mole / 2 * oxygen_molecule_g_per_mole / 10)
print("hydrogen supplied               : " + str(hydrogen_supplied_g) + " g, " + str(hydrogen_supplied_tenths_of_a_mole) + " tenths of a mole")
print("oxygen supplied                 : " + str(oxygen_supplied_g) + " g, " + str(oxygen_supplied_tenths_of_a_mole) + " tenths of a mole")
print("moles of hydrogen per mole of oxygen : " + str(moles_of_hydrogen_per_mole_of_oxygen) + ", where the reaction takes 2")
print("")
print("hydrogen the oxygen can take    : " + str(hydrogen_the_oxygen_can_take_tenths_of_a_mole) + " tenths of a mole, " + str(hydrogen_used_g) + " g")
print("water made                      : " + str(water_made_g) + " g")
print("hydrogen left over              : " + str(hydrogen_left_over_g) + " g, " + str(hydrogen_wasted_per_mille) + " per mille of it")
print("oxygen needed to use it all     : " + str(oxygen_needed_for_all_the_hydrogen_g) + " g")
print("")
print("the equal-amounts reasoning")
print("  weighed : " + str(hydrogen_supplied_g) + " g of each, to the gram")
print("  mass : conserved")
print("  product : water and nothing else")
print("  intent : use up both gases")
print("  facts wrong : 0")
print("  verdict : ALL " + str(mass_supplied_g) + " G BECOME WATER")
print("")
print("  weighing both gases exactly is the part done right here, and")
print("  it is why " + str(hydrogen_supplied_g) + " g of each is exactly what went into the cell")
print("")
print("molecules, not grams")
print("  the reaction : two hydrogen molecules to one oxygen molecule")
print("  their weights : " + str(hydrogen_molecule_g_per_mole) + " and " + str(oxygen_molecule_g_per_mole) + " g a mole, sixteen to one")
print("  equal grams : " + str(hydrogen_supplied_tenths_of_a_mole) + " tenths of a mole of hydrogen against " + str(oxygen_supplied_tenths_of_a_mole))
print("    of oxygen, " + str(moles_of_hydrogen_per_mole_of_oxygen) + " to one")
print("  what runs out : the oxygen, after " + str(hydrogen_used_g) + " g of hydrogen")
print("  what is made : " + str(water_made_g) + " g of water")
print("  to use all the hydrogen : " + str(oxygen_needed_for_all_the_hydrogen_g) + " g of oxygen, eight times its mass")
print("")
print("the cell")
print("  believed : " + str(mass_supplied_g) + " g of water, nothing left")
print("  actual : " + str(water_made_g) + " g of water and " + str(hydrogen_left_over_g) + " g of hydrogen still in the line")
print("  is the weighing wrong : no")
print("  is equal mass equal amount : not to a reaction, which counts")
print("    molecules")
print("")
nc_water_read_from_the_combined_mass_g = 32
nc_water_read_from_the_limiting_gas_g = 18
nc_grams_the_mole_count_removes = 14
print("null control - count in moles")
print("  water, read from the combined mass : " + str(nc_water_read_from_the_combined_mass_g) + " g")
print("  water, read from the gas that runs out : " + str(nc_water_read_from_the_limiting_gas_g) + " g")
print("  grams the mole count removes : " + str(nc_grams_the_mole_count_removes))
print("  no gas and no cell changed; the reactants were counted the way")
print("  the reaction counts them")
print("")
print("what equal, exact weights of the two gases guarantee")
print("  " + str(hydrogen_supplied_g) + " g of each went in : exactly")
print("  both are used up together : not addressed; the reaction takes")
print("    molecules two to one, equal grams are " + str(moles_of_hydrogen_per_mole_of_oxygen) + " to one, and the")
print("    oxygen runs out with " + str(hydrogen_left_over_g) + " g of hydrogen unused")
print("")
print("a scale weighs and a reaction counts; equal on the one is lopsided on the")
print("other whenever the pieces are not the same weight")
print("")
print("Sixteen grams of each went in - weighed exactly. But a reaction counts")
print("molecules, and equal grams of hydrogen and oxygen are " + str(moles_of_hydrogen_per_mole_of_oxygen) + " moles to one where")
print("the reaction wants two to one, so the oxygen runs out at " + str(water_made_g) + " g of water with")
print("" + str(hydrogen_left_over_g) + " g of hydrogen left, until the gases are measured in moles rather than grams.")

stdout (executed)

text
hydrogen supplied               : 16 g, 80 tenths of a mole
oxygen supplied                 : 16 g, 5 tenths of a mole
moles of hydrogen per mole of oxygen : 16, where the reaction takes 2

hydrogen the oxygen can take    : 10 tenths of a mole, 2 g
water made                      : 18 g
hydrogen left over              : 14 g, 875 per mille of it
oxygen needed to use it all     : 128 g

the equal-amounts reasoning
  weighed : 16 g of each, to the gram
  mass : conserved
  product : water and nothing else
  intent : use up both gases
  facts wrong : 0
  verdict : ALL 32 G BECOME WATER

  weighing both gases exactly is the part done right here, and
  it is why 16 g of each is exactly what went into the cell

molecules, not grams
  the reaction : two hydrogen molecules to one oxygen molecule
  their weights : 2 and 32 g a mole, sixteen to one
  equal grams : 80 tenths of a mole of hydrogen against 5
    of oxygen, 16 to one
  what runs out : the oxygen, after 2 g of hydrogen
  what is made : 18 g of water
  to use all the hydrogen : 128 g of oxygen, eight times its mass

the cell
  believed : 32 g of water, nothing left
  actual : 18 g of water and 14 g of hydrogen still in the line
  is the weighing wrong : no
  is equal mass equal amount : not to a reaction, which counts
    molecules

null control - count in moles
  water, read from the combined mass : 32 g
  water, read from the gas that runs out : 18 g
  grams the mole count removes : 14
  no gas and no cell changed; the reactants were counted the way
  the reaction counts them

what equal, exact weights of the two gases guarantee
  16 g of each went in : exactly
  both are used up together : not addressed; the reaction takes
    molecules two to one, equal grams are 16 to one, and the
    oxygen runs out with 14 g of hydrogen unused

a scale weighs and a reaction counts; equal on the one is lopsided on the
other whenever the pieces are not the same weight

Sixteen grams of each went in - weighed exactly. But a reaction counts
molecules, and equal grams of hydrogen and oxygen are 16 moles to one where
the reaction wants two to one, so the oxygen runs out at 18 g of water with
14 g of hydrogen left, until the gases are measured in moles rather than grams.

Trace event types

eml:run:starteml:assigneml:outputeml:run:done