+ G P S A R T L O I L T R I O L P S I O T N L A G I R
In the cryptarithm above, each letter represents a unique digit.
Find the value of GALOISRATS
Read an interesting note on cryptarithms here
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.
@Agnishom Chattopadhyay @Aditya Raut
Log in to reply
I am glad to see that someone liked my ideas.
I do not see any implementation of threading here. Did your.algorithm actually work? How fast/slow was it?
Log in to reply
It would be a great help if you know a way by which I can time my program. I use a borland 5.01 compiler for C++(outdated and stupid, i know).
Yes, I did not use threading or parallelization. Instead, i used sort of an aggressive form of natural selection. In each generation of 100 individuals, the best individual is chosen, and cloned 100 times(rest are discarded). Then, random mutations are induced in these 100 clones, and again the best individual is chosen, and so on. It took 1983 generations for my program to get to perfect fitness.
Log in to reply
@Raghav Vaidyanathan – I do not know how exactly that is done (not much of a C++ guy, here) but I think the standard approach is to use time.h and query for the time at the begining of the code and at the end and then check their difference.
Edit: I looked this up. This is what you should do:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
|
The above code might contain bugs, I've not tried it. CLOCS PER SEC is a macro
Log in to reply
@Agnishom Chattopadhyay – Yes, I did try that out... but I do not know if or how I can get decimal time(in milliseconds). time.h returns time in whole seconds only.
Log in to reply
@Raghav Vaidyanathan – Check the update of the last comment
Log in to reply
@Agnishom Chattopadhyay – I did, and it worked after i tweaked it a bit.
Since my algorithm is aggressive, the runtime depends on the randomisation seedvalue. But the code works under a second in almost all times I have re run it.
Log in to reply
@Raghav Vaidyanathan – Okay, that isvery good.
@Agnishom Chattopadhyay – Thanks a lot!
I really do think that IS a bigg solution, and also, I don't know the language you used, but seems like it's something innovative, so cheers... See my python solution downstairs, though it's bad while assigning the values to letters, after that I've used one nice concept of making strings into integers and integers into strings... As I don't understand above, can you tell me in simple words what is such a concept you've utilised (So that I can use it from now on, bcoz you are really a cool guy as it seems)
Log in to reply
See the note referred in the problem. :)
The note explains it much better than I can. And I did see your python solution, it was good. In fact, I used it to solve the WRONG+WRONG=RIGHT question. I do not know python, all I did was copy paste your code into the GUI and then edit it a bit to give me what I needed. Hope you like the concept of genetic algorithm. Have fun! Thanks.
Log in to reply
@Raghav Vaidyanathan – Alright, I read that note and it's cool, but there's one issue ,that paste bin thing linked at the end says the paste has been removed, I really wanted to see one example of python implementation, that'd be great .. @Agnishom Chattopadhyay , plz do something...
Log in to reply
@Aditya Raut – @Aditya Raut : Can you open this link: http://pastebin.com/84tttH4W
Log in to reply
@Agnishom Chattopadhyay – Can you please check if you have other stuff in your pastebin account that other people can see? @Agnishom Chattopadhyay
Log in to reply
@Raghav Vaidyanathan – What kind o other stuff?
Log in to reply
@Agnishom Chattopadhyay – Idk... sth personal?
Very Easy python solution, using strings. First assign the 10 digits to the 10 variables, for that I used permutations. Then it's cakewalk! See this :-
1 2 3 4 5 6 7 8 9 |
|
So, the answer is 6 5 1 2 8 9 4 5 0 9
The brute force solution... not bad
Log in to reply
I just solved one more problem of this type, it was ' WRONG+WRONG=RIGHT' ... There, the answer I got by above program was 2*ans, because total variables are 8 and values possible are 10... so 2! times more ans.... So cool it felt after noticing that.....
Log in to reply
Did you ever try implementing the permutations utility yourself?
Log in to reply
@Agnishom Chattopadhyay – What exactly do you mean to ask? Is it "Did you try to write a program that gives permutations"? Or is it "Where did you come to know about the permutations tool" ? I don't understand...
@Raghav Vaidyanathan , @Agnishom Chattopadhyay , @Pranjal Jain , @Brock Brown
This solution has been edited, please look again.
Guys, see this cool reduction I found in this brute force solution.... The way I input the variables has been made shorter (If you remember previously there was 1 line for assigning each variable), now the variables are easily obtained by comparing with the list!
Used this trick in the following problems, all are the same type...
here ,
here ,
here ,
here ,
here ,
here ,
here ,
here ,
here ,
here ,
here ,
and things got wayyy shorter!
This is the shortest and the most efficient solution for this problem:
1 2 3 4 5 |
|
1 |
|
Problem Loading...
Note Loading...
Set Loading...
I read @Agnishom Chattopadhyay 's note on cryptarithms before trying this problem. I initially planned to do a brute force tactic, but then switched to a genetic algorithm, to see how it works. I use C++, so not much versatility here, had to make everything from scratch.
The code below is self explanatory. If it isn't, please also take a look at the above mentioned note .