Sock Pairs

After laundry, socks need to be matched into pairs of the same color. The function sock_merchant receives the number of socks n and a list of colors ar, where equal numbers mean the same color. Count how many complete pairs can be made. A leftover sock without a pair does not count.

Примеры

Ввод
9, [10, 20, 20, 10, 10, 30, 50, 10, 20]
Вывод
3
Ввод
1, [1]
Вывод
0
Ввод
4, [1, 1, 1, 1]
Вывод
2

Нужно реализовать

def sock_merchant(n: int, ar: list[int]) -> int:

Теги

arraydicthashmap
PostgreSQLv16

Εδώ θα εμφανιστεί το αποτέλεσμα εκτέλεσης του κώδικα

Visible tests
1
Input
9, [10,20,20,10,10,30,50,10,20]
Expected3
2
Input
1, [1]
Expected0
3
Input
4, [1,1,1,1]
Expected2
4
Input
6, [1,1,2,2,2,2]
Expected3
5
Input
0, []
Expected0
6
Input
1000, [10,20,20,10,10,30,50,10,20,10]
Expected3
Focus radio
Paused · SomaFM · Fluid