diff options
Diffstat (limited to 'challenge-331/ysth/python/ch-2.py')
| -rw-r--r-- | challenge-331/ysth/python/ch-2.py | 15 |
1 files changed, 15 insertions, 0 deletions
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() |
