Guest User

Untitled

a guest
Jun 21st, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. from math import*
  2. from termcolor import colored
  3. class PieChart:
  4. def select(self, choices: list, percents: list, atn: float):
  5. if not percents:
  6. return ' '
  7. if atn<percents[0]:
  8. return choices[0]
  9. return self.select(choices[1:],percents[1:],atn-percents[0])
  10.  
  11. def generate(self, choices: list, percents: list, size: int):
  12. dia=range(-size,size)
  13. for he in dia:
  14. chart=""
  15. for wi in dia:
  16. if he**2+wi**2<size**2:
  17. atn=atan2(he,wi)/pi/2+.5
  18. chart=chart+self.select(choices,percents,atn)
  19. else:
  20. chart += " "
  21. yield chart
Add Comment
Please, Sign In to add comment