From: "Simon Kröger" Date: 2006-07-08T18:43:52+09:00 Subject: Re: [QUIZ] Panagrams (#86) Christoffer Lern� wrote: > This is really crazy. > > Either people have optimized things a whole lot better than me (not > unlikely, I haven't made any real attempts at optimizing things), or I > am using a bad algorithm. > > I didn't time the solution: > > a ruby quiz solution found this sentence enumerating four a's, two b's, > two c's, three d's, thirtyfour e's, nine f's, three g's, eight h's, > sixteen i's, one j, one k, three l's, two m's, twentyfive n's, fifteen > o's, one p, two q's, eleven r's, twentynine s's, twentyfive t's, nine > u's, four v's, nine w's, three x's, six y's and two z's > > ...but it took my program 8018361 iterations. > > Is it the optimization or the algorithm I got wrong? > > /Christoffer Well, what's an iteration in your code? I found a solution (the same) to your sentence above after 255062 full circles over all 26 letters. (changing only some of them each time) It took 36s on my laptop. (Pentium M 2.1 GHz) I ran it again and it took 134s and did 10105853 changes to the original guess (counting each changed count separately). Obviously (at least with my algorithm) it depends on luck. And for the total Time it takes it depends on your PC and optimization. cheers Simon