As I was sight-seeing during our train trip, Holmes came out from the other compartment and sat across me.
Holmes : There are types of compartments in this train. Let us call them for simplicity. Each type contains distinct number of seats as its standard manufacture, and this train has equal amounts of compartments for each type.
I : If you say so.
Holmes : Now if one seat were removed from the train, we would be able to rearrange the remaining seats in any of these new forms of compartments:
I : And so?
Holmes : So if you please tell me, Watson, how many seats are there in each type of the compartment?
You can submit the sum of seats in each type combined as your answer.
Inspired by Hens, Pigs, & Ducks
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
Let S be the total number of seats in the train and x be the number of seats in compartment X , y be that in each Y , and z be that in each Z .
Then we can set up the Diophantine equations as followed:
7 x + 5 y = S − 1 8 y + 3 z = S − 1 4 z + 9 x = S − 1
We can then rewrite the whole system as matrix multiplication:
⎣ ⎡ 7 0 9 5 8 0 0 3 4 ⎦ ⎤ ⎣ ⎡ x y z ⎦ ⎤ = ⎣ ⎡ S − 1 S − 1 S − 1 ⎦ ⎤ = ( S − 1 ) ⎣ ⎡ 1 1 1 ⎦ ⎤
The determinant of the 3 × 3 matrix equals to 7 × 8 × 4 + 5 × 3 × 9 = 2 2 4 + 1 3 5 = 3 5 9
Hence, solving the equation by multiplying the inverse matrix, we will obtain:
⎣ ⎡ x y z ⎦ ⎤ = 3 5 9 S − 1 ⎣ ⎡ 8 × 4 − 9 × − 3 8 × − 9 − 5 × 4 7 × 4 − 5 × − 9 5 × 3 − 7 × 3 7 × 8 ⎦ ⎤ ⎣ ⎡ 1 1 1 ⎦ ⎤ = 3 5 9 S − 1 ⎣ ⎡ 3 2 − 2 0 + 1 5 2 7 + 2 8 − 2 1 − 7 2 + 4 5 + 5 6 ⎦ ⎤ = 3 5 9 S − 1 ⎣ ⎡ 2 7 3 4 2 9 ⎦ ⎤
To yield integer solutions for x , y , z , S − 1 must be multiple of 3 5 9 . Then let S − 1 = 3 5 9 n for some positive integer n . Then x = 2 7 n ; y = 3 4 n ; and z = 2 9 n .
We know that S is a multiple of x + y + z as stated in the question, so we can rewrite S = m ( x + y + z ) = m ( 2 7 n + 3 4 n + 2 9 n ) = 9 0 m n for some positive integer m .
Hence, we can set up new equation:
S − 1 = 9 0 m n − 1 = 3 5 9 n
9 0 m n − 3 5 9 n = n ( 9 0 m − 3 5 9 ) = 1
Clearly, only n = 1 can divide 1 , leading to m = 4 and S = 4 × 9 0 = 3 6 0 . Finally, x = 2 7 ; y = 3 4 ; and z = 2 9 . Then x + y + z = 9 0 .