use itertools: permutations use math.cf: fac use sys: exit function error(s) print("Error: generators test ", s, " failed.") exit(1) end begin for n in 0..6 a = cf.permutations(list(0..n-1)) b = permutations(list(0..n-1)).list() if a!=b or len(a)!=fac(n) error("#1") end end end