Next fun problem based on the generator (not too hard - but interesting to 
see):

For a specified max entries of 10 - figure out the the percentage chance of a 
match.

[EMAIL PROTECTED]:~/yar/server/lib$ perl -e 'for(1..100000){print 
join(" ",map{int(rand(200)-100)}1..1+rand(10-1)),"\n"}' | 
perl -ape '$_="match\n";$i=0;while(++$i<@F){last if(abs$F[$i]-$F[$i-1]||
@F)>[EMAIL PROTECTED] and $_="not a $_"}'|grep -v not|wc -l
11256

So roughly 11%.

How about max entries of 100

[EMAIL PROTECTED]:~/yar/server/lib$ perl -e 'for(1..100000){print 
join(" ",map{int(rand(200)-100)}1..1+rand(100-1)),"\n"}' | 
perl -ape '$_="match\n";$i=0;while(++$i<@F){last if(abs$F[$i]-$F[$i-1]||
@F)>[EMAIL PROTECTED] and $_="not a $_"}'|grep -v not|wc -l
1008

So roughly 1.1%.

So I would assume that for your max entries of 10000 - your chances of a 
matching entry would be .011%.

Paul

/*
PLUG: http://plug.org, #utah on irc.freenode.net
Unsubscribe: http://plug.org/mailman/options/plug
Don't fear the penguin.
*/

Reply via email to