Orig Description
Decrypting the Princess's Code
A brave and boyish poor princess from a country secretly obtained an ancient document written in Japanese while she was out. The princess who could read Japanese immediately began reading the document. Surprisingly, the document revealed the location of an ancient treasure. However, the location of the treasure was written in code, and it was not easy to understand. So, the princess ordered you, her handmaiden, to help decipher the message.
You investigated day and night and discovered that a shortest secret substring (SSS) plays an important role in decoding. SSS is a string that contains all N given words as substrings and has the smallest possible length. You were given the task of finding SSS from the given N words.
Input
The input consists of multiple datasets. The first line of each dataset contains an integer N (1≤N≤10), which is the number of words in the dataset. The next N lines contain the words. Input containing only a line of 0 indicates the end of the input.
The input words contain only lowercase letters of the alphabet and have a maximum length of 10.
Output
For each dataset, output SSS on one line. If there are multiple SSS, output the one that comes first in dictionary order.
Sample Input
4
apple
length
things
thin
2
icp
cpc
3
zeta
eta
alphabet
2
until
till
0
Sample Output
applengthings
icpc
zetalphabet
untill
Extracted Specification
An integer N (1 ≤ N ≤ 10), representing some quantity or size.
A list of N strings, each containing only lowercase letters of the alphabet and having a maximum length of 10.
The input ends with a line containing only the integer 0.
### Example Input:
```
4
apple
length
things
thin
2
icp
cpc
0
```
### Function Signature:
Write a function f(inputs) that takes in the input.
def f(inputs: List[Tuple[int, List[str]]]):
'''
inputs: a list of tuples, where each tuple contains an integer and a list of strings
'''
Test Case Generator
Sure! Here is a test case generator for the problem "Decrypting the Princess's Code":
```python
import random
import string
def generate_word():
# Generate a random word with a length between 1 and 10
length = random.randint(1, 10)
return ''.join(random.choices(string.ascii_lowercase, k=length))
def tcgen():
test_cases = []
while True:
# Generate a random number N (1 ≤ N ≤ 10)
N = random.randint(1, 10)
if N == 0:
break
words = [generate_word() for _ in range(N)]
test_cases.append((N, words))
# Append the termination line
test_cases.append((0, []))
return test_cases
# Example of generating and printing test cases
test_cases = tcgen()
for case in test_cases:
N, words = case
print(N)
for word in words:
print(word)
```
### Explanation
- **generate_word()**: This helper function generates a random word with a length between 1 and 10 characters, using lowercase letters only.
- **tcgen()**: This function generates multiple test cases until a termination condition (N = 0) is reached.
- For each test case, it generates a random number \( N \) (1 ≤ \( N \) ≤ 10).
- It then generates \( N \) random words using the `generate_word()` function.
- The generated test cases are collected in a list.
- The termination condition (N = 0) is appended at the end of the list.
- Finally, the test cases are printed in the specified format, where each test case is separated by a newline and the words are printed line by line.
### Example Usage
You can use this generator to create input files for testing or for feeding directly into your program to ensure it handles various edge cases and random inputs correctly.
```python
# Example of generating and printing test cases
test_cases = tcgen()
for case in test_cases:
N, words = case
print(N)
for word in words:
print(word)
```
This code will generate random test cases and print them in the format required by the problem "Decrypting the Princess's Code".
Extract Arguments
def extract_arguments(fh):
inputs = []
while True:
N = int(fh.readline().strip())
if N == 0:
break
words = [fh.readline().strip() for _ in range(N)]
inputs.append((N, words))
return inputs