Check an expression in a Table Correct

I am working on a self-checking table and I’m able to get the table to check correctly for the first two expressions by using the following code:

a1=table9.cellContent(1,2)
check1=simpleFunction(a1,“x”).evaluateAt(2)=20 and countNumberUsage(a1,6)=1
cellContent(1,3):
when check1 “:white_check_mark:” otherwise “:x:

However, it’s not correctly checking the last expression in the table:

a3=table9.cellContent(3,1)

check3=simpleFunction(a3,“x”).evaluateAt(2)=0 and countNumberUsage(a3,-2)=1

cellContent(3,3):
when check3 “:white_check_mark:” otherwise “:x:

I think there is a problem with the countNumberUsage and the negative number. Any suggestions? Here’s a link to the example I’m working on… Table Self Check Example • Activity Builder by Desmos

Yes, countNumberUsage doesn’t take negatives, just make it 2.

Careful, just checking those two things makes it really easy to break:

source:


Original activity updated with countNumberUsage for 2.

That’s originally why I was trying to search for the negative 2. However, I think if I just search for the 3, in (x-2)(x-3) it will have the same effect and avoid the issue of counting the squared . I also added in another value check to avoid accepting (x-2)(x+3). Do you think that’s strong enough to check corectly?

I updated my original link.

Thank you for your help!!!

I had to try a little harder but I could break it:

If you want to be completely certain, check three points each to make sure its a curve and count both the number total and the individual totals for each number in the expression.

Totally your call

How does the countnumberusage work. can you explain that?

countNumberUsage can count how many numbers are used in a latex string. Say a student enters 3x^2+14x-2.

countNumberUsage(inputName.latex) would output 4, counting the 3, 2 2’s, and 14. Note: It counts numbers, not digits.

It can also count a specific number.

countNumberUsage(inputName.latex, 14) would output 1. You cannot enter negative numbers for the second parameter.