You might like a Satisfiability Modulo Theories (SMT) solver such as Z3.
https://github.com/Z3Prover/z3
It has bindings for other languages and is able to make some rather sophisticated arithmetical and logical deductions in an often pretty efficient way. I've used it successfully for parts of puzzle competitions and CTFs (and I'm really only beginning to scratch the surface of what it can do).
You can read more about the options in that area at
https://en.wikipedia.org/wiki/Satisfiability_modulo_theories
which also links to the related tools in
https://en.wikipedia.org/wiki/Answer_set_programming
https://en.wikipedia.org/wiki/Constraint_programming
These systems can feel pretty magical and are getting more powerful all the time. (Of course there are cases where there is a better algorithm that you could find, perhaps a much more efficient one, and using these solvers will be asymptotically or worst-case slower than it had to be given more human insight.)
Some of these could be overkill for your application, and Z3 doesn't have a Javascript binding, so I guess it's not as helpful for web forms.
https://github.com/Z3Prover/z3
It has bindings for other languages and is able to make some rather sophisticated arithmetical and logical deductions in an often pretty efficient way. I've used it successfully for parts of puzzle competitions and CTFs (and I'm really only beginning to scratch the surface of what it can do).
You can read more about the options in that area at
https://en.wikipedia.org/wiki/Satisfiability_modulo_theories
which also links to the related tools in
https://en.wikipedia.org/wiki/Answer_set_programming
https://en.wikipedia.org/wiki/Constraint_programming
These systems can feel pretty magical and are getting more powerful all the time. (Of course there are cases where there is a better algorithm that you could find, perhaps a much more efficient one, and using these solvers will be asymptotically or worst-case slower than it had to be given more human insight.)
Some of these could be overkill for your application, and Z3 doesn't have a Javascript binding, so I guess it's not as helpful for web forms.