From 39d8e45fc8a55d48a2b5bbceef09d7a2de1d846e Mon Sep 17 00:00:00 2001 From: Simon Green Date: Sun, 3 Aug 2025 17:54:51 +1000 Subject: sgreen solutions to challenge 332 --- challenge-332/sgreen/python/ch-2.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 challenge-332/sgreen/python/ch-2.py (limited to 'challenge-332/sgreen/python/ch-2.py') diff --git a/challenge-332/sgreen/python/ch-2.py b/challenge-332/sgreen/python/ch-2.py new file mode 100755 index 0000000000..8a59970f37 --- /dev/null +++ b/challenge-332/sgreen/python/ch-2.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python3 + +import sys +from collections import Counter + + +def odd_letters(input_string: str) -> bool: + """ + Check if all letters in the input string have an odd frequency. + + Args: + input_string (str): The input string to check. + Returns: + bool: True if all letters have an odd frequency, False otherwise. + """ + + freq = Counter(input_string) + return all(count % 2 == 1 for count in freq.values()) + + +def main(): + result = odd_letters(sys.argv[1]) + print(result) + + +if __name__ == '__main__': + main() -- cgit