From: Daniel Martin Date: 2006-07-14T00:15:42+09:00 Subject: Re: [SUMMARY] Panagrams (#86) Ruby Quiz writes: > Now that we know what to call them, the question becomes how do we > generate self documenting pangrams? The linked article described a > technique called "Robbinsoning," which is a simple process. The > idea is that you start with some random distribution of letter > counts, build the sentence, adjust the counts to reflect the actual > sentence counts, rebuild, adjust, etc. You can zero in on a > solution in this fashion and most of the submitted solutions used > something along these lines. Note that the discussion of the different ways to solve this problem pointed up two distinctly different "randomized Robbinsoning" algorithms: 1) rebuild the sentence (or recalculate the frequencies) after each letter adjustment. This was what my code did. 2) Go through each letter doing randomized adjustments then, after all letters have been adjusted, rebuild/recalculate. To have my program use this second algorithm, you can change the "if" bit in the main loop to: actual2 = 0 lettershifts.each{ |y| g = 0xFF & (guessfreq >> y) a = 0xFF & (actualfreq >> y) if (g != a) d = (g-a).abs r1 = rand(d+1) r2 = rand(d+1) r1=r2 if r1 < r2 r1=-r1 if a