21 lines
462 B
Python
21 lines
462 B
Python
import sys
|
|
|
|
def diastic(word, phrases):
|
|
words = []
|
|
|
|
cur = 0
|
|
|
|
for idx, c in enumerate(word):
|
|
for nxt, phrase in enumerate(phrases[cur:]):
|
|
if len(phrase) > idx and phrase[idx] == c:
|
|
words.append(phrase)
|
|
cur = idx + 1
|
|
break
|
|
|
|
return " ".join(words)
|
|
|
|
if __name__ == "__main__":
|
|
with open(sys.argv[2]) as f:
|
|
words = f.read().split()
|
|
print(diastic(sys.argv[1], words))
|