def drop_redundant_messages(messages):
 sorted_messages = sorted(messages, key=len, reverse=True)
 filtered_messages = set()
 for message in sorted_messages:
  for filtered_message in filtered_messages:
   if (message in filtered_message):
    break
  else:
   filtered_messages.add(message)
 return filtered_messages

def drop_redundant_messages ( messages ) : sorted_messages = sorted ( messages , key = len , reverse = True ) filtered_messages = set ( ) for message in sorted_messages : for filtered_message in filtered_messages : if ( message in filtered_message ) : break else : filtered_messages . add ( message ) return filtered_messages
given a set of message strings discard any redundant messages which are simple a substring of the existing ones .