feat: Initial commit
This commit is contained in:
27
Laboratorio8/esercizio1.py
Normal file
27
Laboratorio8/esercizio1.py
Normal file
@@ -0,0 +1,27 @@
|
||||
def removeDup(a):
|
||||
i=0
|
||||
while i < len(a) - 1:
|
||||
if a[i] == a[i + 1]:
|
||||
a.pop(i)
|
||||
else:
|
||||
i += 1
|
||||
|
||||
|
||||
def sameElements(a, b):
|
||||
cpa = sorted(a)
|
||||
cpb = sorted(b)
|
||||
|
||||
if len(cpa) == len(cpb):
|
||||
i=0
|
||||
while i < len(cpa):
|
||||
if cpa[i] != cpb[i]:
|
||||
break
|
||||
|
||||
i += 1
|
||||
|
||||
if i == len(cpa):
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
print(sameElements([1,5,2,4,8], [1,4,2,8,5]))
|
||||
Reference in New Issue
Block a user