If every letter corresponds a unique digit in decimal system and
T
O
M
+
G
I
V
E
S
=
M
O
S
T
+
T
I
M
E
Find the value of
E
G
G
+
I
S
+
V
E
G
Details and assumptions :
∙ If ( A , B , C , D ) = ( 1 , 2 , 3 , 4 ) , then B A D = 2 1 4 .
∙ Everything is in decimal representation and every letter corresponds to one unique digit. That is why this has exactly one solution.
Everything that i shared on brilliant
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.
@Raghav Vaidyanathan and @Agnishom Chattopadhyay , my programming friends....
"0123456789"="OGSIVMaaET"
Your python code takes 23 seconds to run on my computer.
I actually extended my genetic algorithm from the previous problem to adapt into this. Works well under a second, every time. When I first saw that there were two undefined digits, I thought there might be multiple solutions. My algorithm cannot find both simultaneously. But then I assumed that you must have taken care of that. And I was right. Good job. I have been posting a few programming problems lately, try those if you are interested.
Log in to reply
That's so amazing, I'm gonna try and learn genetic programming right now ! (Time is not issue for me now, I could've waited for 1 hour if that did give answer :P LOL)
This is the most efficient solution so far:
1 2 3 4 5 |
|
1 |
|
Using C++ implement the Genetic Algorithm easily after read article from Agnishom Chattopadhyay
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 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
|
I used Python coding which is similar to [Aditya Raut]. The second line "x=' '.join(i)" may not be necessary. The answer is 1 3 2 4 .
from itertools import permutations for a in permutations("0123456789", 8): T = a[0] O = a[1] M = a[2] G = a[3] I = a[4] V = a[5] E = a[6] S = a[7] if T != "0" and G != "0" and E != "0" and I != "0" and V != "0": if int(T+O+M)+int(G+I+V+E+S)==int(M+O+S+T)+int(T+I+M+E): print T,O,M,G,I,V,E,S print int(E+G+G)+int(I+S)+int(V+E+G)
Problem Loading...
Note Loading...
Set Loading...
The program will print the solution 2 times, because we are using 8 integers out of 10 so the 2 ! permutations will give the solution 2 times, but anyway, the solution is unique, answer 1 3 2 4