serializer.py 文件源码

python
阅读 60 收藏 0 点赞 0 评论 0

项目:Round1 作者: general-ai-challenge 项目源码 文件源码
def gen_pseudo_word(self, L=None):
        if not L:
            L = random.randint(1, 8)
        # generate one word that we hadn't used before
        while True:
            if self.readable:
                # alternating between vowels and consonants, sampled with repl.
                _choice, _range = random.choice, range(int(math.ceil(L / 2)))
                v = [_choice(self.V) for i in _range]
                c = [_choice(self.C) for i in _range]
                zipped = zip(v, c) if random.getrandbits(1) else zip(c, v)
                pseudo_word = ''.join([a for b in zipped for a in b])[:L]
            else:
                pseudo_word = ''.join(random.sample(
                                      string.ascii_lowercase, L))
            if pseudo_word not in self.inv_word_mapping:
                return pseudo_word
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号