Local Judge
What's this?
Local Judge 类似于 Online Judge,但因其运行在本地,故命名为 Local Judge。
它可以让你在练习算法题目时,自动将文件的测试用例输入stdin,而不需要使用freopen等方法。(因为 freopen 每次提交OJ时必须注释代码)。
当然,控制台管道重定向也可以实现此功能,但是输入命令比较繁琐。
另一优势在于可以存储、管理多份测试用例,方便复习查阅。
快速入门
目录结构如下:
.
├── poj-1000 题目文件夹,需要和源码文件名前缀相同
│ ├── 1.in 输入,必须为*.in
│ ├── 1.out 预期输出,必须为*.out
│ ├── 2.in
│ ├── 2.out
│ ├── 3.in
│ ├── 3.out
│ ├── README.md 问题描述文件
└── poj-1000.c 代码
运行实例
➜ lj poj-1000.c
judging
case count: 4
-> case [1] <- accepted
in 5 ms
-> case [2] <- accepted
in 6 ms
-> case [3] <- accepted
in 7 ms
-> case [test-error] <- wrong answer
stdin:
1 2
stdout:
3
expected:
5
in 5 ms
=====summary=====
Wrong Answer: 1 Time Limit Exceeded : 0 Memory Limit Exceeded : 0
All: 4 Accepted: 3 (75.000000 %)
安装
pip install https://github.com/NoCLin/LocalJudge/archive/master.zip
termtosvg
编译器配置
建议将编译器所在目录加入环境变量 path。
修改文件 ~/.localjudge.json 以自定义编译器及参数,内容如下:
➜ cat ~/.localjudge.json
{
"c": "gcc ${src} -o ${temp_exe}",
"c++": "g++ ${src} -o ${temp_exe}"
}
${src} 为源文件路径,${temp_exe}为生成的二进制文件路径,程序会将这些值自动替换
工具
➜ lj -h
usage: lj [-h] [-c CASE] [-t TIMELIMIT] [-d] [-s] [--clean] [--json] src
Local Judge
positional arguments:
src source file
optional arguments:
-h, --help show this help message and exit
-c CASE, --case CASE index of test case
-t TIMELIMIT, --timelimit TIMELIMIT
time limit (ms)
-d, --debug debug mode
-s, --show show cases
--clean clean temp directory
--json output as json
# ljc 自动生成工程文件
➜ ljc poj-1001.c
➜ ls poj-1001*
poj-1001.c
poj-1001:
1.in 1.out 2.in 2.out README.md
TODO
- pypi
- 内存限制 (使用沙盒?)
- 支持更多的语言
- VSCode 插件
Metadata
Release files for LocalJudge 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| LocalJudge-0.0.1.tar.gz | 6.3 kB | Without provenance | Details for LocalJudge-0.0.1.tar.gz |
Release files / LocalJudge-0.0.1.tar.gz
| Download URL | LocalJudge-0.0.1.tar.gz |
|---|---|
| Size | 6.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
66a9692d6a05c30341fb8c069533e95382252c218ac9884496206c1dd1d4c56a
|
|
BLAKE2b-256 checksum How to use checksums |
f25b94db4a2447b6b852dddb8339d7c5f6436adb390b97d1984b0ad1c0fcc2ff
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.6.3
|
Security for LocalJudge 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.