I am trying the following code
def getCount(mySet):
l = len(mySet)
hsh={}
lSet=[]
rSet=[]
for i in range(0,l-1):
for j in range(i+1,l):
if ((mySet[i]+mySet[j])%k==0):
lSet = mySet
rSet = mySet
print "i, j ", i,j
del lSet[i]
del rSet[j]
if len(lSet)==0 or len(rSet==0):
return 0
left = getCount(lSet)
right = getCount(rSet)
if left==right:
return left
return len(lSet)
n,k = [int(i) for i in raw_input().split(" ")]
mySet=[]
for x in raw_input().split(" "):
mySet.append(int(x))
print getCount(mySet)
where an example input is
5 5
2 4 1 6 8
however, I am getting the error
del rSet[j]
IndexError: list assignment index out of range
I don't understand why this is. How is j
out of range?. In the line above, I printed out
i, j 0 4