From 99c4e905c974e2e92e238c10cbfc771e89b6cc90 Mon Sep 17 00:00:00 2001 From: Yitzchak Scott-Thoennes Date: Wed, 23 Jul 2025 17:15:21 -0400 Subject: challenge 330 python, perl, and go solutions --- challenge-331/ysth/python/ch-2.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 challenge-331/ysth/python/ch-2.py (limited to 'challenge-331/ysth/python/ch-2.py') diff --git a/challenge-331/ysth/python/ch-2.py b/challenge-331/ysth/python/ch-2.py new file mode 100644 index 0000000000..6d0f7c80e4 --- /dev/null +++ b/challenge-331/ysth/python/ch-2.py @@ -0,0 +1,15 @@ +import sys +import regex +from itertools import batched + +def buddy_strings(string1: str, string2: str) -> bool: + return True if regex.fullmatch(regex.escape(string1)+'{1<=s<=1}', string2) else False + +def main() -> None: + inputs: list[str] = sys.argv[1:] + + for string1, string2 in batched(inputs, 2): + print(f'{string1:<30}\n{string2:<30}\n -> {"yes" if buddy_strings(string1, string2) else "no"}') + +if __name__ == '__main__': + main() -- cgit