排列3或3D选号Python代码免费分享


 import re
 
 class GenerateTripleNumber:
     """排列3或3D选号"""
 
     def __init__(self, big: int, odd: int, prime: int, exclued_num: str, min_sum: int = 0, max_sum: int = 27):
         """
        :param big:大数据号码数量
        :param odd:奇数号码数量
        :param prime:大号数量
        :param target_sum:目标和值
        :param exclued_num:排除号码
        :param odd_number:奇数正则表达式
        :param big_number:大号正则表达式
        :param prime_number:质数正则表达式
        :param sample_number:样本
        """
         self.min_sum = min_sum
         self.max_sum = max_sum
         self.big = big
         self.odd = odd
         self.prime = prime
         self.exclued_num = re.compile(exclued_num)
         self.odd_number = re.compile(r"1|3|5|7|9")  # 不可修改
         self.big_number = re.compile(r"5|6|7|8|9")  # 不可修改
         self.prime_number = re.compile(r"1|2|3|5|7")  # 不可修改
         self.sample_number = ["{:0>3}".format(i) for i in range(0, 1000)]  # 不可修改
 
     def init_data(self):
         rows = []
         for item in self.sample_number:
             row = {}
             big_nums = len(self.big_number.findall(item))
             odd_nums = len(self.odd_number.findall(item))
             prime_nums = len(self.prime_number.findall(item))
             total = sum(map(int, list(item)))
             row["组合"] = ", ".join(list(item))
             row["大号"] = big_nums
             row["奇数"] = odd_nums
             row["质数"] = prime_nums
             row["和值"] = total
             rows.append(row)
 
         return rows
 
     def find_target(self):
         target_list = []
         for target in self.init_data():
             if target.get("大号") == self.big and target.get("奇数") == self.odd and target.get(
                     "质数") == self.prime and target.get("和值") >= self.min_sum and target.get(
                 "和值") <= self.max_sum 
                     and not self.exclued_num.search(target.get("组合")):
                 target_list.append(target)
         return target_list
 
 
 def main():
     # 最小和值
     min_sum = 13
     # 最大和值
     max_sum = 17
     # 输入大号数量
     big = 1
     # 输入奇数数量
     odd = 0
     # 输入质数数量
     prime = 0
     # 输入可能的和值
     # 输入排除数字,以英文|分割
     exclued_num = "0|1|2|8"
     reuslt = GenerateTripleNumber(big, odd, prime, exclued_num, min_sum, max_sum)
 
     for combination in reuslt.find_target():
         print(f"排3或3D组合: {combination.get('组合')}")
 
 
 if __name__ == "__main__":
     main()
 

输出结果

 排3或3D组合: 4, 4, 6
 排3或3D组合: 4, 6, 4
 排3或3D组合: 6, 4, 4
 需要金额: 6 元



纯属娱乐,纯属娱乐,纯属娱乐,纯属娱乐,纯属娱乐,纯属娱乐,纯属娱乐!

展开阅读全文

页面更新:2024-03-30

标签:选号   排列   质数   组合   奇数   英文   大号   样本   数量   号码   代码

1 2 3 4 5

上滑加载更多 ↓
推荐阅读:
友情链接:
更多:

本站资料均由网友自行发布提供,仅用于学习交流。如有版权问题,请与我联系,QQ:4156828  

© CopyRight 2020-2024 All Rights Reserved. Powered By 71396.com 闽ICP备11008920号-4
闽公网安备35020302034903号

Top