Could someone help me with page 6 (titled Question 5) please? The code currently accepts 7-2m+4d for the numerator, but I haven’t been able to get it to also accept 7+4d-2m. It would be even better if it also accepted variations where 7 appears later eg 4d+7-2m etc as well.
Honestly, unless you really want a particular form here, I think an evaluative check like below is sufficient. You could add some more evaluations to make it a little more robust. Trying to make your pattern check too specific can add significant complexity.
One of the benefits of comparing evaluations is that you don’t have to code additional patterns to match. For example if each term was written as a fraction over 3, that’s a whole new pattern you have to deal with.