This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding=utf-8 | |
class TreeNode: | |
def __init__(self, name='root', data=None, parent=None, children=None): | |
self.name = name | |
self.data = data | |
if parent: | |
assert isinstance(parent, TreeNode) | |
parent.add_child(self) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from math import sqrt | |
from itertools import islice | |
def is_prime(num): | |
if num in (2, 3): | |
return True | |
for factor in range(2, int(sqrt(num)) + 1): | |
if num % factor == 0: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
import requests | |
from time import sleep | |
from pypinyin import lazy_pinyin | |
from termcolor import colored | |
from simpleeval import simple_eval | |
class Bot: | |