Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from math import*
- from termcolor import colored
- class PieChart:
- def select(self, choices: list, percents: list, atn: float):
- if not percents:
- return ' '
- if atn<percents[0]:
- return choices[0]
- return self.select(choices[1:],percents[1:],atn-percents[0])
- def generate(self, choices: list, percents: list, size: int):
- dia=range(-size,size)
- for he in dia:
- chart=""
- for wi in dia:
- if he**2+wi**2<size**2:
- atn=atan2(he,wi)/pi/2+.5
- chart=chart+self.select(choices,percents,atn)
- else:
- chart += " "
- yield chart
Add Comment
Please, Sign In to add comment