简洁的随机红包分配算法

查看 252|回复 21
ShadowPower   
我翻出了 8 年前的代码……
#! python3
#coding: utf-8
import math, random
class RedPacket:
__remainSize = 0
__remainMoney = 0
def __init__(self, size, money):
self.__remainSize = int(size)
self.__remainMoney = int(money * 100)
def is_empty(self):
return self.__remainSize = 1 else 1
self.__remainSize -= 1
self.__remainMoney -= money
return money / 100
ShadowPower   
似乎开头的空格会被删掉,于是我把两个空格换成了全角空格:
#! python3
#coding: utf-8
import math, random
class RedPacket:
  __remainSize = 0
  __remainMoney = 0
   def __init__(self, size, money):
     self.__remainSize = int(size)
     self.__remainMoney = int(money * 100)
   def is_empty(self):
     return self.__remainSize = 1 else 1
     self.__remainSize -= 1
     self.__remainMoney -= money
     return money / 100
您需要登录后才可以回帖 登录 | 立即注册

返回顶部