Inspired by this question, I rolled my own version (notice the solution is very different and not trivial):

Seven skillfull and smart D&D Lv. 20 thieves robbed a diamond shop at night. They ran to a nearby forest and then all slept there for the night. They didn't count how many diamonds there were in the bag, but anyway there can't be more than 400 diamonds in the bag since that's the bag maximum capacity.

  • A thief wins the initiative roll, wakes up and runs away, but as soon as he tries to escape, a second thief catches him, and the second thief decides to divide the loot in 2. Unluckily, the remainder is 1 diamond.
  • Meanwhile another thief wakes up and then tries to divide the loot, but as soon as he divides it the remainder is 2 diamonds.
  • The 4th and 5th and 6th and 7th thieves wake up one by one. Each time the new thief tries to divide the loot equally, but they get 3, 4, 5, 6 diamonds as remainders, respectively.
  • The last thief (7th and last to attempt loot division) then decides to give up the remainder to the other thieves before they even attempt to do some modulus calculations. Anyway only 1 thief is richer than him now.

Tell how many diamonds were in the bag and what happened.


Notice the emphasis and try to be on my side, I couldn't find a perfect fit, so I took the most immediate fit. Calculations are correct.


D&D stuff is just scenic.

Here's a list of what happens to make it even more clear (and thanks for comments!:) )

  1. Thief 1, try to escape
  2. Thief 2 stop the 1st and attempt division (remainder 1)
  3. Thief 3 stop the 1st,2nd and attempt division (remainder 2)

And so on..

  1. Thief 7 stop all previous thief and attempt division (remainder 6), then he distributes the remainder to the other thieves (1 diamond to thieves numbered from 1 to 6)

Before robbing the shop, the thieves have no money, and each diamond has equal value to other diamonds.

@GarethMcCaughan came up with the correct lateral thinking in his answer, however his solution (correct and acceptable, if no one find the elegant solution) is more complicated than needed (Indeed, I'm impressed by his skill, and I'm leaving open the chance to find the best answer!)

@Realdeo was succesfully in finding a exotic and fun explaination for the 7th thief returning part of the loot (though it is not the correct answer), I really enjoyed that answer from another D&D player.

Additional hint:

There is a precise reason for wich the last thief give up the remainder. Indeed every thief don't know if others cheat and by wich quantity cheat. If you think in wich way I could create a puzzle like this you will find the simplest possible solution.

  • 1
    $\begingroup$ Should "3rd and 4th and 5th and 6th" actually say "4th and 5th and 6th and 7th"? $\endgroup$
    – Gareth McCaughan
    Commented Jun 9, 2016 at 17:33
  • 1
    $\begingroup$ It shouldn't say 7th because he never checks $\endgroup$
    – Weasemunk
    Commented Jun 9, 2016 at 17:36
  • 1
    $\begingroup$ OK. And then is the "last thief" the 7th thief again? (In which case I don't think I understand how the process ends.) Or the 8th thief? (But it says there are 7 of them.) Or something else? $\endgroup$
    – Gareth McCaughan
    Commented Jun 9, 2016 at 17:36
  • 3
    $\begingroup$ OK, so your edits seem to have clarified all that. So the 7th thief finds 6 diamonds left over, which he then gives to the other thieves ... and then "only 1 thief is richer than him now". Is that right? $\endgroup$
    – Gareth McCaughan
    Commented Jun 9, 2016 at 17:38
  • 2
    $\begingroup$ DarioOO, the answer to your question about emphasis is that the only (explicit) emphasis in the question is on the word "cheat". If that signifies that one or more of the thieves cheated, then it seems like there are too many possibilities (each thief pocketed some number of diamonds while doing the counting, in such a way that the remainders work out and at the end #7 is second-richest -- but there are surely lots and lots of ways to make that happen) so I guess you mean something else... $\endgroup$
    – Gareth McCaughan
    Commented Jun 9, 2016 at 19:30

8 Answers 8


So I mentioned in comments that a solution along these lines would be possible but rejected it on the grounds that it's not very satisfying -- but DarioOO's made a comment to another answer suggesting that perhaps this is the sort of answer he has in mind:

Each of the thieves who divides up the loot pockets some of the diamonds while counting. There are $n$ diamonds at the start. Thief 1, let's suppose, just has the unopened bag and hasn't done that at all. (Serves him right for being the first to try to swindle the others!) Then thief 2 takes $a_2$ diamonds, leaving a number $n-a_2$ that's 1 mod 2. Then thief 3 takes $a_3$ diamonds, leaving a number $n-a_2-a_3$ that's 2 mod 3. And so on, until thief 7 takes $a_7$ diamonds, leaving $n-a_2-\cdots-a_7$ diamonds, a number that's 6 mod 7. Write $m=\frac{n-a_2-\cdots-a_7-6}{7}$. Then at the end, writing $a_1=0$ for symmetry, the thieves get $m+a_k+1$ for $k=1,\ldots,6$ and $m+a_7$ for the last thief.

It seems like there must be lots of solutions to this -- in some sense "most" choices of the $a_k$ should work because 420 isn't much bigger than 400 -- but let's see what happens if thief 2 pockets two diamonds, thieves 3 through 6 pocket one each, and thief 7 takes two. Then mod 2,3,4,5,6,7 we have $n-2=1,n-3=2,n-4=3,n-5=4,n-6=5,n-8=6$: that is, mod 2,3,4,5,6,7 $n$ is 3,5,7,9,11,14 or equivalently 1,2,3,4,5,0. So $n+1$ is a multiple of 60 and $n$ is a multiple of 7. $n=119$ will do. Then the process goes like this:

Thief 1 runs away with the bag. Thief 2 takes two, divides 117 into 2 and finds a remainder of 1. Thief 3 takes one, divides 116 into 3 and finds a remainder of 2. Thief 4 takes one, divides 115 into 4 and finds a remainder of 3. Thief 5 takes one, divides 114 into 5 and finds a remainder of 4. Thief 6 takes one, divides 113 into 6 and finds a remainder of 5. Thief 7 takes two, divides 111 into 7 and finds a remainder of 6. He gives 16 to each of the others and keeps 15. So now the thieves have, in order: 16, 2+16,1+16,1+16,1+16,1+16,2+15 or 16,18,17,17,17,17,17. The only thief richer than thief 7 is thief 2.

We could (and probably should) make it one notch simpler:

Suppose thief 2 takes one, thieves 3..6 take none, and thief 7 takes one. Then mod 2,3,4,5,6,7 we have $n-1=1,n-1=2,n-1=3,n-1=4,n-1=5,n-2=6$ or equivalently $n=2,3,4,5,6,8$; in other words $n$ is a multiple of 60 and is 1 mod 7. So we might e.g. take $n=120$. This has the further advantage that it's presumably easier to pocket a smaller number of diamonds (which is why I picked ones and twos to begin with, but zeros and ones are clearly better).

This sort of cheating is

similar to what Tony Ruth describes in his answer (but also similar to what I described in a comment to the OP before that, so I'm not cheating here myself!) but I don't think the extra complexity of his suggestions about bribery etc. is necessary. I take it that the thieves just counted out "one for you, one for you, one for you", etc., and none of them counted or calculated the total number of diamonds; so no bribery needed.

  • $\begingroup$ This is a more complex answer than necessary, I'm reading it because it seems to be correct anyway. So probably going to accept it! congratulations :) $\endgroup$ Commented Jun 10, 2016 at 10:19
  • 1
    $\begingroup$ This makes sense except that thief 7 somehow knows only one thief has more diamonds, which implies he knows who cheated and how. $\endgroup$ Commented Jun 10, 2016 at 10:19
  • 1
    $\begingroup$ The question doesn't actually say he knows that. (I agree it makes it sound as if he does.) $\endgroup$
    – Gareth McCaughan
    Commented Jun 10, 2016 at 10:43
  • 1
    $\begingroup$ DarioOO, if you have something substantially more elegant in mind then maybe you should give a hint to point the right way rather than accepting this. On the other hand, if this is basically how your intended solution works then I'll happily accept your acceptance :-) -- but I'd be interested to know how it can be made much simpler. My "one notch simpler" version seems to me about as simple as a solution along these lines can be made, but I'm probably missing something. $\endgroup$
    – Gareth McCaughan
    Commented Jun 10, 2016 at 10:45
  • $\begingroup$ @GarethMcCaughan you are right in suspecting there is a more elegant (and simpler) way to solve that. I was tempted to accept because you came with the correct lateral thinking and anyway I'm impressed by your skill in achieving a solution in the hard way. Now I'll try to hint towards the simpler version (it's hard at this point giving a hint wich is not the solution) XD $\endgroup$ Commented Jun 10, 2016 at 10:51

The part about the remainders can be reworded as

N+1 is a non-zero multiple of 2, 3, 4, 5, 6, and 7.

The smallest N that meets this is


However this contradicts

the stated maximum bag size


That only one thief ends up with more gems than the 7th

We are told they all started with no money.

Perhaps 20 gems were in a pocket, and 5 of the 6 thieves owed the 7th thief various debts, which they repay with some of their share. As a result only a single not-previously-indebted thief retains more than the 7th does.

Not very satisfying, but it's tagged .

  • $\begingroup$ Nice attempt, :) but the thieves starts with no money/diamonds, no debt. They are thieves after all $\endgroup$ Commented Jun 10, 2016 at 8:18

An extension of Gareth McCaughan's answer:

Thief 1 runs away with the bag with 119 diamonds.

Thief 2 came. "Hey you yo rascals!" Thief 2 stoles 2 diamonds and divides 117 into 2 and finds a remainder of 1.

Thief 3 came. "Hey you yo rascals!" Thief 3 stoles 1 diamonds and finds a remainder of 2.

Thief 4 came. "Hey you yo rascals!". Thief 4 stoles 1 diamonds and finds a remainder of 3.

Thief 5 came. "Hey you yo rascals!". Thief 5 stoles 1 diamonds and finds a remainder of 4.

Thief 6 came. "Hey you yo rascals!" Thief 6 stoles 1 diamonds and finds a remainder of 5.

That part is pretty much identical. This is where Thief 7 kicks in and explains what happens.

Thief 7 came in. "Hey dude. You are stealing our diamonds!"

Thief 3 chimed in, "We're dividing the diamonds."

Thief 7 talked, "I tell you what. I have no clue how many diamond is there but here me out. If there is any remainder, I will give them the remainder to you."

There are 6 diamonds. Happily ever after

The reason Thief 7 decided to surrender the diamond was to avoid conflict. When waking up, he must asked the following question.

What question?

Why are they not running with the diamonds already?

Why that question?

Thief 7 figured out that they are having remainders and having problems dividing the diamonds.

Imagine this: have the diamonds be even--despite Thief 1 and Thief 2 got caught by Thief 3, they have incentive to run away. Because the diamond is not split properly, Thief 1 and Thief 2 has incentive to stays to resolves the remainder.

Unfortunately for them, the remainder stays there until Thief 7 ran in.

The second reason Thief 7 want to surrender the remainder, is to make sure that if the remainder is not 6 diamonds--he has a bargaining chip. Imagine that the remainder is not 6 diamonds but 5 diamonds--there'll be blood everywhere on splitting the diamond. Thief 7 can asked to have his life spared because he already dropped his share.

After all:

They're Level 20 Thief. Nasty blood. As a paladin with level 20, there's more hypothetical blood in D&D than in real life at a single fight.

  • $\begingroup$ Ahahah a fun one! $\endgroup$ Commented Jun 11, 2016 at 8:21
  • $\begingroup$ I got it wrong? >< $\endgroup$
    – Realdeo
    Commented Jun 11, 2016 at 8:32
  • $\begingroup$ Well, numerically is based on another answer :) for the "logical" part instead I like the explaination infact +1 (even if it is not the one I thinked). Should I accept the McCaughan answer and spoil the real solution or is there anyone interested in doing more attempts? :) $\endgroup$ Commented Jun 11, 2016 at 9:23
  • $\begingroup$ Nah. Keep the ball rolling. $\endgroup$
    – Realdeo
    Commented Jun 11, 2016 at 10:39

Sigh... okay I'll embarrass myself again...


1 diamond


T1 tries to make off with the diamond and is caught by T2 who wants to split the loot. After reaching in, T1 and T2 discover there is only 1 diamond. The 'remainder' of the split not occurring equally is that of the thieves themselves... or put another way, there is now 1 thief left over without a diamond... Continue to T3 and you get 2 leftover thieves with no diamond. All the way until the final thief wakes up and there are 6 thieves left without a diamond and says, "whatever I don't need it" and gives it to say, T1. Now there is only one thief richer than the 7th thief.

  • 1
    $\begingroup$ Nice idea, but towards the end of the question one of the clarifying remarks says, in so many words, "he distributes the reminder to the other thieves (1 diamond to thieves numbered from 1 to 6)". $\endgroup$
    – Gareth McCaughan
    Commented Jun 10, 2016 at 0:14
  • 1
    $\begingroup$ And the statements about remainders say "2 diamonds", ..., "6 diamonds" explicitly each time. $\endgroup$
    – Gareth McCaughan
    Commented Jun 10, 2016 at 0:15
  • $\begingroup$ So far theorically there are at least 10 diamonds. One diamond is given to thieves from 1 to 6, but 7th is richer than they (so has at least 2 diamonds), and one thief is richer than him (so has at least 3). I am assuming the 5 other thieves have same number of diamonds, wich is not true. $\endgroup$ Commented Jun 10, 2016 at 8:17

My best guess:

The last thief (7th and last to attempt loot division) then decides to give up the remainder to the other thieves before they even attempt to do some modulus calculations. Anyway only 1 thief is richer than him now.
The emphasis here is that the 7th thief acted before the other thieves checked his math (and got away with it). Therefore if thieves 2-6 told the truth, then the possible numbers are:
59, 119, 179, 239, 299, 359
I think what happened was one of these numbers was the amount of diamonds, but the last thief skewed the distribution for himself and reported 6 diamonds left over which he then distributed.
With regards to the thief who somehow had more diamonds than the 7th, I believe there was a thief who somehow had the knowledge necessary to prove that the 7th was cheating them. So the 7th thief gave this other thief extra diamonds to keep his mouth shut.

Still feels kinda flimsy. I have a feeling the answer to this puzzle will not be very satisfying. Also, the word remainder is spell reminder the last several times it is used. Not sure if this is related to the lateral-thinking clue or just a typo

  • $\begingroup$ A typo. Nice guess for the emphasis you are damn pretty near to the solution. Thieves are all almost equal in what they do, you just need to carve out exact numbers (there are many possible solutions that satisfy the constraints), just have to choose one (and one is especially simple to check). $\endgroup$ Commented Jun 10, 2016 at 8:13

I came up with this... but I brute forced it in code:



while i < 401 if i % 7 = 6, %6=5 //so on and so on until %2=1 then i = answer

Deeper explain how/why/what I came up with: Story says talks about 1 thief trying to get away with all the loot but is stopped by the 2nd. The try to split the pot between the two of them but are left unequal by 1.

2 thieves = 1 remainder

Then another thief is added to the mix which results in a remainder of 2

3 thieves = 2 remainder -> and leads to the patter outlined in the story


if a number is true for 7 mod n = 6, 6 mod n = 5, 5 mod n = 4, 4 mod n = 3, 3 mod n = 2 and 2 mod n = 1 AND there is only one number that matches for any number found less than 400 (from story as the bags max capacity)

Executing the logic gives :


Oh and in case you were wondering how many each thief had...

6 thieves had 34 and 1 thief had 35

PART II: I occurred to me that I could "Cheat" with this in the following way:

if we assume that each remainder was kept by each thief that discovered said remainder, than T1 has 0, T2 has 1... etc until T7 says "take 1 each of my 6 that will be left over(T7 is trying to cheat them)" so now T1 = 1, T2 = 2, - T6 = 6... now in order for only one other thief to have more than T7, T7 would have 5. So, 5 + 5 + 6 + 4 + 3 + 2 + 1 = 26 (again a cheat as 26 mod 2 is actually 0 and not 1 as the original piece suggests... but...)

I played with this and did also find the answer that was commented as "probable to be accepted"... but I couldn't for the life of me explain my formula and thus did not post... excellent riddle...

  • 1
    $\begingroup$ Are you sure the code is correct? Just look at this code. The lowest number it prints is 419. ideone.com/zsPPLd .. It seems you attempted to bruteforce the trivial solution, but somewhere your code was bugged (or your calculations if you are not a programmer) $\endgroup$ Commented Jun 9, 2016 at 18:33
  • 1
    $\begingroup$ 34*7 is 238. Check your numbers. $\endgroup$ Commented Jun 9, 2016 at 18:34
  • 1
    $\begingroup$ I think you may have missed something in the oversimplified explanation of my code... cuz it works $\endgroup$
    – MegaMark
    Commented Jun 9, 2016 at 18:34
  • 1
    $\begingroup$ @KateGregory see the last piece of my answer $\endgroup$
    – MegaMark
    Commented Jun 9, 2016 at 18:35
  • 2
    $\begingroup$ You missed the last reminder is 6 not 1. So you should do if (i % 7 == 6) { taht's because 4th ,5th, 6th, 7th thieves gets respectively those reminders 3, 4, 5, 6 $\endgroup$ Commented Jun 9, 2016 at 18:40

@GarethMcCaughan's answer seems correct, but I have another explanation for thief 7. I guess that Thieves 1 and 2 placed that 1 remaining diamond near the rest of the sleeping thieves, in order to resolve the issue of the remaining 1, (of course after thief 2 had taken 1 diamond for himself) and also as a compensation maybe for their hard work.. and maybe thief 7 was clever enough to pocket that diamond silently :P
Then he gave the remaining 6 diamonds to others, realizing that the division of the diamonds would be fair that way, since he already had one with him, oblivious to the fact that thief 2 had stolen one diamond from the bag already.

  • $\begingroup$ very very good :) a bit overcomplicated. but correct :) $\endgroup$ Commented Jul 13, 2016 at 12:06

Since the solutions are now enough here's the intended solution, SPOILER WARNING (OPTIMAL SOLUTION:

Each thief rob a small amount of diamonds, and we start exactly from 400 diamonds (told that was simple :P). The amount stolen is the minimum to get those reminders so the second thief rob 1 Diamond, at this point the third thief know it has half chance to get no reminder at all by robbing 1 diamond. But it is unlucky and got anyway a reminder. The point is that as long as thieves can proove the reminders require an amount of Diamonds greater than the maximum (400) they can accuse someone, they do their best to keep a portion of diamonds for theirself and make harder eventually for the next thief to prevent accusations (wich basically means robbing a small random amount or a targeted amount like the first thieve, however not required to find the strategies used, we could use the "minimum amount to get that reminder startin from 400"). The amounts stolen are 0,1,1,3,1,5,5.

Then the last thief realizes:

If the reminders are like that then he could be accused, so he decide to divide the reminder to others before they do that math too. Of course he don't know how much others stole, however they finally have 1,2,2,4,2,6,5 extra diamonds each one plus 54 that comens from the remaining 378 diamonds divided by 7. The last thief is lucky because even by giving away a reminder greater than the stolen quantity, is still the 2nd richer. Only the 6th thief is richer than him.

The required math:

neither a system resolution was required, just a small trial and error with the simplest things that can come to mind. Apart showing that ther reminders 1,2,3,4,5,6 requires an amount of diamonds greater than 400, wich can be computed easily without necessarily using a system.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.