diff options
Diffstat (limited to 'challenge-331/ysth/python/ch-1.py')
| -rw-r--r-- | challenge-331/ysth/python/ch-1.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/challenge-331/ysth/python/ch-1.py b/challenge-331/ysth/python/ch-1.py new file mode 100644 index 0000000000..815e1f4cfe --- /dev/null +++ b/challenge-331/ysth/python/ch-1.py @@ -0,0 +1,15 @@ +import sys +import grapheme +import regex + +def last_word_length(string: str) -> str: + return grapheme.length(regex.sub(r'^.*[^\pL\pN\pM\p{pC}](?=[\pL\pN\pM\p{pC}])|(?<=[\pL\pN\pM\p{pC}])[^\pL\pN\pM\p{pC}].*', '', string)) + +def main() -> None: + inputs: list[str] = sys.argv[1:] + + for string in inputs: + print(f'{string:<30} -> {last_word_length(string)}') + +if __name__ == '__main__': + main() |
