Skip to content

Instantly share code, notes, and snippets.

@dariosky
Created April 14, 2015 20:22
Show Gist options
  • Save dariosky/a57292374e93bc81381e to your computer and use it in GitHub Desktop.
Save dariosky/a57292374e93bc81381e to your computer and use it in GitHub Desktop.
Tribute to Stevie Wonder
#!/usr/bin/python
import collections
__author__ = "Dario Varotto"
""" This was thought while I was showering, sorry :) """
def stevie():
stack = collections.deque()
stack.append("from the bottom")
stack.append("and I mean it")
stack.append('I just called')
stack.append('I just called')
stack.append('I just called')
counter = collections.defaultdict(int)
while stack:
item = stack.pop()
if item.startswith("I"):
print item.replace("alle", "ode"), "to say",
counter[item] += 1
if counter[item] % 2:
print "I love you"
else:
print "how much I care"
else:
print item
print "of my stack"
if __name__ == '__main__':
stevie()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment