repl.it
@haideralsh/

MatchingSocks

Python

No description

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
pairs = 0

def findSockPairs(arr):
  global pairs
  sock = arr.pop(0)

  if sock in arr:
    pairs += 1
    arr.remove(sock)

  return pairs if len(arr) < 2 else findSockPairs(arr) 
		
  

print(findSockPairs([10, 20, 20, 10, 10, 30, 50, 10, 20]))