Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import itertools
- import sys
- strings = []
- def check_for_interception(noun_animal):
- noun, animal = noun_animal[0], noun_animal[1]
- for i in range(len(noun)):
- if animal.startswith(noun[-i:]) and len(noun[-i:]) >= 3:
- strings.append([noun, animal, noun[:-i] + animal])
- return
- nouns, animals = [], []
- for line in map(str.rstrip, sys.stdin):
- if len(line) == 0:
- break
- nouns.append(line)
- for line in map(str.rstrip, sys.stdin):
- animals.append(line)
- [check_for_interception(x) for x in list(itertools.product(nouns, animals))]
- [print(*x) for x in sorted(strings)]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement