# Factoring Correct Check

Is there a way to correct check this factoring problem so that they cannot type in the original polynomial?

You can use pattern matching for this - itâ€™s a fairly new feature so not fully documented yet, but essentially adding this to your CL:

``````p=patterns
binom=p.product(p.expression,p.expression)
answer = function.evaluateAt(0)=6 and function.evaluateAt(1)=12 and binom.matches(this.latex)
``````

will only accept a correct product of two expressions - ie. (x+2)(x+3) - as the answer.

1 Like

Hi. I tried that. Now it wonâ€™t do the â€ścheckâ€ť. It wonâ€™t mark it as correct or incorrectâ€¦just get the dotâ€¦

Youâ€™ve kept in the line that said `correct: answer`â€¦?

yes. I tried this: This works but only allows for 1 correct answer not allowing for commutative prop. I am totally new to this and I assume I can put in an or statement or somethingâ€¦

function = simpleFunction(this.latex)
p=patterns
binom=p.product(p.expression,p.expression)
check1 = function.evaluateAt(-2)=0 and function.evaluateAt(-3)=0 and binom.matches(this.latex)
f=simpleFunction(text.latex)
check2=text.latex=`(x+2)(x+3)`
correct: check1 and check2

2 Likes

In that case, check1 handles checking of the values (through evaluateAt) and that itâ€™s in factorised form (through binom.matches). You donâ€™t need check2.

1 Like