一个用于projecteuler的命令行工具

EasyEuler的Python项目详细描述


EasyEuler公司

EasyEuler是一个可配置的命令行工具,用于处理Project 欧拉。它提供了对许多语言的开箱即用和添加的支持 更多是容易的。在

这个项目的灵感来自 EulerPy并打算提供 相同的功能适用于各种语言。在

安装

可以使用从PyPI安装EasyEuler pip

$ pip install easyeuler

使用

使用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 .

使用listshow浏览问题:

$ easyeuler list
╒══════╤════════════════════════════════════╤══════════════╕
│   ID │ Name                               │ Difficulty   │
╞══════╪════════════════════════════════════╪══════════════╡
│    1 │ Multiples of 3 and 55%           │
├──────┼────────────────────────────────────┼──────────────┤
│    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.jsontemplates 包中的目录。在

语言

添加新语言就像在^{tt8}中添加几行一样简单$ 文件。在

语言具有以下一般属性:

  • name-语言的名称。(必需)
  • extension-该语言的文件扩展名。(必需)
  • template-模板文件的名称。(默认值:name

使用verify命令时,这些命令按顺序执行:

  • build-根据需要生成文件。
  • execute-计时此命令并将输出与解决方案进行比较。(默认值:./{path}
  • cleanup-执行后删除二进制文件,等等

模板

{使用模板引擎^ a4。 新模板应该放在配置内的templates目录中 目录。在

要求

EasyEuler需要Python 3.5+,以及 使用ClickJinja2tabulate模块。 它已经在Windows和Linux上进行了测试,应该可以在其他任何平台上运行 基于Unix的平台,包括macOS。在

贡献

请看CONTRIBUTING.rst 关于如何为这个项目作出贡献的信息。在

致谢

故障描述由 EulerPy项目,其中 将凯尔·基恩的Local Euler项目中的描述格式化为人类可读的 形式。在

许可证

EasyEuler是根据MIT license授权的。在

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java为什么即使我已经给出了代码中的所有权限,该代码也没有在emulator中运行?   java Android Studio正在抛出“线程中的异常”main“javax.net.ssl.SSLException:收到致命警报:协议\版本”   java中的for循环嵌套foreach语句   java读取/src/main/resources和/webinf/classes下的文件   java无法以此格式构造JSON响应   身份验证尝试从CAS secure rest api获取响应,但从java客户端获取登录页面作为响应   如何在java中使用excel从第1列和第3列获取单元格值,并将其作为键值对放入map中   在Java程序中打开Windows虚拟键盘   java有没有递归调用findMatch的方法?   java Pig脚本/命令,用于根据多个字符串筛选文件   java最小数量应匹配,应与POST匹配   java打开/关闭声音按钮不工作   Java嵌入式数据库持久性   java在方法调用时引发异常   java文本文件被覆盖而不是保存的问题   java Hibernate sql注释