@@ -0,0 +1,1180 @@
+#!/usr/bin/env python%0Aimport sys%0Aimport random%0Afrom argparse import ArgumentParser%0A%0Adef print_loop(names):%0A  %22%22%22Print a loop of name drawings.%22%22%22%0A  if len(names) == 0:%0A    return%0A  for n1, n2 in zip(names, names%5B1:%5D):%0A    print n1, %22--%3E%22, n2%0A  print names%5B-1%5D, %22--%3E%22, names%5B0%5D%0A%0Adef split_loop(names, min_size):%0A  %22%22%22Return a 2-tuple of a list of names split into two loops.%0A%0A  The second item is None when names is the minimum size or can't be divided in%0A  such a way that it obeys the minimum size.%0A  %22%22%22%0A  lo = min_size%0A  hi = len(names) - min_size%0A  if lo %3E hi:%0A    return names, None%0A  pivot = random.randint(0, len(names))%0A  if pivot %3C lo or pivot %3E= hi:%0A    return names, None%0A  return names%5B:pivot%5D, names%5Bpivot:%5D%0A%0Adef make_loops(names, min_size):%0A  loops = %5B%5D%0A  l1, l2 = split_loop(names, min_size)%0A  loops.append(l1)%0A  while not l2 is None:%0A    l1, l2 = split_loop(l2, min_size)%0A    loops.append(l1)%0A  return loops%0A%0Adef main():%0A  names = sys.argv%5B1:%5D%0A  if len(names) %3C= 1:%0A    print %22usage:%22, sys.argv%5B0%5D, %22name name...%22%0A    sys.exit(1)%0A  random.shuffle(names)%0A  loops = make_loops(names, 2)%0A  for loop in loops:%0A    print_loop(loop)%0A%0Aif __name__ == %22__main__%22:%0A  main()%0A

add namedraw script