# What's in my pocket? [duplicate]

Well, I can tell you Johnny has memory cards in his pocket.

Back Story

My brother, Johnny, is a tech nerd. He loves gadgets of all kinds. As a matter of fact, you can be sure at any one given time, he will have SOME sort of tech related thing in his pockets.

That being said...

Johnny-Gadget says to our other brother, Mickey, "Can you figure out how many memory cards I have in my pockets?"

He then gives Mickey three clues:

1. If the number of memory cards I have is a multiple of 5, it is a number between 1 and 19.

2. If the number of memory cards I have is not a multiple of 8, it is a number between 20 and 29.

3. If the number of memory cards I have is not a multiple of 10, it is a number between 30 and 39.

## How many memory cards does Johnny-Gadget have in his pockets?

• Not fair! not fair! It isn't fair, my precious, is it, to ask us what it's got in it's nassty little pocketsess? – Herb Apr 8 '20 at 21:25
• Does this answer your question? Find out the number using three clues – Hemant Agarwal Mar 18 at 9:57

The number is not a multiple of 5. Due to (1) only 1,5,10,15 are possible, which violate (2). Then it is also not a multiple of 10. So the number is between 30 and 39. Then it has to be divisible by 8. So Johnny has 32 cards in his pocket.

• Wow I think I just answered only 15 seconds before you, that's incredibly close! :) – Beastly Gerbil Apr 8 '20 at 20:16
• If I could upvote again because of the concise explanation, I would (but 1 is not a multiple of 5). – phoog Apr 8 '20 at 20:48

He has

32 memory cards in his pocket

Let M be the number of memory cards:

If M is between 1-19 then it could be any number, however

- All numbers 1-19, excluding 5, 10 and 15 for now, are either not multiple of 8 or not multiples of 10 which means it cant be them.

- If it is 5, then it is not a multiple of 8 or 10, which is a contradiction.
- If it is 10, then it is not a multiple of 8 which is a contradiction.
- If it is 15, it is not a multiple of 8 or 10 which is a contradiction.

So we know it's not between 1-19, as all numbers are either not a multiple of 8 or 10.

If M is between 20-29 then it is a not a multiple of 8. Which means that is could be 20, 21, 22, 23, 25, 26, 27, 28 or 29.

- It can't be 20 or 25 as they're a multiple of 5, but not between 1-19.
- It can't be 21, 22, 23, 226, 27, 28 or 29 because they're not multiples of 10 but aren't in 30-39.

So we know it's not between 20-29.

If M is between 30-39, then it's not a multiple of 10. Which means it could be 31-39.

- It can't be 35 because that's a multiple of 5.
- It can't be 31, 33, 34, 35, 36, 37, 38 or 39 as these are not multiples of 8 but aren't in 20-29.

Therefore the only number it can be is

32

as all numbers greater than 39 are

either a multiple of 5, or not a multiple of 8 or 10, which will lead to a contradiction.

• The reasoning here is faulty. "If M is between 1-19 then it is a multiple of 5" does not follow from "if M is a multiple of 5 then it must be between 1 and 19." The rule as given does not by itself exclude values in that range that aren't multiples of five; it excludes multiples of five that aren't in that range. Therefore, the assumption that the answer can't be more than 39 is unnecessary, because that fact can be deduced from the given conditions as illustrated in the other answer. – phoog Apr 8 '20 at 20:34
• @phoog this is true, notice the IF. For it to be between 1-19 then it MUST be a multiple of 5. And the only numbers satisfying this is 5, 10 and 15 of which it cannot be any. I agree with you second point however, and will edit. – Beastly Gerbil Apr 8 '20 at 20:37
• No: the rule as stated excludes multiples of 5 that aren't in the range. (I edited my comment just as you posted yours.) Values that satisfy rule 1 only are all values except ... -15, -10, -5, 0, 20, 25, 30, .... So rule 1 doesn't rule out 2, for example. If the sentence I quoted is intended to be a restatement of the rule, it is incorrect. If it is intended to be a conclusion deduced from multiple rules then it is part of your answer and it should be hidden. – phoog Apr 8 '20 at 20:40
• @phoog I see what you're saying now. I've editted my wording, I think know what I've said is correct. Thanks! – Beastly Gerbil Apr 8 '20 at 20:46
• Yes, it is. I will vote accordingly. – phoog Apr 8 '20 at 20:47

Summarizing the hints:

1. If a multiple of 5, must be 1-19, so one of (5, 10, 15)
2. If not a multiple of 8, must be 20-29, so one of (20, 21, 22, 23, 25, 26, 27, 28, 29)
3. If not a multiple of 10, must be 30-39, so one of (31, 32, 33, 34, 35, 36, 37, 38, 39)

What are the options?

Looking at hints 2 and 3, if the number is not a multiple of 8 it must be between 20-29, and if it is not a multiple of 10 it must be between 30-39. These two ranges do not overlap, so if it were not a multiple of 8 or 10 the number would have to be in both ranges. Take 29 for example. That's not a multiple of 8 so hint 2 says it must be between 20-29. But hint 3 says it must be between 30-39.

Therefore the number is either a multiple of 8, a multiple of 10, or both.

Is it a multiple of 10?

Every multiple of 10 is also a multiple of 5. According to hint 1, if it is a multiple of 5 (and therefore 10) it must be in the range 1-19. The only multiple of 10 in that range is 10. But that is not a multiple of 8, so hint 2 tells us the number has to be in the range 20-29 if it is not a multiple of 8.

Therefore the number is not a multiple of 10

So

We've shown that it must be a multiple of 8, 10, or 8 and 10. But we've shown it cannot be a multiple of 10, so it must be a multiple of 8. Because it isn't a multiple of 10, hint 3 tells us it must be in the range 30-39. The only multiple of 8 in that range is 32.

Therefore the answer is 32.

I'm just sharing my approach here because I think it's a bit more algorithmic than others. So we have 3 questions to ask a potential solution (divisible by 5, 8, 10?) - if we make zero assumptions about what is possible then the set of answers can be 8 possible sets. The truth table below sets out the possible answers, and then from there we can infer three other things about each answer - the range that is is in.

+---+----+----+-----+------+-------+-------+| x | %5 | %8 | %10 | 1-19 | 20-29 | 30-39 |+---+----+----+-----+------+-------+-------+| 1 |  0 |  0 |   0 |      |     1 |     1 || 2 |  0 |  0 |   1 |      |       |       || 3 |  0 |  1 |   0 |      |       |     1 || 4 |  0 |  1 |   1 |      |       |       || 5 |  1 |  0 |   0 |    1 |     1 |     1 || 6 |  1 |  0 |   1 |    1 |     1 |       || 7 |  1 |  1 |   0 |    1 |       |     1 || 8 |  1 |  1 |   1 |    1 |       |       |+---+----+----+-----+------+-------+-------+

So now we just need to use maths rules to eliminate rows that have contradictions:

No number can be in more than one of these ranges, so rows 1, 5, 6, 7 get chucked out.
No number can be a multiple of 10 but not of 5, so goodbye rows 2 and 4.

That leaves:

Row 3, the set of numbers divisible by 8, but not 5 or 10, between 30 and 39.
Row 8, the set of numbers divisible by 8, 5, and 10, between 1 and 19.

And now our answer:

The row 2 set doesn't have any numbers in it, and there's only one in the row 1 set, which is 32, our answer.

This method was probably a bit overkill for this problem, but I definitely found it a lot easier and less error-prone than attempting others.