Is there a mathmatical solution to this problem?

The archivist misplaced his shopping list inside one of the books. He has a handy way to remember which volume he placed it in, though. The volume number was a four-digit number, in which all four digits were unique. If you take the largest possible four-digit number that can be made by rearranging the four digits, and you subtract from that the smallest possible four-digit number that can be made by rearranging the four digits, the number you get is volume number, but with the digits in reverse order.

In what volume of the Encyclopedia Altadoria did he leave his shopping list?

Hmm

Using what you described there is no way to find the volume directly.

However, if you mean that the largest possible 4 digit number that any book in the library can be (with all unique digits) then that would be 9876 (because 9950 has 2 x 9), and we want the largest we can obtin so make each digit 1 smaller than the last. The smallest possible would be 0123.
If this is correct then all you do is subtract the smaller from the larger, reverse the digits and get the volume.

However if you mean what you say exactly, it's not possible to work out directly (i think) because the volume number is unknown, the largest and smallest could be any one of many many permutations.

Last edited by Alias_NeO; August 27th 2007 at 02:59 PM.
Reason: Mistake.

The answer

The largest number obtained from rearranging the digits is 7641The smallest number obtained from rearranging the digits is 1467

Subtract the smaller from the larger to get 6174

Reverse the order of 6174 and you get 4716 which is the number we started with. Interestingly there is only one number between 0000 and 9999 that has this property.

You could say I cheated to get this answer as I wrote a BASIC algorithm to solve it by trial and error. I have posted the program below, with hopefully enough comments to make it self explanatory. The challenge now is to discover if there is a logical or algebraic method to solve this question without needing to resort to a computer.

REM ***** BASIC *****Sub MainDim N(4),P(4),T(4),RT(4) As Integer

For i = 0 to 9950digitize(i,N()) Rem Split i into 4 digits stored in array N().If isunique(N()) then largest(N()) Rem If all the digits are unique then rearrange to find the largest number.NN=N(1)*1000+N(2)*100+N(3)*10+N(4) Rem NN is the value of the largest number express as a single variable.P(1)=N(4) : P(2)=N(3) : P(3)=N(2) : P(4)= N(1) Rem Reverse the digits of N to find the smallest value.PP=P(1)*1000+P(2)*100+P(3)*10+P(4) Rem PP is the smallest value.TT=NN-PPdigitize(TT,T()) Rem Subtract smallest from largest, digitise it and reverse the digits.RT(1)=T(4) : RT(2)=T(3) : RT(3)=T(2) : RT(4)= T(1)NT=RT(1)*1000+RT(2)*100+RT(3)*10+RT(4) Rem Find the actual value of the reversed digits.If NT=i thenPrint "Found a solution ";i;" ";NN;" -";PP;"=";TT;" <--> ";NTend ifend ifnext imsgbox "No more solutions"end Sub

The archivist misplaced his shopping list inside one of the books.
He has a handy way to remember which volume he placed it in, though.
The volume number was a four-digit number, in which all four digits were unique.
If you take the largest possible four-digit number that can be made
by rearranging the four digits, and you subtract from that the smallest
possible four-digit number that can be made by rearranging the four digits,
the number you get is volume number, but with the digits in reverse order.

In what volume of the Encyclopedia Altadoria did he leave his shopping list?