View difference between Paste ID: cUk08bbg and m9ns8ZgJ
SHOW: | | - or go back to the newest paste.
1
from __future__ import division
2
import itertools as it
3
import numpy as np
4
l = input('How many lattices?_')
5
m = input('How many markers?_')
6
sums = 0
7
sumcount = 0
8
pos = 1
9
neg = -1
10-
L = list(it.product([-1,1], repeat =l))
10+
L = it.product([-1,1], repeat =l)
11-
M = range(0,l) # makes a list from 0 to l-1, giving l entries, starting with 0 just like the indices of the lattices.
11+
M = range(0,l)
12-
Markers = list(it.combinations(M, m))
12+
markers = it.combinations(M, m)
13-
i = 0
13+
14-
j = 0
14+
for ring in L:
15
    for marker in markers:
16-
while i < len(L):
16+
        while k < 2*len(ring):
17-
    Ring = L[i]
17+
            ring = list(np.roll(ring,1))
18-
    while j < len(Markers):
18+
            for x in marker:
19-
        while k < 2*len(Ring):
19+
                t = ring.pop(x)
20-
            Marker = Markers[j]
20+
21-
            Ring = list(np.roll(Ring,1))
21+
                    ring.insert(x,pos)
22-
            for x in Marker:
22+
23-
                t = Ring.pop(x)
23+
                    ring.insert(x,neg)
24
                else:
25-
                    Ring.insert(x,pos)
25+
26
                sums = sums + abs(sum(ring))
27-
                    Ring.insert(x,neg)
27+
                sumcount = sumcount + 1
28
                k = k + 1
29
        k = 0
30-
            sums = sums + abs(sum(Ring))
30+
31-
            sumcount = sumcount + 1
31+
32-
            k = k + 1
32+