aani arni bani dani mani pani rani' which means that 'aani' is only one letter different from arni, bani, dani, mani, pani and rani (yes they are all valid words). From the output you can see that it took a little over an hour to process all 4919 words. The program is somewhat inefficient and I could easily improve on it but as I was looking at Go I skipped that and went straight for a version of this program in Go.
First the Ruby version:
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
:
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
I assumed that as list had been implemented as a package it would be a superior solution to plain string slices, I mean why create a package that is inferior to the built in functionality.
Ruby doesn't have linked lists so you wouldn't understand. I mean why should rock star rubists concern themselves with theory and understanding?
On 2 June 2014 09:00, Benjamin Measures <saint....@gmail.com> wrote:
Ruby doesn't have linked lists so you wouldn't understand. I mean why should rock star rubists concern themselves with theory and understanding?
Snide and unhelpful all in one lump.
If you can't be polite, be quiet.
...<font face="arial narrow, sans-s
--
You received this message because you are subscribed to a topic in the Google Groups "golang-nuts" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/golang-nuts/Hkav3BpgWsk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to golang-nuts...@googlegroups.com.
I think Peter's ruby program finds all _shortest_ paths between each pair of words. That is, (shortest) paths between every pair of words, not every path between every pair of words. The latter has exponential blowup and for example there's at least 16! paths from BAT to CAT, since you can take any path through the set of words: EAT FAT GAT HAT KAT LAT MAT NAT OAT PAT QAT RAT SAT TAT VAT WAT. 16! ~= 2e13, which is too big to be feasible.
Anyhow, as an exercise since I've never done any benchmarking/profiling/etc. in go before, I wrote some code to find, for each N, the pair of words of length N that have the longest distance between them. I suppose there's a cleverer way to find a graph diameter than to do a full depth-first search on the graph for every node, but that's what I did, and the slowest N (ie: N=5) took 118sec, which is quite a lot better than 11 hours. It's a curiosity that N=5 is slower than N=6 and N=7, because there's more words 6 and 7 letter words than 5 letter words. I think it's because there's lots of 6 and 7 letter words with common suffixes, and so the graph has relatively fewer edges.
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
:I think Peter's ruby program finds all _shortest_ paths between each pair of words. That is, (shortest) paths between every pair of words, not every path between every pair of words. The latter has exponential blowup and for example there's at least 16! paths from BAT to CAT, since you can take any path through the set of words: EAT FAT GAT HAT KAT LAT MAT NAT OAT PAT QAT RAT SAT TAT VAT WAT. 16! ~= 2e13, which is too big to be feasible.Yes, all shortest paths would be much more reasonable. But I can only go by what people say, and he wrote specifically, "I have a little program I wrote in Ruby to find all the chains between any two four letter words where each intermediate word only differs by one letter." [emphasis mine.] Another support for 'all' meaning 'all' rather than 'each solution of shortest length' is the reported long run times. Anyway, if the problem is as you state it is much more interesting!
Now the Go version which is essentially the same code but with some improvements over the Ruby version. I realise that this may not be the best written program but I was expecting some improvement over the Ruby version. However whereas the Ruby version ran in little over an hour the Go version took 11 hours to process only 1303 words from the dictionary, it seems to be averaging around 30 seconds per word and the program would probably take around 40 hours to complete. As I've said I recognise that the Go version is not the best solution to this problem but I find it difficult to understand how it can be an order of magnitude worse.
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.