如何链接交互式问题(写 CodeJam)?

Dee*_*hta 5 python interactive python-3.x

我不确定是否允许寻求帮助(如果不允许,我不介意在比赛期结束之前不要得到答案)。

我正在解决CodeJam 上的交互式问题 ( Dat Bae )。在我的本地文件上,我可以分别运行法官 ( testing_tool.py) 和我的程序 ( <name>.py) 并手动复制粘贴 I/O。但是,我认为我需要找到一种方法来自动制作它。

编辑:为了清楚起见,我希望 x 文件的每个输出都输入到 y 文件中,反之亦然。

一些细节:

  1. 我在整个程序中使用sys.stdout.write/sys.stdin.readline而不是打印 / 输入

  2. 我试过运行interactive_runner.py,但我似乎不知道如何使用它。

  3. 我尝试在他们的服务器上运行它,我的程序在第一个选项卡中,判断文件在第二个选项卡中。它总是抛出 TLE 错误。

我似乎也没有找到任何教程来做同样的事情,任何帮助将不胜感激!:/

Eug*_*ash 6

用法记录在脚本内的注释中:

Interactive_runner.py

# Run this as:
# python interactive_runner.py <cmd_line_judge> -- <cmd_line_solution>
#
# For example:
# python interactive_runner.py python judge.py 0 -- ./my_binary
#
# This will run the first test set of a python judge called "judge.py" that
# receives the test set number (starting from 0) via command line parameter
# with a solution compiled into a binary called "my_binary".
Run Code Online (Sandbox Code Playgroud)

测试工具.py

# Usage: `testing_tool.py test_number`, where the argument test_number
# is 0 for Test Set 1 or 1 for Test Set 2.
Run Code Online (Sandbox Code Playgroud)

所以像这样使用它们:

python interactive_runner.py python testing_tool.py 0 -- ./dat_bae.py
Run Code Online (Sandbox Code Playgroud)

  • 嘿,不确定我最初是如何错过“0”的。但是,在运行时,我收到另一个错误:“OSError: [WinError 193] %1 不是有效的 Win32 应用程序”。我安装了 32 位,为 32 位创建了 venv,但仍然没有弹出相同的错误:/ (2认同)