diff options
Diffstat (limited to 'challenge-256/lubos-kolouch/python/ch-1.py')
| -rw-r--r-- | challenge-256/lubos-kolouch/python/ch-1.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/challenge-256/lubos-kolouch/python/ch-1.py b/challenge-256/lubos-kolouch/python/ch-1.py new file mode 100644 index 0000000000..2ab63d32bc --- /dev/null +++ b/challenge-256/lubos-kolouch/python/ch-1.py @@ -0,0 +1,13 @@ +from typing import List + + +def max_pairs(words: list[str]) -> int: + word_set = set(words) + count = sum(1 for word in words if word[::-1] in word_set) + return count // 2 + + +# Tests +assert max_pairs(["ab", "de", "ed", "bc"]) == 1 +assert max_pairs(["aa", "ba", "cd", "ed"]) == 0 +assert max_pairs(["uv", "qp", "st", "vu", "mn", "pq"]) == 2 |
