Skip to main content

Kattis-CLI

Kattis CLI - download, test and submit Kattis problems using CLI or TUI. Inspired by the official Kattis CLI: https://github.com/Kattis/kattis-cli

Tests PyPI version PyPI - Downloads PyPI - License

Quick Tour of Kattis-CLI

Kattis-CLI

Requirements

  • Python 3.8+ (PyPy preferred as Kattis uses PyPy to run your Python3 solutions)
  • 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
kattis --version
  • on Windows add the path shown in the output of the above command to your PATH environment variable

Update/Upgrade Kattis-CLI

  • remove or rename .kattis-cli.toml file in your home directory
  • activate virtual environment if you've created one for kattis-cli
kattis --version
pip install kattis-cli --upgrade
python -m pip install kattis-cli --upgrade
  • on Windows add the path shown in the output of the above command to your PATH environment variable

Kattis configuration

  • run the following command and enter your Kattis credentials
  • follow the instructions provided in the terminal
kattis setup

Manual Configuration

  • see SETUP.md for detailed instructions to setup kattis-cli

Usage

kattis <command> [options]
kattis --help
kattis tui # get into text user interface mode

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

Creating project template

  • create project template files for a given programming language
  • src style default templates are created in the home directory under .kattis-templates folder
  • you can overwrite/create new templates following the structure provided kattis_templates
  • local languages codes supported are:
    • python3
    • c++
    • java
    • c
    • nodejs
kattis template --help
# create python3 project template for cold problem
kattis template -l python3 -p cold -s

Test a solution locally

Test

  • 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 # for exact comparison of answers (works with string and int)
kattis test -a 6 # Answer accepted upto 6 decimal places of accuracy

Testing floating point results

  • for floating point ouput, problem provides the tolerance or accuracy upto certain decimal points
  • one can use -a <N> switch after kattis test command to provide the decimal places of accuracy
  • e.g., the following command checks for accuracy upto 6 decimal points or absolute error upto $10^-6$
kattis test -a 6

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
git clone git@github.com:rambasnet/kattis-cli.git
cd kattis-cli
pip install poetry
poetry install

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
docker-compose up -d
docker exec -it kattis-cli zsh

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.2.8.tar.gz (28.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kattis_cli-1.2.8-py3-none-any.whl (38.8 kB view details)

Uploaded Python 3

File details

Details for the file kattis_cli-1.2.8.tar.gz.

File metadata

  • Download URL: kattis_cli-1.2.8.tar.gz
  • Upload date:
  • Size: 28.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 PyPy/7.3.20 Linux/6.10.14-linuxkit

File hashes

Hashes for kattis_cli-1.2.8.tar.gz
Algorithm Hash digest
SHA256 9f02f0d035f675595e548a7680d240fd50d16977f9c25c1e8bdff6a0d875c268
MD5 f8f9ed53dd340c3fcc9191e008f29169
BLAKE2b-256 c6df69405b16302f9b67389046ad26607ac49a78e2ace75dac0161660d98a318

See more details on using hashes here.

File details

Details for the file kattis_cli-1.2.8-py3-none-any.whl.

File metadata

  • Download URL: kattis_cli-1.2.8-py3-none-any.whl
  • Upload date:
  • Size: 38.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 PyPy/7.3.20 Linux/6.10.14-linuxkit

File hashes

Hashes for kattis_cli-1.2.8-py3-none-any.whl
Algorithm Hash digest
SHA256 5ba774dddbe353e44bf1e3410f021e5a84269e72ffb7c9c7d2f70ffae32c0cd4
MD5 3730477937751403893610ca6ecf50e3
BLAKE2b-256 08356cd0b301a299d02dd36fcba6bfe58e6c347f5811f485b5020678d6561490

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.2.8 This release

2 files

1.2.7

2 files

1.2.6

2 files

1.2.5

2 files

1.2.4

2 files

1.2.3

2 files

1.2.2

2 files

1.2.1

2 files

1.2.0

2 files

1.1.2

2 files

1.1.1

2 files

1.1.0

2 files

1.0.7

2 files

1.0.6

2 files

1.0.5

2 files

1.0.4

2 files

1.0.3

2 files

1.0.2

2 files

1.0.1

2 files

1.0.0

2 files

0.1.17

2 files

0.1.16

2 files

0.1.15

2 files

0.1.14

2 files

0.1.13

2 files

0.1.12

2 files

0.1.11

2 files

0.1.10

2 files

0.1.9

2 files

0.1.8

2 files

0.1.7

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

3 files

0.1.0

3 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page