Hard Math Problem

I’ve been trying this for 3 hours and I’m done at this point. Can anyone here do it? I want to tell my teacher that I had multiple people try to do it and they didn’t succeed or something.

There was a jail with 100 cells in it, all in a long row. The warden was feeling very jolly one night and told his assistant that he wanted to give all his prisoners a wonderful surprise. While they were sleeping, he wanted the assistant to unlock all the cells. This should be done, he told the assistant, by putting the key in each lock, turning it once. The assistant did this, and then came back to report that the job was done. Meanwhile, however, the warden had second thoughts. “Maybe I shouldn’t let all the prisonders free,” he said. “Go back and leave the first cell open but lock the second one (by putting the key in and turning it once). Then leave the third open, but lock the fourth, and continue in this way for the entire row.” The assistant wasn’t surprised because the warden often changed his mind. Then the warden changed his mind again and after the assistant came back he said, “Here’s what I really want you to do,” he said. “Go back down the row. Leave the first two cells as they are, and put your key in the third cell and turn it once. Then leave the fourth and fifth cells and turn the key in the sixth. Continue down the row this way.” The assistant did as instructed and then the warden changed his mind again and the assistant had to go back and turn the key in the first cell and then every fourth cell down the row (Like 4, 8, 12… etc) This continued all night, next turning the lock in every fifth cell (ex 5, 10 15… etc) and every sixth cell (ex 6, 12, 18… etc…) and so on and so fourth until the assistant just had to turn the key in the hundreth cell. How many prisoners could walk out?

So what I learned so far about it is that if I do it with then when I get to like 6 I run out of jails to do it with and that it goes in multiples like 6, 12, 18… etc

That’s it so far


I’m too lazy for this haha.



1 Like

Yeah I talked to someone else and they remembered the problem and that’s what they said they got too. But how did you do that?! I was stumped for three hours.

1 Like

umm i dont really know how to explain also it isnt every fourth/fifth/sixth cell as in 4,8,12… 5,10,15… 6,12,18… since you start at 1

1 Like

Ok there may be a simpler way to do this, but what I did was to start by kind of sketching it out. I didn’t want to do all 100 cells because this drawing was just to notice a pattern so I turned a lined notebook sideways and used the red line as a column header and drew 21 columns to represent the first 21 cells

For round 1, I drew a circle (O) to show that every cell was opened in the first row.

For round 2, I started another row and drew an X to show the ones that had been closed. Since the pattern was every other, it was all even cells.

For round 3, I drew either an X, if the cell was still open (any of the off multiples of 3 that hadn’t been closed yet like 3, 9, 15) or an O if had already been closed in the last round (the even multiples like 12).

For round 4, I did the same but for the multiples of 4, noticing I was opening even numbers that weren’t multiples of 3 (so 12 was open so I had to close it).

I did this for rounds 5, 6, 7 and decided to stop drawing after that since I noticed enough patterns to start thinking about it mathematically.

So, I mentioned multiples were kind of important. Remember a number is multiple of another if you can get it by multiplying. So 21 is a multiple of 1 and 21, and 3 and 7.

The opposite of multiples are factors. So 1, 21, 3, and 7 are all factors of 21.

I noticed that in my pattern drawing thingy that once you had gone the round of the number, you stopped messing with the locks. So this left 1 as always open, because in any further patterns, you didn’t touch it. So 2 was always left locked because it was unlocked round 1 and relocked round 2. Same with 3, locked. 4 was unlocked because it was unlocked round 1, locked round 2, and finally unlocked round 4. 5 was the same as 2 and 3, left locked because of round 1 and round 5. Similarly, after the 6th round, you wouldn’t touch cell number 6 again, but cell 6 would always be closed because you unlocked it round 1, relocked it round 2, unlocked it again round 3, and finally locked it again round 6. Well, I noticed 1, 2, 3, and 6 are all the factors of 6. And because there are an even number of factors of 6, it will always be locked at the end.

So that’s how I figured it out - the only cells to be left unlocked (ie prisoners set free) would be numbers 1-100 with an ODD number of factors. Now, this is where you could map out a factor chart of every number 1-100. Or do it for a few and notice a pattern. (Math is really just fun patterns).

So, 1’s only factor is itself, so that 1, which is odd so it’ll be open. 2 is a prime number so its only factor is 1 and itself, so that’s an even number of factors, so it’ll be closed. 3 same thing. 4 has 1, 2, and 4 so it has an odd number of factors so it’s open. 5 is prime, so even factors, closed. 6 has more 1, 2, 3, and 6, but ultimately even, so ultimately closed. 7 is prime. 8 has factors 1, 2, 4, 8, which makes it even which makes it closed. 9 has 1, 3, and 9, so that’s odd and closed.

And this is where I went hm. 4 and 9 are special numbers. They have an odd number of factors because, like all numbers they have 1 and themselves as factors but only 1 more number as a factor because that number times itself is the factor. We call those square numbers because they are made of something to the second power (or squared). So, I don’t need to figure out the factors of every number 1-100, I just need to find the square numbers within that set!!! Much easier!!! And instead of going through the numbers 1-100, I’ll just square numbers til they’re too big to fit into 100.

Ok, so 1 squared is 1, 2 squared is 4, 3 squared is 9, 4 squared is 16, 5 squared is 25, 6 squared is 36, 7 squared is 49, 8 squared is 64, 9 squared is 81, 10 squared is 100. Don’t have to do any further since there were only 100 jail cells!

So only cells 1, 4, 9, 25, 36, 49, 64. 81, and 100 will stay open, which is 10 cells in total!

Phew, let me know if that didn’t make sense! It was a tricky one :blush:


I would never have been able to do that! This was the first math class of the year and I don’t even remember clearly how to do that but that made sense! I’ll probably tell the teacher the wrong answer anyways because I probably couldn’t have done that on my own oof. It does make sense, but I do want to be honest with my teacher in saying I couldn’t get it, next time she might give an easier problem lol.

1 Like

Now even though people figured it out I’m still gonna leave this open for other people to try to solve on their own.

1 Like

Yeah, it’s a tricky one for sure, but in the other thread you were getting close!!!

It sometimes can feel like math is all about formulas and memorization, but I often find that drawing diagrams and writing things down until I see a pattern helps.

I used to be a math teacher and there’s so much pressure to teach to a test but to me, it’s more about feeling comfortable with numbers and logic. So this problem was hard, sure, but I have no doubt with practice at this thing that you’ll get it! Sometimes mathematical concepts just take a while to sink in. It’s a great feeling when you get that aha! moment but like Thomas Edison said, genius is 1% inspiration and 99% perspiration :blush:

1 Like

Yeah, thank you! My teacher said that sometimes we’ll get an answer and sometimes we won’t and that we’re not always gonna get the right answer.

1 Like

Yep, that’s life! Don’t be afraid to ask for help :blush:

1 Like

Maths. :grimacing::purple_heart: