Skip to content

olemp/kattis-ts

Repository files navigation

Kattis with TypeScript and vscode

This repository includes custom tools for submitting TypeScript solutions to Kattis. The TypeScript support consists of:

Scripts and Utilities

submit.py

The submit.py script is the core utility for submitting solutions to Kattis. It handles:

  • Detecting the programming language based on file extension
  • Guessing the problem ID from the filename
  • Authenticating with Kattis using your .kattisrc configuration
  • Submitting solution files
  • Displaying submission results

This script supports multiple programming languages, including TypeScript (.ts files).

kattis_submit_ts.sh

The kattis_submit_ts.sh is a bash script that streamlines the submission of TypeScript solutions:

  • Takes a TypeScript (.ts) file as an argument
  • Activates a Python virtual environment
  • Extracts the problem ID from the filename
  • Submits the TypeScript file directly to Kattis through submit.py

Usage:

./kattis_submit_ts.sh problems/hello.ts

Configuration

Kattis Authentication

Before you can submit solutions, you need to set up authentication with Kattis:

  1. Download your personal .kattisrc configuration file from https://open.kattis.com/download/kattisrc
  2. Place this file in your home directory (~/.kattisrc) or in the same directory as submit.py

The .kattisrc file contains:

  • Your Kattis username
  • A secret token for authentication
  • URLs for the Kattis API

This file is essential for the submission scripts to authenticate with Kattis. Without it, you won't be able to submit solutions.

VS Code Integration

This repository includes VS Code task configuration to make submitting TypeScript solutions even easier.

Submit to Kattis Task

The .vscode/tasks.json file configures a "Submit to Kattis" task that:

  • Is accessible through VS Code's Command Palette (Tasks: Run Task)
  • Takes the currently active file as input
  • Runs the kattis_submit_ts.sh script with the current file as an argument
  • Shows the submission process and results in a dedicated terminal panel

To use this task:

  1. Open your TypeScript solution file in VS Code
  2. Press Cmd+Shift+P (macOS) or Ctrl+Shift+P (Windows/Linux)
  3. Type "Tasks: Run Task" and select it
  4. Choose "Submit to Kattis"

This will submit your currently open TypeScript file to Kattis and show the results.

Setting Up TypeScript

To set up your environment for TypeScript development:

  1. Ensure you have Node.js installed
  2. Install TypeScript-related dependencies:
    npm install
  3. Create a Python virtual environment (for the submission scripts):
    python -m venv venv
    source venv/bin/activate
    pip install requests requests
    pip install requests lxml

Now you can write TypeScript solutions in the problems/ directory and submit them using the VS Code task or the command-line script.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published