Could you please explain aswell as giving me the answer, thanks (=

Printable View

- Aug 25th 2007, 01:49 PMkirsty_bIs there a mathmatical solution to this problem?
Could you please explain aswell as giving me the answer, thanks (=

- Aug 25th 2007, 01:50 PMkirsty_b
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? - Aug 25th 2007, 01:52 PMkirsty_b
There are 9950 books in the library.

- Aug 27th 2007, 02:44 PMAlias_NeOHmm
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. - Aug 31st 2007, 04:35 PMkev pThe answer
The solution to this problem is 4716

The largest number obtained from rearranging the digits is 7641

The 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 Main

Dim N(4),P(4),T(4),RT(4) As Integer

For i = 0 to 9950

digitize(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-PP

digitize(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 then

Print "Found a solution ";i;" ";NN;" -";PP;"=";TT;" <--> ";NT

end if

end if

next i

msgbox "No more solutions"

end Sub

Sub digitize(ii,Q())

k=ii

Q(1)=Fix(k/1000) : k= k-Q(1)*1000

Q(2)=Fix(k/100) : k= k-Q(2)*100

Q(3)=Fix(k/10) : k= k-Q(3)*10

Q(4)=k

end sub

Function isUnique(Q()) as boolean

For j=1 to 4

For k=j+1 to 4

If Q(j)=Q(k) then

isUnique = false

exit function

end if

next k

next j

isUnique=true

end function

Sub reverse_digits(Q(),R())

R(1)=Q(4) : R(2) =Q(3) : R(3)=Q(2) : R(4)= Q(1)

end sub

Sub largest(Q())

For j=2 to 4

For k = j to 4

If Q(k)>Q(j-1) then

temp = Q(j-1) : q(j-1)=q(k) :Q(k)=temp

end if

next k

next j

end sub

- Sep 1st 2007, 01:07 PMSoroban
Hello, kirsty_b!

Quote:

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?

One possible answer: .

The largest permutation is:

The smallest permutation is:

The difference is: .

Hence, the volume number is .

Are there any other solutions? . . . I don't know. - Sep 1st 2007, 05:44 PMkev p
There are no other solutions. 4716 is the only possible solution.

My algorithm above checked every permutation from 0000 to 9999

I am still curious if there is a way to deduce this solution without the brute force method of checking every permutation?