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
command line interface to manage VALORANT skins

A PROPER RELEASE IS COMING SOON, IF YOU KNOW HOW TO USE PYTHON YOU CAN USE IT NOW! valorant skin manager command line interface simple command line in

colinh 131 Dec 25, 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
Konsave lets use save your KDE Plasma customizatios and restore them very easily!

Konsave (Save Plasma Customization) A CLI program that will let you save and apply your KDE Plasma customizations with just one command! Als

439 Jan 02, 2023
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 Python script to generate blog banners from command line.

Auto Blog Banner Generator A Python script to generate blog banners. This script is used at RavSam. The following image is an example of the blog bann

RavSam 10 Sep 20, 2022
A very simple and lightweight ToDo app using python that can be used from the command line

A very simple and lightweight ToDo app using python that can be used from the command line

Nilesh Sengupta 2 Jul 20, 2022
Squirrel - A cli program to track writing progress

Squirrel Very much a WIP project squirrel is a command line program that tracks you writing progress and gives you useful information and cute and pic

3 Mar 23, 2022
Jupyter notebook client in neovim

🪐 Jupyter-Nvim Read jupyter notebooks in neovim Note: The plugin is still in alpha stage 👾 Usage Just open any *.ipynb file and voila! ✨ Contributin

Ahmed Khalf 85 Dec 29, 2022
Generate your name in Ascii modular type art through the terminal

ASCII Name Generator Designed and developed by Eduardo Aire The ASCII Art Name Generator is a simple program that helps you to have a practical Shell/

Eduardo Aire 1 Nov 17, 2021
A VIM-inspired filemanager for the console

ranger 1.9.3 ranger is a console file manager with VI key bindings. It provides a minimalistic and nice curses interface with a view on the directory

12.6k Dec 30, 2022
Convert shellcode generated using pe_2_shellcode to cdb format.

pe2shc-to-cdb This tool will convert shellcode generated using pe_to_shellcode to cdb format. Cdb.exe is a LOLBIN which can help evade detection & app

mrd0x 75 Jan 05, 2023
googler is a power tool to Google (web, news, videos and site search) from the command-line.

googler is a power tool to Google (web, news, videos and site search) from the command-line.

Terminator X 5.9k Jan 04, 2023
A command line connect 4 game against a minimax agent.

A command line connect 4 game against a minimax agent.

1 Oct 17, 2021
Standalone script written in Python 3 for generating Reverse Shell one liner snippets and handles the communication between target and client using custom Netcat binaries

Standalone script written in Python 3 for generating Reverse Shell one liner snippets and handles the communication between target and client using custom Netcat binaries. It automates the boring stu

Yash Bhardwaj 3 Sep 27, 2022
Interactive Python interpreter for executing commands within Node.js

Python Interactive Interactive Python interpreter for executing commands within Node.js. This module provides a means of using the Python interactive

Louis Lefevre 2 Sep 21, 2022
A command line interface to buy things in stregsystemet

Stregsystemet-CLI This repository is the Stregsystemet CLI, to buy things in Stregsystemet, at AAU. Use of this cli-tool is at your own risk and there

F-klubben 14 Oct 18, 2022
Tools hacking termux in the name ant-attack

Hello friends, I am ama.player0000. Web developer, software, Android command line (termux). (1)=Well, ant-attack tool is a tool to attack sites and disable them. (2)=You can use those CCTV servers, s

༺AMA.PLAYER༻ 1 Dec 17, 2021
keep your machine's shell history synchronize

SyncShell Yet another tool for laziness Keep your machine's shell history synchronize Get SyncShell Currently, SyncShell is just available on PyPi and

Masoud Ghorbani 53 Dec 12, 2022
A simple terminal-based localhost chat application written in python

Chat House A simple terminal-based localhost chat application written in python How to Use? Clone the repo git clone https://github.com/heksadecimal/c

Heks 10 Nov 09, 2021
My dotfiles -My configuration, with installations steps.

.dotfiles My configuration, with installations steps. Installation Oh My ZSH Install with this command: sh -c "$(curl -fsSL https://raw.githubusercont

Luca Angioloni 4 Dec 14, 2022