Skip to content

Commit 3de0227

Browse files
author
huhao
committed
修改了一下规则
1 parent 094c935 commit 3de0227

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

python/goodorbad.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#encoding=utf-8
22
'''
33
找出一个锯齿数组里长度大于5的子数组
4-
在符合要求的子数组里的数据小于10的话乘以2
4+
在符合要求的子数组里的数据里找出所有偶数
5+
如果数据小于10的话乘以2,大于10的除以2
56
最后统计符合要求的数据的和
67
'''
78
inputdata = [
@@ -12,7 +13,7 @@
1213
]
1314

1415
def sum1(input):
15-
return sum((lambda x: (x < 10 and [x*x] or [x])[0])(num)
16+
return sum((lambda x: (x < 10 and [x*2] or [x/2])[0])(num)
1617
for seq in inputdata
1718
if len(seq) >= 5
1819
for num in seq
@@ -29,8 +30,8 @@ def filterdata(sublist):
2930
yield data
3031
def processdata(data):
3132
if data < 10:
32-
return data * data
33-
return data
33+
return data * 2
34+
return data / 2
3435
result = 0
3536
for sublist in getsublist():
3637
for data in filterdata(sublist):

0 commit comments

Comments
 (0)