You are given an input string in the format "target_word: subword1, subword2, ... subwordN
"
where:
- The target word appears before the colon
- After the colon is a comma-separated string of subwords
Write a function that determines if the subwords can be combined in any order to create
the target word. If possible, return the combination with all vowels removed.
If not possible, return not possible
.
Notes:
- Subwords can only be used once
- The order of subwords in the input doesn't matter
- Remove all vowels (a,e,i,o,u) from the final output
- The combination should be printed with subwords in the order they form the target word
- Input subwords are separated by commas and may contain leading/trailing spaces
Input: "basketball: basket, ball, net"
Output: "bskt bll"
Input: "python: py, ton, java"
Output: "not possible"
Input: "hello: help, lo, el"
Output: "not possible"
Copy and paste this code into your IDE, and put your code where the comment is:
def can_form_word(input_string):
## Your code goes here
return None # Change this to return the final string
assert can_form_word("basketball", "basket, ball, net") == "bskt bll"
assert can_form_word("python", "py, ton, java") == "not possible"
assert can_form_word("hello", "help, lo, el") == "not possible"
assert can_form_word("football", "foot, ball, bas") == "ft bll"
assert can_form_word("computer", "puter, put, com") == "cm ptr"