thraxil.org:

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

Less complicated version of what you wrote would be:


states = ["alabama","alaska", ... ,"wyoming",]

sset = set()

for s1 in xrange(len(states)):
for s2 in xrange(s1+1, len(states)):
ss = ’’.join(sorted(states[s1] + states[s2]))
if ss in sset:
print states[s1], states[s2]
exit(0)
else:
sset.add(ss)


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?