一个用于projecteuler的命令行工具
EasyEuler的Python项目详细描述
EasyEuler公司
EasyEuler是一个可配置的命令行工具,用于处理Project 欧拉。它提供了对许多语言的开箱即用和添加的支持 更多是容易的。在
这个项目的灵感来自 EulerPy并打算提供 相同的功能适用于各种语言。在
使用
使用create创建新的问题文件:
^{pr2}$一旦你想出了一个解决方案,输出结果并检查它是否 用verify更正:
$ easyeuler verify euler_001.py Checking output of euler_001.py: [no output]# output in red $ echo print(12345) > euler_001.py $ easyeuler verify euler_001.py Checking output of euler_001.py: 12345# incorrect solution, output in red $ echo print(42) > euler_001.py $ easyeuler verify euler_001.py Checking output of euler_001.py: 42# correct solution, output in green
您甚至可以用^{tt3}来计算解决方案的执行时间$ 标志:
$ easyeuler verify --time euler_001.py Checking output of euler_001.py: 42 CPU times - user: 16.7ms, system: 3.33ms, total: 20ms Wall time: 1.02s
…并同时执行多个:
$ easyeuler verify * Checking output of euler_001.py: 42 Checking output of euler_002.c: 12345 Checking output of euler_003.py: [error]# [error] is displayed if an error occurs during execution
其他文件出现一些问题,请使用generate-resources来 生成这些:
$ easyeuler create 22 python Written to euler_022.py $ cat euler_022.py """ Problem 22: Names scores [....] This problem references the following resources: names.txt """ $ easyeuler generate-resources 22# specify the problem ID to generate problem-specific resources Created names.txt at path . $ easyeuler generate-resources # or leave it empty to generate all resources [....] Created 326_formula2.gif at path . Created 326_formula1.gif at path . Created 327_rooms_of_doom.gif at path . Created 330_formula.gif at path .
使用list和show浏览问题:
$ easyeuler list ╒══════╤════════════════════════════════════╤══════════════╕ │ ID │ Name │ Difficulty │ ╞══════╪════════════════════════════════════╪══════════════╡ │ 1 │ Multiples of 3 and 5 │ 5% │ ├──────┼────────────────────────────────────┼──────────────┤ │ 2 │ Even Fibonacci numbers │ 5% │ ├──────┼────────────────────────────────────┼──────────────┤ │ 3 │ Largest prime factor │ 5% │ ├──────┼────────────────────────────────────┼──────────────┤ [....] $ easyeuler show 2 Problem 2: Even Fibonacci numbers Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... Find the sum of all the even-valued terms in the sequence which do not exceed four million.
配置
EasyEuler的设计是可配置的,并且可以适应任何语言 您可能需要与一起使用。它跟在XDG Base Directory Specification后面 用于查找配置文件。默认位置是 $HOME/.config/EasyEuler。 要查看配置示例,请查看config.json和templates 包中的目录。在
语言
添加新语言就像在^{tt8}中添加几行一样简单$ 文件。在
语言具有以下一般属性:
- name-语言的名称。(必需)
- extension-该语言的文件扩展名。(必需)
- template-模板文件的名称。(默认值:name)
使用verify命令时,这些命令按顺序执行:
- build-根据需要生成文件。
- execute-计时此命令并将输出与解决方案进行比较。(默认值:./{path})
- cleanup-执行后删除二进制文件,等等
模板
{使用模板引擎^ a4。 新模板应该放在配置内的templates目录中 目录。在
要求
EasyEuler需要Python 3.5+,以及 使用Click, Jinja2和 tabulate模块。 它已经在Windows和Linux上进行了测试,应该可以在其他任何平台上运行 基于Unix的平台,包括macOS。在
贡献
请看CONTRIBUTING.rst 关于如何为这个项目作出贡献的信息。在
致谢
故障描述由 EulerPy项目,其中 将凯尔·基恩的Local Euler项目中的描述格式化为人类可读的 形式。在
许可证
EasyEuler是根据MIT license授权的。在
- 项目
标签: