sd.py增加逻辑

This commit is contained in:
chenwj113 2022-11-02 17:47:35 +08:00
parent a06e60abb5
commit fe99068e85
2 changed files with 33 additions and 4 deletions

4
pls.py
View File

@ -19,8 +19,8 @@ for i in group3:
sum_group_dict[sum(map(int, list(i)))].append(i) sum_group_dict[sum(map(int, list(i)))].append(i)
for i in sum_group_dict.keys(): for i in sum_group_dict.keys():
f3 = lambda number: True if '1' not in number else False f3 = lambda number: True if '7' not in number else False
print(i, -cachesum_group_dict[i]) print(i, list(filter(f3, sum_group_dict[i])))
# print(sum_group3_dict) # print(sum_group3_dict)
# sum_group3 = [ sum(map(int, list(i))) for i in group3] # sum_group3 = [ sum(map(int, list(i))) for i in group3]
# print(pd.value_counts(sum_group3).to_dict()) # print(pd.value_counts(sum_group3).to_dict())

33
sd.py
View File

@ -3,14 +3,43 @@ import pandas as pd
a = np.arange(1000) a = np.arange(1000)
nums = [ f"{i:03d}" for i in a ]
is_odd = lambda i: True if int(i) % 2 == 1 else False
is_even = lambda i: True if int(i) % 2 == 0 else False
#奇奇奇
odd_odd_odd = [i for i in nums if is_odd(i[0]) and is_odd(i[1]) and is_odd(i[2]) ]
#奇奇偶
odd_odd_even = [i for i in nums if is_odd(i[0]) and is_odd(i[1]) and is_even(i[2]) ]
#
odd_even_odd = [i for i in nums if is_odd(i[0]) and is_even(i[1]) and is_odd(i[2]) ]
#
odd_even_even = [i for i in nums if is_odd(i[0]) and is_even(i[1]) and is_even(i[2])]
#
even_odd_odd = [i for i in nums if is_even(i[0]) and is_odd(i[1]) and is_odd(i[2]) ]
#奇奇偶
even_odd_even = [i for i in nums if is_even(i[0]) and is_odd(i[1]) and is_even(i[2]) ]
#
even_even_odd = [i for i in nums if is_even(i[0]) and is_even(i[1]) and is_odd(i[2]) ]
#
even_even_even = [i for i in nums if is_even(i[0]) and is_even(i[1]) and is_even(i[2])]
print(len(even_even_even))
print(len(even_even_odd))
print(len(odd_odd_even))
f = lambda x: True if '7' not in x and '5' not in x else False
result = list(filter(f, even_odd_even))
print(result)
l = set([ f"{i:03d}" for i in a ]) l = set([ f"{i:03d}" for i in a ])
sum_dict = dict() sum_dict = dict()
print(len(l)) # print(len(l))
for i in l: for i in l:
_sum = sum(map(int, i)) _sum = sum(map(int, i))
v = sum_dict.get(_sum, 0) v = sum_dict.get(_sum, 0)
sum_dict[_sum] = v + 1 sum_dict[_sum] = v + 1
df = pd.Series(sum_dict) df = pd.Series(sum_dict)
print(df.sort_values(ascending=False)) # print(df.sort_values(ascending=False))