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
tox-server is a command line tool which runs tox in a loop and calls it with commands from a remote CLI.

Tox Server tox-server is a command line tool which runs tox in a loop and calls it with commands from a remote CLI. It responds to commands via ZeroMQ

Alexander Rudy 3 Jan 10, 2022
Palm CLI - the tool-belt for data teams

Palm CLI: The extensible CLI at your fingertips Palm is a universal CLI developed to improve the life and work of data professionals. Palm CLI documen

Palmetto 41 Dec 12, 2022
Several tools that can be added to your `PATH` to make your life easier.

CK-CLI Tools Several tools that can be added to your PATH to make your life easier. prettypath Prints the $PATH variable in a human-readable way. It a

Christopher Kumm 2 Apr 21, 2022
A Python package for a basic CLI and GUI user interface

Organizer CLI Organizer CLI is a python command line tool that goes through a given directory and organizes all un-folder bound files into folders by

Caltech Library 12 Mar 25, 2022
A mini command line tool to spellcheck text files using tadqeek.alsharekh.org

tadqeek_sakhr A mini command line tool to spellcheck text files using tadqeek.alsharekh.org Usage usage: python tadqeek_sakhr.py [-h] -i INPUT [-o OUT

Youssif Shaaban Alsager 5 Dec 11, 2022
Pynavt is a cli tool to create clean architecture app for you including Fastapi, bcrypt and jwt.

Pynavt _____ _ | __ \ | | | |__) | _ _ __ __ ___ _| |_ | ___/ | | | '_ \ / _` \ \ / /

Alejandro Castillo 1 Dec 13, 2021
A command line tool to hide and reveal information inside images (works for both PNGs and JPGs)

Imgrerite A command line tool to hide and reveal information inside images (works for both PNGs and JPGs) Dependencies Python 3 Git Most of the Linux

Jigyasu 10 Jul 27, 2022
Python-based implementation and comparison of strategies to guess words at Wordle

Solver and comparison of strategies for Wordle Motivation The goal of this repository is to compare, in terms of performance, strategies that minimize

Ignacio L. Ibarra 4 Feb 16, 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
Get Air Quality Index for your city/country 😷

Air Quality Index CLI Get Air Quality index for your City. Installation $ pip install air-quality-cli Contents Air Quality Index CLI Installation Cont

Yankee 40 Oct 21, 2022
Python codecs extension featuring CLI tools for encoding/decoding anything

CodExt Encode/decode anything. This library extends the native codecs library (namely for adding new custom encodings and character mappings) and prov

Alex 210 Dec 30, 2022
inklayers is a command line program that exports layers from an SVG file.

inklayers is a command line program that exports layers from an SVG file. It can be used to create slide shows by editing a single SVG file.

11 Mar 29, 2022
CLI tool for typescript tasks & migrations

typed CLI tool for typescript tasks & migrations Installation Usage $ typed --list Subcommands: bootstrap 🔨 Bootstrap your environment for TypeS

Lob 1 Nov 15, 2021
This is the public repo for the VS Code Extension AT&T i386/IA32 UIUC-ECE391 Syntax Highlighting

AT&T i386 IA32 UIUC ECE391 GCC Highlighter & Snippet & Linter This is the VS Code Extension for UIUC ECE 391, MIT 6.828, and all other AT&T-based i386

Jackgetup 1 Feb 05, 2022
instant coding answers via the command line

howdoi instant coding answers via the command line Sherlock, your neighborhood command-line sloth sleuth. Are you a hack programmer? Do you find yours

Benjamin Gleitzman 9.8k Jan 08, 2023
🔖 Lemnos: A simple, light-weight command-line to-do list manager.

🔖 Lemnos: CLI To-do List Manager This is a simple program that allows one to manage a to-do list via the command-line. Example $ python3 todo.py add

Rohan Sikand 1 Dec 07, 2022
Bear-Shell is a shell based in the terminal or command prompt.

Bear-Shell is a shell based in the terminal or command prompt. You can navigate files, run python files, create files via the BearUtils text editor, and a lot more coming up!

MichaelBear 6 Dec 25, 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
organize your books on the command line

organize your books on the command line

Ben Winston 19 Jan 21, 2022
Cthulhu is a simple python CLI application that streams torrents directly from 1337x.

Cthulhu is a simple python CLI application that facilitates the streaming of torrents directly from 1337x. It uses webtorrent to stream video

Raiyan 27 Dec 27, 2022