Skip to content

Commit 32a753f

Browse files
committed
solved(python): programmers
- 해시 / 폰켓몬
1 parent 6775b13 commit 32a753f

File tree

4 files changed

+72
-0
lines changed

4 files changed

+72
-0
lines changed

programmers/python/해시/폰켓몬/__init__.py

Whitespace-only changes.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from typing import List
2+
3+
4+
def solution(nums: List[int]) -> int:
5+
return min(len(nums) // 2, len(set(nums)))
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
[
2+
{
3+
"params": [
4+
[
5+
3,
6+
1,
7+
2,
8+
3
9+
]
10+
],
11+
"expected": 2
12+
},
13+
{
14+
"params": [
15+
[
16+
3,
17+
3,
18+
3,
19+
2,
20+
2,
21+
4
22+
]
23+
],
24+
"expected": 3
25+
},
26+
{
27+
"params": [
28+
[
29+
3,
30+
3,
31+
3,
32+
2,
33+
2,
34+
2
35+
]
36+
],
37+
"expected": 2
38+
}
39+
]
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import json
2+
import os
3+
import unittest
4+
5+
from parameterized import parameterized
6+
7+
from .main import solution
8+
9+
10+
def load_sample(filename: str):
11+
path = os.path.join(os.path.dirname(os.path.abspath(__file__)), filename)
12+
13+
with open(path, "r") as file:
14+
return [(case["params"], case["expected"]) for case in json.load(file)]
15+
16+
17+
class TestCase(unittest.TestCase):
18+
@parameterized.expand(load_sample("sample.json"))
19+
def test_case(self, params: list, expected: any):
20+
# When
21+
result = solution(*params)
22+
23+
# Then
24+
self.assertEqual(expected, result)
25+
26+
27+
if __name__ == "__main__":
28+
unittest.main()

0 commit comments

Comments
 (0)