How to show correctness for a simplified expression?

Hello, I have read through some previous posts but I haven’t found the way to code for a simplified algebraic expression. For example, I want students to simplify -8(x + 4) to -8x -32 and not any equivalent expressions like -2x - 6x -32. Here’s a link to my activity:

You can use patterns to make sure that the expression matches a particular form. In this case, I set up a pattern to match against ax + b, ax - b, b - ax, x + b, x - b, or b - x. Then, combine that structure check with testing specific values to make sure it is equivalent to the original expression, to make sure it is correct.

What’s nice about this is that it is comparing their answer to what you have typed in the first column, so you can use the same code snippet again and again. Take a look and let me know if you have questions.

This is brilliant!! Thanks so much @Daniel_Wekselgreene !