diff options
| author | Paulo Custodio <pauloscustodio@gmail.com> | 2023-05-10 17:09:33 +0100 |
|---|---|---|
| committer | Paulo Custodio <pauloscustodio@gmail.com> | 2023-05-10 17:09:33 +0100 |
| commit | bb52405967e3387c63e9fffd0a2bd82678882f40 (patch) | |
| tree | 88eba058d26136d2a86dcc77982f42cdc245bdf6 /challenge-216/lubos-kolouch/python/ch-1.py | |
| parent | 2e943784a5c321b375ba33ab415a70dcf030b61c (diff) | |
| parent | 722527ed475e56e5717e60f8d3b52d9bbcef492c (diff) | |
| download | perlweeklychallenge-club-bb52405967e3387c63e9fffd0a2bd82678882f40.tar.gz perlweeklychallenge-club-bb52405967e3387c63e9fffd0a2bd82678882f40.tar.bz2 perlweeklychallenge-club-bb52405967e3387c63e9fffd0a2bd82678882f40.zip | |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'challenge-216/lubos-kolouch/python/ch-1.py')
| -rw-r--r-- | challenge-216/lubos-kolouch/python/ch-1.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/challenge-216/lubos-kolouch/python/ch-1.py b/challenge-216/lubos-kolouch/python/ch-1.py new file mode 100644 index 0000000000..c52a4df31f --- /dev/null +++ b/challenge-216/lubos-kolouch/python/ch-1.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +from typing import List + + +def matching_words(words: List[str], reg: str) -> List[str]: + reg = reg.upper() + letters = set(letter for letter in reg if letter.isalpha()) + matches = [] + for word in words: + upper_word = word.upper() + matched = all(letter in upper_word for letter in letters) + if matched: + matches.append(word) + return matches + + +words = ['job', 'james', 'bjorg'] +reg = '007 JB' +matches_list = matching_words(words, reg) +print("(", ", ".join(f"'{match}'" for match in matches_list), ")") |
