26 lines
790 B
Python
26 lines
790 B
Python
from random import random as rnd
|
|
|
|
def add_lametta(func):
|
|
def wrapper(*args, **kwargs):
|
|
return func(*args, **kwargs).replace('+++', '+/+')
|
|
return wrapper
|
|
|
|
def add_bulbs(func):
|
|
def wrapper(*args, **kwargs):
|
|
return "".join([x if x in ' \n' or rnd() < 0.9 else 'o' for x in func(*args, **kwargs)])
|
|
return wrapper
|
|
|
|
def add_stars(func):
|
|
def wrapper(*args, **kwargs):
|
|
return "".join([x if x in ' \n' or rnd() < 0.9 else '*' for x in func(*args, **kwargs)])
|
|
return wrapper
|
|
|
|
@add_lametta
|
|
@add_bulbs
|
|
def generate_christmas_tree(height):
|
|
return "\n".join(["".join(['+' if abs(j - (height)/2) < i/2 else ' '
|
|
for j in range(height)]) for i in range(height)])
|
|
|
|
print("christmas tree:")
|
|
print(generate_christmas_tree(14))
|