def factorial(n): if n == 0: return 1 else: return n * factorial(n-1) def permutations(r, n): return factorial(n)/factorial(n-r) def combinations(k, n): return factorial(n)/(factorial(k)*factorial(n-k)) def main(): GRID_SIZE = 20 # v1 = (0,1) # v2 = (1,0) # all possible combinations of a set containing: # GRID_SIZE of v1 and GRID_SIZE of v2 # doesn't matter what the vectors themselves are tho. TYPES_OF_VECTORS = 2 NUM_VECTORS = TYPES_OF_VECTORS * GRID_SIZE print permutations(NUM_VECTORS, NUM_VECTORS)/factorial(GRID_SIZE)**TYPES_OF_VECTORS if __name__ == '__main__': main()