You have two arrays in this kata, every array contain only unique elements. Your task is to calculate number of elements in first array which also are in second array.

Difficulty: introductory

Starter code:

def match_arrays(v, r):
	

Solutions:
def match_arrays(v, r):
    return sum(x in r for x in v)

# DON'T remove
verbose = False # set to True to diplay arrays being tested in the random tests

def match_arrays(v, r):
    return sum(1 for x in v if x in r)

# DON'T remove
verbose = False # set to True to diplay arrays being tested in the random tests

def match_arrays(v, r):
    # Good Luck!

    cnt = 0
    for i in v:
        if i in r:
            cnt += 1
    return cnt

# DON'T remove
verbose = False # set to True to diplay arrays being tested in the random tests



import collections
verbose = False

def setify(s): return { elt if isinstance(elt, collections.Hashable) else tuple(elt) for elt in s }

def match_arrays(v, r): return len(setify(v) & setify(r))

def match_arrays(v, r):
    tool = lambda x: {tuple(y) if type(y) == list else y for y in x}
    return len(tool(v) & tool(r))

# DON'T remove
verbose = False # set to True to diplay arrays being tested in the random tests

def match_arrays(v, r):
    return sum(1 for e in v if e in r)
verbose = False

verbose,match_arrays=0,lambda a,b:sum(1for e in a if e in b)

def match_arrays(v, r):
    return sum(1 for i in r if i in v)

# DON'T remove
verbose = False # set to True to diplay arrays being tested in the random tests

def match_arrays(xs, ys):
    return sum(1 for y in ys if y in xs)

verbose = False

match_arrays = lambda k, l: len([e for e in k if e in l])

# DON'T remove
verbose = False # set to True to diplay arrays being tested in the random tests