File tree Expand file tree Collapse file tree 4 files changed +72
-0
lines changed
programmers/python/해시/폰켓몬 Expand file tree Collapse file tree 4 files changed +72
-0
lines changed Original file line number Diff line number Diff line change 1+ from typing import List
2+
3+
4+ def solution (nums : List [int ]) -> int :
5+ return min (len (nums ) // 2 , len (set (nums )))
Original file line number Diff line number Diff line change 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+ ]
Original file line number Diff line number Diff line change 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 ()
You can’t perform that action at this time.
0 commit comments