P16562 link reply
Three sisters combine their money to buy a mystery box full of an unknown amount of comic books. The box arrives at the sisters’ house one night, and they agree to store it in their younger brother’s room and not open it until the next morning.

But that night, one sister can’t sleep, so she decides to sneak in and open the box. Looking inside, she finds that she can split the comic books into three equal shares, plus one extra comic. She sees her brother awake and spying, so she hands him the extra comic, takes her own share of one-third of the remaining comic books, and goes back to sleep.

An hour later, the second sister does the exact same thing. She opens the box and sees that the comics can be split into three equal shares, plus one extra comic. She bribes the spying little brother with a comic, takes one-third of the remaining books, and goes back to sleep.

Then, an hour after that, the third sister does the same thing yet again, bribing the spying little brother with a comic, taking one-third of the remaining books, and returning to bed.

In the morning, none of the sisters want to reveal that they’ve already taken any comics. So they each pretend to be surprised when they look in the box. They dump out the comics and realize that the number of books can easily be split into three equal shares along with one extra comic, which they gave to their happy little brother.

What’s the smallest possible number of comic books that could have been in that mystery box when it first arrived? And how many comics does each sibling have?
P16576 link reply
>What’s the smallest possible number of comic books that could have been in that mystery box when it first arrived?
79
>And how many comics does each sibling have?
when 1st sister raided the stash (79 left): S1 has 26, LB has 1
when 2nd sister raided the stash (52 left): S2 has 17, LB has 2
when 3rd sister raided the stash (34 left): S3 has 11, LB has 3
morning (22 left): S1 has 33, S2 has 24, S3 has 18, LB has 4

i have 2 brute force solutions:

---

when it is said that X can be divided in 3 equal parts with 1 leftover, it means X%3=1
so after one sister raids the stash, bribe the lil bro and takes 1 third, there is (X-1)*(2/3) comics left
this is repeated 3 times, and each time the leftover must an integer number which modulus 3 must be 1
this can easily be brute forced, the first integer to satisfy these criteria is 79

---

lets invert the previous function: if there are currently X comics leftover, before the previous sister raided the stash there were (3X+2)/2 comics
let F(x) = (3x+2)/2
we know that the final number of leftover comics before the morning was an integer which modulus 3 equals 1
the smallest natural number which mod3=1 is 1
we also know that 3 raids happened
so we can simply brute force all possible final values of leftovers, starting from 1, and increasing by 3, by recursiing F(X) 3 times and the first integer it yields is the number of stating comics
meaning we want to know the smallest value of x for which F(F(F(x))) is an integer
turns out the smallest x is 22 (number of leftover comics in the morning) and the result is 79 (initial number of comics)
x