# Mathematical puzzle: ten digit lock number

A mathematical professor set his lock number, he used mathematics so he would remember the ten digit code. He used all of the numbers from 0-9, every number only once. In his mind the first two numbers of the code became a two-digit-number (XX). If you multiply this number (by some integer) you get a three-digit-number (YYY), which is third, 4th and 5th number of the code. And lastly, if you multiply the first (two-digit-number) with a second (three-digit-number) you get the remaining five numbers of the code (five-digit-number).

In other words, we're looking for

XX-YYY-ZZZZZ

where

XX * ? = YYY
XX * YYY = ZZZZZ

And all digits are unique.

• Could you clarify the question a bit? You wrote "...in his mind the first two numbers of the code became a two-digit-number. If you multiply this number (by what?) you get a three-digit-number..." Are you looking for a solution where you square the first two numbers to get the next three? Are you looking for a solution where you double the first two number to get the next three? – Hugh Sep 4 '18 at 17:35
• Also, are we allowed to insert leading zeroes? For example, if the two digit number XX times the three digit number XXX, and we get a four digit answer, can we put a 0 in front of it to make it 5 digits? – Hugh Sep 4 '18 at 17:53
• @Dejan Pivk, Welcome to PSE. When you say "I would like to find the answer to", does that mean you don't know the answer to the question? Did you create this puzzle yourself, or did you find it somewhere? – nikki Sep 4 '18 at 17:58

Feel a little bit bad because I just brute-forced it but:

27-594-16038

Explanation:

The two digit number is 27. If you multiply this number (specifically by 22) you can get 594. 27 * 594 = 16,038. All these numbers appended together makes 2759416038 which is a ten digit number that uses each digit only once. It is also the only such number that fits all the prescribed rules.

• Awww what? I just ran my program to solve that :( – Rohit Jose Sep 4 '18 at 18:28

I assumed that "multiply this [two-digit] number" means "multiply it by something unknown" and wrote a simple program to see what this unknown could be. I only found one possible value of this unknown:

The statement will read "multiply this number by 22".

In this case the answer is:

2759416038: 27 * 22 = 594, 27 * 594 = 16038

If I understood the riddle correctly we should find ten numbers (a combination for the lock). The first two numbers form a two digit number which multiplied with it self should form another three digit number. And the two-digit number multiplied with the three digit number should form the full lock combination.

XX^2=XXX

XX*XXX=XXXXX

XX XXX XXXXX = combination key

• That's what I thought originally too, but that interpretation has no solutions. The only way I could interpret the riddle to return just one solution is that the first two digit number has to be multiplied by some integer to get the next three digit number. – Luke C. J. Currie Sep 4 '18 at 19:53
• Yup, I think your solution might be just right. Thank you btw. – JackNicholson Sep 4 '18 at 20:00

Checking all possible solutions for this riddle, finally receiving:

XX: 27 , YYY: 594 , ZZZZZ: 16038

x<-0:9
for(i in x){
for(j in x){
if(i!=j){
tmp<-(i*10+j)*1:82
tmph<-tmp%/%100
tmpz<-tmp%/%10-10*tmph
tmpe<-tmp%/%1-100*tmph-10*tmpz
tmpyyy<-tmp[which(!is.element(tmph,c(i,j)) & !is.element(tmpz,c(i,j)) & !is.element(tmpe,c(i,j)) & tmph!=tmpz & tmph!=tmpe &tmpe!=tmpz & tmp>99 & tmp<1000)]
tmp<-(i*10+j)*tmpyyy
tmp2zt<-tmp%/%10000
tmp2t<-tmp%/%1000-10*tmp2zt
tmp2h<-tmp%/%100-10*tmp2t-100*tmp2zt
tmp2z<-tmp%/%10-10*tmp2h-100*tmp2t-1000*tmp2zt
tmp2e<-tmp%/%1-1000*tmp2t-10000*tmp2zt-100*tmp2h-10*tmp2z
tmpzzzzz<-tmp[which(!is.element(tmp2zt,c(i,j)) &!is.element(tmp2t,c(i,j)) & !is.element(tmp2h,c(i,j)) & !is.element(tmp2z,c(i,j)) & !is.element(tmp2e,c(i,j)) & tmp2h!=tmp2z & tmp2h!=tmp2e &tmp2e!=tmp2z & tmp2e!=tmp2t &tmp2e!=tmp2zt &tmp2t!=tmp2z&tmp2zt!=tmp2z &tmp2h!=tmp2t &tmp2h!=tmp2zt &tmp2t!=tmp2zt & tmp>9999 & tmp<100000)]
if(length(tmpyyy)>0 & length(tmpzzzzz)>0){
for(y in tmpyyy){
tmph<-y%/%100
tmpz<-y%/%10-10*tmph
tmpe<-y%/%1-100*tmph-10*tmpz
tmp2zt<-tmpzzzzz%/%10000
tmp2t<-tmpzzzzz%/%1000-10*tmp2zt
tmp2h<-tmpzzzzz%/%100-10*tmp2t-100*tmp2zt
tmp2z<-tmpzzzzz%/%10-10*tmp2h-100*tmp2t-1000*tmp2zt
tmp2e<-tmpzzzzz%/%1-1000*tmp2t-10000*tmp2zt-100*tmp2h-10*tmp2z
tmpres<-tmpzzzzz[which(!is.element(tmp2zt,c(tmph,tmpz,tmpe))& !is.element(tmp2t,c(tmph,tmpz,tmpe)) & !is.element(tmp2h,c(tmph,tmpz,tmpe))&!is.element(tmp2z,c(tmph,tmpz,tmpe)) & !is.element(tmp2e,c(tmph,tmpz,tmpe))& ((i*10+j)*y==tmpzzzzz))]
if(length(tmpres)>0){
cat(paste("XX:",(i*10+j), ", YYY:",y, ", ZZZZZ:",tmpres))
}
}
}
}
}
}

• Hey, you missed the constrain that that the xx multiplied by yyy makes zzzzz – Ontamu Sep 5 '18 at 8:41
• Thanks. I recoded it now which reduced the possible solutions. – Alex2006 Sep 5 '18 at 8:53
• You might still have some debugging to do on the code. 54*216 = 11664 not 37908. I believe you will end up with only 1 solution if find the error in the code. – Ontamu Sep 5 '18 at 8:57