Giter Site home page Giter Site logo

localjudge's Introduction

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 代码


运行实例

➜  test git:(master) ✗ 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

编译器配置

建议将编译器所在目录加入环境变量 path

修改文件 ~/.localjudge.json 以自定义编译器及参数,内容如下:

➜  test git:(master) ✗ cat ~/.localjudge.json
{
  "c": "gcc ${src} -o ${temp_exe}",
  "c++": "g++ ${src} -o ${temp_exe}"
}

工具

# ljc 自动生成工程文件
➜  test git:(master) ✗ ljc poj-1001.c
➜  test git:(master) ✗ ls poj-1001*
poj-1001.c

poj-1001:
1.in      1.out     2.in      2.out     README.md

TODO

  • pypi
  • 内存限制 (使用沙盒?)
  • 支持更多的语言

localjudge's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.