Probability Algorithm
月忧茗
yueyoum at gmail.com
Sat Aug 25 23:47:57 EDT 2012
Sorry, missing some conditions
*already_picked_list* is get from db.
> Why keep a counter? Rather than an iterated loop
so , if use a iterated loop:
for i in range(43):
item = choice( ALIST )
ALIST.remove( item )
if item in already_picked_list:
continue
slot.append( item )
For example, if we picked item from ALIST 43 times, but all picked items
are in already_picked_list
What's the slot? It's a empty list, not contains item from ALIST.
*This is wrong*
> Do you really want to remove an item from the source list?
*Yes*, i*tems in slot must be unique*
( This is also a condition, which I have missing... )
> and if you don't want duplicates from within a source list, you should
remove them when building the source list
*
As I mentioned , The source list are all unique elements*
Your last code.
if B ,C ,D are all empty, result's elements are all from A, A's
probability is 100% ?
I Know , this problem should treated as two situation:
If the four list has not enough elements, There are no way to ensure the
probability requirements.
If they has enough elements, Your solution is a good way.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20120826/7bfbab47/attachment.html>
More information about the Python-list
mailing list