Skip to content

Instantly share code, notes, and snippets.

@porterjamesj
Created June 11, 2014 03:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save porterjamesj/75893084a63672c4a8ec to your computer and use it in GitHub Desktop.
Save porterjamesj/75893084a63672c4a8ec to your computer and use it in GitHub Desktop.
fun exercise from programming praxis
def balanced(s):
raise NotImplementedError("Implement me!")
def test():
for s in ["{}", "[]", "()", "a(b)c", "abc[d]", "a(b)c{d[e]}"]:
assert balanced(s)
for s in ["{]", "(]", "a(b]c", "abc[d}", "a(b)c{d[e}"]:
assert not balanced(s)
if __name__ == "__main__":
test()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment