Generate a random permutation of the elements of a list.
Once again python provides us with a solution, so we don't have to code at all.
random.shuffle(lst)
Since this works in place you may want to copy your list first before operating on.
Keep your shirt on, these do get interesting after a while. But it is nice to see how many "problems" are already solved for us.
Saturday, November 8, 2008
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment