[Community puzzle] Chemical Equation Balancing

This topic is about the puzzle Chemical Equation Balancing.

Feel free to send your feedback or ask some help here!

I already can think of a bruteforce approach.

Is there any other way ? Just want a yes or no :slight_smile:

If bruteforce means trying every possible combination, then yes, there are other ways.

Yup so i am assuming a maximum value of a coefficient say 10.

And then I will try all values between 1-10 for all molecules on both sides of the equation.

OK, see if you can think of another way :slight_smile:

Hey I just solved this puzzle of the week and dint get the achievement ? I havent gotten it before.

Update

Nevermind. I got it 30 minutes later.

Hi !
I’m trying to solve this week’s puzzle.
I did manage to pass all the testcases, but can’t pass validator #6
I googled ‘Potassium tetrachloroplatinate’ and found an equation (2K2PtCl6 + N2H6Cl2 -> 2K2PtCl4 + 6HCl + N2).
My code is able to balance this one too. But is it the right one ?

No, the validator has Potassium tetrachloroplatinate on the left side of the equation and combines it with some Hydrocarbon.

Hi. I passed all the tests but not the first validator (“Hydrogen Peroxide”). I am not sure what I am missing. Could I get a hint? Thanks.

Look for the equation on the wikipedia page of hydrogen peroxide, and test if your code produces the correct output.

Ah! Got it. It was elementary. It works now. I missed a case. Thanks at lot.

Fun puzzle.

Is it this one : K2PtCl4 + H2 ?

Edit : no, my code manages to balance this one too

I am also still struggling with that specific validator.

While looking around for other possible reactions, though, I discovered a bug in my code whereas I was counting atoms in the wrong way in some cases; it might be your case. For example, consider the Glycolic Acid that has brute formula HOCH2COOH, having multiple occurrences of the same kind of atom inside the same molecule! There is no visible testcase with this, I don’t know about validator 6 (it didn’t work for me though).

Thanks mate for the hint !
I didn’t know we could have molecules with the same atom several times.
I changed the script but i still can’t pass validator 6
You can test any testcase in the ‘custom’ tab (display it via settings > expert mode while you’re in a practice)

polettix found a test that he would fail.
I added it as 8th testcase to the puzzle, please try that test too.

1 Like

I was working on the same one (CuSO4H2O -> CuSO4 + H2O)

Edit : That was the inner problem ! Thanks a lot for the help and the nice puzzle !

Done, it works here.

Hello,

I’m working on this puzzle. My program is able to pass all the tests (including the #8) but I only get % of success.
I fail on the “Potassium tetrachloroplatinate” test. Can I have an hint? (I already fix the “identical atoms in same molecule” problem)

Thank you!

Not sure how to provide any specific hints. Some general ones though:

  • Make sure you split the elements correctly. For example, distinguish between Cu, Cl and C.
  • If you are solving by bruteforce, make sure you have proper coverage of the combinations of coefficients and do not miss potential solutions.
  • If you are solving by linear equations, make sure your fractions are handled properly and you are correctly reducing the coefficients to the lowest terms.

I have added another test case regarding the proper parsing of “similar” elements (e.g. Cu / Cl / C), since previously only one validator (and no other test cases) touches on this issue.

1 Like