Can you fill in these boxes? (Part II)

Within the boxes above, each contains a distinct digit from 0 to 9 such that the quotient, with a prime divisor, on the left equals to the difference on the right and that the sum of the four digits of the numerator equals to the sum of two digits of the divisor.

What is the value of this equation?


The answer is 46.

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.

1 solution

First Last
Mar 17, 2018

In C++

Using a simple permutation generator for a list of 0 to 9 then checking the conditions inside:

 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
#include <iostream> #include <list> #include <cmath> using namespace std ;
bool prime(int a){   if(a==2) return true ; if(!(a%2) || a==1) return false ;
    for(int i = 3 ; i < floor(sqrt(a))+1 ; i+= 2) if(!(a%i)) return false ; return true ; }
// ^ junk condensed ^

int done ; //how long the permutation is, 10 here

void loop(list<int> used, list<int> current){ //does permutations
//works by taking what is used and what is left to be organized
    int count = int(current.size()) ;
    for(int i = 0 ; i < count ; i ++){
        list<int>::iterator a = current.begin();
        advance(a, i) ;
        used.push_back(int(*a)) ;
        if(used.size() == done){
            int b[10] ;
            int c = 0 ;
            for(list<int>::const_iterator it = used.begin(); it != used.end(); it++, c++) b[c] = *it ;
            //check conditions and display
            if((double)(b[0]*1000+b[1]*100+b[2]*10+b[3])/(double)(b[4]*10+b[5])==(b[6]-b[8])*10+b[7]-b[9] && b[0]+b[1]+b[2]+b[3] == b[4]+b[5] && prime(b[4]*10+b[5])){
                cout << b[0] <<b[1]<<b[2]<<b[3]<<"/"<<b[4]<<b[5]<<" = "<<b[6]<<b[7]<<" - "<<b[8]<<b[9]<<" = "<<(b[6]-b[8])*10+b[7]-b[9]<< endl ;
            }
        }
        list<int> toPass = current ;
        toPass.remove(int(used.back())) ;
        loop(used, toPass) ;
        used.pop_back() ;
    }
}

int main(){
    int pass1[] = {0,1,2,3,4,5,6,7,8,9} ;
    list<int> pass ;
    pass.assign(pass1, pass1+sizeof(pass1)/sizeof(int)) ;
    done = int(pass.size()) ; //10
    list<int> a ;
    loop(a, pass) ; //pass in a blank list and the one containing 0-9
    return 0;
}

@Worranat Pakornrat This outputs:

0532/19 = 76 - 48 = 28

1843/97 = 25 - 06 = 19

3082/67 = 91 - 45 = 46

Should you specify to get the largest value of the expression?

First Last - 3 years, 3 months ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...