July 3rd, 2012, 03:01 PM
General Programming Question - Self Enumerating Pangrams
I'm trying to create a self enumerating pangram, here is an example of one:
This first pangram has five a's, one b, one c, two d's, twenty-nine e's, six f's, four g's, eight h's, twelve i's, one j, one k, three l's, two m's, nineteen n's, twelve o's, two p's, one q, eight r's, twenty-six s's, twenty t's, three u's, five v's, nine w's, three x's, four y's, and one z.
I've tried two different approaches.
The first approach was to generate a sentence with random numbers. I would compare the randomly generated numbers to the actual number of occurrences of each letter, update the sentence and repeat. This method quickly finds potential pangrams with an error of between 6 - 8 numbers, but there doesn't seem to be much more progress after that.
The second approach was to create a "gene pool" of random potential pangrams. The fittest pangrams can reproduce (by simulating crossover), and there are random mutations, and new individuals are created and destroyed on a random basis. This method takes longer, but has produced potential pangrams with an error of between 1 - 4 numbers.
Are there any other approaches which I haven't thought of? Which of the above two approaches has the most potential of working? I'm nearly going insane trying to figure this out!
Any help will be really appreciated!
Click Here to Expand Forum to Full Width
This a Codeguru.com survey!