4 Replies Latest reply on Jul 13, 2007 11:39 PM by kglad

    Crazy Math Question

    Rothrock Level 5
      So I'm making some math games to teach little kids addition and subtraction. We are doing how three numbers can be related. So imagine 4,8,12:

      4+8=12
      8+4=12
      12-8=4
      12-4=8

      So given three numbers (sum/minuend will be 18 or less and the addends/subtrahend/difference will be 10 or less) how do I check if the kid has typed the answers in correctly? They are given 12 text boxes with the two additions on top and the two subtractions on the bottom. So there are four correct answers for any given set.

      4,8,12
      8,4,12
      12,8,4
      12,4,8

      8,4,12
      4,8,12
      12,8,4
      12,4,8

      8,4,12
      4,8,12
      12,4,8
      12,8,4

      4,8,12
      8,4,12
      12,4,8
      12,8,4

      I can't think of any easy way to check that with if/else. I was thinking of trying to use a dotProduct. And it seems to work, but I"m worried that there is some case it would fail and I just wouldn't know. Any advice? kglad?
        • 1. Re: Crazy Math Question
          kglad Adobe Community Professional & MVP
          i possibly do not understand the issue, but it seems straight-forward. to simplify terminology i'm going to refer to the textfield in the ith row and jth column as tij (where you have 3 columns and 4 rows).

          1. the number in t11 can be either of two smaller numbers. then the number in t12 must be the other smaller number and t13 must be the largest: 1 point.

          2. the number in t21 must be the number in t12, t22 must be t11 and t23 must be the same as t13: 2 points unless they claim this is s stupid waste-of-time question because addition is a commutative property of real numbers, in which case they get 1 point plus 10 bonus points.

          3. the number in t31 must be the largest and t32 can be either of the two smaller and t33 must be the other non-largest number: 1 pt.

          4. t41 must be the same as t31, t42 must be t33 and t43 must be t32: 1 point but if they complain, at all, and even mention something about subtraction being a commutative property they lose 11 points and have to wash the teachers car once per week for 6 weeks.

          now, as for that dotProduct. me being a smart(alec) kid (and assuming i know you're using something crazy like that dotProduct to score my answers), i'm going to enter 12, 12 ,12 for all 4 rows and get the highest score in the class: teacher must wash my car once per week for 6 weeks.
          • 2. Re: Crazy Math Question
            Rothrock Level 5
            Thanks I think that helps me figure it out a different way to look at it. However I'm not just checking that they have done the math correctly but that they have done the math correctly for the three numbers I've given them. So that is still an awful lot of if/elses.

            I'm still liking the dot product thing. Maybe I didn't explain what I'm doing with that.

            I have the correct answer matrix/vector, I dot product their answer and the correct answer then normalize that by dividing by that part in the code shown there. In theory it should return 1 if they are the same and something else if they aren't. So far my testing shows it works. I was worried that it might not scale – say I typed in a vector that was a scalar of the other. But that wasn't 1 either so it seems to work.

            So all the twelves wouldn't work, but any 1st grader who doesn't know how to add, but does know what a dot product is – well – they do get a lot of points. (I'm not sure they will have a car.)
            • 3. Re: Crazy Math Question
              Rothrock Level 5
              Oh as for 2, that is part of the point. We are introducing the idea of the commutative property!

              BTW, your answer is really quite funny.
              • 4. Re: Crazy Math Question
                kglad Adobe Community Professional & MVP
                if you're taking the dotproduct of the correct answer and their answer, the maximum ( = 1) will only occur if their answer is the same as the correct answer or is a multiple of the correct answer (and i assume a multiple would violate some other checking that you're doing).

                so, you could check if one of their two answers has a dotproduct of 1 and you could check if the dotproduct of both their answers matches the dotproduct you would expect.

                but that does seem a bit round-about and you still must be doing some other checking that they are using the right trio of numbers. so you may as well check their answers directly.