Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Check randomly generated numbers have not been used before

by InfiniteSilence (Curate)
on Jun 20, 2014 at 13:44 UTC ( [id://1090636]=note: print w/replies, xml ) Need Help??


in reply to Check randomly generated numbers have not been used before

perl -e 'for (0..100){$randhash{int (rand() * 100)} += 1}; print join +qq|\n|,sort {$a<=>$b} keys %randhash;'

Check elements that have > 1 in the value and recompute until you find a key that does fails exists.

Celebrate Intellectual Diversity

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1090636]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (2)
As of 2024-04-24 23:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found