Numbers of another world

JBEMRA × PTPMIR = IBSMTBRERMAS \displaystyle \large \overline {\text{ JBEMRA} } \times \overline { \text{PTPMIR} } =\overline {\text{ IBSMTBRERMAS }}

Given above is a mathematical expression in base 10 10 . The expression is written in some alien language where each digit is replaced with a particular letter.

Find the number associated with EABMRPSTJIRB \overline { \text{EABMRPSTJIRB} }

Inspiration.


The answer is 926754018356.

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.

3 solutions

Pranjal Jain
Mar 22, 2015
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
from itertools import permutations
for i in permutations('0123456789'):
    x=''.join(i)
    J=x[0]
    B=x[1]
    M=x[2]
    E=x[3]
    S=x[4]
    T=x[5]
    A=x[6]
    P=x[7]
    R=x[8]
    I=x[9]
    if int(J+B+E+M+R+A)*int(P+T+P+M+I+R)==int(I+B+S+M+T+B+R+E+R+M+A+S):
        print(int(E+A+B+M+R+P+S+T+J+I+R+B))        

Returns 926754018356

@Aditya Raut 's algorithm.

Raghav Vaidyanathan - 6 years, 2 months ago

Log in to reply

Yeah right! I use just the same in all such problems.... in this problem, it took 18 seconds to answer....

Aditya Raut - 6 years, 2 months ago

@Pranjal Jain you don't have to import * from math or itertools, you'll have to import just "permutations" from itertools. The multiplication use of Asterisk (*) is inbuilt in python, so it'll do that even if you import just permutations and nothing else...

Aditya Raut - 6 years, 2 months ago

Log in to reply

I agree there is no use to import math, but I usually import math (always) in case I need some basic functions somewhere. Same with itertools, and laziness also, len('*')<len('permutations') Lol XD

Pranjal Jain - 6 years, 2 months ago

Log in to reply

Hey wait!!!! NO! You have to import that asterisk(*) as well as permutations (from itertools) if you go by what you had previously written (b4 edit)

So ` len('*') < len('permutations') is a sentence of no use, though it meant about typing number of characters :P ...

Aditya Raut - 6 years, 2 months ago

Anyways, I have edited it out.

Pranjal Jain - 6 years, 2 months ago

Here is the genetic algorithm code I used to solve this problem:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#include<fstream.h>
#include<conio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>

class indi       //Objects of this class are the individuals
    {
    char x[11];  //genetic code/DNA
    public:
    indi()
        {
        strcpy(x,"EBMJPRSTIA"); //initial DNA
        }
    void mutate() //causes random switching to genetic code
        {
            int a=(rand()%10),b=(rand()%10);
            char t=x[a];
            x[a]=x[b];
            x[b]=t;
        }
    void show() //prints DNA
        {
        cout<<x<<endl;
        }
    int retlet(char a)//returns respective digit that a letter represents
        {
        for(int i=0;i<10;i++)
            if(x[i]==a)
                return i;
        }

    };

double fitness(indi I,char c1[],int n1,char c2[],int n2,char c3[],int n3)
    {
    //used to calculate the fitness level of the DNA
    //more fitness implies better evolved
    double a=0,b=0,c=0;
    for(int i=n1-1;i>=0;i--)
        a+=pow(10,n1-i-1)*I.retlet(c1[i]);
    for(int i=n2-1;i>=0;i--)
        b+=pow(10,n2-i-1)*I.retlet(c2[i]);
    for(int i=n3-1;i>=0;i--)
        c+=pow(10,n3-i-1)*I.retlet(c3[i]);
    double f=abs((a*b)-c);
    return f;
    }

void nature(char S1[],char S2[],char S3[]) //implements natural selection
    {
    indi I[100]; //first 100 DNA
    int ss[3];
    ss[0]=strlen(S1);
    ss[1]=strlen(S2);
    ss[2]=strlen(S3);
    for(int gen=0;;gen++)
        {
        double b=fitness(I[99],S1,ss[0],S2,ss[1],S3,ss[2]);int a=99;
        for(int i=0;i<100;i++)
           {
           I[i].mutate();  //random mutation
           double k=fitness(I[i],S1,ss[0],S2,ss[1],S3,ss[2]);
           if(k<b)
               {
               b=k;a=i;      //fittest DNA chosen
               }
           }
        if(b==0) //if DNA is perfect, print DNA
            {
            I[a].show();
            cout<<endl<<gen;
            break;
            }
        indi II=I[a];
        for(int i=0;i<100;i++)
           I[i]=II;     //fittest DNA of current generation is cloned 100 times
        }
    }

int main()
    {
    clrscr();
    char a[]="PTPMIR",b[]="JBEMRA",c[]="IBSMTBRERMAS";
    nature(a,b,c);
    system("pause");
    return 0;
    }

1
2
3
4
5
from itertools import permutations

for j,b,e,m,r,a,p,t,s,i in permutations('0123456789',10):
  if int(j+b+e+m+r+a)*int(p+t+p+m+i+r)==int(i+b+s+m+t+b+r+e+r+m+a+s):
    print(e+a+b+m+r+p+s+t+j+i+r+b)

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...