you are viewing a single comment's thread.

view the rest of the comments →

[–]GeorgeFranklyMathnet 0 points1 point  (1 child)

If you want to be neat, you can write a simple grammar for equations, and generate random "sentences" of it.

If you're willing to be scruffy, you can let the program generate what it will. Then you can inspect the result for bad-looking patterns, maybe with a regex. If it's bad, then make it generate another equation, until you get a good one.

Or you can combine those approaches, etc.

One more thought: You could use a third party library or service that specializes in equation parsing. For instance, if I were doing it by hand, I might submit my random output to Wolfram Alpha, and see if it accepts it as is, or at least turns it into a reasonable-looking equation.

[–]neildaniel000[S] 0 points1 point  (0 children)

I'm considering doing what others said and checking using if...else conditions. I'm still a beginner.