Given two arrays, the purpose of this Kata is to check if these two arrays are the same. "The same" in this Kata means the two arrays contains arrays of 2 numbers which are same and not necessarily sorted the same way. i.e. [[2,5], [3,6]] is same as [[5,2], [3,6]] or [[6,3], [5,2]] or [[6,3], [2,5]] etc

[[2,5], [3,6]] is NOT the same as [[2,3], [5,6]]
Two empty arrays [] are the same
[[2,5], [5,2]] is the same as [[2,5], [2,5]] but NOT the same as [[2,5]]
[[2,5], [3,5], [6,2]] is the same as [[2,6], [5,3], [2,5]] or [[3,5], [6,2], [5,2]], etc
An array can be empty or contain a minimun of one array of 2 integers and up to 100 array of 2 integers 


Note:
1. [[]] is not applicable because if the array of array are to contain anything, there have to be two numbers.
2. 100 randomly generated tests that can contains either "same" or "not same" arrays.

Source: codewars | Difficulty: EASY
Tags: Fundamentals

Data structures

Starter code: def same(arr_a, arr_b):
	

Solutions:
def same(arr_a, arr_b):
	return sorted(map(sorted, arr_a)) == sorted(map(sorted, arr_b))


def same(arr_a, arr_b):
	return sorted((sorted(a) for a in arr_a)) == sorted((sorted(b) for b in arr_b))


same = lambda a, b: sorted(sum(a, [])) == sorted(sum(b, []))


def same(arr_a, arr_b):
	return sorted((sorted(x) for x in arr_a)) == sorted((sorted(x) for x in arr_b))


same = lambda a1, a2: sorted(map(sorted, a1)) == sorted(map(sorted, a2))


def same(a, b):
	return comp(a) == comp(b)

def comp(arr):
	return sorted(map(sorted, arr))


from collections import Counter

def same(arr_a, arr_b):
	return Counter((frozenset(x) for x in arr_a)) == Counter((frozenset(x) for x in arr_b))


def same(arr_a, arr_b):
	if len(arr_b) != len(arr_a):
		return False
	temp1 = temp2 = []
	for (i, j) in zip(arr_a, arr_b):
		temp1.append(sorted(i))
		temp2.append(sorted(j))
	while temp1 and temp2:
		try:
			temp2.remove(temp1.pop())
		except:
			return False
	return True


def same(arr_a, arr_b):
	return sorted((sorted(arr) for arr in arr_a)) == sorted((sorted(arr) for arr in arr_b))