Jun 25, 2012, 11:42 AM
Post #3 of 5
Heres what the code does.
Re: [FishMonger] string mutation script behaving erraticaly
[In reply to]
The string to be mutated has already been provided inside the code(line 30).
The string is made of 20 alphabets(line 5-24).
%nuc (line 4)is a 24x24 matrix made in hash.
The program generates a random number between 0 and 1 for length times the input string (length $string).
It then checks this value in the corresponding hash %nuc. In our case since the $string has been hardcoded consisting of only "A", therefore each time a random number is generated the program goes to line 17 only.
It then traverses the line 17 horizontally until a number greater than the random number is encountered. The value of the counter is noted when a number greater than the random number is encountered.
For example in case our our $string which has only "A", it will mutate to another alphabet only if the random number is greater than .9799 otherwise it will remain as "A" only.
The biggest problem with this code is that hashes dont get printed in the same order you store them,this shuffling leads to erratic results.
I tried rearranging the rows of hash %nuc but it still didnt help.
Another error is that Im getting an alphabet more in the output string than the hardcoded string.