teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

2

clampにmax使用。

2018/04/12 08:50

投稿

fuzzball
fuzzball

スコア16733

answer CHANGED
@@ -1,7 +1,7 @@
1
1
  とりあえず殴り書き。
2
2
 
3
3
  ```python
4
- score = sum(filter(lambda s: s > 0, [2 - len(x[0]) + len(list(filter(lambda c: c[0] == c[1], zip(x[0], x[1])))) for x in filter(lambda word: len(word[0]) == len(word[1]), data)]))
4
+ score = sum([max(0, 2 - len(x[0]) + len(list(filter(lambda c: c[0] == c[1], zip(x[0], x[1]))))) for x in filter(lambda word: len(word[0]) == len(word[1]), data)])
5
5
  ```
6
6
 
7
7
  ここからが本番w

1

変数名同じで紛らわしい。

2018/04/12 08:50

投稿

fuzzball
fuzzball

スコア16733

answer CHANGED
@@ -1,7 +1,7 @@
1
1
  とりあえず殴り書き。
2
2
 
3
3
  ```python
4
- score = sum(filter(lambda score: score > 0, [2 - len(x[0]) + len(list(filter(lambda c: c[0] == c[1], zip(x[0], x[1])))) for x in filter(lambda word: len(word[0]) == len(word[1]), data)]))
4
+ score = sum(filter(lambda s: s > 0, [2 - len(x[0]) + len(list(filter(lambda c: c[0] == c[1], zip(x[0], x[1])))) for x in filter(lambda word: len(word[0]) == len(word[1]), data)]))
5
5
  ```
6
6
 
7
7
  ここからが本番w