July 14, 2004

A little math

I don't know the capacity of software types to solve something like this with a computer, and I need to know if it's too hard.

You have a combination lock with 0-39 as possible numbers (think high school locker) and you know that the combo includes the digits 2, 2, 3, 4, and 6, and that the combo, x, y, z, can be described as x-(z+2)=y

z%y=0

How hard is this to solve?
_________________________________

Okay, it's looking too easy, perhaps. If you're trying this, don't read the comments yet. :) If you want to suggest a better constraint I'm all ears (but let's make sure you have the right combo first). This doesn't need to take more than 2-5 minutes, but it shouldn't be too obvious either.

Posted by at July 14, 2004 08:30 AM | TrackBack
Comments

2 2 3 4 6

Two-digit numbers:
22, 23, 24, 26, 32, 34, 36

Gaps of x + 2:
22 -> 26 (x == 2)
22 -> 32 (x == 8)
22 -> 34 (x == 10)
22 -> 34 (x == 12)
24 -> 32 (x == 6)
24 -> 34 (x == 8)
24 -> 36 (x == 10)
26 -> 32 (x == 4)
26 -> 34 (x == 6)
26 -> 36 (x == 8)
32 -> 36 (x == 2)

x == 2, 3, 4, or 6:
22 -> 26 (x == 2)
24 -> 32 (x == 6)
26 -> 32 (x == 4)
26 -> 34 (x == 6)
32 -> 36 (x == 2)

But 2 goes into everything, so we're down to:
24 -> 32 (x == 6)
26 -> 32 (x == 4)
26 -> 34 (x == 6)

Written differently:
32 24 6
32 26 4
34 26 6

The last one's invalid because it uses two sixes, so we have:
32 24 6
32 26 4

Only the second satisfies the second constraint, so we have:
32 26 4

Posted by: Eric at July 14, 2004 10:24 AM

Darn it...I got the mod restriction backwards. Only the first one satisfies the constraint (well, sort of; I think you wrote that constraint backwards), so the answer is
32 24 6

Posted by: Eric at July 14, 2004 10:26 AM

Okay, hopefully you'll come back . . . I changed the restriction. Another friend found my more-than-one-solution problem. How does it look to you now? The solution you came up with was not the combo, so hopefully this will narrow the solutions.

Posted by: Kara at July 14, 2004 10:30 AM

It gets a lot easier if you use some common sense. First off, 3 is the only odd number, and subtracting an even # from an odd # (or vice versa) gets you an odd #, so the 3 must be one of the first numbers, as in "32 or "34" or 36".

4 has to be in the ones place, for either 4, 24 or 34. The six has to be in the ones place for either 6, 26, or 36, but 36 * anything but 2 > 100.

And so on. You can pretty quickly narrow this down to, oh, six or eight sets of numbers I think?

Posted by: Erik J. Barzeski at July 14, 2004 10:47 AM

Ack, I looked at an old one wherein you had xy < 100. Now it's z%y == 0? Eek. Please feel free to delete this comment and the previous one.

Posted by: Erik J. Barzeski at July 14, 2004 10:54 AM

Sorry about that. xy<100 was wrong all together. Bad Kara!

Posted by: Kara at July 14, 2004 10:57 AM

Since you mentioned software and computers, I approached this using no mathematical knowledge other than y being nonzero (since a zero modulus isn't a useful concept). I wrote this Perl script in about three minutes:

foreach my $x (0 .. 39) { foreach my $y (1 .. 39) { foreach my $z (0 .. 39) {
if ($x - ($z + 2) == $y && ($z % $y == 0)) {
$_ = "$x$y$z";
printf "$x $y $z\n" if (/2.*2/ && /3/ && /4/ && /6/);
}
} } }

I get only one result (32 6 24), which my meager arithmetic skills says seems to pass the constraints. But it's a different result than the ones above, but you mention changing the constraints, so I don't know. Also, the other solutions seem to assume that 2, 2, 3, 4, 6 are the only digits that appear in the combination, which is not how I read the problem at all.

Posted by: Alexei Kosut at July 14, 2004 11:42 PM

Damn, you are all so smart. :) Thanks for the help, I appreciate it. The combo was 32-6-24, btw - but everyone who got a different answer did so because I was screwing up my own rules.

Smiles!
-Kara

Posted by: Kara at July 15, 2004 08:57 AM

Unless I'm missing something, you really don't need to bruce force it. You just need to step through and fill in blanks.

1) 5 numbers means 2 2-digit numbers and 1 1-digit number.

_ _ , _ _ , _

2) you know that the 3 needs to be in the tens position.

3 _ , _ _ , _

3) You know that y is the 1 digit number (x-(z+2) =y )

3 _ , _ , _ _

4) You know that Z need to start with 2

3 _ , _ , 2 _

5) You know that the ones position of Z can't be two (because of the mod requirement) and that the ones postion of Z needs to be greater than that of the ones position of X.

This leaves two options:

34, 2, 26
32, 6, 24

Only 32, 6, 24 fits the bill.

I didn't spend but a minute on it so the logic could be off though.

Cheers,
Steve

Posted by: steve at July 16, 2004 10:13 AM
Post a comment









Remember personal info?