thraxil.org:

Reply to: A Simple Programming Puzzle Seen Through Three Different Lenses

You can also do this one-liner which works without adding any new functions (though you need to import itertools):

print [zip(*v)[1] for v in [list(v) for k, v in itertools.groupby(sorted([(''.join(sorted(s1 + s2)), (s1, s2)) for s1 in states for s2 in states if s1 < s2], key=lambda v: v[0]), lambda v: v[0])] if len(v) > 1]

Of course, that’s clearly crossing the line from “clever” into “obfuscated”, but oh well. It was fun to write. :)

If you really enjoy this sort of thing, just get it over with and switch to Perl. Much better language for one-liners.

…and incomprehensibility.

;p


formatting is with Textile syntax. Comments are not displayed until they are approved by a moderator. Moderators will not approve unless the comment contributes value to the discussion.

namerequired
emailrequired
url
remember info?