Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Removing some element of a list according to the zero of another

 elec=100
candidats= 4 
nn=list([i for i in range(len(Pref))])
ZZ=IntegerRing()
PP=([0 for i in nn])
PP[0]=ZZ.random_element(0,elec)
for k in nn:
    PP[k]=ZZ.random_element(0,elec-sum(PP[j]for j in nn[:k]))
PP[len(Pref)-1]= PP[len(Pref)-1] if (elec-sum(PP))== 0 else  PP[len(Pref)-1]+(elec-sum(PP))
import random
PP1 = random.sample(PP, len(PP)) 
show(sum(PP))
show(PP)
show(PP1)
show(Pref)
def rz(l1,l2):
    for k in range(len(l1)):
        if l1[k] == 0 : del(l2[k])
show([len(PP),len(Pref)])
show(rz(PP,Pref))

The problem here begin with def rz... I would like to delete the elements of the list Pref which are in the same place than the 0 of PP list (and after, or simultaneously the zero of the listPP. But it doesn't work. I do not find my error. I was also wondering if it could be done by embeding two List comprehension.

click to hide/show revision 2
retagged

Removing some element of a list according to the zero of another

 elec=100
candidats= 4 
nn=list([i for i in range(len(Pref))])
ZZ=IntegerRing()
PP=([0 for i in nn])
PP[0]=ZZ.random_element(0,elec)
for k in nn:
    PP[k]=ZZ.random_element(0,elec-sum(PP[j]for j in nn[:k]))
PP[len(Pref)-1]= PP[len(Pref)-1] if (elec-sum(PP))== 0 else  PP[len(Pref)-1]+(elec-sum(PP))
import random
PP1 = random.sample(PP, len(PP)) 
show(sum(PP))
show(PP)
show(PP1)
show(Pref)
def rz(l1,l2):
    for k in range(len(l1)):
        if l1[k] == 0 : del(l2[k])
show([len(PP),len(Pref)])
show(rz(PP,Pref))

The problem here begin with def rz... I would like to delete the elements of the list Pref which are in the same place than the 0 of PP list (and after, or simultaneously the zero of the listPP. But it doesn't work. I do not find my error. I was also wondering if it could be done by embeding two List comprehension.

Removing some element of a list according to the zero of another

 elec=100

candidats= 4 #nombre de candidats Pref=Arrangements(["a","b","c","d"],candidats).list() show(Pref) #len() = longueur de la liste show(LatexExpr("Nombre~de~préférences~possibles~="+latex(len(Pref))))
elec=100 candidats= 4
nn=list([i for i in range(len(Pref))]) ZZ=IntegerRing() PP=([0 for i in nn]) PP[0]=ZZ.random_element(0,elec) for k in nn: PP[k]=ZZ.random_element(0,elec-sum(PP[j]for j in nn[:k])) PP[len(Pref)-1]= PP[len(Pref)-1] if (elec-sum(PP))== 0 else PP[len(Pref)-1]+(elec-sum(PP)) import random PP1 = random.sample(PP, len(PP)) show(sum(PP)) show(PP) show(PP1) show(Pref) def rz(l1,l2): for k in range(len(l1)): if l1[k] == 0 : del(l2[k]) show([len(PP),len(Pref)]) show(rz(PP,Pref))

show(rz(PP,Pref))

The problem here begin with def rz... I would like to delete the elements of the list Pref which are in the same place than the 0 of PP list (and after, or simultaneously the zero of the listPP. But it doesn't work. I do not find my error. I was also wondering if it could be done by embeding two List comprehension.

Removing some element of a list according to the zero of another

candidats= 4 #nombre de candidats Pref=Arrangements(["a","b","c","d"],candidats).list() show(Pref) #len() = longueur de la liste show(LatexExpr("Nombre~de~préférences~possibles~="+latex(len(Pref))))
elec=100 candidats= 4 nn=list([i for i in range(len(Pref))]) ZZ=IntegerRing() PP=([0 for i in nn]) PP[0]=ZZ.random_element(0,elec) for k in nn: PP[k]=ZZ.random_element(0,elec-sum(PP[j]for j in nn[:k])) PP[len(Pref)-1]= PP[len(Pref)-1] if (elec-sum(PP))== 0 else PP[len(Pref)-1]+(elec-sum(PP)) import random PP1 = random.sample(PP, len(PP)) show(sum(PP)) show(PP) show(PP1) show(Pref) def rz(l1,l2): for k in range(len(l1)): if l1[k] == 0 : del(l2[k]) show([len(PP),len(Pref)]) show(rz(PP,Pref))

The problem here begin with def rz... I would like to delete the elements of the list Pref which are in the same place than the 0 of PP list (and after, or simultaneously the zero of the listPP. But it doesn't work. I do not find my error. I was also wondering if it could be done by embeding two List comprehension.

Removing some element of a list according to the zero of another

candidats= 4 #nombre de candidats Pref=Arrangements(["a","b","c","d"],candidats).list() show(Pref) #len() = longueur de la liste show(LatexExpr("Nombre~de~préférences~possibles~="+latex(len(Pref))))
elec=100 candidats= 4 nn=list([i for i in range(len(Pref))]) ZZ=IntegerRing() PP=([0 for i in nn]) PP[0]=ZZ.random_element(0,elec) for k in nn: PP[k]=ZZ.random_element(0,elec-sum(PP[j]for j in nn[:k])) PP[len(Pref)-1]= PP[len(Pref)-1] if (elec-sum(PP))== 0 else PP[len(Pref)-1]+(elec-sum(PP)) import random PP1 = random.sample(PP, len(PP)) show(sum(PP)) show(PP) show(PP1) show(Pref) def rz(l1,l2): for k in range(len(l1)): if l1[k] == 0 : del(l2[k]) show([len(PP),len(Pref)]) show(rz(PP,Pref))

The problem here begin with def rz... I would like to delete the elements of the list Pref which are in the same place than the 0 of PP list (and after, or simultaneously the zero of the listPP. But it doesn't work. I do not find my error. I was also wondering if it could be done by embeding two List comprehension.

Removing some element of a list according to the zero of another

candidats= 4 #nombre de candidats Pref=Arrangements(["a","b","c","d"],candidats).list() show(Pref) #len() = longueur de la liste show(LatexExpr("Nombre~de~préférences~possibles~="+latex(len(Pref))))
elec=100 candidats= 4 nn=list([i for i in range(len(Pref))]) ZZ=IntegerRing() PP=([0 for i in nn]) PP[0]=ZZ.random_element(0,elec) for k in nn: PP[k]=ZZ.random_element(0,elec-sum(PP[j]for j in nn[:k])) PP[len(Pref)-1]= PP[len(Pref)-1] if (elec-sum(PP))== 0 else PP[len(Pref)-1]+(elec-sum(PP)) import random PP1 = random.sample(PP, len(PP)) show(sum(PP)) show(PP) show(PP1) show(Pref) def rz(l1,l2): for k in range(len(l1)): if l1[k] == 0 : del(l2[k]) show([len(PP),len(Pref)]) show(rz(PP,Pref))

The problem here begin with def rz... I would like to delete the elements of the list Pref which are in the same place than the 0 of PP list (and after, or simultaneously the zero of the listPP. But it doesn't work. I do not find my error. I was also wondering if it could be done by embeding two List comprehension.

Removing some element of a list according to the zero of another

candidats= I have the following code.

candidats = 4 #nombre  # nombre de candidats
    Pref=Arrangements(["a","b","c","d"],candidats).list()
    Pref = Arrangements(["a","b","c","d"], candidats).list()
show(Pref)
    #len() # len() = longueur de la liste
 show(LatexExpr("Nombre~de~préférences~possibles~="+latex(len(Pref)))) 
elec=100 candidats= 4 nn=list([i nn = list([i for i in range(len(Pref))]) ZZ=IntegerRing() PP=([0 ZZ = IntegerRing() PP = ([0 for i in nn]) PP[0]=ZZ.random_element(0,elec) PP[0] = ZZ.random_element(0,elec) for k in nn: PP[k]=ZZ.random_element(0,elec-sum(PP[j]for PP[k] = ZZ.random_element(0,elec-sum(PP[j]for j in nn[:k])) PP[len(Pref)-1]= PP[len(Pref)-1] PP[len(Pref) - 1] = PP[len(Pref) - 1] if (elec-sum(PP))== (elec - sum(PP)) == 0 else PP[len(Pref)-1]+(elec-sum(PP)) PP[len(Pref) - 1] + (elec - sum(PP)) import random PP1 = random.sample(PP, len(PP)) show(sum(PP)) show(PP) show(PP1) show(Pref) def rz(l1,l2): rz(l1, l2): for k in range(len(l1)): if l1[k] == 0 : del(l2[k]) show([len(PP),len(Pref)]) show(rz(PP,Pref))

show([len(PP), len(Pref)]) show(rz(PP, Pref))

The problem here begin with def rz... I would like to delete the elements of the list Pref which are in the same place than the 0 of PP list (and after, or simultaneously the zero of the listlist PP. But it doesn't work. I do not find my error. I was also wondering if it could be done by embeding embedding two List comprehension.

Removing some element of a list according to the zero of another

I have the following code.

candidats = 4  # nombre de candidats
Pref = Arrangements(["a","b","c","d"], Arrangements(["a", "b", "c", "d"], candidats).list()
show(Pref)
# len() = longueur de la liste
show(LatexExpr("Nombre~de~préférences~possibles~="+latex(len(Pref))))   
elec=100
candidats= 4 
show(LatexExpr("Nombre~de~préférences~possibles~="+latex(len(Pref))))
elec = 100
candidats = 4
nn = list([i for i in range(len(Pref))])
ZZ = IntegerRing()
PP = ([0 for i in nn])
PP[0] = ZZ.random_element(0,elec)
ZZ.random_element(0, elec)
for k in nn:
    PP[k] = ZZ.random_element(0,elec-sum(PP[j]for ZZ.random_element(0, elec - sum(PP[j] for j in nn[:k]))
PP[len(Pref) - 1] = PP[len(Pref) (PP[len(Pref) - 1] if (elec - sum(PP)) == 0  else  PP[len(Pref) - 1] + (elec - sum(PP))
sum(PP)))
import random
PP1 = random.sample(PP, len(PP)) 
len(PP))
show(sum(PP))
show(PP)
show(PP1)
show(Pref)
def rz(l1, l2):
    for k in range(len(l1)):
        if l1[k] == 0 : 0:
            del(l2[k])
show([len(PP), len(Pref)])
show(rz(PP, Pref))

The problem here begin with def rz... I would like to delete the elements of the lists Pref and PP at indices where the list Pref which are in the same place than the 0 of PP list (and after, or simultaneously the zero of the list PP. has zeros. But it doesn't work. I do not find my error. I was also wondering if it could be done by embedding two List comprehension."two list comprehensions".

Removing some element of a list according to the zero of another

I have the following code.

candidats = 4  # nombre de candidats
Pref = Arrangements(["a", "b", "c", "d"], candidats).list()
show(Pref)
show(LatexExpr("Nombre~de~préférences~possibles~="+latex(len(Pref))))
elec = 100
candidats = 4
nn = list([i for i in range(len(Pref))])
ZZ = IntegerRing()
PP = ([0 for i in nn])
PP[0] = ZZ.random_element(0, elec)
for k in nn:
    PP[k] = ZZ.random_element(0, elec - sum(PP[j] for j in nn[:k]))
PP[len(Pref) - 1] = (PP[len(Pref) - 1] if (elec - sum(PP)) == 0 
                     else  PP[len(Pref) - 1] + (elec - sum(PP)))
import random
PP1 = random.sample(PP, len(PP))
show(sum(PP))
show(PP)
show(PP1)
show(Pref)
def rz(l1, l2):
    for k in range(len(l1)):
        if l1[k] == 0:
            del(l2[k])
show([len(PP), len(Pref)])
show(rz(PP, Pref))

The problem here begin begins with def rz... I would like to delete the elements of the lists Pref and PP at indices where the list PP has zeros. But it doesn't work. I do not find my error. I was also wondering if it could be done by embedding "two list comprehensions".