Monday, May 23, 2011

Forth for Enlightenment, part two of ten, Logic problem

Here's a logic problem that i came across while helping a 5th grade student with math. My interest in it is to solve it in a brute force manner on the HP-28C. But before i do that, i'll go through the problem and logic solution. First, the problem.

We're looking for a 4 digit number. It must be greater than 2000. The digits of this number add to 14. The one hundred's digit is less than the one's digit. The ten's digit is three times the thousands digit. The number must be odd.

So, first, the logic solution. In these sorts of logic search problems, you'd like to use the clues to narrow down the search, if possible. We'll start with the first two rules. It's a 4 digit number that is greater than 2000. So, the number is in the range from 2001 to 9999. That's roughly 8,000 numbers to check.

It's not immediately clear that adding digits to 14 helps narrow the search at this point. You'd have to check all 8,000 numbers or something. And for the same reason, we'll skip the hundred's digit rule for now as well. But consider that the ten's digit is three times the thousands digit. Well, the thousand's digit has to be at least 2. Three times two is 6. If the thousand's digit is 3, then the ten's digit must be 9. If the thousand's digit is 4, then ten's digit is 12, which is not a digit. So the thousand's digit must be either 2 or 3. That narrows the search to the range 2069 to 3999. And the number must be 2?6? or 3?9?. Here, i'm using ? to mean any digit. That looks like 200 numbers to check.

Now the hundred's digit must be less than the one's digit. So, for 2?6? numbers, the hundred's digit must be in the range of 0 through 5. For 3?9? numbers, the hundred's digit must be 0 through 8. Let's use [0-5] and [0-8] as notation for single digit ranges. We have 2[0-5]6? and 2[0-8]9? as possibilities. Since the hundred's digit must less than the one's digit, it follows that the one's digit must be greater than the hundred's digit. Since the hundred's digit must be at least zero, the one's digit must be at least one. So the ranges are 2[0-5]6[1-9] and 3[0-8]9[1-9]. That's 54 + 72 numbers or 126 possibilities remaining.

Let's check the rule that the digits must add to 14. In the 3[0-8]9[1-9] case, the two known digits add to 12. So the only valid combination is 0, 2. But since the one's digit must be odd, even this combination must be eliminated. In the 2[0-5]6[1-9] case, two of the digits are known, and add to 8. So the other two digits must add to 6. Since the hundreds digit has to be smaller, the valid combinations are 0, 6, and 1, 5, and 2, 4. Since the one's digit must be odd, that leaves 1, 5. So the answer is 2165.

What does a 5th grade student do with this problem? They guess. It's a 4 digit number. It must be greater than 2000. So the first guessed digit is 2. It's 2???. The "digits add to 14" rule is ignored. The 10's digit is 3x the 1000's digit. So, the guess is 2?6?. There's no rule that the numbers must be unique, but they guess '1' for the hundred's digit all the same. They could have guessed zero, since it's a digit. But they don't know much about zero. So that's 216?. The number must be odd. The next guess is 2163, because 1 was already taken and this is the next odd number. Some 5th graders stop there. And it's not quite the right answer. But really smart 5th graders go back to the "adds to 14" rule, and notice they need 4 more, and so guess 2165. And, it's the right answer.

Is this problem reasonable to hand to a 5th grade student? IMO, no. There are several skills that could have been taught first. For example, one could teach the idea of doing the easy stuff first. But my real complaint is that this exercise teaches the 5th grader to guess at answers, and fairly randomly. Usually, at this age, the guesses are not checked for correctness, and wrong answers come out. So, one should also explicitly teach students to check their answers. This problem also requires quite a bit of estimation and mental juggling for anyone, much less a 5th grader. Sorting the rules by next easiest is another teachable skill. But the school that assigned this problem taught none of these skills. Finally, this is a logic problem with no obvious (or explained) real world analogy. There seems to be no use for knowing how to solve it. Most math can be applied. IMO, it's criminal to expose students to math without explaining what it it might be for.

Admittedly, it took me much longer to solve than it took a smart 5th grader. But that's because i took the time to understand more about the problem. For all i know, there might be more than one solution. I invented notation to help keep track of the possible solutions. I did go with easy constraints first. So, i skipped the "adds to 14" constraint until later. But i also ignored the odd number constraint. I could have invented a [2-9]??[13579] notation. But that's really three notation inventions all at once. And when I was finished, not only did i know that i had an answer, i also knew it was the only answer.