|
|
|
|
|
by jonnycomputer
307 days ago
|
|
len(list(filter(lambda line: all([abs(x) >= 1 and abs(x) <= 3 for x in line]) and (all([x > 0 for x in line]) or all([x < 0 for x in line])), diffs)))
Well, point taken about the ordering, but there are many more legible ways to have written that code. Not everything has to be a one liner.even: def f(diffs):
cond = lambda line: all([1 <= abs(x) <= 3 for x in line]) and (
all([x > 0 for x in line]) or all([x < 0 for x in line])
)
items = filter(cond, diffs)
return len(list(items))
|
|