Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def compose(*args):
- def composition(n):
- accum = n
- for func in args:
- accum = func(accum)
- return accum
- return composition
- def carbonize(modulus, message):
- def beer(n):
- if type(n) == str: return n
- return message if n % modulus == 0 else n
- return beer
- def freebeer(n):
- f = compose(carbonize(15, 'freebeer'),
- carbonize(5, 'beer'),
- carbonize(3, 'free'), str)
- return ' '.join(map(f, range(1, n + 1)))
Add Comment
Please, Sign In to add comment