From 39aa246c606877d74f601d39f68ac35fda3ea1ff Mon Sep 17 00:00:00 2001 From: vinodk89 Date: Sun, 5 Oct 2025 00:19:10 +0530 Subject: Python Solutions for Challenge-341 --- challenge-341/vinod-k/python/ch-1.py | 11 +++++++++++ challenge-341/vinod-k/python/ch-2.py | 14 ++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 challenge-341/vinod-k/python/ch-1.py create mode 100644 challenge-341/vinod-k/python/ch-2.py diff --git a/challenge-341/vinod-k/python/ch-1.py b/challenge-341/vinod-k/python/ch-1.py new file mode 100644 index 0000000000..2a2c08228e --- /dev/null +++ b/challenge-341/vinod-k/python/ch-1.py @@ -0,0 +1,11 @@ +sentence = input("Enter the sentence: ") +keys_input = input("Enter the broken keys separated by space: ") + +broken_keys = set(keys_input.lower().split()) + +count = 0 +for word in sentence.split(): + if all(char not in broken_keys for char in word.lower()): + count += 1 + +print(f"Number of words that can be typed: {count}") diff --git a/challenge-341/vinod-k/python/ch-2.py b/challenge-341/vinod-k/python/ch-2.py new file mode 100644 index 0000000000..c9cb239502 --- /dev/null +++ b/challenge-341/vinod-k/python/ch-2.py @@ -0,0 +1,14 @@ +input_str = input("Enter the string: ") +char = input("Enter the character to reverse prefix until: ") + +index = input_str.find(char) + +if index == -1 or index == 0: + # No change if character not found or at start + result = input_str +else: + prefix = input_str[:index+1] + rest = input_str[index+1:] + result = prefix[::-1] + rest + +print(f"Resulting string: {result}") -- cgit