Skip to main content

A command-line tool for Kattis

Project description

Kattis-CLI

Kattis CLI - download, test and submit Kattis problems using CLI. Based on Official Kattis CLI: https://github.com/Kattis/kattis-cli

Requirements

  • Python 3.8+ (PyPy preferred as Kattis uses PyPy to run your code)
  • Kattis account

Windows

  • Use Command Line or PowerShell
  • Make sure python is in your PATH
    • Install Python from Windows Store
  • if you get codec error while running kattis-cli, run the following command in Command Prompt:
python --version
chcp 65001

Installation

If you've Python version 3.8 or higher, you can skip creating virtual environment. If you wish to create a virtual environment, see intructions below.

Create and activate virtual environment using venv

Create and activate virtual environment using conda

Install Kattis-cli

  • activate virtual environment if you've created one for kattis-cli
  • run the following command in Command Prompt or PowerShell
pip install kattis-cli
python -m pip install kattis-cli
  • on Windows add the path shown in the output of the above command to your PATH environment variable

Update Kattis-CLI

  • remove or rename .kattis-cli.toml file in your home directory
  • activate virtual environment if you've created one for kattis-cli
pip install kattis-cli --upgrade
python -m pip install kattis-cli --upgrade

Kattis configuration

  • run the following command and enter your Kattis credentials
  • this will create a .kattisrc file in your home directory
kattis setup

Usage

kattis <command> [options]
kattis --help

Commands

Download a problem sample files and it's metadata

Problem id

kattis get <problem_id>

Get problem id from URL

Display problem metadata

cd <problem_id>
kattis info

Problem info

Test a solution locally

  • currently the following languages have been tested: Python 3, C++, NodeJS, C, Java
  • make sure CLI compilers are in your PATH
  • make sure python3 files have first line shebang: !/usr/bin/env python3
    • or have extensions .py3
  • update the .kattis-cli.toml file in your home directory to add more languages
  • see kattis_cli/.kattis-cli.toml file for example.
cd <problem_id>
kattis test

Test

Submit a problem

  • make sure you've configured kattis-cli
kattis setup
  • see live results right on the terminal
cd <problem_id>
kattis submit

Result

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. Please make sure to update tests as appropriate. Adding support for more languages is highly appreciated.

Using this Repo

  • clone this repo
  • create virtual environment with pypy 3.8 or higher
  • using conda the following command creates kattis virtual environment with pypy3.8

Using conda and virtual environment

conda create -c conda-forge -n kattis pypy python=3.8
conda activate kattis
  • install dependencies
pip install -r requirements.txt
  • run the following command to install kattis-cli from this repo on Mac/Linux
make
./build.sh
pip install dist/kattis_cli-x.x.x-py3-none-any.whl --force-reinstall  

Using Docker

  • clone this repo
  • run the following command to build and run the Dockerfile provided in this repo
  • if using Windows, run the following command in git-bash Terminal
bash run.sh

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kattis_cli-1.0.1.tar.gz (19.0 kB view hashes)

Uploaded Source

Built Distribution

kattis_cli-1.0.1-py3-none-any.whl (22.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page