|Perl: the Markov chain saw|
More while issuesby Dandello (Scribe)
|on Mar 03, 2011 at 20:59 UTC||Need Help??|
Dandello has asked for the
wisdom of the Perl Monks concerning the following question:
As this stands, it works - in a string of 'a's and 'y's, it counts the 'y's and if there aren't enough of them, converts 'a's to 'y's.
Unfortunately, I have to add a second 'layer' as instead of a string with just 'a's and 'y's, I now have a string with 'a's, 'y's, and 'c's. What I need to do is is start converting 'c's to 'y's after all the 'a's have been converted.
But everything I've tried either converts 'c's to 'y's along with the 'a's or it doesn't convert the 'c's at all.
This version doesn't remove any of the 'c's. If I remove the 'last' from the first 'while' loop it removes the 'c's without going through all the 'a's first but it hangs (goes into an unresolvable loop) if all the 'a's are gone before reaching $cndiea == $incrsdel.
I'm sure fresh eyes see what I'm missing here as I know there has to be a simple solution. And yes, which 'a's and 'c's being converted need to be randomly selected
Thanks in advance.