Skip to content

Instantly share code, notes, and snippets.

@zh4ngx
Last active December 28, 2015 17:39
Show Gist options
  • Save zh4ngx/7537472 to your computer and use it in GitHub Desktop.
Save zh4ngx/7537472 to your computer and use it in GitHub Desktop.
Simple interview question to test basic debugging & communication skills. May require a live person to answer questions (particularly if the candidate doesn't know Python). TODO: rewrite this in a few languages and put in a repo.
def foo(a, b):
"""Please document me.
What am I supposed to do?
Rename anything you see fit.
Also, I think I have bugs. Please debug me.
"""
bar = {}
for x in a:
bar[x] = True
for y in a:
if bar[b - x]:
return True
else:
return False
def test_foo(a, b, c):
"""
Bonus: Thanks for debugging & documenting me.
Please now write unit tests to make sure I behave.
Feel free to rename anything here as well.
"""
# example
# assert foo(a,b) == c
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment