We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 094c935 commit 3de0227Copy full SHA for 3de0227
python/goodorbad.py
@@ -1,7 +1,8 @@
1
#encoding=utf-8
2
'''
3
找出一个锯齿数组里长度大于5的子数组
4
-在符合要求的子数组里的数据小于10的话乘以2
+在符合要求的子数组里的数据里找出所有偶数
5
+如果数据小于10的话乘以2,大于10的除以2
6
最后统计符合要求的数据的和
7
8
inputdata = [
@@ -12,7 +13,7 @@
12
13
]
14
15
def sum1(input):
- 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)
17
for seq in inputdata
18
if len(seq) >= 5
19
for num in seq
@@ -29,8 +30,8 @@ def filterdata(sublist):
29
30
yield data
31
def processdata(data):
32
if data < 10:
- return data * data
33
- return data
+ return data * 2
34
+ return data / 2
35
result = 0
36
for sublist in getsublist():
37
for data in filterdata(sublist):
0 commit comments