Guest User

Untitled

a guest
May 20th, 2018
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. def compose(*args):
  2. def composition(n):
  3. accum = n
  4. for func in args:
  5. accum = func(accum)
  6. return accum
  7. return composition
  8.  
  9. def carbonize(modulus, message):
  10. def beer(n):
  11. if type(n) == str: return n
  12. return message if n % modulus == 0 else n
  13. return beer
  14.  
  15. def freebeer(n):
  16. f = compose(carbonize(15, 'freebeer'),
  17. carbonize(5, 'beer'),
  18. carbonize(3, 'free'), str)
  19. return ' '.join(map(f, range(1, n + 1)))
Add Comment
Please, Sign In to add comment