MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / sock_merchant

Function sock_merchant

maths/sock_merchant.py:4–11  ·  view source on GitHub ↗

>>> sock_merchant([10, 20, 20, 10, 10, 30, 50, 10, 20]) 3 >>> sock_merchant([1, 1, 3, 3]) 2

(colors: list[int])

Source from the content-addressed store, hash-verified

2
3
4def sock_merchant(colors: list[int]) -> int:
5 """
6 >>> sock_merchant([10, 20, 20, 10, 10, 30, 50, 10, 20])
7 3
8 >>> sock_merchant([1, 1, 3, 3])
9 2
10 """
11 return sum(socks_by_color // 2 for socks_by_color in Counter(colors).values())
12
13
14if __name__ == "__main__":

Callers 1

sock_merchant.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected