Skip to content

Instantly share code, notes, and snippets.

@zackmdavis
Last active May 7, 2017 01:33
Show Gist options
  • Save zackmdavis/6ae0f119f7106146b66f606dd2d696ff to your computer and use it in GitHub Desktop.
Save zackmdavis/6ae0f119f7106146b66f606dd2d696ff to your computer and use it in GitHub Desktop.
bear hunt
from collections import OrderedDict
OBSTACLES = OrderedDict([('grass', ("long, wavy", "swishy-swashy")),
('a river', ("deep, cold", "splash-splosh")),
('mud', ("thick, oozy", "squelch-squerch")),
('a forest', ("big, dark", "stumble-trip"))])
def hunting_anthem():
print("We're going on a bear hunt, &c.")
def bypass(obstacle):
print("{}!".format(obstacle).capitalize())
is_countable = obstacle.startswith("a ") or obstacle.startswith("an ")
article, bare_obstacle = (obstacle.split(None, 1)
if is_countable
else [None, obstacle])
adjective_pair, onomatopœia = OBSTACLES[obstacle]
args = [word for word in [article, adjective_pair, bare_obstacle] if word]
print("{}.".format(" ".join(args)).capitalize())
for preposition in ["under", "over"]:
print("We can't go {} it.".format(preposition))
print("We've got to go through it!")
for _ in range(3):
print("{}!".format(onomatopœia).capitalize())
def main():
for obstacle in OBSTACLES:
hunting_anthem()
print()
bypass(obstacle)
print()
hunting_anthem()
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment