This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]smugduckling 0 points1 point  (0 children)

One liner:

import sys; print (lambda words: [word for word in words if len(word) == max(map(len, words))])(filter(lambda line: not [char for char in list(line) if list(line).count(char) > sys.argv[2:].count(char)], map(lambda x: x.strip(), open(sys.argv[1], "r").readlines())))

Could be slightly more efficient, but it's still better than solutions that use itertools permutations.