Skip to content

Instantly share code, notes, and snippets.

@srid
Created September 12, 2009 02:16
Show Gist options
  • Save srid/185695 to your computer and use it in GitHub Desktop.
Save srid/185695 to your computer and use it in GitHub Desktop.
def original():
for i in range(10):
for j in range(10):
for k in range(10):
if i == j and j == k:
yield "All equal"
elif (i == j and j != k) or (i == k and j != k):
yield "2 equal"
else:
yield "None equal"
def original2():
return ["All equal" if i==j and j==k else (
"2 equal" if (i==j and j!=k) or (i==k and j!=k) \
else "None equal")
for i in range(10)
for j in range(10)
for k in range(10)]
assert tuple(original()) == tuple(original2())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment