# Checking correct written expression

**URL:** <https://cl.desmos.com/t/checking-correct-written-expression/954>\
**Category:** Questions\
**Tags:** simplefunction, validation, correctness\
**Created:** [May 4, 2020, 1:52pm UTC](https://cl.desmos.com/t/checking-correct-written-expression/954 "2020-05-04T13:52:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Karen\_McPherson](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/karen_mcpherson/32/544_2.png) [@Karen\_McPherson](https://cl.desmos.com/u/Karen_McPherson)\
**Post date:** [May 4, 2020, 1:52pm UTC](https://cl.desmos.com/t/checking-correct-written-expression/954/1 "2020-05-04T13:52:56Z")

</div>

Students are asked to write 7x^2 as a factor pair. The correct answer is 7x \* 1x. They may type the answer as 7x \* x which is also correct. I’ve been using countNumberUseage to look for the coefficients but in this case how can I check for the 1 if they don’t type it? When I just look for the 7 then it marks 7x^2 as correct.

As apossible work around I’m thinking I may have to prompt them to write x as a 1x but I’d rather not.

Here is my code (a is 7x^2 and e1 what the student submits)

c1=when simpleFunction(a,“x”).evaluateAt(3)=simpleFunction(e1,“x”).evaluateAt(3) and  
simpleFunction(a,“x”).evaluateAt(2)=simpleFunction(e1,“x”).evaluateAt(2) and  
countNumberUsage(e1,7)=1 and countNumberUsage(e1,1)=1 1  
otherwise 0

---

<div class="post-metadata">

**Author:** ![Daniel\_Grubbs](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/daniel_grubbs/32/719_2.png) [@Daniel\_Grubbs](https://cl.desmos.com/u/Daniel_Grubbs)\
**Post date:** [May 4, 2020, 5:11pm UTC](https://cl.desmos.com/t/checking-correct-written-expression/954/2 "2020-05-04T17:11:43Z")

</div>

A couple ways you could get around this. First just a quick note. simpleFunction defaults to in terms of x, so you don’t need the “x” in your code. You only need to specify if it’s something other than x or if it’s multivariable.

You could just leave out searching for 1, and instead make sure 2 is missing:  
`countNumberUsage(e1,2)=0`

---

<div class="post-metadata">

**Author:** ![Karen\_McPherson](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/karen_mcpherson/32/544_2.png) [@Karen\_McPherson](https://cl.desmos.com/u/Karen_McPherson)\
**Post date:** [May 4, 2020, 6:50pm UTC](https://cl.desmos.com/t/checking-correct-written-expression/954/3 "2020-05-04T18:50:32Z")

</div>

Thanks! Didn’t realize that countNumberUsage would also look at exponents but it makes sense. Also, appreciate the nugget about simpleFunction defaulting to x.

---

<div class="post-metadata">

**Author:** ![Daniel\_Grubbs](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/daniel_grubbs/32/719_2.png) [@Daniel\_Grubbs](https://cl.desmos.com/u/Daniel_Grubbs)\
**Post date:** [May 4, 2020, 7:43pm UTC](https://cl.desmos.com/t/checking-correct-written-expression/954/4 "2020-05-04T19:43:54Z")

</div>

You can also count all numbers by leaving out the second parameter. So, if you wanted for whatever reason to distinguish between students writing 1x and just x, you could use that like:  
`when countNumberUsage(e1)=2 and countNumberUsage(e1,1)=1...`
