The task is to process a specified number of 4-letter prompts. The objective is to identify common elements among these prompts, create a final word by combining these shared elements, and determine any additional words that do not contribute to the final composition.
-
Input Gathering:
- Prompt the user to input the number of 4-letter prompts desired.
- Collect each prompt from the user and store them in a list.
-
Validation and Common Element Detection:
- Check each prompt's length to ensure it's precisely 4 letters long.
- Iterate through the prompts and identify common elements by comparing the suffix of one prompt with the prefix of the next prompt.
- Accumulate the common elements and construct the final word based on the first prompt and these common elements.
-
Identification of Other Words:
- Compare the collected prompts against the final word to identify any words that are not part of the final composition.
-
Output:
- Display the common elements found.
- Print the final word obtained from combining these common elements.
- Show any words that are outside the final composition.
The code uses loops for iteration, conditional statements for validation and identification of common elements, and list operations to create the final word and identify words not included in the final composition. It's designed to efficiently perform these operations while minimizing redundancy and unnecessary steps.