Check that an expression is in the correct form

Does anyone have a way to check that an expression is in the correct form? For example, when students are given a^m*a^n I want them to enter a^(m+n), I know how to do this for expressions containing numbers by using countNumberUsage(), but I am not sure what to do if the expression only contains variables since the student can just copy/paste the original expression. Here is an activity with an example: https://teacher.desmos.com/activitybuilder/custom/66be571be37c84295a8b7199

Since it’s a pretty specific form you want, a pattern seems like a possible approach, using patterns.literal(“n”). Something like this: [Copy of] Check Expression • Activity Builder by Desmos Classroom

That’s great! I haven’t used patterns before. I just watched Jay’s video from a few years ago introducing patterns and now I can’t wait to learn more. Thanks so much!

1 Like

No problem - I didn’t realize that you didn’t already use patterns. There is a series of patterns videos on the Desmos YouTube channel that are really helpful.