Kattis shell for getting examples, testing and submitting.

Related tags

Command-line ToolsKat
Overview

Kat - a command-line Kattis assistant

This is a command-line program for getting, testing, and submitting Kattis problem attempts!

Credit goes to Kattis and their python script for submitting files found here. Our submission script is heavily inspired by theirs.

Logo provided by @CptF1nn

Installing

  1. First of all, download this repository (either by .zip or via git) and make sure to extract it to a known location.
  2. Install dependencies by running python -m pip install -r requirements.txt inside the directory.
  3. Add the directory to your %PATH-variable on Windows or ln -s /path/to/kat/kattis.py /usr/bin/kat on Unix systems (Linux/Mac)
  4. To use most functionalities, add your personal configuration to this repository. Go to open.kattis.com > Help > How to submit > Download your personal configuration file and download the resulting file to this folder as .kattisrc.
  5. Run kattis startup to run an install-guide where Kat-internal configurations are copied into the .kattisrc and settings such as language are set up.

Usage

To get a list of commands and usage, use kattis --help and kattis [command] --help once installed.

Get

kattis get problem [problem ...]

This downloads the sample input-output files for the problem and creates a directory for the problem. Inside, the test files are put in the subfolder test, and an initial script file is waiting for your solution. To specify your language of choice for a single problem, use the command -l LANGUAGE. Happy hacking!

Test/watch

kattis test/watch problem [file]

test pipes every .in-file into the corresponding script, while recording the output. The output is compared to the corresponding .ans-files and supplied to a report, which tells you which tests failed and displaying failed output.

If multiple supported source files are present within the problem directory, you are prompted to choose one. Alternatively, you can supply the path to your chosen script as a second argument

If you use watch instead of test, then a file watcher is used on the primary script file, making the tests run when you save the file.

Submit

kattis submit problem [file]

This submits a given script to kattis for final judgement. Remember to get your configuration file from here.

If multiple supported source files are present within the problem directory, you are prompted to choose one. Alternatively, you can supply the path to your chosen script as a second argument.

Archive/Unarchive

kattis archive/unarchive problem [problem ...]

Move a problem (or several) between a ./.archive folder and the current folder.

List

kattis list [-p PAGE] [-l LIMIT] [-c] [sorting/filter [sorting/filter ...]]

List problems from the Kattis instance.

--compact shows only the names of the problems.

Possible sortings:

  • Leaving it out sorts problems alphabetically by display name
  • easiest sorts easiest problem first, by points
  • hardest sorts hardest problem first

If you add several filters, then they are used in a union style (unsolved solved would allow every problem again)

Possible filters:

  • unsolved allows any problem not solved, same as tried untried
  • solved allows any solved problem
  • tried allows problems tried before
  • untried allows problem never even tried before

Contest

kattis contest [-c CONTEST_URL] get [-s] [-o] [-l LANGUAGE]

Get all problems from a contest, optionally submitting already completed problems.

You can provide only the ID of a contest if you have the hostname in the config, otherwise the whole URL should be provided.

Read

kattis read [-c] problem [problem ...]

Read the problem descriptions in your browser.

--console prints the description in the console, but test cases and embedded LaTeX takes up a lot of space, making it hard to use.

Work

kattis work [-h] [-oafs] [sorting/filter [sorting/filter ...]]

This command initiates a loop where you can run commands by just typing their command, and where problems are automatically opened according to filters and sorting for the list command. You can specify arguments for submit and get to this command, which will be applied when running them in the loop.

Boilerplates

If you add a script file for your favourite language to the boilerplate folder, it is copied into every new problem you initialize with the get command. That way, you can quickly get started on solving problems.

Configuration

Once you have used almost any command once, configurations have appeared in your .kattisrc. The great part about them is that they are very extensible, allowing you to register additional languages and the like.

User

You probably wouldn't want to change the username or token fields manually, but here you can. These fields are the primary reason for getting the .kattisrc from the Kattis instance.

Kattis

This section contains information about which kattis instance you are currenctly using. If you want to change the hostname, you should either remove the other options (relying on known fallback-routes shared among Kattis instances) or replace the hostname in each.

Kat

The primary config options for the Kat tool, and the ones you would like to change the most often.

language designates the language used for creating the initial script file in the get command.

openfilecommand (WIP) designates a way to open a file after get or unarchive, letting you work just a bit faster on problems.

workcommand specifies which arguments you would want to call the work command with, since there are an awful lot of arguments possible.

File associations

Here, you can associate a file type with a specific language. This is used as the sole source of truth when determining language, so make sure it works with your Kattis instance before editing this config.

Initialize commands

These commands are used to initialize problem folders for languages which cannot use only script files. If you use a build system you would like to use for a language in Kattis, then here is where that command goes.

Run commands

These commands tell Kat how to run and test your submission attempt. Without a command for your language, the test and run commands do not work.

There are some indicators which are replaced when running the command:

  • @f is replaced with the file name
  • @c is replaced with the problem name

Compile commands

These commands tell Kat that script files should be compiled before being run.

See the section on Run commands above for info on indicators.

For C++ support it is required that a C++ compiler exists in PATH and is specified under [Compile commands] in your .kattisrc. By default the compiler used is g++.

Naming

Some languages, like Java, enforce a naming convention for their files. If any other language enforces capital first letter, then add it here.

Currently, only PascalCase is supported, create an issue or edit the namingSchemeConverters in helpers/fileUtils.py to add more cases.

Comments
  • Play sound crashes on windows, not sure why :)

    Play sound crashes on windows, not sure why :)

    Traceback (most recent call last):
      File "D:\.Projekter\Kat\kattis.py", line 41, in main
        execCommand[command](data)
      File "D:\.Projekter\Kat\commands\submit.py", line 81, in submitCommand
        winsound()
      File "D:\.Projekter\Kat\helpers\sound.py", line 8, in winsound
        playsound(random.choice(glob.glob(prefix + "/win/*.mp3")))
      File "C:\Users\mikke\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\playsound.py", line 72, in _playsoundWin
        winCommand(u'open {}'.format(sound))
      File "C:\Users\mikke\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\playsound.py", line 64, in winCommand
        raise PlaysoundException(exceptionMessage)
    playsound.PlaysoundException: 
        Error 305 for command:
            open "D:\.Projekter\Kat\helpers/../resources//win\win.mp3"
        Der kan ikke angives ekstra tegn efter en streng, som er omgivet af anførelsestegn.
    
    
    opened by MikkelNilsson 2
  • Test specific index case only

    Test specific index case only

    If for example a problem has many test cases baiscprogramming1 for example has a lot that take some time to go through.

    Testing the last sample with kattis test basicprogramming1 7 would make it immensely faster.

    This could even include testing only a range, 5-7 on basicprogramming1 for example.

    opened by CptF1nn 2
  • Add alternative to manually changing language

    Add alternative to manually changing language

    I have seperate folders that I use for Kattis written in Python, F# or Java. I would like to have the option to tell Kat what language the folder is for, and then just have that determine what language should be used

    enhancement 
    opened by Jakobis 2
  • Contest mode

    Contest mode

    To enter a contest: kat contest enter <contest-id> this makes future commands work against the contest url.

    when contest is done and you want to go back to normal mode: kat contest leave (perhaps with alias end)

    enhancement 
    opened by jlndk 2
  • Submit crashes when including slashes

    Submit crashes when including slashes

    Most commands, like archive and test, work fine if you tab to complete them, even though the command ends up looking like .\simplecronspec, but submit crashes.

    Traceback (most recent call last):
      File "C:\Users\Clipsterman\PycharmProjects\Kat\kattis.py", line 40, in main
        execCommand[command](data)
      File "C:\Users\Clipsterman\PycharmProjects\Kat\commands\submit.py", line 66, in submitCommand
        "📬 Submission Successful (url " + getConfigUrl("submissionsurl", "submissions") + "/" + id + ")"
    TypeError: can only concatenate str (not "int") to str
    
    
    opened by Jakobis 1
  • Exception:

    Exception: "can only concatenate str (not "NoneType") to str"

    Traceback (most recent call last):
      File "C:\Users\Clipsterman\PycharmProjects\Kat\kattis.py", line 40, in main
        execCommand[command](data)
      File "C:\Users\Clipsterman\PycharmProjects\Kat\commands\submit.py", line 81, in submitCommand
        losesound()
      File "C:\Users\Clipsterman\PycharmProjects\Kat\helpers\sound.py", line 12, in losesound
        playsound(playsound(random.choice(glob.glob(prefix + "/lose/*.mp3"))))
      File "C:\Users\Clipsterman\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\playsound.py", line 35, in _playsoundWin
        winCommand('open "' + sound + '" alias', alias)
    TypeError: can only concatenate str (not "NoneType") to str
    
    
    opened by Jakobis 1
  • Submission results from other Kattis instances (like itu.kattis.com) does not show up

    Submission results from other Kattis instances (like itu.kattis.com) does not show up

    Apparently, the mentioned instance does not use the checkmark sequence that open.kattis.com uses, so a different approach might be required to get the submission status.

    opened by Duckapple 1
  • Add flag to

    Add flag to "test" command for automatically submitting if it passes tests

    Sometimes, you're so sure of your code that you want to run kattis test and immediately submit the code if it passes the tests.

    I imagine it could look something like this: kattis test -s problemname

    And to circumvent the y/N on kattis submit, you could even have a force submit with: kattis test -fs problemname

    This might all be compressed into a single command (test-submit) instead of flags: kattis ts problemname

    enhancement 
    opened by CptF1nn 1
  • Rewrite in Rust

    Rewrite in Rust

    Let's just do it. Pros:

    • Binaries are faster
    • Rust is expandable
    • Rust is good to learn
    • I wanna do it, even if it means I'll do it on my own Cons:
    • There is a learning curve
    • Cloning the repository is not enough to run; building is required
      • Can be alleviated by releasing releases. CI would be required, and we should scope release types.
    opened by Duckapple 1
  • Stop test process if file doesn't compile

    Stop test process if file doesn't compile

    Testing a non-existent or previous version of a .class file i not helpful. It would be more helpful if the testing process ended after a compile error

    opened by poppyjones 1
  • Add unarchive command

    Add unarchive command

    Add a command that allows users to unarchive a certain problem.

    This would also be useful for work mode where getting to an archived problem tells you that you've already gotten a problem, but trying to test or submit it will give an error.

    opened by Jakobis 1
  • Exception:

    Exception: " Error 277 for command: open "C:\Users\jonas\AppData\Roaming\Kat\resources\win\win.mp3" alias playsound_0.3350055210840338 Der opstod et problem under initialisering af MCI."

    Traceback (most recent call last):
      File "C:\Users\jonas\AppData\Roaming\Kat\kattis.py", line 43, in main
        execCommand[command](data)
      File "C:\Users\jonas\AppData\Roaming\Kat\commands\submit.py", line 87, in submitCommand
        winsound()
      File "C:\Users\jonas\AppData\Roaming\Kat\helpers\sound.py", line 9, in winsound
        playsound(random.choice(glob.glob(os.path.join(prefix, "win", "*.mp3"))))
      File "C:\Users\jonas\AppData\Roaming\Python\Python310\site-packages\playsound.py", line 35, in _playsoundWin
        winCommand('open "' + sound + '" alias', alias)
      File "C:\Users\jonas\AppData\Roaming\Python\Python310\site-packages\playsound.py", line 31, in winCommand
        raise PlaysoundException(exceptionMessage)
    playsound.PlaysoundException: 
        Error 277 for command:
            open "C:\Users\jonas\AppData\Roaming\Kat\resources\win\win.mp3" alias playsound_0.3350055210840338
        Der opstod et problem under initialisering af MCI.
    
    
    opened by joglr 0
  • PermissionError:

    PermissionError: "[WinError 32] Processen kan ikke få adgang til filen, da den bruges af en anden proces: 'carrots'"

    Traceback (most recent call last):
      File "...\shutil.py", line 813, in move
        os.rename(src, real_dst)
    PermissionError: [WinError 32] Processen kan ikke få adgang til filen, da den bruges af en anden proces: 'carrots' -> '.solved/carrots'
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "...\Kat\kattis.py", line 41, in main
        execCommand[command](data)
      File "...\Kat\commands\submit.py", line 85, in submitCommand
        archive(problemName, ".solved/")
      File "...\Kat\commands\archive.py", line 30, in archive
        shutil.move(problemName, folder + problemName)
    PermissionError: [WinError 32] Processen kan ikke få adgang til filen, da den bruges af en anden proces: 'carrots'
    
    
    opened by MegetSkuffet 1
  • Extend config command

    Extend config command

    Make config command capable of

    • giving the location(s) of the read configs
    • giving the location of the one it saves to
    • get contents of individual options
    opened by Duckapple 0
  • Exception:

    Exception: "'utf-8' codec can't decode byte 0xe5 in position 23: invalid continuation byte"

    Can't handle special characters in print() statement, throws the above exception (I tried with the Danish 'å' letter.)

    In addition, at submission, because of the issue, it replaces the special characters with others, producing a 'Wrong answer' result.

    Traceback (most recent call last):
      File "C:\Users\path\to\Kat-master\kattis.py", line 40, in main
        execCommand[command](data)
      File "C:\Users\path\to\Kat-master\commands\test.py", line 57, in testCommand
        result, time = runSingleTest(command, directory, inF, ansF)
      File "C:\Users\path\to\Kat-master\commands\test.py", line 107, in runSingleTest
        subprocess.run(command, stdout=subprocess.PIPE, input=inp, cwd=directory)
    UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe5 in position 23: invalid continuation byte
    
    
    opened by Navarot 3
Releases(1.9.0)
  • 1.9.0(Feb 7, 2022)

    Changelog:

    • Added switch command: Allows you to switch between config files for different instances
      • (Currently only works for configs in the same folder)
    • Added more cases for exiting after submission (Thanks @marfavi!)
    • Added Rust support
    • Added Go support
    • Fixed Rust support
    • Fixed lack of feedback when problem is already active with get command
    • Fixed autocomplete for problem names on Windows (Thanks @jakobis!)
    • Bumped packages (Thanks @jakobis!)
    Source code(tar.gz)
    Source code(zip)
    install_mac.sh(949 bytes)
    install_windows.bat(1.32 KB)
  • 1.8.0(Mar 30, 2021)

    Changelog:

    • Made the config make use of the openfilecommand option under [kat]. When defined, get command automatically invokes this function in order to open the problem in your editor of choice. I use Visual Studio Code, and thus my command is code -r @d, which opens the problem source file in my currently open editor. An alternative would be code @p if you want to open the problem folder.
    • Made .out files work like .ans files
    • Fixed boilterplate not getting copied
    • Removed the stacktrace from terminating tests with ctrl+c
    • Added feedback to contest get for when the contest hasn't begun
      • Also added feedback for when it is over.

    On an organizational note: I think I'll start using releases as a way to keep info about changes in this form instead of in commit history, which only I really look at.

    Source code(tar.gz)
    Source code(zip)
Owner
Simon Green Kristensen
Simon Green Kristensen
ghfetch is ai customizable CLI GitHub personal README generator.

ghfetch is ai customizable CLI GitHub personal README generator. Inspired by famous fetch such as screenfetch, neofetch and ufetch, the purpose of this tool is to introduce yourself as if you were a

Alessio Celentano 3 Sep 10, 2021
A Python module and command line utility for working with web archive data using the WACZ format specification

py-wacz The py-wacz repository contains a Python module and command line utility for working with web archive data using the WACZ format specification

Webrecorder 14 Oct 24, 2022
Calculator for CLI. Made with Python

Calculator for CLI. Made with Python

Brandon Arreguin 2 Jan 07, 2022
vimBrain is a brainfuck-based vim-inspired esoteric programming language.

vimBrain vimBrain is a brainfuck-based vim-inspired esoteric programming language. vimBrainPy Currently, the only interpreter available is written in

SalahDin Ahmed 3 May 08, 2022
A webmining CLI tool & library for python.

minet is a webmining command line tool & library for python (= 3.6) that can be used to collect and extract data from a large variety of web sources

médialab Sciences Po 165 Dec 17, 2022
A terminal written in Python.

PyDOS Read the title and then you'll figure out what this actually is. Running First, download or clone this repo. Next, run run.py. After this, you c

TechStudent10 2 Mar 01, 2022
Python CLI for accessing CSCI320 PDM Database

p320_14 Python CLI for accessing CSCI320 PDM Database Authors: Aidan Mellin Dan Skigen Jacob Auger Kyle Baptiste Before running the application for th

Aidan Mellin 1 Nov 23, 2021
The project help you to quickly build layouts in terminal,cross-platform

The project help you to quickly build layouts in terminal,cross-platform

gojuukaze 133 Nov 30, 2022
Fun project to generate The Matrix Code effect on you terminal.

Fun project to generate The Matrix Code effect on you terminal.

Henrique Bastos 11 Jul 13, 2022
A command line tool to create a graph representing your Ansible playbook tasks and roles

Ansible Playbook Grapher ansible-playbook-grapher is a command line tool to create a graph representing your Ansible playbook plays, tasks and roles.

Mohamed El Mouctar Haidara 424 Dec 20, 2022
A simple reverse shell in python

RevShell A simple reverse shell in python Getting started First, start the server python server.py Finally, start the client (victim) python client.py

Lojacopsen 4 Apr 06, 2022
Command-line program for organizing and managing ebook collections

Command-line program for organizing and managing ebook collections. It is a Python port from the original shell scripts ebook-tools

Raul 14 Nov 12, 2022
WazirX Portfolio Tracker on your Terminal!

If you have been investing in crypto in India, there is a very good chance that you are using WazirX. If you are using WazirX, then you definitely know that there is no P&L report, no green arrows no

Raunit 15 Jan 10, 2022
Command line interface for testing internet bandwidth using speedtest.net

speedtest-cli Command line interface for testing internet bandwidth using speedtest.net Versions speedtest-cli works with Python 2.4-3.7 Installation

Matt Martz 12.4k Jan 08, 2023
A simple command line tool written in python to manage a to-do list

A simple command line tool written in python to manage a to-do list Dependencies: python Commands: todolist (-a | --add) [(-p | --priority)] [(-l | --

edwloef 0 Nov 02, 2021
Task-manager-CLI with Priority Modification

Task-manager-CLI with Priority Modification The functions for the app have been written in task.py file. 1. Install Node.js This project requires Node

1 Jan 21, 2022
Tmux Based Dropdown Dashboard For Python

sextans It's a private configuration and an ongoing experiment while I use Archlinux. A simple drop down dashboard based on tmux. It includes followin

秋葉 4 Dec 22, 2021
Customisable pharmacokinetic model accessible via bash CLI allowing for variable dose calculations as well as intravenous and subcutaneous administration calculations

Pharmacokinetic Modelling Group Project A PharmacoKinetic (PK) modelling function for analysis of injected solute dynamics over time, developed by Gro

1 Oct 24, 2021
liquidctl – liquid cooler control Cross-platform tool and drivers for liquid coolers and other devices

Cross-platform CLI and Python drivers for AIO liquid coolers and other devices

1.7k Jan 08, 2023
Display Images in your terminal with python

A python library to display images in the terminal

Pranav Baburaj 57 Dec 30, 2022