commit a20d225b4dfa4b78bb6ce69e643b838ab78b7375 Author: Bigsk Date: Fri Sep 20 07:28:40 2024 +0000 240920 diff --git a/240920.py b/240920.py new file mode 100644 index 0000000..e1ce904 --- /dev/null +++ b/240920.py @@ -0,0 +1,9 @@ +is_palindromic = lambda n: n[0:len(n) // 2] == n[-1:len(n) // 2:-1] if len(n) % 2 else n[0:len(n) // 2] == n[-1:len(n) // 2 - 1:-1] +remove_repeat = lambda w: "".join([w[j] for j in range(len(w)) if w[j] not in w[0:j]]) +remove_repeat_defind = lambda a, b: [d for d in a if d not in b] +extrace_digit = lambda s: "".join([w for w in s if w.isdigit()]) + +remove_repeat_nums = lambda n: "".join([str(n[i]) for i in range(len(n)) if n[i] not in n[0:i]]) +rank_num = lambda n: {j[0]: j[1] for j in dict(zip(n, [n.count(i) for i in n])).items() if j[1] == list(set([n.count(i) for i in n]))[-1]} + +print_num_rank = lambda n: [print(f"{k[0]}字符出现的次数为{k[1]}") for k in sorted([[j[0], j[1]] for j in dict(zip(n, [n.count(i) for i in n])).items()], key=lambda x: x[1], reverse=True)] \ No newline at end of file