A problem in outputting a list
I want to output a list depending on two parameters m and t, My attempt is
def L(m,t):
List=[]
dim=0
for k in srange(m+1):
for j in srange(0,3):
for i in srange(1,m-k+1):
List.extend([(k,i,j)])
dim=dim+1
for j in srange(floor(t)+1):
for k in srange(floor(m/t)*j,m+1):
for i in srange(0,1):
List.extend([(k,i,j)]) # Indentation fixed here
dim=dim+1
return List
When we call len(L(3,1)) i.e.m=3 and t=1; sage outputs 22, this is not logical for me because I implemented again without using the function the length of the list (also for m=3 and t=1) becomes 23 as the following code
dim=0
List=[]
for k in srange(4):
for j in srange(0,3):
for i in srange(1,4-k):
List.extend([(k,i,j)])
dim=dim+1
for j in srange(2):
for k in srange(3*j,4):
for i in srange(0,1):
List.extend([(k,i,j)])
dim=dim+1
So where is the problem to solve it ?