feat(pyproject.toml):添加sympy依赖用于数学计算

📝 feat(0021.AmicableNumbers/readme.md):添加亲和数对文档的中文翻译
 feat(0022):新增欧拉问题22解决方案,包含姓名文件和处理脚本
 feat(0023):新增欧拉问题23解决方案,包含三种实现和文档说明

📝 docs(solutions/0067.MaxPathSum2):新增热带半环理论综述文档

新增关于热带半环(Tropical Semiring)的详细综述文档,涵盖其数学原理、与代数几何的联系(热带几何)、在量子力学与量子信息中的应用,以及其他跨学科应用领域。文档系统性地介绍了热带半环的基本理论结构,包括min-plus/max-plus代数、幂等性与分配律,以及其与全序集和格论的联系。同时深入探讨了热带几何的核心概念(如热带化、热带簇、Amoebas和Newton多边形)及其在代数几何中的应用(如热带Bézout定理、拓扑不变量计算和枚举几何)。文档还综述了热带半环在量子力学(如热带量子理论、非厄米系统特殊点分析)和量子信息(如贝尔不等式分析、热带张量网络)中的前沿应用,并展望了其在密码学、生物信息学等领域的潜力。该文档旨在为相关领域的研究者提供一个全面的理论参考。
This commit is contained in:
2025-12-22 18:27:46 +08:00
parent 1747152a4d
commit 13d5d27c5a
10 changed files with 636 additions and 0 deletions

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,46 @@
"""
Using names.txt (right click and 'Save Link/Target As...'), a 46K text file containing over five-thousand first names, begin by sorting it into alphabetical order. Then working out the alphabetical value for each name, multiply this value by its alphabetical position in the list to obtain a name score.
For example, when the list is sorted into alphabetical order, COLIN, which is worth 3 + 15 + 12 + 9 + 14 = 53,
is the 938th name in the list. So, COLIN would obtain a score of 938 × 53 = 49714.
What is the total of all the name scores in the file?
"""
import time
from pathlib import Path
def timer(func):
def wrapper(*args, **kwargs):
start_time = time.time()
result = func(*args, **kwargs)
end_time = time.time()
print(f"Execution time: {end_time - start_time:.6f} seconds")
return result
return wrapper
def read_names() -> list[str]:
path = Path(__file__).parent / "0022_names.txt"
with open(path, "r") as file:
names = file.read().replace('"', "").split(",")
return sorted(names)
def calculate_name_score(name: str, index: int) -> int:
return sum(ord(char) - ord("A") + 1 for char in name) * index
@timer
def main():
names = read_names()
total_score = sum(
calculate_name_score(name, index + 1) for index, name in enumerate(names)
)
print(total_score)
if __name__ == "__main__":
main()