• + 0 comments
    def gemstones(arr):
        freq = {}
        
        gems = 0
        for rock in arr:
            for i, m in enumerate(rock):
                if i == rock.index(m):
                    freq[m] = freq.get(m, 0) + 1
                    
                    if freq[m] == len(arr):
                        gems += 1
                    
        return gems