It's that time of year again!
Jun. 29th, 2015 01:17 pm![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
Today I do math nerdery and puzzles.
I was looking for the answer to the old one-off marble puzzle[1] because I knew it HAD a solution and I knew it had a SIMPLE solution but I couldn't remember what it was. In the process, I ran into this fun little puzzle:
PUZZLE #1:
"For any prime number greater than 3 (labelled "p") why is it that p2-1 is ALWAYS evenly divisible by 24?"
eg: 5 is prime. 52-1 is 24. 13 is prime. 132-1 is 168, which is 24x9. 17 is prime. 172-1 is 288, which is 24x12. 4027 is prime. 40272-1 is 16216728, which is 24x675697. For ALL prime numbers over 3, the number, squared, minus 1, will be evenly divisible by 24. Why?
In fact, while I'm here, PUZZLE #2
A vending machine dispenses two kinds of chocolate bar. It has three buttons - "Snickers", "Mars", and "Random". Snickers gets you a Snickers bar, Mars gets you a Mars bar, Random gets you either a Snickers or a Mars, 50/50 chance. At least, that's how it's SUPPOSED to work, but the guy who set it up screwed up the labels so none of the labels on the buttons are right. It costs $1 for a chocolate bar; what's the minimum amount of money required to be able to know, for certain, which button is which?
[1]: You know the one, right? You have 12 marbles, identical except one of them is either lighter or heavier than the others. You don't know which is the odd one out or if the odd one is light or heavy. You have only an old-style balance scale to use so you can measure marbles or groups of marbles against each other but not against anything else. Using only this scale, determine which is the odd one, and if it's light or heavy, in no more than 3 weighings. You know what, now that I've written it out, why not throw this out as a question to the audience, too? PUZZLE #3! It's super-old but has a neat counterintuitive solution.
Comments screened, correct answers will stay screened until I post solutions.
I was looking for the answer to the old one-off marble puzzle[1] because I knew it HAD a solution and I knew it had a SIMPLE solution but I couldn't remember what it was. In the process, I ran into this fun little puzzle:
PUZZLE #1:
"For any prime number greater than 3 (labelled "p") why is it that p2-1 is ALWAYS evenly divisible by 24?"
eg: 5 is prime. 52-1 is 24. 13 is prime. 132-1 is 168, which is 24x9. 17 is prime. 172-1 is 288, which is 24x12. 4027 is prime. 40272-1 is 16216728, which is 24x675697. For ALL prime numbers over 3, the number, squared, minus 1, will be evenly divisible by 24. Why?
In fact, while I'm here, PUZZLE #2
A vending machine dispenses two kinds of chocolate bar. It has three buttons - "Snickers", "Mars", and "Random". Snickers gets you a Snickers bar, Mars gets you a Mars bar, Random gets you either a Snickers or a Mars, 50/50 chance. At least, that's how it's SUPPOSED to work, but the guy who set it up screwed up the labels so none of the labels on the buttons are right. It costs $1 for a chocolate bar; what's the minimum amount of money required to be able to know, for certain, which button is which?
[1]: You know the one, right? You have 12 marbles, identical except one of them is either lighter or heavier than the others. You don't know which is the odd one out or if the odd one is light or heavy. You have only an old-style balance scale to use so you can measure marbles or groups of marbles against each other but not against anything else. Using only this scale, determine which is the odd one, and if it's light or heavy, in no more than 3 weighings. You know what, now that I've written it out, why not throw this out as a question to the audience, too? PUZZLE #3! It's super-old but has a neat counterintuitive solution.
Comments screened, correct answers will stay screened until I post solutions.
(no subject)
Date: 2015-06-29 05:37 pm (UTC)By the difference of squares formula, p2 - 1 = (p+1) * (p-1).
Let's call those q and r (though they should be q and o, but o is bad).
If p is prime, then p is not divisible by 3. So it's either modulo 1 or 2 if you divide by 3.
So either q or r is a multiple of 3.
Likewise, if p is prime and greater than 3, it must be odd (the only even prime is 2), so q and r must both be even.
Finally likewise, if p is prime and greater than 3, and therefore odd, when modulo divided by 4 it must be either 1 or 3. (If it were modulo 2, it would be even. No dice.) Which means that one exactly one of q and r is divisible by 4--that is to say, 22.
So, within the prime factorizations of q and r, collectively, there is a 3, a 2, and 22.
Which means that within the prime factorization of q * r, there is 3 * 2 * 2 * 2...which is 24.
(no subject)
Date: 2015-06-29 05:56 pm (UTC)(no subject)
Date: 2015-06-29 05:46 pm (UTC)This is all irrelevant, since it is all hateful candy that pollutes chocolate with nuts.
(no subject)
Date: 2015-06-29 05:56 pm (UTC)(Also, it's worth noting, the buttons ARE labelled. They're just all labelled incorrectly.)
(no subject)
Date: 2015-06-29 05:58 pm (UTC)(no subject)
Date: 2015-06-29 07:21 pm (UTC)(no subject)
Date: 2015-06-29 08:55 pm (UTC)Push Random. That determines whether Random button gives mars or snickers (since we know it can't give random).
If Mars, then the button labelled Mars gives Snickers, and Snickers must give Random.
If Snickers, then the button labelled Snickers gives Mars, and Mars must give Random.
(no subject)
Date: 2015-06-29 06:08 pm (UTC)(no subject)
Date: 2015-06-29 07:23 pm (UTC)Mars bars have nuts. Not all Mars bars have nuts. Some Mars bars have no nuts.
(no subject)
Date: 2015-06-29 08:06 pm (UTC)(no subject)
Date: 2015-06-29 08:11 pm (UTC)(no subject)
Date: 2015-06-29 08:19 pm (UTC)(no subject)
Date: 2015-06-29 06:00 pm (UTC)Push the Random button once. Whatever it dispenses is what it is (If it gives Mars it's Mars, Snickers it's Snickers.)
Whatever is labeled what you got is the other one. (If you got Mars, then the one labeled Mars is Snickers. If you got Snickers, then the one labeled Snickers is Mars.)
The third is random.
(The key is that you know that all three buttons are wrong. Once you know which the one labeled Random is, that's the only way that none of the labels is accidentally right.)
(no subject)
Date: 2015-06-29 06:06 pm (UTC)Start with a difference of squares factorization: p^2 - 1 = (p-1) (p+1)
Now, figure out a couple of things about p-1 and p+1. I'll use modulo notation; if and only if a is evenly divisible by b, a mod b = 0.
p mod 2 can't be 0, so it must be 1, therefore (p+1) mod 2 = 0 and (p-1) mod 2 = 0. Also, either (p-1)/2 mod 2 = 0, in which case (p-1) mod 4 = 0, or (p-1)/2 mod 4 = 1, in which case (p-1+2) mod 4 = (p+1) mod 4 = 0.
Also, p mod 3 can't be 0, so p mod 3 must be 1 or 2. If p mod 3 = 1, (p-1) mod 3 = 0, and if p mod 3 = 2, (p+1) mod 3 = 0.
From the above, one of (p+1) and (p-1) must be divisible by 4, and the other must be still divisible by 2; also, one of them must be divisible by 3. Multiplying 2, 3, and 4, we find that the product of (p-1) and (p+1) must be divisible by 24.
(no subject)
Date: 2015-06-29 06:11 pm (UTC)(no subject)
Date: 2015-06-29 07:08 pm (UTC)#3, I didn't know of, and initially thought I had a solution using 3 groups of 4 marbles, but then realised that about 50% of the time, it needs a 4th weighing to solve. Will sleep on it.
#1 is very interesting, and I suspect has something to do with 24 being 23 * 3, but I'm far too foggy of brain to math it out. Might have to cheat and look up the solution, as it's a fascinating little mathoid.
ETA (after looking at the answer): Oh, right - factoring into (p-1)(p+1) where p > 3, and it all falls out. Hah, that's very neat.
(no subject)
Date: 2015-06-29 08:07 pm (UTC)(no subject)
Date: 2015-06-29 08:11 pm (UTC)(no subject)
Date: 2015-06-29 09:24 pm (UTC)p2-1 equals p+1 times p-1. Given p-1, p, and p+1, one of them is a multiple of 3. Given that p-1 and p+1 are even, one of them is a multiple of 2, and the other will be a multiple of 4. 2*3*4 == 24.
(no subject)
Date: 2015-06-29 09:29 pm (UTC)(no subject)
Date: 2015-06-29 09:39 pm (UTC)(no subject)
Date: 2015-06-29 09:46 pm (UTC)If the outlier is LIGHTER, you would weigh 6v6, discard the light half, weigh 3v3.... and they level.
Now you have one measurement left to determine which of the light half is the light one, which AFAIK can't be done.
(no subject)
Date: 2015-06-29 10:54 pm (UTC)(no subject)
Date: 2015-06-30 01:27 am (UTC)Puzzle 2: minimum required is $3. Press button 1: get foo chocolate bar. Press button 2: get bar chocolate bar. Press button 2 again: get foo chocolate bar. Ergo button 2 is the random button, button 1 will always deliver foo chocolate bar (whether it's Mars or Snicker); ergo button 3 is the button that delivers whatever button 1 doesn't.
Puzzle 3: gah, I never remember this one. Weigh the first four marbles against the next four, and when Monty Hall says one weighs more than the other, pick the remaining four.
(no subject)
Date: 2015-06-30 01:49 am (UTC)But that assumes a perfectly spherical vending machine of uniform density. So I'm assuming the limiting factor is the number of chocolate bars of each type that the machine contains. Let's suppose it contains 50 Mars bars and 50 Snickers bar, and the random number gods are against us, so button A gives us a Mars bar and buttons B and C give us a Snickers bar. We know one of buttons B or C has to be the "always Snickers", and button A therefore has to be the "always Mars" button, so we're out $3, and we have 49 Mars bars left and 48 Snickers bars.
We then press buttons B and C each another 24 times, which costs us another $48. We get a Snickers bar from each of them.
Thereafter, assuming that if the machine is out of what you want you get your money back, we feed a dollar into the machine, pressing button B or C, until one of them gives us a Mars bar.
So the total cost is VENDING_MACHINE_CAPACITY + 2?
Or, alternatively, you could tell the guy in charge of the vending machine "hey, can I rig up my electrician's tools to your machine?" or "you set it up wrong, you probably know what you did wrong better than I did".
(no subject)
Date: 2015-06-30 12:27 pm (UTC)(no subject)
Date: 2015-06-30 04:02 am (UTC)Put three marbles on one side and six on the other.
-If the six are exactly twice as heavy, none of the nine weighed marbles are the oddball. Remove them and place one each of the unweighed marbles on the scale. If they are still equal, neither of these are the oddball, so replace one with the final (odd) marble to find out if it's heavier or lighter. If they are not equal, replace the heavier one with a previously-weighed marble. If the scale levels, the removed oddball was heavier. If the scale remains tipped, the remaining oddball is lighter.
Unfortunately, if the six AREN'T exactly twice as heavy, that means you know that one of the weighed marbles is the oddball, and you have two weighings left to sort through nine marbles, which I couldn't work out before my brain gave up for the night. Am I even close to being on the right track?
-TG
(no subject)
Date: 2015-06-30 12:32 pm (UTC)So no, you're not close to the right track.
(no subject)
Date: 2015-06-30 12:44 pm (UTC)-TG
(no subject)
Date: 2015-06-30 05:52 am (UTC)(no subject)
Date: 2015-06-30 06:54 am (UTC)#2: $1. Push random; it'll produce either S or M. If it gives S, what's labeled M must be random (as it can't be M), and what's labeled S must be M. Similarly, if label-R gives M, label-M is S, label-S is random.
#3 I hated that fucking puzzle because it requires a series of arbitrary states and I always just looked up the answer in the Spellbreaker walkthrough.
I think I've seen all of the questions (or variations therein) before, so it feels unfair. I blame Raymond Smullyan.
(no subject)
Date: 2015-06-30 10:19 am (UTC)OK, any prime number greater than 3, p, is going to be odd. Therefore the two bracketing numbers will be even, and one will be a multiple of 4.
Also that same number will be either one greater or one less than a multiple of 3, because if it *was* a multiple of 3, it wouldn't be prime. And out of any 3 consecutive numbers, one of them will be a multiple of 3.
So, p2-1 = (p+1)(p-1)
Assume p+1 is the multiple of 4. P-1 will also be a multiple of 2, and one or the other will be a multiple of 3.
(Or you could take it the other way around. Either works)
Thus the product of p+1 and p-1 must have 2x4x3 as one of its factors.
(Kudos to
(no subject)
Date: 2015-06-30 11:50 am (UTC)2. $1. hit random. whatever it spits out is what it is supposed to be labeled, say mars. Then you have two buttons labeled mars and snickers. since you know they are wrong, the one labeled mars must be snickers, and the one labeled snickers must be random. vice versa if the random spits out a snickers.
3. my intuition here is that the solution involves weighing all 12 in groups of 6 just scrambled each time. but not sure if that will get you down to knowing it's a single marble in 3 groupings.