Skip to content

Instantly share code, notes, and snippets.

@avamsi
Created November 23, 2014 04:25
Show Gist options
  • Select an option

  • Save avamsi/ee5af56652e009dfcda7 to your computer and use it in GitHub Desktop.

Select an option

Save avamsi/ee5af56652e009dfcda7 to your computer and use it in GitHub Desktop.
def common(a, b):
out = []
for i in a:
try:
b.remove(i)
out.append(i)
except ValueError:
pass
return sorted(out)
while True:
try:
a = raw_input()
b = raw_input()
except EOFError:
break
print ''.join(common(list(a), list(b)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment