aboutsummaryrefslogtreecommitdiff
path: root/challenge-331/ysth/python/ch-1.py
diff options
context:
space:
mode:
authorYitzchak Scott-Thoennes <sthoenna@gmail.com>2025-07-23 17:15:21 -0400
committerYitzchak Scott-Thoennes <sthoenna@gmail.com>2025-07-23 17:15:21 -0400
commit99c4e905c974e2e92e238c10cbfc771e89b6cc90 (patch)
tree7b9b94dc1bb5ba419d0a9f383e60b785b2e99f20 /challenge-331/ysth/python/ch-1.py
parentfa6ac79755faeac2482b731861634bf63036ff3a (diff)
downloadperlweeklychallenge-club-99c4e905c974e2e92e238c10cbfc771e89b6cc90.tar.gz
perlweeklychallenge-club-99c4e905c974e2e92e238c10cbfc771e89b6cc90.tar.bz2
perlweeklychallenge-club-99c4e905c974e2e92e238c10cbfc771e89b6cc90.zip
challenge 330 python, perl, and go solutions
Diffstat (limited to 'challenge-331/ysth/python/ch-1.py')
-rw-r--r--challenge-331/ysth/python/ch-1.py15
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()