Make pypy submission easier with atcoder-cli (python)

Introduction

Hello everyone. This is ʻatcoderbeginner [jacky](https://twitter.com/jacky_dev) who just turned brown a while ago. I'm usingpypy3 with ʻatcoder, but when I tried to simplify submission using ʻatcoder-cli`, I was a little lost, so I will share the information.

What is ʻatcoder-cli`?

ʻAtcoder-cli is when you join ʻatcoder

--Test case download --Creating a template --Run test --Submit

It is a tool that lets you do things with cli (command line) instead of a browser. Copy the test case on the browser one by one and open the code test tab. .. .. If you do something like that, you will waste time, so It is a convenient tool that makes those processes easier. There are already many good articles on how to install and explain the tool itself, so please have a look there.

reference

-Command line tool atcoder-cli has been released (Author's blog) -atcoder-cli tutorial (author's blog) -Atcoder beginners should build an environment! (Installation and usage of atcoder-cli, online-judge-tools) (Qiita) -Automate AtCoder directory creation, sample case testing, and submission. atcoder-cli and online-judge-tools (Qiita)

Submit pypy3 using ʻatcoder-cli`

If you have read all the above articles, you will know that submission is done with the following command (assuming submission with pypy)

acc s

Then, I think that the output will be like this.


[x] PyPy is available for Python interpreter
[*] chosen language: 4006 (Python (3.8.2))
[!] the problem "https://atcoder.jp/contests/abc170/tasks/abc170_d" is specified to submit, but no samples were downloaded in this directory. this may be mis-operation
[x] sleep(3.00)
Are you sure? Please type "abcd" 

This is, in short

--You can use pypy (I don't use it) --Submit in Python (3.8.2) -Is the sample case not downloaded to this directory and you made a mistake? --Wait for 3 seconds --If you want to submit, enter ʻabcd`

Is the message. (You can ignore the third message (whether you made an operation error) unless it is really an operation error.)

As written here, if you execute the submit command normally, it will be submitted as the answer in python. To submit this with PyPy, use the following command.

acc s main.py -- --guess-python-interpreter pypy

The output at this time is

[x] PyPy is available for Python interpreter
[x] both Python2 and Python3 are available for version of Python
[x] use: 3
[*] chosen language: 4047 (PyPy3 (7.3.0))
[!] the problem "https://atcoder.jp/contests/abc170/tasks/abc170_d" is specified to submit, but no samples were downloaded in this directory. this may be mis-operation
[x] sleep(3.00)
Are you sure? Please type "abcd" 

Then, when you look at the 4th line, you can see that PyPy3 is properly selected. If you execute the submission with this, it will be submitted properly with PyPy3.

For details, see the following issue. How can I use PyPy as default language?

Isn't it annoying to type commands?

Now I can submit it, but I'm tired of typing this command and I want to submit it more easily. I use the task runner feature of VScode to make things easier. About the task runner function

Please look around. Simply put, if you describe the task as .vscode/tasks.json directly under the project directory, it is a function that can be executed easily.

I am making the following tasks.json.

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "test",
            "type": "shell",
            "command": "oj",
            "args": ["t","-c","'pypy3 main.py'"],
            "options": {"cwd": "${fileDirname}"}
        },
        {
            "label": "submit",
            "type": "shell",
            "command": "acc",
            "args": ["s","main.py","--","--guess-python-interpreter","pypy"],
            "options": {"cwd": "${fileDirname}"}
        },

    ]
}

In tasks, the first is the task for test execution and the second is the task for submission. Common to both,

"options": {"cwd": "${fileDirname}"}

The meaning of the part is that the directory containing the currently open file is specified as the location to execute these commands.

By doing this, you can easily execute the task after opening the command palette. (Command Palette (⇧⌘P))

Finally

This will make your life comfortable and your rate will explode! !! !! !! !!

Recommended Posts

Make pypy submission easier with atcoder-cli (python)
Make Puyo Puyo AI with Python
Make a fortune with Python
Make apache log csv with python
Let's make a GUI with python.
Make a recommender system with python
Let's make a graph with python! !!
Make the Python console covered with UNKO
Let's make a shiritori game with Python
Tips to make Python here-documents easier to read
Fractal to make and play with Python
Let's make a voice slowly with Python
[Python] Let's make matplotlib compatible with Japanese
Let's make a web framework with Python! (1)
Make a desktop app with Python with Electron
Let's make a Twitter Bot with Python!
Let's make a web framework with Python! (2)
Make C compilation a little easier
[Lambda] Make import requests available [python]
Make SikuliX's click function easier to use
Tips to make Python here-documents easier to read
About import
Make pypy submission easier with atcoder-cli (python)
About import
FizzBuzz with Python3
Make Python scripts into Windows-executable .exes with Pyinstaller
Scraping with Python
Make a Twitter trend bot with heroku + Python
Statistics with python
Scraping with Python
Python with Go
Twilio with Python
Integrate with Python
Play with 2016-Python
Try to make a "cryptanalysis" cipher with Python
AES256 with python
Tested with Python
Make OpenCV3 available from python3 installed with pyenv
Make your own module quickly with setuptools (python)
python starts with ()
[Python] Make a simple maze game with Pyxel
with syntax (Python)
Let's replace UWSC with Python (5) Let's make a Robot
Bingo with python
Try to make a dihedral group with Python
Zundokokiyoshi with python
[Python] Expression (1,2) does not make tuples with parentheses
Make JSON into CSV with Python from Splunk
Make Python built with jhbuild work on OSX
Build PyPy and Python execution environment with Docker
Excel with Python
Make your Python environment "easy" with VS Code
Microcomputer with Python
[# 1] Make Minecraft with Python. ~ Preliminary research and design ~
Cast with python
Make one repeating string with a Python regular expression.
Try to make a command standby tool with python
Explain in detail how to make sounds with python
[Practice] Make a Watson app with Python! # 2 [Translation function]
[Practice] Make a Watson app with Python! # 1 [Language discrimination]
[Let's play with Python] Make a household account book
[# 2] Make Minecraft with Python. ~ Model drawing and player implementation ~
Let's make a simple game with Python 3 and iPhone
Make a breakpoint on the c layer with python
[AWS] Make friends with Lambda's JSON input (Python version)
Let's make dependency management with pip a little easier
Make a CSV formatting tool with Python Pandas PyInstaller