aboutsummaryrefslogtreecommitdiff
path: root/challenge-330/ysth/python
diff options
context:
space:
mode:
authorYitzchak Scott-Thoennes <sthoenna@gmail.com>2025-07-18 15:56:53 -0400
committerYitzchak Scott-Thoennes <sthoenna@gmail.com>2025-07-20 18:40:52 -0400
commitc59c514f141986ca1c98e32d44f6ad37bf15b28c (patch)
tree718b574bd8f3fbe0b4a1794468504fcf7e31cfa2 /challenge-330/ysth/python
parent9e8884f1448e66646c1e56eb7dfc94339da4acbb (diff)
downloadperlweeklychallenge-club-c59c514f141986ca1c98e32d44f6ad37bf15b28c.tar.gz
perlweeklychallenge-club-c59c514f141986ca1c98e32d44f6ad37bf15b28c.tar.bz2
perlweeklychallenge-club-c59c514f141986ca1c98e32d44f6ad37bf15b28c.zip
challenge 330 python, perl, and go solutions
Diffstat (limited to 'challenge-330/ysth/python')
-rw-r--r--challenge-330/ysth/python/ch-1.py14
-rw-r--r--challenge-330/ysth/python/ch-2.py17
2 files changed, 31 insertions, 0 deletions
diff --git a/challenge-330/ysth/python/ch-1.py b/challenge-330/ysth/python/ch-1.py
new file mode 100644
index 0000000000..13f8df9546
--- /dev/null
+++ b/challenge-330/ysth/python/ch-1.py
@@ -0,0 +1,14 @@
+import sys
+import regex
+
+def clear_digits(string: str) -> str:
+ return regex.sub(r'[0-9]*(?<pair>[a-z](?&pair)?[0-9])*', '', string)
+
+def main() -> None:
+ inputs: list[str] = sys.argv[1:]
+
+ for string in inputs:
+ print(f'{string:<30} -> {clear_digits(string)}')
+
+if __name__ == '__main__':
+ main()
diff --git a/challenge-330/ysth/python/ch-2.py b/challenge-330/ysth/python/ch-2.py
new file mode 100644
index 0000000000..0b3f0ae6fa
--- /dev/null
+++ b/challenge-330/ysth/python/ch-2.py
@@ -0,0 +1,17 @@
+import sys
+import grapheme
+
+def grapheme_length_more_than_2(string: str) -> bool:
+ return grapheme.length(string, 3) > 2
+
+def title_capital(string: str) -> str:
+ return ' '.join( word.capitalize() if grapheme_length_more_than_2(word) else word.lower() for word in string.split(' ') )
+
+def main() -> None:
+ inputs: list[str] = sys.argv[1:]
+
+ for string in inputs:
+ print(f'{string:<30} -> {title_capital(string)}')
+
+if __name__ == '__main__':
+ main()