Thanks for your help in finding it!
Now that I read this, I also remember another bug I hit (how many!) that only appeared randomly. Iâm not solving with bruteforce by the way.
Basically, when calculating the equations and forming a matrix out of them, I had randomness in the row number they would appear. This does not influence the outcome theoretically, but can bite you the elimination process is not⌠careful enough.
So, you might want to try and balance K2PtCl4 + PPh3 + KOH + C2H5OH -> PtP4Ph12 + KCl + CH3CHO + H2O
a few times and see if any error comes out of it (by the way, please note that this reaction contains the same element repeated multiple times inside the same molecule).
I get the same answer every time :
K2PtCl4 + 4PPh3 + 2KOH + C2H5OH -> PtP4Ph12 + 4KCl + CH3CHO + 2H2O
Maybe you have to sort your list of different elements once, so it doesnât change from one execution to another ?
I removed the bug in the code so Iâm not suffering from it any more. Anyway, even if your equations are always ordered deterministically, it might be that in the specific test they yield a combination that you donât support?
I keep failing test 01. Still, when I test my code against hydrogen peroxyde, I get a correct :
2H2O2 -> 2H2O + O2
Any hint ?
What are the results of your other test cases and validators? Have you passed them all?
Yes, all of them. Thatâs why I am surprised.
Does your code work for AB + CD -> AC + BD?
Hi, I am struggling to pass the 7 validator âCopper and Ammoniaâ, however my code is able to solve the following equations: Cu(H2O)6 + NH3 -> Cu(NH3)4(H2O)2 + H2O; Cu(H2O)6 + NH3 -> Cu(H2O)4(OH)2 + NH4. Is there another copper and ammonia reaction that I am not aware of?
It looks like the answer is yes.
As said in statement, there is no parenthesis in the equationâŚ
It is not needed to be a chemist to solve this puzzle but, without spoiling, copper is present here in an inorganic compound.
Yeah, involving parenthesis was my addition to this puzzle to test out other cases.
By inorganic compound, you mean something like Cu + NH3 + H2O -> CuOH + NH4? It is not valid, because it should be (OH)2, just an example though.
It is possible to solve the coeficients using equation system / matrix, but it is really not necessary as coeficients wonât be that big and a brute force / monte carlo approach will be enough.
Could we consider making a level II version of this problem, which would be the same problem but scaled to bigger testcases for which the bruteforce approach wouldnât work?
Itâs better to introduce additional features at the same time. Otherwise, a player who did not solve this puzzle by brute force could just use the solution to this puzzle to pass the level II version.
Too easy for a very hard puzzle.
I succeeded in Lua, but Iâm ashamed
This makes me wanna do brainfuck code instead
Try to solve the formula when it is aready balanced. H2 + O2 â H2O2
Because of coming deadline I submit my awful code and it gain 100% score.
Although my solution didnât pass two cases, so something wrong with code assessment.
Thank you for this comment. I usually avoid âvery hardâ puzzles - but due to this comment I gave this one a try. And indeed, the parsing was a bit challenging - but I have had as much difficulty with some medium and certainly some hard level puzzles, as with this one.
I was especially surprised to be able to solve this by brute force checking all permutations of different counts of any of the molecules. A level II version as suggested by @Stef_3 makes sense - and that one I would not be able to solve so easily.
My âdamn, Iâm goodâ (solving three very hard puzzles) badge that I received thanks to completing this puzzle feels a bit cheap now .