Post Reply 
Little explorations with HP calculators (no Prime)
12-28-2018, 03:41 PM (This post was last modified: 12-28-2018 05:56 PM by Albert Chan.)
Post: #329
RE: Little explorations with HP calculators (no Prime)
Hi DavidM

Yes, using random.shuffle may be overkill.
With only 2 kinds of balls, random.sample may be faster.

Code:
def main(n):
    idx = range(140)
    result = [0] * 72
    for _ in range(n):
        thelist = [1] * 140  # all blue balls
        for i in random.sample(idx, 40): thelist[i] = 0
        result[match_count(thelist)] += 1
    for x in zip(idx, result): print("%d\t%d" % x)
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Little explorations with HP calculators (no Prime) - Albert Chan - 12-28-2018 03:41 PM



User(s) browsing this thread: 2 Guest(s)