Skip to content

Commit 2fd9807

Browse files
committed
Add another method for q1 file
Signed-off-by: Jackey <smjjackey@sina.com>
1 parent cdbb74f commit 2fd9807

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

Huawei/2019/q1.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ def fun():
99
input_num_list=list(map(int,input().strip().split(',')))
1010
out=set()
1111
for num in input_num_list:
12-
if(num !=1 and all(num%i !=0 for i in range(2,int(math.sqrt(num))+1))):
13-
##### Return True if all elements of the iterable are true (or if the iterable is empty)
14-
##### So, if the input_num_list contain {1}, the result is wrong
15-
out.add(num)
16-
# flag= True
17-
# for i in range(2,int(math.sqrt(num))+1):
18-
# if (num%i):
19-
# flag= False
20-
# break
21-
# if(flag and num!=1): out.add(num)
12+
# if(num !=1 and all(num%i !=0 for i in range(2,int(math.sqrt(num))+1))):
13+
# ##### Return True if all elements of the iterable are true (or if the iterable is empty)
14+
# ##### So, if the input_num_list contain {1}, the result is wrong
15+
# out.add(num)
16+
flag= True
17+
for i in range(2,int(math.sqrt(num))+1):
18+
if (num%i==0):
19+
flag= False
20+
break
21+
if(flag and num!=1): out.add(num)
2222

2323
out=sorted(out)
2424
if(len(out)==0):

0 commit comments

Comments
 (0)