Transform Set of Strings to Common Prefix Notation
Go to file
2022-08-20 09:51:37 +02:00
README.md Initial commit 2022-08-20 09:51:37 +02:00
trie.py Initial commit 2022-08-20 09:51:37 +02:00

Transform Set of Strings to Common Prefix Notation

Description

Presented with a series of lines on standard input, the program will print an expression on standard output that denotes the line strings in a syntax described in https://tk-sls.de/wp/6071.

The expression is suitable for Bourne Again Shell brace expansion.

Test

$ python3 trie.py << EOF
a
ab
abc
EOF

Expected output:

a{,b{,c}}

Test if the output is accurate:

$ bash -c 'echo a{,b{,c}}'

Expected output:

a ab abc