+ 5

How to solve this mathematic puzzle with a program?

Find 2 numbers: Number A: 3 digits. The last digit is 9. Number B: 3 digits. The second digit is 6. A + B = C C is a 4 digits number, and the second digit is 0. • • 9 + • 6 • ------------- = • 0 • • All digits 0 to 9 must be placed, and only once time. Thanks

15th Jan 2019, 12:56 PM
S K Lurk //\●●/\\
S K Lurk //\●●/\\ - avatar
5 Réponses
+ 6
There are two possible solutions to this problem: Option 1: A = 289 and B = 764 Option 2: A = 788 and B = 264 In both cases the sum is 1053
9th May 2019, 8:44 PM
Stefaan Lampaert
Stefaan Lampaert - avatar
+ 5
Seen like this. (As idk what language will you use) for (int A = 100; A < 1000; A++) for (int B = 100; B < 1000; B++) { if (A % 10 == 9 && (B/10)%10 == 6 && (A+B)/100%10 == 0) print("%d, %d" A, B); } (And additional loops to check for 1 to 9
15th Jan 2019, 1:34 PM
ShortCode
+ 4
You know that 'a' is a three digit number that ends in a 9, so you can use for(int a=109; a < 1000; a+= 10) in your loop. For 'b' you could do something like: for(int i=100; i<1000; i+=100) { for(int j=0; j<10; j++) { b = i+60+j; } } (there might be a better way, not sure). Seems complicated, but spares you thousands of unnecessary comparisons and calculations.
15th Jan 2019, 2:22 PM
Anna
Anna - avatar
+ 2
Use loops. check each the number until found the condition you want.
15th Jan 2019, 1:33 PM
ShortCode
0
You need to put digits 1234578 in the right order onto the points. So generate all the permutations (7! Altogether), place it one by one, then check the addition.
23rd Feb 2019, 3:46 PM
tamaslud
tamaslud - avatar