Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys;
- input_string = sys.stdin.readline()
- input_string = input_string.strip()
- input_string = input_string.replace("\n",' ')
- input_string = input_string.replace(".",' ')
- input_array = input_string.split(" ")
- _dict = { }
- iter = 0
- for word in input_array:
- iter += 1
- _lower = word.lower()
- _hash = ''.join(sorted(_lower))
- if not _hash in _dict:
- _dict[_hash] = { 'first':iter,
- 'words':[] }
- if not _lower in _dict[_hash]['words']:
- _dict[_hash]['words'].append(_lower)
- _array = []
- for _hash in _dict:
- if len(_dict[_hash]['words']) > 1:
- _array.append(_dict[_hash]);
- _dict = len(_array)
- _array = sorted( _array, key=lambda t: t['first'] )
- for x in range(0,_dict):
- sys.stdout.write( '\n' + ' '.join( _array[x]['words'] ) )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement