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
CLI tool to show the current crypto balance

CryptoBoard The simple python CLI tool for one currency to show the current crypto balance yours purchases. That's all. Data source is from https://ww

John 2 Nov 18, 2021
Simple CLI prompt for easy I/O with OpenAI's API

openai-cli-prompt Simple CLI prompt for easy I/O with OpenAI's API Quickstart Create a .env file with: OPENAI_API_KEY=Your OpenAI API Key Configure

Erik Nomitch 1 Oct 12, 2021
Autosub - Command-line utility for auto-generating subtitles for any video file

Auto-generated subtitles for any video Autosub is a utility for automatic speech recognition and subtitle generation. It takes a video or an a

Anastasis Germanidis 3.9k Jan 05, 2023
PyWordle: A Python-made wordle manual solver

PyWordle: A Python-made wordle manual solver How to use it Start the program with python3 pywordlesolver.py. How it works The program has a simple 5-l

Federico Torrielli 5 Nov 24, 2022
cli simple python script to interact with iphone afc api based on python library( tidevice )

afcclient cli simple python script to interact with iphone afc api based on python library( tidevice ) installation pip3 install -U tidevice cp afccli

fyst_14 2 Jul 15, 2022
pyGinit is a command line tools that help you to initialize your current project a local git repo and remote repo

pyGinit pyGinit is a command line tools that help you to initialize your current project a local git repo and remote repo Requirements Requirements be

AlphaBeta 15 Feb 26, 2022
Terminal-based keyboard testing

kbdtest kbdtest is a simple Python program that tests keyboard input using an interactive, terminal-based, visual keyboard display. It was originally

Ruunyox 12 Jul 19, 2022
A minimalist Vim plugin manager.

A minimalist Vim plugin manager. Pros. Easy to set up: Single file. No boilerplate code required. Easy to use: Concise, intuitive syntax Super-fast pa

Junegunn Choi 30.2k Jan 08, 2023
Proman is a simple tool for managing projects through cli.

proman proman is a project manager. It helps you manage your projects from a terminal. The features are listed below. Installation Step 1: Download or

Arjun Somvanshi 2 Dec 06, 2021
A user-friendly python CLI for Fmask 4.3 software (GERS Lab, UCONN).

pyFmask What is pyFmask pyFmask is a user-friendly python CLI for Fmask 4.3 software (GERS Lab, UCONN; https://github.com/GERSL/Fmask). Fmask (Zhu et

1 Jan 05, 2022
Code for "Salient Deconvolutional Networks, Aravindh Mahendran, Andrea Vedaldi, ECCV 2016"

deconvnet_analysis Code for "Salient Deconvolutional Networks, Aravindh Mahendran, Andrea Vedaldi, ECCV 2016" Parts of this code Generate figures in t

Aravindh Mahendran 12 Jan 25, 2021
The WalletsNet CLI helps you connect to WalletsNet

WalletsNet CLI The WalletsNet CLI helps you connect to WalletsNet. With the CLI, you can: Trigger webhook events or resend events for easy testing Tai

WalletsClub 8 Dec 22, 2021
argofloats: Simple CLI for ArgoVis and Argofloats

argofloats: Simple CLI for ArgoVis and Argofloats Argo is an international program that collects information from inside the ocean using a fleet of ro

Samapriya Roy 2 Feb 13, 2022
Hack-All is a simple CLI tool that helps ethical-hackers to make a reverse connection without knowing the target device in use is it computer or phone

Hack-All is a simple CLI tool that helps ethical-hackers to make a reverse connection without knowing the target device in use is it computer

LightYagami17 5 Nov 22, 2022
A simple command line dumper written in Python 3.

A simple command line dumper written in Python 3.

ImFatF1sh 1 Oct 10, 2021
pypinfo is a simple CLI to access PyPI download statistics via Google's BigQuery.

pypinfo: View PyPI download statistics with ease. pypinfo is a simple CLI to access PyPI download statistics via Google's BigQuery. Installation pypin

Ofek Lev 351 Dec 26, 2022
Command line client for Audience Insights

Dynamics 365 Audience Insights CLI The AuI CLI is a command line tool for Dynamics 365 Audience Insights. It is based on the customerinsights Python l

Microsoft 8 Jan 09, 2023
A very simple python script to encode and decode PowerShell one-liners.

PowerShell Encoder A very simple python script to encode and decode PowerShell one-liners. I used Raikia's PowerShell encoder ALOT, but one day it wen

John Tear 5 Jul 29, 2022
A command-line tool to upload local files and pastebin pastes to your mega account, without signing in anywhere

A command-line tool to upload local files and pastebin pastes to your mega account, without signing in anywhere

ADI 4 Nov 17, 2022
Shellmon is a tool used to create and control a webshell remotely, created using the Python3

An Simple PHP Webshell Manager Description Shellmon is a tool used to create and control a webshell remotely, created using the Python3 programming la

22XploiterCrew 12 Dec 30, 2022