a-robots-conundrum/robotgame/misc.py

10 lines
210 B
Python
Raw Normal View History

from __future__ import print_function
import random
def pick_random_elements(xs, n):
for i in range(min(n, len(xs))):
i1 = random.randrange(i, len(xs))
yield xs[i1]
xs[i1] = xs[i]