Python is Love (Very easy and concise)


#1
def solve(self, A, B):
        
        A = set(A.split("_"))
        ans = []
        for i,v in enumerate(B):
            temp = 0
            for w in v.split("_"):
                if w in A:
                    temp+=1
            
            ans.append((temp,i))
        
        return [v for i,v in sorted(ans,key = lambda x:(-x[0],x[1]))]