I have an exam in two days and we an example from teacher, but I'm new to Python, and I kind of blocked at this
This is the problem statement:
Write an algorithm which will get the parameters two array of integers x[1..n] if y[1..n] which returns number of common elements in the two arrays.
def apartine(a,e):
e=1
gasit=False
n=len(a)
i=0
while i<=n and gasit==False:
if a[i]==e:
gasit=True
else:
i=i+1
return gasit
def intersectie(a,b,c):
e=0
k=len(c)
m=len(b)
for i in range(1,m):
if apartine(a,e)==True:
k=k+1
c.append(b[i])
print(c)
return c
a=[1,3,5,7]
b=[2,3,4,6]
c=[]
print intersectie(a,b,c)
I'm stuck with this.
I need some help to find out what I'm doing wrong.